diff --git a/packages/core/src/config/index.js b/packages/core/src/config/index.js index 927030b1..c0018d45 100644 --- a/packages/core/src/config/index.js +++ b/packages/core/src/config/index.js @@ -11,7 +11,10 @@ function getRootCaKeyPath () { } module.exports = { app: { - mode: 'default' + mode: 'default', + autoStart: { + enabled: false + } }, server: { enabled: true, diff --git a/packages/gui/src/bridge/auto-start/backend.js b/packages/gui/src/bridge/auto-start/backend.js new file mode 100644 index 00000000..e40c9aa7 --- /dev/null +++ b/packages/gui/src/bridge/auto-start/backend.js @@ -0,0 +1,29 @@ +export default { + install (context) { + const { ipcMain, dialog, log, app } = context + + const ex = process.execPath + + // 定义事件,渲染进程中直接使用 + + // 开启 开机自启动 + ipcMain.on('auto-start', (event, message) => { + console.log('updateExe', ex) + if (message.value) { + app.setLoginItemSettings({ + openAtLogin: true, + path: ex, + args: [] + }) + event.sender.send('auto-start', { key: 'enabled', value: true }) + } else { + app.setLoginItemSettings({ + openAtLogin: false, + path: ex, + args: [] + }) + event.sender.send('auto-start', { key: 'enabled', value: false }) + } + }) + } +} diff --git a/packages/gui/src/bridge/auto-start/front.js b/packages/gui/src/bridge/auto-start/front.js new file mode 100644 index 00000000..2e1a4f2a --- /dev/null +++ b/packages/gui/src/bridge/auto-start/front.js @@ -0,0 +1,19 @@ + +function install (app, api) { + api.ipc.on('auto-start', (event, message) => { + if (message.value === true) { + app.$message.info('已添加开机自启') + } else { + app.$message.info('已取消开机自启') + } + }) + api.autoStart = { + async enabled (value) { + api.ipc.send('auto-start', { key: 'enabled', value }) + } + } +} + +export default { + install +} diff --git a/packages/gui/src/bridge/backend.js b/packages/gui/src/bridge/backend.js index 39764669..041e878e 100644 --- a/packages/gui/src/bridge/backend.js +++ b/packages/gui/src/bridge/backend.js @@ -2,12 +2,14 @@ import api from './api/backend' import tongji from './tongji/backend' import update from './update/backend' import fileSelector from './file-selector/backend' +import autoStart from './auto-start/backend' const modules = { api, // 核心接口模块 fileSelector, // 文件选择模块 tongji, // 统计模块 - update // 自动更新 + update, // 自动更新 + autoStart } export default { install (context) { diff --git a/packages/gui/src/bridge/front.js b/packages/gui/src/bridge/front.js index 18e360a1..1df8e863 100644 --- a/packages/gui/src/bridge/front.js +++ b/packages/gui/src/bridge/front.js @@ -3,13 +3,15 @@ import error from './error/front' import tongji from './tongji/front' import update from './update/front' import fileSelector from './file-selector/front' +import autoStart from './auto-start/front' const modules = { // api, // 核心接口模块 error, fileSelector, // 文件选择模块 tongji, // 统计模块 - update // 自动更新 + update, // 自动更新 + autoStart } export default { install (app, api, router) { diff --git a/packages/gui/src/view/pages/setting.vue b/packages/gui/src/view/pages/setting.vue new file mode 100644 index 00000000..7f8acb62 --- /dev/null +++ b/packages/gui/src/view/pages/setting.vue @@ -0,0 +1,50 @@ + + + + diff --git a/packages/gui/src/view/router/index.js b/packages/gui/src/view/router/index.js index 8e250518..fc93433f 100644 --- a/packages/gui/src/view/router/index.js +++ b/packages/gui/src/view/router/index.js @@ -4,6 +4,7 @@ import Proxy from '../pages/proxy' import Node from '../pages/plugin/node' import Git from '../pages/plugin/git' import Overwall from '../pages/plugin/overwall' +import Setting from '../pages/setting' const routes = [ { path: '/', redirect: '/index' }, @@ -12,7 +13,8 @@ const routes = [ { path: '/proxy', component: Proxy }, { path: '/plugin/node', component: Node }, { path: '/plugin/git', component: Git }, - { path: '/plugin/overwall', component: Overwall } + { path: '/plugin/overwall', component: Overwall }, + { path: '/setting', component: Setting } ] diff --git a/packages/gui/src/view/router/menu.js b/packages/gui/src/view/router/menu.js index f1440bb6..13945c56 100644 --- a/packages/gui/src/view/router/menu.js +++ b/packages/gui/src/view/router/menu.js @@ -7,6 +7,7 @@ export default function createMenus (app) { { title: '首页', path: '/index', icon: 'home' }, { title: '加速服务', path: '/server', icon: 'thunderbolt' }, { title: '系统代理', path: '/proxy', icon: 'deployment-unit' }, + { title: '设置', path: '/setting', icon: 'setting' }, { title: '应用', path: '/plugin', diff --git a/packages/gui/yarn.lock b/packages/gui/yarn.lock index 2de1f861..93eea7e8 100644 --- a/packages/gui/yarn.lock +++ b/packages/gui/yarn.lock @@ -3514,7 +3514,7 @@ commander@2.17.x: resolved "https://registry.npm.taobao.org/commander/download/commander-2.17.1.tgz?cache=0&sync_timestamp=1598576116597&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcommander%2Fdownload%2Fcommander-2.17.1.tgz" integrity sha1-vXerfebelCBc6sxy8XFtKfIKd78= -commander@^2.18.0, commander@^2.2.0, commander@^2.20.0, commander@^2.9.0: +commander@^2.18.0, commander@^2.20.0, commander@^2.9.0: version "2.20.3" resolved "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz" integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== @@ -7082,11 +7082,6 @@ lie@~3.3.0: dependencies: immediate "~3.0.5" -limiter@^1.0.5: - version "1.1.5" - resolved "https://registry.npm.taobao.org/limiter/download/limiter-1.1.5.tgz#8f92a25b3b16c6131293a0cc834b4a838a2aa7c2" - integrity sha1-j5KiWzsWxhMSk6DMg0tKg4oqp8I= - lines-and-columns@^1.1.6: version "1.1.6" resolved "https://registry.npm.taobao.org/lines-and-columns/download/lines-and-columns-1.1.6.tgz" @@ -10132,14 +10127,6 @@ stream-shift@^1.0.0: resolved "https://registry.npm.taobao.org/stream-shift/download/stream-shift-1.0.1.tgz" integrity sha1-1wiCgVWasneEJCebCHfaPDktWj0= -stream-throttle@^0.1.3: - version "0.1.3" - resolved "https://registry.npm.taobao.org/stream-throttle/download/stream-throttle-0.1.3.tgz#add57c8d7cc73a81630d31cd55d3961cfafba9c3" - integrity sha1-rdV8jXzHOoFjDTHNVdOWHPr7qcM= - dependencies: - commander "^2.2.0" - limiter "^1.0.5" - streamroller@^2.2.4: version "2.2.4" resolved "https://registry.npmjs.org/streamroller/-/streamroller-2.2.4.tgz" diff --git a/packages/mitmproxy/src/lib/dns/lookup.js b/packages/mitmproxy/src/lib/dns/lookup.js new file mode 100644 index 00000000..5b2f3414 --- /dev/null +++ b/packages/mitmproxy/src/lib/dns/lookup.js @@ -0,0 +1,5 @@ +module.exports = { + lookup () { + + } +} diff --git a/packages/mitmproxy/src/lib/proxy/mitmproxy/createRequestHandler.js b/packages/mitmproxy/src/lib/proxy/mitmproxy/createRequestHandler.js index b0b3d32b..9a3a14dc 100644 --- a/packages/mitmproxy/src/lib/proxy/mitmproxy/createRequestHandler.js +++ b/packages/mitmproxy/src/lib/proxy/mitmproxy/createRequestHandler.js @@ -276,7 +276,7 @@ module.exports = function createRequestHandler (createIntercepts, middlewares, e if (!res.writableEnded) { const status = e.status || 500 res.writeHead(status, { 'Content-Type': 'text/html;charset=UTF8' }) - res.write(`DevSidecar Warning:\n\n ${e.toString()}`) + res.write(`DevSidecar Warning:
${e.toString()}`) res.end() log.error('request error', e.message) }