ngx.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import http from '@/lib/http'
  2. export interface NgxConfig {
  3. file_name?: string
  4. name: string
  5. upstreams?: NgxUpstream[]
  6. servers: NgxServer[]
  7. custom?: string
  8. }
  9. export interface NgxServer {
  10. directives?: NgxDirective[]
  11. locations?: NgxLocation[]
  12. comments?: string
  13. }
  14. export interface NgxUpstream {
  15. name: string
  16. directives: NgxDirective[]
  17. comments?: string
  18. }
  19. export interface NgxDirective {
  20. idx?: number
  21. directive: string
  22. params: string
  23. comments?: string
  24. }
  25. export interface NgxLocation {
  26. path: string
  27. content: string
  28. comments: string
  29. }
  30. const ngx = {
  31. build_config(ngxConfig: NgxConfig) {
  32. return http.post('/ngx/build_config', ngxConfig)
  33. },
  34. tokenize_config(content: string) {
  35. return http.post('/ngx/tokenize_config', { content })
  36. },
  37. format_code(content: string) {
  38. return http.post('/ngx/format_code', { content })
  39. },
  40. status() {
  41. return http.get('/nginx/status')
  42. },
  43. reload() {
  44. return http.post('/nginx/reload')
  45. },
  46. restart() {
  47. return http.post('/nginx/restart')
  48. },
  49. test() {
  50. return http.post('/nginx/test')
  51. },
  52. }
  53. export default ngx