fix: win执行路径空格问题

This commit is contained in:
lecepin 2022-05-22 13:59:17 +08:00
parent da65630e86
commit 58490e39d3
3 changed files with 24 additions and 15 deletions

View File

@ -2,8 +2,8 @@ import CONFIG from './const';
import mkdirp from 'mkdirp';
import fs from 'fs';
import path from 'path';
import sudo from 'sudo-prompt';
import { clipboard, dialog } from 'electron';
import spawn from 'cross-spawn';
export function checkCertInstalled() {
return fs.existsSync(CONFIG.INSTALL_CERT_FLAG);
@ -30,18 +30,19 @@ export async function installCert(checkInstalled = true) {
});
} else {
return new Promise((resolve, reject) => {
sudo.exec(
`${CONFIG.WIN_CERT_INSTALL_HELPER} -c -add ${CONFIG.CERT_PUBLIC_PATH} -s root`,
{ name: CONFIG.APP_EN_NAME },
(error, stdout) => {
if (error) {
reject(error);
const result = spawn.sync(CONFIG.WIN_CERT_INSTALL_HELPER, [
'-c',
'-add',
CONFIG.CERT_PUBLIC_PATH,
'-s',
'root',
]);
if (result.stdout.toString().indexOf('Succeeded') > -1) {
resolve();
} else {
fs.writeFileSync(CONFIG.INSTALL_CERT_FLAG, '');
resolve(stdout);
reject();
}
},
);
});
}
}

View File

@ -52,6 +52,7 @@
"@xstate/react": "^3.0.0",
"antd": "^4.20.5",
"axios": "^0.27.2",
"cross-spawn": "^7.0.3",
"electron-is-dev": "^2.0.0",
"electron-log": "^4.4.7",
"get-port": "^6.1.2",
@ -63,7 +64,6 @@
"react-dom": "^18.1.0",
"regedit": "5.0.0",
"semver": "^7.3.7",
"sudo-prompt": "^9.2.1",
"xstate": "^4.32.1"
},
"author": "lecepin",
@ -74,7 +74,7 @@
},
"build": {
"extends": null,
"productName": "Lecepin WeChatVideoDownloader",
"productName": "WeChatVideoDownloader",
"appId": "com.lecepin.WeChatVideoDownloader",
"directories": {
"output": "packs"

View File

@ -139,6 +139,14 @@ function App() {
</Button>
</div>
) : null}
{state.matches('开启服务失败') ? (
<div className="App-uninit">
<Alert message="开启服务失败,请允许开启" type="error" showIcon closable={false} />
<Button size="large" onClick={() => send('e_重试')} type="primary">
尝试开启
</Button>
</div>
) : null}
</div>
);
}