在歌词滚动结束后清理窗口阴影,缓解Mac下桌面歌词出现残留阴影的问题
parent
10028cf500
commit
1f6a6bbb39
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
- 修复存在多级弹窗时的背景显示问题
|
- 修复存在多级弹窗时的背景显示问题
|
||||||
- 增大在线导入自定义源文件的大小限制问题(#1857)
|
- 增大在线导入自定义源文件的大小限制问题(#1857)
|
||||||
|
- 在歌词滚动结束后清理窗口阴影,缓解Mac下桌面歌词出现残留阴影的问题
|
||||||
|
|
||||||
### 变更
|
### 变更
|
||||||
|
|
||||||
|
|
|
@ -165,6 +165,7 @@ const modules = {
|
||||||
key_down: 'key_down',
|
key_down: 'key_down',
|
||||||
request_main_window_channel: 'request_main_window_channel',
|
request_main_window_channel: 'request_main_window_channel',
|
||||||
provide_main_window_channel: 'provide_main_window_channel',
|
provide_main_window_channel: 'provide_main_window_channel',
|
||||||
|
invalidate_shadow: 'invalidate_shadow',
|
||||||
},
|
},
|
||||||
hotKey: {
|
hotKey: {
|
||||||
enable: 'enable',
|
enable: 'enable',
|
||||||
|
|
|
@ -194,6 +194,11 @@ export const getMainFrame = (): Electron.WebFrameMain | null => {
|
||||||
return browserWindow.webContents.mainFrame
|
return browserWindow.webContents.mainFrame
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const invalidateShadow = () => {
|
||||||
|
if (!browserWindow) return
|
||||||
|
browserWindow.invalidateShadow()
|
||||||
|
}
|
||||||
|
|
||||||
interface AlwaysOnTopTools {
|
interface AlwaysOnTopTools {
|
||||||
timeout: NodeJS.Timeout | null
|
timeout: NodeJS.Timeout | null
|
||||||
setAlwaysOnTop: (isLoop: boolean) => void
|
setAlwaysOnTop: (isLoop: boolean) => void
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { mainOn, mainHandle } from '@common/mainIpc'
|
||||||
import { WIN_LYRIC_RENDERER_EVENT_NAME } from '@common/ipcNames'
|
import { WIN_LYRIC_RENDERER_EVENT_NAME } from '@common/ipcNames'
|
||||||
import { buildLyricConfig, getLyricWindowBounds } from './utils'
|
import { buildLyricConfig, getLyricWindowBounds } from './utils'
|
||||||
import { sendNewDesktopLyricClient } from '@main/modules/winMain'
|
import { sendNewDesktopLyricClient } from '@main/modules/winMain'
|
||||||
import { getBounds, getMainFrame, sendEvent, setBounds } from './main'
|
import { getBounds, getMainFrame, invalidateShadow, sendEvent, setBounds } from './main'
|
||||||
import { MessageChannelMain } from 'electron'
|
import { MessageChannelMain } from 'electron'
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,6 +29,10 @@ export default () => {
|
||||||
setBounds(getLyricWindowBounds(getBounds(), options))
|
setBounds(getLyricWindowBounds(getBounds(), options))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
mainOn(WIN_LYRIC_RENDERER_EVENT_NAME.invalidate_shadow, () => {
|
||||||
|
invalidateShadow()
|
||||||
|
})
|
||||||
|
|
||||||
mainOn(WIN_LYRIC_RENDERER_EVENT_NAME.request_main_window_channel, ({ event }) => {
|
mainOn(WIN_LYRIC_RENDERER_EVENT_NAME.request_main_window_channel, ({ event }) => {
|
||||||
if (event.senderFrame !== getMainFrame()) return
|
if (event.senderFrame !== getMainFrame()) return
|
||||||
// Create a new channel ...
|
// Create a new channel ...
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { ref, onMounted, onBeforeUnmount, watch, nextTick } from '@common/utils/
|
||||||
import { scrollTo } from '@common/utils/renderer'
|
import { scrollTo } from '@common/utils/renderer'
|
||||||
import { lyric } from '@lyric/store/lyric'
|
import { lyric } from '@lyric/store/lyric'
|
||||||
import { isPlay, setting } from '@lyric/store/state'
|
import { isPlay, setting } from '@lyric/store/state'
|
||||||
import { setWindowBounds } from '@lyric/utils/ipc'
|
import { invalidateShadow, setWindowBounds } from '@lyric/utils/ipc'
|
||||||
|
|
||||||
const getOffsetTop = (contentHeight, lineHeight) => {
|
const getOffsetTop = (contentHeight, lineHeight) => {
|
||||||
switch (setting['desktopLyric.scrollAlign']) {
|
switch (setting['desktopLyric.scrollAlign']) {
|
||||||
|
@ -45,9 +45,13 @@ export default (isComputeHeight) => {
|
||||||
offset = prevActiveLine < lyric.line ? ((dom_lines[prevActiveLine]?.clientHeight ?? 0) - prevLineHeight) : 0
|
offset = prevActiveLine < lyric.line ? ((dom_lines[prevActiveLine]?.clientHeight ?? 0) - prevLineHeight) : 0
|
||||||
// console.log(prevActiveLine, dom_lines[prevActiveLine]?.clientHeight ?? 0, prevLineHeight, offset)
|
// console.log(prevActiveLine, dom_lines[prevActiveLine]?.clientHeight ?? 0, prevLineHeight, offset)
|
||||||
}
|
}
|
||||||
cancelScrollFn = scrollTo(dom_lyric.value, dom_p ? (dom_p.offsetTop - offset - getOffsetTop(dom_lyric.value.clientHeight, dom_p.clientHeight)) : 0, duration)
|
cancelScrollFn = scrollTo(dom_lyric.value, dom_p ? (dom_p.offsetTop - offset - getOffsetTop(dom_lyric.value.clientHeight, dom_p.clientHeight)) : 0, duration, () => {
|
||||||
|
invalidateShadow()
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
cancelScrollFn = scrollTo(dom_lyric.value, 0, duration)
|
cancelScrollFn = scrollTo(dom_lyric.value, 0, duration, () => {
|
||||||
|
invalidateShadow()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const clearLyricScrollTimeout = () => {
|
const clearLyricScrollTimeout = () => {
|
||||||
|
@ -158,6 +162,7 @@ export default (isComputeHeight) => {
|
||||||
setLyric(lines)
|
setLyric(lines)
|
||||||
} else {
|
} else {
|
||||||
cancelScrollFn = scrollTo(dom_lyric.value, 0, 300, () => {
|
cancelScrollFn = scrollTo(dom_lyric.value, 0, 300, () => {
|
||||||
|
invalidateShadow()
|
||||||
if (lyric.lines !== lines) return
|
if (lyric.lines !== lines) return
|
||||||
setLyric(lines)
|
setLyric(lines)
|
||||||
}, 50)
|
}, 50)
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { ref, onMounted, onBeforeUnmount, watch, nextTick } from '@common/utils/
|
||||||
import { scrollXRTo } from '@common/utils/renderer'
|
import { scrollXRTo } from '@common/utils/renderer'
|
||||||
import { lyric } from '@lyric/store/lyric'
|
import { lyric } from '@lyric/store/lyric'
|
||||||
import { isPlay, setting } from '@lyric/store/state'
|
import { isPlay, setting } from '@lyric/store/state'
|
||||||
import { setWindowBounds } from '@lyric/utils/ipc'
|
import { invalidateShadow, setWindowBounds } from '@lyric/utils/ipc'
|
||||||
|
|
||||||
const getOffsetTop = (contentWidth, lineWidth) => {
|
const getOffsetTop = (contentWidth, lineWidth) => {
|
||||||
switch (setting['desktopLyric.scrollAlign']) {
|
switch (setting['desktopLyric.scrollAlign']) {
|
||||||
|
@ -45,9 +45,13 @@ export default (isComputeWidth) => {
|
||||||
offset = prevActiveLine < lyric.line ? ((dom_lines[prevActiveLine]?.clientWidth ?? 0) - prevLineWidth) : 0
|
offset = prevActiveLine < lyric.line ? ((dom_lines[prevActiveLine]?.clientWidth ?? 0) - prevLineWidth) : 0
|
||||||
// console.log(prevActiveLine, dom_lines[prevActiveLine]?.clientHeight ?? 0, prevLineWidth, offset)
|
// console.log(prevActiveLine, dom_lines[prevActiveLine]?.clientHeight ?? 0, prevLineWidth, offset)
|
||||||
}
|
}
|
||||||
cancelScrollFn = scrollXRTo(dom_lyric.value, dom_p ? (dom_p.offsetLeft + offset - getOffsetTop(dom_lyric.value.clientWidth, dom_p.clientWidth)) : 0, duration)
|
cancelScrollFn = scrollXRTo(dom_lyric.value, dom_p ? (dom_p.offsetLeft + offset - getOffsetTop(dom_lyric.value.clientWidth, dom_p.clientWidth)) : 0, duration, () => {
|
||||||
|
invalidateShadow()
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
cancelScrollFn = scrollXRTo(dom_lyric.value, 0, duration)
|
cancelScrollFn = scrollXRTo(dom_lyric.value, 0, duration, () => {
|
||||||
|
invalidateShadow()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const clearLyricScrollTimeout = () => {
|
const clearLyricScrollTimeout = () => {
|
||||||
|
@ -158,6 +162,7 @@ export default (isComputeWidth) => {
|
||||||
setLyric(lines)
|
setLyric(lines)
|
||||||
} else {
|
} else {
|
||||||
cancelScrollFn = scrollXRTo(dom_lyric.value, 0, 300, () => {
|
cancelScrollFn = scrollXRTo(dom_lyric.value, 0, 300, () => {
|
||||||
|
invalidateShadow()
|
||||||
if (lyric.lines !== lines) return
|
if (lyric.lines !== lines) return
|
||||||
setLyric(lines)
|
setLyric(lines)
|
||||||
}, 50)
|
}, 50)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { rendererSend, rendererInvoke, rendererOn, rendererOff } from '@common/rendererIpc'
|
import { rendererSend, rendererInvoke, rendererOn, rendererOff } from '@common/rendererIpc'
|
||||||
import { CMMON_EVENT_NAME, WIN_LYRIC_RENDERER_EVENT_NAME } from '@common/ipcNames'
|
import { CMMON_EVENT_NAME, WIN_LYRIC_RENDERER_EVENT_NAME } from '@common/ipcNames'
|
||||||
|
import { isMac } from '@common/utils'
|
||||||
|
|
||||||
type RemoveListener = () => void
|
type RemoveListener = () => void
|
||||||
|
|
||||||
|
@ -18,6 +19,10 @@ export const onSettingChanged = (listener: LX.IpcRendererEventListenerParams<Par
|
||||||
export const setWindowBounds = (bounds: LX.DesktopLyric.NewBounds) => {
|
export const setWindowBounds = (bounds: LX.DesktopLyric.NewBounds) => {
|
||||||
rendererSend<LX.DesktopLyric.NewBounds>(WIN_LYRIC_RENDERER_EVENT_NAME.set_win_bounds, bounds)
|
rendererSend<LX.DesktopLyric.NewBounds>(WIN_LYRIC_RENDERER_EVENT_NAME.set_win_bounds, bounds)
|
||||||
}
|
}
|
||||||
|
export const invalidateShadow = () => {
|
||||||
|
if (!isMac) return
|
||||||
|
rendererSend(WIN_LYRIC_RENDERER_EVENT_NAME.invalidate_shadow)
|
||||||
|
}
|
||||||
|
|
||||||
export const sendConnectMainWindowEvent = () => {
|
export const sendConnectMainWindowEvent = () => {
|
||||||
rendererSend(WIN_LYRIC_RENDERER_EVENT_NAME.request_main_window_channel)
|
rendererSend(WIN_LYRIC_RENDERER_EVENT_NAME.request_main_window_channel)
|
||||||
|
|
Loading…
Reference in New Issue