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,龙芯需要另找运行时;
|
||||
|
||||
Reference in new issue
Block a user