新增桌面歌词字体设置

This commit is contained in:
lyswhut
2021-08-29 18:27:01 +08:00
parent 1da275ff3a
commit 3fdf7411fc
20 changed files with 94 additions and 11 deletions
+2 -1
View File
@@ -2,7 +2,7 @@ const path = require('path')
const os = require('os')
const defaultSetting = {
version: '1.0.44',
version: '1.0.45',
player: {
togglePlayMethod: 'listLoop',
highQuality: false,
@@ -26,6 +26,7 @@ const defaultSetting = {
theme: 0,
isLockScreen: true,
style: {
font: '',
fontSize: 120,
opacity: 95,
isZoomActiveLrc: true,
+1
View File
@@ -22,6 +22,7 @@ const names = {
set_app_setting: 'set_app_setting',
set_window_size: 'set_window_size',
show_save_dialog: 'show_save_dialog',
get_system_fonts: 'get_system_fonts',
handle_request: 'handle_request',
cancel_request: 'cancel_request',
+1
View File
@@ -19,6 +19,7 @@ require('./playList')
require('./data')
require('./lyric')
require('./musicUrl')
require('./systemFonts')
require('./kw_decodeLyric')
+5
View File
@@ -0,0 +1,5 @@
const { mainHandle, NAMES: { mainWindow: ipcMainWindowNames } } = require('@common/ipc')
const { getFonts } = require('@main/utils/fontManage')
mainHandle(ipcMainWindowNames.get_system_fonts, getFonts)
+9
View File
@@ -0,0 +1,9 @@
// const { getAvailableFontFamilies } = require('electron-font-manager')
// exports.getAvailableFontFamilies = getAvailableFontFamilies
const fontList = require('font-list')
exports.getFonts = fontList.getFonts
+1
View File
@@ -39,6 +39,7 @@ export default {
y: -1,
theme: 0,
style: {
font: '',
fontSize: 125,
opacity: 80,
isZoomActiveLrc: true,
@@ -21,6 +21,7 @@ export default {
default() {
return {
style: {
font: '',
fontSize: 125,
opacity: 80,
isZoomActiveLrc: true,
@@ -77,6 +78,7 @@ export default {
computed: {
lrcStyles() {
return {
fontFamily: this.lrcConfig.style.font,
fontSize: this.lrcConfig.style.fontSize / 100 + 'rem',
opacity: this.lrcConfig.style.opacity / 100,
}
+1 -1
View File
@@ -288,7 +288,7 @@ export default {
})
rendererOn(NAMES.mainWindow.set_config, (event, config) => {
console.log(config)
// console.log(config)
// this.setDesktopLyricConfig(config)
// console.log('set_config', JSON.stringify(this.setting) === JSON.stringify(config))
this.setSetting(Object.assign({}, this.setting, config))
@@ -45,8 +45,8 @@ export default {
},
computed: {
label() {
if (!this.value) return ''
if (!this.itemName) return this.value
if (this.value == null) return ''
if (this.itemName == null) return this.value
const item = this.list.find(l => l[this.itemKey] == this.value)
if (!item) return ''
return item[this.itemName]
@@ -51,6 +51,8 @@
"desktop_lyric": "Desktop Lyric Settings",
"desktop_lyric_always_on_top": "Make the lyrics always above other windows",
"desktop_lyric_enable": "Display lyrics",
"desktop_lyric_font": "Lyric font",
"desktop_lyric_font_default": "Default",
"desktop_lyric_lock": "Lock lyrics",
"desktop_lyric_lock_screen": "It is not allowed to drag the lyrics window out of the main screen",
"download": "Download",
@@ -51,6 +51,8 @@
"desktop_lyric": "桌面歌词设置",
"desktop_lyric_always_on_top": "使歌词总是在其他窗口之上",
"desktop_lyric_enable": "显示歌词",
"desktop_lyric_font": "歌词字体",
"desktop_lyric_font_default": "默认",
"desktop_lyric_lock": "锁定歌词",
"desktop_lyric_lock_screen": "不允许歌词窗口拖出主屏幕之外",
"download": "下载设置",
@@ -51,6 +51,8 @@
"desktop_lyric": "桌面歌詞設置",
"desktop_lyric_always_on_top": "使歌詞總是在其他窗口之上",
"desktop_lyric_enable": "顯示歌詞",
"desktop_lyric_font": "歌詞字體",
"desktop_lyric_font_default": "默認",
"desktop_lyric_lock": "鎖定歌詞",
"desktop_lyric_lock_screen": "不允許歌詞窗口拖出主屏幕之外",
"download": "下載設置",
+17
View File
@@ -91,6 +91,10 @@ div(:class="$style.main")
material-checkbox(id="setting_desktop_lyric_alwaysOnTop" v-model="current_setting.desktopLyric.isAlwaysOnTop" :label="$t('view.setting.desktop_lyric_always_on_top')")
div(:class="$style.gapTop")
material-checkbox(id="setting_desktop_lyric_lockScreen" v-model="current_setting.desktopLyric.isLockScreen" :label="$t('view.setting.desktop_lyric_lock_screen')")
dd
h3#desktop_lyric_font {{$t('view.setting.desktop_lyric_font')}}
div
material-selection(:list="fontList" :class="$style.gapLeft" v-model="current_setting.desktopLyric.style.font" item-key="id" item-name="label")
dt#search {{$t('view.setting.search')}}
dd
@@ -468,6 +472,9 @@ export default {
? this.sync.status.devices.map(d => `${d.deviceName} (${d.clientId.substring(0, 5)})`).join(', ')
: ''
},
fontList() {
return [{ id: '', label: this.$t('view.setting.desktop_lyric_font_default') }, ...this.systemFontList]
},
},
data() {
return {
@@ -489,6 +496,7 @@ export default {
y: -1,
theme: '',
style: {
font: '',
fontSize: 125,
opacity: 80,
isZoomActiveLrc: true,
@@ -680,6 +688,7 @@ export default {
devices: [],
},
},
systemFontList: [],
}
},
watch: {
@@ -753,6 +762,7 @@ export default {
if (!window.currentWindowSizeId) window.currentWindowSizeId = this.setting.windowSizeId
// this.initTOC()
this.getCacheSize()
this.getSystemFonts()
this.getMediaDevice()
this.current_hot_key = window.appHotKeyConfig
this.initHotKeyConfig()
@@ -1261,6 +1271,13 @@ export default {
handleRefreshSyncCode() {
rendererInvoke(NAMES.mainWindow.sync_generate_code)
},
getSystemFonts() {
rendererInvoke(NAMES.mainWindow.get_system_fonts).then(fonts => {
this.systemFontList = fonts.map(f => ({ id: f, label: f.replace(/(^"|"$)/g, '') }))
}).catch(() => {
this.systemFontList = []
})
},
},
}
</script>