feat(web): I1 shell and I2 customer/project UI

Vue 3 + Element Plus layout with JWT login, RBAC routes, axios 401
handling with token restore, and Customers/Projects views wired to
platform APIs.

Made-with: Cursor
This commit is contained in:
2026-04-06 21:05:02 +08:00
parent 3f577b34d5
commit 65eb983035
18 changed files with 2939 additions and 0 deletions
@@ -0,0 +1,34 @@
import { defineStore } from "pinia";
import axios from "axios";
const TOKEN_KEY = "craftlabs_platform_token";
export const useAuthStore = defineStore("auth", {
state: () => ({
token: localStorage.getItem(TOKEN_KEY) || "",
displayName: "",
roles: [],
}),
actions: {
async login(username, password) {
const { data } = await axios.post("/api/v1/auth/login", { username, password });
this.token = data.token;
this.displayName = data.displayName || username;
this.roles = data.roles || [];
localStorage.setItem(TOKEN_KEY, this.token);
axios.defaults.headers.common.Authorization = `Bearer ${this.token}`;
},
logout() {
this.token = "";
this.displayName = "";
this.roles = [];
localStorage.removeItem(TOKEN_KEY);
delete axios.defaults.headers.common.Authorization;
},
restoreAxiosAuth() {
if (this.token) {
axios.defaults.headers.common.Authorization = `Bearer ${this.token}`;
}
},
},
});