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

View File

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

View File

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

View File

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