From 39aaa73d6dc67ae1696ec8afdf0b1afe9f659640 Mon Sep 17 00:00:00 2001 From: "web@ppanel" Date: Sun, 1 Dec 2024 15:44:51 +0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(api):=20Update=20Model?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/admin/app/dashboard/system/currency.tsx | 2 +- apps/admin/app/dashboard/system/email.tsx | 2 +- apps/admin/app/dashboard/system/invite.tsx | 2 +- apps/admin/app/dashboard/system/node.tsx | 2 +- apps/admin/app/dashboard/system/register.tsx | 2 +- .../app/dashboard/system/subscription.tsx | 14 +- apps/admin/app/dashboard/system/telegram.tsx | 2 +- apps/admin/app/dashboard/system/tos.tsx | 2 +- apps/admin/app/dashboard/system/verify.tsx | 2 +- apps/admin/config/use-global.tsx | 7 + apps/admin/locales/en-US/common.json | 4 +- apps/admin/locales/zh-CN/common.json | 4 +- apps/admin/services/admin/system.ts | 149 +++---- apps/admin/services/admin/typings.d.ts | 292 +++++++------- apps/admin/services/common/common.ts | 19 + apps/admin/services/common/typings.d.ts | 351 +++++++++++++++++ .../(main)/(user)/dashboard/announcemnet.tsx | 2 +- .../user/app/(main)/(user)/dashboard/page.tsx | 8 +- .../(user)/document/document-button.tsx | 10 +- apps/user/app/(main)/(user)/order/page.tsx | 10 +- .../user/app/(main)/(user)/order/purchase.tsx | 4 +- apps/user/app/(main)/(user)/order/renewal.tsx | 6 +- .../user/app/(main)/(user)/subscribe/page.tsx | 3 +- apps/user/app/(main)/(user)/ticket/page.tsx | 4 +- apps/user/config/use-global.tsx | 19 +- apps/user/services/common/common.ts | 19 + apps/user/services/common/typings.d.ts | 351 +++++++++++++++++ apps/user/services/user/document.ts | 2 +- apps/user/services/user/order.ts | 2 +- apps/user/services/user/subscribe.ts | 2 +- apps/user/services/user/ticket.ts | 2 +- apps/user/services/user/typings.d.ts | 368 +++++++++++++----- apps/user/services/user/user.ts | 2 +- 33 files changed, 1257 insertions(+), 413 deletions(-) diff --git a/apps/admin/app/dashboard/system/currency.tsx b/apps/admin/app/dashboard/system/currency.tsx index 17cdafb..5fd2276 100644 --- a/apps/admin/app/dashboard/system/currency.tsx +++ b/apps/admin/app/dashboard/system/currency.tsx @@ -25,7 +25,7 @@ export default function Site() { await updateCurrencyConfig({ ...data, [key]: value, - } as API.UpdateCurrencyConfigRequest); + } as API.CurrencyConfig); toast.success(t('saveSuccess')); refetch(); } catch (error) { diff --git a/apps/admin/app/dashboard/system/email.tsx b/apps/admin/app/dashboard/system/email.tsx index b5318cd..2a8b2dd 100644 --- a/apps/admin/app/dashboard/system/email.tsx +++ b/apps/admin/app/dashboard/system/email.tsx @@ -31,7 +31,7 @@ export default function Email() { await updateEmailSmtpConfig({ ...data, [key]: value, - } as API.UpdateEmailSmtpConfigRequest); + } as API.EmailSmtpConfig); toast.success(t('saveSuccess')); refetch(); } catch (error) { diff --git a/apps/admin/app/dashboard/system/invite.tsx b/apps/admin/app/dashboard/system/invite.tsx index e1f9b78..f3b1739 100644 --- a/apps/admin/app/dashboard/system/invite.tsx +++ b/apps/admin/app/dashboard/system/invite.tsx @@ -27,7 +27,7 @@ export default function Invite() { await updateInviteConfig({ ...data, [key]: value, - } as API.UpdateInviteConfigRequest); + } as API.InviteConfig); toast.success(t('saveSuccess')); refetch(); } catch (error) { diff --git a/apps/admin/app/dashboard/system/node.tsx b/apps/admin/app/dashboard/system/node.tsx index a033129..239b503 100644 --- a/apps/admin/app/dashboard/system/node.tsx +++ b/apps/admin/app/dashboard/system/node.tsx @@ -28,7 +28,7 @@ export default function Node() { await updateNodeConfig({ ...data, [key]: value, - } as API.GetNodeConfigResponse); + } as API.NodeConfig); toast.success(t('saveSuccess')); refetch(); } catch (error) { diff --git a/apps/admin/app/dashboard/system/register.tsx b/apps/admin/app/dashboard/system/register.tsx index 2dd3648..ab12df3 100644 --- a/apps/admin/app/dashboard/system/register.tsx +++ b/apps/admin/app/dashboard/system/register.tsx @@ -28,7 +28,7 @@ export default function Register() { await updateRegisterConfig({ ...data, [key]: value, - } as API.GetRegisterConfigResponse); + } as API.RegisterConfig); toast.success(t('saveSuccess')); refetch(); } catch (error) { diff --git a/apps/admin/app/dashboard/system/subscription.tsx b/apps/admin/app/dashboard/system/subscription.tsx index bc7aa6d..b24c12c 100644 --- a/apps/admin/app/dashboard/system/subscription.tsx +++ b/apps/admin/app/dashboard/system/subscription.tsx @@ -24,8 +24,8 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from '@shadcn/ui/tabs'; import { Textarea } from '@shadcn/ui/textarea'; function compareData( - originalData: API.GetApplicationResponse, - modifiedData: API.GetApplicationResponse, + originalData: API.ApplicationResponse, + modifiedData: API.ApplicationResponse, ): { added: API.Application[]; deleted: API.Application[]; @@ -107,7 +107,7 @@ export default function Subscription() { await updateSubscribeConfig({ ...data, [key]: value, - } as API.GetSubscribeConfigResponse); + } as API.SubscribeConfig); toast.success(t('saveSuccess')); refetch(); } catch (error) { @@ -123,7 +123,7 @@ export default function Subscription() { return data.data?.subscribe_types || []; }, }); - const [app, setApp] = useState(); + const [app, setApp] = useState(); const appTypes = Object.keys(apps || {}); useEffect(() => { @@ -253,7 +253,7 @@ export default function Subscription() { setApp({ ...app, [type]: newList, - } as API.GetApplicationResponse); + } as API.ApplicationResponse); }; return ( @@ -300,7 +300,7 @@ export default function Subscription() { setApp({ ...app, [type]: list.filter((l, i) => i !== index), - } as API.GetApplicationResponse); + } as API.ApplicationResponse); }} > {t('delete')} @@ -320,7 +320,7 @@ export default function Subscription() { platform: type, }, ], - } as API.GetApplicationResponse); + } as API.ApplicationResponse); }} > {t('add')} diff --git a/apps/admin/app/dashboard/system/telegram.tsx b/apps/admin/app/dashboard/system/telegram.tsx index 0eec188..6eb4f3a 100644 --- a/apps/admin/app/dashboard/system/telegram.tsx +++ b/apps/admin/app/dashboard/system/telegram.tsx @@ -27,7 +27,7 @@ export default function Telegram() { await updateTelegramConfig({ ...data, [key]: value, - } as API.GetTelegramConfigResponse); + } as API.TelegramConfig); toast.success(t('saveSuccess')); refetch(); } catch (error) { diff --git a/apps/admin/app/dashboard/system/tos.tsx b/apps/admin/app/dashboard/system/tos.tsx index 7346b1c..7d0fb42 100644 --- a/apps/admin/app/dashboard/system/tos.tsx +++ b/apps/admin/app/dashboard/system/tos.tsx @@ -25,7 +25,7 @@ export default function Tos() { await updateTosConfig({ ...data, [key]: value, - } as API.GetTosConfigResponse); + } as API.TosConfig); toast.success(t('saveSuccess')); refetch(); } catch (error) { diff --git a/apps/admin/app/dashboard/system/verify.tsx b/apps/admin/app/dashboard/system/verify.tsx index 2aabbe3..58e88c1 100644 --- a/apps/admin/app/dashboard/system/verify.tsx +++ b/apps/admin/app/dashboard/system/verify.tsx @@ -26,7 +26,7 @@ export default function Verify() { await updateVerifyConfig({ ...data, [key]: value, - } as API.GetVerifyConfigResponse); + } as API.VerifyConfig); toast.success(t('saveSuccess')); refetch(); } catch (error) { diff --git a/apps/admin/config/use-global.tsx b/apps/admin/config/use-global.tsx index 03213a1..93057b4 100644 --- a/apps/admin/config/use-global.tsx +++ b/apps/admin/config/use-global.tsx @@ -26,13 +26,20 @@ export const useGlobalStore = create((set) => ({ enable_email_verify: false, enable_email_domain_suffix: false, email_domain_suffix_list: '', + enable_trial: false, + enable_ip_register_limit: false, + ip_register_limit: 0, + ip_register_limit_duration: 0, }, invite: { forced_invite: false, + referral_percentage: 0, + only_first_purchase: false, }, currency: { currency_unit: 'USD', currency_symbol: '$', + access_key: '', }, subscribe: { single_model: false, diff --git a/apps/admin/locales/en-US/common.json b/apps/admin/locales/en-US/common.json index 3d19c53..3262bb1 100644 --- a/apps/admin/locales/en-US/common.json +++ b/apps/admin/locales/en-US/common.json @@ -1,7 +1,7 @@ { "billing": { - "title": "赞助商", - "description": "赞助有助于 PPanel 继续发布更新!" + "description": "Sponsoring helps PPanel to continue releasing updates!", + "title": "Sponsor" }, "empty": [ "Imagine this place filled with exciting content! For now, you'll have to use your imagination...", diff --git a/apps/admin/locales/zh-CN/common.json b/apps/admin/locales/zh-CN/common.json index fe3a8b9..2e3578b 100644 --- a/apps/admin/locales/zh-CN/common.json +++ b/apps/admin/locales/zh-CN/common.json @@ -1,7 +1,7 @@ { "billing": { - "title": "赞助商", - "description": "赞助有助于 PPanel 继续发布更新!" + "description": "赞助有助于 PPanel 继续发布更新!", + "title": "赞助商" }, "empty": [ "想象一下这里充满了精彩的内容!暂时只能靠想象了…", diff --git a/apps/admin/services/admin/system.ts b/apps/admin/services/admin/system.ts index 575f4c6..8d65824 100644 --- a/apps/admin/services/admin/system.ts +++ b/apps/admin/services/admin/system.ts @@ -4,7 +4,7 @@ import request from '@/utils/request'; /** Get application GET /v1/admin/system/application */ export async function getApplication(options?: { [key: string]: any }) { - return request( + return request( '/v1/admin/system/application', { method: 'GET', @@ -60,18 +60,15 @@ export async function deleteApplication( /** Get Currency Config GET /v1/admin/system/currency_config */ export async function getCurrencyConfig(options?: { [key: string]: any }) { - return request( - '/v1/admin/system/currency_config', - { - method: 'GET', - ...(options || {}), - }, - ); + return request('/v1/admin/system/currency_config', { + method: 'GET', + ...(options || {}), + }); } /** Update Currency Config PUT /v1/admin/system/currency_config */ export async function updateCurrencyConfig( - body: API.UpdateCurrencyConfigRequest, + body: API.CurrencyConfig, options?: { [key: string]: any }, ) { return request('/v1/admin/system/currency_config', { @@ -86,18 +83,15 @@ export async function updateCurrencyConfig( /** Get email smtp config GET /v1/admin/system/email_config */ export async function getEmailSmtpConfig(options?: { [key: string]: any }) { - return request( - '/v1/admin/system/email_config', - { - method: 'GET', - ...(options || {}), - }, - ); + return request('/v1/admin/system/email_config', { + method: 'GET', + ...(options || {}), + }); } /** Update email smtp config PUT /v1/admin/system/email_config */ export async function updateEmailSmtpConfig( - body: API.UpdateEmailSmtpConfigRequest, + body: API.EmailSmtpConfig, options?: { [key: string]: any }, ) { return request('/v1/admin/system/email_config', { @@ -112,20 +106,14 @@ export async function updateEmailSmtpConfig( /** Get invite config GET /v1/admin/system/invite_config */ export async function getInviteConfig(options?: { [key: string]: any }) { - return request( - '/v1/admin/system/invite_config', - { - method: 'GET', - ...(options || {}), - }, - ); + return request('/v1/admin/system/invite_config', { + method: 'GET', + ...(options || {}), + }); } /** Update invite config PUT /v1/admin/system/invite_config */ -export async function updateInviteConfig( - body: API.UpdateInviteConfigRequest, - options?: { [key: string]: any }, -) { +export async function updateInviteConfig(body: API.InviteConfig, options?: { [key: string]: any }) { return request('/v1/admin/system/invite_config', { method: 'PUT', headers: { @@ -138,20 +126,14 @@ export async function updateInviteConfig( /** Get node config GET /v1/admin/system/node_config */ export async function getNodeConfig(options?: { [key: string]: any }) { - return request( - '/v1/admin/system/node_config', - { - method: 'GET', - ...(options || {}), - }, - ); + return request('/v1/admin/system/node_config', { + method: 'GET', + ...(options || {}), + }); } /** Update node config PUT /v1/admin/system/node_config */ -export async function updateNodeConfig( - body: API.UpdateNodeConfigRequest, - options?: { [key: string]: any }, -) { +export async function updateNodeConfig(body: API.NodeConfig, options?: { [key: string]: any }) { return request('/v1/admin/system/node_config', { method: 'PUT', headers: { @@ -164,18 +146,15 @@ export async function updateNodeConfig( /** Get register config GET /v1/admin/system/register_config */ export async function getRegisterConfig(options?: { [key: string]: any }) { - return request( - '/v1/admin/system/register_config', - { - method: 'GET', - ...(options || {}), - }, - ); + return request('/v1/admin/system/register_config', { + method: 'GET', + ...(options || {}), + }); } /** Update register config PUT /v1/admin/system/register_config */ export async function updateRegisterConfig( - body: API.UpdateRegisterConfigRequest, + body: API.RegisterConfig, options?: { [key: string]: any }, ) { return request('/v1/admin/system/register_config', { @@ -190,20 +169,14 @@ export async function updateRegisterConfig( /** Get site config GET /v1/admin/system/site_config */ export async function getSiteConfig(options?: { [key: string]: any }) { - return request( - '/v1/admin/system/site_config', - { - method: 'GET', - ...(options || {}), - }, - ); + return request('/v1/admin/system/site_config', { + method: 'GET', + ...(options || {}), + }); } /** Update site config PUT /v1/admin/system/site_config */ -export async function updateSiteConfig( - body: API.UpdateSiteConfigRequest, - options?: { [key: string]: any }, -) { +export async function updateSiteConfig(body: API.SiteConfig, options?: { [key: string]: any }) { return request('/v1/admin/system/site_config', { method: 'PUT', headers: { @@ -216,7 +189,7 @@ export async function updateSiteConfig( /** Get subscribe config GET /v1/admin/system/subscribe_config */ export async function getSubscribeConfig(options?: { [key: string]: any }) { - return request( + return request( '/v1/admin/system/subscribe_config', { method: 'GET', @@ -227,7 +200,7 @@ export async function getSubscribeConfig(options?: { [key: string]: any }) { /** Update subscribe config PUT /v1/admin/system/subscribe_config */ export async function updateSubscribeConfig( - body: API.UpdateSubscribeConfigRequest, + body: API.SubscribeConfig, options?: { [key: string]: any }, ) { return request('/v1/admin/system/subscribe_config', { @@ -242,29 +215,23 @@ export async function updateSubscribeConfig( /** Get subscribe type GET /v1/admin/system/subscribe_type */ export async function getSubscribeType(options?: { [key: string]: any }) { - return request( - '/v1/admin/system/subscribe_type', - { - method: 'GET', - ...(options || {}), - }, - ); + return request('/v1/admin/system/subscribe_type', { + method: 'GET', + ...(options || {}), + }); } /** Get Telegram Config GET /v1/admin/system/telegram_config */ export async function getTelegramConfig(options?: { [key: string]: any }) { - return request( - '/v1/admin/system/telegram_config', - { - method: 'GET', - ...(options || {}), - }, - ); + return request('/v1/admin/system/telegram_config', { + method: 'GET', + ...(options || {}), + }); } /** Update Telegram Config PUT /v1/admin/system/telegram_config */ export async function updateTelegramConfig( - body: API.UpdateTelegramConfigRequest, + body: API.TelegramConfig, options?: { [key: string]: any }, ) { return request('/v1/admin/system/telegram_config', { @@ -294,20 +261,14 @@ export async function testEmailSmtp( /** Get Team of Service Config GET /v1/admin/system/tos_config */ export async function getTosConfig(options?: { [key: string]: any }) { - return request( - '/v1/admin/system/tos_config', - { - method: 'GET', - ...(options || {}), - }, - ); + return request('/v1/admin/system/tos_config', { + method: 'GET', + ...(options || {}), + }); } /** Update Team of Service Config PUT /v1/admin/system/tos_config */ -export async function updateTosConfig( - body: API.UpdateTosConfigRequest, - options?: { [key: string]: any }, -) { +export async function updateTosConfig(body: API.TosConfig, options?: { [key: string]: any }) { return request('/v1/admin/system/tos_config', { method: 'PUT', headers: { @@ -320,20 +281,14 @@ export async function updateTosConfig( /** Get verify config GET /v1/admin/system/verify_config */ export async function getVerifyConfig(options?: { [key: string]: any }) { - return request( - '/v1/admin/system/verify_config', - { - method: 'GET', - ...(options || {}), - }, - ); + return request('/v1/admin/system/verify_config', { + method: 'GET', + ...(options || {}), + }); } /** Update verify config PUT /v1/admin/system/verify_config */ -export async function updateVerifyConfig( - body: API.UpdateVerifyConfigRequest, - options?: { [key: string]: any }, -) { +export async function updateVerifyConfig(body: API.VerifyConfig, options?: { [key: string]: any }) { return request('/v1/admin/system/verify_config', { method: 'PUT', headers: { diff --git a/apps/admin/services/admin/typings.d.ts b/apps/admin/services/admin/typings.d.ts index caa3fc0..1d17682 100644 --- a/apps/admin/services/admin/typings.d.ts +++ b/apps/admin/services/admin/typings.d.ts @@ -17,6 +17,14 @@ declare namespace API { url: string; }; + type ApplicationResponse = { + windows: Application[]; + mac: Application[]; + linux: Application[]; + android: Application[]; + ios: Application[]; + }; + type BatchDeleteCouponRequest = { ids: number[]; }; @@ -172,6 +180,12 @@ declare namespace API { is_admin: boolean; }; + type CurrencyConfig = { + currency_unit: string; + currency_symbol: string; + access_key: string; + }; + type DeleteAnnouncementRequest = { id: number; }; @@ -218,6 +232,18 @@ declare namespace API { updated_at: number; }; + type EmailSmtpConfig = { + email_smtp_host: string; + email_smtp_port: number; + email_smtp_user: string; + email_smtp_pass: string; + email_smtp_from: string; + email_smtp_ssl: boolean; + verify_email_template: string; + maintenance_email_template: string; + expiration_email_template: string; + }; + type Follow = { id: number; ticket_id: number; @@ -258,14 +284,6 @@ declare namespace API { id: number; }; - type GetApplicationResponse = { - windows: Application[]; - mac: Application[]; - linux: Application[]; - android: Application[]; - ios: Application[]; - }; - type GetCouponListParams = { page: number; size: number; @@ -285,12 +303,6 @@ declare namespace API { list: Coupon[]; }; - type GetCurrencyConfigResponse = { - currency_unit: string; - currency_symbol: string; - access_key: string; - }; - type GetDetailRequest = { id: number; }; @@ -318,30 +330,6 @@ declare namespace API { list: Document[]; }; - type GetEmailSmtpConfigResponse = { - email_smtp_host: string; - email_smtp_port: number; - email_smtp_user: string; - email_smtp_pass: string; - email_smtp_from: string; - email_smtp_ssl: boolean; - verify_email_template: string; - maintenance_email_template: string; - expiration_email_template: string; - }; - - type GetInviteConfigResponse = { - forced_invite: boolean; - referral_percentage: number; - only_first_purchase: boolean; - }; - - type GetNodeConfigResponse = { - node_secret: string; - node_pull_interval: number; - node_push_interval: number; - }; - type GetNodeDetailParams = { id: number; }; @@ -397,31 +385,6 @@ declare namespace API { list: Order[]; }; - type GetRegisterConfigResponse = { - stop_register: boolean; - enable_trial: boolean; - enable_email_verify: boolean; - enable_email_domain_suffix: boolean; - email_domain_suffix_list: string; - enable_ip_register_limit: boolean; - ip_register_limit: number; - ip_register_limit_duration: number; - }; - - type GetSiteConfigResponse = { - host: string; - site_name: string; - site_desc: string; - site_logo: string; - }; - - type GetSubscribeConfigResponse = { - single_model: boolean; - subscribe_path: string; - subscribe_domain: string; - pan_domain: boolean; - }; - type GetSubscribeDetailsParams = { id: number; }; @@ -454,16 +417,6 @@ declare namespace API { total: number; }; - type GetSubscribeTypeResponse = { - subscribe_types: string[]; - }; - - type GetTelegramConfigResponse = { - telegram_bot_token: string; - telegram_group_url: string; - telegram_notify: boolean; - }; - type GetTicketListParams = { page: number; size: number; @@ -493,10 +446,6 @@ declare namespace API { id: number; }; - type GetTosConfigResponse = { - tos_content: string; - }; - type GetUserDetailParams = { id: number; }; @@ -518,12 +467,16 @@ declare namespace API { list: User[]; }; - type GetVerifyConfigResponse = { - turnstile_site_key: string; - turnstile_secret: string; - enable_login_verify: boolean; - enable_register_verify: boolean; - enable_reset_password_verify: boolean; + type InviteConfig = { + forced_invite: boolean; + referral_percentage: number; + only_first_purchase: boolean; + }; + + type NodeConfig = { + node_secret: string; + node_pull_interval: number; + node_push_interval: number; }; type Order = { @@ -546,6 +499,27 @@ declare namespace API { updated_at: number; }; + type OrderDetail = { + id: number; + user_id: number; + order_no: string; + type: number; + quantity: number; + price: number; + amount: number; + discount: number; + coupon: string; + coupon_discount: number; + method: string; + fee_amount: number; + trade_no: string; + status: number; + subscribe_id: number; + subscribe: Subscribe; + created_at: number; + updated_at: number; + }; + type PaymentConfig = { id: number; name: string; @@ -564,6 +538,17 @@ declare namespace API { count: number; }; + type RegisterConfig = { + stop_register: boolean; + enable_trial: boolean; + enable_email_verify: boolean; + enable_email_domain_suffix: boolean; + email_domain_suffix_list: string; + enable_ip_register_limit: boolean; + ip_register_limit: number; + ip_register_limit_duration: number; + }; + type Response = { /** 状态码 */ code?: number; @@ -607,6 +592,13 @@ declare namespace API { relay_port: number; }; + type SiteConfig = { + host: string; + site_name: string; + site_desc: string; + site_logo: string; + }; + type Subscribe = { id: number; name: string; @@ -628,6 +620,13 @@ declare namespace API { updated_at: number; }; + type SubscribeConfig = { + single_model: boolean; + subscribe_path: string; + subscribe_domain: string; + pan_domain: boolean; + }; + type SubscribeDiscount = { months: number; discount: number; @@ -641,6 +640,16 @@ declare namespace API { updated_at: number; }; + type SubscribeType = { + subscribe_types: string[]; + }; + + type TelegramConfig = { + telegram_bot_token: string; + telegram_group_url: string; + telegram_notify: boolean; + }; + type TestEmailSmtpRequest = { email: string; }; @@ -656,6 +665,10 @@ declare namespace API { updated_at: number; }; + type TosConfig = { + tos_content: string; + }; + type Trojan = { network: string; port: number; @@ -703,12 +716,6 @@ declare namespace API { enable?: boolean; }; - type UpdateCurrencyConfigRequest = { - currency_unit: string; - currency_symbol: string; - access_key: string; - }; - type UpdateDocumentRequest = { id: number; title: string; @@ -717,28 +724,6 @@ declare namespace API { show: boolean; }; - type UpdateEmailSmtpConfigRequest = { - email_smtp_host: string; - email_smtp_port: number; - email_smtp_user: string; - email_smtp_pass: string; - email_smtp_from: string; - email_smtp_ssl: boolean; - email_template: string; - }; - - type UpdateInviteConfigRequest = { - forced_invite: boolean; - referral_percentage: number; - only_first_purchase: boolean; - }; - - type UpdateNodeConfigRequest = { - node_secret: string; - node_pull_interval: number; - node_push_interval: number; - }; - type UpdateNodeGroupRequest = { id: number; name: string; @@ -767,31 +752,6 @@ declare namespace API { trade_no?: string; }; - type UpdateRegisterConfigRequest = { - stop_register: boolean; - enable_trial: boolean; - enable_email_verify: boolean; - enable_email_domain_suffix: boolean; - email_domain_suffix_list: string; - enable_ip_register_limit: boolean; - ip_register_limit: number; - ip_register_limit_duration: number; - }; - - type UpdateSiteConfigRequest = { - host: string; - site_name: string; - site_desc: string; - site_logo: string; - }; - - type UpdateSubscribeConfigRequest = { - single_model: boolean; - subscribe_path: string; - subscribe_domain: string; - pan_domain: boolean; - }; - type UpdateSubscribeGroupRequest = { id: number; name: string; @@ -817,21 +777,11 @@ declare namespace API { sell: boolean; }; - type UpdateTelegramConfigRequest = { - telegram_bot_token: string; - telegram_group_url: string; - telegram_notify: boolean; - }; - type UpdateTicketStatusRequest = { id: number; status: number; }; - type UpdateTosConfigRequest = { - tos_content: string; - }; - type UpdateUserRequest = { id: number; email: string; @@ -852,14 +802,6 @@ declare namespace API { enable_trade_notify: boolean; }; - type UpdateVerifyConfigRequest = { - turnstile_site_key: string; - turnstile_secret: string; - enable_login_verify: boolean; - enable_register_verify: boolean; - enable_reset_password_verify: boolean; - }; - type User = { id: number; email: string; @@ -883,6 +825,48 @@ declare namespace API { is_del?: boolean; }; + type UserAffiliate = { + email: string; + avatar: string; + registered_at: number; + enable: boolean; + }; + + type UserBalanceLog = { + id: number; + user_id: number; + amount: number; + type: number; + order_id: number; + balance: number; + created_at: number; + }; + + type UserSubscribe = { + id: number; + user_id: number; + order_id: number; + subscribe_id: number; + subscribe: Subscribe; + start_time: number; + expire_time: number; + traffic: number; + download: number; + upload: number; + mark: string; + status: number; + created_at: number; + updated_at: number; + }; + + type VerifyConfig = { + turnstile_site_key: string; + turnstile_secret: string; + enable_login_verify: boolean; + enable_register_verify: boolean; + enable_reset_password_verify: boolean; + }; + type Vless = { host: string; port: number; diff --git a/apps/admin/services/common/common.ts b/apps/admin/services/common/common.ts index e138af7..07b6b82 100644 --- a/apps/admin/services/common/common.ts +++ b/apps/admin/services/common/common.ts @@ -22,6 +22,25 @@ export async function getGlobalConfig(options?: { [key: string]: any }) { }); } +/** Get stat GET /v1/common/site/stat */ +export async function getStat(options?: { [key: string]: any }) { + return request('/v1/common/site/stat', { + method: 'GET', + ...(options || {}), + }); +} + +/** Get Subscription GET /v1/common/site/subscribe */ +export async function getSubscription(options?: { [key: string]: any }) { + return request( + '/v1/common/site/subscribe', + { + method: 'GET', + ...(options || {}), + }, + ); +} + /** Get Tos Content GET /v1/common/site/tos */ export async function getTos(options?: { [key: string]: any }) { return request('/v1/common/site/tos', { diff --git a/apps/admin/services/common/typings.d.ts b/apps/admin/services/common/typings.d.ts index 826480f..60ce7a5 100644 --- a/apps/admin/services/common/typings.d.ts +++ b/apps/admin/services/common/typings.d.ts @@ -1,4 +1,30 @@ declare namespace API { + type Announcement = { + id: number; + title: string; + content: string; + enable: boolean; + created_at: number; + updated_at: number; + }; + + type Application = { + id: number; + name: string; + platform: string; + subscribe_type: string; + icon: string; + url: string; + }; + + type ApplicationResponse = { + windows: Application[]; + mac: Application[]; + linux: Application[]; + android: Application[]; + ios: Application[]; + }; + type CheckUserParams = { email: string; }; @@ -11,9 +37,58 @@ declare namespace API { exist: boolean; }; + type Coupon = { + id: number; + name: string; + code: string; + count: number; + type: number; + discount: number; + start_time: number; + expire_time: number; + user_limit: number; + subscribe: number[]; + used_count: number; + enable: boolean; + created_at: number; + updated_at: number; + }; + type CurrencyConfig = { currency_unit: string; currency_symbol: string; + access_key: string; + }; + + type Document = { + id: number; + title: string; + content: string; + tags: string[]; + show: boolean; + created_at: number; + updated_at: number; + }; + + type EmailSmtpConfig = { + email_smtp_host: string; + email_smtp_port: number; + email_smtp_user: string; + email_smtp_pass: string; + email_smtp_from: string; + email_smtp_ssl: boolean; + verify_email_template: string; + maintenance_email_template: string; + expiration_email_template: string; + }; + + type Follow = { + id: number; + ticket_id: number; + from: string; + type: number; + content: string; + created_at: number; }; type GetGlobalConfigResponse = { @@ -25,23 +100,104 @@ declare namespace API { subscribe: SubscribeConfig; }; + type GetStatResponse = { + user: number; + node: number; + country: number; + }; + + type GetSubscriptionResponse = { + list: Subscribe[]; + }; + type GetTosResponse = { tos_content: string; }; type InviteConfig = { forced_invite: boolean; + referral_percentage: number; + only_first_purchase: boolean; }; type LoginResponse = { token: string; }; + type NodeConfig = { + node_secret: string; + node_pull_interval: number; + node_push_interval: number; + }; + + type Order = { + id: number; + user_id: number; + order_no: string; + type: number; + quantity: number; + price: number; + amount: number; + discount: number; + coupon: string; + coupon_discount: number; + method: string; + fee_amount: number; + trade_no: string; + status: number; + subscribe_id: number; + created_at: number; + updated_at: number; + }; + + type OrderDetail = { + id: number; + user_id: number; + order_no: string; + type: number; + quantity: number; + price: number; + amount: number; + discount: number; + coupon: string; + coupon_discount: number; + method: string; + fee_amount: number; + trade_no: string; + status: number; + subscribe_id: number; + subscribe: Subscribe; + created_at: number; + updated_at: number; + }; + + type PaymentConfig = { + id: number; + name: string; + mark: string; + icon?: string; + domain?: string; + config: Record; + fee_mode: number; + fee_percent?: number; + fee_amount?: number; + enable: boolean; + }; + + type Push = { + push_at: number; + count: number; + }; + type RegisterConfig = { stop_register: boolean; + enable_trial: boolean; enable_email_verify: boolean; enable_email_domain_suffix: boolean; email_domain_suffix_list: string; + enable_ip_register_limit: boolean; + ip_register_limit: number; + ip_register_limit_duration: number; }; type ResetPasswordRequest = { @@ -69,6 +225,40 @@ declare namespace API { status: boolean; }; + type Server = { + id: number; + name: string; + server_addr: string; + speed_limit: number; + traffic_ratio: number; + groupId: number; + protocol: string; + enable: boolean; + vmess?: Vmess; + vless?: Vless; + trojan?: Trojan; + shadowsocks?: Shadowsocks; + created_at: number; + updated_at: number; + last: Push; + }; + + type ServerGroup = { + id: number; + name: string; + description: string; + created_at: number; + updated_at: number; + }; + + type Shadowsocks = { + method: string; + port: number; + enable_relay: boolean; + relay_host: string; + relay_port: number; + }; + type SiteConfig = { host: string; site_name: string; @@ -76,6 +266,27 @@ declare namespace API { site_logo: string; }; + type Subscribe = { + id: number; + name: string; + description: string; + unit_price: number; + discount: SubscribeDiscount[]; + replacement: number; + inventory: number; + traffic: number; + speed_limit: number; + device_limit: number; + quota: number; + group_id: number; + server_group: number[]; + server: number[]; + show: boolean; + sell: boolean; + created_at: number; + updated_at: number; + }; + type SubscribeConfig = { single_model: boolean; subscribe_path: string; @@ -83,6 +294,96 @@ declare namespace API { pan_domain: boolean; }; + type SubscribeDiscount = { + months: number; + discount: number; + }; + + type SubscribeGroup = { + id: number; + name: string; + description: string; + created_at: number; + updated_at: number; + }; + + type SubscribeType = { + subscribe_types: string[]; + }; + + type TelegramConfig = { + telegram_bot_token: string; + telegram_group_url: string; + telegram_notify: boolean; + }; + + type Ticket = { + id: number; + title: string; + description: string; + user_id: number; + follow?: Follow[]; + status: number; + created_at: number; + updated_at: number; + }; + + type TosConfig = { + tos_content: string; + }; + + type Trojan = { + network: string; + port: number; + host: string; + sni: string; + allow_insecure: boolean; + transport: Record; + enable_relay: boolean; + relay_host: string; + relay_port: number; + }; + + type User = { + id: number; + email: string; + avatar: string; + balance: number; + telegram: number; + refer_code: string; + referer_id: number; + enable: boolean; + is_admin?: boolean; + valid_email: boolean; + enable_email_notify: boolean; + enable_telegram_notify: boolean; + enable_balance_notify: boolean; + enable_login_notify: boolean; + enable_subscribe_notify: boolean; + enable_trade_notify: boolean; + created_at: number; + updated_at: number; + deleted_at?: number; + is_del?: boolean; + }; + + type UserAffiliate = { + email: string; + avatar: string; + registered_at: number; + enable: boolean; + }; + + type UserBalanceLog = { + id: number; + user_id: number; + amount: number; + type: number; + order_id: number; + balance: number; + created_at: number; + }; + type UserLoginRequest = { email: string; password: string; @@ -97,10 +398,60 @@ declare namespace API { cf_token?: string; }; + type UserSubscribe = { + id: number; + user_id: number; + order_id: number; + subscribe_id: number; + subscribe: Subscribe; + start_time: number; + expire_time: number; + traffic: number; + download: number; + upload: number; + mark: string; + status: number; + created_at: number; + updated_at: number; + }; + type VeifyConfig = { turnstile_site_key: string; enable_login_verify: boolean; enable_register_verify: boolean; enable_reset_password_verify: boolean; }; + + type VerifyConfig = { + turnstile_site_key: string; + turnstile_secret: string; + enable_login_verify: boolean; + enable_register_verify: boolean; + enable_reset_password_verify: boolean; + }; + + type Vless = { + host: string; + port: number; + network: string; + transport: Record; + security: string; + security_config: Record; + xtls: string; + enable_relay: boolean; + relay_host: string; + relay_port: number; + }; + + type Vmess = { + host: string; + port: number; + enable_tls: boolean; + tls_config: Record; + network: string; + transport: Record; + enable_relay: boolean; + relay_host: string; + relay_port: number; + }; } diff --git a/apps/user/app/(main)/(user)/dashboard/announcemnet.tsx b/apps/user/app/(main)/(user)/dashboard/announcemnet.tsx index 613223b..fb45fc7 100644 --- a/apps/user/app/(main)/(user)/dashboard/announcemnet.tsx +++ b/apps/user/app/(main)/(user)/dashboard/announcemnet.tsx @@ -18,7 +18,7 @@ export default function Announcement() { page: 1, size: 1, }); - return (data.data?.announcements?.[0] as API.AnnouncementDetails) || {}; + return (data.data?.announcements?.[0] as API.Announcement) || {}; }, }); diff --git a/apps/user/app/(main)/(user)/dashboard/page.tsx b/apps/user/app/(main)/(user)/dashboard/page.tsx index 3127ee0..b38557c 100644 --- a/apps/user/app/(main)/(user)/dashboard/page.tsx +++ b/apps/user/app/(main)/(user)/dashboard/page.tsx @@ -53,10 +53,10 @@ export default function Page() { queryKey: ['queryApplicationConfig'], queryFn: async () => { const { data } = await queryApplicationConfig(); - return data.data as API.QueryApplicationConfigResponse; + return data.data as API.ApplicationResponse; }, }); - const [platform, setPlatform] = useState('windows'); + const [platform, setPlatform] = useState('windows'); const handleCopy = async (text: string) => { try { @@ -79,9 +79,7 @@ export default function Page() {
- setPlatform(value as keyof API.QueryApplicationConfigResponse) - } + onValueChange={(value) => setPlatform(value as keyof API.ApplicationResponse)} className='w-full max-w-full md:w-auto' > diff --git a/apps/user/app/(main)/(user)/document/document-button.tsx b/apps/user/app/(main)/(user)/document/document-button.tsx index 065f85f..bc9ea8b 100644 --- a/apps/user/app/(main)/(user)/document/document-button.tsx +++ b/apps/user/app/(main)/(user)/document/document-button.tsx @@ -12,18 +12,18 @@ import { AnimatePresence, motion } from 'framer-motion'; import { useTranslations } from 'next-intl'; import { useEffect, useId, useRef, useState } from 'react'; -export function DocumentButton({ items }: { items: API.DocumentItem[] }) { +export function DocumentButton({ items }: { items: API.Document[] }) { const t = useTranslations('document'); - const [active, setActive] = useState(null); + const [active, setActive] = useState(null); const id = useId(); const ref = useRef(null); const { data } = useQuery({ - enabled: !!(active as API.DocumentItem)?.id, - queryKey: ['queryDocumentDetail', (active as API.DocumentItem)?.id], + enabled: !!(active as API.Document)?.id, + queryKey: ['queryDocumentDetail', (active as API.Document)?.id], queryFn: async () => { const { data } = await queryDocumentDetail({ - id: (active as API.DocumentItem)?.id, + id: (active as API.Document)?.id, }); return data.data?.content; }, diff --git a/apps/user/app/(main)/(user)/order/page.tsx b/apps/user/app/(main)/(user)/order/page.tsx index 03c840b..8f2740c 100644 --- a/apps/user/app/(main)/(user)/order/page.tsx +++ b/apps/user/app/(main)/(user)/order/page.tsx @@ -15,7 +15,7 @@ export default function Page() { const ref = useRef(null); return ( - > + > action={ref} request={async (pagination, filter) => { const response = await queryOrderList({ ...pagination, ...filter }); @@ -30,14 +30,14 @@ export default function Page() { {t('orderNo')} -

{item.orderNo}

+

{item.order_no}

{item.status === 1 ? ( <> {t('payment')} @@ -47,7 +47,7 @@ export default function Page() { size='sm' variant='destructive' onClick={async () => { - await closeOrder({ orderNo: item.orderNo }); + await closeOrder({ orderNo: item.order_no }); ref.current?.refresh(); }} > @@ -57,7 +57,7 @@ export default function Page() { ) : ( {t('detail')} diff --git a/apps/user/app/(main)/(user)/order/purchase.tsx b/apps/user/app/(main)/(user)/order/purchase.tsx index d9d228b..52a9ceb 100644 --- a/apps/user/app/(main)/(user)/order/purchase.tsx +++ b/apps/user/app/(main)/(user)/order/purchase.tsx @@ -25,8 +25,8 @@ export default function Purchase({ subscribe, setSubscribe, }: { - subscribe?: API.SubscribeDetails; - setSubscribe: (subscribe?: API.SubscribeDetails) => void; + subscribe?: API.Subscribe; + setSubscribe: (subscribe?: API.Subscribe) => void; }) { const t = useTranslations('order'); diff --git a/apps/user/app/(main)/(user)/order/renewal.tsx b/apps/user/app/(main)/(user)/order/renewal.tsx index 530d075..6a564b3 100644 --- a/apps/user/app/(main)/(user)/order/renewal.tsx +++ b/apps/user/app/(main)/(user)/order/renewal.tsx @@ -26,8 +26,8 @@ export default function Renewal({ subscribe, }: { mark: string; - subscribe: Omit & { - discount: string | API.UserSubscribeDiscount[]; + subscribe: Omit & { + discount: string | API.SubscribeDiscount[]; }; }) { const t = useTranslations('order'); @@ -77,7 +77,7 @@ export default function Renewal({ function getDiscount() { try { if (typeof subscribe.discount === 'string') { - return JSON.parse(subscribe?.discount) as API.UserSubscribeDiscount[]; + return JSON.parse(subscribe?.discount) as API.SubscribeDiscount[]; } return subscribe?.discount; } catch (error) { diff --git a/apps/user/app/(main)/(user)/subscribe/page.tsx b/apps/user/app/(main)/(user)/subscribe/page.tsx index 319069a..1b9b06a 100644 --- a/apps/user/app/(main)/(user)/subscribe/page.tsx +++ b/apps/user/app/(main)/(user)/subscribe/page.tsx @@ -17,7 +17,7 @@ import { SubscribeDetail } from './detail'; export default function Page() { const t = useTranslations('subscribe'); - const [subscribe, setSubscribe] = useState(); + const [subscribe, setSubscribe] = useState(); const [group, setGroup] = useState(''); @@ -81,7 +81,6 @@ export default function Page() { icon: string; label: string; type: 'default' | 'success' | 'destructive'; - support: boolean; }, index: number, ) => ( diff --git a/apps/user/app/(main)/(user)/ticket/page.tsx b/apps/user/app/(main)/(user)/ticket/page.tsx index 26cd999..5451c8b 100644 --- a/apps/user/app/(main)/(user)/ticket/page.tsx +++ b/apps/user/app/(main)/(user)/ticket/page.tsx @@ -51,7 +51,7 @@ export default function Page() { queryKey: ['getUserTicketDetails', ticketId], queryFn: async () => { const { data } = await getUserTicketDetails({ id: ticketId }); - return data.data as API.UserTicket; + return data.data as API.Ticket; }, enabled: !!ticketId, refetchInterval: 5000, @@ -74,7 +74,7 @@ export default function Page() { return ( <> - + action={ref} header={{ title: t('ticketList'), diff --git a/apps/user/config/use-global.tsx b/apps/user/config/use-global.tsx index 39e584e..b9480b7 100644 --- a/apps/user/config/use-global.tsx +++ b/apps/user/config/use-global.tsx @@ -5,15 +5,11 @@ import Base64 from 'crypto-js/enc-base64'; import UTF8 from 'crypto-js/enc-utf8'; import { create } from 'zustand'; -interface ICommon extends API.GetGlobalConfigResponse { - background: string; -} - export interface GlobalStore { - common: ICommon; - user?: API.UserInfo; - setCommon: (common: Partial) => void; - setUser: (user?: API.UserInfo) => void; + common: API.GetGlobalConfigResponse; + user?: API.User; + setCommon: (common: Partial) => void; + setUser: (user?: API.User) => void; getUserInfo: () => Promise; getUserSubscribe: (uuid: string, type?: string) => string[]; getAppSubLink: (type: string, url: string) => string; @@ -39,13 +35,20 @@ export const useGlobalStore = create((set, get) => ({ enable_email_verify: false, enable_email_domain_suffix: false, email_domain_suffix_list: '', + enable_trial: false, + enable_ip_register_limit: false, + ip_register_limit: 0, + ip_register_limit_duration: 0, }, invite: { forced_invite: false, + referral_percentage: 0, + only_first_purchase: false, }, currency: { currency_unit: 'USD', currency_symbol: '$', + access_key: '', }, subscribe: { single_model: false, diff --git a/apps/user/services/common/common.ts b/apps/user/services/common/common.ts index e138af7..07b6b82 100644 --- a/apps/user/services/common/common.ts +++ b/apps/user/services/common/common.ts @@ -22,6 +22,25 @@ export async function getGlobalConfig(options?: { [key: string]: any }) { }); } +/** Get stat GET /v1/common/site/stat */ +export async function getStat(options?: { [key: string]: any }) { + return request('/v1/common/site/stat', { + method: 'GET', + ...(options || {}), + }); +} + +/** Get Subscription GET /v1/common/site/subscribe */ +export async function getSubscription(options?: { [key: string]: any }) { + return request( + '/v1/common/site/subscribe', + { + method: 'GET', + ...(options || {}), + }, + ); +} + /** Get Tos Content GET /v1/common/site/tos */ export async function getTos(options?: { [key: string]: any }) { return request('/v1/common/site/tos', { diff --git a/apps/user/services/common/typings.d.ts b/apps/user/services/common/typings.d.ts index 826480f..60ce7a5 100644 --- a/apps/user/services/common/typings.d.ts +++ b/apps/user/services/common/typings.d.ts @@ -1,4 +1,30 @@ declare namespace API { + type Announcement = { + id: number; + title: string; + content: string; + enable: boolean; + created_at: number; + updated_at: number; + }; + + type Application = { + id: number; + name: string; + platform: string; + subscribe_type: string; + icon: string; + url: string; + }; + + type ApplicationResponse = { + windows: Application[]; + mac: Application[]; + linux: Application[]; + android: Application[]; + ios: Application[]; + }; + type CheckUserParams = { email: string; }; @@ -11,9 +37,58 @@ declare namespace API { exist: boolean; }; + type Coupon = { + id: number; + name: string; + code: string; + count: number; + type: number; + discount: number; + start_time: number; + expire_time: number; + user_limit: number; + subscribe: number[]; + used_count: number; + enable: boolean; + created_at: number; + updated_at: number; + }; + type CurrencyConfig = { currency_unit: string; currency_symbol: string; + access_key: string; + }; + + type Document = { + id: number; + title: string; + content: string; + tags: string[]; + show: boolean; + created_at: number; + updated_at: number; + }; + + type EmailSmtpConfig = { + email_smtp_host: string; + email_smtp_port: number; + email_smtp_user: string; + email_smtp_pass: string; + email_smtp_from: string; + email_smtp_ssl: boolean; + verify_email_template: string; + maintenance_email_template: string; + expiration_email_template: string; + }; + + type Follow = { + id: number; + ticket_id: number; + from: string; + type: number; + content: string; + created_at: number; }; type GetGlobalConfigResponse = { @@ -25,23 +100,104 @@ declare namespace API { subscribe: SubscribeConfig; }; + type GetStatResponse = { + user: number; + node: number; + country: number; + }; + + type GetSubscriptionResponse = { + list: Subscribe[]; + }; + type GetTosResponse = { tos_content: string; }; type InviteConfig = { forced_invite: boolean; + referral_percentage: number; + only_first_purchase: boolean; }; type LoginResponse = { token: string; }; + type NodeConfig = { + node_secret: string; + node_pull_interval: number; + node_push_interval: number; + }; + + type Order = { + id: number; + user_id: number; + order_no: string; + type: number; + quantity: number; + price: number; + amount: number; + discount: number; + coupon: string; + coupon_discount: number; + method: string; + fee_amount: number; + trade_no: string; + status: number; + subscribe_id: number; + created_at: number; + updated_at: number; + }; + + type OrderDetail = { + id: number; + user_id: number; + order_no: string; + type: number; + quantity: number; + price: number; + amount: number; + discount: number; + coupon: string; + coupon_discount: number; + method: string; + fee_amount: number; + trade_no: string; + status: number; + subscribe_id: number; + subscribe: Subscribe; + created_at: number; + updated_at: number; + }; + + type PaymentConfig = { + id: number; + name: string; + mark: string; + icon?: string; + domain?: string; + config: Record; + fee_mode: number; + fee_percent?: number; + fee_amount?: number; + enable: boolean; + }; + + type Push = { + push_at: number; + count: number; + }; + type RegisterConfig = { stop_register: boolean; + enable_trial: boolean; enable_email_verify: boolean; enable_email_domain_suffix: boolean; email_domain_suffix_list: string; + enable_ip_register_limit: boolean; + ip_register_limit: number; + ip_register_limit_duration: number; }; type ResetPasswordRequest = { @@ -69,6 +225,40 @@ declare namespace API { status: boolean; }; + type Server = { + id: number; + name: string; + server_addr: string; + speed_limit: number; + traffic_ratio: number; + groupId: number; + protocol: string; + enable: boolean; + vmess?: Vmess; + vless?: Vless; + trojan?: Trojan; + shadowsocks?: Shadowsocks; + created_at: number; + updated_at: number; + last: Push; + }; + + type ServerGroup = { + id: number; + name: string; + description: string; + created_at: number; + updated_at: number; + }; + + type Shadowsocks = { + method: string; + port: number; + enable_relay: boolean; + relay_host: string; + relay_port: number; + }; + type SiteConfig = { host: string; site_name: string; @@ -76,6 +266,27 @@ declare namespace API { site_logo: string; }; + type Subscribe = { + id: number; + name: string; + description: string; + unit_price: number; + discount: SubscribeDiscount[]; + replacement: number; + inventory: number; + traffic: number; + speed_limit: number; + device_limit: number; + quota: number; + group_id: number; + server_group: number[]; + server: number[]; + show: boolean; + sell: boolean; + created_at: number; + updated_at: number; + }; + type SubscribeConfig = { single_model: boolean; subscribe_path: string; @@ -83,6 +294,96 @@ declare namespace API { pan_domain: boolean; }; + type SubscribeDiscount = { + months: number; + discount: number; + }; + + type SubscribeGroup = { + id: number; + name: string; + description: string; + created_at: number; + updated_at: number; + }; + + type SubscribeType = { + subscribe_types: string[]; + }; + + type TelegramConfig = { + telegram_bot_token: string; + telegram_group_url: string; + telegram_notify: boolean; + }; + + type Ticket = { + id: number; + title: string; + description: string; + user_id: number; + follow?: Follow[]; + status: number; + created_at: number; + updated_at: number; + }; + + type TosConfig = { + tos_content: string; + }; + + type Trojan = { + network: string; + port: number; + host: string; + sni: string; + allow_insecure: boolean; + transport: Record; + enable_relay: boolean; + relay_host: string; + relay_port: number; + }; + + type User = { + id: number; + email: string; + avatar: string; + balance: number; + telegram: number; + refer_code: string; + referer_id: number; + enable: boolean; + is_admin?: boolean; + valid_email: boolean; + enable_email_notify: boolean; + enable_telegram_notify: boolean; + enable_balance_notify: boolean; + enable_login_notify: boolean; + enable_subscribe_notify: boolean; + enable_trade_notify: boolean; + created_at: number; + updated_at: number; + deleted_at?: number; + is_del?: boolean; + }; + + type UserAffiliate = { + email: string; + avatar: string; + registered_at: number; + enable: boolean; + }; + + type UserBalanceLog = { + id: number; + user_id: number; + amount: number; + type: number; + order_id: number; + balance: number; + created_at: number; + }; + type UserLoginRequest = { email: string; password: string; @@ -97,10 +398,60 @@ declare namespace API { cf_token?: string; }; + type UserSubscribe = { + id: number; + user_id: number; + order_id: number; + subscribe_id: number; + subscribe: Subscribe; + start_time: number; + expire_time: number; + traffic: number; + download: number; + upload: number; + mark: string; + status: number; + created_at: number; + updated_at: number; + }; + type VeifyConfig = { turnstile_site_key: string; enable_login_verify: boolean; enable_register_verify: boolean; enable_reset_password_verify: boolean; }; + + type VerifyConfig = { + turnstile_site_key: string; + turnstile_secret: string; + enable_login_verify: boolean; + enable_register_verify: boolean; + enable_reset_password_verify: boolean; + }; + + type Vless = { + host: string; + port: number; + network: string; + transport: Record; + security: string; + security_config: Record; + xtls: string; + enable_relay: boolean; + relay_host: string; + relay_port: number; + }; + + type Vmess = { + host: string; + port: number; + enable_tls: boolean; + tls_config: Record; + network: string; + transport: Record; + enable_relay: boolean; + relay_host: string; + relay_port: number; + }; } diff --git a/apps/user/services/user/document.ts b/apps/user/services/user/document.ts index c1a3dd3..b07007a 100644 --- a/apps/user/services/user/document.ts +++ b/apps/user/services/user/document.ts @@ -8,7 +8,7 @@ export async function queryDocumentDetail( params: API.QueryDocumentDetailParams, options?: { [key: string]: any }, ) { - return request('/v1/public/document/detail', { + return request('/v1/public/document/detail', { method: 'GET', params: { ...params, diff --git a/apps/user/services/user/order.ts b/apps/user/services/user/order.ts index ee57044..59db689 100644 --- a/apps/user/services/user/order.ts +++ b/apps/user/services/user/order.ts @@ -35,7 +35,7 @@ export async function queryOrderDetail( params: API.QueryOrderDetailParams, options?: { [key: string]: any }, ) { - return request('/v1/public/order/detail', { + return request('/v1/public/order/detail', { method: 'GET', params: { ...params, diff --git a/apps/user/services/user/subscribe.ts b/apps/user/services/user/subscribe.ts index da84762..52f0c9a 100644 --- a/apps/user/services/user/subscribe.ts +++ b/apps/user/services/user/subscribe.ts @@ -4,7 +4,7 @@ import request from '@/utils/request'; /** Get application config GET /v1/public/subscribe/application/config */ export async function queryApplicationConfig(options?: { [key: string]: any }) { - return request( + return request( '/v1/public/subscribe/application/config', { method: 'GET', diff --git a/apps/user/services/user/ticket.ts b/apps/user/services/user/ticket.ts index 3f288cb..98be1ab 100644 --- a/apps/user/services/user/ticket.ts +++ b/apps/user/services/user/ticket.ts @@ -38,7 +38,7 @@ export async function getUserTicketDetails( params: API.GetUserTicketDetailsParams, options?: { [key: string]: any }, ) { - return request('/v1/public/ticket/detail', { + return request('/v1/public/ticket/detail', { method: 'GET', params: { ...params, diff --git a/apps/user/services/user/typings.d.ts b/apps/user/services/user/typings.d.ts index 2119086..8ce3c26 100644 --- a/apps/user/services/user/typings.d.ts +++ b/apps/user/services/user/typings.d.ts @@ -1,13 +1,14 @@ declare namespace API { - type AnnouncementDetails = { + type Announcement = { id: number; title: string; content: string; + enable: boolean; created_at: number; updated_at: number; }; - type ApplicationConfig = { + type Application = { id: number; name: string; platform: string; @@ -16,6 +17,14 @@ declare namespace API { url: string; }; + type ApplicationResponse = { + windows: Application[]; + mac: Application[]; + linux: Application[]; + android: Application[]; + ios: Application[]; + }; + type CheckoutOrderRequest = { orderNo: string; }; @@ -30,6 +39,23 @@ declare namespace API { orderNo: string; }; + type Coupon = { + id: number; + name: string; + code: string; + count: number; + type: number; + discount: number; + start_time: number; + expire_time: number; + user_limit: number; + subscribe: number[]; + used_count: number; + enable: boolean; + created_at: number; + updated_at: number; + }; + type CreateUserTicketFollowRequest = { ticket_id: number; from: string; @@ -42,24 +68,45 @@ declare namespace API { description: string; }; - type DocumentDetail = { + type CurrencyConfig = { + currency_unit: string; + currency_symbol: string; + access_key: string; + }; + + type Document = { id: number; title: string; content: string; tags: string[]; + show: boolean; created_at: number; updated_at: number; }; - type DocumentItem = { + type EmailSmtpConfig = { + email_smtp_host: string; + email_smtp_port: number; + email_smtp_user: string; + email_smtp_pass: string; + email_smtp_from: string; + email_smtp_ssl: boolean; + verify_email_template: string; + maintenance_email_template: string; + expiration_email_template: string; + }; + + type Follow = { id: number; - title: string; - tags: string[]; - updated_at: number; + ticket_id: number; + from: string; + type: number; + content: string; + created_at: number; }; type GetAvailablePaymentMethodsResponse = { - list: PaymentItem[]; + list: PaymentConfig[]; }; type GetUserTicketDetailRequest = { @@ -86,12 +133,25 @@ declare namespace API { type GetUserTicketListResponse = { total: number; - list: UserTicket[]; + list: Ticket[]; }; - type OrderDetails = { + type InviteConfig = { + forced_invite: boolean; + referral_percentage: number; + only_first_purchase: boolean; + }; + + type NodeConfig = { + node_secret: string; + node_pull_interval: number; + node_push_interval: number; + }; + + type Order = { id: number; - orderNo: string; + user_id: number; + order_no: string; type: number; quantity: number; price: number; @@ -104,19 +164,41 @@ declare namespace API { trade_no: string; status: number; subscribe_id: number; - subscribe: SubscribeInfo; created_at: number; + updated_at: number; }; - type PaymentItem = { + type OrderDetail = { + id: number; + user_id: number; + order_no: string; + type: number; + quantity: number; + price: number; + amount: number; + discount: number; + coupon: string; + coupon_discount: number; + method: string; + fee_amount: number; + trade_no: string; + status: number; + subscribe_id: number; + subscribe: Subscribe; + created_at: number; + updated_at: number; + }; + + type PaymentConfig = { id: number; name: string; mark: string; - icon: string; - domain: string; + icon?: string; + domain?: string; + config: Record; fee_mode: number; - fee_percent: number; - fee_amount: number; + fee_percent?: number; + fee_amount?: number; enable: boolean; }; @@ -144,6 +226,11 @@ declare namespace API { order_no: string; }; + type Push = { + push_at: number; + count: number; + }; + type QueryAnnouncementParams = { page: number; size: number; @@ -156,15 +243,7 @@ declare namespace API { type QueryAnnouncementResponse = { total: number; - announcements: AnnouncementDetails[]; - }; - - type QueryApplicationConfigResponse = { - windows: ApplicationConfig[]; - mac: ApplicationConfig[]; - linux: ApplicationConfig[]; - android: ApplicationConfig[]; - ios: ApplicationConfig[]; + announcements: Announcement[]; }; type QueryDocumentDetailParams = { @@ -177,7 +256,7 @@ declare namespace API { type QueryDocumentListResponse = { total: number; - list: DocumentItem[]; + list: Document[]; }; type QueryOrderDetailParams = { @@ -200,16 +279,16 @@ declare namespace API { type QueryOrderListResponse = { total: number; - list: OrderDetails[]; + list: OrderDetail[]; }; type QuerySubscribeGroupListResponse = { - list: UserSubscribeGroupDetails[]; + list: SubscribeGroup[]; total: number; }; type QuerySubscribeListResponse = { - list: SubscribeDetails[]; + list: Subscribe[]; total: number; }; @@ -238,6 +317,17 @@ declare namespace API { order_no: string; }; + type RegisterConfig = { + stop_register: boolean; + enable_trial: boolean; + enable_email_verify: boolean; + enable_email_domain_suffix: boolean; + email_domain_suffix_list: string; + enable_ip_register_limit: boolean; + ip_register_limit: number; + ip_register_limit_duration: number; + }; + type RenewalOrderRequest = { subscribe_id: number; quantity: number; @@ -269,66 +359,129 @@ declare namespace API { data?: Record; }; + type Server = { + id: number; + name: string; + server_addr: string; + speed_limit: number; + traffic_ratio: number; + groupId: number; + protocol: string; + enable: boolean; + vmess?: Vmess; + vless?: Vless; + trojan?: Trojan; + shadowsocks?: Shadowsocks; + created_at: number; + updated_at: number; + last: Push; + }; + + type ServerGroup = { + id: number; + name: string; + description: string; + created_at: number; + updated_at: number; + }; + + type Shadowsocks = { + method: string; + port: number; + enable_relay: boolean; + relay_host: string; + relay_port: number; + }; + + type SiteConfig = { + host: string; + site_name: string; + site_desc: string; + site_logo: string; + }; + type StripePayment = { method: string; client_secret: string; publishable_key: string; }; - type SubscribeDetails = { + type Subscribe = { id: number; name: string; description: string; unit_price: number; - discount: UserSubscribeDiscount[]; + discount: SubscribeDiscount[]; replacement: number; inventory: number; traffic: number; - group_id: number; speed_limit: number; device_limit: number; quota: number; + group_id: number; + server_group: number[]; + server: number[]; show: boolean; sell: boolean; + created_at: number; + updated_at: number; }; - type SubscribeDiscountInfo = { + type SubscribeConfig = { + single_model: boolean; + subscribe_path: string; + subscribe_domain: string; + pan_domain: boolean; + }; + + type SubscribeDiscount = { months: number; discount: number; }; - type SubscribeInfo = { + type SubscribeGroup = { id: number; name: string; description: string; - discount: string; - unit_price: number; - replacement: number; - inventory: number; - traffic: number; - group_id: number; - speed_limit: number; - device_limit: number; - quota: number; - show: boolean; - sell: boolean; + created_at: number; + updated_at: number; }; - type SubscribeItem = { + type SubscribeType = { + subscribe_types: string[]; + }; + + type TelegramConfig = { + telegram_bot_token: string; + telegram_group_url: string; + telegram_notify: boolean; + }; + + type Ticket = { id: number; - name: string; + title: string; description: string; - discount: string; - unit_price: number; - replacement: number; - inventory: number; - traffic: number; - group_id: number; - speed_limit: number; - device_limit: number; - quota: number; - show: boolean; - sell: boolean; + user_id: number; + follow?: Follow[]; + status: number; + created_at: number; + updated_at: number; + }; + + type TosConfig = { + tos_content: string; + }; + + type Trojan = { + network: string; + port: number; + host: string; + sni: string; + allow_insecure: boolean; + transport: Record; + enable_relay: boolean; + relay_host: string; + relay_port: number; }; type UpdateUserNotifyRequest = { @@ -353,6 +506,29 @@ declare namespace API { status: number; }; + type User = { + id: number; + email: string; + avatar: string; + balance: number; + telegram: number; + refer_code: string; + referer_id: number; + enable: boolean; + is_admin?: boolean; + valid_email: boolean; + enable_email_notify: boolean; + enable_telegram_notify: boolean; + enable_balance_notify: boolean; + enable_login_notify: boolean; + enable_subscribe_notify: boolean; + enable_trade_notify: boolean; + created_at: number; + updated_at: number; + deleted_at?: number; + is_del?: boolean; + }; + type UserAffiliate = { email: string; avatar: string; @@ -370,41 +546,12 @@ declare namespace API { created_at: number; }; - type UserFollow = { - id: number; - ticket_id: number; - from: string; - type: number; - content: string; - created_at: number; - }; - - type UserInfo = { - id: number; - email: string; - avatar: string; - balance: number; - telegram: number; - refer_code: string; - referer_id: number; - enable: boolean; - valid_email: boolean; - enable_email_notify: boolean; - enable_telegram_notify: boolean; - enable_balance_notify: boolean; - enable_login_notify: boolean; - enable_subscribe_notify: boolean; - enable_trade_notify: boolean; - created_at: number; - updated_at: number; - }; - type UserSubscribe = { id: number; user_id: number; order_id: number; subscribe_id: number; - subscribe: SubscribeItem; + subscribe: Subscribe; start_time: number; expire_time: number; traffic: number; @@ -416,25 +563,36 @@ declare namespace API { updated_at: number; }; - type UserSubscribeDiscount = { - months: number; - discount: number; + type VerifyConfig = { + turnstile_site_key: string; + turnstile_secret: string; + enable_login_verify: boolean; + enable_register_verify: boolean; + enable_reset_password_verify: boolean; }; - type UserSubscribeGroupDetails = { - id: number; - name: string; - description: string; + type Vless = { + host: string; + port: number; + network: string; + transport: Record; + security: string; + security_config: Record; + xtls: string; + enable_relay: boolean; + relay_host: string; + relay_port: number; }; - type UserTicket = { - id: number; - title: string; - description: string; - user_id: number; - follow?: UserFollow[]; - status: number; - created_at: number; - updated_at: number; + type Vmess = { + host: string; + port: number; + enable_tls: boolean; + tls_config: Record; + network: string; + transport: Record; + enable_relay: boolean; + relay_host: string; + relay_port: number; }; } diff --git a/apps/user/services/user/user.ts b/apps/user/services/user/user.ts index 7232e33..ecc821d 100644 --- a/apps/user/services/user/user.ts +++ b/apps/user/services/user/user.ts @@ -26,7 +26,7 @@ export async function queryUserBalanceLog(options?: { [key: string]: any }) { /** Query User Info GET /v1/public/user/info */ export async function queryUserInfo(options?: { [key: string]: any }) { - return request('/v1/public/user/info', { + return request('/v1/public/user/info', { method: 'GET', ...(options || {}), });