feat(api): 添加新的foo接口并支持alova风格API调用
添加新的foo接口实现,同时扩展http模块以支持alova风格的API调用方式(Get/Post/Put/Delete)。移除旧的alova-foo.ts文件并统一使用新的实现。
This commit is contained in:
16
src/api/foo.ts
Normal file
16
src/api/foo.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { http } from '@/http/http'
|
||||
|
||||
export interface IFoo {
|
||||
id: number
|
||||
name: string
|
||||
}
|
||||
|
||||
export function foo() {
|
||||
return http.Get<IFoo>('/foo', {
|
||||
params: {
|
||||
name: '菲鸽',
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -110,3 +110,9 @@ http.get = httpGet
|
||||
http.post = httpPost
|
||||
http.put = httpPut
|
||||
http.delete = httpDelete
|
||||
|
||||
// 支持与 alovaJS 类似的API调用
|
||||
http.Get = httpGet
|
||||
http.Post = httpPost
|
||||
http.Put = httpPut
|
||||
http.Delete = httpDelete
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { useRequest } from 'alova/client'
|
||||
import { foo } from '@/api/alova-foo'
|
||||
import { foo } from '@/api/foo-alova'
|
||||
|
||||
const initialData = undefined
|
||||
|
||||
|
||||
Reference in New Issue
Block a user