mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-03 13:44:47 +08:00
feat: 添加按钮权限
This commit is contained in:
@@ -8,12 +8,28 @@ export const usePermissionStore = defineStore({
|
||||
state: () => ({
|
||||
constantRoutes: constantRoutesArr, //静态路由
|
||||
wholeRoutes: [],
|
||||
buttonAuth: [],
|
||||
}),
|
||||
actions: {
|
||||
asyncActionRoutes(routes) {
|
||||
if (this.wholeRoutes.length > 0) return;
|
||||
this.wholeRoutes = ascending(this.constantRoutes.concat(routes)).filter(
|
||||
(v) => v.meta.showLink
|
||||
);
|
||||
|
||||
const getButtonAuth = (arrRoutes: Array<string>) => {
|
||||
if (!arrRoutes || !arrRoutes.length) return;
|
||||
arrRoutes.forEach((v: any) => {
|
||||
if (v.meta && v.meta.authority) {
|
||||
this.buttonAuth.push(...v.meta.authority);
|
||||
}
|
||||
if (v.children) {
|
||||
getButtonAuth(v.children);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
getButtonAuth(this.wholeRoutes);
|
||||
},
|
||||
async changeSetting(routes) {
|
||||
await this.asyncActionRoutes(routes);
|
||||
|
||||
Reference in New Issue
Block a user