fix(win7): 降到 Electron 22.3.27 —— Windows 7 只支持到 Electron 22
会议室那台电脑是 Windows 7 x64。Electron 从 23 起不再支持 Windows 7/8/8.1
(Chromium 用到了 Win7 没有的 API,典型报错是 GetPackageFamilyName 找不到入口点)。
客观对比(同一份代码、只换 Electron 版本,用 file 读 PE 子系统版本):
Electron 38 → PE32+ executable for MS Windows 10.00 ← 声明需要 Win10
Electron 22 → PE32+ executable for MS Windows 5.02 ← 兼容到 XP 时代
代码零改动(我们只用基础 API:BrowserWindow frame/resizable/setAlwaysOnTop/setBounds、
screen.getAllDisplays、contextBridge、ipcMain/ipcRenderer);152 条测试不受影响。
Electron 22 在 Windows 10/11 上同样能跑,所以这一版两边通吃,只是**不能让 Win7 用 38**。
⚠️ 以后想升级 Electron 的话:23 以上会议室那台就起不来了。
This commit is contained in:
1 parent
9c7081b21d
commit
0daa912ee1
4 files changed
+44
-33
No files matched your search
+23
-7
@@ -130,17 +130,19 @@ npm run selftest # GUI 自检:electron . --selftest,跑完出截图
|
||||
:: electron 的 postinstall 会去下载运行时,网络不通时会把整个 install 拖垮
|
||||
pnpm install --ignore-scripts
|
||||
|
||||
:: 2) 运行时:把 electron-v38.2.2-win32-x64.zip 手工解压到位
|
||||
:: 2) 运行时:把 electron-v22.3.27-win32-x64.zip 手工解压到位
|
||||
:: 下载(能在上网的机器上先把 zip 下好再传过来最稳):
|
||||
:: https://npmmirror.com/mirrors/electron/22.3.27/electron-v22.3.27-win32-x64.zip
|
||||
:: ⚠️ node_modules/electron 是 pnpm 的**符号链接**,tar 拒绝"穿过符号链接"解压
|
||||
:: → 先解到临时目录,再 robocopy 进去
|
||||
mkdir D:\tmp\electron-dist
|
||||
cd /d D:\tmp\electron-dist && tar -xf D:\tmp\electron-win-x64.zip
|
||||
robocopy D:\tmp\electron-dist <项目>\node_modules\electron\dist /E
|
||||
mkdir D:\tmp\electron22-dist
|
||||
cd /d D:\tmp\electron22-dist && tar -xf D:\tmp\electron-v22.3.27-win32-x64.zip
|
||||
robocopy D:\tmp\electron22-dist <项目>\node_modules\electron\dist /E
|
||||
|
||||
:: 3) 出包:直接调 electron-builder 的 CLI(`pnpm run` 会先做依赖检查、可能 EPERM)
|
||||
:: 用 --config.electronDist 明确告诉它运行时在哪,别让它走下载分支
|
||||
node node_modules\electron-builder\out\cli\cli.js --win --x64 ^
|
||||
--config.electronDist=D:\tmp\electron-dist
|
||||
--config.electronDist=D:\tmp\electron22-dist
|
||||
|
||||
:: 4) 压缩:electron-builder 的 zip target 会去下 7zip 工具(见 6.3),自己压更稳
|
||||
cd dist && tar -a -c -f ClockLab-1.0.0-win-x64.zip win-unpacked
|
||||
@@ -188,7 +190,7 @@ tar -C dist -czf dist/ClockLab-1.0.0-linux-arm64.tar.gz ClockLab-1.0.0-linux-arm
|
||||
- 直连 GitHub:`%TEMP%` 里会堆一排 `electron-download-*` 重试目录直到失败;
|
||||
- npmmirror 镜像:`ELECTRON_MIRROR` 可用,但它在拼 `SHASUMS256.txt` 时可能 404;
|
||||
- gh 加速站(`gh-proxy.com`):实测 403;
|
||||
- **最稳**:**在能上网的机器上把 zip 下好**(`https://npmmirror.com/mirrors/electron/38.2.2/electron-v38.2.2-<平台>.zip`),再传过去手工放。
|
||||
- **最稳**:**在能上网的机器上把 zip 下好**(`https://npmmirror.com/mirrors/electron/22.3.27/electron-v22.3.27-<平台>.zip`),再传过去手工放。
|
||||
|
||||
**④ pnpm 11 的 `strictDepBuilds`**
|
||||
只要有依赖的构建脚本被跳过,`pnpm install` 会**直接以退出码 1 失败**(`ERR_PNPM_IGNORED_BUILDS`),而 electron 的 postinstall 正是下载运行时那一步。放行写在 `pnpm-workspace.yaml` 的 `allowBuilds`(`package.json` 的 `pnpm` 字段与 `.npmrc` 的 `onlyBuiltDependencies` 在 pnpm 11 已不生效),**这个文件别删**。
|
||||
@@ -198,7 +200,21 @@ tar -C dist -czf dist/ClockLab-1.0.0-linux-arm64.tar.gz ClockLab-1.0.0-linux-arm
|
||||
|
||||
---
|
||||
|
||||
## 七、已知可以再做的
|
||||
## 七、为什么锁在 Electron 22
|
||||
|
||||
`package.json` 里 Electron **故意锁在 `22.3.27`**(22 系列的最后一个补丁版),**不要"顺手升级"**。
|
||||
|
||||
原因:**Electron 23 起彻底不支持 Windows 7 / 8 / 8.1**。官方在 [Windows 7/8/8.1 弃用公告](https://electronjs.org/blog/windows-7-to-8-1-deprecation-notice) 里写明,23 用的 Chromium 调用了 Win7 没有的系统 API,程序在 Win7 上一启动就报:
|
||||
|
||||
```
|
||||
GetProcedureEntryPoint GetPackageFamilyName ... KERNEL32.dll
|
||||
```
|
||||
|
||||
`GetPackageFamilyName` 这类是 Windows 8+ 才有的入口,Win7 的 `kernel32.dll` 里没有,加载器直接失败。
|
||||
|
||||
Electron **22.3.27** 是最后一个支持 Win7 的版本(Chromium 108 / Node 16)。本项目要跑在会议室那台 **Windows 7 x64** 上,所以必须锁在这一版;Windows 10/11 也照常能跑,不受影响。升级 Electron 之前先确认那台机器还需不需要 Win7 —— 还想保 Win7 就不能越过 22。
|
||||
|
||||
## 八、已知可以再做的
|
||||
|
||||
- **Windows 的 portable 单文件 exe** 还没做成(卡在 6.3 ① 的 7zip 工具那条路)—— 绿色版 zip 功能等价,只是多一步解压;
|
||||
- **飞腾平台(LoongArch 不是 ARM64)不支持** —— 本项目产出的是 ARM64,龙芯需要另找运行时;
|
||||
|
||||
@@ -66,6 +66,8 @@
|
||||
|
||||
解压 `ClockLab-1.0.0-win-x64.zip`,双击里面的 **`ClockLab.exe`**。绿色版,不写注册表、不需要安装。
|
||||
|
||||
> 兼容性:这一版把运行时锁在 **Electron 22**,是最后一个支持 **Windows 7** 的版本;**Windows 10 / 11** 同样可以用。
|
||||
|
||||
### Linux(ARM64)
|
||||
|
||||
```bash
|
||||
|
||||
+2
-2
@@ -14,8 +14,8 @@
|
||||
"dist:linux": "electron-builder --linux --arm64"
|
||||
},
|
||||
"devDependencies": {
|
||||
"electron": "38.2.2",
|
||||
"electron-builder": "26.15.3"
|
||||
"electron": "22.3.27",
|
||||
"electron-builder": "26.16.1"
|
||||
},
|
||||
"build": {
|
||||
"appId": "com.askasoft.clocklab",
|
||||
|
||||
Generated
+17
-24
@@ -9,8 +9,8 @@ importers:
|
||||
.:
|
||||
devDependencies:
|
||||
electron:
|
||||
specifier: 38.2.2
|
||||
version: 38.2.2(supports-color@7.1.0)
|
||||
specifier: 22.3.27
|
||||
version: 22.3.27(supports-color@7.1.0)
|
||||
electron-builder:
|
||||
specifier: 26.16.1
|
||||
version: 26.16.1(electron-builder-squirrel-windows@26.16.1)(supports-color@7.1.0)
|
||||
@@ -130,8 +130,8 @@ packages:
|
||||
'@types/ms@2.1.0':
|
||||
resolution: {integrity: sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==}
|
||||
|
||||
'@types/node@22.20.2':
|
||||
resolution: {integrity: sha512-xlvWf4Vs9n1PEVYwP1n4vvG07M6y8WgvJ2t0vbrWTmijsIHp1cS+uJ2kMIRdY3nHZK0nCYKrPeD171+SzF4/zw==}
|
||||
'@types/node@16.11.26':
|
||||
resolution: {integrity: sha512-GZ7bu5A6+4DtG7q9GsoHXy3ALcgeIHP4NnL0Vv2wu0uUB/yQex26v0tf6/na1mm0+bS9Uw+0DFex7aaKr2qawQ==}
|
||||
|
||||
'@types/node@26.5.1':
|
||||
resolution: {integrity: sha512-CzNm2FezW4VR/LjG6yUdiEgLE/rAQ9Slj5gCu/C2VrdcW7I0ahNZ8DRbHT7zOZ6r3ONgd/bsQIeSaoDGrd1C6g==}
|
||||
@@ -411,8 +411,8 @@ packages:
|
||||
resolution: {integrity: sha512-bO3y10YikuUwUuDUQRM4KfwNkKhnpVO7IPdbsrejwN9/AABJzzTQ4GeHwyzNSrVO+tEH3/Np255a3sVZpZDjvg==}
|
||||
engines: {node: '>=8.0.0'}
|
||||
|
||||
electron@38.2.2:
|
||||
resolution: {integrity: sha512-OXSaVNXDlonXDjMRsFNQo1j5tzTKwKXh5/m46IjAFccBcZJZMISI+EjSI07oexIuhvKM8AZLuFuihVn4YjWWrA==}
|
||||
electron@22.3.27:
|
||||
resolution: {integrity: sha512-7Rht21vHqj4ZFRnKuZdFqZFsvMBCmDqmjetiMqPtF+TmTBiGne1mnstVXOA/SRGhN2Qy5gY5bznJKpiqogjM8A==}
|
||||
engines: {node: '>= 12.20.55'}
|
||||
hasBin: true
|
||||
|
||||
@@ -1035,9 +1035,6 @@ packages:
|
||||
resolution: {integrity: sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
undici-types@6.21.0:
|
||||
resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==}
|
||||
|
||||
undici-types@8.9.0:
|
||||
resolution: {integrity: sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg==}
|
||||
|
||||
@@ -1279,7 +1276,7 @@ snapshots:
|
||||
dependencies:
|
||||
'@types/http-cache-semantics': 4.2.0
|
||||
'@types/keyv': 3.1.4
|
||||
'@types/node': 22.20.2
|
||||
'@types/node': 26.5.1
|
||||
'@types/responselike': 1.0.3
|
||||
|
||||
'@types/debug@4.1.13':
|
||||
@@ -1300,18 +1297,16 @@ snapshots:
|
||||
|
||||
'@types/keyv@3.1.4':
|
||||
dependencies:
|
||||
'@types/node': 22.20.2
|
||||
'@types/node': 26.5.1
|
||||
|
||||
'@types/minimatch@6.0.0':
|
||||
dependencies:
|
||||
minimatch: 3.1.5
|
||||
minimatch: 10.2.6
|
||||
optional: true
|
||||
|
||||
'@types/ms@2.1.0': {}
|
||||
|
||||
'@types/node@22.20.2':
|
||||
dependencies:
|
||||
undici-types: 6.21.0
|
||||
'@types/node@16.11.26': {}
|
||||
|
||||
'@types/node@26.5.1':
|
||||
dependencies:
|
||||
@@ -1319,11 +1314,11 @@ snapshots:
|
||||
|
||||
'@types/responselike@1.0.3':
|
||||
dependencies:
|
||||
'@types/node': 22.20.2
|
||||
'@types/node': 26.5.1
|
||||
|
||||
'@types/yauzl@2.10.3':
|
||||
dependencies:
|
||||
'@types/node': 22.20.2
|
||||
'@types/node': 26.5.1
|
||||
optional: true
|
||||
|
||||
'@xmldom/xmldom@0.8.15': {}
|
||||
@@ -1686,10 +1681,10 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
electron@38.2.2(supports-color@7.1.0):
|
||||
electron@22.3.27(supports-color@7.1.0):
|
||||
dependencies:
|
||||
'@electron/get': 2.0.0(supports-color@7.1.0)
|
||||
'@types/node': 22.20.2
|
||||
'@types/node': 16.11.26
|
||||
extract-zip: 2.0.1(supports-color@7.1.0)
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
@@ -2052,11 +2047,11 @@ snapshots:
|
||||
|
||||
node-abi@4.35.0:
|
||||
dependencies:
|
||||
semver: 7.7.4
|
||||
semver: 7.8.5
|
||||
|
||||
node-api-version@0.2.1:
|
||||
dependencies:
|
||||
semver: 7.7.4
|
||||
semver: 7.8.5
|
||||
|
||||
node-gyp@12.4.0:
|
||||
dependencies:
|
||||
@@ -2065,7 +2060,7 @@ snapshots:
|
||||
graceful-fs: 4.2.11
|
||||
nopt: 9.0.0
|
||||
proc-log: 6.0.0
|
||||
semver: 7.7.4
|
||||
semver: 7.8.5
|
||||
tar: 7.5.22
|
||||
tinyglobby: 0.2.17
|
||||
undici: 6.28.1
|
||||
@@ -2333,8 +2328,6 @@ snapshots:
|
||||
type-fest@0.13.1:
|
||||
optional: true
|
||||
|
||||
undici-types@6.21.0: {}
|
||||
|
||||
undici-types@8.9.0: {}
|
||||
|
||||
undici@6.28.1: {}
|
||||
|
||||
Reference in new issue
Block a user