mirror of
https://github.com/Buriburizaem0n/admin-frontend-domain.git
synced 2026-02-04 12:40:08 +00:00
update settings api (#121)
* update settings api * chore: auto-fix linting and formatting issues
This commit is contained in:
@@ -8,7 +8,7 @@ import {
|
|||||||
import { useAuth } from "@/hooks/useAuth"
|
import { useAuth } from "@/hooks/useAuth"
|
||||||
import useSettings from "@/hooks/useSetting"
|
import useSettings from "@/hooks/useSetting"
|
||||||
import { copyToClipboard } from "@/lib/utils"
|
import { copyToClipboard } from "@/lib/utils"
|
||||||
import { ModelConfig, ModelProfile } from "@/types"
|
import { ModelProfile, ModelSetting } from "@/types"
|
||||||
import i18next from "i18next"
|
import i18next from "i18next"
|
||||||
import { Check, Clipboard } from "lucide-react"
|
import { Check, Clipboard } from "lucide-react"
|
||||||
import { forwardRef, useState } from "react"
|
import { forwardRef, useState } from "react"
|
||||||
@@ -88,7 +88,7 @@ export const InstallCommandsMenu = forwardRef<HTMLButtonElement, ButtonProps>((p
|
|||||||
|
|
||||||
const generateCommand = (
|
const generateCommand = (
|
||||||
type: number,
|
type: number,
|
||||||
{ agent_secret_key, install_host, tls }: ModelConfig,
|
{ agent_secret_key, install_host, tls }: ModelSetting,
|
||||||
{ agent_secret, role }: ModelProfile,
|
{ agent_secret, role }: ModelProfile,
|
||||||
) => {
|
) => {
|
||||||
if (!install_host) throw new Error(i18next.t("Results.InstallHostRequired"))
|
if (!install_host) throw new Error(i18next.t("Results.InstallHostRequired"))
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
import { swrFetcher } from "@/api/api"
|
import { swrFetcher } from "@/api/api"
|
||||||
import { GithubComNezhahqNezhaModelSettingResponseModelConfig } from "@/types"
|
import { ModelSettingResponse } from "@/types"
|
||||||
import useSWR from "swr"
|
import useSWR from "swr"
|
||||||
|
|
||||||
export default function useSetting() {
|
export default function useSetting() {
|
||||||
return useSWR<GithubComNezhahqNezhaModelSettingResponseModelConfig>(
|
return useSWR<ModelSettingResponse>("/api/v1/setting", swrFetcher)
|
||||||
"/api/v1/setting",
|
|
||||||
swrFetcher,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|||||||
116
src/types/api.ts
116
src/types/api.ts
@@ -93,12 +93,6 @@ export interface GithubComNezhahqNezhaModelCommonResponseArrayUint64 {
|
|||||||
success: boolean
|
success: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GithubComNezhahqNezhaModelCommonResponseGithubComNezhahqNezhaModelSettingResponseModelConfig {
|
|
||||||
data: GithubComNezhahqNezhaModelSettingResponseModelConfig
|
|
||||||
error: string
|
|
||||||
success: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface GithubComNezhahqNezhaModelCommonResponseModelLoginResponse {
|
export interface GithubComNezhahqNezhaModelCommonResponseModelLoginResponse {
|
||||||
data: ModelLoginResponse
|
data: ModelLoginResponse
|
||||||
error: string
|
error: string
|
||||||
@@ -123,6 +117,12 @@ export interface GithubComNezhahqNezhaModelCommonResponseModelServiceResponse {
|
|||||||
success: boolean
|
success: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface GithubComNezhahqNezhaModelCommonResponseModelSettingResponse {
|
||||||
|
data: ModelSettingResponse
|
||||||
|
error: string
|
||||||
|
success: boolean
|
||||||
|
}
|
||||||
|
|
||||||
export interface GithubComNezhahqNezhaModelCommonResponseString {
|
export interface GithubComNezhahqNezhaModelCommonResponseString {
|
||||||
data: string
|
data: string
|
||||||
error: string
|
error: string
|
||||||
@@ -147,12 +147,6 @@ export interface GithubComNezhahqNezhaModelPaginatedResponseArrayModelWAFApiMock
|
|||||||
success: boolean
|
success: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GithubComNezhahqNezhaModelSettingResponseModelConfig {
|
|
||||||
config: ModelConfig
|
|
||||||
frontend_templates: ModelFrontendTemplate[]
|
|
||||||
version: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface GithubComNezhahqNezhaModelValueArrayModelOnlineUser {
|
export interface GithubComNezhahqNezhaModelValueArrayModelOnlineUser {
|
||||||
pagination: ModelPagination
|
pagination: ModelPagination
|
||||||
value: ModelOnlineUser[]
|
value: ModelOnlineUser[]
|
||||||
@@ -194,47 +188,6 @@ export interface ModelAlertRuleForm {
|
|||||||
trigger_mode: number
|
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<string, boolean>
|
|
||||||
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<string, ModelOauth2Config>
|
|
||||||
/** oauth2 供应商列表,无需配置,自动生成 */
|
|
||||||
oauth2_providers: string[]
|
|
||||||
/** 真实IP */
|
|
||||||
real_ip_header: string
|
|
||||||
site_name: string
|
|
||||||
tls: boolean
|
|
||||||
user_template: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ModelCreateFMResponse {
|
export interface ModelCreateFMResponse {
|
||||||
session_id: string
|
session_id: string
|
||||||
}
|
}
|
||||||
@@ -463,20 +416,6 @@ export interface ModelNotificationGroupResponseItem {
|
|||||||
notifications: number[]
|
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 {
|
export interface ModelOauth2LoginResponse {
|
||||||
redirect: string
|
redirect: string
|
||||||
}
|
}
|
||||||
@@ -690,6 +629,43 @@ export interface ModelServiceResponseItem {
|
|||||||
up: number[]
|
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<string, boolean>
|
||||||
|
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 {
|
export interface ModelSettingForm {
|
||||||
cover: number
|
cover: number
|
||||||
custom_code?: string
|
custom_code?: string
|
||||||
@@ -711,6 +687,12 @@ export interface ModelSettingForm {
|
|||||||
user_template?: string
|
user_template?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ModelSettingResponse {
|
||||||
|
config: ModelSetting
|
||||||
|
frontend_templates: ModelFrontendTemplate[]
|
||||||
|
version: string
|
||||||
|
}
|
||||||
|
|
||||||
export interface ModelStreamServer {
|
export interface ModelStreamServer {
|
||||||
country_code: string
|
country_code: string
|
||||||
/** 展示排序,越大越靠前 */
|
/** 展示排序,越大越靠前 */
|
||||||
|
|||||||
Reference in New Issue
Block a user