From 9d8b81421232f8c47336413b6d966cd74bfcace1 Mon Sep 17 00:00:00 2001 From: "web@ppanel" Date: Sat, 18 Jan 2025 18:48:28 +0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(api):=20Rename=20app-related?= =?UTF-8?q?=20functions=20and=20types=20to=20application=20for=20consisten?= =?UTF-8?q?cy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/dashboard/subscribe/app/config.tsx | 8 +- .../app/dashboard/subscribe/app/form.tsx | 10 ++ apps/admin/services/admin/app.ts | 101 ------------------ apps/admin/services/admin/index.ts | 4 +- apps/admin/services/admin/system.ts | 26 +++++ apps/admin/services/admin/typings.d.ts | 63 ++--------- apps/admin/services/common/common.ts | 6 +- apps/admin/services/common/typings.d.ts | 29 ++--- apps/user/services/common/common.ts | 6 +- apps/user/services/common/typings.d.ts | 29 ++--- apps/user/services/user/typings.d.ts | 23 ++-- 11 files changed, 77 insertions(+), 228 deletions(-) delete mode 100644 apps/admin/services/admin/app.ts diff --git a/apps/admin/app/dashboard/subscribe/app/config.tsx b/apps/admin/app/dashboard/subscribe/app/config.tsx index 903a4fe..776a1e5 100644 --- a/apps/admin/app/dashboard/subscribe/app/config.tsx +++ b/apps/admin/app/dashboard/subscribe/app/config.tsx @@ -1,6 +1,6 @@ 'use client'; -import { getAppConfig, updateAppConfig } from '@/services/admin/app'; +import { getApplicationConfig, updateApplicationConfig } from '@/services/admin/system'; import { zodResolver } from '@hookform/resolvers/zod'; import { Icon } from '@iconify/react'; import { useQuery } from '@tanstack/react-query'; @@ -55,9 +55,9 @@ export default function ConfigForm() { }); const { data, refetch } = useQuery({ - queryKey: ['getAppConfig'], + queryKey: ['getApplicationConfig'], queryFn: async () => { - const { data } = await getAppConfig(); + const { data } = await getApplicationConfig(); return data.data; }, }); @@ -74,7 +74,7 @@ export default function ConfigForm() { async function onSubmit(values: FormSchema) { setLoading(true); try { - await updateAppConfig(values as API.AppConfig); + await updateApplicationConfig(values as API.ApplicationConfig); toast.success(t('updateSuccess')); refetch(); setOpen(false); diff --git a/apps/admin/app/dashboard/subscribe/app/form.tsx b/apps/admin/app/dashboard/subscribe/app/form.tsx index 5e20326..758a4de 100644 --- a/apps/admin/app/dashboard/subscribe/app/form.tsx +++ b/apps/admin/app/dashboard/subscribe/app/form.tsx @@ -231,6 +231,16 @@ export default function SubscribeAppForm< name: 'is_default', type: 'boolean', 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', diff --git a/apps/admin/services/admin/app.ts b/apps/admin/services/admin/app.ts deleted file mode 100644 index 16cb222..0000000 --- a/apps/admin/services/admin/app.ts +++ /dev/null @@ -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('/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('/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('/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('/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('/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('/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( - '/v1/admin/app/version_list', - { - method: 'GET', - params: { - ...params, - }, - ...(options || {}), - }, - ); -} diff --git a/apps/admin/services/admin/index.ts b/apps/admin/services/admin/index.ts index 057602e..5cabc85 100644 --- a/apps/admin/services/admin/index.ts +++ b/apps/admin/services/admin/index.ts @@ -1,9 +1,8 @@ // @ts-ignore - + // API 更新时间: // API 唯一标识: import * as announcement from './announcement'; -import * as app from './app'; import * as console from './console'; import * as coupon from './coupon'; import * as document from './document'; @@ -18,7 +17,6 @@ import * as tool from './tool'; import * as user from './user'; export default { announcement, - app, console, coupon, document, diff --git a/apps/admin/services/admin/system.ts b/apps/admin/services/admin/system.ts index 1ab39de..7da3a2e 100644 --- a/apps/admin/services/admin/system.ts +++ b/apps/admin/services/admin/system.ts @@ -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( + '/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('/v1/admin/system/application_config', { + method: 'PUT', + headers: { + 'Content-Type': 'application/json', + }, + data: body, + ...(options || {}), + }); +} + /** Update application version PUT /v1/admin/system/application_version */ export async function updateApplicationVersion( body: API.UpdateApplicationVersionRequest, diff --git a/apps/admin/services/admin/typings.d.ts b/apps/admin/services/admin/typings.d.ts index a9d5286..3d31bbe 100644 --- a/apps/admin/services/admin/typings.d.ts +++ b/apps/admin/services/admin/typings.d.ts @@ -18,14 +18,6 @@ declare namespace API { updated_at: number; }; - type AppConfig = { - name: string; - domains: string[]; - describe: string; - startup_picture: string; - startup_picture_skip_time: number; - }; - type Application = { id: number; icon: string; @@ -34,6 +26,12 @@ declare namespace API { subscribe_type: string; }; + type ApplicationConfig = { + domains: string[]; + startup_picture: string; + startup_picture_skip_time: number; + }; + type ApplicationPlatform = { ios?: ApplicationVersion[]; mac?: ApplicationVersion[]; @@ -64,15 +62,6 @@ declare namespace API { is_default: boolean; }; - type AppVersion = { - id: number; - os: string; - version: string; - download_url: string; - describe: string; - default_version: boolean; - }; - type AuthConfig = { sms: SmsAuthenticateConfig; email: EmailAuthticateConfig; @@ -145,13 +134,6 @@ declare namespace API { application_id: number; }; - type CreateAppVersionRequest = { - os: string; - version: string; - download_url: string; - describe: string; - }; - type CreateCouponRequest = { name: string; code?: string; @@ -267,10 +249,6 @@ declare namespace API { currency_symbol: string; }; - type DefaultAppVersionRequest = { - id: number; - }; - type DeleteAnnouncementRequest = { id: number; }; @@ -283,10 +261,6 @@ declare namespace API { id: number; }; - type DeleteAppVersionRequest = { - id: number; - }; - type DeleteCouponRequest = { id: number; }; @@ -398,23 +372,6 @@ declare namespace API { 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 = { page: number; size: number; @@ -1082,14 +1039,6 @@ declare namespace API { application_id: number; }; - type UpdateAppVersionRequest = { - id: number; - os: string; - version: string; - download_url: string; - describe: string; - }; - type UpdateCouponRequest = { id: number; name: string; diff --git a/apps/admin/services/common/common.ts b/apps/admin/services/common/common.ts index b86d7bb..d200045 100644 --- a/apps/admin/services/common/common.ts +++ b/apps/admin/services/common/common.ts @@ -2,9 +2,9 @@ /* eslint-disable */ import request from '@/utils/request'; -/** Get Tos Content GET /v1/common/app/info */ -export async function getAppInfo(options?: { [key: string]: any }) { - return request('/v1/common/app/info', { +/** Get Tos Content GET /v1/common/application */ +export async function getApplication(options?: { [key: string]: any }) { + return request('/v1/common/application', { method: 'GET', ...(options || {}), }); diff --git a/apps/admin/services/common/typings.d.ts b/apps/admin/services/common/typings.d.ts index 29599d5..e34759a 100644 --- a/apps/admin/services/common/typings.d.ts +++ b/apps/admin/services/common/typings.d.ts @@ -10,14 +10,6 @@ declare namespace API { updated_at: number; }; - type AppConfig = { - name: string; - domains: string[]; - describe: string; - startup_picture: string; - startup_picture_skip_time: number; - }; - type Application = { id: number; icon: string; @@ -26,6 +18,12 @@ declare namespace API { subscribe_type: string; }; + type ApplicationConfig = { + domains: string[]; + startup_picture: string; + startup_picture_skip_time: number; + }; + type ApplicationPlatform = { ios?: ApplicationVersion[]; mac?: ApplicationVersion[]; @@ -56,15 +54,6 @@ declare namespace API { is_default: boolean; }; - type AppVersion = { - id: number; - os: string; - version: string; - download_url: string; - describe: string; - default_version: boolean; - }; - type AuthConfig = { sms: SmsAuthenticateConfig; email: EmailAuthticateConfig; @@ -151,9 +140,9 @@ declare namespace API { created_at: number; }; - type GetAppInfoResponse = { - config: AppConfig; - versions: AppVersion[]; + type GetAppcationResponse = { + config: ApplicationConfig; + applications: ApplicationResponseInfo[]; }; type GetGlobalConfigResponse = { diff --git a/apps/user/services/common/common.ts b/apps/user/services/common/common.ts index b86d7bb..d200045 100644 --- a/apps/user/services/common/common.ts +++ b/apps/user/services/common/common.ts @@ -2,9 +2,9 @@ /* eslint-disable */ import request from '@/utils/request'; -/** Get Tos Content GET /v1/common/app/info */ -export async function getAppInfo(options?: { [key: string]: any }) { - return request('/v1/common/app/info', { +/** Get Tos Content GET /v1/common/application */ +export async function getApplication(options?: { [key: string]: any }) { + return request('/v1/common/application', { method: 'GET', ...(options || {}), }); diff --git a/apps/user/services/common/typings.d.ts b/apps/user/services/common/typings.d.ts index 29599d5..e34759a 100644 --- a/apps/user/services/common/typings.d.ts +++ b/apps/user/services/common/typings.d.ts @@ -10,14 +10,6 @@ declare namespace API { updated_at: number; }; - type AppConfig = { - name: string; - domains: string[]; - describe: string; - startup_picture: string; - startup_picture_skip_time: number; - }; - type Application = { id: number; icon: string; @@ -26,6 +18,12 @@ declare namespace API { subscribe_type: string; }; + type ApplicationConfig = { + domains: string[]; + startup_picture: string; + startup_picture_skip_time: number; + }; + type ApplicationPlatform = { ios?: ApplicationVersion[]; mac?: ApplicationVersion[]; @@ -56,15 +54,6 @@ declare namespace API { is_default: boolean; }; - type AppVersion = { - id: number; - os: string; - version: string; - download_url: string; - describe: string; - default_version: boolean; - }; - type AuthConfig = { sms: SmsAuthenticateConfig; email: EmailAuthticateConfig; @@ -151,9 +140,9 @@ declare namespace API { created_at: number; }; - type GetAppInfoResponse = { - config: AppConfig; - versions: AppVersion[]; + type GetAppcationResponse = { + config: ApplicationConfig; + applications: ApplicationResponseInfo[]; }; type GetGlobalConfigResponse = { diff --git a/apps/user/services/user/typings.d.ts b/apps/user/services/user/typings.d.ts index dd5b479..b6188f3 100644 --- a/apps/user/services/user/typings.d.ts +++ b/apps/user/services/user/typings.d.ts @@ -10,14 +10,6 @@ declare namespace API { updated_at: number; }; - type AppConfig = { - name: string; - domains: string[]; - describe: string; - startup_picture: string; - startup_picture_skip_time: number; - }; - type Application = { id: number; icon: string; @@ -26,6 +18,12 @@ declare namespace API { subscribe_type: string; }; + type ApplicationConfig = { + domains: string[]; + startup_picture: string; + startup_picture_skip_time: number; + }; + type ApplicationPlatform = { ios?: ApplicationVersion[]; mac?: ApplicationVersion[]; @@ -56,15 +54,6 @@ declare namespace API { is_default: boolean; }; - type AppVersion = { - id: number; - os: string; - version: string; - download_url: string; - describe: string; - default_version: boolean; - }; - type AuthConfig = { sms: SmsAuthenticateConfig; email: EmailAuthticateConfig;