fix(windows): NSIS 也注册 32-bit TSF DLL — 修 P1 review

Codex review 发现:windows_ime_profile.rs::inspect_windows_ime_registration() 同时
用 KEY_WOW64_64KEY 和 KEY_WOW64_32KEY 两次检查 HKLM\Software\Classes\CLSID\{...}\
InprocServer32,少了任一边就返回 RegistrationBroken("OpenLess 32-bit COM
registration is missing")。MSI 流程通过 wxs 同时跑了 64-bit 和 SysWOW64\regsvr32
注册两份;之前的 NSIS hook 只注册了 x64,所以 NSIS / updater 用户依然在 Settings
页看到「不可用」。

修复:
- bundle.resources 拆出 x64 / x86 两份 dll target;x64 → tsf-ime\x64,x86 → tsf-ime\x86
- installer.nsh PostInstall/PreUninstall 增加 x86 分支,
  x86 用 $WINDIR\SysWOW64\regsvr32.exe(写 KEY_WOW64_32KEY 必需)
- CI Build Windows IME native DLLs 步骤把复制 dll 移到循环里,x64 + x86 都覆盖
  仓库占位
- 仓库新增 0 字节 x86 占位 dll,让本地 mac/linux 构建也能 resolve resources
This commit is contained in:
baiqing committed 2026-05-06 10:47:03 +08:00
1 parent 5aec74653b
commit c52658b08b
4 files changed
+34 -15

No files matched your search

+10 -8
View File
@@ -212,15 +212,17 @@ jobs:
}
"$($t.EnvName)=$dll" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
Write-Host "[ok] built $dll (exported $($t.EnvName))"
}
# bundle.resources 引用的是 src-tauri/openless-ime-payload/x64/OpenLessIme.dll
# (仓库里 commit 的是 0 字节占位让 mac 本地 build 也能 resolve)。
# Windows CI 这里用真 x64 dll 覆盖占位,让 NSIS / MSI 包装的是真 dll。
$payloadDir = Join-Path $appRoot 'src-tauri\openless-ime-payload\x64'
New-Item -ItemType Directory -Force -Path $payloadDir | Out-Null
Copy-Item -Force -Path $env:OPENLESS_IME_DLL_X64 -Destination (Join-Path $payloadDir 'OpenLessIme.dll')
Write-Host "[ok] copied real x64 dll into bundle.resources payload path"
# bundle.resources 引用的是 src-tauri/openless-ime-payload/{x64,x86}/OpenLessIme.dll
# (仓库里 commit 的是 0 字节占位让 mac 本地 build 也能 resolve)。
# 这里用真 dll 覆盖占位,让 NSIS / MSI 都装上真文件;NSIS hook 的 regsvr32
# 同时会把 64 / 32 位 COM 注册到 HKLM\Software\Classes\CLSID 的
# KEY_WOW64_64KEY / KEY_WOW64_32KEY 两侧(windows_ime_profile.rs 都会查)。
$payloadDir = Join-Path $appRoot "src-tauri\openless-ime-payload\$($t.Folder)"
New-Item -ItemType Directory -Force -Path $payloadDir | Out-Null
Copy-Item -Force -Path $dll -Destination (Join-Path $payloadDir 'OpenLessIme.dll')
Write-Host "[ok] copied real $($t.Folder) dll into bundle.resources payload path"
}
# ── Windows tauri build:保持 bash shell,因为 PowerShell 调外部命令
# 会把 '{"bundle":...}' 的内部双引号吃掉、让 tauri 收到无效 JSON。
+22 -6
View File
@@ -5,25 +5,41 @@
; "设置 → 权限"页面看到 "Windows 输入法后端:不可用"。
;
; 这里的 hook 在 NSIS 安装/卸载流程里调 regsvr32 把 OpenLessIme.dll 注册到 HKLM。
; bundle.resources 把 DLL 拷到 $INSTDIR\tsf-ime\OpenLessIme.dll
; bundle.resources 把 x64 / x86 DLL 拷到 $INSTDIR\tsf-ime\{x64,x86}\OpenLessIme.dll
; (resources map 的 target 必须避开 wxs fragment 已声明的 windows-ime\x64\
; 路径,否则 MSI 包里同一路径会被两个 component 占用)。
; tauri.conf.json 的 nsis.installMode = "perMachine" 让 NSIS 以管理员身份运行
; (写 HKLM 必需)。
;
; 必须同时注册 x64 + x86 两份 dll:windows_ime_profile.rs 的
; inspect_windows_ime_registration() 会用 KEY_WOW64_64KEY 和 KEY_WOW64_32KEY 两次
; 检查 HKLM CLSID InprocServer32,少了任何一边都会被判 RegistrationBroken。
; - x64 用 $SYSDIR\regsvr32.exe (System32 = 64-bit on x64 Windows)
; - x86 用 $WINDIR\SysWOW64\regsvr32.exe (32-bit regsvr32 → 写 KEY_WOW64_32KEY)
;
; regsvr32 失败时不阻塞安装:用户仍可以靠 SendInput / 粘贴兜底完成上屏。
!macro NSIS_HOOK_POSTINSTALL
DetailPrint "Registering OpenLess TSF IME ..."
nsExec::ExecToLog '"$SYSDIR\regsvr32.exe" /s "$INSTDIR\tsf-ime\OpenLessIme.dll"'
DetailPrint "Registering OpenLess TSF IME (x64) ..."
nsExec::ExecToLog '"$SYSDIR\regsvr32.exe" /s "$INSTDIR\tsf-ime\x64\OpenLessIme.dll"'
Pop $0
${If} $0 != 0
DetailPrint "OpenLess TSF IME registration failed (exit $0); fallback insertion paths still work."
DetailPrint "OpenLess TSF IME x64 registration failed (exit $0); fallback insertion paths still work."
${EndIf}
DetailPrint "Registering OpenLess TSF IME (x86) ..."
nsExec::ExecToLog '"$WINDIR\SysWOW64\regsvr32.exe" /s "$INSTDIR\tsf-ime\x86\OpenLessIme.dll"'
Pop $0
${If} $0 != 0
DetailPrint "OpenLess TSF IME x86 registration failed (exit $0); fallback insertion paths still work."
${EndIf}
!macroend
!macro NSIS_HOOK_PREUNINSTALL
DetailPrint "Unregistering OpenLess TSF IME ..."
nsExec::ExecToLog '"$SYSDIR\regsvr32.exe" /s /u "$INSTDIR\tsf-ime\OpenLessIme.dll"'
DetailPrint "Unregistering OpenLess TSF IME (x86) ..."
nsExec::ExecToLog '"$WINDIR\SysWOW64\regsvr32.exe" /s /u "$INSTDIR\tsf-ime\x86\OpenLessIme.dll"'
Pop $0
DetailPrint "Unregistering OpenLess TSF IME (x64) ..."
nsExec::ExecToLog '"$SYSDIR\regsvr32.exe" /s /u "$INSTDIR\tsf-ime\x64\OpenLessIme.dll"'
Pop $0
!macroend
Whitespace-only changes.
+2 -1
View File
@@ -80,7 +80,8 @@
"icons/icon.ico"
],
"resources": {
"openless-ime-payload/x64/OpenLessIme.dll": "tsf-ime/OpenLessIme.dll"
"openless-ime-payload/x64/OpenLessIme.dll": "tsf-ime/x64/OpenLessIme.dll",
"openless-ime-payload/x86/OpenLessIme.dll": "tsf-ime/x86/OpenLessIme.dll"
},
"macOS": {
"minimumSystemVersion": "12.0",