-
Notifications
You must be signed in to change notification settings - Fork 693
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
357fc44
commit 3fc7d4d
Showing
20 changed files
with
354 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { createProdMockServer } from 'vite-plugin-mock/es/createProdMockServer' | ||
|
||
const modules = import.meta.globEager('./**/*.ts') | ||
|
||
const mockModules: any[] = [] | ||
Object.keys(modules).forEach((key) => { | ||
if (key.includes('_')) { | ||
return | ||
} | ||
mockModules.push(...modules[key].default) | ||
}) | ||
|
||
export function setupProdMockServer() { | ||
createProdMockServer(mockModules) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { config } from '@/config/axios' | ||
import { MockMethod } from 'vite-plugin-mock' | ||
|
||
const { result_code } = config | ||
|
||
const List: { | ||
username: string | ||
password: string | ||
role: string | ||
roleId: string | ||
}[] = [ | ||
{ | ||
username: 'admin', | ||
password: 'admin', | ||
role: 'admin', | ||
roleId: '1' | ||
}, | ||
{ | ||
username: 'test', | ||
password: 'test', | ||
role: 'test', | ||
roleId: '2' | ||
} | ||
] | ||
|
||
export default [ | ||
// 登录接口 | ||
{ | ||
url: '/user/login', | ||
method: 'post', | ||
response: ({ body }) => { | ||
const data = body | ||
let hasUser = false | ||
for (const user of List) { | ||
if (user.username === data.username && user.password === data.password) { | ||
hasUser = true | ||
return { | ||
code: result_code, | ||
data: user | ||
} | ||
} | ||
} | ||
if (!hasUser) { | ||
return { | ||
code: '500', | ||
message: '账号或密码错误' | ||
} | ||
} | ||
} | ||
} | ||
] as MockMethod[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.