Move the dashboard and setup pages to a Vue SPA
The pages are now a Vue 3 + Vite + TypeScript app in web/, built into internal/web/dist/app and embedded in the binary. Go still serves index.html for / and /setup behind the admin gate, plus the hashed /assets/* (public, cached forever). The router takes its base from the current URL, so it works under nginx's /tracker/ prefix unchanged. Only dist/.gitkeep is committed, so go build and go test need no Node; an unbuilt binary shows a "run make web" page at /. The Dockerfile gains a Node stage, CI typechecks and builds the app, and make build/run build it first. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { createApp } from "vue";
|
||||
import { createRouter, createWebHistory } from "vue-router";
|
||||
import App from "./App.vue";
|
||||
import Dashboard from "./views/Dashboard.vue";
|
||||
import Setup from "./views/Setup.vue";
|
||||
import "./style.css";
|
||||
|
||||
const router = createRouter({
|
||||
// The tracker is served under a prefix only the browser knows (nginx strips
|
||||
// /tracker/), and every route is one segment deep, so the directory of the
|
||||
// current URL is the app's base.
|
||||
history: createWebHistory(new URL(".", location.href).pathname),
|
||||
routes: [
|
||||
{ path: "/", component: Dashboard, meta: { title: "Activity Tracker" } },
|
||||
{ path: "/setup", component: Setup, meta: { title: "Activity Tracker Setup" } },
|
||||
{ path: "/:rest(.*)", redirect: "/" },
|
||||
],
|
||||
scrollBehavior: to => (to.hash ? { el: to.hash } : { top: 0 }),
|
||||
});
|
||||
router.afterEach(to => { document.title = String(to.meta.title); });
|
||||
|
||||
createApp(App).use(router).mount("#app");
|
||||
Reference in New Issue
Block a user