mirror of
https://github.com/lifegpc/eh-downloader.git
synced 2026-06-06 05:38:44 +08:00
Add PWA support
This commit is contained in:
@@ -36,7 +36,7 @@ export default function Index({ data }: PageProps<Props>) {
|
||||
: null}
|
||||
</Head>
|
||||
<GlobalContext>
|
||||
<Container i18n={i18n} />
|
||||
<Container i18n={i18n} lang={data.lang} />
|
||||
</GlobalContext>
|
||||
</body>
|
||||
);
|
||||
|
||||
47
routes/manifest.json.ts
Normal file
47
routes/manifest.json.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { Handlers } from "$fresh/server.ts";
|
||||
import { get_i18nmap, i18n_handle_request } from "../server/i18ns.ts";
|
||||
import t, { i18n_map } from "../server/i18n.ts";
|
||||
|
||||
export const handler: Handlers = {
|
||||
GET(req, _ctx) {
|
||||
const i18n = i18n_handle_request(req);
|
||||
if (typeof i18n === "string") {
|
||||
const m = get_i18nmap(i18n);
|
||||
i18n_map.value = m;
|
||||
const base = `/?lang=${i18n}`;
|
||||
const data = {
|
||||
name: t("common.title"),
|
||||
lang: i18n,
|
||||
start_url: base,
|
||||
display: "standalone",
|
||||
icons: [
|
||||
{
|
||||
src: "/favicon.ico",
|
||||
sizes: "64x64",
|
||||
"type": "image/vnd.microsoft.icon",
|
||||
},
|
||||
{
|
||||
src: "/logo.svg",
|
||||
sizes: "any",
|
||||
"type": "image/svg+xml",
|
||||
},
|
||||
],
|
||||
scope: base,
|
||||
shortcuts: [
|
||||
{
|
||||
name: t("task.add"),
|
||||
url: `${base}#/task_manager/new`,
|
||||
},
|
||||
{
|
||||
name: t("common.settings"),
|
||||
url: `${base}#/settings`,
|
||||
},
|
||||
],
|
||||
};
|
||||
return new Response(JSON.stringify(data), {
|
||||
headers: { "Content-Type": "application/manifest+json" },
|
||||
});
|
||||
}
|
||||
return i18n;
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user