From d2f5485996ad13e71a0908e0838f6dc275783529 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Sat, 19 Sep 2026 00:50:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20Windows=20=E6=97=A7?= =?UTF-8?q?=E7=89=88=E6=8F=90=E7=A4=BA=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=8F=90?= =?UTF-8?q?=E9=86=92=E7=94=A8=E6=88=B7=E5=8D=87=E7=BA=A7=E8=87=B3=E6=96=B0?= =?UTF-8?q?=E7=89=88=E7=B3=BB=E7=BB=9F=E4=BB=A5=E6=8F=90=E9=AB=98=E5=AE=89?= =?UTF-8?q?=E5=85=A8=E6=80=A7=E5=92=8C=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build-config/main/webpack.config.prod.js | 1 + src/main/index.ts | 1 + src/main/utils/winLegacy.ts | 44 ++++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 src/main/utils/winLegacy.ts diff --git a/build-config/main/webpack.config.prod.js b/build-config/main/webpack.config.prod.js index f8dd9256..7ec5d61b 100644 --- a/build-config/main/webpack.config.prod.js +++ b/build-config/main/webpack.config.prod.js @@ -37,6 +37,7 @@ module.exports = merge(baseConfig, { new webpack.DefinePlugin({ 'process.env': { NODE_ENV: '"production"', + BUILD_WIN7: `'${process.env.BUILD_WIN7}'`, }, }), ], diff --git a/src/main/index.ts b/src/main/index.ts index c5a6bc52..318846b2 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -16,6 +16,7 @@ import registerModules from '@main/modules' // 初始化应用 const init = () => { console.log('init') + if (process.env.BUILD_WIN7 == 'true') import('./utils/winLegacy') void initAppSetting().then(() => { registerModules() global.lx.event_app.app_inited() diff --git a/src/main/utils/winLegacy.ts b/src/main/utils/winLegacy.ts new file mode 100644 index 00000000..a7b3b51e --- /dev/null +++ b/src/main/utils/winLegacy.ts @@ -0,0 +1,44 @@ +import os from 'node:os' + +import { dialog } from 'electron' +import { STORE_NAMES } from '@common/constants' +import getStore from '@main/utils/store' +import { openUrl } from '@common/utils/electron' + + +const showWinLegacyMessage = () => { + if (process.platform !== 'win32') return + const storeKey = 'winLegacyMessageShown' + const dataStore = getStore(STORE_NAMES.DATA) + const count = dataStore.get(storeKey) || 0 + if (count > 2) return + const osVersion = os.release() + const majorVersion = parseInt(osVersion.split('.')[0], 10) + const isOldWindows = majorVersion < 10 + + if (isOldWindows) { + const result = dialog.showMessageBoxSync({ + type: 'warning', + title: 'Windows 旧版提示', + message: '您正在使用专为旧版 Windows 准备的 Any Listen,它仅用于实在无法升级到新版系统的用户。\n该版本缺乏安全更新,可能存在安全风险,并且功能未经测试,可能存在兼容性问题。\n\n如果您的设备支持 Windows 10 或更高版本,强烈建议升级系统,切换到标准版本的 Any Listen,以获得更好的安全性和性能。', + buttons: ['知道了'], + }) + if (result === 0) { + dataStore.set(storeKey, count + 1) + } + } else { + const result = dialog.showMessageBoxSync({ + type: 'warning', + title: '您正在使用旧版', + message: '您正在使用专为旧版 Windows 准备的 Any Listen,它仅用于实在无法升级到新版系统的用户,但您的系统似乎在标准版的支持范围内,为了获得最佳体验,请切换到 Any Listen 的标准版本。\n\n注意:当前版本缺乏安全更新,可能存在安全风险,并且功能未经测试,可能存在兼容性问题。', + buttons: ['跳转新版发布页', '知道了'], + }) + if (result === 0) { + void openUrl('https://github.com/lyswhut/lx-music-desktop/releases') + } else if (result === 1) { + dataStore.set('winLegacyMessageShown', count + 1) + } + } +} + +showWinLegacyMessage()