initial commit

This commit is contained in:
陈文彬
2020-09-28 20:19:10 +08:00
commit 2f6253cfb6
436 changed files with 26843 additions and 0 deletions

132
mock/sys/menu.ts Normal file
View File

@@ -0,0 +1,132 @@
import { resultSuccess } from '../_util';
import { MockMethod } from 'vite-plugin-mock';
const dashboardRoute = {
layout: {
path: '/dashboard',
name: 'Dashboard',
component: 'PAGE_LAYOUT',
redirect: '/dashboard/welcome',
meta: {
icon: 'ant-design:home-outlined',
title: 'Dashboard',
},
},
routes: [
{
path: '/welcome',
name: 'Welcome',
component: '/dashboard/welcome/index.vue',
meta: {
title: '欢迎页',
affix: true,
},
},
],
};
const frontRoute = {
path: '/front',
name: 'PermissionFrontDemo',
meta: {
title: '基于前端权限',
},
children: [
{
path: 'page',
component: '/demo/permission/front/index.vue',
meta: {
title: '页面权限',
},
},
{
path: 'btn',
component: '/demo/permission/front/Btn.vue',
meta: {
title: '按钮权限',
},
},
{
path: 'auth-pageA',
component: '/demo/permission/front/AuthPageA.vue',
meta: {
title: '权限测试页A',
},
},
{
path: 'auth-pageB',
component: '/demo/permission/front/AuthPageB.vue',
meta: {
title: '权限测试页B',
},
},
],
};
const backRoute = {
path: '/back',
name: 'PermissionBackDemo',
meta: {
title: '基于后台权限',
},
children: [
{
path: 'page',
component: 'demo/permission/back/index.vue',
meta: {
title: '页面权限',
},
},
{
path: 'btn',
component: '/demo/permission/back/Btn.vue',
meta: {
title: '按钮权限',
},
},
],
};
const authRoute = {
layout: {
path: '/permission',
name: 'Permission',
component: 'PAGE_LAYOUT',
redirect: '/permission/front/page',
meta: {
icon: 'ant-design:home-outlined',
title: '权限管理',
},
},
routes: [frontRoute, backRoute],
};
const authRoute1 = {
layout: {
path: '/permission',
name: 'Permission',
component: 'PAGE_LAYOUT',
redirect: '/permission/front/page',
meta: {
icon: 'ant-design:home-outlined',
title: '权限管理',
},
},
routes: [backRoute],
};
export default [
{
url: '/api/getMenuListById',
timeout: 1000,
method: 'get',
response: ({ query }) => {
const { id } = query;
if (!id || id === '1') {
return resultSuccess([dashboardRoute, authRoute]);
}
if (id === '2') {
return resultSuccess([dashboardRoute, authRoute1]);
}
},
},
] as MockMethod[];

90
mock/sys/user.ts Normal file
View File

@@ -0,0 +1,90 @@
import { MockMethod } from 'vite-plugin-mock';
import { resultError, resultSuccess } from '../_util';
function createFakeUserList() {
return [
{
userId: '1',
username: 'vben',
realName: 'Vben',
desc: 'manager',
password: '123456',
token: 'fakeToken1',
role: {
roleName: 'Super Admin',
value: 'super',
},
},
{
userId: '2',
username: 'test',
password: '123456',
realName: 'test user',
desc: 'tester',
token: 'fakeToken2',
role: {
roleName: 'Tester',
value: 'test',
},
},
];
}
const fakeCodeList: any = {
'1': ['1000', '3000', '5000'],
'2': ['2000', '4000', '6000'],
};
export default [
// mock user login
{
url: '/api/login',
timeout: 1000,
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, role } = checkUser;
return resultSuccess({
role,
userId,
username: _username,
token,
realName,
desc,
});
},
},
{
url: '/api/getUserInfoById',
timeout: 200,
method: 'get',
response: ({ query }) => {
const { userId } = query;
const checkUser = createFakeUserList().find((item) => item.userId === userId);
if (!checkUser) {
return resultError('The corresponding user information was not obtained!');
}
return resultSuccess(checkUser);
},
},
{
url: '/api/getPermCodeByUserId',
timeout: 200,
method: 'get',
response: ({ query }) => {
const { userId } = query;
if (!userId) {
return resultError('userId is not null!');
}
const codeList = fakeCodeList[userId];
return resultSuccess(codeList);
},
},
] as MockMethod[];