From e20b2844fba18b0e458e24cda1e2cf643d3ec28d Mon Sep 17 00:00:00 2001 From: lyswhut Date: Sat, 19 Sep 2026 00:29:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=80=8F=E6=98=8E=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=E8=BE=B9=E6=A1=86=E6=98=BE=E7=A4=BA=E6=95=88=E6=9E=9C?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=E5=85=A8=E5=B1=8F=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E4=B8=8B=E7=9A=84=E7=9B=B8=E5=85=B3=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- publish/changeLog.md | 3 ++ src/common/utils/index.ts | 8 ++++- src/main/modules/winMain/main.ts | 25 +++++++++++++--- src/renderer/App.vue | 7 +++-- src/renderer/index.html | 50 +++++++++++++++++--------------- 5 files changed, 63 insertions(+), 30 deletions(-) diff --git a/publish/changeLog.md b/publish/changeLog.md index 2de9e1e6..243eac8a 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -6,7 +6,10 @@ Any Listen 的项目地址为 https://github.com/any-listen/any-listen ### 优化 - 优化 tx 推荐歌单列表 +- 优化禁用透明窗口的窗口边框显示效果 ### 修复 - 修复打开某些 kg 歌单时歌曲丢失的问题 +- 修复 Windows 7 无法启动的问题 +- 修复禁用透明窗口时按 F11 无法全屏的问题 diff --git a/src/common/utils/index.ts b/src/common/utils/index.ts index cf479e99..85a9dd2f 100644 --- a/src/common/utils/index.ts +++ b/src/common/utils/index.ts @@ -1,4 +1,5 @@ import log from 'electron-log/node' +import os from 'node:os' export const isLinux = process.platform == 'linux' @@ -13,7 +14,12 @@ export const getPlatform = (platform: NodeJS.Platform = process.platform) => { default: return 'linux' } } - +export const getOSVersion = (): string => { + const release = os.release() + const versionMatch = /^(\d+)/.exec(release) + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + return versionMatch?.[1] || release +} // https://stackoverflow.com/a/53387532 export function compareVer(currentVer: string, targetVer: string): -1 | 0 | 1 { diff --git a/src/main/modules/winMain/main.ts b/src/main/modules/winMain/main.ts index ca6d64dd..cedb6096 100644 --- a/src/main/modules/winMain/main.ts +++ b/src/main/modules/winMain/main.ts @@ -1,7 +1,7 @@ import { BrowserWindow, dialog, session } from 'electron' import path from 'node:path' import { createTaskBarButtons, getWindowSizeInfo } from './utils' -import { getPlatform, isLinux, isWin } from '@common/utils' +import { getOSVersion, getPlatform, isLinux, isMac, isWin } from '@common/utils' import { getProxy, openDevTools as handleOpenDevTools } from '@main/utils' import { mainSend } from '@common/mainIpc' import { sendFocus, sendTaskbarButtonClick } from './rendererEvent' @@ -40,6 +40,19 @@ const winEvent = () => { browserWindow.on('blur', () => { global.lx.event_app.main_window_blur() }) + browserWindow.on('enter-full-screen', () => { + global.lx.event_app.main_window_fullscreen(true) + }) + browserWindow.on('leave-full-screen', () => { + global.lx.event_app.main_window_fullscreen(false) + + // macOS needs here to set resizable to false after exiting full screen + if (isMac) { + if (browserWindow?.resizable) { + browserWindow.setResizable(false) + } + } + }) browserWindow.once('ready-to-show', () => { if (!global.envParams.cmdParams.hidden) { @@ -107,7 +120,7 @@ export const createWindow = () => { browserWindow = new BrowserWindow(options) const winURL = process.env.NODE_ENV !== 'production' ? 'http://localhost:9080' : `file://${path.join(encodePath(__dirname), 'index.html')}` - void browserWindow.loadURL(winURL + `?os=${getPlatform()}&dt=${global.envParams.cmdParams.dt}&dark=${shouldUseDarkColors}&theme=${encodeURIComponent(JSON.stringify(theme))}`) + void browserWindow.loadURL(winURL + `?os=${getPlatform()}&osver=${encodeURIComponent(getOSVersion())}&dt=${global.envParams.cmdParams.dt}&dark=${shouldUseDarkColors}&theme=${encodeURIComponent(JSON.stringify(theme))}`) winEvent() @@ -228,13 +241,17 @@ export const toggleDevTools = () => { export const setFullScreen = (isFullscreen: boolean): boolean => { if (!browserWindow) return false - if (isLinux) { // linux 需要先设置为可调整窗口大小才能全屏 + // https://github.com/any-listen/any-listen/issues/190 + // in electron ^41.2.0, windows -dt mode need to set resizable to true before setting full screen + if (!!global.envParams.cmdParams.dt || isLinux) { + // linux 需要先设置为可调整窗口大小才能全屏 if (isFullscreen) { browserWindow.setResizable(isFullscreen) browserWindow.setFullScreen(isFullscreen) } else { browserWindow.setFullScreen(isFullscreen) - browserWindow.setResizable(isFullscreen) + // windows/linux need to set resizable to true after exiting full screen + if (!isMac) browserWindow.setResizable(isFullscreen) } } else { browserWindow.setFullScreen(isFullscreen) diff --git a/src/renderer/App.vue b/src/renderer/App.vue index c9151f4c..99ac2b9b 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -99,8 +99,11 @@ body { .disableTransparent { background-color: var(--color-content-background); - #body { - border: 1Px solid var(--color-primary-light-500); + &.linux #body { + border: 1px solid var(--color-primary-light-500); + } + &.windows:not(.windows-11, .fullscreen) #body { + border-top: 1px solid #aaa; } #right { diff --git a/src/renderer/index.html b/src/renderer/index.html index bbfcedbd..ea0b85e1 100644 --- a/src/renderer/index.html +++ b/src/renderer/index.html @@ -15,31 +15,35 @@