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" "lerna": "^3.22.1"
}, },
"dependencies": { "dependencies": {
} },
"version": "1.0.2"
} }

4
packages/core/package.json

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

6
packages/gui/package.json

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

26
packages/gui/src/background.js

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

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

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

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

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

2
packages/mitmproxy/package.json

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

Loading…
Cancel
Save