新增设置-桌面歌词设置-重置窗口设置功能
parent
ea515fdd85
commit
ec6e067938
|
@ -8,6 +8,7 @@
|
|||
|
||||
- 重构数据同步功能,新增客户端模式
|
||||
- 新增全屏时自动关闭歌词设置,默认开启,可以去设置-桌面歌词设置更改
|
||||
- 新增设置-桌面歌词设置-重置窗口设置功能,点击时会重置桌面歌词窗口大小及位置
|
||||
|
||||
### 优化
|
||||
|
||||
|
|
|
@ -327,6 +327,8 @@
|
|||
"setting__desktop_lyric_lock": "Lock lyrics",
|
||||
"setting__desktop_lyric_lock_screen": "It is not allowed to drag the lyrics window out of the main screen",
|
||||
"setting__desktop_lyric_played_color": "color played",
|
||||
"setting__desktop_lyric_reset": "Reset",
|
||||
"setting__desktop_lyric_reset_window": "Reset window settings",
|
||||
"setting__desktop_lyric_scroll_align": "now playing lyrics scroll position",
|
||||
"setting__desktop_lyric_scroll_align_center": "Center",
|
||||
"setting__desktop_lyric_scroll_align_top": "Top",
|
||||
|
|
|
@ -329,6 +329,8 @@
|
|||
"setting__desktop_lyric_lock": "锁定歌词",
|
||||
"setting__desktop_lyric_lock_screen": "不允许歌词窗口拖出主屏幕之外",
|
||||
"setting__desktop_lyric_played_color": "已播放颜色",
|
||||
"setting__desktop_lyric_reset": "重置",
|
||||
"setting__desktop_lyric_reset_window": "重置窗口设置",
|
||||
"setting__desktop_lyric_scroll_align": "正在播放歌词滚动位置",
|
||||
"setting__desktop_lyric_scroll_align_center": "中心",
|
||||
"setting__desktop_lyric_scroll_align_top": "顶部",
|
||||
|
|
|
@ -328,6 +328,8 @@
|
|||
"setting__desktop_lyric_lock": "鎖定歌詞",
|
||||
"setting__desktop_lyric_lock_screen": "不允許歌詞窗口拖出主屏幕之外",
|
||||
"setting__desktop_lyric_played_color": "已播放顏色",
|
||||
"setting__desktop_lyric_reset": "重置",
|
||||
"setting__desktop_lyric_reset_window": "重置窗口設置",
|
||||
"setting__desktop_lyric_scroll_align": "正在播放歌詞滾動位置",
|
||||
"setting__desktop_lyric_scroll_align_center": "中心",
|
||||
"setting__desktop_lyric_scroll_align_top": "頂部",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { isLinux } from '@common/utils'
|
||||
import { closeWindow, createWindow, getBounds, isExistWindow, alwaysOnTopTools, setBounds, setIgnoreMouseEvents, setSkipTaskbar } from './main'
|
||||
import { sendConfigChange } from './rendererEvent'
|
||||
import { buildLyricConfig, getLyricWindowBounds, watchConfigKeys } from './utils'
|
||||
import { buildLyricConfig, getLyricWindowBounds, initWindowSize, watchConfigKeys } from './utils'
|
||||
|
||||
let isLock: boolean
|
||||
let isEnable: boolean
|
||||
|
@ -62,6 +62,14 @@ export const setLrcConfig = (keys: Array<keyof LX.AppSetting>, setting: Partial<
|
|||
}))
|
||||
}
|
||||
}
|
||||
if (keys.includes('desktopLyric.x') && setting['desktopLyric.x'] == null) {
|
||||
setBounds(initWindowSize(
|
||||
global.lx.appSetting['desktopLyric.x'],
|
||||
global.lx.appSetting['desktopLyric.y'],
|
||||
global.lx.appSetting['desktopLyric.width'],
|
||||
global.lx.appSetting['desktopLyric.height'],
|
||||
))
|
||||
}
|
||||
}
|
||||
if (keys.includes('desktopLyric.enable') && isEnable != global.lx.appSetting['desktopLyric.enable']) {
|
||||
isEnable = global.lx.appSetting['desktopLyric.enable']
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { join } from 'path'
|
||||
import { BrowserWindow } from 'electron'
|
||||
import { debounce, isLinux } from '@common/utils'
|
||||
import { getLyricWindowBounds, minHeight, minWidth, padding } from './utils'
|
||||
import { initWindowSize } from './utils'
|
||||
import { mainSend } from '@common/mainIpc'
|
||||
import { encodePath } from '@common/utils/electron'
|
||||
|
||||
|
@ -9,11 +9,11 @@ import { encodePath } from '@common/utils/electron'
|
|||
// require('./rendererEvent')
|
||||
|
||||
let browserWindow: Electron.BrowserWindow | null = null
|
||||
let isWinBoundsUdating = false
|
||||
let isWinBoundsUpdateing = false
|
||||
|
||||
const saveBoundsConfig = debounce((config: Partial<LX.AppSetting>) => {
|
||||
global.lx.event_app.update_config(config)
|
||||
if (isWinBoundsUdating) isWinBoundsUdating = false
|
||||
if (isWinBoundsUpdateing) isWinBoundsUpdateing = false
|
||||
}, 500)
|
||||
|
||||
const winEvent = () => {
|
||||
|
@ -32,8 +32,8 @@ const winEvent = () => {
|
|||
|
||||
browserWindow.on('move', () => {
|
||||
// bounds = browserWindow.getBounds()
|
||||
// console.log('move', isWinBoundsUdating)
|
||||
if (isWinBoundsUdating) {
|
||||
// console.log('move', isWinBoundsUpdateing)
|
||||
if (isWinBoundsUpdateing) {
|
||||
const bounds = browserWindow!.getBounds()
|
||||
saveBoundsConfig({
|
||||
'desktopLyric.x': bounds.x,
|
||||
|
@ -95,27 +95,12 @@ export const createWindow = () => {
|
|||
// let isLockScreen = global.lx.appSetting['desktopLyric.isLockScreen']
|
||||
let isShowTaskbar = global.lx.appSetting['desktopLyric.isShowTaskbar']
|
||||
// let { width: screenWidth, height: screenHeight } = global.envParams.workAreaSize
|
||||
if (x == null || y == null) {
|
||||
if (width < minWidth) width = minWidth
|
||||
if (height < minHeight) height = minHeight
|
||||
if (global.envParams.workAreaSize) {
|
||||
x = global.envParams.workAreaSize.width + padding - width
|
||||
y = global.envParams.workAreaSize.height + padding - height
|
||||
} else {
|
||||
x = y = -padding
|
||||
}
|
||||
} else {
|
||||
let bounds = getLyricWindowBounds({ x, y, width, height }, { x: 0, y: 0, w: width, h: height })
|
||||
x = bounds.x
|
||||
y = bounds.y
|
||||
width = bounds.width
|
||||
height = bounds.height
|
||||
}
|
||||
const winSize = initWindowSize(x, y, width, height)
|
||||
global.lx.event_app.update_config({
|
||||
'desktopLyric.x': x,
|
||||
'desktopLyric.y': y,
|
||||
'desktopLyric.width': width,
|
||||
'desktopLyric.height': height,
|
||||
'desktopLyric.x': winSize.x,
|
||||
'desktopLyric.y': winSize.y,
|
||||
'desktopLyric.width': winSize.width,
|
||||
'desktopLyric.height': winSize.height,
|
||||
})
|
||||
|
||||
const { shouldUseDarkColors, theme } = global.lx.theme
|
||||
|
@ -124,10 +109,10 @@ export const createWindow = () => {
|
|||
* Initial window options
|
||||
*/
|
||||
browserWindow = new BrowserWindow({
|
||||
height,
|
||||
width,
|
||||
x,
|
||||
y,
|
||||
height: winSize.height,
|
||||
width: winSize.width,
|
||||
x: winSize.x,
|
||||
y: winSize.y,
|
||||
minWidth: 380,
|
||||
minHeight: 80,
|
||||
useContentSize: true,
|
||||
|
@ -183,7 +168,7 @@ export const getBounds = (): Electron.Rectangle => {
|
|||
|
||||
export const setBounds = (bounds: Electron.Rectangle) => {
|
||||
if (!browserWindow) return
|
||||
isWinBoundsUdating = true
|
||||
isWinBoundsUpdateing = true
|
||||
browserWindow.setBounds(bounds)
|
||||
}
|
||||
|
||||
|
|
|
@ -95,3 +95,28 @@ export const buildLyricConfig = (appSetting: Partial<LX.AppSetting>): Partial<LX
|
|||
}
|
||||
return setting
|
||||
}
|
||||
|
||||
export const initWindowSize = (x: LX.AppSetting['desktopLyric.x'], y: LX.AppSetting['desktopLyric.y'], width: LX.AppSetting['desktopLyric.width'], height: LX.AppSetting['desktopLyric.height']) => {
|
||||
if (x == null || y == null) {
|
||||
if (width < minWidth) width = minWidth
|
||||
if (height < minHeight) height = minHeight
|
||||
if (global.envParams.workAreaSize) {
|
||||
x = global.envParams.workAreaSize.width + padding - width
|
||||
y = global.envParams.workAreaSize.height + padding - height
|
||||
} else {
|
||||
x = y = -padding
|
||||
}
|
||||
} else {
|
||||
let bounds = getLyricWindowBounds({ x, y, width, height }, { x: 0, y: 0, w: width, h: height })
|
||||
x = bounds.x
|
||||
y = bounds.y
|
||||
width = bounds.width
|
||||
height = bounds.height
|
||||
}
|
||||
return {
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,6 +81,13 @@ dd
|
|||
h3#desktop_lyric_font {{$t('setting__desktop_lyric_font')}}
|
||||
div
|
||||
base-selection.gap-teft(:list="fontList" :modelValue="appSetting['desktopLyric.style.font']" @update:modelValue="updateSetting({ 'desktopLyric.style.font': $event })" item-key="id" item-name="label")
|
||||
|
||||
dd
|
||||
h3#desktop_lyric_reset {{ $t('setting__desktop_lyric_reset') }}
|
||||
div
|
||||
p.gap-top
|
||||
base-btn.btn(min @click="resetWindowSetting") {{$t('setting__desktop_lyric_reset_window')}}
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
@ -266,6 +273,15 @@ export default {
|
|||
systemFontList.value = fonts.map(f => ({ id: f, label: f.replace(/(^"|"$)/g, '') }))
|
||||
})
|
||||
|
||||
const resetWindowSetting = () => {
|
||||
updateSetting({
|
||||
'desktopLyric.width': 450,
|
||||
'desktopLyric.height': 300,
|
||||
'desktopLyric.x': null,
|
||||
'desktopLyric.y': null,
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
appSetting,
|
||||
updateSetting,
|
||||
|
@ -274,6 +290,7 @@ export default {
|
|||
lyric_played_color_ref,
|
||||
lyric_shadow_color_ref,
|
||||
resetColor,
|
||||
resetWindowSetting,
|
||||
|
||||
fontList,
|
||||
isLinux,
|
||||
|
|
Loading…
Reference in New Issue