mirror of
https://github.com/soybeanjs/soybean-admin.git
synced 2025-11-11 19:23:41 +08:00
feat(projects): integration fast-crud
This commit is contained in:
55
mock/api/crud/modules/demo.ts
Normal file
55
mock/api/crud/modules/demo.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import type { MethodType, MockMethod } from 'vite-plugin-mock';
|
||||
import mockBase from '../base';
|
||||
|
||||
const options: any = {
|
||||
name: 'crud/demo',
|
||||
idGenerator: 0
|
||||
};
|
||||
const list: any[] = [
|
||||
{
|
||||
select: '1',
|
||||
text: '文本测试',
|
||||
copyable: '文本可复制',
|
||||
avatar: 'http://greper.handsfree.work/extends/avatar.jpg',
|
||||
richtext: '富文本',
|
||||
datetime: '2023-01-30 11:11:11'
|
||||
},
|
||||
{
|
||||
select: '2'
|
||||
},
|
||||
{
|
||||
select: '0'
|
||||
}
|
||||
];
|
||||
options.list = list;
|
||||
const mockedApis = mockBase.buildMock(options);
|
||||
|
||||
const apis: MockMethod[] = [
|
||||
{
|
||||
url: `/mock/${options.name}/dict`,
|
||||
method: 'get',
|
||||
response: () => {
|
||||
return {
|
||||
code: 200,
|
||||
message: '',
|
||||
data: [
|
||||
{ value: '0', label: '关', color: 'warning' },
|
||||
{ value: '1', label: '开', color: 'success' },
|
||||
{ value: '2', label: '停' }
|
||||
]
|
||||
};
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
for (const mockedApi of mockedApis) {
|
||||
apis.push({
|
||||
url: mockedApi.path,
|
||||
method: mockedApi.method as MethodType,
|
||||
response: (request: any) => {
|
||||
return mockedApi.handle(request);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export default apis;
|
||||
45
mock/api/crud/modules/header-group.ts
Normal file
45
mock/api/crud/modules/header-group.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import type { MethodType, MockMethod } from 'vite-plugin-mock';
|
||||
import mockBase from '../base';
|
||||
|
||||
const options: any = {
|
||||
name: 'crud/header-group',
|
||||
idGenerator: 0
|
||||
};
|
||||
const list: any[] = [
|
||||
{
|
||||
name: '张三',
|
||||
age: 18,
|
||||
province: '广东省',
|
||||
city: '深圳市',
|
||||
county: '南山区',
|
||||
street: '粤海街道'
|
||||
},
|
||||
{
|
||||
name: '李四',
|
||||
age: 26,
|
||||
province: '浙江省',
|
||||
city: '杭州市',
|
||||
county: '西湖区',
|
||||
street: '西湖街道'
|
||||
},
|
||||
{
|
||||
name: '王五',
|
||||
age: 24
|
||||
}
|
||||
];
|
||||
options.list = list;
|
||||
const mockedApis = mockBase.buildMock(options);
|
||||
|
||||
const apis: MockMethod[] = [];
|
||||
|
||||
for (const mockedApi of mockedApis) {
|
||||
apis.push({
|
||||
url: mockedApi.path,
|
||||
method: mockedApi.method as MethodType,
|
||||
response: (request: any) => {
|
||||
return mockedApi.handle(request);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export default apis;
|
||||
Reference in New Issue
Block a user