diff --git a/apps/zhi-core/src/theme/zhi.ts b/apps/zhi-core/src/theme/zhi.ts index f9fee684..6adf04fe 100644 --- a/apps/zhi-core/src/theme/zhi.ts +++ b/apps/zhi-core/src/theme/zhi.ts @@ -53,6 +53,7 @@ class Zhi { */ public async init(): Promise { try { + alert(this.runAs) this.logger.info(`Theme runAs ${this.runAs}`) this.logger.info("Theme inited.") } catch (e) { diff --git a/apps/zhi-device-detection/README.md b/apps/zhi-device-detection/README.md index cfdb476e..0f392440 100644 --- a/apps/zhi-device-detection/README.md +++ b/apps/zhi-device-detection/README.md @@ -1,2 +1,62 @@ # zhi-device-detection -auto check environment whether in browser, browser extension, electron, node and more \ No newline at end of file + +auto check environment whether in browser, browser extension, electron, node and more + +## Usage + +```ts +import DeviceDetection, { BrowserUtil, DeviceTypeEnum } from "zhi-device-detection" + +console.log("isInBrowser=>", BrowserUtil.isInBrowser) + +const deviceType: DeviceTypeEnum = DeviceDetection.getDevice() +console.log("deviceType=>", deviceType) + +// supported platforms +// Mobile +// Siyuan_Widget +// Siyuan_NewWindow +// Siyuan_MainWindow +// Chrome_Extension +// Chrome_Browser +// Node +``` + +## Deps + +``` +## Congregations! zhi-device-detection need no deps, it is just pure js code 🎉 +``` + +## Dev + +```bash +pnpm dev -F zhi-device-detection +``` + +## Build + +```bash +pnpm build -F zhi-device-detection +``` + +## Api + +```bash +pnpm doc -F zhi-device-detection +pnpm md -F zhi-device-detection +``` + +## Test + +Execute the unit tests via [jest](https://jestjs.io/docs/getting-started#via-ts-jest) + +```bash +pnpm test -F zhi-device-detection +``` + +## Publish + +``` +pnpm publish -F zhi-device-detection --ver=0.1.0 --tag=latest +``` \ No newline at end of file diff --git a/apps/zhi-device-detection/src/index.ts b/apps/zhi-device-detection/src/index.ts index dec594e4..ea06892b 100644 --- a/apps/zhi-device-detection/src/index.ts +++ b/apps/zhi-device-detection/src/index.ts @@ -25,9 +25,11 @@ import DeviceDetection from "./deviceDetection" import DeviceTypeEnum from "./lib/deviceTypeEnum" +import BrowserUtil from "./lib/browserUtil" /** * zhi-device-detection 入口 */ export default DeviceDetection +export { BrowserUtil } export { DeviceTypeEnum } diff --git a/apps/zhi-device-detection/src/lib/browserUtil.ts b/apps/zhi-device-detection/src/lib/browserUtil.ts index f8f870c4..3fff538a 100644 --- a/apps/zhi-device-detection/src/lib/browserUtil.ts +++ b/apps/zhi-device-detection/src/lib/browserUtil.ts @@ -183,14 +183,15 @@ class BrowserUtil { * 重新加载指定tab * * @param tabname - tabname + * @param t - 延迟时间 */ - public static reloadTabPage = (tabname: string): void => { + public static reloadTabPage = (tabname: string, t = 200): void => { setTimeout(function () { if (BrowserUtil.isInBrowser) { const url = window.location.href window.location.href = BrowserUtil.setUrlParameter(url, "tab", tabname) } - }, 200) + }, t) } /**