add manifest
This commit is contained in:
50
src/main.ts
50
src/main.ts
@@ -11,6 +11,53 @@ import "vue-virtual-scroller/dist/vue-virtual-scroller.css";
|
||||
import { axios } from "timi-web";
|
||||
import { useSettingStore } from "@/store/settingStore.ts";
|
||||
|
||||
type FullscreenElement = HTMLElement & {
|
||||
webkitRequestFullscreen?: () => Promise<void> | void;
|
||||
msRequestFullscreen?: () => Promise<void> | void;
|
||||
};
|
||||
|
||||
type StandaloneNavigator = Navigator & {
|
||||
standalone?: boolean;
|
||||
};
|
||||
|
||||
const requestLaunchFullscreen = async (): Promise<void> => {
|
||||
if (document.fullscreenElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
const navigatorInfo = window.navigator as StandaloneNavigator;
|
||||
const isStandaloneMode = window.matchMedia("(display-mode: standalone)").matches || navigatorInfo.standalone === true;
|
||||
if (isStandaloneMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
const rootElement = document.documentElement as FullscreenElement;
|
||||
if (rootElement.requestFullscreen) {
|
||||
await rootElement.requestFullscreen();
|
||||
return;
|
||||
}
|
||||
if (rootElement.webkitRequestFullscreen) {
|
||||
await rootElement.webkitRequestFullscreen();
|
||||
return;
|
||||
}
|
||||
if (rootElement.msRequestFullscreen) {
|
||||
await rootElement.msRequestFullscreen();
|
||||
}
|
||||
};
|
||||
|
||||
const bindLaunchFullscreenRequest = (): void => {
|
||||
const onFirstInteraction = async (): Promise<void> => {
|
||||
try {
|
||||
await requestLaunchFullscreen();
|
||||
} catch (error) {
|
||||
console.warn("\u5168\u5c4f\u8bf7\u6c42\u88ab\u6d4f\u89c8\u5668\u62d2\u7edd\u6216\u4e0d\u652f\u6301", error);
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener("pointerdown", onFirstInteraction, { once: true, passive: true });
|
||||
window.addEventListener("keydown", onFirstInteraction, { once: true });
|
||||
};
|
||||
|
||||
axios.interceptors.request.use((config) => {
|
||||
const settingStore = useSettingStore();
|
||||
const token = settingStore.connect.token.trim();
|
||||
@@ -35,9 +82,10 @@ app.config.errorHandler = (error) => {
|
||||
console.error(error);
|
||||
Toast({
|
||||
theme: "error",
|
||||
message: "页面发生异常,请稍后重试"
|
||||
message: "\u9875\u9762\u53d1\u751f\u5f02\u5e38\uff0c\u8bf7\u7a0d\u540e\u91cd\u8bd5"
|
||||
});
|
||||
};
|
||||
app.use(pinia);
|
||||
app.use(router);
|
||||
app.mount("#root");
|
||||
bindLaunchFullscreenRequest();
|
||||
|
||||
Reference in New Issue
Block a user