Browse Source

refactor: 1.0.2

pull/180/head
xiaojunnuo 4 years ago
parent
commit
8eeb6d0a13
  1. 3
      package.json
  2. 4
      packages/core/package.json
  3. 6
      packages/gui/package.json
  4. 26
      packages/gui/src/background.js
  5. 10
      packages/gui/src/bridge/index.js
  6. 2
      packages/gui/src/bridge/update-handle.js
  7. 2
      packages/mitmproxy/package.json

3
package.json

@ -6,5 +6,6 @@
"lerna": "^3.22.1"
},
"dependencies": {
}
},
"version": "1.0.2"
}

4
packages/core/package.json

@ -1,6 +1,6 @@
{
"name": "@docmirror/dev-sidecar",
"version": "1.0.1",
"version": "1.0.2",
"description": "给开发者的加速代理工具",
"main": "src/index.js",
"keywords": ["dev-sidecar","github加速","google加速","代理"],
@ -35,7 +35,7 @@
"util": "^0.12.3",
"validator": "^13.1.17",
"winreg": "^1.2.4",
"@docmirror/mitmproxy": "1.0.1"
"@docmirror/mitmproxy": "1.0.2"
},
"devDependencies": {
"@vue/cli-plugin-eslint": "~4.5.0",

6
packages/gui/package.json

@ -1,6 +1,6 @@
{
"name": "@docmirror/dev-sidecar-gui",
"version": "1.0.1",
"version": "1.0.2",
"private": false,
"license": "MPL-2.0",
"scripts": {
@ -14,8 +14,8 @@
},
"main": "background.js",
"dependencies": {
"@docmirror/dev-sidecar": "1.0.1",
"@docmirror/mitmproxy": "1.0.1",
"@docmirror/dev-sidecar": "1.0.2",
"@docmirror/mitmproxy": "1.0.2",
"ant-design-vue": "^1.6.5",
"core-js": "^3.6.5",
"electron-store": "^6.0.1",

26
packages/gui/src/background.js

@ -111,24 +111,31 @@ function createWindow () {
}
function quit (app) {
bridge.devSidecar.api.shutdown().then(() => {
app.quit()
})
if (tray) {
tray.displayBalloon({ title: '正在关闭,请稍候...', content: '正在关闭中,请稍候。。。' })
}
app.quit()
}
// -------------执行开始---------------
const isFirstInstance = app.requestSingleInstanceLock()
let isShutdown = false
if (!isFirstInstance) {
console.log('is second instance')
setTimeout(() => {
app.quit()
}, 1000)
} else {
app.on('before-quit', async (event) => {
console.log('before-quit', event)
if (!isShutdown) {
event.preventDefault()
if (tray) {
tray.displayBalloon({ title: '正在关闭,请稍候...', content: '正在关闭中,请稍候。。。' })
}
await bridge.devSidecar.api.shutdown()
isShutdown = true
app.quit()
}
})
app.on('second-instance', (event, commandLine, workingDirectory) => {
console.log('new app started', commandLine)
if (win) {
@ -169,14 +176,15 @@ if (!isFirstInstance) {
createWindow()
bridge.init(win)
let updateUrl = 'https://update-dev-sidecar.docmirror.cn/update/'
let updateUrl = 'https://dev-sidecar.docmirror.cn/update/'
if (process.env.NODE_ENV === 'development') {
Object.defineProperty(app, 'isPackaged', {
get () {
return true
}
})
updateUrl = 'http://localhost/dev-sidecar/'
updateUrl = 'https://dev-sidecar.docmirror.cn/update/'
// updateUrl = 'http://localhost/dev-sidecar/'
}
updateHandle(win, updateUrl)
try {

10
packages/gui/src/bridge/index.js

@ -4,6 +4,7 @@ import { ipcMain, Menu } from 'electron'
import fs from 'fs'
import JSON5 from 'json5'
import path from 'path'
const pk = require('../../package.json')
const mitmproxyPath = path.join(__dirname, 'mitmproxy.js')
const localApi = {
/**
@ -19,6 +20,14 @@ const localApi = {
// console.log('api list:', list)
return list
},
info: {
get () {
console.log(pk)
return {
version: pk.version
}
}
},
/**
* 软件设置
*/
@ -30,7 +39,6 @@ const localApi = {
}
const file = fs.readFileSync(settingPath)
const setting = JSON5.parse(file.toString())
console.log('read file,', file.toString(), setting)
return setting || {}
},
save (setting = {}) {

2
packages/gui/src/bridge/update-handle.js

@ -67,7 +67,7 @@ function updateHandle (win, updateUrl) {
ipcMain.on('update', (e, arg) => {
if (arg.key === 'doUpdateNow') {
// some code here to handle event
autoUpdater.quitAndInstall(true, true)
autoUpdater.quitAndInstall()
} else if (arg.key === 'checkForUpdate') {
// 执行自动更新检查
console.log('autoUpdater checkForUpdates')

2
packages/mitmproxy/package.json

@ -1,6 +1,6 @@
{
"name": "@docmirror/mitmproxy",
"version": "1.0.1",
"version": "1.0.2",
"description": "",
"main": "src/index.js",
"keywords": [

Loading…
Cancel
Save