新增 不允许将歌词窗口拖出主屏幕之外 的设置项
parent
44acc7d5ac
commit
c15895ab45
|
@ -1,6 +1,7 @@
|
||||||
### 新增
|
### 新增
|
||||||
|
|
||||||
- 在歌单详情界面新增播放当前歌单按钮、收藏歌单按钮
|
- 在歌单详情界面新增播放当前歌单按钮、收藏歌单按钮
|
||||||
|
- 新增`不允许将歌词窗口拖出主屏幕之外`的设置项,默认开启,在连接多个屏幕时想要拖动到其他屏幕时可关闭此设置
|
||||||
|
|
||||||
### 修复
|
### 修复
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ const os = require('os')
|
||||||
const { isMac } = require('./utils')
|
const { isMac } = require('./utils')
|
||||||
|
|
||||||
const defaultSetting = {
|
const defaultSetting = {
|
||||||
version: '1.0.34',
|
version: '1.0.35',
|
||||||
player: {
|
player: {
|
||||||
togglePlayMethod: 'listLoop',
|
togglePlayMethod: 'listLoop',
|
||||||
highQuality: false,
|
highQuality: false,
|
||||||
|
@ -22,6 +22,7 @@ const defaultSetting = {
|
||||||
x: null,
|
x: null,
|
||||||
y: null,
|
y: null,
|
||||||
theme: 0,
|
theme: 0,
|
||||||
|
isLockScreen: true,
|
||||||
style: {
|
style: {
|
||||||
fontSize: 120,
|
fontSize: 120,
|
||||||
opacity: 95,
|
opacity: 95,
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
const { common: COMMON_EVENT_NAME, winLyric: WIN_LYRIC_EVENT_NAME, hotKey: HOT_KEY_EVENT_NAME, mainWindow: MAIN_WINDOW_EVENT_NAME } = require('../../events/_name')
|
const { common: COMMON_EVENT_NAME, winLyric: WIN_LYRIC_EVENT_NAME, hotKey: HOT_KEY_EVENT_NAME, mainWindow: MAIN_WINDOW_EVENT_NAME } = require('../../events/_name')
|
||||||
const { mainSend, NAMES: { winLyric: ipcWinLyricNames } } = require('../../../common/ipc')
|
const { mainSend, NAMES: { winLyric: ipcWinLyricNames } } = require('../../../common/ipc')
|
||||||
const { desktop_lyric } = require('../../../common/hotKey')
|
const { desktop_lyric } = require('../../../common/hotKey')
|
||||||
|
const { setLyricWindow } = require('./utils')
|
||||||
|
|
||||||
let isLock = null
|
let isLock = null
|
||||||
let isEnable = null
|
let isEnable = null
|
||||||
let isAlwaysOnTop = null
|
let isAlwaysOnTop = null
|
||||||
|
let isLockScreen = null
|
||||||
const setLrcConfig = () => {
|
const setLrcConfig = () => {
|
||||||
let desktopLyric = global.appSetting.desktopLyric
|
let desktopLyric = global.appSetting.desktopLyric
|
||||||
if (global.modules.lyricWindow) {
|
if (global.modules.lyricWindow) {
|
||||||
|
@ -33,10 +35,21 @@ const setLrcConfig = () => {
|
||||||
global.lx_event.winLyric.close()
|
global.lx_event.winLyric.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (isLockScreen != desktopLyric.isLockScreen) {
|
||||||
|
isLockScreen = desktopLyric.isLockScreen
|
||||||
|
if (desktopLyric.isLockScreen) {
|
||||||
|
setLyricWindow({
|
||||||
|
x: desktopLyric.x,
|
||||||
|
y: desktopLyric.y,
|
||||||
|
w: desktopLyric.width,
|
||||||
|
h: desktopLyric.height,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
global.lx_event.common.on(COMMON_EVENT_NAME.config, name => {
|
global.lx_event.common.on(COMMON_EVENT_NAME.config, name => {
|
||||||
if (WIN_LYRIC_EVENT_NAME.name === name) return
|
if (WIN_LYRIC_EVENT_NAME.name === name) return
|
||||||
setLrcConfig(false)
|
setLrcConfig()
|
||||||
})
|
})
|
||||||
|
|
||||||
global.lx_event.mainWindow.on(MAIN_WINDOW_EVENT_NAME.setLyricInfo, info => {
|
global.lx_event.mainWindow.on(MAIN_WINDOW_EVENT_NAME.setLyricInfo, info => {
|
||||||
|
|
|
@ -80,14 +80,18 @@ const createWindow = () => {
|
||||||
x = screenWidth - width - offset
|
x = screenWidth - width - offset
|
||||||
y = screenHeight - height - offset
|
y = screenHeight - height - offset
|
||||||
}
|
}
|
||||||
|
if (global.appSetting.desktopLyric.isLockScreen) {
|
||||||
|
x = Math.max(-offset, screenWidth < (width + x) ? screenWidth - width : x)
|
||||||
|
y = Math.max(-offset, screenHeight < (height + y) ? screenHeight - height : y)
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Initial window options
|
* Initial window options
|
||||||
*/
|
*/
|
||||||
global.modules.lyricWindow = new BrowserWindow({
|
global.modules.lyricWindow = new BrowserWindow({
|
||||||
height: Math.max(height > screenHeight ? screenHeight : height, 80),
|
height: Math.max(height > screenHeight ? screenHeight : height, 80),
|
||||||
width: Math.max(width > screenWidth ? screenWidth : width, 380),
|
width: Math.max(width > screenWidth ? screenWidth : width, 380),
|
||||||
x: Math.max(-offset, screenWidth < (width + x) ? screenWidth - width : x),
|
x,
|
||||||
y: Math.max(-offset, screenHeight < (height + y) ? screenHeight - height : y),
|
y,
|
||||||
minWidth: 380,
|
minWidth: 380,
|
||||||
minHeight: 80,
|
minHeight: 80,
|
||||||
useContentSize: true,
|
useContentSize: true,
|
||||||
|
|
|
@ -8,6 +8,7 @@ const {
|
||||||
},
|
},
|
||||||
} = require('../../../common/ipc')
|
} = require('../../../common/ipc')
|
||||||
const { winLyric: WIN_LYRIC_EVENT_NAME } = require('../../events/_name')
|
const { winLyric: WIN_LYRIC_EVENT_NAME } = require('../../events/_name')
|
||||||
|
const { setLyricWindow } = require('./utils')
|
||||||
|
|
||||||
mainOn(ipcWinLyricNames.get_lyric_info, (event, action) => {
|
mainOn(ipcWinLyricNames.get_lyric_info, (event, action) => {
|
||||||
if (!global.modules.mainWindow) return
|
if (!global.modules.mainWindow) return
|
||||||
|
@ -26,51 +27,6 @@ mainHandle(ipcWinLyricNames.get_lyric_config, async() => {
|
||||||
return { config: global.appSetting.desktopLyric, languageId: global.appSetting.langId }
|
return { config: global.appSetting.desktopLyric, languageId: global.appSetting.langId }
|
||||||
})
|
})
|
||||||
|
|
||||||
let bounds
|
mainOn(ipcWinLyricNames.set_win_bounds, (event, options) => {
|
||||||
let winX
|
setLyricWindow(options)
|
||||||
let winY
|
|
||||||
let wasW
|
|
||||||
let wasY
|
|
||||||
let offset = 8
|
|
||||||
mainOn(ipcWinLyricNames.set_win_bounds, (event, { x = 0, y = 0, w = 0, h = 0 }) => {
|
|
||||||
if (!global.modules.lyricWindow) return
|
|
||||||
bounds = global.modules.lyricWindow.getBounds()
|
|
||||||
wasW = global.envParams.workAreaSize.width
|
|
||||||
wasY = global.envParams.workAreaSize.height + offset
|
|
||||||
|
|
||||||
bounds.width = w
|
|
||||||
bounds.height = h
|
|
||||||
if (bounds.width > wasW - offset) {
|
|
||||||
bounds.width = wasW - offset
|
|
||||||
} else if (bounds.width < 380) {
|
|
||||||
bounds.width = 380
|
|
||||||
}
|
|
||||||
if (bounds.height > wasY) {
|
|
||||||
bounds.height = wasY + offset
|
|
||||||
} else if (bounds.height < 80) {
|
|
||||||
bounds.height = 80
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (x != 0) {
|
|
||||||
winX = bounds.x + x
|
|
||||||
if (winX > wasW - bounds.width + offset) {
|
|
||||||
winX = wasW - bounds.width + offset
|
|
||||||
} else if (winX < -offset) {
|
|
||||||
winX = -offset
|
|
||||||
}
|
|
||||||
bounds.x = winX
|
|
||||||
}
|
|
||||||
if (y != 0) {
|
|
||||||
winY = bounds.y + y
|
|
||||||
if (winY > wasY - bounds.height) {
|
|
||||||
winY = wasY - bounds.height
|
|
||||||
} else if (winY < -offset) {
|
|
||||||
winY = -offset
|
|
||||||
}
|
|
||||||
bounds.y = winY
|
|
||||||
}
|
|
||||||
|
|
||||||
// console.log(bounds, x, y, w, h)
|
|
||||||
global.modules.lyricWindow.setBounds(bounds)
|
|
||||||
})
|
})
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
// 设置窗口位置、大小
|
||||||
|
let bounds
|
||||||
|
let winX
|
||||||
|
let winY
|
||||||
|
let wasW
|
||||||
|
let wasY
|
||||||
|
let offset = 8
|
||||||
|
exports.setLyricWindow = ({ x = 0, y = 0, w = 0, h = 0 }) => {
|
||||||
|
if (!global.modules.lyricWindow) return
|
||||||
|
bounds = global.modules.lyricWindow.getBounds()
|
||||||
|
wasW = global.envParams.workAreaSize.width
|
||||||
|
wasY = global.envParams.workAreaSize.height + offset
|
||||||
|
|
||||||
|
bounds.width = w
|
||||||
|
bounds.height = h
|
||||||
|
if (bounds.width > wasW - offset) {
|
||||||
|
bounds.width = wasW - offset
|
||||||
|
} else if (bounds.width < 380) {
|
||||||
|
bounds.width = 380
|
||||||
|
}
|
||||||
|
if (bounds.height > wasY) {
|
||||||
|
bounds.height = wasY + offset
|
||||||
|
} else if (bounds.height < 80) {
|
||||||
|
bounds.height = 80
|
||||||
|
}
|
||||||
|
|
||||||
|
if (global.appSetting.desktopLyric.isLockScreen) {
|
||||||
|
if (x != 0) {
|
||||||
|
winX = bounds.x + x
|
||||||
|
if (winX > wasW - bounds.width + offset) {
|
||||||
|
winX = wasW - bounds.width + offset
|
||||||
|
} else if (winX < -offset) {
|
||||||
|
winX = -offset
|
||||||
|
}
|
||||||
|
bounds.x = winX
|
||||||
|
}
|
||||||
|
if (y != 0) {
|
||||||
|
winY = bounds.y + y
|
||||||
|
if (winY > wasY - bounds.height) {
|
||||||
|
winY = wasY - bounds.height
|
||||||
|
} else if (winY < -offset) {
|
||||||
|
winY = -offset
|
||||||
|
}
|
||||||
|
bounds.y = winY
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (x != 0) {
|
||||||
|
bounds.x = bounds.x + x
|
||||||
|
}
|
||||||
|
if (y != 0) {
|
||||||
|
bounds.y = bounds.y + y
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// console.log(bounds, x, y, w, h)
|
||||||
|
global.modules.lyricWindow.setBounds(bounds)
|
||||||
|
}
|
|
@ -48,6 +48,7 @@
|
||||||
"desktop_lyric_enable": "Display lyrics",
|
"desktop_lyric_enable": "Display lyrics",
|
||||||
"desktop_lyric_lock": "Lock lyrics",
|
"desktop_lyric_lock": "Lock lyrics",
|
||||||
"desktop_lyric_always_on_top": "Make the lyrics always above other windows",
|
"desktop_lyric_always_on_top": "Make the lyrics always above other windows",
|
||||||
|
"desktop_lyric_lock_screen": "It is not allowed to drag the lyrics window out of the main screen",
|
||||||
|
|
||||||
"search": "Search",
|
"search": "Search",
|
||||||
"search_hot_title": "Select whether to show popular searches",
|
"search_hot_title": "Select whether to show popular searches",
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
"desktop_lyric_enable": "显示歌词",
|
"desktop_lyric_enable": "显示歌词",
|
||||||
"desktop_lyric_lock": "锁定歌词",
|
"desktop_lyric_lock": "锁定歌词",
|
||||||
"desktop_lyric_always_on_top": "使歌词总是在其他窗口之上",
|
"desktop_lyric_always_on_top": "使歌词总是在其他窗口之上",
|
||||||
|
"desktop_lyric_lock_screen": "不允许歌词窗口拖出主屏幕之外",
|
||||||
|
|
||||||
"search": "搜索设置",
|
"search": "搜索设置",
|
||||||
"search_hot_title": "是否显示热门搜索",
|
"search_hot_title": "是否显示热门搜索",
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
"desktop_lyric_enable": "顯示歌詞",
|
"desktop_lyric_enable": "顯示歌詞",
|
||||||
"desktop_lyric_lock": "鎖定歌詞",
|
"desktop_lyric_lock": "鎖定歌詞",
|
||||||
"desktop_lyric_always_on_top": "使歌詞總是在其他窗口之上",
|
"desktop_lyric_always_on_top": "使歌詞總是在其他窗口之上",
|
||||||
|
"desktop_lyric_lock_screen": "不允許歌詞窗口拖出主屏幕之外",
|
||||||
"search": "搜索設置",
|
"search": "搜索設置",
|
||||||
"search_hot_title": "是否顯示熱門搜索",
|
"search_hot_title": "是否顯示熱門搜索",
|
||||||
"search_hot": "熱門搜索",
|
"search_hot": "熱門搜索",
|
||||||
|
|
|
@ -82,6 +82,8 @@ div.scroll(:class="$style.setting")
|
||||||
material-checkbox(id="setting_desktop_lyric_lock" v-model="current_setting.desktopLyric.isLock" :label="$t('view.setting.desktop_lyric_lock')")
|
material-checkbox(id="setting_desktop_lyric_lock" v-model="current_setting.desktopLyric.isLock" :label="$t('view.setting.desktop_lyric_lock')")
|
||||||
div(:class="$style.gapTop")
|
div(:class="$style.gapTop")
|
||||||
material-checkbox(id="setting_desktop_lyric_alwaysOnTop" v-model="current_setting.desktopLyric.isAlwaysOnTop" :label="$t('view.setting.desktop_lyric_always_on_top')")
|
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')")
|
||||||
dt {{$t('view.setting.search')}}
|
dt {{$t('view.setting.search')}}
|
||||||
dd(:title="$t('view.setting.search_hot_title')")
|
dd(:title="$t('view.setting.search_hot_title')")
|
||||||
h3 {{$t('view.setting.search_hot')}}
|
h3 {{$t('view.setting.search_hot')}}
|
||||||
|
|
Loading…
Reference in New Issue