🐛 fix(api): Rename app-related functions and types to application for consistency

This commit is contained in:
web@ppanel 2025-01-18 18:48:28 +07:00
parent 5e5e4edd2e
commit 9d8b814212
11 changed files with 77 additions and 228 deletions

View File

@ -1,6 +1,6 @@
'use client'; 'use client';
import { getAppConfig, updateAppConfig } from '@/services/admin/app'; import { getApplicationConfig, updateApplicationConfig } from '@/services/admin/system';
import { zodResolver } from '@hookform/resolvers/zod'; import { zodResolver } from '@hookform/resolvers/zod';
import { Icon } from '@iconify/react'; import { Icon } from '@iconify/react';
import { useQuery } from '@tanstack/react-query'; import { useQuery } from '@tanstack/react-query';
@ -55,9 +55,9 @@ export default function ConfigForm() {
}); });
const { data, refetch } = useQuery({ const { data, refetch } = useQuery({
queryKey: ['getAppConfig'], queryKey: ['getApplicationConfig'],
queryFn: async () => { queryFn: async () => {
const { data } = await getAppConfig(); const { data } = await getApplicationConfig();
return data.data; return data.data;
}, },
}); });
@ -74,7 +74,7 @@ export default function ConfigForm() {
async function onSubmit(values: FormSchema) { async function onSubmit(values: FormSchema) {
setLoading(true); setLoading(true);
try { try {
await updateAppConfig(values as API.AppConfig); await updateApplicationConfig(values as API.ApplicationConfig);
toast.success(t('updateSuccess')); toast.success(t('updateSuccess'));
refetch(); refetch();
setOpen(false); setOpen(false);

View File

@ -231,6 +231,16 @@ export default function SubscribeAppForm<
name: 'is_default', name: 'is_default',
type: 'boolean', type: 'boolean',
placeholder: t('defaultVersion'), placeholder: t('defaultVersion'),
calculateValue: (value) => {
const newField = field.value?.map((item) => {
if (item.is_default) {
item.is_default = false;
}
return item;
});
form.setValue(field.name, newField);
return value;
},
}, },
{ {
name: 'url', name: 'url',

View File

@ -1,101 +0,0 @@
// @ts-ignore
/* eslint-disable */
import request from '@/utils/request';
/** get app config GET /v1/admin/app/config */
export async function getAppConfig(options?: { [key: string]: any }) {
return request<API.Response & { data?: API.AppConfig }>('/v1/admin/app/config', {
method: 'GET',
...(options || {}),
});
}
/** update app config PUT /v1/admin/app/config */
export async function updateAppConfig(body: API.AppConfig, options?: { [key: string]: any }) {
return request<API.Response & { data?: any }>('/v1/admin/app/config', {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
});
}
/** update app version PUT /v1/admin/app/version */
export async function updateAppVersion(
body: API.UpdateAppVersionRequest,
options?: { [key: string]: any },
) {
return request<API.Response & { data?: any }>('/v1/admin/app/version', {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
});
}
/** create app version POST /v1/admin/app/version */
export async function createAppVersion(
body: API.CreateAppVersionRequest,
options?: { [key: string]: any },
) {
return request<API.Response & { data?: any }>('/v1/admin/app/version', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
});
}
/** delete app version DELETE /v1/admin/app/version */
export async function deleteAppVersionInfo(
body: API.DeleteAppVersionRequest,
options?: { [key: string]: any },
) {
return request<API.Response & { data?: any }>('/v1/admin/app/version', {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
});
}
/** set default app version PUT /v1/admin/app/version_default */
export async function setDefaultAppVersionInfo(
body: API.DefaultAppVersionRequest,
options?: { [key: string]: any },
) {
return request<API.Response & { data?: any }>('/v1/admin/app/version_default', {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
});
}
/** query app version info GET /v1/admin/app/version_list */
export async function getAppVersionList(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
params: API.GetAppVersionListParams,
options?: { [key: string]: any },
) {
return request<API.Response & { data?: API.GetAppVersionListResponse }>(
'/v1/admin/app/version_list',
{
method: 'GET',
params: {
...params,
},
...(options || {}),
},
);
}

View File

@ -3,7 +3,6 @@
// API 更新时间: // API 更新时间:
// API 唯一标识: // API 唯一标识:
import * as announcement from './announcement'; import * as announcement from './announcement';
import * as app from './app';
import * as console from './console'; import * as console from './console';
import * as coupon from './coupon'; import * as coupon from './coupon';
import * as document from './document'; import * as document from './document';
@ -18,7 +17,6 @@ import * as tool from './tool';
import * as user from './user'; import * as user from './user';
export default { export default {
announcement, announcement,
app,
console, console,
coupon, coupon,
document, document,

View File

@ -58,6 +58,32 @@ export async function deleteApplication(
}); });
} }
/** get application config GET /v1/admin/system/application_config */
export async function getApplicationConfig(options?: { [key: string]: any }) {
return request<API.Response & { data?: API.ApplicationConfig }>(
'/v1/admin/system/application_config',
{
method: 'GET',
...(options || {}),
},
);
}
/** update application config PUT /v1/admin/system/application_config */
export async function updateApplicationConfig(
body: API.ApplicationConfig,
options?: { [key: string]: any },
) {
return request<API.Response & { data?: any }>('/v1/admin/system/application_config', {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
});
}
/** Update application version PUT /v1/admin/system/application_version */ /** Update application version PUT /v1/admin/system/application_version */
export async function updateApplicationVersion( export async function updateApplicationVersion(
body: API.UpdateApplicationVersionRequest, body: API.UpdateApplicationVersionRequest,

View File

@ -18,14 +18,6 @@ declare namespace API {
updated_at: number; updated_at: number;
}; };
type AppConfig = {
name: string;
domains: string[];
describe: string;
startup_picture: string;
startup_picture_skip_time: number;
};
type Application = { type Application = {
id: number; id: number;
icon: string; icon: string;
@ -34,6 +26,12 @@ declare namespace API {
subscribe_type: string; subscribe_type: string;
}; };
type ApplicationConfig = {
domains: string[];
startup_picture: string;
startup_picture_skip_time: number;
};
type ApplicationPlatform = { type ApplicationPlatform = {
ios?: ApplicationVersion[]; ios?: ApplicationVersion[];
mac?: ApplicationVersion[]; mac?: ApplicationVersion[];
@ -64,15 +62,6 @@ declare namespace API {
is_default: boolean; is_default: boolean;
}; };
type AppVersion = {
id: number;
os: string;
version: string;
download_url: string;
describe: string;
default_version: boolean;
};
type AuthConfig = { type AuthConfig = {
sms: SmsAuthenticateConfig; sms: SmsAuthenticateConfig;
email: EmailAuthticateConfig; email: EmailAuthticateConfig;
@ -145,13 +134,6 @@ declare namespace API {
application_id: number; application_id: number;
}; };
type CreateAppVersionRequest = {
os: string;
version: string;
download_url: string;
describe: string;
};
type CreateCouponRequest = { type CreateCouponRequest = {
name: string; name: string;
code?: string; code?: string;
@ -267,10 +249,6 @@ declare namespace API {
currency_symbol: string; currency_symbol: string;
}; };
type DefaultAppVersionRequest = {
id: number;
};
type DeleteAnnouncementRequest = { type DeleteAnnouncementRequest = {
id: number; id: number;
}; };
@ -283,10 +261,6 @@ declare namespace API {
id: number; id: number;
}; };
type DeleteAppVersionRequest = {
id: number;
};
type DeleteCouponRequest = { type DeleteCouponRequest = {
id: number; id: number;
}; };
@ -398,23 +372,6 @@ declare namespace API {
id: number; id: number;
}; };
type GetAppVersionListParams = {
page: number;
size: number;
os?: string;
};
type GetAppVersionListRequest = {
page: number;
size: number;
os?: string;
};
type GetAppVersionListResponse = {
total: number;
list: AppVersion[];
};
type GetCouponListParams = { type GetCouponListParams = {
page: number; page: number;
size: number; size: number;
@ -1082,14 +1039,6 @@ declare namespace API {
application_id: number; application_id: number;
}; };
type UpdateAppVersionRequest = {
id: number;
os: string;
version: string;
download_url: string;
describe: string;
};
type UpdateCouponRequest = { type UpdateCouponRequest = {
id: number; id: number;
name: string; name: string;

View File

@ -2,9 +2,9 @@
/* eslint-disable */ /* eslint-disable */
import request from '@/utils/request'; import request from '@/utils/request';
/** Get Tos Content GET /v1/common/app/info */ /** Get Tos Content GET /v1/common/application */
export async function getAppInfo(options?: { [key: string]: any }) { export async function getApplication(options?: { [key: string]: any }) {
return request<API.Response & { data?: API.GetAppInfoResponse }>('/v1/common/app/info', { return request<API.Response & { data?: API.GetAppcationResponse }>('/v1/common/application', {
method: 'GET', method: 'GET',
...(options || {}), ...(options || {}),
}); });

View File

@ -10,14 +10,6 @@ declare namespace API {
updated_at: number; updated_at: number;
}; };
type AppConfig = {
name: string;
domains: string[];
describe: string;
startup_picture: string;
startup_picture_skip_time: number;
};
type Application = { type Application = {
id: number; id: number;
icon: string; icon: string;
@ -26,6 +18,12 @@ declare namespace API {
subscribe_type: string; subscribe_type: string;
}; };
type ApplicationConfig = {
domains: string[];
startup_picture: string;
startup_picture_skip_time: number;
};
type ApplicationPlatform = { type ApplicationPlatform = {
ios?: ApplicationVersion[]; ios?: ApplicationVersion[];
mac?: ApplicationVersion[]; mac?: ApplicationVersion[];
@ -56,15 +54,6 @@ declare namespace API {
is_default: boolean; is_default: boolean;
}; };
type AppVersion = {
id: number;
os: string;
version: string;
download_url: string;
describe: string;
default_version: boolean;
};
type AuthConfig = { type AuthConfig = {
sms: SmsAuthenticateConfig; sms: SmsAuthenticateConfig;
email: EmailAuthticateConfig; email: EmailAuthticateConfig;
@ -151,9 +140,9 @@ declare namespace API {
created_at: number; created_at: number;
}; };
type GetAppInfoResponse = { type GetAppcationResponse = {
config: AppConfig; config: ApplicationConfig;
versions: AppVersion[]; applications: ApplicationResponseInfo[];
}; };
type GetGlobalConfigResponse = { type GetGlobalConfigResponse = {

View File

@ -2,9 +2,9 @@
/* eslint-disable */ /* eslint-disable */
import request from '@/utils/request'; import request from '@/utils/request';
/** Get Tos Content GET /v1/common/app/info */ /** Get Tos Content GET /v1/common/application */
export async function getAppInfo(options?: { [key: string]: any }) { export async function getApplication(options?: { [key: string]: any }) {
return request<API.Response & { data?: API.GetAppInfoResponse }>('/v1/common/app/info', { return request<API.Response & { data?: API.GetAppcationResponse }>('/v1/common/application', {
method: 'GET', method: 'GET',
...(options || {}), ...(options || {}),
}); });

View File

@ -10,14 +10,6 @@ declare namespace API {
updated_at: number; updated_at: number;
}; };
type AppConfig = {
name: string;
domains: string[];
describe: string;
startup_picture: string;
startup_picture_skip_time: number;
};
type Application = { type Application = {
id: number; id: number;
icon: string; icon: string;
@ -26,6 +18,12 @@ declare namespace API {
subscribe_type: string; subscribe_type: string;
}; };
type ApplicationConfig = {
domains: string[];
startup_picture: string;
startup_picture_skip_time: number;
};
type ApplicationPlatform = { type ApplicationPlatform = {
ios?: ApplicationVersion[]; ios?: ApplicationVersion[];
mac?: ApplicationVersion[]; mac?: ApplicationVersion[];
@ -56,15 +54,6 @@ declare namespace API {
is_default: boolean; is_default: boolean;
}; };
type AppVersion = {
id: number;
os: string;
version: string;
download_url: string;
describe: string;
default_version: boolean;
};
type AuthConfig = { type AuthConfig = {
sms: SmsAuthenticateConfig; sms: SmsAuthenticateConfig;
email: EmailAuthticateConfig; email: EmailAuthticateConfig;
@ -151,9 +140,9 @@ declare namespace API {
created_at: number; created_at: number;
}; };
type GetAppInfoResponse = { type GetAppcationResponse = {
config: AppConfig; config: ApplicationConfig;
versions: AppVersion[]; applications: ApplicationResponseInfo[];
}; };
type GetGlobalConfigResponse = { type GetGlobalConfigResponse = {

View File

@ -10,14 +10,6 @@ declare namespace API {
updated_at: number; updated_at: number;
}; };
type AppConfig = {
name: string;
domains: string[];
describe: string;
startup_picture: string;
startup_picture_skip_time: number;
};
type Application = { type Application = {
id: number; id: number;
icon: string; icon: string;
@ -26,6 +18,12 @@ declare namespace API {
subscribe_type: string; subscribe_type: string;
}; };
type ApplicationConfig = {
domains: string[];
startup_picture: string;
startup_picture_skip_time: number;
};
type ApplicationPlatform = { type ApplicationPlatform = {
ios?: ApplicationVersion[]; ios?: ApplicationVersion[];
mac?: ApplicationVersion[]; mac?: ApplicationVersion[];
@ -56,15 +54,6 @@ declare namespace API {
is_default: boolean; is_default: boolean;
}; };
type AppVersion = {
id: number;
os: string;
version: string;
download_url: string;
describe: string;
default_version: boolean;
};
type AuthConfig = { type AuthConfig = {
sms: SmsAuthenticateConfig; sms: SmsAuthenticateConfig;
email: EmailAuthticateConfig; email: EmailAuthticateConfig;