diff --git a/app/src/components/NginxControl/NginxControl.vue b/app/src/components/NginxControl/NginxControl.vue index 9166ff0f..15355b34 100644 --- a/app/src/components/NginxControl/NginxControl.vue +++ b/app/src/components/NginxControl/NginxControl.vue @@ -4,9 +4,12 @@ import { ReloadOutlined } from '@ant-design/icons-vue' import ngx from '@/api/ngx' import { logLevel } from '@/views/config/constants' import { NginxStatus } from '@/constants' +import { useGlobalStore } from '@/pinia/moudule/global' -const status = ref(0) -async function get_status() { +const global = useGlobalStore() +const { nginxStatus: status } = storeToRefs(global) + +async function getStatus() { const r = await ngx.status() if (r?.running === true) status.value = NginxStatus.Running @@ -16,7 +19,7 @@ async function get_status() { return r } -function reload_nginx() { +function reloadNginx() { status.value = NginxStatus.Reloading ngx.reload().then(r => { if (r.level < logLevel.Warn) @@ -27,14 +30,14 @@ function reload_nginx() { message.error(r.message) }).catch(e => { message.error(`${$gettext('Server error')} ${e?.message}`) - }).finally(() => get_status()) + }).finally(() => getStatus()) } -async function restart_nginx() { +async function restartNginx() { status.value = NginxStatus.Restarting await ngx.restart() - get_status().then(r => { + getStatus().then(r => { if (r.level < logLevel.Warn) message.success($gettext('Nginx restarted successfully')) else if (r.level === logLevel.Warn) @@ -50,7 +53,7 @@ const visible = ref(false) watch(visible, v => { if (v) - get_status() + getStatus() }) @@ -58,7 +61,7 @@ watch(visible, v => {