settings.ts 2.3 KB

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