Add API page and related routes
All checks were successful
CI / build-and-deploy (push) Successful in 5m58s

This commit is contained in:
严浩
2024-09-27 18:06:59 +08:00
parent 1380e280d4
commit 8143cf2e07
8 changed files with 382 additions and 5 deletions

34
fake/user.fake.ts Normal file
View File

@ -0,0 +1,34 @@
// fake/user.fake.ts
import Mock from 'mockjs';
import { defineFakeRoute } from 'vite-plugin-fake-server/client';
import { faker } from '@faker-js/faker';
export default defineFakeRoute([
{
url: '/mock/get-user-info',
response: () => {
return Mock.mock({
id: '@guid',
username: '@first',
email: '@email',
avatar: '@image("200x200")',
role: 'admin',
});
},
},
{
url: '/fake/get-user-info',
response: () => {
return {
id: faker.string.uuid(),
avatar: faker.image.avatar(),
birthday: faker.date.birthdate(),
email: faker.internet.email(),
firstName: faker.person.firstName(),
lastName: faker.person.lastName(),
sex: faker.person.sexType(),
role: 'admin',
};
},
},
]);