mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-06-08 01:17:23 +08:00
fix: 根据角色返回不同数据,权限管理
This commit is contained in:
parent
ad0281839f
commit
a26f711d83
@ -42,11 +42,18 @@ export default [
|
|||||||
{
|
{
|
||||||
url: "/getAsyncRoutes",
|
url: "/getAsyncRoutes",
|
||||||
method: "get",
|
method: "get",
|
||||||
response: () => {
|
response: ({ query }) => {
|
||||||
|
if (query.name === "admin") {
|
||||||
return {
|
return {
|
||||||
code: 0,
|
code: 0,
|
||||||
info: systemRouter,
|
info: systemRouter,
|
||||||
};
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
code: 0,
|
||||||
|
info: [],
|
||||||
|
};
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
] as MockMethod[];
|
] as MockMethod[];
|
||||||
|
26
mock/map.ts
26
mock/map.ts
@ -1,29 +1,29 @@
|
|||||||
import { MockMethod } from 'vite-plugin-mock'
|
import { MockMethod } from "vite-plugin-mock";
|
||||||
|
|
||||||
// http://mockjs.com/examples.html#Object
|
// http://mockjs.com/examples.html#Object
|
||||||
const mapList = (): any => {
|
const mapList = (): any => {
|
||||||
const result: any[] = []
|
const result: any[] = [];
|
||||||
for (let index = 0; index < 200; index++) {
|
for (let index = 0; index < 200; index++) {
|
||||||
result.push({
|
result.push({
|
||||||
plateNumber: "豫A@natural(11111, 99999)@character('upper')",
|
plateNumber: "豫A@natural(11111, 99999)@character('upper')",
|
||||||
driver: '@cname()',
|
driver: "@cname()",
|
||||||
"orientation|1-360": 100,
|
"orientation|1-360": 100,
|
||||||
"lng|113-114.1-10": 1,
|
"lng|113-114.1-10": 1,
|
||||||
"lat|34-35.1-10": 1
|
"lat|34-35.1-10": 1,
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
return result
|
return result;
|
||||||
}
|
};
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
{
|
{
|
||||||
url: '/getMapInfo',
|
url: "/getMapInfo",
|
||||||
method: 'get',
|
method: "get",
|
||||||
response: () => {
|
response: () => {
|
||||||
return {
|
return {
|
||||||
code: 0,
|
code: 0,
|
||||||
info: mapList()
|
info: mapList(),
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
] as MockMethod[]
|
] as MockMethod[];
|
||||||
|
@ -50,9 +50,7 @@ export const getServerConfig = async (): Promise<any> => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
getServerConfig().then(async () => {
|
getServerConfig().then(async () => {
|
||||||
app.use(router).use(store).use(useElementPlus).use(useTable).use(usI18n);
|
app.use(router);
|
||||||
|
|
||||||
await router.isReady();
|
await router.isReady();
|
||||||
|
app.use(store).use(useElementPlus).use(useTable).use(usI18n).mount("#app");
|
||||||
app.mount("#app");
|
|
||||||
});
|
});
|
||||||
|
@ -75,9 +75,12 @@ const whiteList = ["/login", "/register"];
|
|||||||
router.beforeEach((to, _from, next) => {
|
router.beforeEach((to, _from, next) => {
|
||||||
let isLogin = storageSession.getItem("info");
|
let isLogin = storageSession.getItem("info");
|
||||||
// _from?.name;
|
// _from?.name;
|
||||||
if (isLogin && isLogin.username === "admin") {
|
if (isLogin) {
|
||||||
// 异步路由
|
// 异步路由
|
||||||
getAsyncRoutes().then(({ info }) => {
|
getAsyncRoutes({ name: isLogin.username }).then(({ info }) => {
|
||||||
|
if (info.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
addAsyncRoutes([info]).forEach((v: any) => {
|
addAsyncRoutes([info]).forEach((v: any) => {
|
||||||
// 防止重复添加路由
|
// 防止重复添加路由
|
||||||
if (
|
if (
|
||||||
@ -92,6 +95,7 @@ router.beforeEach((to, _from, next) => {
|
|||||||
router.addRoute(v.name, v);
|
router.addRoute(v.name, v);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
console.log(router.options.routes);
|
||||||
}
|
}
|
||||||
NProgress.start();
|
NProgress.start();
|
||||||
const { t } = i18n.global;
|
const { t } = i18n.global;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user