From 51acfe42e0170e20f865d9a51807bbe09c33a4a2 Mon Sep 17 00:00:00 2001 From: feige996 <1020102647@qq.com> Date: Tue, 8 Jul 2025 17:02:10 +0800 Subject: [PATCH] =?UTF-8?q?feat(api):=20=E6=B7=BB=E5=8A=A0=E6=96=B0?= =?UTF-8?q?=E7=9A=84foo=E6=8E=A5=E5=8F=A3=E5=B9=B6=E6=94=AF=E6=8C=81alova?= =?UTF-8?q?=E9=A3=8E=E6=A0=BCAPI=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加新的foo接口实现,同时扩展http模块以支持alova风格的API调用方式(Get/Post/Put/Delete)。移除旧的alova-foo.ts文件并统一使用新的实现。 --- src/api/{alova-foo.ts => foo-alova.ts} | 0 src/api/foo.ts | 16 ++++++++++++++++ src/http/http.ts | 6 ++++++ src/pages/about/alova.vue | 2 +- 4 files changed, 23 insertions(+), 1 deletion(-) rename src/api/{alova-foo.ts => foo-alova.ts} (100%) create mode 100644 src/api/foo.ts diff --git a/src/api/alova-foo.ts b/src/api/foo-alova.ts similarity index 100% rename from src/api/alova-foo.ts rename to src/api/foo-alova.ts diff --git a/src/api/foo.ts b/src/api/foo.ts new file mode 100644 index 0000000..51a1905 --- /dev/null +++ b/src/api/foo.ts @@ -0,0 +1,16 @@ +import { http } from '@/http/http' + +export interface IFoo { + id: number + name: string +} + +export function foo() { + return http.Get('/foo', { + params: { + name: '菲鸽', + page: 1, + pageSize: 10, + }, + }) +} diff --git a/src/http/http.ts b/src/http/http.ts index edf510d..5cea939 100644 --- a/src/http/http.ts +++ b/src/http/http.ts @@ -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 diff --git a/src/pages/about/alova.vue b/src/pages/about/alova.vue index 4123b22..d105747 100644 --- a/src/pages/about/alova.vue +++ b/src/pages/about/alova.vue @@ -9,7 +9,7 @@