feat: Unify the response body of the API interface (#8158)

This commit is contained in:
2025-03-14 22:38:40 +08:00 committed by GitHub
parent e64b3f2d7d
commit 23f83068f1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 15 additions and 9 deletions

View file

@ -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 {

View file

@ -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 {

View file

@ -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: <current_unix_timestamp>"
// @description ```

View file

@ -64,7 +64,7 @@ export const appInstalledDeleteCheck = (appInstallId: number) => {
};
export const getAppInstalled = (search: App.AppInstalledSearch) => {
return http.post<App.AppInstalled[]>('apps/installed/search', search);
return http.post<ResPage<App.AppInstalled>>('apps/installed/search', search);
};
export const installedOp = (op: App.AppInstalledOp) => {

View file

@ -51,7 +51,7 @@ export const SearchPHPExtensions = (req: ReqPage) => {
};
export const ListPHPExtensions = (req: Runtime.PHPExtensionsList) => {
return http.post<Runtime.PHPExtensions[]>(`/runtimes/php/extensions/search`, req);
return http.post<ResPage<Runtime.PHPExtensions>>(`/runtimes/php/extensions/search`, req);
};
export const CreatePHPExtensions = (req: Runtime.PHPExtensionsCreate) => {

View file

@ -451,7 +451,7 @@ const listPHPExtensions = async () => {
page: 1,
pageSize: 100,
});
phpExtensions.value = res.data;
phpExtensions.value = res.data.items;
} catch (error) {}
};

View file

@ -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;
}
});
};