mirror of
https://github.com/pure-admin/pure-admin-thin.git
synced 2025-04-24 23:47:17 +08:00
perf: 优化
This commit is contained in:
parent
cdac80a1c2
commit
ca89c4c501
@ -1,34 +0,0 @@
|
||||
// 根据角色动态生成路由
|
||||
import { defineFakeRoute } from "vite-plugin-fake-server/client";
|
||||
|
||||
export default defineFakeRoute([
|
||||
{
|
||||
url: "/login",
|
||||
method: "post",
|
||||
response: ({ body }) => {
|
||||
if (body.username === "admin") {
|
||||
return {
|
||||
success: true,
|
||||
data: {
|
||||
username: "admin",
|
||||
// 一个用户可能有多个角色
|
||||
roles: ["admin"],
|
||||
accessToken: "eyJhbGciOiJIUzUxMiJ9.admin",
|
||||
expires: "2030/10/30 00:00:00"
|
||||
}
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
success: true,
|
||||
data: {
|
||||
username: "common",
|
||||
// 一个用户可能有多个角色
|
||||
roles: ["common"],
|
||||
accessToken: "eyJhbGciOiJIUzUxMiJ9.common",
|
||||
expires: "2030/10/30 00:00:00"
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
]);
|
@ -1,3 +1,39 @@
|
||||
import { http } from "@/utils/http";
|
||||
import type { ApiAbstract } from "@/utils/http/ApiAbstract";
|
||||
|
||||
export const baseUrlApi = (url: string) => `/api/${url}`;
|
||||
export const baseUrlAuth = (url: string) => `/auth/${url}`;
|
||||
export const baseUrlAvatar = (url: string) => `/avatar/${url}`;
|
||||
|
||||
export const get = (params: any) => {
|
||||
return http.request<ApiAbstract>("get", baseUrlApi("menus"), {
|
||||
params
|
||||
});
|
||||
};
|
||||
|
||||
export const add = (data: any) => {
|
||||
return http.request("post", baseUrlApi("menus"), {
|
||||
data
|
||||
});
|
||||
};
|
||||
|
||||
export const del = (ids: number[] | any) => {
|
||||
return http.request("delete", baseUrlApi("menus"), {
|
||||
data: ids
|
||||
});
|
||||
};
|
||||
export const edit = (data: any) => {
|
||||
return http.request<ApiAbstract>("put", baseUrlApi("menus"), {
|
||||
data
|
||||
});
|
||||
};
|
||||
export const download = (data: any) => {
|
||||
return http.request<Blob>(
|
||||
"get",
|
||||
baseUrlApi("menus/download"),
|
||||
{
|
||||
data
|
||||
},
|
||||
{ responseType: "blob" }
|
||||
);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user