settings.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. import { http } from '@uozi-admin/request'
  2. export interface AppSettings {
  3. page_size: number
  4. jwt_secret: string
  5. }
  6. export interface ServerSettings {
  7. host: string
  8. port: number
  9. run_mode: 'debug' | 'release'
  10. enable_https: boolean
  11. ssl_cert: string
  12. ssl_key: string
  13. // HTTP/2 and HTTP/3 protocol support (fixed priority: h3->h2->h1)
  14. enable_h2: boolean
  15. enable_h3: boolean
  16. }
  17. export interface DatabaseSettings {
  18. name: string
  19. }
  20. export interface AuthSettings {
  21. ip_white_list: string[]
  22. ban_threshold_minutes: number
  23. max_attempts: number
  24. }
  25. export interface CasdoorSettings {
  26. endpoint: string
  27. client_id: string
  28. client_secret: string
  29. certificate_path: string
  30. organization: string
  31. application: string
  32. redirect_uri: string
  33. }
  34. export interface CertSettings {
  35. email: string
  36. ca_dir: string
  37. renewal_interval: number
  38. recursive_nameservers: string[]
  39. http_challenge_port: string
  40. }
  41. export interface HTTPSettings {
  42. github_proxy: string
  43. insecure_skip_verify: boolean
  44. }
  45. export interface LogrotateSettings {
  46. enabled: boolean
  47. cmd: string
  48. interval: number
  49. }
  50. export interface NginxSettings {
  51. access_log_path: string
  52. error_log_path: string
  53. config_dir: string
  54. config_path: string
  55. log_dir_white_list: string[]
  56. pid_path: string
  57. test_config_cmd: string
  58. reload_cmd: string
  59. restart_cmd: string
  60. stub_status_port: number
  61. container_name: string
  62. }
  63. export interface NodeSettings {
  64. name: string
  65. secret: string
  66. skip_installation: boolean
  67. demo: boolean
  68. icp_number: string
  69. public_security_number: string
  70. }
  71. export interface OpenaiSettings {
  72. model: string
  73. base_url: string
  74. proxy: string
  75. token: string
  76. api_type: string
  77. enable_code_completion: boolean
  78. code_completion_model: string
  79. }
  80. export interface TerminalSettings {
  81. start_cmd: string
  82. }
  83. export interface WebauthnSettings {
  84. rp_display_name: string
  85. rpid: string
  86. rp_origins: string[]
  87. }
  88. export interface BannedIP {
  89. ip: string
  90. attempts: number
  91. expired_at: string
  92. }
  93. export interface Settings {
  94. app: AppSettings
  95. server: ServerSettings
  96. database: DatabaseSettings
  97. auth: AuthSettings
  98. casdoor: CasdoorSettings
  99. cert: CertSettings
  100. http: HTTPSettings
  101. logrotate: LogrotateSettings
  102. nginx: NginxSettings
  103. node: NodeSettings
  104. openai: OpenaiSettings
  105. terminal: TerminalSettings
  106. webauthn: WebauthnSettings
  107. }
  108. const settings = {
  109. get(): Promise<Settings> {
  110. return http.get('/settings')
  111. },
  112. save(data: Settings) {
  113. return http.post('/settings', data)
  114. },
  115. get_server_name(): Promise<{ name: string }> {
  116. return http.get('/settings/server/name')
  117. },
  118. get_banned_ips(): Promise<BannedIP[]> {
  119. return http.get('/settings/auth/banned_ips')
  120. },
  121. remove_banned_ip(ip: string) {
  122. return http.delete('/settings/auth/banned_ip', { data: { ip } })
  123. },
  124. }
  125. export default settings