wuhu-torn-helper/src/class/Application.ts
2022-11-10 18:05:07 +08:00

46 lines
1.3 KiB
TypeScript

import WuhuBase from "./WuhuBase";
import WuHuTornHelper from "./WuhuTornHelper";
import ZhongIcon from "./ZhongIcon";
import { Common } from "./Common";
import UrlPattern from "./UrlMatch";
import WuhuConfig from "./WuhuConfig";
import translateMain from "../func/translate/translateMain";
import CommonUtils from "./utils/CommonUtils";
export default class Application {
public static main(): void {
WuhuBase.conditionInterrupt();
// 初始化
WuHuTornHelper.getInstance().init();
// 插件设置默认值
WuhuConfig.setDefaults();
// 插件图标和设置菜单
ZhongIcon.getInstance().init();
let tmp = () => {
// 所有页面通用
try {
Common.getInstance().resolve(Application.main);
} catch (e) {
// if (e.message === '重载') Common.getInstance().resolve(null);
}
// URL匹配
UrlPattern.getInstance().resolve();
// 翻译
if (WuhuConfig.get('transEnable')) translateMain(window.location.href);
};
// TODO 临时检测jquery
if (typeof $ === "function") {
tmp();
} else {
CommonUtils.getInstance().jQueryReady().then(() => tmp());
}
}
}