diff --git a/internal/apps/openresty/request.go b/internal/apps/openresty/request.go new file mode 100644 index 00000000..80ae0eba --- /dev/null +++ b/internal/apps/openresty/request.go @@ -0,0 +1,5 @@ +package openresty + +type UpdateConfig struct { + Config string `form:"config" json:"config"` +} diff --git a/internal/apps/openresty/service.go b/internal/apps/openresty/service.go index 9621bdf2..4f90c8b1 100644 --- a/internal/apps/openresty/service.go +++ b/internal/apps/openresty/service.go @@ -37,18 +37,21 @@ func (s *Service) GetConfig(w http.ResponseWriter, r *http.Request) { } func (s *Service) SaveConfig(w http.ResponseWriter, r *http.Request) { - config := r.FormValue("config") - if len(config) == 0 { - service.Error(w, http.StatusInternalServerError, "配置不能为空") + req, err := service.Bind[UpdateConfig](r) + if err != nil { + service.Error(w, http.StatusUnprocessableEntity, err.Error()) + return } - if err := io.Write(fmt.Sprintf("%s/server/openresty/conf/nginx.conf", app.Root), config, 0644); err != nil { + if err = io.Write(fmt.Sprintf("%s/server/openresty/conf/nginx.conf", app.Root), req.Config, 0644); err != nil { service.Error(w, http.StatusInternalServerError, "保存配置失败") + return } - if err := systemctl.Reload("openresty"); err != nil { + if err = systemctl.Reload("openresty"); err != nil { _, err = shell.Execf("openresty -t") service.Error(w, http.StatusInternalServerError, fmt.Sprintf("重载服务失败: %v", err)) + return } service.Success(w, nil) @@ -59,17 +62,14 @@ func (s *Service) ErrorLog(w http.ResponseWriter, r *http.Request) { service.Success(w, "") } - out, err := shell.Execf("tail -n 100 %s/%s", app.Root, "/wwwlogs/openresty_error.log") - if err != nil { - service.Error(w, http.StatusInternalServerError, err.Error()) - } - + out, _ := shell.Execf("tail -n 100 %s/%s", app.Root, "wwwlogs/openresty_error.log") service.Success(w, out) } func (s *Service) ClearErrorLog(w http.ResponseWriter, r *http.Request) { - if _, err := shell.Execf("echo '' > %s/%s", app.Root, "/wwwlogs/openresty_error.log"); err != nil { + if _, err := shell.Execf("echo '' > %s/%s", app.Root, "wwwlogs/openresty_error.log"); err != nil { service.Error(w, http.StatusInternalServerError, err.Error()) + return } service.Success(w, nil) @@ -88,6 +88,7 @@ func (s *Service) Load(w http.ResponseWriter, r *http.Request) { workers, err := shell.Execf("ps aux | grep nginx | grep 'worker process' | wc -l") if err != nil { service.Error(w, http.StatusInternalServerError, "获取负载失败") + return } data = append(data, types.NV{ Name: "工作进程", @@ -97,6 +98,7 @@ func (s *Service) Load(w http.ResponseWriter, r *http.Request) { out, err := shell.Execf("ps aux | grep nginx | grep 'worker process' | awk '{memsum+=$6};END {print memsum}'") if err != nil { service.Error(w, http.StatusInternalServerError, "获取负载失败") + return } mem := str.FormatBytes(cast.ToFloat64(out)) data = append(data, types.NV{ diff --git a/web/src/views/apps/fail2ban/IndexView.vue b/web/src/views/apps/fail2ban/IndexView.vue index 196e610c..ad96c9e2 100644 --- a/web/src/views/apps/fail2ban/IndexView.vue +++ b/web/src/views/apps/fail2ban/IndexView.vue @@ -2,7 +2,7 @@ import { NButton, NDataTable, NInput, NPopconfirm, NSwitch } from 'naive-ui' import fail2ban from '@/api/apps/fail2ban' -import service from '@/api/panel/system/service' +import systemctl from '@/api/panel/systemctl' import website from '@/api/panel/website' import { renderIcon } from '@/utils' import type { Jail } from '@/views/apps/fail2ban/types' @@ -219,48 +219,48 @@ const onPageSizeChange = (pageSize: number) => { } const getStatus = async () => { - await service.status('fail2ban').then((res: any) => { + await systemctl.status('fail2ban').then((res: any) => { status.value = res.data }) } const getIsEnabled = async () => { - await service.isEnabled('fail2ban').then((res: any) => { + await systemctl.isEnabled('fail2ban').then((res: any) => { isEnabled.value = res.data }) } const handleStart = async () => { - await service.start('fail2ban') + await systemctl.start('fail2ban') window.$message.success('启动成功') await getStatus() } const handleIsEnabled = async () => { if (isEnabled.value) { - await service.enable('fail2ban') + await systemctl.enable('fail2ban') window.$message.success('开启自启动成功') } else { - await service.disable('fail2ban') + await systemctl.disable('fail2ban') window.$message.success('禁用自启动成功') } await getIsEnabled() } const handleStop = async () => { - await service.stop('fail2ban') + await systemctl.stop('fail2ban') window.$message.success('停止成功') await getStatus() } const handleRestart = async () => { - await service.restart('fail2ban') + await systemctl.restart('fail2ban') window.$message.success('重启成功') await getStatus() } const handleReload = async () => { - await service.reload('fail2ban') + await systemctl.reload('fail2ban') window.$message.success('重载成功') await getStatus() } diff --git a/web/src/views/apps/frp/IndexView.vue b/web/src/views/apps/frp/IndexView.vue index f164517b..f1783825 100644 --- a/web/src/views/apps/frp/IndexView.vue +++ b/web/src/views/apps/frp/IndexView.vue @@ -3,7 +3,7 @@ import Editor from '@guolao/vue-monaco-editor' import { NButton, NPopconfirm } from 'naive-ui' import frp from '@/api/apps/frp' -import service from '@/api/panel/system/service' +import systemctl from '@/api/panel/systemctl' const currentTab = ref('frps') const status = ref({ @@ -27,19 +27,19 @@ const statusStr = computed(() => { }) const getStatus = async () => { - await service.status('frps').then((res: any) => { + await systemctl.status('frps').then((res: any) => { status.value.frps = res.data }) - await service.status('frpc').then((res: any) => { + await systemctl.status('frpc').then((res: any) => { status.value.frpc = res.data }) } const getIsEnabled = async () => { - await service.isEnabled('frps').then((res: any) => { + await systemctl.isEnabled('frps').then((res: any) => { isEnabled.value.frps = res.data }) - await service.isEnabled('frpc').then((res: any) => { + await systemctl.isEnabled('frpc').then((res: any) => { isEnabled.value.frpc = res.data }) } @@ -59,29 +59,29 @@ const handleSaveConfig = async (service: string) => { } const handleStart = async (name: string) => { - await service.start(name) + await systemctl.start(name) window.$message.success('启动成功') await getStatus() } const handleStop = async (name: string) => { - await service.stop(name) + await systemctl.stop(name) window.$message.success('停止成功') await getStatus() } const handleRestart = async (name: string) => { - await service.restart(name) + await systemctl.restart(name) window.$message.success('重启成功') await getStatus() } const handleIsEnabled = async (name: string) => { if (isEnabled.value[name as keyof typeof isEnabled.value]) { - await service.enable(name) + await systemctl.enable(name) window.$message.success('开启自启动成功') } else { - await service.disable(name) + await systemctl.disable(name) window.$message.success('禁用自启动成功') } await getIsEnabled() diff --git a/web/src/views/apps/gitea/IndexView.vue b/web/src/views/apps/gitea/IndexView.vue index b46dc821..1e7307cd 100644 --- a/web/src/views/apps/gitea/IndexView.vue +++ b/web/src/views/apps/gitea/IndexView.vue @@ -3,7 +3,7 @@ import Editor from '@guolao/vue-monaco-editor' import { NButton, NPopconfirm } from 'naive-ui' import gitea from '@/api/apps/gitea' -import service from '@/api/panel/system/service' +import systemctl from '@/api/panel/systemctl' const currentTab = ref('status') const status = ref(false) @@ -15,13 +15,13 @@ const statusStr = computed(() => { }) const getStatus = async () => { - await service.status('gitea').then((res: any) => { + await systemctl.status('gitea').then((res: any) => { status.value = res.data }) } const getIsEnabled = async () => { - await service.isEnabled('gitea').then((res: any) => { + await systemctl.isEnabled('gitea').then((res: any) => { isEnabled.value = res.data }) } @@ -38,29 +38,29 @@ const handleSaveConfig = async () => { } const handleStart = async () => { - await service.start('gitea') + await systemctl.start('gitea') window.$message.success('启动成功') await getStatus() } const handleStop = async () => { - await service.stop('gitea') + await systemctl.stop('gitea') window.$message.success('停止成功') await getStatus() } const handleRestart = async () => { - await service.restart('gitea') + await systemctl.restart('gitea') window.$message.success('重启成功') await getStatus() } const handleIsEnabled = async () => { if (isEnabled.value) { - await service.enable('gitea') + await systemctl.enable('gitea') window.$message.success('开启自启动成功') } else { - await service.disable('gitea') + await systemctl.disable('gitea') window.$message.success('禁用自启动成功') } await getIsEnabled() diff --git a/web/src/views/apps/mysql/IndexView.vue b/web/src/views/apps/mysql/IndexView.vue index a0db3e86..6527c7da 100644 --- a/web/src/views/apps/mysql/IndexView.vue +++ b/web/src/views/apps/mysql/IndexView.vue @@ -4,7 +4,7 @@ import type { MessageReactive, UploadFileInfo } from 'naive-ui' import { NButton, NDataTable, NInput, NPopconfirm } from 'naive-ui' import mysql from '@/api/apps/mysql' -import service from '@/api/panel/system/service' +import systemctl from '@/api/panel/systemctl' import { generateRandomString, renderIcon } from '@/utils' import type { Backup, Database, User } from '@/views/apps/mysql/types' @@ -360,13 +360,13 @@ const showChangePrivilegesModal = (user: string) => { } const getIsEnabled = async () => { - await service.isEnabled('mysqld').then((res: any) => { + await systemctl.isEnabled('mysqld').then((res: any) => { isEnabled.value = res.data }) } const getStatus = async () => { - await service.status('mysqld').then((res: any) => { + await systemctl.status('mysqld').then((res: any) => { status.value = res.data }) } @@ -415,35 +415,35 @@ const handleClearSlowLog = async () => { const handleIsEnabled = async () => { if (isEnabled.value) { - await service.enable('mysqld') + await systemctl.enable('mysqld') window.$message.success('开启自启动成功') } else { - await service.disable('mysqld') + await systemctl.disable('mysqld') window.$message.success('禁用自启动成功') } await getIsEnabled() } const handleStart = async () => { - await service.start('mysqld') + await systemctl.start('mysqld') window.$message.success('启动成功') await getStatus() } const handleStop = async () => { - await service.stop('mysqld') + await systemctl.stop('mysqld') window.$message.success('停止成功') await getStatus() } const handleRestart = async () => { - await service.restart('mysqld') + await systemctl.restart('mysqld') window.$message.success('重启成功') await getStatus() } const handleReload = async () => { - await service.reload('mysqld') + await systemctl.reload('mysqld') window.$message.success('重载成功') await getStatus() } diff --git a/web/src/views/apps/openresty/IndexView.vue b/web/src/views/apps/openresty/IndexView.vue index 5362f337..4a01635b 100644 --- a/web/src/views/apps/openresty/IndexView.vue +++ b/web/src/views/apps/openresty/IndexView.vue @@ -3,7 +3,7 @@ import Editor from '@guolao/vue-monaco-editor' import { NButton, NDataTable, NPopconfirm } from 'naive-ui' import openresty from '@/api/apps/openresty' -import service from '@/api/panel/system/service' +import systemctl from '@/api/panel/systemctl' const currentTab = ref('status') const status = ref(false) @@ -32,13 +32,13 @@ const getLoad = async () => { } const getStatus = async () => { - service.status('openresty').then((res: any) => { + await systemctl.status('openresty').then((res: any) => { status.value = res.data }) } const getIsEnabled = async () => { - await service.isEnabled('openresty').then((res: any) => { + await systemctl.isEnabled('openresty').then((res: any) => { isEnabled.value = res.data }) } @@ -68,35 +68,35 @@ const handleClearErrorLog = async () => { const handleIsEnabled = async () => { if (isEnabled.value) { - await service.enable('openresty') + await systemctl.enable('openresty') window.$message.success('开启自启动成功') } else { - await service.disable('openresty') + await systemctl.disable('openresty') window.$message.success('禁用自启动成功') } await getIsEnabled() } const handleStart = async () => { - await service.start('openresty') + await systemctl.start('openresty') window.$message.success('启动成功') await getStatus() } const handleStop = async () => { - await service.stop('openresty') + await systemctl.stop('openresty') window.$message.success('停止成功') await getStatus() } const handleRestart = async () => { - await service.restart('openresty') + await systemctl.restart('openresty') window.$message.success('重启成功') await getStatus() } const handleReload = async () => { - await service.reload('openresty') + await systemctl.reload('openresty') window.$message.success('重载成功') await getStatus() } diff --git a/web/src/views/apps/php/IndexView.vue b/web/src/views/apps/php/IndexView.vue index b1736dae..5b4746a8 100644 --- a/web/src/views/apps/php/IndexView.vue +++ b/web/src/views/apps/php/IndexView.vue @@ -3,7 +3,7 @@ import Editor from '@guolao/vue-monaco-editor' import { NButton, NDataTable, NPopconfirm } from 'naive-ui' import php from '@/api/apps/php' -import service from '@/api/panel/system/service' +import systemctl from '@/api/panel/systemctl' import { renderIcon } from '@/utils' const route = useRoute() @@ -107,13 +107,13 @@ const getExtensions = async () => { } const getStatus = async () => { - await service.status(`php-fpm-${version}`).then((res: any) => { + await systemctl.status(`php-fpm-${version}`).then((res: any) => { status.value = res.data }) } const getIsEnabled = async () => { - await service.isEnabled(`php-fpm-${version}`).then((res: any) => { + await systemctl.isEnabled(`php-fpm-${version}`).then((res: any) => { isEnabled.value = res.data }) } @@ -168,38 +168,38 @@ const handleClearSlowLog = async () => { const handleIsEnabled = async () => { if (isEnabled.value) { - await service.enable(`php-fpm-${version}`) + await systemctl.enable(`php-fpm-${version}`) window.$message.success('开启自启动成功') } else { - await service.disable(`php-fpm-${version}`) + await systemctl.disable(`php-fpm-${version}`) window.$message.success('禁用自启动成功') } await getIsEnabled() } const handleStart = async () => { - await service.start(`php-fpm-${version}`) + await systemctl.start(`php-fpm-${version}`) window.$message.success('启动成功') await getStatus() await getErrorLog() } const handleStop = async () => { - await service.stop(`php-fpm-${version}`) + await systemctl.stop(`php-fpm-${version}`) window.$message.success('停止成功') await getStatus() await getErrorLog() } const handleRestart = async () => { - await service.restart(`php-fpm-${version}`) + await systemctl.restart(`php-fpm-${version}`) window.$message.success('重启成功') await getStatus() await getErrorLog() } const handleReload = async () => { - await service.reload(`php-fpm-${version}`) + await systemctl.reload(`php-fpm-${version}`) window.$message.success('重载成功') await getStatus() await getErrorLog() diff --git a/web/src/views/apps/podman/IndexView.vue b/web/src/views/apps/podman/IndexView.vue index 7ca77aee..53fafa6b 100644 --- a/web/src/views/apps/podman/IndexView.vue +++ b/web/src/views/apps/podman/IndexView.vue @@ -3,7 +3,7 @@ import Editor from '@guolao/vue-monaco-editor' import { NButton, NPopconfirm } from 'naive-ui' import podman from '@/api/apps/podman' -import service from '@/api/panel/system/service' +import systemctl from '@/api/panel/systemctl' const currentTab = ref('status') const status = ref(false) @@ -16,13 +16,13 @@ const statusStr = computed(() => { }) const getStatus = async () => { - await service.status('podman').then((res: any) => { + await systemctl.status('podman').then((res: any) => { status.value = res.data }) } const getIsEnabled = async () => { - await service.isEnabled('podman').then((res: any) => { + await systemctl.isEnabled('podman').then((res: any) => { isEnabled.value = res.data }) } @@ -47,29 +47,29 @@ const handleSaveStorageConfig = async () => { } const handleStart = async () => { - await service.start('podman') + await systemctl.start('podman') window.$message.success('启动成功') await getStatus() } const handleStop = async () => { - await service.stop('podman') + await systemctl.stop('podman') window.$message.success('停止成功') await getStatus() } const handleRestart = async () => { - await service.restart('podman') + await systemctl.restart('podman') window.$message.success('重启成功') await getStatus() } const handleIsEnabled = async () => { if (isEnabled.value) { - await service.enable('podman') + await systemctl.enable('podman') window.$message.success('开启自启动成功') } else { - await service.disable('podman') + await systemctl.disable('podman') window.$message.success('禁用自启动成功') } await getIsEnabled() diff --git a/web/src/views/apps/postgresql/IndexView.vue b/web/src/views/apps/postgresql/IndexView.vue index 04fabbae..4097e3d7 100644 --- a/web/src/views/apps/postgresql/IndexView.vue +++ b/web/src/views/apps/postgresql/IndexView.vue @@ -4,7 +4,7 @@ import type { MessageReactive, UploadFileInfo } from 'naive-ui' import { NButton, NDataTable, NFlex, NInput, NPopconfirm, NTag } from 'naive-ui' import postgresql from '@/api/apps/postgresql' -import service from '@/api/panel/system/service' +import systemctl from '@/api/panel/systemctl' import { generateRandomString, renderIcon } from '@/utils' import type { Backup, Database, Role } from '@/views/apps/postgresql/types' @@ -352,13 +352,13 @@ const showChangePasswordModal = (user: string) => { } const getIsEnabled = async () => { - await service.isEnabled('postgresql').then((res: any) => { + await systemctl.isEnabled('postgresql').then((res: any) => { isEnabled.value = res.data }) } const getStatus = async () => { - await service.status('postgresql').then((res: any) => { + await systemctl.status('postgresql').then((res: any) => { status.value = res.data }) } @@ -400,35 +400,35 @@ const handleClearLog = async () => { const handleIsEnabled = async () => { if (isEnabled.value) { - await service.enable('postgresql') + await systemctl.enable('postgresql') window.$message.success('开启自启动成功') } else { - await service.disable('postgresql') + await systemctl.disable('postgresql') window.$message.success('禁用自启动成功') } await getIsEnabled() } const handleStart = async () => { - await service.start('postgresql') + await systemctl.start('postgresql') window.$message.success('启动成功') await getStatus() } const handleStop = async () => { - await service.stop('postgresql') + await systemctl.stop('postgresql') window.$message.success('停止成功') await getStatus() } const handleRestart = async () => { - await service.restart('postgresql') + await systemctl.restart('postgresql') window.$message.success('重启成功') await getStatus() } const handleReload = async () => { - await service.reload('postgresql') + await systemctl.reload('postgresql') window.$message.success('重载成功') await getStatus() } diff --git a/web/src/views/apps/pureftpd/IndexView.vue b/web/src/views/apps/pureftpd/IndexView.vue index 4a91c084..bb07b669 100644 --- a/web/src/views/apps/pureftpd/IndexView.vue +++ b/web/src/views/apps/pureftpd/IndexView.vue @@ -2,7 +2,7 @@ import { NButton, NDataTable, NInput, NPopconfirm } from 'naive-ui' import pureftpd from '@/api/apps/pureftpd' -import service from '@/api/panel/system/service' +import systemctl from '@/api/panel/systemctl' import { generateRandomString, renderIcon } from '@/utils' import type { User } from '@/views/apps/pureftpd/types' @@ -110,13 +110,13 @@ const userColumns: any = [ const users = ref([] as User[]) const getStatus = async () => { - await service.status('pure-ftpd').then((res: any) => { + await systemctl.status('pure-ftpd').then((res: any) => { status.value = res.data }) } const getIsEnabled = async () => { - await service.isEnabled('pure-ftpd').then((res: any) => { + await systemctl.isEnabled('pure-ftpd').then((res: any) => { isEnabled.value = res.data }) } @@ -133,30 +133,30 @@ const handleSavePort = async () => { } const handleStart = async () => { - await service.start('pure-ftpd') + await systemctl.start('pure-ftpd') window.$message.success('启动成功') await getStatus() } const handleIsEnabled = async () => { if (isEnabled.value) { - await service.enable('pure-ftpd') + await systemctl.enable('pure-ftpd') window.$message.success('开启自启动成功') } else { - await service.disable('pure-ftpd') + await systemctl.disable('pure-ftpd') window.$message.success('禁用自启动成功') } await getIsEnabled() } const handleStop = async () => { - await service.stop('pure-ftpd') + await systemctl.stop('pure-ftpd') window.$message.success('停止成功') await getStatus() } const handleRestart = async () => { - await service.restart('pure-ftpd') + await systemctl.restart('pure-ftpd') window.$message.success('重启成功') await getStatus() } diff --git a/web/src/views/apps/redis/IndexView.vue b/web/src/views/apps/redis/IndexView.vue index 7eb1b48d..0bbfa37c 100644 --- a/web/src/views/apps/redis/IndexView.vue +++ b/web/src/views/apps/redis/IndexView.vue @@ -3,7 +3,7 @@ import Editor from '@guolao/vue-monaco-editor' import { NButton, NDataTable, NPopconfirm } from 'naive-ui' import redis from '@/api/apps/redis' -import service from '@/api/panel/system/service' +import systemctl from '@/api/panel/systemctl' const currentTab = ref('status') const status = ref(false) @@ -30,13 +30,13 @@ const getLoad = async () => { } const getStatus = async () => { - await service.status('redis').then((res: any) => { + await systemctl.status('redis').then((res: any) => { status.value = res.data }) } const getIsEnabled = async () => { - await service.isEnabled('redis').then((res: any) => { + await systemctl.isEnabled('redis').then((res: any) => { isEnabled.value = res.data }) } @@ -53,30 +53,30 @@ const handleSaveConfig = async () => { } const handleStart = async () => { - await service.start('redis') + await systemctl.start('redis') window.$message.success('启动成功') await getStatus() } const handleIsEnabled = async () => { if (isEnabled.value) { - await service.enable('redis') + await systemctl.enable('redis') window.$message.success('开启自启动成功') } else { - await service.disable('redis') + await systemctl.disable('redis') window.$message.success('禁用自启动成功') } await getIsEnabled() } const handleStop = async () => { - await service.stop('redis') + await systemctl.stop('redis') window.$message.success('停止成功') await getStatus() } const handleRestart = async () => { - await service.restart('redis') + await systemctl.restart('redis') window.$message.success('重启成功') await getStatus() } diff --git a/web/src/views/apps/rsync/IndexView.vue b/web/src/views/apps/rsync/IndexView.vue index d03917e3..f18a2ed2 100644 --- a/web/src/views/apps/rsync/IndexView.vue +++ b/web/src/views/apps/rsync/IndexView.vue @@ -3,7 +3,7 @@ import Editor from '@guolao/vue-monaco-editor' import { NButton, NDataTable, NInput, NPopconfirm } from 'naive-ui' import rsync from '@/api/apps/rsync' -import service from '@/api/panel/system/service' +import systemctl from '@/api/panel/systemctl' import { generateRandomString, renderIcon } from '@/utils' import type { Module } from '@/views/apps/rsync/types' @@ -135,13 +135,13 @@ const onPageSizeChange = (pageSize: number) => { } const getStatus = async () => { - await service.status('rsyncd').then((res: any) => { + await systemctl.status('rsyncd').then((res: any) => { status.value = res.data }) } const getIsEnabled = async () => { - await service.isEnabled('rsyncd').then((res: any) => { + await systemctl.isEnabled('rsyncd').then((res: any) => { isEnabled.value = res.data }) } @@ -159,30 +159,30 @@ const handleSaveConfig = async () => { } const handleStart = async () => { - await service.start('rsyncd') + await systemctl.start('rsyncd') window.$message.success('启动成功') await getStatus() } const handleIsEnabled = async () => { if (isEnabled.value) { - await service.enable('rsyncd') + await systemctl.enable('rsyncd') window.$message.success('开启自启动成功') } else { - await service.disable('rsyncd') + await systemctl.disable('rsyncd') window.$message.success('禁用自启动成功') } await getIsEnabled() } const handleStop = async () => { - await service.stop('rsyncd') + await systemctl.stop('rsyncd') window.$message.success('停止成功') await getStatus() } const handleRestart = async () => { - await service.restart('rsyncd') + await systemctl.restart('rsyncd') window.$message.success('重启成功') await getStatus() } diff --git a/web/src/views/apps/supervisor/IndexView.vue b/web/src/views/apps/supervisor/IndexView.vue index fdb3d2e3..29bc9605 100644 --- a/web/src/views/apps/supervisor/IndexView.vue +++ b/web/src/views/apps/supervisor/IndexView.vue @@ -3,7 +3,7 @@ import Editor from '@guolao/vue-monaco-editor' import { NButton, NDataTable, NInput, NPopconfirm } from 'naive-ui' import supervisor from '@/api/apps/supervisor' -import service from '@/api/panel/system/service' +import systemctl from '@/api/panel/systemctl' import { renderIcon } from '@/utils' import type { Process } from '@/views/apps/supervisor/types' @@ -217,13 +217,13 @@ const onPageSizeChange = (pageSize: number) => { } const getStatus = async () => { - await service.status(serviceName.value).then((res: any) => { + await systemctl.status(serviceName.value).then((res: any) => { status.value = res.data }) } const getIsEnabled = async () => { - await service.isEnabled(serviceName.value).then((res: any) => { + await systemctl.isEnabled(serviceName.value).then((res: any) => { isEnabled.value = res.data }) } @@ -252,7 +252,7 @@ const handleClearLog = async () => { } const handleStart = async () => { - await service.start(serviceName.value) + await systemctl.start(serviceName.value) window.$message.success('启动成功') await getStatus() await getLog() @@ -260,31 +260,31 @@ const handleStart = async () => { const handleIsEnabled = async () => { if (isEnabled.value) { - await service.enable(serviceName.value) + await systemctl.enable(serviceName.value) window.$message.success('开启自启动成功') } else { - await service.disable(serviceName.value) + await systemctl.disable(serviceName.value) window.$message.success('禁用自启动成功') } await getIsEnabled() } const handleStop = async () => { - await service.stop(serviceName.value) + await systemctl.stop(serviceName.value) window.$message.success('停止成功') await getStatus() await getLog() } const handleRestart = async () => { - await service.restart(serviceName.value) + await systemctl.restart(serviceName.value) window.$message.success('重启成功') await getStatus() await getLog() } const handleReload = async () => { - await service.reload(serviceName.value) + await systemctl.reload(serviceName.value) window.$message.success('重载成功') await getStatus() await getLog()