Skip to content

Commit a6d2685

Browse files
feature: 域名白名单,支持反向配置,用于大范围设置不代理,个别域名设置需要代理。
1 parent f575e6b commit a6d2685

File tree

16 files changed

+209
-146
lines changed

16 files changed

+209
-146
lines changed

packages/gui/src/view/App.vue

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import { colorTheme } from './composables/theme'
55
66
export default {
77
name: 'App',
8-
components: {
9-
},
108
data () {
119
return {
1210
locale: zhCN,
@@ -39,9 +37,6 @@ export default {
3937
})
4038
},
4139
methods: {
42-
handleClick (e) {
43-
console.log('click', e)
44-
},
4540
titleClick (item) {
4641
console.log('title click:', item)
4742
},

packages/gui/src/view/api.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ export function apiInit (app) {
2727
ipcRenderer.removeAllListeners(channel)
2828
},
2929
invoke,
30+
postMessage (channel, ...args) {
31+
ipcRenderer.postMessage(channel, ...args)
32+
},
3033
send,
3134
async openExternal (href) {
3235
await shell.openExternal(href)

packages/gui/src/view/components/container.vue

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export default {
88
<div class="ds-container">
99
<div class="body-wrapper">
1010
<div v-if="$slots.header" class="container-header">
11-
<slot name="header" />
11+
<span><slot name="header" /></span>
12+
<span style="color:#999"><slot name="header-right" /></span>
1213
</div>
1314
<div class="container-body">
1415
<slot />
@@ -23,16 +24,16 @@ export default {
2324
<style lang="scss">
2425
.ds-container {
2526
height: 100%;
26-
background: #fff;
27+
background-color: #fff;
2728
display: flex;
2829
position: relative;
2930
3031
.body-wrapper {
3132
position: absolute;
32-
top: 0px;
33-
right: 0px;
34-
bottom: 0px;
35-
left: 0px;
33+
top: 0;
34+
right: 0;
35+
bottom: 0;
36+
left: 0;
3637
display: flex;
3738
flex-direction: column;
3839
overflow: hidden;
@@ -41,7 +42,7 @@ export default {
4142
.container-header {
4243
padding: 15px;
4344
border-bottom: 1px solid #eee;
44-
background: #fff;
45+
background-color: #fff;
4546
height: 60px;
4647
display: flex;
4748
align-items: center;

packages/gui/src/view/mixins/plugin.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,5 +142,17 @@ export default {
142142
const dir = await this.$api.info.getLogDir()
143143
this.$api.ipc.openPath(dir)
144144
},
145+
handleHostname (hostname) {
146+
if (this.isNotHostname(hostname)) {
147+
return ''
148+
}
149+
150+
// 移除所有空白符
151+
return hostname.replaceAll(/\s+/g, '')
152+
},
153+
isNotHostname (hostname) {
154+
// 暂时只判断数字
155+
return !hostname || /^[\d\s]+$/.test(hostname)
156+
},
145157
},
146158
}

packages/gui/src/view/pages/help.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ export default {
2525
<ds-container>
2626
<template slot="header">
2727
帮助中心
28-
<span>
29-
<a-button class="md-mr-10" @click="openExternal('https://github.com/docmirror/dev-sidecar/issues/new/choose')">反馈问题</a-button>
30-
<a-button class="md-mr-10" icon="profile" @click="openLog()">查看日志</a-button>
31-
</span>
28+
</template>
29+
<template slot="header-right">
30+
<a-button class="md-mr-10" @click="openExternal('https://github.com/docmirror/dev-sidecar/issues/new/choose')">反馈问题</a-button>
31+
<a-button class="md-mr-10" icon="profile" @click="openLog()">查看日志</a-button>
3232
</template>
3333

3434
<div v-if="config" class="help-list">

packages/gui/src/view/pages/index.vue

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -259,20 +259,20 @@ export default {
259259
<DsContainer class="page_index">
260260
<template slot="header">
261261
给开发者的辅助工具
262-
<span>
263-
<a-button style="margin-right:10px" @click="openSetupCa">
264-
<a-badge :count="_rootCaSetuped ? 0 : 1" dot>安装根证书</a-badge>
265-
</a-button>
262+
</template>
263+
<template slot="header-right">
264+
<a-button style="margin-right:10px" @click="openSetupCa">
265+
<a-badge :count="_rootCaSetuped ? 0 : 1" dot>安装根证书</a-badge>
266+
</a-button>
266267

267-
<a-button
268-
style="margin-right:10px" :loading="update.downloading || update.checking" :title="`当前版本:${info.version}`"
269-
@click="doCheckUpdate(true)"
270-
>
271-
<a-badge :count="update.newVersion ? 1 : 0" dot>
272-
<span v-if="update.downloading">{{ update.progress }}%</span>{{ update.downloading ? '新版本下载中' : (`检查更新${update.checking ? '中' : ''}`) }}
273-
</a-badge>
274-
</a-button>
275-
</span>
268+
<a-button
269+
style="margin-right:10px" :loading="update.downloading || update.checking" :title="`当前版本:${info.version}`"
270+
@click="doCheckUpdate(true)"
271+
>
272+
<a-badge :count="update.newVersion ? 1 : 0" dot>
273+
<span v-if="update.downloading">{{ update.progress }}%</span>{{ update.downloading ? '新版本下载中' : (`检查更新${update.checking ? '中' : ''}`) }}
274+
</a-badge>
275+
</a-button>
276276
</template>
277277

278278
<div class="box">
@@ -319,7 +319,7 @@ export default {
319319
</div>
320320
<div :span="12">
321321
<a-form style="margin-top:20px" :label-col="{ span: 15 }" :wrapper-col="{ span: 9 }">
322-
<a-form-item v-for=" (item, key) in switchBtns" :key="key" :label="item.label">
322+
<a-form-item v-for="(item, key) in switchBtns" :key="key" :label="item.label">
323323
<a-tooltip placement="topLeft">
324324
<a-switch
325325
style="margin-left:10px" :loading="item.loading" :checked="item.status()" default-checked

packages/gui/src/view/pages/plugin/git.vue

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ export default {
77
data () {
88
return {
99
key: 'plugin.git',
10+
labelCol: { span: 4 },
11+
wrapperCol: { span: 20 },
1012
noProxyUrls: [],
1113
needRestart: false,
1214
}
@@ -45,7 +47,7 @@ export default {
4547
}
4648
},
4749
addNoProxyUrl () {
48-
this.noProxyUrls.unshift({ key: '', value: true })
50+
this.noProxyUrls.unshift({ key: '' })
4951
},
5052
delNoProxyUrl (item, index) {
5153
this.noProxyUrls.splice(index, 1)
@@ -54,7 +56,10 @@ export default {
5456
const noProxyUrls = {}
5557
for (const item of this.noProxyUrls) {
5658
if (item.key) {
57-
noProxyUrls[item.key] = item.value
59+
const hostname = this.handleHostname(item.key)
60+
if (hostname) {
61+
noProxyUrls[hostname] = true
62+
}
5863
}
5964
}
6065
this.config.plugin.git.setting.noProxyUrls = noProxyUrls
@@ -67,9 +72,9 @@ export default {
6772
<ds-container>
6873
<template slot="header">
6974
Git.exe代理设置
70-
<span style="color:#999;">
71-
仅针对git命令行的代理设置,github网站的访问无需设置
72-
</span>
75+
</template>
76+
<template slot="header-right">
77+
仅针对git命令行的代理设置,github网站的访问无需设置
7378
</template>
7479

7580
<div v-if="config">
@@ -103,7 +108,7 @@ export default {
103108
</a-row>
104109
<a-row v-for="(item, index) of noProxyUrls" :key="index" :gutter="10">
105110
<a-col :span="22">
106-
<a-input v-model="item.key" :disabled="item.value === false" />
111+
<a-input v-model="item.key" />
107112
</a-col>
108113
<a-col :span="2">
109114
<a-button type="danger" icon="minus" @click="delNoProxyUrl(item, index)" />

packages/gui/src/view/pages/plugin/node.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ export default {
77
data () {
88
return {
99
key: 'plugin.node',
10+
labelCol: { span: 4 },
11+
wrapperCol: { span: 20 },
1012
npmVariables: undefined,
1113
registry: false,
1214
}
@@ -51,9 +53,9 @@ export default {
5153
<ds-container>
5254
<template slot="header">
5355
NPM加速
54-
<span style="color:#999;">
55-
由于nodejs不走系统证书,所以npm加速不是很好用,可以用淘宝registry
56-
</span>
56+
</template>
57+
<template slot="header-right">
58+
由于nodejs不走系统证书,所以npm加速不是很好用,可以用淘宝registry
5759
</template>
5860

5961
<div v-if="config">
@@ -97,7 +99,6 @@ export default {
9799
设置后立即生效,即使关闭 ds 也会继续保持
98100
</div>
99101
</a-form-item>
100-
101102
<a-form-item label="yarn仓库镜像" :label-col="labelCol" :wrapper-col="wrapperCol">
102103
<a-radio-group v-model="config.plugin.node.setting.yarnRegistry" default-value="null" button-style="solid" @change="onSwitchYarnRegistry">
103104
<a-radio-button value="default" title="https://registry.yarnpkg.com">
@@ -111,7 +112,6 @@ export default {
111112
设置后立即生效,即使关闭 ds 也会继续保持
112113
</div>
113114
</a-form-item>
114-
115115
<a-form-item label="镜像变量设置" :label-col="labelCol" :wrapper-col="wrapperCol">
116116
<a-checkbox v-model="config.plugin.node.startup.variables">
117117
自动设置,启动npm加速开关时将会设置如下环境变量
@@ -123,10 +123,10 @@ export default {
123123
<a-col :span="10">
124124
<a-input v-model="item.key" :title="item.key" read-only />
125125
</a-col>
126-
<a-col :span="10">
126+
<a-col :span="13">
127127
<a-input v-model="item.value" :title="item.value" read-only />
128128
</a-col>
129-
<a-col :span="4">
129+
<a-col :span="1">
130130
<a-icon v-if="item.exists && item.hadSet" title="已设置" style="color:green" type="check" />
131131
<a-icon v-else title="还未设置" style="color:red" type="exclamation-circle" />
132132
</a-col>

packages/gui/src/view/pages/plugin/overwall.vue

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ export default {
77
data () {
88
return {
99
key: 'plugin.overwall',
10+
labelCol: { span: 4 },
11+
wrapperCol: { span: 20 },
1012
targets: undefined,
1113
servers: undefined,
1214
overwallOptions: [
@@ -40,8 +42,8 @@ export default {
4042
this.initServer()
4143
},
4244
async applyBefore () {
43-
this.saveTarget()
44-
this.saveServer()
45+
this.submitTarget()
46+
this.submitServer()
4547
},
4648
initTarget () {
4749
this.targets = []
@@ -54,17 +56,20 @@ export default {
5456
})
5557
}
5658
},
57-
deleteTarget (item, index) {
58-
this.targets.splice(index, 1)
59-
},
6059
addTarget () {
6160
this.targets.unshift({ key: '', value: 'true' })
6261
},
63-
saveTarget () {
62+
deleteTarget (item, index) {
63+
this.targets.splice(index, 1)
64+
},
65+
submitTarget () {
6466
const map = {}
6567
for (const item of this.targets) {
6668
if (item.key) {
67-
map[item.key] = item.value === 'true'
69+
const hostname = this.handleHostname(item.key)
70+
if (hostname) {
71+
map[hostname] = (item.value === 'true')
72+
}
6873
}
6974
}
7075
this.config.plugin.overwall.targets = map
@@ -90,11 +95,14 @@ export default {
9095
addServer () {
9196
this.servers.unshift({ key: '', value: { type: 'path' } })
9297
},
93-
saveServer () {
98+
submitServer () {
9499
const map = {}
95100
for (const item of this.servers) {
96101
if (item.key) {
97-
map[item.key] = item.value
102+
const hostname = this.handleHostname(item.key)
103+
if (hostname) {
104+
map[hostname] = item.value
105+
}
98106
}
99107
}
100108
this.config.plugin.overwall.server = map
@@ -107,9 +115,9 @@ export default {
107115
<ds-container>
108116
<template slot="header">
109117
梯子
110-
<span>
111-
<a-button type="primary" @click="openExternal('https://github.com/docmirror/dev-sidecar-doc/blob/main/ow.md')">原理说明</a-button>
112-
</span>
118+
</template>
119+
<template slot="header-right">
120+
<a-button type="primary" @click="openExternal('https://github.com/docmirror/dev-sidecar-doc/blob/main/ow.md')">原理说明</a-button>
113121
</template>
114122

115123
<div v-if="config">
@@ -142,7 +150,7 @@ export default {
142150
注:只要下载成功后,即使关闭自动更新功能,也会优先读取最近下载的文件!
143151
</div>
144152
</a-form-item>
145-
<a-form-item label="远程PAC文件地址" :label-col="labelCol" :wrapper-col="wrapperCol">
153+
<a-form-item label="远程PAC文件" :label-col="labelCol" :wrapper-col="wrapperCol">
146154
<a-input v-model="config.plugin.overwall.pac.pacFileUpdateUrl" :title="config.plugin.overwall.pac.pacFileUpdateUrl" />
147155
<div class="form-help">
148156
远程PAC文件内容可以是<code>base64</code>编码格式,也可以是未经过编码的

packages/gui/src/view/pages/plugin/pip.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ export default {
77
data () {
88
return {
99
key: 'plugin.pip',
10+
labelCol: { span: 4 },
11+
wrapperCol: { span: 20 },
1012
npmVariables: undefined,
1113
registry: false,
1214
trustedHostList: [],

0 commit comments

Comments
 (0)