import { MockHandler } from 'vite-plugin-mock-server' type UserModel = { username: string; password: string; avatar: string; } type LoginUserModel = { token: string; user: UserModel; } const loginUserList: LoginUserModel[] = [] const userMock: MockHandler[] = [ { pattern: '/api/user/login', method:'POST', handle: (req, res) => { const data = { code: 1 } res.end(JSON.stringify(data)) } }, { pattern: '/api/test1/*', handle: (req, res) => { res.end('Hello world!' + req.url) } }, { pattern: '/api/test1/users/{userId}', handle: (req, res, pathVars) => { const data = { url: req.url, pathVars: pathVars } res.setHeader('Content-Type', 'application/json') res.end(JSON.stringify(data)) } }, { pattern: '/api/test1/users/{userId}/{blogId}', handle: (req, res, pathVars) => { const data = { url: req.url, pathVars: pathVars } res.setHeader('Content-Type', 'application/json') res.end(JSON.stringify(data)) } } ] export default userMock