提交 171206c6 编写于 作者: AndroidLeaves's avatar AndroidLeaves

update

上级 7baf3981
......@@ -418,7 +418,7 @@ class Widget extends BaseWidget {
let response = undefined;
try {
//////
const html = await this.httpGet(`${this.defaultPreference.domain}/search?q=${encodeURIComponent(keyword)}`, { jsonFormat: false, headers: this.defaultPreference.phoneHeaders });
const html = await this.httpGet(`${this.defaultPreference.domain}/search?q=${encodeURIComponent(keyword)}`, { jsonFormat: false, useCache: false, headers: this.defaultPreference.phoneHeaders });
let webview = new WebView();
await webview.loadHTML(html);
// 通过dom操作把HTML里面的热榜内容提取出来
......
......@@ -711,18 +711,22 @@ class BaseWidget {
headers: null,
logable: false,
useICloud: false,
useCache: true,
scriptName: this.scriptName
};
options = {
...defaultOptions,
...options
};
const { jsonFormat, headers, logable, useICloud, scriptName } = options;
const { jsonFormat, headers, logable, useICloud, useCache, scriptName } = options;
// 根据URL进行md5生成cacheKey
const cacheFileName = this.md5(url);
const ufm = this.useFileManager({ useICloud, scriptName });
// 读取本地缓存
const localCache = ufm.readStringCache(cacheFileName);
if (useCache) {
// 判断是否需要刷新
const lastCacheTime = ufm.getCacheModifyDate(cacheFileName);
const timeInterval = Math.floor((this.getCurrentTimeStamp() - lastCacheTime) / 60);
......@@ -740,6 +744,8 @@ class BaseWidget {
this.logDivider();
return jsonFormat ? JSON.parse(localCache) : localCache;
}
}
console.log(`🚀 Get在线请求:${url}`);
let req = new Request(url);
req.method = 'GET';
......@@ -792,6 +798,7 @@ class BaseWidget {
headers: null,
logable: false,
useICloud: false,
useCache: true,
scriptName: Script.name()
};
options = {
......@@ -799,11 +806,14 @@ class BaseWidget {
...options
};
const { jsonFormat, headers, logable, useICloud, scriptName } = options;
// 根据URL进行md5生成cacheKey
const cacheFileName = this.md5(url);
const ufm = this.useFileManager({ useICloud, scriptName });
// 读取本地缓存
const localCache = ufm.readStringCache(cacheFileName);
if (useCache) {
// 判断是否需要刷新
const lastCacheTime = ufm.getCacheModifyDate(cacheFileName);
const timeInterval = Math.floor((this.getCurrentTimeStamp() - lastCacheTime) / 60);
......@@ -821,6 +831,8 @@ class BaseWidget {
this.logDivider();
return jsonFormat ? JSON.parse(localCache) : localCache;
}
}
console.log(`🚀 Post在线请求:${url}`);
let req = new Request(url);
req.method = 'POST';
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册