From 23f83068f18611459fe5508ca074664115a72e8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=98=AD?= <81747598+lan-yonghui@users.noreply.github.com> Date: Fri, 14 Mar 2025 22:38:40 +0800 Subject: [PATCH] feat: Unify the response body of the API interface (#8158) --- agent/app/api/v2/app_install.go | 5 ++++- agent/app/api/v2/php_extensions.go | 5 ++++- core/cmd/server/main.go | 2 +- frontend/src/api/modules/app.ts | 2 +- frontend/src/api/modules/runtime.ts | 2 +- frontend/src/views/website/runtime/php/create/index.vue | 2 +- frontend/src/views/website/website/create/index.vue | 6 +++--- 7 files changed, 15 insertions(+), 9 deletions(-) diff --git a/agent/app/api/v2/app_install.go b/agent/app/api/v2/app_install.go index b5ff1c524..c694f481f 100644 --- a/agent/app/api/v2/app_install.go +++ b/agent/app/api/v2/app_install.go @@ -27,7 +27,10 @@ func (b *BaseApi) SearchAppInstalled(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithData(c, list) + helper.SuccessWithData(c, dto.PageResult{ + Items: list, + Total: int64(len(list)), + }) } else { total, list, err := appInstallService.Page(req) if err != nil { diff --git a/agent/app/api/v2/php_extensions.go b/agent/app/api/v2/php_extensions.go index 72305b514..320387df7 100644 --- a/agent/app/api/v2/php_extensions.go +++ b/agent/app/api/v2/php_extensions.go @@ -26,7 +26,10 @@ func (b *BaseApi) PagePHPExtensions(c *gin.Context) { helper.InternalServer(c, err) return } - helper.SuccessWithData(c, list) + helper.SuccessWithData(c, dto.PageResult{ + Total: int64(len(list)), + Items: list, + }) } else { total, list, err := phpExtensionsService.Page(req) if err != nil { diff --git a/core/cmd/server/main.go b/core/cmd/server/main.go index cd296a717..2a0d875ab 100644 --- a/core/cmd/server/main.go +++ b/core/cmd/server/main.go @@ -23,7 +23,7 @@ import ( // @description Custom Token Format, Format: md5('1panel' + API-Key + UnixTimestamp). // @description ``` // @description eg: -// @description curl -X GET "http://localhost:4004/api/v1/resource" \ +// @description curl -X GET "http://localhost:4004/api/v1/dashboard/current" \ // @description -H "1Panel-Token: <1panel_token>" \ // @description -H "1Panel-Timestamp: " // @description ``` diff --git a/frontend/src/api/modules/app.ts b/frontend/src/api/modules/app.ts index 9aaaa1127..d6e1b10ff 100644 --- a/frontend/src/api/modules/app.ts +++ b/frontend/src/api/modules/app.ts @@ -64,7 +64,7 @@ export const appInstalledDeleteCheck = (appInstallId: number) => { }; export const getAppInstalled = (search: App.AppInstalledSearch) => { - return http.post('apps/installed/search', search); + return http.post>('apps/installed/search', search); }; export const installedOp = (op: App.AppInstalledOp) => { diff --git a/frontend/src/api/modules/runtime.ts b/frontend/src/api/modules/runtime.ts index b11cd18cd..1eb591076 100644 --- a/frontend/src/api/modules/runtime.ts +++ b/frontend/src/api/modules/runtime.ts @@ -51,7 +51,7 @@ export const SearchPHPExtensions = (req: ReqPage) => { }; export const ListPHPExtensions = (req: Runtime.PHPExtensionsList) => { - return http.post(`/runtimes/php/extensions/search`, req); + return http.post>(`/runtimes/php/extensions/search`, req); }; export const CreatePHPExtensions = (req: Runtime.PHPExtensionsCreate) => { diff --git a/frontend/src/views/website/runtime/php/create/index.vue b/frontend/src/views/website/runtime/php/create/index.vue index 563248170..3b4724a00 100644 --- a/frontend/src/views/website/runtime/php/create/index.vue +++ b/frontend/src/views/website/runtime/php/create/index.vue @@ -451,7 +451,7 @@ const listPHPExtensions = async () => { page: 1, pageSize: 100, }); - phpExtensions.value = res.data; + phpExtensions.value = res.data.items; } catch (error) {} }; diff --git a/frontend/src/views/website/website/create/index.vue b/frontend/src/views/website/website/create/index.vue index 6b3ff27e3..4cb27a762 100644 --- a/frontend/src/views/website/website/create/index.vue +++ b/frontend/src/views/website/website/create/index.vue @@ -729,10 +729,10 @@ const changeType = (type: string) => { const searchAppInstalled = (appType: string) => { getAppInstalled({ type: appType, unused: true, all: true, page: 1, pageSize: 100 }).then((res) => { - appInstalls.value = res.data; + appInstalls.value = res.data.items; website.value.appInstallId = undefined; - if (appType == 'website' && res.data && res.data.length > 0) { - website.value.appInstallId = res.data[0].id; + if (appType == 'website' && res.data.items && res.data.items.length > 0) { + website.value.appInstallId = res.data.items[0].id; } }); };