Skip to content

Commit 580c6e7

Browse files
committed
缓存base url
1 parent 95e4c01 commit 580c6e7

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@
382382
var vTransfer = document.getElementById("vTransfer");
383383
var vSend = document.getElementById("vSend");
384384

385-
vUrl.value = new String(URL_GET); //main.js里访问不到,可能是script引用顺序问题
385+
vUrl.value = new String(URL_BASE + '/get'); //main.js里访问不到,可能是script引用顺序问题
386386

387387
var vMarkdown = document.getElementById('vMarkdown');
388388

js/main.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,13 @@
256256
//设置基地址
257257
setBaseUrl: function () {
258258
// 重新拉取文档
259-
if (baseUrl != this.getBaseUrl()) {
260-
baseUrl = this.getBaseUrl();
259+
var bu = this.getBaseUrl()
260+
if (baseUrl != bu) {
261+
baseUrl = bu;
261262
doc = null
262263
this.User = this.getCache(baseUrl, 'User') || {}
263264
this.remotes = []
265+
this.saveCache('', 'URL_BASE', baseUrl)
264266
}
265267
},
266268
//获取基地址
@@ -1347,6 +1349,17 @@
13471349
}
13481350
},
13491351
created () {
1352+
try { //可能URL_BASE是const类型,不允许改,这里是初始化,不能出错
1353+
var url = this.getCache('', 'URL_BASE')
1354+
if (StringUtil.isEmpty(url, true) == false) {
1355+
URL_BASE = url
1356+
}
1357+
} catch (e) {
1358+
console.log('created try { ' +
1359+
'\nURL_BASE = this.getCache(, URL_BASE)' +
1360+
'\n} catch (e) {\n' + e.message)
1361+
}
1362+
//无效,只能在index里设置 vUrl.value = this.getCache('', 'URL_BASE')
13501363
this.listHistory()
13511364
this.transfer()
13521365
}

0 commit comments

Comments
 (0)