From 842f69c691ce50852d88b0578b006c35fdbb6fe6 Mon Sep 17 00:00:00 2001 From: Liwanyi Date: Sat, 1 Oct 2022 15:38:24 +0800 Subject: [PATCH] =?UTF-8?q?TS=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/class/UrlMatch.ts | 2 +- src/class/WuhuConfig.ts | 12 ++++++++++-- src/class/action/TravelItem.ts | 4 ++-- src/class/utils/CommonUtils.ts | 4 ++-- src/html/loading_img.html | 3 +++ src/html/stock_img.html | 2 ++ src/json/github.io.stock.png.json | 3 --- src/json/loading.json | 4 ---- 8 files changed, 20 insertions(+), 14 deletions(-) create mode 100644 src/html/loading_img.html create mode 100644 src/html/stock_img.html delete mode 100644 src/json/github.io.stock.png.json delete mode 100644 src/json/loading.json diff --git a/src/class/UrlMatch.ts b/src/class/UrlMatch.ts index 44fbd29..65636f2 100644 --- a/src/class/UrlMatch.ts +++ b/src/class/UrlMatch.ts @@ -310,7 +310,7 @@ $1,000 // 圣诞小镇 if (href.contains(/christmas_town\.php/)) { let $root = document.querySelector('#christmastownroot'); - const { xmasTownWT, xmasTownNotify } = getWhSettingObj() + const [xmasTownWT, xmasTownNotify] = WuhuConfig.get(['xmasTownWT', 'xmasTownNotify']); // 解密攻略 if (xmasTownWT) { const insert_html = `
diff --git a/src/class/WuhuConfig.ts b/src/class/WuhuConfig.ts index 3d3f148..cae881c 100644 --- a/src/class/WuhuConfig.ts +++ b/src/class/WuhuConfig.ts @@ -3,8 +3,16 @@ import Alert from "./utils/Alert"; import Log from "./Log"; export default class WuhuConfig extends WuhuBase { - static get(key: string) { - return WuhuConfig.getLocal()[key]; + static get(key: string | string[]) { + let localPool = this.getLocal(); + if (typeof key === 'string') return localPool[key]; + else { + let ret: string[] = []; + key.forEach(k => { + ret.push(localPool[k]) + }); + return ret; + } } static set(key: string, val: any, isNotify = false, callback: Function = () => null) { diff --git a/src/class/action/TravelItem.ts b/src/class/action/TravelItem.ts index 8210403..29af229 100644 --- a/src/class/action/TravelItem.ts +++ b/src/class/action/TravelItem.ts @@ -3,7 +3,7 @@ import Log from "../Log"; import WuhuBase from "../WuhuBase"; import UserScriptEngine from "../../enum/UserScriptEngine"; import Popup from "../utils/Popup"; -import * as STOCK_PNG from "../../json/github.io.stock.png.json"; +import STOCK_IMG_HTML from "../../html/stock_img.html"; import * as FILTER from "../../json/ForStockItemFilter.json"; export default class TravelItem extends WuhuBase { @@ -35,7 +35,7 @@ export default class TravelItem extends WuhuBase { // 呈现内容 public async clickHandler(): Promise { if (CommonUtils.getScriptEngine() === UserScriptEngine.RAW) { - new Popup(STOCK_PNG.html.replace('{{}}', performance.now().toString()), '飞花库存'); + new Popup(STOCK_IMG_HTML.replace('{{}}', performance.now().toString()), '飞花库存'); } else { const popup = new Popup("请稍后 " + CommonUtils.loading_gif_html(), '飞花库存'); let table = ``; diff --git a/src/class/utils/CommonUtils.ts b/src/class/utils/CommonUtils.ts index 155aa7c..ec48470 100644 --- a/src/class/utils/CommonUtils.ts +++ b/src/class/utils/CommonUtils.ts @@ -4,7 +4,7 @@ import Log from "../Log"; import Device from "../../enum/Device"; import AjaxFetchOption from "../../interface/AjaxFetchOption"; import Alert from "./Alert"; -import * as LOADING_JSON from "../../json/loading.json"; +import LOADING_IMG_HTML from "../../html/loading_img.html"; export default class CommonUtils extends WuhuBase { static getScriptEngine() { @@ -175,6 +175,6 @@ export default class CommonUtils extends WuhuBase { } static loading_gif_html(): string { - return LOADING_JSON.html; + return LOADING_IMG_HTML; } } \ No newline at end of file diff --git a/src/html/loading_img.html b/src/html/loading_img.html new file mode 100644 index 0000000..c3d64ec --- /dev/null +++ b/src/html/loading_img.html @@ -0,0 +1,3 @@ +LOADING \ No newline at end of file diff --git a/src/html/stock_img.html b/src/html/stock_img.html new file mode 100644 index 0000000..232f308 --- /dev/null +++ b/src/html/stock_img.html @@ -0,0 +1,2 @@ +stock.png \ No newline at end of file diff --git a/src/json/github.io.stock.png.json b/src/json/github.io.stock.png.json deleted file mode 100644 index 2df561e..0000000 --- a/src/json/github.io.stock.png.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "html": "\"stock.png\"" -} \ No newline at end of file diff --git a/src/json/loading.json b/src/json/loading.json deleted file mode 100644 index e467d5f..0000000 --- a/src/json/loading.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "loading gif html", - "html": "\"lgif\"" -} \ No newline at end of file
目的地 - 更新时间库存