Browse Source

refactor: 1

pull/88/head
xiaojunnuo 3 years ago
parent
commit
89d40ef0f4
  1. 15
      packages/core/src/shell/scripts/set-system-proxy/index.js
  2. 2
      packages/gui/.env
  3. 3
      packages/gui/package.json
  4. 2
      packages/gui/src/background.js
  5. 3
      packages/gui/src/bridge/update/backend.js
  6. 6
      packages/gui/src/bridge/update/front.js
  7. 19
      packages/gui/src/utils/util.apppath.js
  8. 5
      packages/gui/vue.config.js

15
packages/core/src/shell/scripts/set-system-proxy/index.js

@ -152,10 +152,25 @@ const executor = {
if (params == null) {
await exec(`networksetup -setwebproxystate '${wifiAdaptor}' off`)
await exec(`networksetup -setsecurewebproxystate '${wifiAdaptor}' off`)
// const removeEnv = `
// sed -ie '/export http_proxy/d' ~/.zshrc
// sed -ie '/export https_proxy/d' ~/.zshrc
// source ~/.zshrc
// `
// await exec(removeEnv)
} else {
const { ip, port } = params
await exec(`networksetup -setwebproxy '${wifiAdaptor}' ${ip} ${port}`)
await exec(`networksetup -setsecurewebproxy '${wifiAdaptor}' ${ip} ${port}`)
// const setEnv = `cat <<ENDOF >> ~/.zshrc
// export http_proxy="http://${ip}:${port}"
// export https_proxy="http://${ip}:${port}"
// ENDOF
// source ~/.zshrc
// `
// await exec(setEnv)
}
}
}

2
packages/gui/.env

@ -1,2 +1,2 @@
VUE_APP_PUBLISH_URL=http://dev-sidecar.docmirror.cn/update/
VUE_APP_PUBLISH_PROVIDER=generic
VUE_APP_PUBLISH_PROVIDER=generic

3
packages/gui/package.json

@ -1,6 +1,6 @@
{
"name": "@docmirror/dev-sidecar-gui",
"version": "1.6.0",
"version": "1.5.0",
"private": false,
"license": "MPL-2.0",
"main": "background.js",
@ -24,6 +24,7 @@
"@docmirror/mitmproxy": "^1.6.0",
"adm-zip": "^0.5.5",
"ant-design-vue": "^1.6.5",
"axios": "^0.21.1",
"compressing": "^1.5.1",
"core-js": "^3.6.5",
"electron-baidu-tongji": "^1.0.5",

2
packages/gui/src/background.js

@ -262,6 +262,6 @@ if (isDevelopment) {
// 系统关机和重启时的操作
process.on('exit', function () {
log.info('系统关机,退出app')
log.info('进程结束,退出app')
quit(app)
})

3
packages/gui/src/bridge/update/backend.js

@ -13,6 +13,7 @@ const isMac = process.platform === 'darwin'
const isLinux = process.platform === 'linux'
function downloadFile (uri, filePath, onProgress, onSuccess, onError) {
logger.info('download url', uri)
progress(request(uri), {
// throttle: 2000, // Throttle the progress event to 2000ms, defaults to 1000ms
// delay: 1000, // Only start to emit after 1000ms delay, defaults to 0ms
@ -55,7 +56,7 @@ function updateHandle (app, api, win, beforeQuit, quit, log) {
// url: publishUrl
// })
if (isMac) {
// autoUpdater.updateConfigPath = path.join(__dirname, 'mac/DevSidecar.app/Contents/Resources/app-update.yml')
autoUpdater.updateConfigPath = path.join(__dirname, 'mac/dev-sidecar.app/Contents/Resources/app-update.yml')
} else if (isLinux) {
autoUpdater.updateConfigPath = path.join(__dirname, 'linux-unpacked/resources/app-update.yml')
} else {

6
packages/gui/src/bridge/update/front.js

@ -57,8 +57,8 @@ function install (app, api) {
function goManualUpdate (value) {
app.$confirm({
title: '暂不支持自动升级',
cancelText: 'cancel',
okText: 'ok',
cancelText: '取消',
okText: '确定',
content: h => {
function openGithubUrl () {
api.ipc.openExternal('https://github.com/docmirror/dev-sidecar/releases')
@ -145,11 +145,9 @@ function install (app, api) {
}
},
onOk () {
console.log('OK')
api.update.doUpdateNow()
},
onCancel () {
console.log('Cancel')
}
})
}

19
packages/gui/src/utils/util.apppath.js

@ -1,7 +1,26 @@
import path from 'path'
import os from 'os'
function getSystemPlatform () {
switch (os.platform()) {
case 'darwin':
return 'mac'
case 'linux':
return 'linux'
case 'win32':
return 'windows'
case 'win64':
return 'windows'
case 'unknown os':
default:
throw new Error(`UNKNOWN OS TYPE ${os.platform()}`)
}
}
export default {
getAppRootPath (app) {
const exePath = app.getPath('exe')
if (getSystemPlatform() === 'mac') {
return path.join(exePath, '../../')
}
return path.join(exePath, '../')
}
}

5
packages/gui/vue.config.js

@ -61,7 +61,10 @@ module.exports = {
allowToChangeInstallationDirectory: true
},
mac: {
icon: './build/mac/icon.icns'
icon: './build/mac/icon.icns',
target: [
'dmg'
]
},
win: {
requestedExecutionLevel: 'requireAdministrator'

Loading…
Cancel
Save