From 5fdce07190df31bcacea748b94aa36fe3a8510fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=97=E5=AD=90?= Date: Mon, 1 Dec 2025 19:37:19 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=80=E5=A0=86=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/ace/wire_gen.go | 4 +- go.sum | 6 + internal/http/middleware/must_login.go | 2 +- .../http/request/{dashboard.go => home.go} | 2 +- internal/route/http.go | 28 +-- internal/service/{dashboard.go => home.go} | 28 +-- internal/service/service.go | 2 +- web/src/api/panel/dashboard/index.ts | 25 --- web/src/api/panel/home/index.ts | 25 +++ .../layout/sidebar/components/SideLogo.vue | 6 +- web/src/locales/menu.ts | 9 +- web/src/main.ts | 2 +- web/src/views/app/IndexView.vue | 29 ++- web/src/views/app/InstallView.vue | 12 -- web/src/views/backup/IndexView.vue | 4 +- .../views/{dashboard => home}/IndexView.vue | 26 +-- .../views/{dashboard => home}/UpdateView.vue | 10 +- web/src/views/{dashboard => home}/route.ts | 13 +- web/src/views/{dashboard => home}/types.ts | 0 web/src/views/project/route.ts | 4 +- web/src/views/setting/route.ts | 2 +- web/src/views/task/CreateModal.vue | 2 +- web/src/views/task/IndexView.vue | 3 - web/src/views/task/route.ts | 2 +- web/src/views/toolbox/IndexView.vue | 5 +- web/src/views/toolbox/ProcessView.vue | 171 ++++++++++++++++++ web/src/views/website/EditView.vue | 2 +- web/src/views/website/PhpView.vue | 2 +- 28 files changed, 304 insertions(+), 122 deletions(-) rename internal/http/request/{dashboard.go => home.go} (77%) rename internal/service/{dashboard.go => home.go} (88%) delete mode 100644 web/src/api/panel/dashboard/index.ts create mode 100644 web/src/api/panel/home/index.ts rename web/src/views/{dashboard => home}/IndexView.vue (97%) rename web/src/views/{dashboard => home}/UpdateView.vue (90%) rename web/src/views/{dashboard => home}/route.ts (76%) rename web/src/views/{dashboard => home}/types.ts (100%) create mode 100644 web/src/views/toolbox/ProcessView.vue diff --git a/cmd/ace/wire_gen.go b/cmd/ace/wire_gen.go index c46ceafa..4ff93513 100644 --- a/cmd/ace/wire_gen.go +++ b/cmd/ace/wire_gen.go @@ -82,7 +82,7 @@ func initWeb() (*app.Web, error) { settingRepo := data.NewSettingRepo(locale, db, koanf, taskRepo) cronRepo := data.NewCronRepo(locale, db) backupRepo := data.NewBackupRepo(locale, db, settingRepo, websiteRepo) - dashboardService := service.NewDashboardService(locale, koanf, taskRepo, websiteRepo, appRepo, settingRepo, cronRepo, backupRepo) + homeService := service.NewHomeService(locale, koanf, taskRepo, websiteRepo, appRepo, settingRepo, cronRepo, backupRepo) taskService := service.NewTaskService(taskRepo) websiteService := service.NewWebsiteService(websiteRepo, settingRepo) databaseService := service.NewDatabaseService(databaseRepo) @@ -142,7 +142,7 @@ func initWeb() (*app.Web, error) { s3fsApp := s3fs.NewApp(locale) supervisorApp := supervisor.NewApp(locale) loader := bootstrap.NewLoader(codeserverApp, dockerApp, fail2banApp, frpApp, giteaApp, memcachedApp, minioApp, mysqlApp, nginxApp, php74App, php80App, php81App, php82App, php83App, php84App, phpmyadminApp, podmanApp, postgresqlApp, pureftpdApp, redisApp, rsyncApp, s3fsApp, supervisorApp) - http := route.NewHttp(koanf, userService, userTokenService, dashboardService, taskService, websiteService, databaseService, databaseServerService, databaseUserService, backupService, certService, certDNSService, certAccountService, appService, cronService, processService, safeService, firewallService, sshService, containerService, containerComposeService, containerNetworkService, containerImageService, containerVolumeService, fileService, monitorService, settingService, systemctlService, toolboxSystemService, toolboxBenchmarkService, loader) + http := route.NewHttp(koanf, userService, userTokenService, homeService, taskService, websiteService, databaseService, databaseServerService, databaseUserService, backupService, certService, certDNSService, certAccountService, appService, cronService, processService, safeService, firewallService, sshService, containerService, containerComposeService, containerNetworkService, containerImageService, containerVolumeService, fileService, monitorService, settingService, systemctlService, toolboxSystemService, toolboxBenchmarkService, loader) wsService := service.NewWsService(locale, koanf, logger, sshRepo) ws := route.NewWs(wsService) mux, err := bootstrap.NewRouter(locale, middlewares, http, ws) diff --git a/go.sum b/go.sum index f5bb7f86..12efd332 100644 --- a/go.sum +++ b/go.sum @@ -167,6 +167,8 @@ github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXi github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/subcommands v1.2.0 h1:vWQspBTo2nEqTUFita5/KeEWlUL8kQObDFbub/EN9oE= +github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/wire v0.7.0 h1:JxUKI6+CVBgCO2WToKy/nQk0sS+amI9z9EjVmdaocj4= @@ -462,6 +464,8 @@ golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= +golang.org/x/mod v0.29.0 h1:HV8lRxZC4l2cr3Zq1LvtOsi/ThTgWnUk/y64QSs8GwA= +golang.org/x/mod v0.29.0/go.mod h1:NyhrlYXJ2H4eJiRy/WDBO6HMqZQ6q9nk4JzS3NuCK+w= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -534,6 +538,8 @@ golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.38.0 h1:Hx2Xv8hISq8Lm16jvBZ2VQf+RLmbd7wVUsALibYI/IQ= +golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= diff --git a/internal/http/middleware/must_login.go b/internal/http/middleware/must_login.go index c4446f21..3b4b75d9 100644 --- a/internal/http/middleware/must_login.go +++ b/internal/http/middleware/must_login.go @@ -27,7 +27,7 @@ func MustLogin(t *gotext.Locale, conf *koanf.Koanf, session *sessions.Manager, u "/api/user/logout", "/api/user/is_login", "/api/user/is_2fa", - "/api/dashboard/panel", + "/api/home/panel", } return func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { diff --git a/internal/http/request/dashboard.go b/internal/http/request/home.go similarity index 77% rename from internal/http/request/dashboard.go rename to internal/http/request/home.go index 62e62230..342fbd8b 100644 --- a/internal/http/request/dashboard.go +++ b/internal/http/request/home.go @@ -1,6 +1,6 @@ package request -type DashboardCurrent struct { +type HomeCurrent struct { Nets []string `json:"nets" form:"nets"` Disks []string `json:"disks" form:"disks"` } diff --git a/internal/route/http.go b/internal/route/http.go index 602a0eac..316e7b6a 100644 --- a/internal/route/http.go +++ b/internal/route/http.go @@ -19,7 +19,7 @@ type Http struct { conf *koanf.Koanf user *service.UserService userToken *service.UserTokenService - dashboard *service.DashboardService + home *service.HomeService task *service.TaskService website *service.WebsiteService database *service.DatabaseService @@ -53,7 +53,7 @@ func NewHttp( conf *koanf.Koanf, user *service.UserService, userToken *service.UserTokenService, - dashboard *service.DashboardService, + home *service.HomeService, task *service.TaskService, website *service.WebsiteService, database *service.DatabaseService, @@ -86,7 +86,7 @@ func NewHttp( conf: conf, user: user, userToken: userToken, - dashboard: dashboard, + home: home, task: task, website: website, database: database, @@ -146,17 +146,17 @@ func (route *Http) Register(r *chi.Mux) { r.Delete("/{id}", route.userToken.Delete) }) - r.Route("/dashboard", func(r chi.Router) { - r.Get("/panel", route.dashboard.Panel) - r.Get("/home_apps", route.dashboard.HomeApps) - r.Post("/current", route.dashboard.Current) - r.Get("/system_info", route.dashboard.SystemInfo) - r.Get("/count_info", route.dashboard.CountInfo) - r.Get("/installed_db_and_php", route.dashboard.InstalledDbAndPhp) - r.Get("/check_update", route.dashboard.CheckUpdate) - r.Get("/update_info", route.dashboard.UpdateInfo) - r.Post("/update", route.dashboard.Update) - r.Post("/restart", route.dashboard.Restart) + r.Route("/home", func(r chi.Router) { + r.Get("/panel", route.home.Panel) + r.Get("/apps", route.home.Apps) + r.Post("/current", route.home.Current) + r.Get("/system_info", route.home.SystemInfo) + r.Get("/count_info", route.home.CountInfo) + r.Get("/installed_db_and_php", route.home.InstalledDbAndPhp) + r.Get("/check_update", route.home.CheckUpdate) + r.Get("/update_info", route.home.UpdateInfo) + r.Post("/update", route.home.Update) + r.Post("/restart", route.home.Restart) }) r.Route("/task", func(r chi.Router) { diff --git a/internal/service/dashboard.go b/internal/service/home.go similarity index 88% rename from internal/service/dashboard.go rename to internal/service/home.go index 49096bfd..ba9d445c 100644 --- a/internal/service/dashboard.go +++ b/internal/service/home.go @@ -26,7 +26,7 @@ import ( "github.com/acepanel/panel/pkg/types" ) -type DashboardService struct { +type HomeService struct { t *gotext.Locale api *api.API conf *koanf.Koanf @@ -38,8 +38,8 @@ type DashboardService struct { backupRepo biz.BackupRepo } -func NewDashboardService(t *gotext.Locale, conf *koanf.Koanf, task biz.TaskRepo, website biz.WebsiteRepo, appRepo biz.AppRepo, setting biz.SettingRepo, cron biz.CronRepo, backupRepo biz.BackupRepo) *DashboardService { - return &DashboardService{ +func NewHomeService(t *gotext.Locale, conf *koanf.Koanf, task biz.TaskRepo, website biz.WebsiteRepo, appRepo biz.AppRepo, setting biz.SettingRepo, cron biz.CronRepo, backupRepo biz.BackupRepo) *HomeService { + return &HomeService{ t: t, api: api.NewAPI(app.Version, app.Locale), conf: conf, @@ -52,7 +52,7 @@ func NewDashboardService(t *gotext.Locale, conf *koanf.Koanf, task biz.TaskRepo, } } -func (s *DashboardService) Panel(w http.ResponseWriter, r *http.Request) { +func (s *HomeService) Panel(w http.ResponseWriter, r *http.Request) { name, _ := s.settingRepo.Get(biz.SettingKeyName) if name == "" { name = s.t.Get("AcePanel") @@ -64,7 +64,7 @@ func (s *DashboardService) Panel(w http.ResponseWriter, r *http.Request) { }) } -func (s *DashboardService) HomeApps(w http.ResponseWriter, r *http.Request) { +func (s *HomeService) Apps(w http.ResponseWriter, r *http.Request) { apps, err := s.appRepo.GetHomeShow() if err != nil { Error(w, http.StatusInternalServerError, s.t.Get("failed to get home apps: %v", err)) @@ -74,8 +74,8 @@ func (s *DashboardService) HomeApps(w http.ResponseWriter, r *http.Request) { Success(w, apps) } -func (s *DashboardService) Current(w http.ResponseWriter, r *http.Request) { - req, err := Bind[request.DashboardCurrent](r) +func (s *HomeService) Current(w http.ResponseWriter, r *http.Request) { + req, err := Bind[request.HomeCurrent](r) if err != nil { Error(w, http.StatusUnprocessableEntity, "%v", err) return @@ -84,7 +84,7 @@ func (s *DashboardService) Current(w http.ResponseWriter, r *http.Request) { Success(w, tools.CurrentInfo(req.Nets, req.Disks)) } -func (s *DashboardService) SystemInfo(w http.ResponseWriter, r *http.Request) { +func (s *HomeService) SystemInfo(w http.ResponseWriter, r *http.Request) { hostInfo, err := host.Info() if err != nil { Error(w, http.StatusInternalServerError, s.t.Get("failed to get system info: %v", err)) @@ -130,7 +130,7 @@ func (s *DashboardService) SystemInfo(w http.ResponseWriter, r *http.Request) { }) } -func (s *DashboardService) CountInfo(w http.ResponseWriter, r *http.Request) { +func (s *HomeService) CountInfo(w http.ResponseWriter, r *http.Request) { websiteCount, err := s.websiteRepo.Count() if err != nil { Error(w, http.StatusInternalServerError, s.t.Get("failed to get the total number of websites: %v", err)) @@ -190,7 +190,7 @@ func (s *DashboardService) CountInfo(w http.ResponseWriter, r *http.Request) { }) } -func (s *DashboardService) InstalledDbAndPhp(w http.ResponseWriter, r *http.Request) { +func (s *HomeService) InstalledDbAndPhp(w http.ResponseWriter, r *http.Request) { mysqlInstalled, _ := s.appRepo.IsInstalled("slug = ?", "mysql") postgresqlInstalled, _ := s.appRepo.IsInstalled("slug = ?", "postgresql") php, _ := s.appRepo.GetInstalledAll("slug like ?", "php%") @@ -223,7 +223,7 @@ func (s *DashboardService) InstalledDbAndPhp(w http.ResponseWriter, r *http.Requ }) } -func (s *DashboardService) CheckUpdate(w http.ResponseWriter, r *http.Request) { +func (s *HomeService) CheckUpdate(w http.ResponseWriter, r *http.Request) { if offline, _ := s.settingRepo.GetBool(biz.SettingKeyOfflineMode); offline { Error(w, http.StatusForbidden, s.t.Get("unable to check for updates in offline mode")) return @@ -259,7 +259,7 @@ func (s *DashboardService) CheckUpdate(w http.ResponseWriter, r *http.Request) { }) } -func (s *DashboardService) UpdateInfo(w http.ResponseWriter, r *http.Request) { +func (s *HomeService) UpdateInfo(w http.ResponseWriter, r *http.Request) { if offline, _ := s.settingRepo.GetBool(biz.SettingKeyOfflineMode); offline { Error(w, http.StatusForbidden, s.t.Get("unable to check for updates in offline mode")) return @@ -297,7 +297,7 @@ func (s *DashboardService) UpdateInfo(w http.ResponseWriter, r *http.Request) { Success(w, versions) } -func (s *DashboardService) Update(w http.ResponseWriter, r *http.Request) { +func (s *HomeService) Update(w http.ResponseWriter, r *http.Request) { if offline, _ := s.settingRepo.GetBool(biz.SettingKeyOfflineMode); offline { Error(w, http.StatusForbidden, s.t.Get("unable to update in offline mode")) return @@ -334,7 +334,7 @@ func (s *DashboardService) Update(w http.ResponseWriter, r *http.Request) { tools.RestartPanel() } -func (s *DashboardService) Restart(w http.ResponseWriter, r *http.Request) { +func (s *HomeService) Restart(w http.ResponseWriter, r *http.Request) { if s.taskRepo.HasRunningTask() { Error(w, http.StatusInternalServerError, s.t.Get("background task is running, restart is prohibited, please try again later")) return diff --git a/internal/service/service.go b/internal/service/service.go index 9d9ac57b..23e01a69 100644 --- a/internal/service/service.go +++ b/internal/service/service.go @@ -16,12 +16,12 @@ var ProviderSet = wire.NewSet( NewContainerNetworkService, NewContainerVolumeService, NewCronService, - NewDashboardService, NewDatabaseService, NewDatabaseServerService, NewDatabaseUserService, NewFileService, NewFirewallService, + NewHomeService, NewMonitorService, NewProcessService, NewSafeService, diff --git a/web/src/api/panel/dashboard/index.ts b/web/src/api/panel/dashboard/index.ts deleted file mode 100644 index c8dcb391..00000000 --- a/web/src/api/panel/dashboard/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { http } from '@/utils' - -export default { - // 面板信息 - panel: (): any => http.Get('/dashboard/panel'), - // 首页应用 - homeApps: (): any => http.Get('/dashboard/home_apps'), - // 实时信息 - current: (nets: string[], disks: string[]): any => - http.Post('/dashboard/current', { nets, disks }, { meta: { noAlert: true } }), - // 系统信息 - systemInfo: (): any => http.Get('/dashboard/system_info'), - // 统计信息 - countInfo: (): any => http.Get('/dashboard/count_info'), - // 已安装的数据库和PHP - installedDbAndPhp: (): any => http.Get('/dashboard/installed_db_and_php'), - // 检查更新 - checkUpdate: (): any => http.Get('/dashboard/check_update'), - // 更新日志 - updateInfo: (): any => http.Get('/dashboard/update_info'), - // 更新面板 - update: (): any => http.Post('/dashboard/update'), - // 重启面板 - restart: (): any => http.Post('/dashboard/restart') -} diff --git a/web/src/api/panel/home/index.ts b/web/src/api/panel/home/index.ts new file mode 100644 index 00000000..4e2882c4 --- /dev/null +++ b/web/src/api/panel/home/index.ts @@ -0,0 +1,25 @@ +import { http } from '@/utils' + +export default { + // 面板信息 + panel: (): any => http.Get('/home/panel'), + // 首页应用 + apps: (): any => http.Get('/home/apps'), + // 实时信息 + current: (nets: string[], disks: string[]): any => + http.Post('/home/current', { nets, disks }, { meta: { noAlert: true } }), + // 系统信息 + systemInfo: (): any => http.Get('/home/system_info'), + // 统计信息 + countInfo: (): any => http.Get('/home/count_info'), + // 已安装的数据库和PHP + installedDbAndPhp: (): any => http.Get('/home/installed_db_and_php'), + // 检查更新 + checkUpdate: (): any => http.Get('/home/check_update'), + // 更新日志 + updateInfo: (): any => http.Get('/home/update_info'), + // 更新面板 + update: (): any => http.Post('/home/update'), + // 重启面板 + restart: (): any => http.Post('/home/restart') +} diff --git a/web/src/layout/sidebar/components/SideLogo.vue b/web/src/layout/sidebar/components/SideLogo.vue index 758d06d6..6e3c0e69 100644 --- a/web/src/layout/sidebar/components/SideLogo.vue +++ b/web/src/layout/sidebar/components/SideLogo.vue @@ -6,13 +6,13 @@ const themeStore = useThemeStore() const router = useRouter() const logo = computed(() => themeStore.logo || logoImg) -const toDashboard = () => { - router.push({ name: 'dashboard' }) +const toHome = () => { + router.push({ name: 'home' }) }