Skip to content

Commit 7fe14cb

Browse files
committed
更新[BoxJs]: 尝试修复部分情况下保存数据不生效问题
1 parent eaa40bd commit 7fe14cb

6 files changed

Lines changed: 74 additions & 71 deletions

File tree

‎QuantumultX.box.local.conf‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
hostname = 8.8.8.8
22

33
^https://8.8.8.8/api url script-request-body chavyleung/chavy.box.js
4-
^https://8.8.8.8/(home|sub|my|app|log\/) url script-response-body chavyleung/chavy.box.js
4+
^https://8.8.8.8/(home|sub|my|app|log)($|\/) url script-response-body chavyleung/chavy.box.js

‎QuantumultX.box.remote.conf‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
hostname = 8.8.8.8
22

33
^https://8.8.8.8/api url script-request-body https://raw.githubusercontent.com/chavyleung/scripts/master/chavy.box.js
4-
^https://8.8.8.8/(home|sub|my|app|log\/) url script-response-body https://raw.githubusercontent.com/chavyleung/scripts/master/chavy.box.js
4+
^https://8.8.8.8/(home|sub|my|app|log)($|\/) url script-response-body https://raw.githubusercontent.com/chavyleung/scripts/master/chavy.box.js

‎box/release/box.release.json‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
{
22
"releases": [
3+
{
4+
"version": "0.4.2",
5+
"tags": ["beta"],
6+
"author": "@chavyleung",
7+
"icon": "https://avatars3.githubusercontent.com/u/29748519",
8+
"repo": "https://github.com/chavyleung",
9+
"notes": [
10+
{
11+
"name": "修复",
12+
"descs": ["部分情况下保存数据不生效问题 (实验)", "Rewrite正则 (注意更新正则)"]
13+
},
14+
{
15+
"name": "移除",
16+
"descs": ["修复VPN断连设置项", "自动更新订阅 (可手动更新)"]
17+
}
18+
]
19+
},
320
{
421
"version": "0.4.1",
522
"tags": ["beta"],

‎chavy.box.js‎

Lines changed: 53 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const $ = new Env('BoxJs')
22
$.domain = '8.8.8.8'
33

4-
$.version = '0.4.1'
4+
$.version = '0.4.2'
55
$.versionType = 'beta'
66
$.KEY_sessions = 'chavy_boxjs_sessions'
77
$.KEY_versions = 'chavy_boxjs_versions'
@@ -740,38 +740,6 @@ function printHtml(data, curapp = null, curview = 'app') {
740740
</v-list-item-content>
741741
<v-list-item-action>{{ box.usercfgs.refreshsecs }} 秒</v-list-item-action>
742742
</v-list-item>
743-
<v-list-item>
744-
<v-list-item-content>
745-
<v-switch label="修复断连" v-model="box.usercfgs.isFixVPN" @change="onUserCfgsChange"></v-switch>
746-
</v-list-item-content>
747-
<v-list-item-action>
748-
<v-dialog v-model="ui.fixvpnDialog" persistent max-width="290">
749-
<template v-slot:activator="{ on, attrs }">
750-
<v-btn fab small text v-on="on" v-bind="attrs">
751-
<v-icon>mdi-information-variant</v-icon>
752-
</v-btn>
753-
</template>
754-
<v-card>
755-
<v-card-title class="headline">修复 VPN 断连 (实验)</v-card-title>
756-
<v-card-text>
757-
打开会导致:
758-
<ul>
759-
<!-- <li>无法自动检查 BoxJs 版本</li> -->
760-
<li>无法自动刷新应用订阅</li>
761-
</ul>
762-
<p class="mt-4">
763-
注意: 仍可手动刷新订阅 <br />
764-
路径: 底栏 > 订阅 > 刷新 (右上)
765-
</p>
766-
</v-card-text>
767-
<v-card-actions>
768-
<v-spacer></v-spacer>
769-
<v-btn color="green darken-1" text @click="ui.fixvpnDialog = false">朕, 知道了!</v-btn>
770-
</v-card-actions>
771-
</v-card>
772-
</v-dialog>
773-
</v-list-item-action>
774-
</v-list-item>
775743
<v-list-item>
776744
<v-list-item-content>
777745
<v-switch label="透明图标" v-model="box.usercfgs.isTransparentIcons" @change="onUserCfgsChange"></v-switch>
@@ -1222,9 +1190,6 @@ function printHtml(data, curapp = null, curview = 'app') {
12221190
</v-card-actions>
12231191
</v-card>
12241192
</v-dialog>
1225-
<v-overlay v-model="ui.overlay.show">
1226-
<v-progress-circular indeterminate size="64"></v-progress-circular>
1227-
</v-overlay>
12281193
</v-main>
12291194
<v-expand-transition>
12301195
<v-bottom-navigation v-model="ui.curview" app v-show="ui.navi.show && !box.usercfgs.isHideNavi">
@@ -1357,6 +1322,9 @@ function printHtml(data, curapp = null, curview = 'app') {
13571322
</v-card>
13581323
</v-sheet>
13591324
</v-bottom-sheet>
1325+
<v-overlay v-model="ui.overlay.show" :opacity="0.7">
1326+
<v-progress-circular indeterminate size="64"></v-progress-circular>
1327+
</v-overlay>
13601328
</v-app>
13611329
</div>
13621330
<script src="https://cdn.jsdelivr.net/npm/vue@2.x/dist/vue.js"></script>
@@ -1586,20 +1554,26 @@ function printHtml(data, curapp = null, curview = 'app') {
15861554
},
15871555
onClearCurAppSessionData(app, datas, data) {
15881556
data.val = ''
1589-
axios.post('/api', JSON.stringify({ cmd: 'saveCurAppSession', val: app }))
1590-
this.onReload()
1557+
this.ui.overlay.show = true
1558+
axios.post('/api', JSON.stringify({ cmd: 'saveCurAppSession', val: app })).finally(() => {
1559+
this.onReload()
1560+
})
15911561
},
15921562
onSaveSessionTo(session) {
15931563
const val = {
15941564
fromapp: this.ui.curapp,
15951565
toSession: session
15961566
}
1597-
axios.post('/api', JSON.stringify({ cmd: 'saveSessionTo', val }))
1598-
this.onReload()
1567+
this.ui.overlay.show = true
1568+
axios.post('/api', JSON.stringify({ cmd: 'saveSessionTo', val })).finally(() => {
1569+
this.onReload()
1570+
})
15991571
},
16001572
onModSession () {
1601-
axios.post('/api', JSON.stringify({ cmd: 'onModSession', val: this.ui.modSessionDialog.session }))
1602-
this.onReload()
1573+
this.ui.overlay.show = true
1574+
axios.post('/api', JSON.stringify({ cmd: 'onModSession', val: this.ui.modSessionDialog.session })).finally(() => {
1575+
this.onReload()
1576+
})
16031577
},
16041578
onSaveSession() {
16051579
const session = {
@@ -1616,8 +1590,10 @@ function printHtml(data, curapp = null, curview = 'app') {
16161590
axios.post('/api', JSON.stringify({ cmd: 'saveSession', val: session }))
16171591
},
16181592
onSaveSettings() {
1619-
axios.post('/api', JSON.stringify({ cmd: 'saveSettings', val: this.ui.curapp.settings }))
1620-
this.onReload()
1593+
this.ui.overlay.show = true
1594+
axios.post('/api', JSON.stringify({ cmd: 'saveSettings', val: this.ui.curapp.settings })).finally(() => {
1595+
this.onReload()
1596+
})
16211597
},
16221598
onImpSessionPaste() {
16231599
navigator.clipboard.readText().then((text) => {
@@ -1654,8 +1630,10 @@ function printHtml(data, curapp = null, curview = 'app') {
16541630
}
16551631
this.box.sessions.push(session)
16561632
this.ui.curappSessions.push(session)
1657-
axios.post('/api', JSON.stringify({ cmd: 'saveSession', val: session }))
1658-
this.ui.impSessionDialog.show = false
1633+
this.ui.overlay.show = true
1634+
axios.post('/api', JSON.stringify({ cmd: 'saveSession', val: session })).finally(() => {
1635+
this.ui.impSessionDialog.show = false
1636+
})
16591637
} else {
16601638
alert('导入失败! 原因: appId 为空?')
16611639
}
@@ -1666,44 +1644,48 @@ function printHtml(data, curapp = null, curview = 'app') {
16661644
url: this.ui.addAppSubDialog.url,
16671645
enable: true
16681646
}
1669-
axios.post('/api', JSON.stringify({ cmd: 'addAppSub', val: sub }))
1670-
this.ui.addAppSubDialog.show = false
1671-
this.onReload()
1647+
this.ui.overlay.show = true
1648+
axios.post('/api', JSON.stringify({ cmd: 'addAppSub', val: sub })).finally(() => {
1649+
this.ui.addAppSubDialog.show = false
1650+
this.onReload()
1651+
})
16721652
},
16731653
onRefreshAppSubs(){
1674-
if (['true', true].includes(this.box.usercfgs.isFixVPN)) {
1675-
axios.post('/api', JSON.stringify({ cmd: 'refreshAppSubs', val: null }))
1654+
this.ui.overlay.show = true
1655+
axios.post('/api', JSON.stringify({ cmd: 'refreshAppSubs', val: null })).finally(() => {
16761656
this.box.usercfgs.refreshsecs = 3
1677-
}
1657+
})
16781658
this.onReload()
16791659
},
16801660
reload() {
16811661
window.location.reload()
16821662
},
16831663
onReload() {
1684-
if (!['true', true].includes(this.box.usercfgs.isFixVPN)) {
1685-
axios.post('/api', JSON.stringify({ cmd: 'refreshAppSubs', val: null }))
1686-
}
16871664
const refreshsecs = this.box.usercfgs.refreshsecs
16881665
const sec = [undefined, null, 'null', 'undefined', ''].includes(refreshsecs) ? 3 : refreshsecs * 1
16891666
if (sec === 0) {
16901667
this.reload()
16911668
} else {
1669+
this.ui.overlay.show = false
16921670
this.ui.reloadConfirmDialog.show = true
16931671
this.ui.reloadConfirmDialog.sec = sec
16941672
}
16951673
},
16961674
onDelSession(session) {
1697-
axios.post('/api', JSON.stringify({ cmd: 'delSession', val: session }))
1698-
const sessionIdx = this.box.sessions.findIndex((s) => session.id === s.id)
1699-
if (this.box.sessions.splice(sessionIdx, 1) !== -1) {
1700-
this.ui.curappSessions = this.box.sessions.filter((s) => s.appId === this.ui.curapp.id)
1701-
}
1675+
this.ui.overlay.show = true
1676+
axios.post('/api', JSON.stringify({ cmd: 'delSession', val: session })).finally(() => {
1677+
const sessionIdx = this.box.sessions.findIndex((s) => session.id === s.id)
1678+
if (this.box.sessions.splice(sessionIdx, 1) !== -1) {
1679+
this.ui.curappSessions = this.box.sessions.filter((s) => s.appId === this.ui.curapp.id)
1680+
}
1681+
})
17021682
},
17031683
onUseSession(session) {
1704-
axios.post('/api', JSON.stringify({ cmd: 'useSession', val: session }))
1705-
this.ui.curapp.datas = JSON.parse(JSON.stringify(session.datas))
1706-
this.onReload()
1684+
this.ui.overlay.show = true
1685+
axios.post('/api', JSON.stringify({ cmd: 'useSession', val: session })).finally(() => {
1686+
this.ui.curapp.datas = JSON.parse(JSON.stringify(session.datas))
1687+
this.onReload()
1688+
})
17071689
},
17081690
onImpGlobalBak() {
17091691
const env = this.box.syscfgs.env
@@ -1721,8 +1703,10 @@ function printHtml(data, curapp = null, curview = 'app') {
17211703
bakobj.tags = [env, version, versionType]
17221704
this.box.globalbaks.push(bakobj)
17231705
this.ui.impGlobalBakDialog.show = false
1724-
axios.post('/api', JSON.stringify({ cmd: 'globalBak', val: bakobj }))
1725-
this.onReload()
1706+
this.ui.overlay.show = true
1707+
axios.post('/api', JSON.stringify({ cmd: 'globalBak', val: bakobj })).finally(() => {
1708+
this.onReload()
1709+
})
17261710
},
17271711
onGlobalBak() {
17281712
const env = this.box.syscfgs.env
@@ -1748,8 +1732,10 @@ function printHtml(data, curapp = null, curview = 'app') {
17481732
axios.post('/api', JSON.stringify({ cmd: 'delGlobalBak', val: id }))
17491733
},
17501734
onRevertGlobalBak(id) {
1751-
axios.post('/api', JSON.stringify({ cmd: 'revertGlobalBak', val: id }))
1752-
this.onReload()
1735+
this.ui.overlay.show = true
1736+
axios.post('/api', JSON.stringify({ cmd: 'revertGlobalBak', val: id })).finally(() => {
1737+
this.onReload()
1738+
})
17531739
},
17541740
onCopy(e) {
17551741
this.ui.snackbar.show = true

‎loon.box.conf‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
hostname = 8.8.8.8
22

33
http-request ^https://8.8.8.8/api script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/chavy.box.js, requires-body=true
4-
http-response ^https://8.8.8.8/(home|sub|my|app|log\/) script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/chavy.box.js, requires-body=true
4+
http-response ^https://8.8.8.8/(home|sub|my|app|log)($|\/) script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/chavy.box.js, requires-body=true

‎surge.box.sgmodule‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
[Script]
55
Rewrite: Scripts Manager = type=http-request,pattern=^https://8.8.8.8/api,script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/chavy.box.js,requires-body=true,max-size=0
6-
Rewrite: Scripts Manager = type=http-response,pattern=^https://8.8.8.8/(home|sub|my|app|log\/),script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/chavy.box.js,requires-body=true,max-size=0
6+
Rewrite: Scripts Manager = type=http-response,pattern=^https://8.8.8.8/(home|sub|my|app|log)($|\/),script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/chavy.box.js,requires-body=true,max-size=0
77

88
[MITM]
99
hostname = %INSERT%, 8.8.8.8

0 commit comments

Comments
 (0)