-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
6bed9ea
commit bed4292
Showing
8 changed files
with
63 additions
and
38 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
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,20 @@ | ||
import type { MockMethod } from 'vite-plugin-mock'; | ||
|
||
const apis: MockMethod[] = [ | ||
{ | ||
url: '/mock/apiDemoWithAdapter', | ||
method: 'post', | ||
response: (): Service.MockServiceResult<ApiDemo.DataWithAdapter> => { | ||
return { | ||
code: 200, | ||
message: 'ok', | ||
data: { | ||
dataId: '123', | ||
dataName: 'demoName' | ||
} | ||
}; | ||
} | ||
} | ||
]; | ||
|
||
export default apis; |
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 |
---|---|---|
@@ -1 +1,10 @@ | ||
export {}; | ||
export function adapterOfDataWithAdapter(res: Service.RequestResult<ApiDemo.DataWithAdapter>): Demo.DataWithAdapter { | ||
const { dataId, dataName } = res.data!; | ||
|
||
const result: Demo.DataWithAdapter = { | ||
id: dataId, | ||
name: dataName | ||
}; | ||
|
||
return result; | ||
} |
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 |
---|---|---|
@@ -1,6 +1,9 @@ | ||
import { request } from '../request'; | ||
import { adapterOfServiceResult } from '@/utils'; | ||
import { mockRequest } from '../request'; | ||
import { adapterOfDataWithAdapter } from '../adapter'; | ||
|
||
/** 测试请求代理 */ | ||
export function fetchTestProxy() { | ||
return request.get('/test'); | ||
/** 带有适配器的请求(将请求结果进行数据处理) */ | ||
export async function fetchDataWithAdapter() { | ||
const res = await mockRequest.post<ApiDemo.DataWithAdapter>('/apiDemoWithAdapter'); | ||
return adapterOfServiceResult(adapterOfDataWithAdapter, res); | ||
} |
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
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
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
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
bed4292
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: