mirror of
https://github.com/jekip/naive-ui-admin.git
synced 2026-02-04 13:42:27 +08:00
2.0.0
This commit is contained in:
@@ -1,7 +1,19 @@
|
||||
import { defineMock } from '@alova/mock';
|
||||
import { resultSuccess } from '../_util';
|
||||
|
||||
export interface ListDate {
|
||||
label: string;
|
||||
key: string;
|
||||
type: number;
|
||||
subtitle: string;
|
||||
openType: number;
|
||||
auth: string;
|
||||
path: string;
|
||||
children?: ListDate[];
|
||||
}
|
||||
|
||||
const menuList = () => {
|
||||
const result: any[] = [
|
||||
const result: ListDate[] = [
|
||||
{
|
||||
label: 'Dashboard',
|
||||
key: 'dashboard',
|
||||
@@ -74,16 +86,11 @@ const menuList = () => {
|
||||
return result;
|
||||
};
|
||||
|
||||
export default [
|
||||
{
|
||||
url: '/api/menu/list',
|
||||
timeout: 1000,
|
||||
method: 'get',
|
||||
response: () => {
|
||||
const list = menuList();
|
||||
return resultSuccess({
|
||||
list,
|
||||
});
|
||||
},
|
||||
export default defineMock({
|
||||
'/api/menu/list': () => {
|
||||
const list = menuList();
|
||||
return resultSuccess({
|
||||
list,
|
||||
});
|
||||
},
|
||||
];
|
||||
});
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import { defineMock } from '@alova/mock';
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { resultSuccess, doCustomTimes } from '../_util';
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
function getMenuKeys() {
|
||||
const keys = ['dashboard', 'console', 'workplace', 'basic-form', 'step-form', 'detail'];
|
||||
const newKeys = [];
|
||||
doCustomTimes(parseInt(Math.random() * 6), () => {
|
||||
const key = keys[Math.floor(Math.random() * keys.length)];
|
||||
newKeys.push(key);
|
||||
newKeys.push(key as never);
|
||||
});
|
||||
return Array.from(new Set(newKeys));
|
||||
}
|
||||
@@ -14,32 +16,30 @@ const roleList = (pageSize) => {
|
||||
const result: any[] = [];
|
||||
doCustomTimes(pageSize, () => {
|
||||
result.push({
|
||||
id: '@integer(10,100)',
|
||||
name: '@cname()',
|
||||
explain: '@cname()',
|
||||
isDefault: '@boolean()',
|
||||
id: faker.string.numeric(4),
|
||||
name: faker.person.firstName(),
|
||||
explain: faker.lorem.sentence({ min: 2, max: 4 }),
|
||||
isDefault: faker.helpers.arrayElement([true, false]),
|
||||
menu_keys: getMenuKeys(),
|
||||
create_date: `@date('yyyy-MM-dd hh:mm:ss')`,
|
||||
'status|1': ['normal', 'enable', 'disable'],
|
||||
create_date: dayjs(faker.date.anytime()).format('YYYY-MM-DD HH:mm'),
|
||||
status: faker.helpers.arrayElement(['normal', 'enable', 'disable']),
|
||||
});
|
||||
});
|
||||
return result;
|
||||
};
|
||||
|
||||
export default [
|
||||
{
|
||||
url: '/api/role/list',
|
||||
timeout: 1000,
|
||||
method: 'get',
|
||||
response: ({ query }) => {
|
||||
const { page = 1, pageSize = 10 } = query;
|
||||
const list = roleList(Number(pageSize));
|
||||
return resultSuccess({
|
||||
page: Number(page),
|
||||
pageSize: Number(pageSize),
|
||||
pageCount: 60,
|
||||
list,
|
||||
});
|
||||
},
|
||||
export default defineMock({
|
||||
'/api/role/list': ({ query }) => {
|
||||
const { page = 1, pageSize = 10, name } = query;
|
||||
const list = roleList(Number(pageSize));
|
||||
// 并非真实,只是为了模拟搜索结果
|
||||
const count = name ? 30 : 60;
|
||||
return resultSuccess({
|
||||
page: Number(page),
|
||||
pageSize: Number(pageSize),
|
||||
pageCount: count,
|
||||
itemCount: count * Number(pageSize),
|
||||
list,
|
||||
});
|
||||
},
|
||||
];
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user