From 58490e39d3a4ee185baeff62b6fb494067ad8ed2 Mon Sep 17 00:00:00 2001 From: lecepin <383810086@qq.com> Date: Sun, 22 May 2022 13:59:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20win=E6=89=A7=E8=A1=8C=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E7=A9=BA=E6=A0=BC=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- electron/cert.js | 27 ++++++++++++++------------- package.json | 4 ++-- src/App.jsx | 8 ++++++++ 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/electron/cert.js b/electron/cert.js index 459bb3c..96d7129 100644 --- a/electron/cert.js +++ b/electron/cert.js @@ -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); - } else { - fs.writeFileSync(CONFIG.INSTALL_CERT_FLAG, ''); - resolve(stdout); - } - }, - ); + 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 { + reject(); + } }); } } diff --git a/package.json b/package.json index ec83e3d..9db6b7e 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/src/App.jsx b/src/App.jsx index 2e77ffc..259502d 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -139,6 +139,14 @@ function App() { ) : null} + {state.matches('开启服务失败') ? ( +