Skip to content

Commit 812969e

Browse files
committed
同步2.0.0.3更改,更新版权年份信息,为内置配置和样例配置适配元信息规范(注意元信息的位置更改了,应在2.0.2发行时修正官方配置;另外内置配置可能未同步2.0.0.3的官方配置修改)
1 parent 5cbfb5c commit 812969e

5 files changed

Lines changed: 60 additions & 44 deletions

File tree

packages/core/src/config/index.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,20 @@
22
import path from 'node:path'
33
import configLoader from './local-config-loader.js'
44

5-
function getRootCaCertPath () {
5+
function getRootCaCertPath() {
66
return path.join(configLoader.getUserBasePath(), '/dev-sidecar.ca.crt')
77
}
88

9-
function getRootCaKeyPath () {
9+
function getRootCaKeyPath() {
1010
return path.join(configLoader.getUserBasePath(), '/dev-sidecar.ca.key.pem')
1111
}
1212

1313
const defaultConfig = {
14+
metaInfo: {
15+
version: 202602032238, // 格式是GMT+8的开始编辑时间,固定位数为年月日+时分;一天有1440分钟,够用了;这就是个number,可以用来比较,别加引号
16+
updateLog: "2.0.2的内置配置,需要等待与2.0.0.3官方配置同步",
17+
id: "internal"
18+
},
1419
app: {
1520
mode: 'default',
1621
autoStart: {
@@ -278,10 +283,10 @@ const defaultConfig = {
278283
// google cdn
279284
'www.google.com': {
280285
'/recaptcha/.*': { proxy: 'www.recaptcha.net' },
281-
// '.*': {
282-
// proxy: 'gg.docmirror.top/_yxorp',
283-
// desc: '呀,被你发现了,偷偷的用,别声张'
284-
// }
286+
// '.*': {
287+
// proxy: 'gg.docmirror.top/_yxorp',
288+
// desc: '呀,被你发现了,偷偷的用,别声张'
289+
// }
285290
},
286291
'www.gstatic.com': {
287292
'/recaptcha/.*': { proxy: 'www.recaptcha.net' },
@@ -715,7 +720,7 @@ const defaultConfig = {
715720

716721
// Pixiv
717722
'*.pixiv.net': {
718-
// 以下为 `cdn-origin.pixiv.net` 域名的IP
723+
// 以下为 `cdn-origin.pixiv.net` 域名的IP
719724
'210.140.139.154': true,
720725
'210.140.139.157': true,
721726
'210.140.139.160': true,

packages/core/src/config/remote_config.json5

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
// 样例配置,仅作测试用途
22
{
3+
metaInfo: {
4+
version: 202602032238, // 格式是GMT+8的开始编辑时间,固定位数为年月日+时分;一天有1440分钟,够用了;这就是个number,可以用来比较,别加引号
5+
updateLog: "样例配置,适配元信息规范", // 我真的不觉得这个字段有多大必要
6+
id: "internal-test",
7+
},
38
server: {
49
compatible: {
510
connect: {

packages/gui/src/view/App.vue

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { colorTheme } from './composables/theme'
66
77
export default {
88
name: 'App',
9-
data () {
9+
data() {
1010
return {
1111
locale: zhCN,
1212
info: {},
@@ -18,22 +18,22 @@ export default {
1818
}
1919
},
2020
computed: {
21-
themeClass () {
21+
themeClass() {
2222
return `theme-${colorTheme.value}`
2323
},
24-
theme () {
24+
theme() {
2525
return colorTheme.value
2626
},
2727
},
28-
mounted () {
28+
mounted() {
2929
let theme = this.config.app.theme
3030
if (this.config.app.theme === 'system') {
3131
theme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
3232
}
3333
3434
colorTheme.value = theme
3535
},
36-
created () {
36+
created() {
3737
this.menus = createMenus(this)
3838
this.config = this.$global.config
3939
this.$api.info.get().then((ret) => {
@@ -91,19 +91,19 @@ export default {
9191
})
9292
},
9393
methods: {
94-
getSearchBarInput () {
94+
getSearchBarInput() {
9595
return this.$refs.searchBar.$el.querySelector('input[type=text]')
9696
},
97-
onSearchBarInputFocus () {
97+
onSearchBarInputFocus() {
9898
this.searchBarIsFocused = true
9999
},
100-
onSearchBarInputBlur () {
100+
onSearchBarInputBlur() {
101101
this.searchBarIsFocused = false
102102
},
103-
onSearchBarInputKeydown () {
103+
onSearchBarInputKeydown() {
104104
clearTimeout(this.searchBarInputKeyupTimeout)
105105
},
106-
onSearchBarInputKeyup (e) {
106+
onSearchBarInputKeyup(e) {
107107
if (!this.$refs.searchBar || e.key === 'Enter' || e.key === 'F3') {
108108
return
109109
}
@@ -114,23 +114,23 @@ export default {
114114
this.$refs.searchBar.previous()
115115
}, 150)
116116
},
117-
doSearchBarInputFocus () {
117+
doSearchBarInputFocus() {
118118
setTimeout(() => {
119119
const input = this.getSearchBarInput()
120120
if (input) {
121121
input.focus()
122122
}
123123
}, 100)
124124
},
125-
titleClick (item) {
125+
titleClick(item) {
126126
console.log('title click:', item)
127127
},
128-
menuClick (item) {
128+
menuClick(item) {
129129
console.log('menu click:', item)
130130
window.config.disableSearchBar = false
131131
this.$router.replace(item.path)
132132
},
133-
async openExternal (url) {
133+
async openExternal(url) {
134134
await this.$api.ipc.openExternal(url)
135135
},
136136
},
@@ -140,26 +140,19 @@ export default {
140140
<template>
141141
<a-config-provider :locale="locale">
142142
<div class="ds_layout" :class="themeClass">
143-
<SearchBar
144-
ref="searchBar"
145-
root="#document"
146-
highlight-class="search-bar-highlight"
147-
selected-class="selected-highlight"
148-
:hiden.sync="hideSearchBar"
149-
style="inset:auto auto 53px 210px; background-color:#ddd"
150-
/>
143+
<SearchBar ref="searchBar" root="#document" highlight-class="search-bar-highlight"
144+
selected-class="selected-highlight" :hiden.sync="hideSearchBar"
145+
style="inset:auto auto 53px 210px; background-color:#ddd" />
151146
<a-layout>
152147
<a-layout-sider :theme="theme" style="overflow-y: auto">
153148
<div class="logo" />
154149
<div class="aside">
155-
<a-menu
156-
mode="inline"
157-
:default-selected-keys="[$route.fullPath]"
158-
:default-open-keys="['/plugin']"
159-
>
150+
<a-menu mode="inline" :default-selected-keys="[$route.fullPath]" :default-open-keys="['/plugin']">
160151
<template v-for="(item) of menus">
161-
<a-sub-menu v-if="item.children && item.children.length > 0" :key="item.path" @titleClick="titleClick(item)">
162-
<span slot="title"><a-icon :type="item.icon ? item.icon : 'file'" /><span>{{ item.title }}</span></span>
152+
<a-sub-menu v-if="item.children && item.children.length > 0" :key="item.path"
153+
@titleClick="titleClick(item)">
154+
<span slot="title"><a-icon :type="item.icon ? item.icon : 'file'" /><span>{{ item.title
155+
}}</span></span>
163156
<a-menu-item v-for="(sub) of item.children" :key="sub.path" @click="menuClick(sub)">
164157
<a-icon :type="sub.icon ? sub.icon : 'file'" /> {{ sub.title }}
165158
</a-menu-item>
@@ -179,7 +172,9 @@ export default {
179172
</a-layout-content>
180173
<a-layout-footer>
181174
<div class="footer">
182-
©2020-2025 docmirror.cn by <a @click="openExternal('https://github.com/greper')">Greper</a>, <a @click="openExternal('https://github.com/wangliang181230')">WangLiang</a>, <a @click="openExternal('https://github.com/cute-omega')">CuteOmega</a> <span>{{ info.version }}</span>
175+
©2020-2026 docmirror.cn by <a @click="openExternal('https://github.com/greper')">Greper</a>, <a
176+
@click="openExternal('https://github.com/wangliang181230')">WangLiang</a>, <a
177+
@click="openExternal('https://github.com/cute-omega')">CuteOmega</a> <span>{{ info.version }}</span>
183178
</div>
184179
</a-layout-footer>
185180
</a-layout>
@@ -192,21 +187,26 @@ export default {
192187
body {
193188
height: 100%;
194189
}
190+
195191
.ds_layout {
196192
font-family: Avenir, Helvetica, Arial, sans-serif;
197193
-webkit-font-smoothing: antialiased;
198194
-moz-osx-font-smoothing: grayscale;
199195
color: #2c3e50;
200196
height: 100%;
197+
201198
.ant-layout-has-sider {
202199
border: 1px solid #eee;
203200
}
201+
204202
.ant-layout-sider-children {
205203
border-right: 1px solid #eee;
206204
}
205+
207206
.ant-layout {
208207
height: 100%;
209208
}
209+
210210
.logo {
211211
padding: 5px;
212212
border-bottom: #eee solid 1px;
@@ -216,17 +216,20 @@ body {
216216
background-repeat: no-repeat;
217217
background-position: 5px center;
218218
}
219+
219220
.ant-layout-footer {
220221
padding: 10px;
221222
text-align: center;
222223
border-top: #d6d4d4 solid 1px;
223224
}
225+
224226
.ant-menu-inline,
225227
.ant-menu-vertical,
226228
.ant-menu-vertical-left {
227229
border: 0;
228230
}
229231
}
232+
230233
.search-bar-highlight {
231234
background-color: #ef0fff;
232235
color: #fdfdfd;

packages/gui/vue.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ module.exports = defineConfig({
7575
productName: 'dev-sidecar',
7676
// eslint-disable-next-line no-template-curly-in-string
7777
artifactName: 'DevSidecar-${version}-${arch}.${ext}',
78-
copyright: 'Copyright © 2020-2025 Greper, WangLiang, CuteOmega',
78+
copyright: 'Copyright © 2020-2026 Greper, WangLiang, CuteOmega',
7979
nsis: {
8080
oneClick: false,
8181
perMachine: true,
@@ -128,7 +128,7 @@ module.exports = defineConfig({
128128
// url: 'http://dev-sidecar.docmirror.cn/update/preview/',
129129
},
130130
},
131-
chainWebpackMainProcess (config) {
131+
chainWebpackMainProcess(config) {
132132
config.entry('mitmproxy').add(path.join(__dirname, 'src/bridge/mitmproxy.js'))
133133
},
134134
},

packages/mitmproxy/src/lib/interceptor/impl/res/script.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ const SCRIPT_URL_PRE = '/____ds_script____/' // 内置脚本的请求地址前
77
const SCRIPT_PROXY_URL_PRE = '/____ds_script_proxy____/' // 绝对地址脚本的伪脚本地址前缀
88
const REMOVE = '[remove]' // 标记需要移除的头信息
99

10-
function getScript (key, script) {
10+
function getScript(key, script) {
1111
const scriptUrl = SCRIPT_URL_PRE + key
1212
// const hash = CryptoJs.SHA256(script).toString(CryptoJs.enc.Base64)
1313
// return `<script crossorigin="anonymous" defer="defer" type="application/javascript" src="${scriptUrl}" integrity="sha256-${hash}"></script>`
1414
return `<script crossorigin="anonymous" defer="defer" type="application/javascript" src="${scriptUrl}"></script>`
1515
}
16-
function getScriptByUrlOrPath (scriptUrlOrPath) {
16+
function getScriptByUrlOrPath(scriptUrlOrPath) {
1717
return `<script crossorigin="anonymous" defer="defer" type="application/javascript" src="${scriptUrlOrPath}"></script>`
1818
}
1919

2020
module.exports = {
2121
name: 'script',
2222
priority: 211,
23-
responseIntercept (context, interceptOpt, req, res, proxyReq, proxyRes, ssl, next) {
23+
responseIntercept(context, interceptOpt, req, res, proxyReq, proxyRes, ssl, next) {
2424
const { rOptions, log, setting } = context
2525

2626
// github特殊处理
@@ -75,6 +75,9 @@ module.exports = {
7575
tags = `\r\n\t${getScript('tampermonkey', scripts.tampermonkey.script)}${tags}`
7676
}
7777

78+
// 增加一个假的js文件,避免github的js异步加载策略获得错误的根路径
79+
tags = `\r\n\t${tags}${getScriptByUrlOrPath(" https://github.githubassets.com/assets/fakefile.js ")}`
80+
7881
res.setHeader('DS-Script-Interceptor', 'true')
7982
log.info(`script response intercept: insert script ${rOptions.protocol}//${rOptions.hostname}:${rOptions.port}${rOptions.path}`, ', head:', tags)
8083
return {
@@ -89,11 +92,11 @@ module.exports = {
8992
log.error('load monkey script error', err)
9093
}
9194
},
92-
is (interceptOpt) {
95+
is(interceptOpt) {
9396
return interceptOpt.script
9497
},
9598
// 处理拦截配置:自动生成script拦截器所需的辅助配置,降低使用`script拦截器`配置绝对地址和相对地址时的门槛
96-
handleScriptInterceptConfig (intercepts) {
99+
handleScriptInterceptConfig(intercepts) {
97100
// 为了简化 script 拦截器配置脚本绝对地址,这里特殊处理一下
98101
for (const hostnamePattern in intercepts) {
99102
const hostnameConfig = intercepts[hostnamePattern]

0 commit comments

Comments
 (0)