2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 14:57:16 +08:00

feat: 添加cli命令及前端优化

This commit is contained in:
2025-05-15 20:10:31 +08:00
parent 9faa2a74df
commit 7df9b92c58
9 changed files with 128 additions and 25 deletions

View File

@@ -138,14 +138,14 @@ func (s *App) Delete(w http.ResponseWriter, r *http.Request) {
return
}
if _, err = shell.Execf(`fusermount -uzq '%s'`, mount.Path); err != nil {
service.Error(w, http.StatusInternalServerError, "%v", err)
return
}
if _, err = shell.Execf(`umount -lfq '%s'`, mount.Path); err != nil {
service.Error(w, http.StatusInternalServerError, "%v", err)
_, _ = shell.Execf(`fusermount -uz '%s'`, mount.Path)
_, err2 := shell.Execf(`umount -lf '%s'`, mount.Path)
// 卸载之后再检查下是否还有挂载
if _, err = shell.Execf(`df -h | grep '%s'`, mount.Path); err == nil {
service.Error(w, http.StatusUnprocessableEntity, s.t.Get("failed to unmount: %v", err2))
return
}
if _, err = shell.Execf(`sed -i 's@^s3fs#%s\s%s.*$@@g' /etc/fstab`, mount.Bucket, mount.Path); err != nil {
service.Error(w, http.StatusInternalServerError, "%v", err)
return

View File

@@ -119,6 +119,39 @@ func (route *Cli) Commands() []*cli.Command {
},
},
},
{
Name: "bind-domain",
Usage: route.t.Get("Operate panel domain binding"),
Commands: []*cli.Command{
{
Name: "off",
Usage: route.t.Get("Disable domain binding"),
Action: route.cli.BindDomainOff,
},
},
},
{
Name: "bind-ip",
Usage: route.t.Get("Operate panel IP binding"),
Commands: []*cli.Command{
{
Name: "off",
Usage: route.t.Get("Disable IP binding"),
Action: route.cli.BindIPOff,
},
},
},
{
Name: "bind-ua",
Usage: route.t.Get("Operate panel UA binding"),
Commands: []*cli.Command{
{
Name: "off",
Usage: route.t.Get("Disable UA binding"),
Action: route.cli.BindUAOff,
},
},
},
{
Name: "port",
Usage: route.t.Get("Change panel port"),

View File

@@ -436,6 +436,81 @@ func (s *CliService) EntranceOff(ctx context.Context, cmd *cli.Command) error {
return s.Restart(ctx, cmd)
}
func (s *CliService) BindDomainOff(ctx context.Context, cmd *cli.Command) error {
config := new(types.PanelConfig)
raw, err := io.Read("/usr/local/etc/panel/config.yml")
if err != nil {
return err
}
if err = yaml.Unmarshal([]byte(raw), config); err != nil {
return err
}
config.HTTP.BindDomain = nil
encoded, err := yaml.Marshal(config)
if err != nil {
return err
}
if err = io.Write("/usr/local/etc/panel/config.yml", string(encoded), 0700); err != nil {
return err
}
fmt.Println(s.t.Get("Bind domain disabled"))
return s.Restart(ctx, cmd)
}
func (s *CliService) BindIPOff(ctx context.Context, cmd *cli.Command) error {
config := new(types.PanelConfig)
raw, err := io.Read("/usr/local/etc/panel/config.yml")
if err != nil {
return err
}
if err = yaml.Unmarshal([]byte(raw), config); err != nil {
return err
}
config.HTTP.BindIP = nil
encoded, err := yaml.Marshal(config)
if err != nil {
return err
}
if err = io.Write("/usr/local/etc/panel/config.yml", string(encoded), 0700); err != nil {
return err
}
fmt.Println(s.t.Get("Bind IP disabled"))
return s.Restart(ctx, cmd)
}
func (s *CliService) BindUAOff(ctx context.Context, cmd *cli.Command) error {
config := new(types.PanelConfig)
raw, err := io.Read("/usr/local/etc/panel/config.yml")
if err != nil {
return err
}
if err = yaml.Unmarshal([]byte(raw), config); err != nil {
return err
}
config.HTTP.BindUA = nil
encoded, err := yaml.Marshal(config)
if err != nil {
return err
}
if err = io.Write("/usr/local/etc/panel/config.yml", string(encoded), 0700); err != nil {
return err
}
fmt.Println(s.t.Get("Bind UA disabled"))
return s.Restart(ctx, cmd)
}
func (s *CliService) Port(ctx context.Context, cmd *cli.Command) error {
port := cast.ToUint(cmd.Args().First())
if port < 1 || port > 65535 {

View File

@@ -8,11 +8,6 @@ body {
height: 100%;
overflow: hidden;
background-color: #f2f2f2;
font-family:
-apple-system, 'Noto Sans', 'Helvetica Neue', Helvetica, 'Nimbus Sans L', Arial,
'Liberation Sans', 'PingFang SC', 'Hiragino Sans GB', 'Noto Sans CJK SC', 'Noto Sans SC',
'Source Han Sans SC', 'Source Han Sans CN', 'Microsoft YaHei', 'Wenquanyi Micro Hei',
'WenQuanYi Zen Hei', 'ST Heiti', SimHei, 'WenQuanYi Zen Hei Sharp', sans-serif;
}
#app {

View File

@@ -325,7 +325,7 @@ onMounted(() => {
</n-space>
</n-tab-pane>
<n-tab-pane name="extensions" :tab="$gettext('Extension Management')">
<n-card :title="$gettext('Extension List')" :segmented="true">
<n-flex vertical>
<n-data-table
striped
remote
@@ -335,7 +335,7 @@ onMounted(() => {
:data="extensions"
:row-key="(row: any) => row.slug"
/>
</n-card>
</n-flex>
</n-tab-pane>
<n-tab-pane name="config" :tab="$gettext('Main Configuration')">
<n-space vertical>

View File

@@ -265,7 +265,7 @@ onMounted(() => {
</n-space>
</n-tab-pane>
<n-tab-pane name="users" :tab="$gettext('User Management')">
<n-card :title="$gettext('User List')" :segmented="true">
<n-flex vertical>
<n-data-table
striped
remote
@@ -286,7 +286,7 @@ onMounted(() => {
pageSizes: [20, 50, 100, 200]
}"
/>
</n-card>
</n-flex>
</n-tab-pane>
<n-tab-pane name="run-log" :tab="$gettext('Run Log')">
<realtime-log service="pure-ftpd" />

View File

@@ -300,7 +300,7 @@ onMounted(() => {
</n-space>
</n-tab-pane>
<n-tab-pane name="modules" :tab="$gettext('Module Management')">
<n-card :title="$gettext('Module List')" :segmented="true">
<n-flex vertical>
<n-data-table
striped
remote
@@ -321,7 +321,7 @@ onMounted(() => {
pageSizes: [20, 50, 100, 200]
}"
/>
</n-card>
</n-flex>
</n-tab-pane>
<n-tab-pane name="config" :tab="$gettext('Main Configuration')">
<n-space vertical>

View File

@@ -24,15 +24,15 @@ const columns: any = [
{
title: $gettext('Mount Path'),
key: 'path',
minWidth: 250,
minWidth: 150,
resizable: true,
ellipsis: { tooltip: true }
},
{ title: 'Bucket', key: 'bucket', resizable: true, minWidth: 250, ellipsis: { tooltip: true } },
{ title: 'Bucket', key: 'bucket', resizable: true, minWidth: 150, ellipsis: { tooltip: true } },
{
title: $gettext('Actions'),
key: 'actions',
width: 240,
width: 150,
hideInExcel: true,
render(row: any) {
return [
@@ -105,11 +105,11 @@ onMounted(() => {
{{ $gettext('Add Mount') }}
</n-button>
</template>
<n-card :title="$gettext('Mount List')" :segmented="true">
<n-flex vertical>
<n-data-table
striped
remote
:scroll-x="1000"
:scroll-x="450"
:loading="loading"
:columns="columns"
:data="data"
@@ -126,7 +126,7 @@ onMounted(() => {
pageSizes: [20, 50, 100, 200]
}"
/>
</n-card>
</n-flex>
</common-page>
<n-modal v-model:show="addMountModal" :title="$gettext('Add Mount')">
<n-card

View File

@@ -422,7 +422,7 @@ onUnmounted(() => {
</n-space>
</n-tab-pane>
<n-tab-pane name="processes" :tab="$gettext('Process Management')">
<n-card :title="$gettext('Process List')" :segmented="true">
<n-flex vertical>
<n-data-table
striped
remote
@@ -443,7 +443,7 @@ onUnmounted(() => {
pageSizes: [20, 50, 100, 200]
}"
/>
</n-card>
</n-flex>
</n-tab-pane>
<n-tab-pane name="config" :tab="$gettext('Main Configuration')">
<n-space vertical>