Browse Source

refactor: dns设置

pull/180/head
xiaojunnuo 4 years ago
parent
commit
e4456088d4
  1. 15
      packages/core/src/config.js
  2. 14
      packages/core/src/config/index.js
  3. 5
      packages/core/src/expose.js
  4. 20
      packages/core/src/server/options.js
  5. 3
      packages/gui/.gitignore
  6. BIN
      packages/gui/extra/favicon.ico
  7. 12
      packages/gui/package.json
  8. BIN
      packages/gui/public/favicon.ico
  9. 71
      packages/gui/public/logo-1.svg
  10. 18
      packages/gui/src/background.js
  11. 29
      packages/gui/src/bridge/index.js
  12. 29
      packages/gui/src/view/components/App.vue
  13. 27
      packages/gui/src/view/components/settings.vue
  14. 0
      packages/gui/src/view/electron/api.js
  15. 8
      packages/gui/vue.config.js
  16. 903
      packages/gui/yarn.lock

15
packages/core/src/config.js

@ -1,13 +1,28 @@
const lodash = require('lodash')
const defConfig = require('./config/index.js')
let configTarget = defConfig
function _deleteDisabledItem(target,objKey){
const obj = lodash.get(target,objKey)
for (let key in obj) {
if(obj[key]===false){
delete obj[key]
}
}
}
module.exports = {
get () {
return configTarget
},
set (newConfig) {
if(newConfig == null){
return
}
const clone = lodash.cloneDeep(defConfig)
lodash.merge(clone, newConfig)
_deleteDisabledItem(clone,'intercepts')
_deleteDisabledItem(clone,'dns.mapping')
configTarget = clone
return configTarget
},

14
packages/core/src/config/index.js

@ -28,44 +28,37 @@ module.exports = {
// ],
'raw.githubusercontent.com': [
{
regexp: '.*',
proxy: 'https://raw.fastgit.org'
}
],
'github.githubassets.com': [
{
regexp: '.*',
proxy: 'https://assets.fastgit.org'
}
],
'customer-stories-feed.github.com': [
{
regexp: '.*',
proxy: 'https://customer-stories-feed.fastgit.org'
}
],
// google cdn
'ajax.googleapis.com': [
{
regexp: '.*',
proxy: 'https://ajax.loli.net'
}
],
'fonts.googleapis.com': [
{
regexp: '.*',
proxy: 'https://fonts.loli.net'
}
],
'themes.googleapis.com': [
{
regexp: '.*',
proxy: 'https://themes.loli.net'
}
],
'fonts.gstatic.com': [
{
regexp: '.*',
proxy: 'https://gstatic.loli.net'
}
],
@ -77,20 +70,17 @@ module.exports = {
],
'secure.gravatar.com': [
{
regexp: '.*',
redirect: 'https://gravatar.loli.net'
}
],
'clients*.google.com': [
{
regexp: '.*',
redirect: 'https://localhost:99999'
abort:true
}
],
'lh*.googleusercontent.com': [
{
regexp: '.*',
redirect: 'https://localhost:99999'
abort:true
}
]
},

5
packages/core/src/expose.js

@ -27,7 +27,10 @@ module.exports = {
proxy,
config,
startup: async (newConfig) => {
config.set(newConfig)
if(newConfig){
config.set(newConfig)
}
try {
if (config.get().setting.startup.server) {
server.start(newConfig)

20
packages/core/src/server/options.js

@ -46,15 +46,23 @@ module.exports = (config) => {
for (const interceptOpt of interceptOpts) { // 遍历拦截配置
let regexpList
if (interceptOpt.regexp instanceof Array) {
regexpList = interceptOpt.regexp
} else {
regexpList = [interceptOpt.regexp]
if(interceptOpt.regexp!=null){
if (interceptOpt.regexp instanceof Array) {
regexpList = interceptOpt.regexp
} else {
regexpList = [interceptOpt.regexp]
}
}else{
regexpList = [true]
}
for (const regexp of regexpList) { // 遍历regexp配置
if (!isMatched(req.url, regexp)) {
continue
if(regexp!==true){
if (!isMatched(req.url, regexp)) {
continue
}
}
for (const interceptImpl of interceptors) {
// 根据拦截配置挑选合适的拦截器来处理

3
packages/gui/.gitignore vendored

@ -23,4 +23,5 @@ pnpm-debug.log*
*.sw?
#Electron-builder output
/dist_electron
/dist_electron
/config

BIN
packages/gui/extra/favicon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

12
packages/gui/package.json

@ -1,5 +1,5 @@
{
"name": "dev-sidecar-gui",
"name": "@docmirror/dev-sidecar-gui",
"version": "1.0.0",
"private": false,
"scripts": {
@ -18,8 +18,9 @@
"lodash": "^4.17.20",
"vue": "^2.6.11",
"vue-json-editor": "^1.4.2",
"dev-sidecar": "1.0.0",
"json5": "^2.1.3"
"@docmirror/dev-sidecar": "1.0.0",
"json5": "^2.1.3",
"es-abstract": "^1.17.7"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
@ -57,5 +58,6 @@
"> 1%",
"last 2 versions",
"not dead"
]
}
],
"__npminstall_done": false
}

BIN
packages/gui/public/favicon.ico

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 17 KiB

71
packages/gui/public/logo-1.svg

@ -0,0 +1,71 @@
<svg id="svg_canvas" viewBox="0 0 300 300" width="300" height="300" version="1.1" xmlns="http://www.w3.org/2000/svg" >
<g transform="translate(100,40) scale(1,1)">
<path fill="#368FB1" d="M102.423,165.089H62.778c-2.534,0-4.589-2.056-4.589-4.589s2.055-4.589,4.589-4.589h39.645
c15.916,0,32.379-11.18,32.379-29.892c0-22.1-21.58-25.871-22.498-26.02l-4.244-0.693l0.397-4.281
c0.686-7.096-1.867-14.598-6.831-20.063c-5.45-6.002-13.351-9.175-22.85-9.175c-23.706,0-27.28,23.842-27.42,24.858l-0.565,4.081
l-4.122-0.111c-23.445-0.729-30.104,8.127-30.168,8.216c-1.457,2.02-4.294,2.558-6.348,1.147c-2.054-1.407-2.644-4.15-1.287-6.238
c0.837-1.288,8.623-12.082,34.18-12.339c2.982-11.745,13.044-28.793,35.731-28.793c15.36,0,24.6,6.624,29.645,12.184
c5.737,6.319,9.076,14.694,9.309,23.038c10.814,3.128,26.25,12.961,26.25,34.189C143.98,150.476,122.851,165.089,102.423,165.089z
"></path>
<rect x="140.167" y="74.342" fill="#368FB1" width="25.821" height="25.821"></rect>
<path fill="#368FB1" d="M137.108,98.083c-4.099-4.038-9.485-7.74-16.337-10.891c0,0-4.895-41.302-54.795-35.062
c0,0,49.319-22.548,64.248,26.77c0,0,2.907,1.439,6.884,4.314V98.083z"></path>
<path fill="#368FB1" d="M153.537,100.164h-13.37V85.509C144.543,89.027,149.59,93.922,153.537,100.164z"></path>
<path fill="#368FB1" d="M159.747,129.932c-4.803,29.615-33.316,34.602-35.091,34.877c1.071-0.581,12.789-7.129,19.58-20.774
c5.599-11.197,7.404-27.167-2.601-40.812h13.676C159.197,110.535,161.461,119.438,159.747,129.932z"></path>
<rect x="160.828" y="51.603" fill="#368FB1" width="17.177" height="17.177"></rect>
<rect x="173.065" y="75.186" fill="#368FB1" width="12.556" height="12.556"></rect>
</g>
<g transform="translate(10,150)">
<path fill="rgb(54, 143, 177)"
d="M2.52 0L2.52-24.68L12.99-24.68Q16.91-24.68 19.05-23.90L19.05-23.90Q23.01-22.46 24.35-18.61L24.35-18.61Q25.34-15.65 25.34-12.28L25.34-12.28Q25.34-8.95 24.38-5.99L24.38-5.99Q23.42-2.96 21.20-1.52L21.20-1.52Q19.79-0.63 18.11-0.31Q16.43 0 12.99 0L12.99 0L2.52 0ZM12.99-20.28L7.77-20.28L7.77-4.40L12.99-4.40Q16.43-4.40 17.76-5.92L17.76-5.92Q18.57-6.88 19.07-8.62Q19.57-10.36 19.57-12.32L19.57-12.32Q19.57-14.50 18.98-16.32Q18.39-18.13 17.43-19.02L17.43-19.02Q16.02-20.28 12.99-20.28L12.99-20.28Z"
transform="translate(5 31)" ></path>
<path fill="rgb(54, 143, 177)"
d="M6.70-10.95L17.13-10.95L17.13-7.10L6.70-7.10Q6.84-5.33 7.84-4.59Q8.84-3.85 11.10-3.85L11.10-3.85L17.13-3.85L17.13 0L10.54 0Q8.40 0 7.05-0.39Q5.70-0.78 4.51-1.66L4.51-1.66Q1.22-4.22 1.22-9.25L1.22-9.25Q1.22-12.51 2.96-14.95L2.96-14.95Q4.14-16.61 5.81-17.32Q7.47-18.02 10.17-18.02L10.17-18.02L17.13-18.02L17.13-14.17L10.54-14.17Q8.51-14.17 7.70-13.49Q6.88-12.80 6.70-10.95L6.70-10.95Z"
transform="translate(31 31)" ></path>
<path fill="rgb(54, 143, 177)"
d="M5.62-18.02L10.21-5.62L15.24-18.02L20.50-18.02L12.73 0L7.40 0L0.22-18.02L5.62-18.02Z"
transform="translate(50 31)" ></path>
<path fill="rgb(54, 143, 177)" d="M0-11.77L8.62-11.77L8.62-7.33L0-7.33L0-11.77Z"
transform="translate(71 31)"></path>
<path fill="rgb(54, 143, 177)"
d="M14.80 0L2.40 0L2.40-4.40L13.69-4.40Q16.39-4.40 17.28-4.92L17.28-4.92Q18.57-5.70 18.57-7.25L18.57-7.25Q18.57-9.06 17.06-9.88L17.06-9.88Q16.21-10.36 14.32-10.36L14.32-10.36L9.73-10.36Q5.55-10.36 3.70-11.88L3.70-11.88Q2.55-12.84 1.91-14.28Q1.26-15.72 1.26-17.39L1.26-17.39Q1.26-19.98 2.77-22.13L2.77-22.13Q4.25-24.20 7.51-24.57L7.51-24.57Q8.62-24.68 10.80-24.68L10.80-24.68L23.05-24.68L23.05-20.28L11.99-20.28Q9.51-20.24 8.70-20.05L8.70-20.05Q7.03-19.65 7.03-17.54L7.03-17.54Q7.03-15.76 8.44-15.17L8.44-15.17Q9.36-14.73 11.54-14.73L11.54-14.73L15.50-14.73Q18.54-14.73 20.02-14.21L20.02-14.21Q22.64-13.32 23.64-11.10L23.64-11.10Q24.42-9.32 24.42-7.29L24.42-7.29Q24.42-5.03 23.38-3.26L23.38-3.26Q21.94-0.74 19.05-0.22L19.05-0.22Q17.65 0 14.80 0L14.80 0Z"
transform="translate(79 31)" ></path>
<path fill="rgb(54, 143, 177)"
d="M2.40 0L2.40-18.02L7.36-18.02L7.36 0L2.40 0ZM7.36-19.87L2.40-19.87L2.40-24.68L7.36-24.68L7.36-19.87Z"
transform="translate(105 31)" ></path>
<path fill="rgb(54, 143, 177)"
d="M9.84-18.02L14.50-18.02L14.50-24.68L19.43-24.68L19.43 0L10.91 0Q8.32 0 6.99-0.41L6.99-0.41Q3.85-1.41 2.29-4.33L2.29-4.33Q1.22-6.29 1.22-9.14L1.22-9.14Q1.22-13.76 4.33-16.32L4.33-16.32Q6.36-18.02 9.84-18.02L9.84-18.02ZM10.91-3.85L14.50-3.85L14.50-14.17L10.91-14.17Q8.55-14.17 7.33-12.58L7.33-12.58Q6.25-11.25 6.25-9.14L6.25-9.14Q6.25-6.07 8.03-4.74L8.03-4.74Q9.25-3.85 10.91-3.85L10.91-3.85Z"
transform="translate(115 31)"
></path>
<path fill="rgb(54, 143, 177)"
d="M6.70-10.95L17.13-10.95L17.13-7.10L6.70-7.10Q6.84-5.33 7.84-4.59Q8.84-3.85 11.10-3.85L11.10-3.85L17.13-3.85L17.13 0L10.54 0Q8.40 0 7.05-0.39Q5.70-0.78 4.51-1.66L4.51-1.66Q1.22-4.22 1.22-9.25L1.22-9.25Q1.22-12.51 2.96-14.95L2.96-14.95Q4.14-16.61 5.81-17.32Q7.47-18.02 10.17-18.02L10.17-18.02L17.13-18.02L17.13-14.17L10.54-14.17Q8.51-14.17 7.70-13.49Q6.88-12.80 6.70-10.95L6.70-10.95Z"
transform="translate(137.053 31)"></path>
<path fill="rgb(54, 143, 177)"
d="M10.69-18.02L17.46-18.02L17.46-14.17L11.54-14.17Q8.55-14.17 7.40-12.84L7.40-12.84Q6.29-11.58 6.29-8.99L6.29-8.99Q6.29-6.10 8.10-4.77L8.10-4.77Q8.84-4.25 9.71-4.05Q10.58-3.85 12.14-3.85L12.14-3.85L17.46-3.85L17.46 0L10.69 0Q7.95 0 6.36-0.55Q4.77-1.11 3.55-2.48L3.55-2.48Q1.22-5.07 1.22-9.06L1.22-9.06Q1.22-13.88 4.00-16.24L4.00-16.24Q5.11-17.20 6.66-17.61Q8.21-18.02 10.69-18.02L10.69-18.02Z"
transform="translate(155.812 31)"></path>
<path fill="rgb(54, 143, 177)"
d="M8.77-10.95L14.84-10.95Q14.84-12.84 14.08-13.50Q13.32-14.17 11.06-14.17L11.06-14.17L2.70-14.17L2.70-18.02L11.06-18.02Q13.32-18.02 14.17-17.93Q15.02-17.83 15.91-17.57L15.91-17.57Q20.02-16.02 19.79-10.14L19.79-10.14L19.79 0L9.36 0Q6.55 0 5.48-0.17Q4.40-0.33 3.59-0.85L3.59-0.85Q1.41-2.33 1.41-5.33L1.41-5.33Q1.41-7.14 2.28-8.57Q3.15-9.99 4.59-10.51L4.59-10.51Q5.85-10.95 8.77-10.95L8.77-10.95ZM14.84-3.85L14.84-7.10L9.14-7.10L8.29-7.10Q7.44-7.10 6.94-6.66Q6.44-6.22 6.44-5.44L6.44-5.44Q6.44-4.59 7.05-4.22Q7.66-3.85 9.14-3.85L9.14-3.85L14.84-3.85Z"
transform="translate(174.645 31)"></path>
<path fill="rgb(54, 143, 177)"
d="M2.40 0L2.40-18.02L9.73-18.02Q11.99-18.02 13.23-17.70Q14.47-17.39 15.28-16.65L15.28-16.65Q16.09-15.91 16.43-14.80Q16.76-13.69 16.76-11.62L16.76-11.62L16.76-9.88L11.99-9.88L11.99-10.84Q11.99-12.76 11.32-13.47Q10.66-14.17 8.77-14.17L8.77-14.17L7.36-14.17L7.36 0L2.40 0Z"
transform="translate(196 31)"></path>
</g>
<g transform="translate(40,190)">
<path fill="rgb(54, 143, 177)"
d="M18.56-12.98L15.44-12.98L15.44-8.21L19.05-8.21L18.56-7.22L15.44-7.22L15.44-1.13L12.94-1.13L12.94-7.22L8.11-7.22L8.11-6.26L5.84-1.13L3.11-1.13L5.69-6.55L5.69-7.22L1.93-7.22L1.93-8.21L5.69-8.21L5.69-12.98L1.93-12.98L1.93-13.97L5.69-13.97L5.69-13.99L15.44-13.99L15.44-13.97L19.05-13.97L18.56-12.98ZM12.94-8.21L12.94-12.98L8.11-12.98L8.11-8.21L12.94-8.21Z"
transform="translate(5 18)" ></path>
<path fill="rgb(54, 143, 177)"
d="M13.13-2.69L10.08-1.09L6.47-1.09L11.40-3.59L7.41-5.71L10.37-5.71L12.92-4.37L15.94-5.90L15.94-6.72L7.16-6.72L4.22-1.18L1.53-1.18L6.07-9.74L1.49-9.74L3.30-14.03L5.86-14.03L4.43-10.65L6.55-10.65L8.36-14.03L11.07-14.03L9.26-10.65L16.09-10.65L15.29-12.89L17.70-12.89L18.52-10.65L19.49-10.65L19.49-9.74L8.78-9.74L7.67-7.64L18.33-7.64L18.33-5.44L14.62-3.47L19.15-1.09L16.17-1.09L13.13-2.69Z"
transform="translate(26 18)" ></path>
<path fill="rgb(54, 143, 177)"
d="M11.47-12.92L18.71-12.92L18.08-11.99L11.47-11.99L11.47-9.87L13.17-9.87L14.09-11.40L17.07-11.40L16.15-9.87L19.30-9.87L18.67-8.95L7.27-8.95L6.24-7.64L15.81-7.64L15.81-7.67L18.19-7.67L18.19-1.32L3.42-1.32L3.42-5.80L1.81-5.80L4.28-8.95L1.70-8.95L1.70-9.87L9.07-9.87L9.07-11.99L2.71-11.99L2.71-12.92L9.07-12.92L9.07-13.80L11.47-13.80L11.47-12.92ZM15.25-4.12L5.82-4.12L5.82-2.25L15.81-2.25L15.81-4.79L15.25-4.12ZM15.33-6.68L5.82-6.68L5.82-5.06L15.81-5.06L15.81-7.27L15.33-6.68Z"
transform="translate(47 18)" ></path>
<path fill="rgb(54, 143, 177)"
d="M11.03-6.11L8.93-2.67L6.49-2.67L8.59-6.11L8.59-11.28L6.41-11.28L6.41-12.26L8.59-12.26L8.59-13.86L11.03-13.86L11.03-12.26L18.44-12.26L18.44-2.67L13.57-2.67L13.02-3.65L16.00-3.65L16.00-11.28L11.03-11.28L11.03-6.11ZM1.47-9.91L4.96-9.91L4.96-2.25L19.53-2.25L19.13-1.28L5.71-1.28L4.89-2.10L4.26-1.28L1.47-1.28L1.47-2.25L2.56-2.25L2.56-8.93L1.47-8.93L1.47-9.91ZM4.31-13.80L5.40-11.05L2.83-11.05L1.72-13.80L4.31-13.80Z"
transform="translate(68 18)" ></path>
<path fill="rgb(54, 143, 177)"
d="M11.87-1.07L9.37-1.07L9.37-3.49L2.46-3.49L2.46-4.45L9.37-4.45L9.37-6.53L2.92-6.53L6.13-11.32L2.50-11.32L2.50-12.29L6.78-12.29L7.96-14.05L11.05-14.05L9.87-12.29L17.07-12.29L16.53-11.32L9.22-11.32L6.66-7.48L9.37-7.48L9.37-10.40L11.87-10.40L11.87-7.48L17.07-7.48L16.53-6.53L11.87-6.53L11.87-4.45L18.54-4.45L18.00-3.49L11.87-3.49L11.87-1.07Z"
transform="translate(89 18)" ></path>
</g>
</svg>

After

Width:  |  Height:  |  Size: 9.3 KiB

18
packages/gui/src/background.js

@ -9,7 +9,7 @@ const isDevelopment = process.env.NODE_ENV !== 'production'
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let win
let tray
let forceClose = false
// Scheme must be registered before the app is ready
@ -33,8 +33,7 @@ function setTray (app) {
}
]
// 设置系统托盘图标
const iconPath = path.join(__dirname, '../public/favicon.ico')
const iconPath = path.join(__dirname, '../extra/favicon.ico')
const appTray = new Tray(iconPath)
// 图标的上下文菜单
@ -78,10 +77,9 @@ function createWindow () {
win.loadURL('app://./index.html')
}
win.on('closed', (e) => {
win.on('closed', async (e) => {
win = null
bridge.devSidecar.expose.api.shutdown()
await bridge.devSidecar.api.shutdown()
})
win.on('close', (e) => {
@ -122,9 +120,13 @@ app.on('ready', async () => {
// }
}
createWindow()
// 最小化到托盘
setTray(app)
bridge.init(win)
try {
// 最小化到托盘
tray = setTray(app)
} catch (err) {
console.log('err', err)
}
})
// Exit cleanly on request from parent process in development mode.

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

@ -1,5 +1,5 @@
import lodash from 'lodash'
import DevSidecar from 'dev-sidecar'
import DevSidecar from '@docmirror/dev-sidecar'
import { ipcMain } from 'electron'
import fs from 'fs'
import JSON5 from 'json5'
@ -23,17 +23,30 @@ const localApi = {
// TODO 保存到文件
console.log('save config ', saveConfig)
fs.writeFileSync('./config.json5', JSON5.stringify(saveConfig, null, 2))
fs.writeFileSync(_getConfigPath(), JSON5.stringify(saveConfig, null, 2))
return saveConfig
},
reload () {
const file = fs.readFileSync('./config.json5')
const path = _getConfigPath()
if (!fs.existsSync(path)) {
return
}
const file = fs.readFileSync(path)
const userConfig = JSON5.parse(file.toString())
DevSidecar.api.config.set(userConfig)
return DevSidecar.api.config.get()
}
}
}
function _getConfigPath () {
const dir = './config/'
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir)
}
return dir + 'config.json5'
}
function _merge (defConfig, newConfig, saveConfig, target, self = false) {
if (self) {
const defValue = lodash.get(defConfig, target)
@ -62,7 +75,6 @@ function _mergeConfig (defObj, newObj) {
}
// 深度对比 是否有修改
if (lodash.isEqual(newItem, defItem)) {
console.log('equle', key, newItem, defItem)
// 没有修改则删除
delete newObj[key]
}
@ -75,10 +87,10 @@ export default {
// 接收view的方法调用
ipcMain.handle('apiInvoke', async (event, args) => {
const api = args[0]
let target = lodash.get(DevSidecar.api, api)
let target = lodash.get(localApi, api)
if (target == null) {
console.log('get local api')
target = lodash.get(localApi, api)
console.log('get core api')
target = lodash.get(DevSidecar.api, api)
}
if (target == null) {
console.log('找不到此接口方法:', api)
@ -96,6 +108,9 @@ export default {
console.log('bridge on status', event)
win.webContents.send('status', { ...event })
})
// 合并用户配置
localApi.config.reload()
},
devSidecar: DevSidecar
}

29
packages/gui/src/view/components/App.vue

@ -80,7 +80,7 @@ export default {
key: '代理服务',
loading: false,
doClick: (checked) => {
this.onSwitchClick(this.server, api.server.start, api.server.close, checked)
this.onServerClick(checked)
}
},
proxy: undefined,
@ -96,17 +96,19 @@ export default {
}
},
created () {
api.config.set().then(() => {
return api.config.get().then(ret => {
this.config = ret
this.start(true)
})
}).then(() => {
this.proxy = this.createProxyBtns()
this.proxy = this.createProxyBtns()
this.reloadConfig().then(() => {
this.start(true)
console.log('proxy', this.proxy)
})
},
methods: {
reloadConfig () {
return api.config.reload().then(ret => {
this.config = ret
return ret
})
},
_lang (key, parent) {
const label = parent ? lodash.get(parent, key) : lodash.get(this.langSetting, key)
if (label) {
@ -147,6 +149,9 @@ export default {
this.apiCall(btn, closeApi)
}
},
onServerClick (checked) {
this.onSwitchClick(this.server, api.server.start, api.server.close, checked)
},
start (checked) {
this.apiCall(this.startup, api.startup)
},
@ -156,7 +161,13 @@ export default {
onConfigChanged (newConfig) {
console.log('config chagned', newConfig)
api.config.save(newConfig).then(() => {
api.config.reload()
return this.reloadConfig()
}).then(() => {
if (this.status.server) {
this.onServerClick(false).then(() => {
this.onServerClick(true)
})
}
})
}
}

27
packages/gui/src/view/components/settings.vue

@ -22,8 +22,8 @@
<a-tab-pane tab="DNS设置" key="2">
<div>
<div>某些域名有时候需要通过其他DNS服务器获取到的IP才可以访问</div>
<a-row :gutter="10" style="margin-top: 10px" v-for="item in dnsMappings" :key = 'item.key'>
<a-col :span="18">
<a-row :gutter="10" style="margin-top: 10px" v-for="(item,index) in dnsMappings" :key = 'item.key'>
<a-col :span="16">
<a-input v-model="item.key"></a-input>
</a-col>
<a-col :span="6">
@ -31,8 +31,15 @@
<a-select-option value="usa">USA</a-select-option>
<a-select-option value="aliyun">Aliyun</a-select-option>
</a-select>
<a-button style="margin-left:10px" type="danger" icon="minus" @click="deleteDnsMapping(item,index)" />
</a-col>
</a-row>
<a-row style="margin-top:10px">
<a-col>
<a-button type="primary" icon="plus" @click="addDnsMapping(item)" />
</a-col>
</a-row>
</div>
</a-tab-pane>
<a-tab-pane tab="启动设置" key="3" >
@ -119,13 +126,27 @@ export default {
title: '提示',
content: '是否需要保存?',
onOk: () => {
this.$emit('change', this.targetConfig)
this.doSave()
},
onCancel () {}
})
}
this.$emit('update:visible', false)
},
doSave () {
const mapping = {}
for (const item of this.dnsMappings) {
mapping[item.key] = item.value
}
this.targetConfig.dns.mapping = mapping
this.$emit('change', this.targetConfig)
},
deleteDnsMapping (item, index) {
this.dnsMappings.splice(index, 1)
},
addDnsMapping () {
this.dnsMappings.push({ key: '', value: 'usa' })
}
}
}

0
packages/gui/src/view/electron/api.js

8
packages/gui/vue.config.js

@ -25,12 +25,8 @@ module.exports = {
builderOptions: {
extraResources: [
{
from: 'src/config.json5',
to: 'app/config.json5'
},
{
from: 'public',
to: 'public'
from: 'extra',
to: 'extra'
}
]
}

903
packages/gui/yarn.lock

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save