diff --git a/apps/admin/app/(auth)/email/login-form.tsx b/apps/admin/app/(auth)/email/login-form.tsx index 939dd46..fd510df 100644 --- a/apps/admin/app/(auth)/email/login-form.tsx +++ b/apps/admin/app/(auth)/email/login-form.tsx @@ -1,9 +1,9 @@ import useGlobalStore from '@/config/use-global'; import { zodResolver } from '@hookform/resolvers/zod'; -import { Icon } from '@iconify/react/dist/iconify.js'; import { Button } from '@workspace/ui/components/button'; import { Form, FormControl, FormField, FormItem, FormMessage } from '@workspace/ui/components/form'; import { Input } from '@workspace/ui/components/input'; +import { Icon } from '@workspace/ui/custom-components/icon'; import { useTranslations } from 'next-intl'; import { Dispatch, SetStateAction } from 'react'; import { useForm } from 'react-hook-form'; @@ -60,12 +60,7 @@ export default function LoginForm({ render={({ field }) => ( - + diff --git a/apps/admin/app/(auth)/email/register-form.tsx b/apps/admin/app/(auth)/email/register-form.tsx index 7650a15..9ae0c9c 100644 --- a/apps/admin/app/(auth)/email/register-form.tsx +++ b/apps/admin/app/(auth)/email/register-form.tsx @@ -1,9 +1,9 @@ import useGlobalStore from '@/config/use-global'; import { zodResolver } from '@hookform/resolvers/zod'; -import { Icon } from '@iconify/react/dist/iconify.js'; import { Button } from '@workspace/ui/components/button'; import { Form, FormControl, FormField, FormItem, FormMessage } from '@workspace/ui/components/form'; import { Input } from '@workspace/ui/components/input'; +import { Icon } from '@workspace/ui/custom-components/icon'; import { Markdown } from '@workspace/ui/custom-components/markdown'; import { useTranslations } from 'next-intl'; import { Dispatch, SetStateAction } from 'react'; @@ -102,12 +102,7 @@ export default function RegisterForm({ render={({ field }) => ( - + @@ -119,12 +114,7 @@ export default function RegisterForm({ render={({ field }) => ( - + @@ -139,7 +129,6 @@ export default function RegisterForm({
( - + @@ -86,7 +81,6 @@ export default function ResetForm({
('/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 05010d8..057602e 100644 --- a/apps/admin/services/admin/index.ts +++ b/apps/admin/services/admin/index.ts @@ -3,6 +3,7 @@ // 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'; @@ -17,6 +18,7 @@ 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 cf52d15..1ab39de 100644 --- a/apps/admin/services/admin/system.ts +++ b/apps/admin/services/admin/system.ts @@ -58,6 +58,51 @@ export async function deleteApplication( }); } +/** Update application version PUT /v1/admin/system/application_version */ +export async function updateApplicationVersion( + body: API.UpdateApplicationVersionRequest, + options?: { [key: string]: any }, +) { + return request('/v1/admin/system/application_version', { + method: 'PUT', + headers: { + 'Content-Type': 'application/json', + }, + data: body, + ...(options || {}), + }); +} + +/** Create application version POST /v1/admin/system/application_version */ +export async function createApplicationVersion( + body: API.CreateApplicationVersionRequest, + options?: { [key: string]: any }, +) { + return request('/v1/admin/system/application_version', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + data: body, + ...(options || {}), + }); +} + +/** Delete application DELETE /v1/admin/system/application_version */ +export async function deleteApplicationVersion( + body: API.DeleteApplicationVersionRequest, + options?: { [key: string]: any }, +) { + return request('/v1/admin/system/application_version', { + method: 'DELETE', + headers: { + 'Content-Type': 'application/json', + }, + data: body, + ...(options || {}), + }); +} + /** Get Currency Config GET /v1/admin/system/currency_config */ export async function getCurrencyConfig(options?: { [key: string]: any }) { return request('/v1/admin/system/currency_config', { diff --git a/apps/admin/services/admin/typings.d.ts b/apps/admin/services/admin/typings.d.ts index 4e704b8..a9d5286 100644 --- a/apps/admin/services/admin/typings.d.ts +++ b/apps/admin/services/admin/typings.d.ts @@ -18,21 +18,59 @@ 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; - name: string; - platform: string; - subscribe_type: string; icon: string; - url: string; + name: string; + description: string; + subscribe_type: string; + }; + + type ApplicationPlatform = { + ios?: ApplicationVersion[]; + mac?: ApplicationVersion[]; + linux?: ApplicationVersion[]; + android?: ApplicationVersion[]; + windows?: ApplicationVersion[]; + harmony?: ApplicationVersion[]; }; type ApplicationResponse = { - windows: Application[]; - mac: Application[]; - linux: Application[]; - android: Application[]; - ios: Application[]; + applications: ApplicationResponseInfo[]; + }; + + type ApplicationResponseInfo = { + id: number; + name: string; + icon: string; + description: string; + subscription_protocol: string; + platform: ApplicationPlatform; + }; + + type ApplicationVersion = { + id: number; + url: string; + version: string; + description: string; + is_default: boolean; + }; + + type AppVersion = { + id: number; + os: string; + version: string; + download_url: string; + describe: string; + default_version: boolean; }; type AuthConfig = { @@ -92,11 +130,26 @@ declare namespace API { }; type CreateApplicationRequest = { - name: string; - platform: 'windows' | 'mac' | 'linux' | 'android' | 'ios'; - subscribe_type: string; icon: string; + name: string; + description: string; + subscribe_type: string; + }; + + type CreateApplicationVersionRequest = { url: string; + version: string; + description: string; + platform: 'windows' | 'mac' | 'linux' | 'android' | 'ios' | 'harmony'; + is_default: boolean; + application_id: number; + }; + + type CreateAppVersionRequest = { + os: string; + version: string; + download_url: string; + describe: string; }; type CreateCouponRequest = { @@ -214,6 +267,10 @@ declare namespace API { currency_symbol: string; }; + type DefaultAppVersionRequest = { + id: number; + }; + type DeleteAnnouncementRequest = { id: number; }; @@ -222,6 +279,14 @@ declare namespace API { id: number; }; + type DeleteApplicationVersionRequest = { + id: number; + }; + + type DeleteAppVersionRequest = { + id: number; + }; + type DeleteCouponRequest = { id: number; }; @@ -333,6 +398,23 @@ 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; @@ -984,10 +1066,28 @@ declare namespace API { type UpdateApplicationRequest = { id: number; - name: string; - subscribe_type: string; icon: string; + name: string; + description: string; + subscribe_type: string; + }; + + type UpdateApplicationVersionRequest = { + id: number; url: string; + version: string; + description: string; + platform: 'windows' | 'mac' | 'linux' | 'android' | 'ios' | 'harmony'; + is_default: boolean; + application_id: number; + }; + + type UpdateAppVersionRequest = { + id: number; + os: string; + version: string; + download_url: string; + describe: string; }; type UpdateCouponRequest = { diff --git a/apps/admin/services/common/common.ts b/apps/admin/services/common/common.ts index 1eda615..b86d7bb 100644 --- a/apps/admin/services/common/common.ts +++ b/apps/admin/services/common/common.ts @@ -2,6 +2,14 @@ /* 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', { + method: 'GET', + ...(options || {}), + }); +} + /** Get verification code POST /v1/common/send_code */ export async function sendEmailCode(body: API.SendCodeRequest, options?: { [key: string]: any }) { return request('/v1/common/send_code', { diff --git a/apps/admin/services/common/typings.d.ts b/apps/admin/services/common/typings.d.ts index f4ae1dc..29599d5 100644 --- a/apps/admin/services/common/typings.d.ts +++ b/apps/admin/services/common/typings.d.ts @@ -10,21 +10,59 @@ 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; - name: string; - platform: string; - subscribe_type: string; icon: string; - url: string; + name: string; + description: string; + subscribe_type: string; + }; + + type ApplicationPlatform = { + ios?: ApplicationVersion[]; + mac?: ApplicationVersion[]; + linux?: ApplicationVersion[]; + android?: ApplicationVersion[]; + windows?: ApplicationVersion[]; + harmony?: ApplicationVersion[]; }; type ApplicationResponse = { - windows: Application[]; - mac: Application[]; - linux: Application[]; - android: Application[]; - ios: Application[]; + applications: ApplicationResponseInfo[]; + }; + + type ApplicationResponseInfo = { + id: number; + name: string; + icon: string; + description: string; + subscription_protocol: string; + platform: ApplicationPlatform; + }; + + type ApplicationVersion = { + id: number; + url: string; + version: string; + description: string; + is_default: boolean; + }; + + type AppVersion = { + id: number; + os: string; + version: string; + download_url: string; + describe: string; + default_version: boolean; }; type AuthConfig = { @@ -113,6 +151,11 @@ declare namespace API { created_at: number; }; + type GetAppInfoResponse = { + config: AppConfig; + versions: AppVersion[]; + }; + type GetGlobalConfigResponse = { site: SiteConfig; verify: VeifyConfig; diff --git a/apps/user/app/(main)/(user)/dashboard/content.tsx b/apps/user/app/(main)/(user)/dashboard/content.tsx index fe318ae..edf27a0 100644 --- a/apps/user/app/(main)/(user)/dashboard/content.tsx +++ b/apps/user/app/(main)/(user)/dashboard/content.tsx @@ -9,7 +9,6 @@ import { getStat } from '@/services/common/common'; import { queryApplicationConfig } from '@/services/user/subscribe'; import { queryUserSubscribe } from '@/services/user/user'; import { getPlatform } from '@/utils/common'; -import { Icon } from '@iconify/react'; import { useQuery } from '@tanstack/react-query'; import { Accordion, @@ -32,6 +31,7 @@ import { Button } from '@workspace/ui/components/button'; import { Card, CardContent, CardHeader, CardTitle } from '@workspace/ui/components/card'; import { Separator } from '@workspace/ui/components/separator'; import { Tabs, TabsList, TabsTrigger } from '@workspace/ui/components/tabs'; +import { Icon } from '@workspace/ui/custom-components/icon'; import { isBrowser } from '@workspace/ui/utils'; import { differenceInDays } from 'date-fns'; import { useTranslations } from 'next-intl'; diff --git a/apps/user/app/(main)/(user)/payment/page.tsx b/apps/user/app/(main)/(user)/payment/page.tsx index c4b01ad..5238aaa 100644 --- a/apps/user/app/(main)/(user)/payment/page.tsx +++ b/apps/user/app/(main)/(user)/payment/page.tsx @@ -5,7 +5,6 @@ import { SubscribeBilling } from '@/components/subscribe/billing'; import { SubscribeDetail } from '@/components/subscribe/detail'; import useGlobalStore from '@/config/use-global'; import { checkoutOrder, queryOrderDetail } from '@/services/user/order'; -import { Icon } from '@iconify/react'; import { useQuery } from '@tanstack/react-query'; import { Badge } from '@workspace/ui/components/badge'; import { Button } from '@workspace/ui/components/button'; @@ -17,6 +16,7 @@ import { CardTitle, } from '@workspace/ui/components/card'; import { Separator } from '@workspace/ui/components/separator'; +import { Icon } from '@workspace/ui/custom-components/icon'; import { formatDate } from '@workspace/ui/utils'; import { useCountDown } from 'ahooks'; import { addMinutes, format } from 'date-fns'; diff --git a/apps/user/app/(main)/(user)/sidebar-left.tsx b/apps/user/app/(main)/(user)/sidebar-left.tsx index 17b9802..25a1674 100644 --- a/apps/user/app/(main)/(user)/sidebar-left.tsx +++ b/apps/user/app/(main)/(user)/sidebar-left.tsx @@ -1,6 +1,5 @@ 'use client'; import { navs } from '@/config/navs'; -import { Icon } from '@iconify/react'; import { Sidebar, SidebarContent, @@ -11,6 +10,7 @@ import { SidebarMenuButton, SidebarMenuItem, } from '@workspace/ui/components/sidebar'; +import { Icon } from '@workspace/ui/custom-components/icon'; import { useTranslations } from 'next-intl'; import Link from 'next/link'; import { usePathname } from 'next/navigation'; diff --git a/apps/user/app/(main)/(user)/sidebar-right.tsx b/apps/user/app/(main)/(user)/sidebar-right.tsx index f618b5b..f834d00 100644 --- a/apps/user/app/(main)/(user)/sidebar-right.tsx +++ b/apps/user/app/(main)/(user)/sidebar-right.tsx @@ -3,7 +3,6 @@ import { Display } from '@/components/display'; import Recharge from '@/components/subscribe/recharge'; import useGlobalStore from '@/config/use-global'; -import { Icon } from '@iconify/react'; import { Button } from '@workspace/ui/components/button'; import { Card, CardContent, CardHeader, CardTitle } from '@workspace/ui/components/card'; import { Sidebar, SidebarContent } from '@workspace/ui/components/sidebar'; @@ -13,6 +12,7 @@ import { TooltipProvider, TooltipTrigger, } from '@workspace/ui/components/tooltip'; +import { Icon } from '@workspace/ui/custom-components/icon'; import { isBrowser } from '@workspace/ui/utils'; import { useTranslations } from 'next-intl'; import CopyToClipboard from 'react-copy-to-clipboard'; diff --git a/apps/user/app/(main)/(user)/subscribe/page.tsx b/apps/user/app/(main)/(user)/subscribe/page.tsx index 5000ed3..ff3bd9a 100644 --- a/apps/user/app/(main)/(user)/subscribe/page.tsx +++ b/apps/user/app/(main)/(user)/subscribe/page.tsx @@ -2,12 +2,12 @@ import { Display } from '@/components/display'; import { querySubscribeGroupList, querySubscribeList } from '@/services/user/subscribe'; -import { Icon } from '@iconify/react'; import { useQuery } from '@tanstack/react-query'; import { Button } from '@workspace/ui/components/button'; import { Card, CardContent, CardFooter, CardHeader } from '@workspace/ui/components/card'; import { Separator } from '@workspace/ui/components/separator'; import { Tabs, TabsList, TabsTrigger } from '@workspace/ui/components/tabs'; +import { Icon } from '@workspace/ui/custom-components/icon'; import { cn } from '@workspace/ui/lib/utils'; import { useTranslations } from 'next-intl'; import { useState } from 'react'; diff --git a/apps/user/app/(main)/(user)/ticket/page.tsx b/apps/user/app/(main)/(user)/ticket/page.tsx index 607e1f4..fe21356 100644 --- a/apps/user/app/(main)/(user)/ticket/page.tsx +++ b/apps/user/app/(main)/(user)/ticket/page.tsx @@ -9,7 +9,6 @@ import { getUserTicketList, updateUserTicketStatus, } from '@/services/user/ticket'; -import { Icon } from '@iconify/react'; import { useQuery } from '@tanstack/react-query'; import { Button } from '@workspace/ui/components/button'; import { @@ -41,6 +40,7 @@ import { Label } from '@workspace/ui/components/label'; import { ScrollArea } from '@workspace/ui/components/scroll-area'; import { Textarea } from '@workspace/ui/components/textarea'; import { ConfirmButton } from '@workspace/ui/custom-components/confirm-button'; +import { Icon } from '@workspace/ui/custom-components/icon'; import { cn } from '@workspace/ui/lib/utils'; import { formatDate } from '@workspace/ui/utils'; import { useTranslations } from 'next-intl'; diff --git a/apps/user/app/auth/email/login-form.tsx b/apps/user/app/auth/email/login-form.tsx index 939dd46..fd510df 100644 --- a/apps/user/app/auth/email/login-form.tsx +++ b/apps/user/app/auth/email/login-form.tsx @@ -1,9 +1,9 @@ import useGlobalStore from '@/config/use-global'; import { zodResolver } from '@hookform/resolvers/zod'; -import { Icon } from '@iconify/react/dist/iconify.js'; import { Button } from '@workspace/ui/components/button'; import { Form, FormControl, FormField, FormItem, FormMessage } from '@workspace/ui/components/form'; import { Input } from '@workspace/ui/components/input'; +import { Icon } from '@workspace/ui/custom-components/icon'; import { useTranslations } from 'next-intl'; import { Dispatch, SetStateAction } from 'react'; import { useForm } from 'react-hook-form'; @@ -60,12 +60,7 @@ export default function LoginForm({ render={({ field }) => ( - + diff --git a/apps/user/app/auth/email/register-form.tsx b/apps/user/app/auth/email/register-form.tsx index 7650a15..821d6c6 100644 --- a/apps/user/app/auth/email/register-form.tsx +++ b/apps/user/app/auth/email/register-form.tsx @@ -1,9 +1,9 @@ import useGlobalStore from '@/config/use-global'; import { zodResolver } from '@hookform/resolvers/zod'; -import { Icon } from '@iconify/react/dist/iconify.js'; import { Button } from '@workspace/ui/components/button'; import { Form, FormControl, FormField, FormItem, FormMessage } from '@workspace/ui/components/form'; import { Input } from '@workspace/ui/components/input'; +import { Icon } from '@workspace/ui/custom-components/icon'; import { Markdown } from '@workspace/ui/custom-components/markdown'; import { useTranslations } from 'next-intl'; import { Dispatch, SetStateAction } from 'react'; @@ -102,12 +102,7 @@ export default function RegisterForm({ render={({ field }) => ( - + diff --git a/apps/user/app/auth/email/reset-form.tsx b/apps/user/app/auth/email/reset-form.tsx index 4ae43f0..cf1cc0f 100644 --- a/apps/user/app/auth/email/reset-form.tsx +++ b/apps/user/app/auth/email/reset-form.tsx @@ -1,9 +1,9 @@ import useGlobalStore from '@/config/use-global'; import { zodResolver } from '@hookform/resolvers/zod'; -import { Icon } from '@iconify/react/dist/iconify.js'; import { Button } from '@workspace/ui/components/button'; import { Form, FormControl, FormField, FormItem, FormMessage } from '@workspace/ui/components/form'; import { Input } from '@workspace/ui/components/input'; +import { Icon } from '@workspace/ui/custom-components/icon'; import { useTranslations } from 'next-intl'; import { Dispatch, SetStateAction } from 'react'; import { useForm } from 'react-hook-form'; @@ -65,12 +65,7 @@ export default function ResetForm({ render={({ field }) => ( - + diff --git a/apps/user/app/auth/phone/login-form.tsx b/apps/user/app/auth/phone/login-form.tsx index e1707e8..c06d930 100644 --- a/apps/user/app/auth/phone/login-form.tsx +++ b/apps/user/app/auth/phone/login-form.tsx @@ -1,10 +1,10 @@ import useGlobalStore from '@/config/use-global'; import { zodResolver } from '@hookform/resolvers/zod'; -import { Icon } from '@iconify/react/dist/iconify.js'; import { Button } from '@workspace/ui/components/button'; import { Form, FormControl, FormField, FormItem, FormMessage } from '@workspace/ui/components/form'; import { Input } from '@workspace/ui/components/input'; import { AreaCodeSelect } from '@workspace/ui/custom-components/area-code-select'; +import { Icon } from '@workspace/ui/custom-components/icon'; import { useTranslations } from 'next-intl'; import { Dispatch, SetStateAction, useState } from 'react'; @@ -99,7 +99,6 @@ export default function LoginForm({
( - + diff --git a/apps/user/app/auth/phone/reset-form.tsx b/apps/user/app/auth/phone/reset-form.tsx index 7882420..6917d96 100644 --- a/apps/user/app/auth/phone/reset-form.tsx +++ b/apps/user/app/auth/phone/reset-form.tsx @@ -1,10 +1,10 @@ import useGlobalStore from '@/config/use-global'; import { zodResolver } from '@hookform/resolvers/zod'; -import { Icon } from '@iconify/react/dist/iconify.js'; import { Button } from '@workspace/ui/components/button'; import { Form, FormControl, FormField, FormItem, FormMessage } from '@workspace/ui/components/form'; import { Input } from '@workspace/ui/components/input'; import { AreaCodeSelect } from '@workspace/ui/custom-components/area-code-select'; +import { Icon } from '@workspace/ui/custom-components/icon'; import { useTranslations } from 'next-intl'; import { Dispatch, SetStateAction, useState } from 'react'; import { useForm } from 'react-hook-form'; @@ -97,12 +97,7 @@ export default function ResetForm({ render={({ field }) => ( - + @@ -118,7 +113,6 @@ export default function ResetForm({
('/v1/common/app/info', { + method: 'GET', + ...(options || {}), + }); +} + /** Get verification code POST /v1/common/send_code */ export async function sendEmailCode(body: API.SendCodeRequest, options?: { [key: string]: any }) { return request('/v1/common/send_code', { diff --git a/apps/user/services/common/typings.d.ts b/apps/user/services/common/typings.d.ts index f4ae1dc..29599d5 100644 --- a/apps/user/services/common/typings.d.ts +++ b/apps/user/services/common/typings.d.ts @@ -10,21 +10,59 @@ 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; - name: string; - platform: string; - subscribe_type: string; icon: string; - url: string; + name: string; + description: string; + subscribe_type: string; + }; + + type ApplicationPlatform = { + ios?: ApplicationVersion[]; + mac?: ApplicationVersion[]; + linux?: ApplicationVersion[]; + android?: ApplicationVersion[]; + windows?: ApplicationVersion[]; + harmony?: ApplicationVersion[]; }; type ApplicationResponse = { - windows: Application[]; - mac: Application[]; - linux: Application[]; - android: Application[]; - ios: Application[]; + applications: ApplicationResponseInfo[]; + }; + + type ApplicationResponseInfo = { + id: number; + name: string; + icon: string; + description: string; + subscription_protocol: string; + platform: ApplicationPlatform; + }; + + type ApplicationVersion = { + id: number; + url: string; + version: string; + description: string; + is_default: boolean; + }; + + type AppVersion = { + id: number; + os: string; + version: string; + download_url: string; + describe: string; + default_version: boolean; }; type AuthConfig = { @@ -113,6 +151,11 @@ declare namespace API { created_at: number; }; + type GetAppInfoResponse = { + config: AppConfig; + versions: AppVersion[]; + }; + type GetGlobalConfigResponse = { site: SiteConfig; verify: VeifyConfig; diff --git a/apps/user/services/user/typings.d.ts b/apps/user/services/user/typings.d.ts index d084fec..dd5b479 100644 --- a/apps/user/services/user/typings.d.ts +++ b/apps/user/services/user/typings.d.ts @@ -10,21 +10,59 @@ 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; - name: string; - platform: string; - subscribe_type: string; icon: string; - url: string; + name: string; + description: string; + subscribe_type: string; + }; + + type ApplicationPlatform = { + ios?: ApplicationVersion[]; + mac?: ApplicationVersion[]; + linux?: ApplicationVersion[]; + android?: ApplicationVersion[]; + windows?: ApplicationVersion[]; + harmony?: ApplicationVersion[]; }; type ApplicationResponse = { - windows: Application[]; - mac: Application[]; - linux: Application[]; - android: Application[]; - ios: Application[]; + applications: ApplicationResponseInfo[]; + }; + + type ApplicationResponseInfo = { + id: number; + name: string; + icon: string; + description: string; + subscription_protocol: string; + platform: ApplicationPlatform; + }; + + type ApplicationVersion = { + id: number; + url: string; + version: string; + description: string; + is_default: boolean; + }; + + type AppVersion = { + id: number; + os: string; + version: string; + download_url: string; + describe: string; + default_version: boolean; }; type AuthConfig = { diff --git a/bun.lockb b/bun.lockb index 1ef807b..059ed41 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/packages/ui/package.json b/packages/ui/package.json index 58cf795..eb51892 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -21,6 +21,10 @@ "@dnd-kit/core": "^6.3.1", "@dnd-kit/sortable": "^10.0.0", "@hookform/resolvers": "^3.10.0", + "@iconify-json/flagpack": "^1.2.2", + "@iconify-json/mdi": "^1.2.2", + "@iconify-json/uil": "^1.2.3", + "@iconify/react": "^5.2.0", "@monaco-editor/react": "^4.6.0", "@radix-ui/react-accordion": "^1.2.2", "@radix-ui/react-alert-dialog": "^1.1.4", diff --git a/packages/ui/src/custom-components/area-code-select.tsx b/packages/ui/src/custom-components/area-code-select.tsx index 4907cff..14b5bb1 100644 --- a/packages/ui/src/custom-components/area-code-select.tsx +++ b/packages/ui/src/custom-components/area-code-select.tsx @@ -1,6 +1,5 @@ 'use client'; -import { Icon } from '@iconify/react'; import { Button } from '@workspace/ui/components/button'; import { Command, @@ -11,6 +10,7 @@ import { CommandList, } from '@workspace/ui/components/command'; import { Popover, PopoverContent, PopoverTrigger } from '@workspace/ui/components/popover'; +import { Icon } from '@workspace/ui/custom-components/icon'; import { cn } from '@workspace/ui/lib/utils'; import { countries, type ICountry } from '@workspace/ui/utils/countries'; import { BoxIcon, Check, ChevronsUpDown } from 'lucide-react'; diff --git a/packages/ui/src/custom-components/dynamic-Inputs.tsx b/packages/ui/src/custom-components/dynamic-Inputs.tsx index dd705b2..522f31f 100644 --- a/packages/ui/src/custom-components/dynamic-Inputs.tsx +++ b/packages/ui/src/custom-components/dynamic-Inputs.tsx @@ -1,4 +1,6 @@ import { Button } from '@workspace/ui/components/button'; +import { Label } from '@workspace/ui/components/label.js'; +import { Switch } from '@workspace/ui/components/switch'; import { Combobox } from '@workspace/ui/custom-components/combobox'; import { EnhancedInput, EnhancedInputProps } from '@workspace/ui/custom-components/enhanced-input'; import { cn } from '@workspace/ui/lib/utils'; @@ -7,7 +9,7 @@ import { useEffect, useState } from 'react'; interface FieldConfig extends Omit { name: string; - type: 'text' | 'number' | 'select' | 'time'; + type: 'text' | 'number' | 'select' | 'time' | 'boolean'; options?: { label: string; value: string }[]; internal?: boolean; // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -18,6 +20,7 @@ interface ObjectInputProps { value: T; onChange: (value: T) => void; fields: FieldConfig[]; + className?: string; } // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -25,6 +28,7 @@ export function ObjectInput>({ value, onChange, fields, + className, }: ObjectInputProps) { const [internalState, setInternalState] = useState(value); @@ -32,7 +36,7 @@ export function ObjectInput>({ setInternalState(value); }, [value]); - const updateField = (key: keyof T, fieldValue: string | number) => { + const updateField = (key: keyof T, fieldValue: string | number | boolean) => { let updatedInternalState = { ...internalState, [key]: fieldValue }; fields.forEach((field) => { if (field.calculateValue && field.name === key) { @@ -52,28 +56,44 @@ export function ObjectInput>({ onChange(filteredValue); }; - - return ( -
- {fields.map(({ name, type, options, className, ...fieldProps }) => ( -
- {type === 'select' && options ? ( + const renderField = (field: FieldConfig) => { + switch (field.type) { + case 'select': + return ( + field.options && ( - placeholder={fieldProps.placeholder} - options={options} - value={internalState[name]} - onChange={(fieldValue) => { - updateField(name, fieldValue); - }} + placeholder={field.placeholder} + options={field.options} + value={internalState[field.name]} + onChange={(fieldValue) => updateField(field.name, fieldValue)} /> - ) : ( - updateField(name, fieldValue)} - type={type} - {...fieldProps} + ) + ); + case 'boolean': + return ( +
+ updateField(field.name, fieldValue)} /> - )} + {field.placeholder && } +
+ ); + default: + return ( + updateField(field.name, fieldValue)} + {...field} + /> + ); + } + }; + return ( +
+ {fields.map((field) => ( +
+ {renderField(field)}
))}
@@ -83,6 +103,8 @@ interface ArrayInputProps { value?: T[]; onChange: (value: T[]) => void; fields: FieldConfig[]; + isReverse?: boolean; + className?: string; } // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -90,6 +112,8 @@ export function ArrayInput>({ value = [], onChange, fields, + isReverse = false, + className, }: ArrayInputProps) { const initializeDefaultItem = (): T => fields.reduce((acc, field) => { @@ -117,7 +141,11 @@ export function ArrayInput>({ }; const createField = () => { - setDisplayItems([...displayItems, initializeDefaultItem()]); + if (isReverse) { + setDisplayItems([initializeDefaultItem(), ...displayItems]); + } else { + setDisplayItems([...displayItems, initializeDefaultItem()]); + } }; const deleteField = (index: number) => { @@ -142,6 +170,7 @@ export function ArrayInput>({ value={item} onChange={(updatedItem) => handleItemChange(index, updatedItem)} fields={fields} + className={className} />
{displayItems.length > 1 && ( @@ -155,7 +184,7 @@ export function ArrayInput>({ )} - {index === displayItems.length - 1 && ( + {(isReverse ? index === 0 : index === displayItems.length - 1) && (