settings.ts 2.6 KB

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