feat: 权限控制

This commit is contained in:
xiaojunnuo
2023-06-27 09:29:43 +08:00
parent fdc25dc0d7
commit 27a4c81c6d
37 changed files with 325 additions and 134 deletions
@@ -1,5 +1,11 @@
import { request, requestForMock } from "../service";
import { env } from "/@/utils/util.env";
export interface RegisterReq {
username: string;
password: string;
confirmPassword: string;
}
/**
* @description: Login interface parameters
*/
@@ -19,6 +25,14 @@ export interface LoginRes {
expire: number;
}
export async function register(user: RegisterReq): Promise<UserInfoRes> {
return await request({
url: "/register",
method: "post",
data: user
});
}
export async function login(data: LoginReq): Promise<LoginRes> {
if (env.PM_ENABLED === "false") {
//没有开启权限模块,模拟登录
+1 -1
View File
@@ -31,7 +31,7 @@ function createService() {
const { code } = dataAxios;
// 根据 code 进行判断
if (code === undefined) {
// 如果没有 code 代表这不是项目后端开发的接口 比如可能是 D2Admin 请求最新版本
// 如果没有 code 代表这不是项目后端开发的接口
errorCreate(`非标准返回:${dataAxios} ${response.config.url}`);
return dataAxios;
} else {
+3 -1
View File
@@ -63,5 +63,7 @@ export function errorLog(error: any) {
* @param {String} msg 错误信息
*/
export function errorCreate(msg: string) {
throw new Error(msg);
const err = new Error(msg);
uiContext.get().notification.error({ message: err.message });
throw err;
}