perf: 优化

This commit is contained in:
pan 2024-03-13 17:59:07 +08:00
parent cdac80a1c2
commit ca89c4c501
2 changed files with 36 additions and 34 deletions

View File

@ -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"
}
};
}
}
}
]);

View File

@ -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" }
);
};