我的 build/installer.nsh 文件中有以下脚本,用于在卸载时删除文件。
!macro customUnInstall
SetShellVarContext current
Delete "$LocalAppdata\MyUI\.settings.db"
Delete "$LocalAppdata\MyUI\.contrib.db"
!macroend
但是,安装时也会删除以下文件。这是我的 package.json 的 nsis 部分的样子:
"nsis": {
"oneClick": false,
"uninstallDisplayName": "Equella Sync Uninstaller",
"allowToChangeInstallationDirectory": true,
"deleteAppDataOnUninstall": true,
"runAfterFinish": true,
"createDesktopShortcut": true,
"createStartMenuShortcut": true,
"perMachine": true,
"license": "license.txt",
"include": "build/installer.nsh",
"installerIcon": "build/gadoeicon.ico"
}
任何帮助将不胜感激。
如果 Electron 是偷偷摸摸的,并且还在您的安装程序中插入了宏,那么您可以通过以下方式解决这个问题:
!macro customUnInstall
!ifdef __UNINSTALL__
SetShellVarContext current
Delete "$LocalAppdata\MyUI\.settings.db"
Delete "$LocalAppdata\MyUI\.contrib.db"
SetShellVarContext lastused
!endif
!macroend
但是当您在现有安装之上安装时,它更有可能运行以前的卸载程序。我假设有一种方法可以禁用它,但我对 Electron builder 一无所知,所以我不能告诉你要设置哪个 JSON 属性。
快速查看他们的来源确实表明您可以检查
$CMDLINE
在/KEEP_APP_DATA
中的customUnInstall
。