fix: 防火墙与进程守护加载样式调整 (#1864)

This commit is contained in:
ssongliu 2023-08-07 22:46:27 +08:00 committed by GitHub
parent 2e73857b42
commit 9b02e88e3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 267 additions and 251 deletions

View File

@ -3,6 +3,7 @@ package client
import ( import (
"fmt" "fmt"
"strings" "strings"
"sync"
"github.com/1Panel-dev/1Panel/backend/buserr" "github.com/1Panel-dev/1Panel/backend/buserr"
"github.com/1Panel-dev/1Panel/backend/constant" "github.com/1Panel-dev/1Panel/backend/constant"
@ -60,12 +61,16 @@ func (f *Firewall) Reload() error {
} }
func (f *Firewall) ListPort() ([]FireInfo, error) { func (f *Firewall) ListPort() ([]FireInfo, error) {
var wg sync.WaitGroup
var datas []FireInfo
wg.Add(2)
go func() {
defer wg.Done()
stdout, err := cmd.Exec("firewall-cmd --zone=public --list-ports") stdout, err := cmd.Exec("firewall-cmd --zone=public --list-ports")
if err != nil { if err != nil {
return nil, err return
} }
ports := strings.Split(strings.ReplaceAll(stdout, "\n", ""), " ") ports := strings.Split(strings.ReplaceAll(stdout, "\n", ""), " ")
var datas []FireInfo
for _, port := range ports { for _, port := range ports {
if len(port) == 0 { if len(port) == 0 {
continue continue
@ -78,10 +83,13 @@ func (f *Firewall) ListPort() ([]FireInfo, error) {
itemPort.Strategy = "accept" itemPort.Strategy = "accept"
datas = append(datas, itemPort) datas = append(datas, itemPort)
} }
}()
go func() {
defer wg.Done()
stdout1, err := cmd.Exec("firewall-cmd --zone=public --list-rich-rules") stdout1, err := cmd.Exec("firewall-cmd --zone=public --list-rich-rules")
if err != nil { if err != nil {
return nil, err return
} }
rules := strings.Split(stdout1, "\n") rules := strings.Split(stdout1, "\n")
for _, rule := range rules { for _, rule := range rules {
@ -93,6 +101,8 @@ func (f *Firewall) ListPort() ([]FireInfo, error) {
datas = append(datas, itemRule) datas = append(datas, itemRule)
} }
} }
}()
wg.Wait()
return datas, nil return datas, nil
} }

View File

@ -1,6 +1,8 @@
<template> <template>
<div v-loading="loading" style="position: relative"> <div>
<FireRouter /> <FireRouter />
<div v-loading="loading">
<FireStatus <FireStatus
v-show="fireName !== '-'" v-show="fireName !== '-'"
ref="fireStatuRef" ref="fireStatuRef"
@ -105,7 +107,7 @@
</template> </template>
</LayoutContent> </LayoutContent>
</div> </div>
</div>
<OperatrDialog @search="search" ref="dialogRef" /> <OperatrDialog @search="search" ref="dialogRef" />
</div> </div>
</template> </template>

View File

@ -1,7 +1,8 @@
<template> <template>
<div v-loading="loading" style="position: relative"> <div>
<FireRouter /> <FireRouter />
<div v-loading="loading">
<FireStatus <FireStatus
v-show="fireName !== '-'" v-show="fireName !== '-'"
ref="fireStatuRef" ref="fireStatuRef"
@ -137,6 +138,7 @@
</template> </template>
</LayoutContent> </LayoutContent>
</div> </div>
</div>
<OperatrDialog @search="search" ref="dialogRef" /> <OperatrDialog @search="search" ref="dialogRef" />
</div> </div>

View File

@ -131,7 +131,9 @@ const getStatus = async () => {
loading.value = true; loading.value = true;
em('update:loading', true); em('update:loading', true);
const res = await GetSupervisorStatus(); const res = await GetSupervisorStatus();
if (res.data.config) {
data.value = res.data.config as HostTool.Supersivor; data.value = res.data.config as HostTool.Supersivor;
}
const status = { const status = {
isExist: data.value.isExist && data.value.ctlExist, isExist: data.value.isExist && data.value.ctlExist,