added as PWA

This commit is contained in:
liyunze 2026-08-31 23:01:27 +08:00
parent 203dccda52
commit 2ff5b92bbc
8 changed files with 5435 additions and 2 deletions

5383
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -24,6 +24,8 @@
"@sveltejs/vite-plugin-svelte": "^7.1.2",
"@tailwindcss/vite": "^4.3.0",
"@types/node": "^26.3.0",
"@vite-pwa/assets-generator": "^1.0.2",
"@vite-pwa/sveltekit": "^1.1.0",
"@vitest/browser-playwright": "^4.1.8",
"oxfmt": "^0.65.0",
"playwright": "^1.60.0",

2
src/app.d.ts vendored
View file

@ -1,3 +1,5 @@
/// <reference types="vite-plugin-pwa/client" />
export {};
declare global {

View file

@ -3,7 +3,18 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="text-scale" content="scale" />
<meta
name="description"
content="DSEC Notebook — a resource hub for Deakin University students. Shared study notes, questions and answers for SIT and Mathematics units."
/>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="default" />
<meta name="apple-mobile-web-app-title" content="Notebook" />
<meta name="format-detection" content="telephone=no" />
<meta name="theme-color" content="#ffffff" />
<link rel="manifest" href="/manifest.webmanifest" />
<link rel="icon" href="/favicon.ico" sizes="any" />
<link rel="apple-touch-icon" href="/apple-touch-icon-180x180.png" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link

View file

@ -9,12 +9,21 @@
onMount(() => {
initAuth();
});
onMount(async () => {
const { registerSW } = await import("virtual:pwa-register");
registerSW({
immediate: true,
onRegisterError(error) {
console.error("Service worker registration failed", error);
},
});
});
</script>
<svelte:head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="/favicon.svg" />
</svelte:head>
<div class="flex min-h-screen flex-col bg-white">

BIN
static/dsec-logo.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
static/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View file

@ -3,6 +3,7 @@ import { defineConfig } from "vitest/config";
import { playwright } from "@vitest/browser-playwright";
import adapter from "@sveltejs/adapter-node";
import { sveltekit } from "@sveltejs/kit/vite";
import { SvelteKitPWA } from "@vite-pwa/sveltekit";
export default defineConfig({
plugins: [
@ -17,6 +18,31 @@ export default defineConfig({
// adapter-node is used because the app persists data to a local SQLite file on the server.
adapter: adapter(),
}),
SvelteKitPWA({
registerType: "autoUpdate",
devOptions: {
enabled: true,
type: "module",
},
manifest: {
name: "DSEC Notebook",
short_name: "Notebook",
description:
"A resource hub for Deakin University students: shared study notes, questions and answers for SIT and Mathematics units.",
start_url: "/",
scope: "/",
display: "standalone",
background_color: "#ffffff",
theme_color: "#ffffff",
lang: "en",
},
pwaAssets: {
image: "static/dsec-logo.webp",
preset: "minimal-2023",
includeHtmlHeadLinks: false,
injectThemeColor: false,
},
}),
],
test: {
expect: { requireAssertions: true },