🎨合并编译打包
Some checks failed
continuous-integration/drone/tag Build is failing

This commit is contained in:
coward
2024-06-04 09:55:48 +08:00
parent e1f168b274
commit 6d4f4b2e02
275 changed files with 17590 additions and 951 deletions

View File

@@ -0,0 +1,52 @@
// 模拟后端动态生成路由
import { defineFakeRoute } from "vite-plugin-fake-server/client";
/**
* roles页面级别权限这里模拟二种 "user"、"common"
* user管理员角色
* common普通角色
*/
const permissionRouter = {
path: "/permission",
meta: {
title: "权限管理",
icon: "ep:lollipop",
rank: 10
},
children: [
{
path: "/permission/page/index",
name: "PermissionPage",
meta: {
title: "页面权限",
roles: ["user", "common"]
}
},
{
path: "/permission/button/index",
name: "PermissionButton",
meta: {
title: "按钮权限",
roles: ["user", "common"],
auths: [
"permission:btn:add",
"permission:btn:edit",
"permission:btn:delete"
]
}
}
]
};
export default defineFakeRoute([
{
url: "/get-async-routes",
method: "get",
response: () => {
return {
success: true,
data: [permissionRouter]
};
}
}
]);

39
web-src/mock/login.ts Normal file
View File

@@ -0,0 +1,39 @@
// 根据角色动态生成路由
import { defineFakeRoute } from "vite-plugin-fake-server/client";
export default defineFakeRoute([
{
url: "/login",
method: "post",
response: ({ body }) => {
if (body.username === "user") {
return {
success: true,
data: {
avatar: "https://avatars.githubusercontent.com/u/44761321",
username: "user",
nickname: "小铭",
// 一个用户可能有多个角色
roles: ["user"],
accessToken: "eyJhbGciOiJIUzUxMiJ9.user",
refreshToken: "eyJhbGciOiJIUzUxMiJ9.adminRefresh",
expires: "2030/10/30 00:00:00"
}
};
} else {
return {
success: true,
data: {
avatar: "https://avatars.githubusercontent.com/u/52823142",
username: "common",
nickname: "小林",
roles: ["common"],
accessToken: "eyJhbGciOiJIUzUxMiJ9.common",
refreshToken: "eyJhbGciOiJIUzUxMiJ9.commonRefresh",
expires: "2030/10/30 00:00:00"
}
};
}
}
}
]);

View File

@@ -0,0 +1,27 @@
import { defineFakeRoute } from "vite-plugin-fake-server/client";
// 模拟刷新token接口
export default defineFakeRoute([
{
url: "/refresh-token",
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: "2030/10/30 23:59:59"
}
};
} else {
return {
success: false,
data: {}
};
}
}
}
]);