vue-vben-admin/mock/sys/user.ts
mfish 8dd8a5ed01
个人设置图标修改时弹出窗显示原图片,由于跨域获取图片存在问题暂时将user.ts中的跨域图片链接去掉,直接采用本地图片 (#2487)
* feat(axiosSuccess): 操作成功后根据传入提示模式进行相应

* fix(axiosRetry): 解决get重试请求返回的headers造成无法成功请求的问题

* fix(axiosRetry): 参数首字母小写

* fix(useDataSource): 解决deleteTableRecord删除树形表格的行记录时,无法删除,无法找到子节点的问题

* feat(useDataSource): 删除之前提交代码遗留的console

* fix(permissionGuard): 当获取用户信息失败时,不允许正常登陆返回登陆界面

* fix(permissionGuard): 代码还原

* fix(menu): 解决隐藏菜单目录只能隐藏第一层目录的问题,递归隐藏所有子菜单

* feat(baseSetting): 个人设置图标修改时弹出窗显示原图片,由于跨域获取图片存在问题暂时将user.ts中的跨域图片链接去掉,直接采用本地图片
2023-01-18 11:17:18 +08:00

123 lines
3.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { MockMethod } from 'vite-plugin-mock';
import { resultError, resultSuccess, getRequestToken, requestParams } from '../_util';
export function createFakeUserList() {
return [
{
userId: '1',
username: 'vben',
realName: 'Vben Admin',
avatar: '',
desc: 'manager',
password: '123456',
token: 'fakeToken1',
homePath: '/dashboard/analysis',
roles: [
{
roleName: 'Super Admin',
value: 'super',
},
],
},
{
userId: '2',
username: 'test',
password: '123456',
realName: 'test user',
avatar: '',
desc: 'tester',
token: 'fakeToken2',
homePath: '/dashboard/workbench',
roles: [
{
roleName: 'Tester',
value: 'test',
},
],
},
];
}
const fakeCodeList: any = {
'1': ['1000', '3000', '5000'],
'2': ['2000', '4000', '6000'],
};
export default [
// mock user login
{
url: '/basic-api/login',
timeout: 200,
method: 'post',
response: ({ body }) => {
const { username, password } = body;
const checkUser = createFakeUserList().find(
(item) => item.username === username && password === item.password,
);
if (!checkUser) {
return resultError('Incorrect account or password');
}
const { userId, username: _username, token, realName, desc, roles } = checkUser;
return resultSuccess({
roles,
userId,
username: _username,
token,
realName,
desc,
});
},
},
{
url: '/basic-api/getUserInfo',
method: 'get',
response: (request: requestParams) => {
const token = getRequestToken(request);
if (!token) return resultError('Invalid token');
const checkUser = createFakeUserList().find((item) => item.token === token);
if (!checkUser) {
return resultError('The corresponding user information was not obtained!');
}
return resultSuccess(checkUser);
},
},
{
url: '/basic-api/getPermCode',
timeout: 200,
method: 'get',
response: (request: requestParams) => {
const token = getRequestToken(request);
if (!token) return resultError('Invalid token');
const checkUser = createFakeUserList().find((item) => item.token === token);
if (!checkUser) {
return resultError('Invalid token!');
}
const codeList = fakeCodeList[checkUser.userId];
return resultSuccess(codeList);
},
},
{
url: '/basic-api/logout',
timeout: 200,
method: 'get',
response: (request: requestParams) => {
const token = getRequestToken(request);
if (!token) return resultError('Invalid token');
const checkUser = createFakeUserList().find((item) => item.token === token);
if (!checkUser) {
return resultError('Invalid token!');
}
return resultSuccess(undefined, { message: 'Token has been destroyed' });
},
},
{
url: '/basic-api/testRetry',
statusCode: 405,
method: 'get',
response: () => {
return resultError('Error!');
},
},
] as MockMethod[];