feat(m11): add v-permission directive and button-level permission codes

This commit is contained in:
2026-05-25 01:41:50 +08:00
parent 1f599e5646
commit 3bb19537fe
6 changed files with 69 additions and 10 deletions
@@ -8,6 +8,7 @@ export const useAuthStore = defineStore("auth", {
token: localStorage.getItem(TOKEN_KEY) || "",
displayName: "",
roles: [],
permissions: [],
}),
getters: {
hasAnyRole: (state) => {
@@ -24,6 +25,7 @@ export const useAuthStore = defineStore("auth", {
this.token = data.token;
this.displayName = data.displayName || username;
this.roles = data.roles || [];
this.permissions = data.permissions || [];
localStorage.setItem(TOKEN_KEY, this.token);
axios.defaults.headers.common.Authorization = `Bearer ${this.token}`;
},
@@ -31,6 +33,7 @@ export const useAuthStore = defineStore("auth", {
this.token = "";
this.displayName = "";
this.roles = [];
this.permissions = [];
localStorage.removeItem(TOKEN_KEY);
delete axios.defaults.headers.common.Authorization;
},