settings.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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 NginxLogSettings {
  64. advanced_indexing_enabled: boolean
  65. index_path: string
  66. }
  67. export interface NodeSettings {
  68. name: string
  69. secret: string
  70. skip_installation: boolean
  71. demo: boolean
  72. icp_number: string
  73. public_security_number: string
  74. }
  75. export interface OpenaiSettings {
  76. model: string
  77. base_url: string
  78. proxy: string
  79. token: string
  80. api_type: string
  81. enable_code_completion: boolean
  82. code_completion_model: string
  83. }
  84. export interface TerminalSettings {
  85. start_cmd: string
  86. }
  87. export interface WebauthnSettings {
  88. rp_display_name: string
  89. rpid: string
  90. rp_origins: string[]
  91. }
  92. export interface BannedIP {
  93. ip: string
  94. attempts: number
  95. expired_at: string
  96. }
  97. export interface Settings {
  98. app: AppSettings
  99. server: ServerSettings
  100. database: DatabaseSettings
  101. auth: AuthSettings
  102. casdoor: CasdoorSettings
  103. cert: CertSettings
  104. http: HTTPSettings
  105. logrotate: LogrotateSettings
  106. nginx: NginxSettings
  107. nginx_log: NginxLogSettings
  108. node: NodeSettings
  109. openai: OpenaiSettings
  110. terminal: TerminalSettings
  111. webauthn: WebauthnSettings
  112. }
  113. const settings = {
  114. get(): Promise<Settings> {
  115. return http.get('/settings')
  116. },
  117. save(data: Settings) {
  118. return http.post('/settings', data)
  119. },
  120. get_server_name(): Promise<{ name: string }> {
  121. return http.get('/settings/server/name')
  122. },
  123. get_banned_ips(): Promise<BannedIP[]> {
  124. return http.get('/settings/auth/banned_ips')
  125. },
  126. remove_banned_ip(ip: string) {
  127. return http.delete('/settings/auth/banned_ip', { data: { ip } })
  128. },
  129. }
  130. export default settings