-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(request): 优化 request类型及使用示例以更好的提示返回值
- Loading branch information
1 parent
4e166dd
commit f3f4079
Showing
2 changed files
with
10 additions
and
7 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 |
---|---|---|
@@ -1,17 +1,20 @@ | ||
import request from '@/utils/request'; | ||
import { request, RequestOptions } from '@/utils/request'; | ||
import { RouteRecordRaw } from 'vue-router'; | ||
|
||
const enum Api { | ||
MENU = '/api/menu/list', | ||
} | ||
|
||
export function menuApi(returnAxios = true) { | ||
return request<RouteRecordRaw[], [], typeof returnAxios>( | ||
export function menuApi<T extends boolean = true>( | ||
options: RequestOptions<RouteRecordRaw[], []> = {}, | ||
returnAxios: T = true as T, | ||
) { | ||
return request( | ||
() => ({ | ||
url: Api.MENU, | ||
method: 'get', | ||
}), | ||
{}, | ||
options, | ||
returnAxios, | ||
); | ||
} |
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