mirror of
https://github.com/fumiama/paper-manager.git
synced 2026-06-26 05:42:23 +08:00
optimize vben/mock
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { MockMethod } from 'vite-plugin-mock';
|
||||
import { resultError, resultPageSuccess, resultSuccess } from '../_util';
|
||||
import { MockMethod } from 'vite-plugin-mock'
|
||||
import { resultError, resultPageSuccess, resultSuccess } from '../_util'
|
||||
|
||||
const accountList = (() => {
|
||||
const result: any[] = [];
|
||||
const result: any[] = []
|
||||
for (let index = 0; index < 20; index++) {
|
||||
result.push({
|
||||
id: `${index}`,
|
||||
@@ -13,61 +13,61 @@ const accountList = (() => {
|
||||
createTime: '@datetime',
|
||||
remark: '@cword(10,20)',
|
||||
'status|1': ['0', '1'],
|
||||
});
|
||||
})
|
||||
}
|
||||
return result;
|
||||
})();
|
||||
return result
|
||||
})()
|
||||
|
||||
const roleList = (() => {
|
||||
const result: any[] = [];
|
||||
const result: any[] = []
|
||||
for (let index = 0; index < 4; index++) {
|
||||
result.push({
|
||||
id: index + 1,
|
||||
orderNo: `${index + 1}`,
|
||||
roleName: ['超级管理员', '管理员', '文章管理员', '普通用户'][index],
|
||||
roleName: ['超级管理员', '权限管理员', '归档管理员', '普通用户'][index],
|
||||
roleValue: '@first',
|
||||
createTime: '@datetime',
|
||||
remark: '@cword(10,20)',
|
||||
menu: [['0', '1', '2'], ['0', '1'], ['0', '2'], ['2']][index],
|
||||
'status|1': ['0', '1'],
|
||||
});
|
||||
})
|
||||
}
|
||||
return result;
|
||||
})();
|
||||
return result
|
||||
})()
|
||||
|
||||
const deptList = (() => {
|
||||
const result: any[] = [];
|
||||
const result: any[] = []
|
||||
for (let index = 0; index < 3; index++) {
|
||||
result.push({
|
||||
id: `${index}`,
|
||||
deptName: ['华东分部', '华南分部', '西北分部'][index],
|
||||
deptName: ['清水河校区', '沙河校区', '九里堤校区'][index],
|
||||
orderNo: index + 1,
|
||||
createTime: '@datetime',
|
||||
remark: '@cword(10,20)',
|
||||
'status|1': ['0', '0', '1'],
|
||||
children: (() => {
|
||||
const children: any[] = [];
|
||||
const children: any[] = []
|
||||
for (let j = 0; j < 4; j++) {
|
||||
children.push({
|
||||
id: `${index}-${j}`,
|
||||
deptName: ['研发部', '市场部', '商务部', '财务部'][j],
|
||||
deptName: ['TCP/IP课程组', '接入网课程组', '信号与系统课程组', '大学物理课程组'][j],
|
||||
orderNo: j + 1,
|
||||
createTime: '@datetime',
|
||||
remark: '@cword(10,20)',
|
||||
'status|1': ['0', '1'],
|
||||
parentDept: `${index}`,
|
||||
children: undefined,
|
||||
});
|
||||
})
|
||||
}
|
||||
return children;
|
||||
return children
|
||||
})(),
|
||||
});
|
||||
})
|
||||
}
|
||||
return result;
|
||||
})();
|
||||
return result
|
||||
})()
|
||||
|
||||
const menuList = (() => {
|
||||
const result: any[] = [];
|
||||
const result: any[] = []
|
||||
for (let index = 0; index < 3; index++) {
|
||||
result.push({
|
||||
id: `${index}`,
|
||||
@@ -80,7 +80,7 @@ const menuList = (() => {
|
||||
createTime: '@datetime',
|
||||
'status|1': ['0', '0', '1'],
|
||||
children: (() => {
|
||||
const children: any[] = [];
|
||||
const children: any[] = []
|
||||
for (let j = 0; j < 4; j++) {
|
||||
children.push({
|
||||
id: `${index}-${j}`,
|
||||
@@ -99,7 +99,7 @@ const menuList = (() => {
|
||||
'status|1': ['0', '1'],
|
||||
parentMenu: `${index}`,
|
||||
children: (() => {
|
||||
const children: any[] = [];
|
||||
const children: any[] = []
|
||||
for (let k = 0; k < 4; k++) {
|
||||
children.push({
|
||||
id: `${index}-${j}-${k}`,
|
||||
@@ -121,18 +121,18 @@ const menuList = (() => {
|
||||
'status|1': ['0', '1'],
|
||||
parentMenu: `${index}-${j}`,
|
||||
children: undefined,
|
||||
});
|
||||
})
|
||||
}
|
||||
return children;
|
||||
return children
|
||||
})(),
|
||||
});
|
||||
})
|
||||
}
|
||||
return children;
|
||||
return children
|
||||
})(),
|
||||
});
|
||||
})
|
||||
}
|
||||
return result;
|
||||
})();
|
||||
return result
|
||||
})()
|
||||
|
||||
export default [
|
||||
{
|
||||
@@ -140,8 +140,8 @@ export default [
|
||||
timeout: 100,
|
||||
method: 'get',
|
||||
response: ({ query }) => {
|
||||
const { page = 1, pageSize = 20 } = query;
|
||||
return resultPageSuccess(page, pageSize, accountList);
|
||||
const { page = 1, pageSize = 20 } = query
|
||||
return resultPageSuccess(page, pageSize, accountList)
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -149,8 +149,8 @@ export default [
|
||||
timeout: 100,
|
||||
method: 'get',
|
||||
response: ({ query }) => {
|
||||
const { page = 1, pageSize = 20 } = query;
|
||||
return resultPageSuccess(page, pageSize, roleList);
|
||||
const { page = 1, pageSize = 20 } = query
|
||||
return resultPageSuccess(page, pageSize, roleList)
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -158,8 +158,8 @@ export default [
|
||||
timeout: 500,
|
||||
method: 'post',
|
||||
response: ({ query }) => {
|
||||
const { id, status } = query;
|
||||
return resultSuccess({ id, status });
|
||||
const { id, status } = query
|
||||
return resultSuccess({ id, status })
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -167,7 +167,7 @@ export default [
|
||||
timeout: 100,
|
||||
method: 'get',
|
||||
response: () => {
|
||||
return resultSuccess(roleList);
|
||||
return resultSuccess(roleList)
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -175,7 +175,7 @@ export default [
|
||||
timeout: 100,
|
||||
method: 'get',
|
||||
response: () => {
|
||||
return resultSuccess(deptList);
|
||||
return resultSuccess(deptList)
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -183,7 +183,7 @@ export default [
|
||||
timeout: 100,
|
||||
method: 'get',
|
||||
response: () => {
|
||||
return resultSuccess(menuList);
|
||||
return resultSuccess(menuList)
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -191,12 +191,12 @@ export default [
|
||||
timeout: 500,
|
||||
method: 'post',
|
||||
response: ({ body }) => {
|
||||
const { account } = body || {};
|
||||
const { account } = body || {}
|
||||
if (account && account.indexOf('admin') !== -1) {
|
||||
return resultError('该字段不能包含admin');
|
||||
return resultError('该字段不能包含admin')
|
||||
} else {
|
||||
return resultSuccess(`${account} can use`);
|
||||
return resultSuccess(`${account} can use`)
|
||||
}
|
||||
},
|
||||
},
|
||||
] as MockMethod[];
|
||||
] as MockMethod[]
|
||||
|
||||
Reference in New Issue
Block a user