2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 03:07:20 +08:00

feat: 首页添加任务状态

This commit is contained in:
2026-01-10 19:29:32 +08:00
parent 1d2ba12696
commit 7bef2f34c0
6 changed files with 52 additions and 12 deletions

View File

@@ -35,7 +35,7 @@ func NewCli(t *gotext.Locale, cmd *route.Cli) *cli.Command {
cli.RootCommandHelpTemplate += "\n" + t.Get("QQ Group12370907") + "\n"
return &cli.Command{
Name: "panel-cli",
Name: "acepanel",
Usage: t.Get("AcePanel CLI Tool"),
Version: app.Version,
Commands: cmd.Commands(),

View File

@@ -62,16 +62,16 @@ func (r *cronRepo) Create(req *request.CronCreate) error {
script = fmt.Sprintf(`#!/bin/bash
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$PATH
panel-cli backup website -n '%s' -p '%s'
panel-cli backup clear -t website -f '%s' -s '%d' -p '%s'
acepanel backup website -n '%s' -p '%s'
acepanel backup clear -t website -f '%s' -s '%d' -p '%s'
`, req.Target, req.BackupPath, req.Target, req.Save, req.BackupPath)
}
if req.BackupType == "mysql" || req.BackupType == "postgres" {
script = fmt.Sprintf(`#!/bin/bash
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$PATH
panel-cli backup database -t '%s' -n '%s' -p '%s'
panel-cli backup clear -t '%s' -f '%s' -s '%d' -p '%s'
acepanel backup database -t '%s' -n '%s' -p '%s'
acepanel backup clear -t '%s' -f '%s' -s '%d' -p '%s'
`, req.BackupType, req.Target, req.BackupPath, req.BackupType, req.Target, req.Save, req.BackupPath)
}
}
@@ -79,8 +79,8 @@ panel-cli backup clear -t '%s' -f '%s' -s '%d' -p '%s'
script = fmt.Sprintf(`#!/bin/bash
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$PATH
panel-cli cutoff website -n '%s' -p '%s'
panel-cli cutoff clear -t website -f '%s' -s '%d' -p '%s'
acepanel cutoff website -n '%s' -p '%s'
acepanel cutoff clear -t website -f '%s' -s '%d' -p '%s'
`, req.Target, req.BackupPath, req.Target, req.Save, req.BackupPath)
}
if req.Type == "shell" {

View File

@@ -196,7 +196,7 @@ func (s *CliService) Info(ctx context.Context, cmd *cli.Command) error {
fmt.Println(s.t.Get("Please choose the appropriate address to access the panel based on your network situation"))
fmt.Println(s.t.Get("If you cannot access, please check whether the server's security group and firewall allow port %d", port))
fmt.Println(s.t.Get("If you still cannot access, try running panel-cli https off to turn off panel HTTPS"))
fmt.Println(s.t.Get("If you still cannot access, try running `acepanel https off` to turn off panel HTTPS"))
fmt.Println(s.t.Get("Warning: After turning off panel HTTPS, the security of the panel will be greatly reduced, please operate with caution"))
return nil

View File

@@ -1,5 +1,6 @@
<script lang="ts" setup>
import ReloadPage from '@/layout/header/components/ReloadPage.vue'
import TaskStatus from '@/layout/header/components/TaskStatus.vue'
import AppTab from '@/layout/tab/IndexView.vue'
import FullScreen from './components/FullScreen.vue'
import ThemeMode from './components/ThemeMode.vue'
@@ -12,13 +13,14 @@ const themeStore = useThemeStore()
</script>
<template>
<div flex w-full items-center justify-between >
<div flex w-full items-center justify-between>
<menu-collapse v-if="themeStore.isMobile" />
<section v-if="!themeStore.isMobile && themeStore.tab.visible" pr-12 flex-1 w-0 >
<section v-if="!themeStore.isMobile && themeStore.tab.visible" pr-12 flex-1 w-0>
<app-tab />
</section>
<span v-if="!themeStore.isMobile && themeStore.tab.visible" mx-6 opacity-20>|</span>
<div ml-auto px-12 flex flex-shrink-0 items-center >
<div ml-auto px-12 flex flex-shrink-0 items-center>
<task-status />
<reload-page />
<full-screen />
<theme-mode />

View File

@@ -0,0 +1,37 @@
<script lang="ts" setup>
import task from '@/api/panel/task'
import { useGettext } from 'vue3-gettext'
const { $gettext } = useGettext()
const router = useRouter()
const { data, send } = useRequest(() => task.status(), { initialData: { task: false } })
const goToTask = () => {
router.push({ path: '/task', query: { tab: 'task' } })
}
let timer: ReturnType<typeof setInterval> | null = null
onMounted(() => {
timer = setInterval(send, 5000)
})
onUnmounted(() => {
if (timer) {
clearInterval(timer)
}
})
</script>
<template>
<n-tooltip trigger="hover">
<template #trigger>
<n-icon mr-20 cursor-pointer size="20" @click="goToTask">
<i-mdi-sync v-if="data.task" class="animate-spin" />
<i-mdi-checkbox-outline v-else />
</n-icon>
</template>
{{ data.task ? $gettext('Tasks Running') : $gettext('Panel Tasks') }}
</n-tooltip>
</template>

View File

@@ -10,7 +10,8 @@ import { NButton } from 'naive-ui'
import { useGettext } from 'vue3-gettext'
const { $gettext } = useGettext()
const current = ref('cron')
const route = useRoute()
const current = ref(route.query.tab === 'task' ? 'task' : 'cron')
const create = ref(false)
</script>