feat: 逻辑完善,对接后端菜单接口完成

This commit is contained in:
李寻欢 2024-02-01 18:09:10 +08:00
parent fb187190b6
commit 9f1b4ed85b
6 changed files with 36 additions and 112 deletions

View File

@ -1,49 +0,0 @@
// 模拟后端动态生成路由
import { MockMethod } from "vite-plugin-mock";
/**
* roles "admin""common"
* admin
* common
*/
const permissionRouter = {
path: "/permission",
meta: {
title: "权限管理",
icon: "lollipop",
rank: 10
},
children: [
{
path: "/permission/page/index",
name: "PermissionPage",
meta: {
title: "页面权限",
roles: ["admin", "common"]
}
},
{
path: "/permission/button/index",
name: "PermissionButton",
meta: {
title: "按钮权限",
roles: ["admin", "common"],
auths: ["btn_add", "btn_edit", "btn_delete"]
}
}
]
};
export default [
{
url: "/getAsyncRoutes",
method: "get",
response: () => {
return {
success: true,
data: [permissionRouter]
};
}
}
] as MockMethod[];

View File

@ -1,36 +0,0 @@
// 根据角色动态生成路由
import { MockMethod } from "vite-plugin-mock";
export default [
{
url: "/login",
method: "post",
response: ({ body }) => {
if (body.username === "admin") {
return {
success: true,
data: {
username: "admin",
// 一个用户可能有多个角色
roles: ["admin"],
accessToken: "eyJhbGciOiJIUzUxMiJ9.admin",
refreshToken: "eyJhbGciOiJIUzUxMiJ9.adminRefresh",
expires: "2023/10/30 00:00:00"
}
};
} else {
return {
success: true,
data: {
username: "common",
// 一个用户可能有多个角色
roles: ["common"],
accessToken: "eyJhbGciOiJIUzUxMiJ9.common",
refreshToken: "eyJhbGciOiJIUzUxMiJ9.commonRefresh",
expires: "2023/10/30 00:00:00"
}
};
}
}
}
] as MockMethod[];

View File

@ -1,27 +0,0 @@
import { MockMethod } from "vite-plugin-mock";
// 模拟刷新token接口
export default [
{
url: "/refreshToken",
method: "post",
response: ({ body }) => {
if (body.refreshToken) {
return {
success: true,
data: {
accessToken: "eyJhbGciOiJIUzUxMiJ9.newAdmin",
refreshToken: "eyJhbGciOiJIUzUxMiJ9.newAdminRefresh",
// `expires`选择这种日期格式是为了方便调试,后端直接设置时间戳或许更方便(每次都应该递增)。如果后端返回的是时间戳格式,前端开发请来到这个目录`src/utils/auth.ts`,把第`38`行的代码换成expires = data.expires即可。
expires: "2023/10/30 23:59:59"
}
};
} else {
return {
success: false,
data: {}
};
}
}
}
] as MockMethod[];

View File

@ -0,0 +1,12 @@
<script setup lang="ts">
defineOptions({
name: "AdminRole"
});
</script>
<template>
<div class="flex justify-center items-center h-[640px]">
角色管理
</div>
</template>

View File

@ -0,0 +1,12 @@
<script setup lang="ts">
defineOptions({
name: "AdminUser"
});
</script>
<template>
<div class="flex justify-center items-center h-[640px]">
用户管理
</div>
</template>

View File

@ -0,0 +1,12 @@
<script setup lang="ts">
defineOptions({
name: "AdminUser"
});
</script>
<template>
<div class="flex justify-center items-center h-[640px]">
用户管理
</div>
</template>