feat(storage): add offline SQLite mode

This commit is contained in:
Codex committed 2026-10-02 16:18:13 +00:00
1 parent 0a68782172
commit ada528ed7b
13 files changed
+299 -21

No files matched your search

+5 -4
View File
@@ -1,4 +1,5 @@
import { addonsJs, bootGuardJs, i18nJs, localeEn, localeZh, localeEnJs, localeZhJs, localeScripts, localeData, tasksJs, calendarJs, notificationsJs, i18nRenderersJs, systemNavigationJs, browserAppJs, dataActionsJs, terminalAppJs, dbAdminJs, indexHtml, manifest, serviceWorker, icon } from "./assets.js";
import { localDbWorkerJs, sqliteModuleJs, sqliteWasmBase64 } from "./local-assets.js";
import { cloudApi } from "./cloud-state.js";
import { dbAdminApi } from "./db-admin.js";
@@ -77,6 +78,9 @@ export default {
return Response.json({ error: "Bing wallpaper is temporarily unavailable", detail: String(error) }, { status: 502 });
}
if (url.pathname === "/addons.js") return new Response(addonsJs, { headers: headers("application/javascript; charset=utf-8", "no-cache") });
if (url.pathname === "/local-db-worker.js") return new Response(localDbWorkerJs, { headers: headers("application/javascript; charset=utf-8", "public, max-age=31536000, immutable") });
if (url.pathname === "/sqlite3.mjs") return new Response(sqliteModuleJs, { headers: headers("application/javascript; charset=utf-8", "public, max-age=31536000, immutable") });
if (url.pathname === "/sqlite3.wasm") return new Response(Uint8Array.from(atob(sqliteWasmBase64), char => char.charCodeAt(0)), { headers: headers("application/wasm", "public, max-age=31536000, immutable") });
if (url.pathname === "/service-worker.js") return new Response(serviceWorker, { headers: headers("application/javascript; charset=utf-8", "no-cache") });
if (url.pathname === "/manifest.webmanifest") return new Response(manifest, { headers: headers("application/manifest+json; charset=utf-8", "no-cache") });
if (url.pathname === "/life-os-icon.svg") return new Response(icon, { headers: headers("image/svg+xml", "public, max-age=86400") });
@@ -95,10 +99,7 @@ export default {
if (url.pathname === "/system-navigation.js") return new Response(systemNavigationJs, { headers: headers("application/javascript; charset=utf-8", "no-cache") });
if (url.pathname === "/browser-app.js") return new Response(browserAppJs, { headers: headers("application/javascript; charset=utf-8", "no-cache") });
if (url.pathname === "/i18n-renderers.js") return new Response(i18nRenderersJs, { headers: headers("application/javascript; charset=utf-8", "no-cache") });
if (url.pathname === "/" || url.pathname === "/index.html") {
if (!id) return new Response(loginPage(request), { headers: headers("text/html; charset=utf-8", "no-cache") });
return new Response(indexHtml, { headers: headers("text/html; charset=utf-8", "no-cache") });
}
if (url.pathname === "/" || url.pathname === "/index.html") return new Response(indexHtml, { headers: headers("text/html; charset=utf-8", "no-cache") });
return new Response("Not found", { status: 404 });
},
};