diff --git a/src/components/install-commands.tsx b/src/components/install-commands.tsx index 012a189..a634e6f 100644 --- a/src/components/install-commands.tsx +++ b/src/components/install-commands.tsx @@ -8,7 +8,7 @@ import { import { useAuth } from "@/hooks/useAuth" import useSettings from "@/hooks/useSetting" import { copyToClipboard } from "@/lib/utils" -import { ModelConfig, ModelProfile } from "@/types" +import { ModelProfile, ModelSetting } from "@/types" import i18next from "i18next" import { Check, Clipboard } from "lucide-react" import { forwardRef, useState } from "react" @@ -88,7 +88,7 @@ export const InstallCommandsMenu = forwardRef((p const generateCommand = ( type: number, - { agent_secret_key, install_host, tls }: ModelConfig, + { agent_secret_key, install_host, tls }: ModelSetting, { agent_secret, role }: ModelProfile, ) => { if (!install_host) throw new Error(i18next.t("Results.InstallHostRequired")) diff --git a/src/hooks/useSetting.tsx b/src/hooks/useSetting.tsx index 6a2001e..cebccef 100644 --- a/src/hooks/useSetting.tsx +++ b/src/hooks/useSetting.tsx @@ -1,10 +1,7 @@ import { swrFetcher } from "@/api/api" -import { GithubComNezhahqNezhaModelSettingResponseModelConfig } from "@/types" +import { ModelSettingResponse } from "@/types" import useSWR from "swr" export default function useSetting() { - return useSWR( - "/api/v1/setting", - swrFetcher, - ) + return useSWR("/api/v1/setting", swrFetcher) } diff --git a/src/types/api.ts b/src/types/api.ts index 186b146..1d79661 100644 --- a/src/types/api.ts +++ b/src/types/api.ts @@ -93,12 +93,6 @@ export interface GithubComNezhahqNezhaModelCommonResponseArrayUint64 { success: boolean } -export interface GithubComNezhahqNezhaModelCommonResponseGithubComNezhahqNezhaModelSettingResponseModelConfig { - data: GithubComNezhahqNezhaModelSettingResponseModelConfig - error: string - success: boolean -} - export interface GithubComNezhahqNezhaModelCommonResponseModelLoginResponse { data: ModelLoginResponse error: string @@ -123,6 +117,12 @@ export interface GithubComNezhahqNezhaModelCommonResponseModelServiceResponse { success: boolean } +export interface GithubComNezhahqNezhaModelCommonResponseModelSettingResponse { + data: ModelSettingResponse + error: string + success: boolean +} + export interface GithubComNezhahqNezhaModelCommonResponseString { data: string error: string @@ -147,12 +147,6 @@ export interface GithubComNezhahqNezhaModelPaginatedResponseArrayModelWAFApiMock success: boolean } -export interface GithubComNezhahqNezhaModelSettingResponseModelConfig { - config: ModelConfig - frontend_templates: ModelFrontendTemplate[] - version: string -} - export interface GithubComNezhahqNezhaModelValueArrayModelOnlineUser { pagination: ModelPagination value: ModelOnlineUser[] @@ -194,47 +188,6 @@ export interface ModelAlertRuleForm { trigger_mode: number } -export interface ModelConfig { - admin_template: string - agent_secret_key: string - avg_ping_count: number - /** 覆盖范围(0:提醒未被 IgnoredIPNotification 包含的所有服务器; 1:仅提醒被 IgnoredIPNotification 包含的服务器;) */ - cover: number - custom_code: string - custom_code_dashboard: string - /** debug模式开关 */ - debug: boolean - dns_servers: string - /** IP变更提醒 */ - enable_ip_change_notification: boolean - /** 通知信息IP不打码 */ - enable_plain_ip_in_notification: boolean - /** 强制要求认证 */ - force_auth: boolean - /** 特定服务器IP(多个服务器用逗号分隔) */ - ignored_ip_notification: string - /** [ServerID] -> bool(值为true代表当前ServerID在特定服务器列表内) */ - ignored_ip_notification_server_ids: Record - install_host: string - ip_change_notification_group_id: number - jwt_secret_key: string - /** 系统语言,默认 zh_CN */ - language: string - listen_host: string - listen_port: number - /** 时区,默认为 Asia/Shanghai */ - location: string - /** oauth2 配置 */ - oauth2: Record - /** oauth2 供应商列表,无需配置,自动生成 */ - oauth2_providers: string[] - /** 真实IP */ - real_ip_header: string - site_name: string - tls: boolean - user_template: string -} - export interface ModelCreateFMResponse { session_id: string } @@ -463,20 +416,6 @@ export interface ModelNotificationGroupResponseItem { notifications: number[] } -export interface ModelOauth2Config { - client_id: string - client_secret: string - endpoint: ModelOauth2Endpoint - scopes: string[] - user_id_path: string - user_info_url: string -} - -export interface ModelOauth2Endpoint { - auth_url: string - token_url: string -} - export interface ModelOauth2LoginResponse { redirect: string } @@ -690,6 +629,43 @@ export interface ModelServiceResponseItem { up: number[] } +export interface ModelSetting { + admin_template: string + agent_secret_key: string + avg_ping_count: number + /** 覆盖范围(0:提醒未被 IgnoredIPNotification 包含的所有服务器; 1:仅提醒被 IgnoredIPNotification 包含的服务器;) */ + cover: number + custom_code: string + custom_code_dashboard: string + /** debug模式开关 */ + debug: boolean + dns_servers: string + /** IP变更提醒 */ + enable_ip_change_notification: boolean + /** 通知信息IP不打码 */ + enable_plain_ip_in_notification: boolean + /** 强制要求认证 */ + force_auth: boolean + /** 特定服务器IP(多个服务器用逗号分隔) */ + ignored_ip_notification: string + /** [ServerID] -> bool(值为true代表当前ServerID在特定服务器列表内) */ + ignored_ip_notification_server_ids: Record + install_host: string + ip_change_notification_group_id: number + /** 系统语言,默认 zh_CN */ + language: string + /** 时区,默认为 Asia/Shanghai */ + location: string + /** oauth2 供应商列表,无需配置,自动生成 */ + oauth2_providers: string[] + /** 真实IP */ + real_ip_header: string + site_name: string + /** 用于前端判断生成的安装命令是否启用 TLS */ + tls: boolean + user_template: string +} + export interface ModelSettingForm { cover: number custom_code?: string @@ -711,6 +687,12 @@ export interface ModelSettingForm { user_template?: string } +export interface ModelSettingResponse { + config: ModelSetting + frontend_templates: ModelFrontendTemplate[] + version: string +} + export interface ModelStreamServer { country_code: string /** 展示排序,越大越靠前 */