add manifest

This commit is contained in:
Timi
2026-04-13 18:29:36 +08:00
parent 9942afafa7
commit 631122c79b
3 changed files with 66 additions and 1 deletions

View File

@@ -3,7 +3,14 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
<meta name="application-name" content="Timi Server" />
<meta name="mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="apple-mobile-web-app-title" content="Timi Server" />
<meta name="format-detection" content="telephone=no" />
<meta name="theme-color" content="#ffffff" />
<link rel="manifest" href="/manifest.webmanifest" />
<title>Timi Server</title>
</head>
<body>

View File

@@ -0,0 +1,10 @@
{
"name": "Timi Server",
"short_name": "Timi",
"lang": "zh-CN",
"start_url": "/",
"scope": "/",
"display": "standalone",
"background_color": "#ffffff",
"theme_color": "#ffffff"
}

View File

@@ -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();