mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-10-11 00:00:30 +00:00
Compare commits
33
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
96ab4c53af | ||
|
|
96cf46d834 | ||
|
|
208414704d | ||
|
|
7f453aa145 | ||
|
|
123997fa13 | ||
|
|
7faef2f8a7 | ||
|
|
f93cf3b996 | ||
|
|
df5b69756c | ||
|
|
745bb98abe | ||
|
|
cf1d02771f | ||
|
|
52377b0042 | ||
|
|
270501a237 | ||
|
|
2e5283b8d3 | ||
|
|
8cad47b29e | ||
|
|
2458d60d80 | ||
|
|
9a79dc4cdd | ||
|
|
e531b509d6 | ||
|
|
d287fc1186 | ||
|
|
f47f7c7361 | ||
|
|
7a6c99d57d | ||
|
|
5105114321 | ||
|
|
60beebcb4c | ||
|
|
fa03b4226a | ||
|
|
b047a053c5 | ||
|
|
42907cd228 | ||
|
|
425892cfc4 | ||
|
|
16fd804e93 | ||
|
|
2f147dde13 | ||
|
|
0d04f07f2a | ||
|
|
96485218b7 | ||
|
|
227cc57426 | ||
|
|
b99061777a | ||
|
|
8749dc649a |
@@ -2,7 +2,6 @@ package v1
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
||||
@@ -57,7 +56,7 @@ func (b *BaseApi) LoadDashboardBaseInfo(c *gin.Context) {
|
||||
// @Tags Dashboard
|
||||
// @Summary Load dashboard current info
|
||||
// @Description 获取首页实时数据
|
||||
// @Accept json
|
||||
// @Accept json、
|
||||
// @Param request body dto.DashboardReq true "request"
|
||||
// @Success 200 {object} dto.DashboardCurrent
|
||||
// @Security ApiKeyAuth
|
||||
|
||||
@@ -62,7 +62,7 @@ func (b *BaseApi) CreateRuntime(c *gin.Context) {
|
||||
// @Success 200
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /runtimes/del [post]
|
||||
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"删除运行环境 [name]","formatEN":"Delete runtime [name]"}
|
||||
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"删除网站 [name]","formatEN":"Delete website [name]"}
|
||||
func (b *BaseApi) DeleteRuntime(c *gin.Context) {
|
||||
var req request.RuntimeDelete
|
||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package dto
|
||||
|
||||
type CreateOrUpdateAlert struct {
|
||||
AlertTitle string `json:"alertTitle"`
|
||||
AlertType string `json:"alertType"`
|
||||
AlertCount uint `json:"alertCount"`
|
||||
EntryID uint `json:"entryID"`
|
||||
}
|
||||
|
||||
type AlertBase struct {
|
||||
AlertType string `json:"alertType"`
|
||||
EntryID uint `json:"entryID"`
|
||||
}
|
||||
|
||||
type PushAlert struct {
|
||||
TaskName string `json:"taskName"`
|
||||
AlertType string `json:"alertType"`
|
||||
EntryID uint `json:"entryID"`
|
||||
Param string `json:"param"`
|
||||
}
|
||||
@@ -33,6 +33,7 @@ type ClamInfo struct {
|
||||
LastHandleDate string `json:"lastHandleDate"`
|
||||
Spec string `json:"spec"`
|
||||
Description string `json:"description"`
|
||||
AlertCount uint `json:"alertCount"`
|
||||
}
|
||||
|
||||
type ClamLogSearch struct {
|
||||
@@ -71,6 +72,8 @@ type ClamCreate struct {
|
||||
InfectedDir string `json:"infectedDir"`
|
||||
Spec string `json:"spec"`
|
||||
Description string `json:"description"`
|
||||
AlertCount uint `json:"alertCount"`
|
||||
AlertTitle string `json:"alertTitle"`
|
||||
}
|
||||
|
||||
type ClamUpdate struct {
|
||||
|
||||
@@ -218,7 +218,7 @@ type ComposeCreate struct {
|
||||
}
|
||||
type ComposeOperation struct {
|
||||
Name string `json:"name" validate:"required"`
|
||||
Path string `json:"path"`
|
||||
Path string `json:"path" validate:"required"`
|
||||
Operation string `json:"operation" validate:"required,oneof=up start stop down delete"`
|
||||
WithFile bool `json:"withFile"`
|
||||
}
|
||||
|
||||
@@ -31,10 +31,13 @@ type CronjobCreate struct {
|
||||
DefaultDownload string `json:"defaultDownload"`
|
||||
RetainCopies int `json:"retainCopies" validate:"number,min=1"`
|
||||
Secret string `json:"secret"`
|
||||
AlertCount uint `json:"alertCount"`
|
||||
AlertTitle string `json:"alertTitle"`
|
||||
}
|
||||
|
||||
type CronjobUpdate struct {
|
||||
ID uint `json:"id" validate:"required"`
|
||||
Type string `json:"type" validate:"required"`
|
||||
Name string `json:"name" validate:"required"`
|
||||
Spec string `json:"spec" validate:"required"`
|
||||
|
||||
@@ -53,6 +56,8 @@ type CronjobUpdate struct {
|
||||
DefaultDownload string `json:"defaultDownload"`
|
||||
RetainCopies int `json:"retainCopies" validate:"number,min=1"`
|
||||
Secret string `json:"secret"`
|
||||
AlertCount uint `json:"alertCount"`
|
||||
AlertTitle string `json:"alertTitle"`
|
||||
}
|
||||
|
||||
type CronjobUpdateStatus struct {
|
||||
@@ -99,6 +104,7 @@ type CronjobInfo struct {
|
||||
LastRecordTime string `json:"lastRecordTime"`
|
||||
Status string `json:"status"`
|
||||
Secret string `json:"secret"`
|
||||
AlertCount uint `json:"alertCount"`
|
||||
}
|
||||
|
||||
type SearchRecord struct {
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -154,6 +155,16 @@ func (c *ClamService) SearchWithPage(req dto.SearchClamWithPage) (int64, interfa
|
||||
}
|
||||
datas[i].LastHandleDate = t1.Format(constant.DateTimeLayout)
|
||||
}
|
||||
alertBase := dto.AlertBase{
|
||||
AlertType: "clams",
|
||||
EntryID: datas[i].ID,
|
||||
}
|
||||
alertCount := xpack.GetAlert(alertBase)
|
||||
if alertCount != 0 {
|
||||
datas[i].AlertCount = alertCount
|
||||
} else {
|
||||
datas[i].AlertCount = 0
|
||||
}
|
||||
}
|
||||
return total, datas, err
|
||||
}
|
||||
@@ -180,6 +191,19 @@ func (c *ClamService) Create(req dto.ClamCreate) error {
|
||||
if err := clamRepo.Create(&clam); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if req.AlertCount != 0 {
|
||||
createAlert := dto.CreateOrUpdateAlert{
|
||||
AlertTitle: req.AlertTitle,
|
||||
AlertCount: req.AlertCount,
|
||||
AlertType: "clams",
|
||||
EntryID: clam.ID,
|
||||
}
|
||||
err := xpack.CreateAlert(createAlert)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -225,6 +249,16 @@ func (c *ClamService) Update(req dto.ClamUpdate) error {
|
||||
if err := clamRepo.Update(req.ID, upMap); err != nil {
|
||||
return err
|
||||
}
|
||||
updateAlert := dto.CreateOrUpdateAlert{
|
||||
AlertTitle: req.AlertTitle,
|
||||
AlertType: "clams",
|
||||
AlertCount: req.AlertCount,
|
||||
EntryID: clam.ID,
|
||||
}
|
||||
err := xpack.UpdateAlert(updateAlert)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -265,6 +299,14 @@ func (c *ClamService) Delete(req dto.ClamDelete) error {
|
||||
if err := clamRepo.Delete(commonRepo.WithByID(id)); err != nil {
|
||||
return err
|
||||
}
|
||||
alertBase := dto.AlertBase{
|
||||
AlertType: "clams",
|
||||
EntryID: clam.ID,
|
||||
}
|
||||
err := xpack.DeleteAlert(alertBase)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -305,6 +347,7 @@ func (c *ClamService) HandleOnce(req dto.OperateByID) error {
|
||||
}
|
||||
global.LOG.Debugf("clamdscan --fdpass %s %s -l %s", strategy, clam.Path, logFile)
|
||||
stdout, err := cmd.Execf("clamdscan --fdpass %s %s -l %s", strategy, clam.Path, logFile)
|
||||
handleAlert(stdout, clam.Name, clam.ID)
|
||||
if err != nil {
|
||||
global.LOG.Errorf("clamdscan failed, stdout: %v, err: %v", stdout, err)
|
||||
}
|
||||
@@ -585,3 +628,28 @@ func (c *ClamService) loadLogPath(name string) string {
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
func handleAlert(stdout, clamName string, clamId uint) {
|
||||
if strings.Contains(stdout, "- SCAN SUMMARY -") {
|
||||
lines := strings.Split(stdout, "\n")
|
||||
for _, line := range lines {
|
||||
if strings.HasPrefix(line, "Infected files: ") {
|
||||
var infectedFiles = 0
|
||||
infectedFiles, _ = strconv.Atoi(strings.TrimPrefix(line, "Infected files: "))
|
||||
if infectedFiles > 0 {
|
||||
pushAlert := dto.PushAlert{
|
||||
TaskName: clamName,
|
||||
AlertType: "clams",
|
||||
EntryID: clamId,
|
||||
Param: strconv.Itoa(infectedFiles),
|
||||
}
|
||||
err := xpack.PushAlert(pushAlert)
|
||||
if err != nil {
|
||||
global.LOG.Errorf("clamdscan push failed, err: %v", err)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,10 +252,6 @@ func (u *ContainerService) CreateCompose(req dto.ComposeCreate) (string, error)
|
||||
}
|
||||
|
||||
func (u *ContainerService) ComposeOperation(req dto.ComposeOperation) error {
|
||||
if len(req.Path) == 0 && req.Operation == "delete" {
|
||||
_ = composeRepo.DeleteRecord(commonRepo.WithByName(req.Name))
|
||||
return nil
|
||||
}
|
||||
if cmd.CheckIllegal(req.Path, req.Operation) {
|
||||
return buserr.New(constant.ErrCmdIllegal)
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
"github.com/1Panel-dev/1Panel/backend/app/model"
|
||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
||||
"github.com/1Panel-dev/1Panel/backend/global"
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/xpack"
|
||||
"github.com/jinzhu/copier"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/robfig/cron/v3"
|
||||
@@ -53,6 +54,16 @@ func (u *CronjobService) SearchWithPage(search dto.PageCronjob) (int64, interfac
|
||||
} else {
|
||||
item.LastRecordTime = "-"
|
||||
}
|
||||
alertBase := dto.AlertBase{
|
||||
AlertType: cronjob.Type,
|
||||
EntryID: cronjob.ID,
|
||||
}
|
||||
alertCount := xpack.GetAlert(alertBase)
|
||||
if alertCount != 0 {
|
||||
item.AlertCount = alertCount
|
||||
} else {
|
||||
item.AlertCount = 0
|
||||
}
|
||||
dtoCronjobs = append(dtoCronjobs, item)
|
||||
}
|
||||
return total, dtoCronjobs, err
|
||||
@@ -190,6 +201,18 @@ func (u *CronjobService) Create(cronjobDto dto.CronjobCreate) error {
|
||||
if err := cronjobRepo.Create(&cronjob); err != nil {
|
||||
return err
|
||||
}
|
||||
if cronjobDto.AlertCount != 0 {
|
||||
createAlert := dto.CreateOrUpdateAlert{
|
||||
AlertTitle: cronjobDto.AlertTitle,
|
||||
AlertCount: cronjobDto.AlertCount,
|
||||
AlertType: cronjob.Type,
|
||||
EntryID: cronjob.ID,
|
||||
}
|
||||
err := xpack.CreateAlert(createAlert)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -232,6 +255,14 @@ func (u *CronjobService) Delete(req dto.CronjobBatchDelete) error {
|
||||
if err := cronjobRepo.Delete(commonRepo.WithByID(id)); err != nil {
|
||||
return err
|
||||
}
|
||||
alertBase := dto.AlertBase{
|
||||
AlertType: cronjob.Type,
|
||||
EntryID: cronjob.ID,
|
||||
}
|
||||
err := xpack.DeleteAlert(alertBase)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -281,7 +312,21 @@ func (u *CronjobService) Update(id uint, req dto.CronjobUpdate) error {
|
||||
upMap["default_download"] = req.DefaultDownload
|
||||
upMap["retain_copies"] = req.RetainCopies
|
||||
upMap["secret"] = req.Secret
|
||||
return cronjobRepo.Update(id, upMap)
|
||||
err = cronjobRepo.Update(id, upMap)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
updateAlert := dto.CreateOrUpdateAlert{
|
||||
AlertTitle: req.AlertTitle,
|
||||
AlertType: cronModel.Type,
|
||||
AlertCount: req.AlertCount,
|
||||
EntryID: cronModel.ID,
|
||||
}
|
||||
err = xpack.UpdateAlert(updateAlert)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (u *CronjobService) UpdateStatus(id uint, status string) error {
|
||||
@@ -293,6 +338,7 @@ func (u *CronjobService) UpdateStatus(id uint, status string) error {
|
||||
entryIDs string
|
||||
err error
|
||||
)
|
||||
|
||||
if status == constant.StatusEnable {
|
||||
entryIDs, err = u.StartJob(&cronjob, false)
|
||||
if err != nil {
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/1Panel-dev/1Panel/backend/buserr"
|
||||
"github.com/1Panel-dev/1Panel/backend/i18n"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
||||
"github.com/1Panel-dev/1Panel/backend/app/model"
|
||||
"github.com/1Panel-dev/1Panel/backend/app/repo"
|
||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
||||
@@ -20,6 +21,7 @@ import (
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/cmd"
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/files"
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/ntp"
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/xpack"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
@@ -90,6 +92,7 @@ func (u *CronjobService) HandleJob(cronjob *model.Cronjob) {
|
||||
record.Records, _ = mkdirAndWriteFile(cronjob, record.StartTime, message)
|
||||
}
|
||||
cronjobRepo.EndRecords(record, constant.StatusFailed, err.Error(), record.Records)
|
||||
handleCronJobAlert(cronjob)
|
||||
return
|
||||
}
|
||||
if len(message) != 0 {
|
||||
@@ -391,3 +394,17 @@ func (u *CronjobService) generateLogsPath(cronjob model.Cronjob, startTime time.
|
||||
func hasBackup(cronjobType string) bool {
|
||||
return cronjobType == "app" || cronjobType == "database" || cronjobType == "website" || cronjobType == "directory" || cronjobType == "snapshot" || cronjobType == "log"
|
||||
}
|
||||
|
||||
func handleCronJobAlert(cronjob *model.Cronjob) {
|
||||
pushAlert := dto.PushAlert{
|
||||
TaskName: cronjob.Name,
|
||||
AlertType: cronjob.Type,
|
||||
EntryID: cronjob.ID,
|
||||
Param: cronjob.Type,
|
||||
}
|
||||
err := xpack.PushAlert(pushAlert)
|
||||
if err != nil {
|
||||
global.LOG.Errorf("cronjob alert push failed, err: %v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,11 +84,8 @@ func (u *ImageRepoService) Create(req dto.ImageRepoCreate) error {
|
||||
if imageRepo.ID != 0 {
|
||||
return constant.ErrRecordExist
|
||||
}
|
||||
|
||||
if req.Protocol == "http" {
|
||||
if err := u.handleRegistries(req.DownloadUrl, "", "create"); err != nil {
|
||||
return fmt.Errorf("create registry %s failed, err: %v", req.DownloadUrl, err)
|
||||
}
|
||||
_ = u.handleRegistries(req.DownloadUrl, "", "create")
|
||||
if err := validateDockerConfig(); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -117,18 +114,23 @@ func (u *ImageRepoService) Create(req dto.ImageRepoCreate) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if req.Auth {
|
||||
if err := u.CheckConn(req.DownloadUrl, req.Username, req.Password); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if err := copier.Copy(&imageRepo, &req); err != nil {
|
||||
return errors.WithMessage(constant.ErrStructTransform, err.Error())
|
||||
}
|
||||
|
||||
imageRepo.Status = constant.StatusSuccess
|
||||
return imageRepoRepo.Create(&imageRepo)
|
||||
if req.Auth {
|
||||
if err := u.CheckConn(req.DownloadUrl, req.Username, req.Password); err != nil {
|
||||
imageRepo.Status = constant.StatusFailed
|
||||
imageRepo.Message = err.Error()
|
||||
}
|
||||
}
|
||||
if err := imageRepoRepo.Create(&imageRepo); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (u *ImageRepoService) BatchDelete(req dto.ImageRepoDelete) error {
|
||||
@@ -154,47 +156,33 @@ func (u *ImageRepoService) Update(req dto.ImageRepoUpdate) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if repo.Protocol == "http" && req.Protocol == "https" {
|
||||
if err := u.handleRegistries("", repo.DownloadUrl, "delete"); err != nil {
|
||||
return fmt.Errorf("delete registry %s failed, err: %v", repo.DownloadUrl, err)
|
||||
}
|
||||
}
|
||||
if repo.Protocol == "http" && req.Protocol == "http" {
|
||||
if err := u.handleRegistries(req.DownloadUrl, repo.DownloadUrl, "update"); err != nil {
|
||||
return fmt.Errorf("update registry %s => %s failed, err: %v", repo.DownloadUrl, req.DownloadUrl, err)
|
||||
}
|
||||
}
|
||||
if repo.Protocol == "https" && req.Protocol == "http" {
|
||||
if err := u.handleRegistries(req.DownloadUrl, "", "create"); err != nil {
|
||||
return fmt.Errorf("create registry %s failed, err: %v", req.DownloadUrl, err)
|
||||
}
|
||||
}
|
||||
if repo.Auth != req.Auth || repo.DownloadUrl != req.DownloadUrl {
|
||||
if repo.DownloadUrl != req.DownloadUrl || (!repo.Auth && req.Auth) {
|
||||
_ = u.handleRegistries(req.DownloadUrl, repo.DownloadUrl, "update")
|
||||
if repo.Auth {
|
||||
_, _ = cmd.ExecWithCheck("docker", "logout", repo.DownloadUrl)
|
||||
}
|
||||
if req.Auth {
|
||||
if err := u.CheckConn(req.DownloadUrl, req.Username, req.Password); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := validateDockerConfig(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := restartDocker(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if err := validateDockerConfig(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := restartDocker(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
upMap := make(map[string]interface{})
|
||||
upMap["download_url"] = req.DownloadUrl
|
||||
upMap["protocol"] = req.Protocol
|
||||
upMap["username"] = req.Username
|
||||
upMap["password"] = req.Password
|
||||
upMap["auth"] = req.Auth
|
||||
|
||||
upMap["status"] = constant.StatusSuccess
|
||||
upMap["message"] = ""
|
||||
if req.Auth {
|
||||
if err := u.CheckConn(req.DownloadUrl, req.Username, req.Password); err != nil {
|
||||
upMap["status"] = constant.StatusFailed
|
||||
upMap["message"] = err.Error()
|
||||
}
|
||||
}
|
||||
return imageRepoRepo.Update(req.ID, upMap)
|
||||
}
|
||||
|
||||
|
||||
@@ -309,10 +309,6 @@ func (w WebsiteService) CreateWebsite(create request.WebsiteCreate) (err error)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err = docker.CreateDefaultDockerNetwork(); err != nil {
|
||||
err = buserr.WithDetail(constant.Err1PanelNetworkFailed, err.Error(), nil)
|
||||
return
|
||||
}
|
||||
website.RuntimeID = runtime.ID
|
||||
switch runtime.Type {
|
||||
case constant.RuntimePHP:
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
||||
"github.com/1Panel-dev/1Panel/backend/app/model"
|
||||
"github.com/1Panel-dev/1Panel/backend/app/repo"
|
||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
||||
@@ -14,6 +15,7 @@ import (
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/cmd"
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/common"
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/encrypt"
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/xpack"
|
||||
)
|
||||
|
||||
func Init() {
|
||||
@@ -126,11 +128,24 @@ func handleSnapStatus() {
|
||||
}
|
||||
|
||||
func handleCronjobStatus() {
|
||||
_ = global.DB.Model(&model.JobRecords{}).Where("status = ?", constant.StatusWaiting).
|
||||
Updates(map[string]interface{}{
|
||||
"status": constant.StatusFailed,
|
||||
"message": "the task was interrupted due to the restart of the 1panel service",
|
||||
}).Error
|
||||
var jobRecords []model.JobRecords
|
||||
_ = global.DB.Where("status = ?", constant.StatusWaiting).Find(&jobRecords).Error
|
||||
for _, record := range jobRecords {
|
||||
err := global.DB.Model(&model.JobRecords{}).Where("status = ?", constant.StatusWaiting).
|
||||
Updates(map[string]interface{}{
|
||||
"status": constant.StatusFailed,
|
||||
"message": "the task was interrupted due to the restart of the 1panel service",
|
||||
}).Error
|
||||
|
||||
if err != nil {
|
||||
global.LOG.Errorf("Failed to update job ID: %v, Error:%v", record.ID, err)
|
||||
continue
|
||||
}
|
||||
|
||||
var cronjob *model.Cronjob
|
||||
_ = global.DB.Where("id = ?", record.CronjobID).First(&cronjob).Error
|
||||
handleCronJobAlert(cronjob)
|
||||
}
|
||||
}
|
||||
|
||||
func loadLocalDir() {
|
||||
@@ -178,8 +193,6 @@ func handleUserInfo(tags string, settingRepo repo.ISettingRepo) {
|
||||
if err := settingRepo.Update("SecurityEntrance", common.RandStrAndNum(10)); err != nil {
|
||||
global.LOG.Fatalf("init entrance before start failed, err: %v", err)
|
||||
}
|
||||
sudo := cmd.SudoHandleCmd()
|
||||
_, _ = cmd.Execf("%s sed -i '/CHANGE_USER_INFO=%v/d' /usr/local/bin/1pctl", sudo, global.CONF.System.ChangeUserInfo)
|
||||
return
|
||||
}
|
||||
if strings.Contains(global.CONF.System.ChangeUserInfo, "username") {
|
||||
@@ -212,3 +225,20 @@ func initDir() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func handleCronJobAlert(cronjob *model.Cronjob) {
|
||||
if cronjob.Type == "snapshot" {
|
||||
return
|
||||
}
|
||||
pushAlert := dto.PushAlert{
|
||||
TaskName: cronjob.Name,
|
||||
AlertType: cronjob.Type,
|
||||
EntryID: cronjob.ID,
|
||||
Param: cronjob.Type,
|
||||
}
|
||||
err := xpack.PushAlert(pushAlert)
|
||||
if err != nil {
|
||||
global.LOG.Errorf("cronjob alert push failed, err: %v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
||||
"github.com/1Panel-dev/1Panel/backend/app/model"
|
||||
"github.com/1Panel-dev/1Panel/backend/buserr"
|
||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
||||
@@ -39,3 +40,23 @@ func LoadXpuInfo() []interface{} {
|
||||
func StartClam(startClam model.Clam, isUpdate bool) (int, error) {
|
||||
return 0, buserr.New(constant.ErrXpackNotFound)
|
||||
}
|
||||
|
||||
func CreateAlert(createAlert dto.CreateOrUpdateAlert) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func UpdateAlert(updateAlert dto.CreateOrUpdateAlert) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func DeleteAlert(alertBase dto.AlertBase) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetAlert(alertBase dto.AlertBase) uint {
|
||||
return 0
|
||||
}
|
||||
|
||||
func PushAlert(pushAlert dto.PushAlert) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ system:
|
||||
db_file: 1Panel.db
|
||||
base_dir: /opt
|
||||
mode: dev
|
||||
repo_url: https://resource.fit2cloud.com/1panel/package/aliyun
|
||||
repo_url: https://resource.fit2cloud.com/1panel/package
|
||||
app_repo: https://apps-assets.fit2cloud.com
|
||||
is_demo: false
|
||||
port: 9999
|
||||
|
||||
+20
-192
@@ -3872,8 +3872,8 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/dashboard/current": {
|
||||
"post": {
|
||||
"/dashboard/current/:ioOption/:netOption": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
@@ -3889,13 +3889,18 @@ const docTemplate = `{
|
||||
"summary": "Load dashboard current info",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "request",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.DashboardReq"
|
||||
}
|
||||
"name": "ioOption",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "request",
|
||||
"name": "netOption",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
@@ -9125,8 +9130,8 @@ const docTemplate = `{
|
||||
"bodyKeys": [
|
||||
"id"
|
||||
],
|
||||
"formatEN": "Delete runtime [name]",
|
||||
"formatZH": "删除运行环境 [name]",
|
||||
"formatEN": "Delete website [name]",
|
||||
"formatZH": "删除网站 [name]",
|
||||
"paramKeys": []
|
||||
}
|
||||
}
|
||||
@@ -10803,7 +10808,7 @@ const docTemplate = `{
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.PageSnapshot"
|
||||
"$ref": "#/definitions/dto.SearchWithPage"
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -10817,39 +10822,6 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/settings/snapshot/size": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "获取系统快照大小",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"System Setting"
|
||||
],
|
||||
"summary": "Load system snapshot size",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "request",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.PageSnapshot"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/settings/snapshot/status": {
|
||||
"post": {
|
||||
"security": [
|
||||
@@ -15619,12 +15591,6 @@ const docTemplate = `{
|
||||
"dto.ClamCreate": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"alertCount": {
|
||||
"type": "integer"
|
||||
},
|
||||
"alertTitle": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -15723,12 +15689,6 @@ const docTemplate = `{
|
||||
"dto.ClamUpdate": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"alertCount": {
|
||||
"type": "integer"
|
||||
},
|
||||
"alertTitle": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -15845,9 +15805,6 @@ const docTemplate = `{
|
||||
"detailName": {
|
||||
"type": "string"
|
||||
},
|
||||
"fileName": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -15919,12 +15876,6 @@ const docTemplate = `{
|
||||
"from"
|
||||
],
|
||||
"properties": {
|
||||
"env": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"file": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -15951,7 +15902,8 @@ const docTemplate = `{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name",
|
||||
"operation"
|
||||
"operation",
|
||||
"path"
|
||||
],
|
||||
"properties": {
|
||||
"name": {
|
||||
@@ -15960,11 +15912,9 @@ const docTemplate = `{
|
||||
"operation": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"up",
|
||||
"start",
|
||||
"stop",
|
||||
"down",
|
||||
"delete"
|
||||
"down"
|
||||
]
|
||||
},
|
||||
"path": {
|
||||
@@ -16037,12 +15987,6 @@ const docTemplate = `{
|
||||
"content": {
|
||||
"type": "string"
|
||||
},
|
||||
"env": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -16218,7 +16162,6 @@ const docTemplate = `{
|
||||
"operation": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"up",
|
||||
"start",
|
||||
"stop",
|
||||
"restart",
|
||||
@@ -16366,12 +16309,6 @@ const docTemplate = `{
|
||||
"type"
|
||||
],
|
||||
"properties": {
|
||||
"alertCount": {
|
||||
"type": "integer"
|
||||
},
|
||||
"alertTitle": {
|
||||
"type": "string"
|
||||
},
|
||||
"appID": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -16446,16 +16383,9 @@ const docTemplate = `{
|
||||
"required": [
|
||||
"id",
|
||||
"name",
|
||||
"spec",
|
||||
"type"
|
||||
"spec"
|
||||
],
|
||||
"properties": {
|
||||
"alertCount": {
|
||||
"type": "integer"
|
||||
},
|
||||
"alertTitle": {
|
||||
"type": "string"
|
||||
},
|
||||
"appID": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -16502,9 +16432,6 @@ const docTemplate = `{
|
||||
"spec": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"type": "string"
|
||||
},
|
||||
"url": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -16630,9 +16557,6 @@ const docTemplate = `{
|
||||
"dto.DashboardBase": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"SystemProxy": {
|
||||
"type": "string"
|
||||
},
|
||||
"appInstalledNumber": {
|
||||
"type": "integer"
|
||||
},
|
||||
@@ -16657,9 +16581,6 @@ const docTemplate = `{
|
||||
"hostname": {
|
||||
"type": "string"
|
||||
},
|
||||
"ipv4Addr": {
|
||||
"type": "string"
|
||||
},
|
||||
"kernelArch": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -16784,26 +16705,6 @@ const docTemplate = `{
|
||||
},
|
||||
"uptime": {
|
||||
"type": "integer"
|
||||
},
|
||||
"xpuData": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/dto.XPUInfo"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.DashboardReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"ioOption": {
|
||||
"type": "string"
|
||||
},
|
||||
"netOption": {
|
||||
"type": "string"
|
||||
},
|
||||
"scope": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -18707,41 +18608,6 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.PageSnapshot": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"order",
|
||||
"orderBy",
|
||||
"page",
|
||||
"pageSize"
|
||||
],
|
||||
"properties": {
|
||||
"info": {
|
||||
"type": "string"
|
||||
},
|
||||
"order": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"null",
|
||||
"ascending",
|
||||
"descending"
|
||||
]
|
||||
},
|
||||
"orderBy": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"name",
|
||||
"created_at"
|
||||
]
|
||||
},
|
||||
"page": {
|
||||
"type": "integer"
|
||||
},
|
||||
"pageSize": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.PasswordUpdate": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
@@ -19407,9 +19273,6 @@ const docTemplate = `{
|
||||
"sslType"
|
||||
],
|
||||
"properties": {
|
||||
"autoRestart": {
|
||||
"type": "string"
|
||||
},
|
||||
"cert": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -19638,9 +19501,6 @@ const docTemplate = `{
|
||||
"appStoreVersion": {
|
||||
"type": "string"
|
||||
},
|
||||
"autoRestart": {
|
||||
"type": "string"
|
||||
},
|
||||
"bindAddress": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -20065,32 +19925,6 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.XPUInfo": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"deviceID": {
|
||||
"type": "integer"
|
||||
},
|
||||
"deviceName": {
|
||||
"type": "string"
|
||||
},
|
||||
"memory": {
|
||||
"type": "string"
|
||||
},
|
||||
"memoryUsed": {
|
||||
"type": "string"
|
||||
},
|
||||
"memoryUtil": {
|
||||
"type": "string"
|
||||
},
|
||||
"power": {
|
||||
"type": "string"
|
||||
},
|
||||
"temperature": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"files.FileInfo": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -22600,9 +22434,6 @@ const docTemplate = `{
|
||||
"proxyPass": {
|
||||
"type": "string"
|
||||
},
|
||||
"proxySSLName": {
|
||||
"type": "string"
|
||||
},
|
||||
"replaces": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
@@ -22645,9 +22476,6 @@ const docTemplate = `{
|
||||
"ID": {
|
||||
"type": "integer"
|
||||
},
|
||||
"disableLog": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"nameservers": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
|
||||
+20
-192
@@ -3866,8 +3866,8 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/dashboard/current": {
|
||||
"post": {
|
||||
"/dashboard/current/:ioOption/:netOption": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
@@ -3883,13 +3883,18 @@
|
||||
"summary": "Load dashboard current info",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "request",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.DashboardReq"
|
||||
}
|
||||
"name": "ioOption",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "request",
|
||||
"name": "netOption",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
@@ -9119,8 +9124,8 @@
|
||||
"bodyKeys": [
|
||||
"id"
|
||||
],
|
||||
"formatEN": "Delete runtime [name]",
|
||||
"formatZH": "删除运行环境 [name]",
|
||||
"formatEN": "Delete website [name]",
|
||||
"formatZH": "删除网站 [name]",
|
||||
"paramKeys": []
|
||||
}
|
||||
}
|
||||
@@ -10797,7 +10802,7 @@
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.PageSnapshot"
|
||||
"$ref": "#/definitions/dto.SearchWithPage"
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -10811,39 +10816,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/settings/snapshot/size": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "获取系统快照大小",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"System Setting"
|
||||
],
|
||||
"summary": "Load system snapshot size",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "request",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.PageSnapshot"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/settings/snapshot/status": {
|
||||
"post": {
|
||||
"security": [
|
||||
@@ -15613,12 +15585,6 @@
|
||||
"dto.ClamCreate": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"alertCount": {
|
||||
"type": "integer"
|
||||
},
|
||||
"alertTitle": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -15717,12 +15683,6 @@
|
||||
"dto.ClamUpdate": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"alertCount": {
|
||||
"type": "integer"
|
||||
},
|
||||
"alertTitle": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -15839,9 +15799,6 @@
|
||||
"detailName": {
|
||||
"type": "string"
|
||||
},
|
||||
"fileName": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -15913,12 +15870,6 @@
|
||||
"from"
|
||||
],
|
||||
"properties": {
|
||||
"env": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"file": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -15945,7 +15896,8 @@
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name",
|
||||
"operation"
|
||||
"operation",
|
||||
"path"
|
||||
],
|
||||
"properties": {
|
||||
"name": {
|
||||
@@ -15954,11 +15906,9 @@
|
||||
"operation": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"up",
|
||||
"start",
|
||||
"stop",
|
||||
"down",
|
||||
"delete"
|
||||
"down"
|
||||
]
|
||||
},
|
||||
"path": {
|
||||
@@ -16031,12 +15981,6 @@
|
||||
"content": {
|
||||
"type": "string"
|
||||
},
|
||||
"env": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -16212,7 +16156,6 @@
|
||||
"operation": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"up",
|
||||
"start",
|
||||
"stop",
|
||||
"restart",
|
||||
@@ -16360,12 +16303,6 @@
|
||||
"type"
|
||||
],
|
||||
"properties": {
|
||||
"alertCount": {
|
||||
"type": "integer"
|
||||
},
|
||||
"alertTitle": {
|
||||
"type": "string"
|
||||
},
|
||||
"appID": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -16440,16 +16377,9 @@
|
||||
"required": [
|
||||
"id",
|
||||
"name",
|
||||
"spec",
|
||||
"type"
|
||||
"spec"
|
||||
],
|
||||
"properties": {
|
||||
"alertCount": {
|
||||
"type": "integer"
|
||||
},
|
||||
"alertTitle": {
|
||||
"type": "string"
|
||||
},
|
||||
"appID": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -16496,9 +16426,6 @@
|
||||
"spec": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"type": "string"
|
||||
},
|
||||
"url": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -16624,9 +16551,6 @@
|
||||
"dto.DashboardBase": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"SystemProxy": {
|
||||
"type": "string"
|
||||
},
|
||||
"appInstalledNumber": {
|
||||
"type": "integer"
|
||||
},
|
||||
@@ -16651,9 +16575,6 @@
|
||||
"hostname": {
|
||||
"type": "string"
|
||||
},
|
||||
"ipv4Addr": {
|
||||
"type": "string"
|
||||
},
|
||||
"kernelArch": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -16778,26 +16699,6 @@
|
||||
},
|
||||
"uptime": {
|
||||
"type": "integer"
|
||||
},
|
||||
"xpuData": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/dto.XPUInfo"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.DashboardReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"ioOption": {
|
||||
"type": "string"
|
||||
},
|
||||
"netOption": {
|
||||
"type": "string"
|
||||
},
|
||||
"scope": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -18701,41 +18602,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.PageSnapshot": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"order",
|
||||
"orderBy",
|
||||
"page",
|
||||
"pageSize"
|
||||
],
|
||||
"properties": {
|
||||
"info": {
|
||||
"type": "string"
|
||||
},
|
||||
"order": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"null",
|
||||
"ascending",
|
||||
"descending"
|
||||
]
|
||||
},
|
||||
"orderBy": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"name",
|
||||
"created_at"
|
||||
]
|
||||
},
|
||||
"page": {
|
||||
"type": "integer"
|
||||
},
|
||||
"pageSize": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.PasswordUpdate": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
@@ -19401,9 +19267,6 @@
|
||||
"sslType"
|
||||
],
|
||||
"properties": {
|
||||
"autoRestart": {
|
||||
"type": "string"
|
||||
},
|
||||
"cert": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -19632,9 +19495,6 @@
|
||||
"appStoreVersion": {
|
||||
"type": "string"
|
||||
},
|
||||
"autoRestart": {
|
||||
"type": "string"
|
||||
},
|
||||
"bindAddress": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -20059,32 +19919,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.XPUInfo": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"deviceID": {
|
||||
"type": "integer"
|
||||
},
|
||||
"deviceName": {
|
||||
"type": "string"
|
||||
},
|
||||
"memory": {
|
||||
"type": "string"
|
||||
},
|
||||
"memoryUsed": {
|
||||
"type": "string"
|
||||
},
|
||||
"memoryUtil": {
|
||||
"type": "string"
|
||||
},
|
||||
"power": {
|
||||
"type": "string"
|
||||
},
|
||||
"temperature": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"files.FileInfo": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -22594,9 +22428,6 @@
|
||||
"proxyPass": {
|
||||
"type": "string"
|
||||
},
|
||||
"proxySSLName": {
|
||||
"type": "string"
|
||||
},
|
||||
"replaces": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
@@ -22639,9 +22470,6 @@
|
||||
"ID": {
|
||||
"type": "integer"
|
||||
},
|
||||
"disableLog": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"nameservers": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
|
||||
+14
-128
@@ -233,10 +233,6 @@ definitions:
|
||||
type: object
|
||||
dto.ClamCreate:
|
||||
properties:
|
||||
alertCount:
|
||||
type: integer
|
||||
alertTitle:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
infectedDir:
|
||||
@@ -301,10 +297,6 @@ definitions:
|
||||
type: object
|
||||
dto.ClamUpdate:
|
||||
properties:
|
||||
alertCount:
|
||||
type: integer
|
||||
alertTitle:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
id:
|
||||
@@ -379,8 +371,6 @@ definitions:
|
||||
properties:
|
||||
detailName:
|
||||
type: string
|
||||
fileName:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
secret:
|
||||
@@ -434,10 +424,6 @@ definitions:
|
||||
type: object
|
||||
dto.ComposeCreate:
|
||||
properties:
|
||||
env:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
file:
|
||||
type: string
|
||||
from:
|
||||
@@ -461,11 +447,9 @@ definitions:
|
||||
type: string
|
||||
operation:
|
||||
enum:
|
||||
- up
|
||||
- start
|
||||
- stop
|
||||
- down
|
||||
- delete
|
||||
type: string
|
||||
path:
|
||||
type: string
|
||||
@@ -474,6 +458,7 @@ definitions:
|
||||
required:
|
||||
- name
|
||||
- operation
|
||||
- path
|
||||
type: object
|
||||
dto.ComposeTemplateCreate:
|
||||
properties:
|
||||
@@ -512,10 +497,6 @@ definitions:
|
||||
properties:
|
||||
content:
|
||||
type: string
|
||||
env:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
name:
|
||||
type: string
|
||||
path:
|
||||
@@ -633,7 +614,6 @@ definitions:
|
||||
type: array
|
||||
operation:
|
||||
enum:
|
||||
- up
|
||||
- start
|
||||
- stop
|
||||
- restart
|
||||
@@ -733,10 +713,6 @@ definitions:
|
||||
type: object
|
||||
dto.CronjobCreate:
|
||||
properties:
|
||||
alertCount:
|
||||
type: integer
|
||||
alertTitle:
|
||||
type: string
|
||||
appID:
|
||||
type: string
|
||||
backupAccounts:
|
||||
@@ -789,10 +765,6 @@ definitions:
|
||||
type: object
|
||||
dto.CronjobUpdate:
|
||||
properties:
|
||||
alertCount:
|
||||
type: integer
|
||||
alertTitle:
|
||||
type: string
|
||||
appID:
|
||||
type: string
|
||||
backupAccounts:
|
||||
@@ -824,8 +796,6 @@ definitions:
|
||||
type: string
|
||||
spec:
|
||||
type: string
|
||||
type:
|
||||
type: string
|
||||
url:
|
||||
type: string
|
||||
website:
|
||||
@@ -834,7 +804,6 @@ definitions:
|
||||
- id
|
||||
- name
|
||||
- spec
|
||||
- type
|
||||
type: object
|
||||
dto.CronjobUpdateStatus:
|
||||
properties:
|
||||
@@ -914,8 +883,6 @@ definitions:
|
||||
type: object
|
||||
dto.DashboardBase:
|
||||
properties:
|
||||
SystemProxy:
|
||||
type: string
|
||||
appInstalledNumber:
|
||||
type: integer
|
||||
cpuCores:
|
||||
@@ -932,8 +899,6 @@ definitions:
|
||||
type: integer
|
||||
hostname:
|
||||
type: string
|
||||
ipv4Addr:
|
||||
type: string
|
||||
kernelArch:
|
||||
type: string
|
||||
kernelVersion:
|
||||
@@ -1017,19 +982,6 @@ definitions:
|
||||
type: string
|
||||
uptime:
|
||||
type: integer
|
||||
xpuData:
|
||||
items:
|
||||
$ref: '#/definitions/dto.XPUInfo'
|
||||
type: array
|
||||
type: object
|
||||
dto.DashboardReq:
|
||||
properties:
|
||||
ioOption:
|
||||
type: string
|
||||
netOption:
|
||||
type: string
|
||||
scope:
|
||||
type: string
|
||||
type: object
|
||||
dto.DatabaseCreate:
|
||||
properties:
|
||||
@@ -2326,31 +2278,6 @@ definitions:
|
||||
total:
|
||||
type: integer
|
||||
type: object
|
||||
dto.PageSnapshot:
|
||||
properties:
|
||||
info:
|
||||
type: string
|
||||
order:
|
||||
enum:
|
||||
- "null"
|
||||
- ascending
|
||||
- descending
|
||||
type: string
|
||||
orderBy:
|
||||
enum:
|
||||
- name
|
||||
- created_at
|
||||
type: string
|
||||
page:
|
||||
type: integer
|
||||
pageSize:
|
||||
type: integer
|
||||
required:
|
||||
- order
|
||||
- orderBy
|
||||
- page
|
||||
- pageSize
|
||||
type: object
|
||||
dto.PasswordUpdate:
|
||||
properties:
|
||||
newPassword:
|
||||
@@ -2796,8 +2723,6 @@ definitions:
|
||||
type: object
|
||||
dto.SSLUpdate:
|
||||
properties:
|
||||
autoRestart:
|
||||
type: string
|
||||
cert:
|
||||
type: string
|
||||
domain:
|
||||
@@ -2957,8 +2882,6 @@ definitions:
|
||||
type: string
|
||||
appStoreVersion:
|
||||
type: string
|
||||
autoRestart:
|
||||
type: string
|
||||
bindAddress:
|
||||
type: string
|
||||
bindDomain:
|
||||
@@ -3238,23 +3161,6 @@ definitions:
|
||||
type:
|
||||
type: string
|
||||
type: object
|
||||
dto.XPUInfo:
|
||||
properties:
|
||||
deviceID:
|
||||
type: integer
|
||||
deviceName:
|
||||
type: string
|
||||
memory:
|
||||
type: string
|
||||
memoryUsed:
|
||||
type: string
|
||||
memoryUtil:
|
||||
type: string
|
||||
power:
|
||||
type: string
|
||||
temperature:
|
||||
type: string
|
||||
type: object
|
||||
files.FileInfo:
|
||||
properties:
|
||||
content:
|
||||
@@ -4930,8 +4836,6 @@ definitions:
|
||||
type: string
|
||||
proxyPass:
|
||||
type: string
|
||||
proxySSLName:
|
||||
type: string
|
||||
replaces:
|
||||
additionalProperties:
|
||||
type: string
|
||||
@@ -4964,8 +4868,6 @@ definitions:
|
||||
properties:
|
||||
ID:
|
||||
type: integer
|
||||
disableLog:
|
||||
type: boolean
|
||||
nameservers:
|
||||
items:
|
||||
type: string
|
||||
@@ -8079,18 +7981,22 @@ paths:
|
||||
summary: Load os info
|
||||
tags:
|
||||
- Dashboard
|
||||
/dashboard/current:
|
||||
post:
|
||||
/dashboard/current/:ioOption/:netOption:
|
||||
get:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 获取首页实时数据
|
||||
parameters:
|
||||
- description: request
|
||||
in: body
|
||||
name: request
|
||||
in: path
|
||||
name: ioOption
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/dto.DashboardReq'
|
||||
type: string
|
||||
- description: request
|
||||
in: path
|
||||
name: netOption
|
||||
required: true
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
@@ -11404,8 +11310,8 @@ paths:
|
||||
BeforeFunctions: []
|
||||
bodyKeys:
|
||||
- id
|
||||
formatEN: Delete runtime [name]
|
||||
formatZH: 删除运行环境 [name]
|
||||
formatEN: Delete website [name]
|
||||
formatZH: 删除网站 [name]
|
||||
paramKeys: []
|
||||
/runtimes/node/modules:
|
||||
post:
|
||||
@@ -12462,7 +12368,7 @@ paths:
|
||||
name: request
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/dto.PageSnapshot'
|
||||
$ref: '#/definitions/dto.SearchWithPage'
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
@@ -12473,26 +12379,6 @@ paths:
|
||||
summary: Page system snapshot
|
||||
tags:
|
||||
- System Setting
|
||||
/settings/snapshot/size:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 获取系统快照大小
|
||||
parameters:
|
||||
- description: request
|
||||
in: body
|
||||
name: request
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/dto.PageSnapshot'
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
security:
|
||||
- ApiKeyAuth: []
|
||||
summary: Load system snapshot size
|
||||
tags:
|
||||
- System Setting
|
||||
/settings/snapshot/status:
|
||||
post:
|
||||
consumes:
|
||||
|
||||
@@ -30,6 +30,9 @@ export namespace Cronjob {
|
||||
retainCopies: number;
|
||||
status: string;
|
||||
secret: string;
|
||||
hasAlert: boolean;
|
||||
alertCount: number;
|
||||
alertTitle: string;
|
||||
}
|
||||
export interface CronjobCreate {
|
||||
name: string;
|
||||
|
||||
@@ -139,6 +139,9 @@ export namespace Toolbox {
|
||||
spec: string;
|
||||
specObj: Cronjob.SpecObj;
|
||||
description: string;
|
||||
hasAlert: boolean;
|
||||
alertCount: number;
|
||||
alertTitle: string;
|
||||
}
|
||||
export interface ClamCreate {
|
||||
name: string;
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-dialog class="level-up-pro" v-model="open" :close-on-click-modal="false" @close="handleClose">
|
||||
<div style="text-align: center" v-loading="loading">
|
||||
<span class="text-3xl font-medium title">{{ $t('license.levelUpPro') }}</span>
|
||||
<el-row type="flex" justify="center" class="mt-6">
|
||||
<el-col :span="22">
|
||||
<el-upload
|
||||
action="#"
|
||||
:auto-upload="false"
|
||||
ref="uploadRef"
|
||||
class="upload-demo"
|
||||
drag
|
||||
:limit="1"
|
||||
:on-change="fileOnChange"
|
||||
:on-exceed="handleExceed"
|
||||
v-model:file-list="uploaderFiles"
|
||||
>
|
||||
<el-icon class="el-icon--upload"><upload-filled /></el-icon>
|
||||
<div class="el-upload__text">
|
||||
{{ $t('license.importHelper') }}
|
||||
</div>
|
||||
</el-upload>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-button
|
||||
type="primary"
|
||||
class="mt-3 w-52"
|
||||
:disabled="loading || uploaderFiles.length == 0"
|
||||
plain
|
||||
@click="submit"
|
||||
>
|
||||
{{ $t('license.power') }}
|
||||
</el-button>
|
||||
<div class="mt-3 mb-5">
|
||||
<el-button text type="primary" @click="toHalo">{{ $t('license.knowMorePro') }}</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import i18n from '@/lang';
|
||||
import { ref } from 'vue';
|
||||
import { MsgSuccess } from '@/utils/message';
|
||||
import { UploadFileData } from '@/api/modules/setting';
|
||||
import { GlobalStore } from '@/store';
|
||||
import { UploadFile, UploadFiles, UploadInstance, UploadProps, UploadRawFile, genFileId } from 'element-plus';
|
||||
import { useTheme } from '@/hooks/use-theme';
|
||||
import { getXpackSetting } from '@/utils/xpack';
|
||||
const globalStore = GlobalStore();
|
||||
|
||||
const { switchTheme } = useTheme();
|
||||
const loading = ref(false);
|
||||
const open = ref(false);
|
||||
const uploadRef = ref<UploadInstance>();
|
||||
const uploaderFiles = ref<UploadFiles>([]);
|
||||
|
||||
const handleClose = () => {
|
||||
open.value = false;
|
||||
uploadRef.value!.clearFiles();
|
||||
};
|
||||
|
||||
const fileOnChange = (_uploadFile: UploadFile, uploadFiles: UploadFiles) => {
|
||||
uploaderFiles.value = uploadFiles;
|
||||
};
|
||||
|
||||
const handleExceed: UploadProps['onExceed'] = (files) => {
|
||||
uploadRef.value!.clearFiles();
|
||||
const file = files[0] as UploadRawFile;
|
||||
file.uid = genFileId();
|
||||
uploadRef.value!.handleStart(file);
|
||||
};
|
||||
|
||||
const toHalo = () => {
|
||||
window.open('https://www.lxware.cn/1panel' + '', '_blank', 'noopener,noreferrer');
|
||||
};
|
||||
|
||||
const submit = async () => {
|
||||
if (uploaderFiles.value.length !== 1) {
|
||||
return;
|
||||
}
|
||||
const file = uploaderFiles.value[0];
|
||||
const formData = new FormData();
|
||||
formData.append('file', file.raw);
|
||||
loading.value = true;
|
||||
await UploadFileData(formData)
|
||||
.then(async () => {
|
||||
globalStore.isProductPro = true;
|
||||
const xpackRes = await getXpackSetting();
|
||||
if (xpackRes) {
|
||||
globalStore.themeConfig.isGold = xpackRes.data.theme === 'dark-gold';
|
||||
}
|
||||
loading.value = false;
|
||||
switchTheme();
|
||||
uploadRef.value!.clearFiles();
|
||||
uploaderFiles.value = [];
|
||||
open.value = false;
|
||||
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
|
||||
window.location.reload();
|
||||
})
|
||||
.catch(() => {
|
||||
loading.value = false;
|
||||
uploadRef.value!.clearFiles();
|
||||
uploaderFiles.value = [];
|
||||
});
|
||||
};
|
||||
|
||||
const acceptParams = () => {
|
||||
uploaderFiles.value = [];
|
||||
uploadRef.value?.clearFiles();
|
||||
open.value = true;
|
||||
};
|
||||
|
||||
defineExpose({
|
||||
acceptParams,
|
||||
});
|
||||
</script>
|
||||
@@ -16,6 +16,11 @@
|
||||
<el-divider v-if="!mobile" direction="vertical" />
|
||||
</div>
|
||||
<div class="flex flex-wrap">
|
||||
<el-button type="primary" link @click="toHalo">
|
||||
<span class="font-normal">
|
||||
{{ isProductPro ? $t('license.pro') : $t('license.community') }}
|
||||
</span>
|
||||
</el-button>
|
||||
<span class="version" @click="copyText(version)">{{ version }}</span>
|
||||
<el-badge is-dot style="margin-top: -3px" v-if="version !== 'Waiting' && globalStore.hasNewVersion">
|
||||
<el-button type="primary" link @click="onLoadUpgradeInfo">
|
||||
@@ -121,6 +126,10 @@ const handleClose = () => {
|
||||
drawerVisible.value = false;
|
||||
};
|
||||
|
||||
const toHalo = () => {
|
||||
window.open('https://www.lxware.cn/1panel' + '', '_blank', 'noopener,noreferrer');
|
||||
};
|
||||
|
||||
const toDoc = () => {
|
||||
window.open('https://1panel.cn/docs/', '_blank', 'noopener,noreferrer');
|
||||
};
|
||||
|
||||
@@ -1101,6 +1101,7 @@ const message = {
|
||||
clam: {
|
||||
clam: 'Virus Scan',
|
||||
cron: 'Scheduled scan',
|
||||
cronHelper: 'Professional version supports scheduled scan feature',
|
||||
specErr: 'Execution schedule format error, please check and retry!',
|
||||
disableMsg:
|
||||
'Stopping scheduled execution will prevent this scan task from running automatically. Do you want to continue?',
|
||||
@@ -1139,8 +1140,8 @@ const message = {
|
||||
clamLog: 'Scan Logs',
|
||||
freshClam: 'Update Virus Definitions',
|
||||
freshClamLog: 'Update Virus Definitions Logs',
|
||||
alertHelper: 'Professional version supports SMS alert',
|
||||
alertTitle: 'Virus scanning 「{0}」 task failed alert',
|
||||
alertHelper: 'Professional version supports scheduled scan and SMS alert',
|
||||
alertTitle: 'Virus scan task 「{0}」 detected infected file alert',
|
||||
},
|
||||
},
|
||||
logs: {
|
||||
@@ -1664,6 +1665,49 @@ const message = {
|
||||
compressPassword: 'Compression Password',
|
||||
backupRecoverMessage: 'Please enter the compression or decompression password (leave blank to not set)',
|
||||
},
|
||||
license: {
|
||||
community: 'Community Edition: ',
|
||||
community2: 'Community Edition',
|
||||
pro: 'Professional Edition: ',
|
||||
trial: 'Trial Edition',
|
||||
office: 'Official Edition',
|
||||
trialInfo: 'Version',
|
||||
authorizationId: 'Subscription Authorization ID',
|
||||
authorizedUser: 'Authorized User',
|
||||
expiresAt: 'Expiry Date',
|
||||
productName: 'Product Name',
|
||||
productStatus: 'Product Status',
|
||||
Lost01: 'Lost * 1',
|
||||
Lost02: 'Lost * 2',
|
||||
Lost03: 'Lost',
|
||||
Enable: 'Enabled',
|
||||
Disable: 'Disabled',
|
||||
lostHelper:
|
||||
'The License needs to be periodically synchronized for availability. Please ensure normal external network access. After three losses of connection, the License binding will be released.',
|
||||
quickUpdate: 'Quick Update',
|
||||
import: 'Import',
|
||||
power: 'Authorize',
|
||||
unbind: 'Unbind License',
|
||||
unbindHelper: 'All Pro related Settings will be cleared after unbinding. Do you want to continue? ',
|
||||
importLicense: 'Import License',
|
||||
importHelper: 'Please click or drag the license file here',
|
||||
technicalAdvice: 'Technical Advice',
|
||||
advice: 'Consultation',
|
||||
indefinitePeriod: 'Indefinite Period',
|
||||
levelUpPro: 'Upgrade to Professional Edition',
|
||||
licenseSync: 'License Sync',
|
||||
knowMorePro: 'Learn More',
|
||||
closeAlert: 'The current page can be closed in the panel settings',
|
||||
introduce: 'Feature Introduction',
|
||||
waf: 'Upgrading to the professional version can provide features such as interception map, logs, block records, geographical location blocking, custom rules, custom interception pages, etc.',
|
||||
tamper: 'Upgrading to the professional version can protect websites from unauthorized modifications or tampering.',
|
||||
gpu: 'Upgrading to the professional version can help users visually monitor important parameters of GPU such as workload, temperature, memory usage in real time.',
|
||||
setting:
|
||||
'Upgrading to the professional version allows customization of panel logo, welcome message, and other information.',
|
||||
monitor:
|
||||
'Upgrade to the professional version to view the real-time status of the website, visitor trends, visitor sources, request logs and other information. ',
|
||||
alert: 'Upgrade to the professional version to receive alarm information via SMS and view alarm logs, fully control various key events, and ensure worry-free system operation',
|
||||
},
|
||||
clean: {
|
||||
scan: 'Start Scanning',
|
||||
scanHelper: 'Easily tidy up junk files accumulated during 1Panel runtime',
|
||||
|
||||
@@ -1038,6 +1038,7 @@ const message = {
|
||||
clam: {
|
||||
clam: '病毒掃描',
|
||||
cron: '定時掃描',
|
||||
cronHelper: '專業版支持定時掃描功能',
|
||||
specErr: '執行周期格式錯誤,請檢查後重試!',
|
||||
disableMsg: '停止定時執行會導致該掃描任務不再自動執行。是否繼續?',
|
||||
enableMsg: '啟用定時執行會讓該掃描任務定期自動執行。是否繼續?',
|
||||
@@ -1073,8 +1074,8 @@ const message = {
|
||||
clamLog: '掃描日誌',
|
||||
freshClam: '病毒庫刷新配置',
|
||||
freshClamLog: '病毒庫刷新日誌',
|
||||
alertHelper: '專業版支持短信告警功能',
|
||||
alertTitle: '病毒掃描「{0}」任務失敗告警',
|
||||
alertHelper: '專業版支持定時掃描和短信告警功能',
|
||||
alertTitle: '病毒掃描「{0}」任務检测到感染文件告警',
|
||||
},
|
||||
},
|
||||
logs: {
|
||||
@@ -1311,8 +1312,8 @@ const message = {
|
||||
systemIP: '伺服器地址',
|
||||
proxy: '代理伺服器',
|
||||
proxyHelper: '設置代理伺服器後,將在以下場景中生效:',
|
||||
proxyHelper1: '應用商店的安裝包下載和同步',
|
||||
proxyHelper2: '系統版本升級及獲取更新說明',
|
||||
proxyHelper1: '應用商店的安裝包下載和同步(專業版功能)',
|
||||
proxyHelper2: '系統版本升級及獲取更新說明(專業版功能)',
|
||||
proxyHelper3: '系統許可證的驗證和同步',
|
||||
proxyType: '代理類型',
|
||||
proxyUrl: '代理地址',
|
||||
@@ -1543,6 +1544,46 @@ const message = {
|
||||
compressPassword: '壓縮密碼',
|
||||
backupRecoverMessage: '請輸入壓縮或解壓縮密碼(留空則不設定)',
|
||||
},
|
||||
license: {
|
||||
community: '社區版:',
|
||||
community2: '社區版',
|
||||
pro: '專業版:',
|
||||
trial: '試用版',
|
||||
office: '正式版',
|
||||
trialInfo: '版本',
|
||||
authorizationId: '訂閱授權 ID',
|
||||
authorizedUser: '被授權方',
|
||||
expiresAt: '到期時間',
|
||||
productName: '產品名稱',
|
||||
productStatus: '產品狀態',
|
||||
Lost01: '失聯 * 1',
|
||||
Lost02: '失聯 * 2',
|
||||
Lost03: '已失聯',
|
||||
Enable: '已啟用',
|
||||
Disable: '未啟用',
|
||||
lostHelper: '許可證需要定時同步是否可用,請保證正常外網訪問,失聯三次後將解除許可證綁定',
|
||||
quickUpdate: '快速更新',
|
||||
import: '導入',
|
||||
power: '授 權',
|
||||
unbind: '解除綁定',
|
||||
unbindHelper: '解除綁定後將清除所有專業版相關設置,是否繼續?',
|
||||
importLicense: '導入許可證',
|
||||
importHelper: '請點擊或拖動許可文件到此處',
|
||||
technicalAdvice: '技術諮詢',
|
||||
advice: '諮詢',
|
||||
indefinitePeriod: '無限期',
|
||||
levelUpPro: '升級專業版',
|
||||
licenseSync: '許可證同步',
|
||||
knowMorePro: '了解更多',
|
||||
closeAlert: '當前頁面可在面板設置中關閉顯示',
|
||||
introduce: '功能介紹',
|
||||
waf: '升級專業版可以獲得攔截地圖、日誌、封鎖記錄、地理位置封禁、自定義規則、自定義攔截頁面等功能。',
|
||||
tamper: '升級專業版可以保護網站免受未經授權的修改或篡改。',
|
||||
gpu: '升級專業版可以幫助用戶實時直觀查看到 GPU 的工作負載、溫度、顯存等重要參數。',
|
||||
setting: '升級專業版可以自定義面板 Logo、歡迎簡介等信息。',
|
||||
monitor: '升級專業版可以查看網站的即時狀態、訪客趨勢、訪客來源、請求日誌等資訊。 ',
|
||||
alert: '陞級專業版可通過簡訊接收告警資訊,並查看告警日誌,全面掌控各類關鍵事件,確保系統運行無憂。',
|
||||
},
|
||||
clean: {
|
||||
scan: '開始掃描',
|
||||
scanHelper: '輕鬆梳理 1Panel 運行期間積累的垃圾文件',
|
||||
@@ -2257,7 +2298,7 @@ const message = {
|
||||
isAlert: '是否告警',
|
||||
alertCount: '告警次數',
|
||||
clamHelper: '掃描到感染檔案時觸發簡訊告警',
|
||||
cronJobHelper: '定時執行計畫任務失敗時觸發簡訊告警',
|
||||
cronJobHelper: '定時任務執行失敗時將觸發簡訊告警',
|
||||
licenseHelper: '專業版支持簡訊告警功能',
|
||||
alertCountHelper: '每日最大告警次數',
|
||||
},
|
||||
|
||||
@@ -1039,6 +1039,7 @@ const message = {
|
||||
clam: {
|
||||
clam: '病毒扫描',
|
||||
cron: '定时扫描',
|
||||
cronHelper: '专业版支持定时扫描功能 ',
|
||||
specErr: '执行周期格式错误,请检查后重试!',
|
||||
disableMsg: '停止定时执行会导致该扫描任务不再自动执行。是否继续?',
|
||||
enableMsg: '启用定时执行会让该扫描任务定期自动执行。是否继续?',
|
||||
@@ -1075,8 +1076,8 @@ const message = {
|
||||
clamLog: '扫描日志',
|
||||
freshClam: '病毒库刷新配置',
|
||||
freshClamLog: '病毒库刷新日志',
|
||||
alertHelper: '专业版支持短信告警功能',
|
||||
alertTitle: '病毒扫描「 {0} 」任务失败告警',
|
||||
alertHelper: '专业版支持定时扫描和短信告警功能',
|
||||
alertTitle: '病毒扫描「 {0} 」任务检测到感染文件告警',
|
||||
},
|
||||
},
|
||||
logs: {
|
||||
@@ -1313,8 +1314,8 @@ const message = {
|
||||
systemIP: '服务器地址',
|
||||
proxy: '代理服务器',
|
||||
proxyHelper: '设置代理服务器后,将在以下场景中生效:',
|
||||
proxyHelper1: '应用商店的安装包下载和同步',
|
||||
proxyHelper2: '系统版本升级及获取更新说明',
|
||||
proxyHelper1: '应用商店的安装包下载和同步(专业版功能)',
|
||||
proxyHelper2: '系统版本升级及获取更新说明(专业版功能)',
|
||||
proxyHelper3: '系统许可证的验证和同步',
|
||||
proxyType: '代理类型',
|
||||
proxyUrl: '代理地址',
|
||||
@@ -1544,6 +1545,46 @@ const message = {
|
||||
compressPassword: '压缩密码',
|
||||
backupRecoverMessage: '请输入压缩或解压缩密码(留空则不设置)',
|
||||
},
|
||||
license: {
|
||||
community: '社区版:',
|
||||
community2: '社区版',
|
||||
pro: '专业版:',
|
||||
trial: '试用版',
|
||||
office: '正式版',
|
||||
trialInfo: '版本',
|
||||
authorizationId: '订阅授权 ID',
|
||||
authorizedUser: '被授权方',
|
||||
expiresAt: '到期时间',
|
||||
productName: '产品名称',
|
||||
productStatus: '产品状态',
|
||||
Lost01: '失联 * 1',
|
||||
Lost02: '失联 * 2',
|
||||
Lost03: '已失联',
|
||||
Enable: '已激活',
|
||||
Disable: '未激活',
|
||||
lostHelper: '许可证需要定时同步是否可用,请保证正常外网访问,失联三次后将解除许可证绑定',
|
||||
quickUpdate: '快速更新',
|
||||
import: '导入',
|
||||
power: '授 权',
|
||||
unbind: '解除绑定',
|
||||
unbindHelper: '解除绑定后将清除所有专业版相关设置,是否继续?',
|
||||
importLicense: '导入许可证',
|
||||
importHelper: '请点击或拖动许可文件到此处',
|
||||
technicalAdvice: '技术咨询',
|
||||
advice: '咨询',
|
||||
indefinitePeriod: '无限期',
|
||||
levelUpPro: '升级专业版',
|
||||
licenseSync: '许可证同步',
|
||||
knowMorePro: '了解更多',
|
||||
closeAlert: '当前页面可在面板设置中关闭显示',
|
||||
introduce: '功能介绍',
|
||||
waf: '升级专业版可以获得拦截地图、日志、封锁记录、地理位置封禁、自定义规则、自定义拦截页面等功能。',
|
||||
tamper: '升级专业版可以保护网站免受未经授权的修改或篡改。',
|
||||
gpu: '升级专业版可以帮助用户实时直观查看到 GPU 的工作负载、温度、显存等重要参数。',
|
||||
setting: '升级专业版可以自定义面板 Logo、欢迎简介等信息。',
|
||||
monitor: '升级专业版可以查看网站的实时状态、访客趋势、访客来源、请求日志等信息。',
|
||||
alert: '升级专业版可通过短信接收告警信息,并查看告警日志,全面掌控各类关键事件,确保系统运行无忧。',
|
||||
},
|
||||
clean: {
|
||||
scan: '开始扫描',
|
||||
scanHelper: '轻松梳理 1Panel 运行期间积累的垃圾文件',
|
||||
@@ -2259,7 +2300,7 @@ const message = {
|
||||
isAlert: '是否告警',
|
||||
alertCount: '告警次数',
|
||||
clamHelper: '扫描到感染文件时触发短信告警',
|
||||
cronJobHelper: '定时执行计划任务失败时触发短信告警',
|
||||
cronJobHelper: '定时任务执行失败时将触发短信告警',
|
||||
licenseHelper: '专业版支持短信告警功能',
|
||||
alertCountHelper: '每日最大告警次数',
|
||||
},
|
||||
|
||||
@@ -100,7 +100,7 @@ onMounted(() => {
|
||||
|
||||
loadStatus();
|
||||
loadProductProFromDB();
|
||||
globalStore.isFullScreen = false;
|
||||
|
||||
const mqList = window.matchMedia('(prefers-color-scheme: dark)');
|
||||
if (mqList.addEventListener) {
|
||||
mqList.addEventListener('change', () => {
|
||||
|
||||
@@ -37,6 +37,16 @@ const settingRouter = {
|
||||
activeMenu: 'Setting',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'license',
|
||||
name: 'License',
|
||||
component: () => import('@/views/setting/license/index.vue'),
|
||||
hidden: true,
|
||||
meta: {
|
||||
requiresAuth: true,
|
||||
activeMenu: 'Setting',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'about',
|
||||
name: 'About',
|
||||
|
||||
@@ -20,6 +20,11 @@ body,
|
||||
height: 12px;
|
||||
}
|
||||
|
||||
.el-switch--small,.is-checked .el-switch__core::after {
|
||||
margin-left: 12px !important;
|
||||
}
|
||||
.el-switch--small.is-checked .el-switch__core::after {
|
||||
margin-left: -13px;
|
||||
}
|
||||
|
||||
.el-alert__title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
@@ -320,6 +320,31 @@
|
||||
</el-form-item>
|
||||
</div>
|
||||
|
||||
<el-form-item prop="hasAlert">
|
||||
<el-checkbox v-model="dialogData.rowData!.hasAlert" :label="$t('alert.isAlert')" />
|
||||
<span class="input-help">{{ $t('alert.cronJobHelper') }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
prop="alertCount"
|
||||
v-if="dialogData.rowData!.hasAlert && isProductPro"
|
||||
:label="$t('alert.alertCount')"
|
||||
>
|
||||
<el-input-number
|
||||
style="width: 200px"
|
||||
:min="1"
|
||||
step-strictly
|
||||
:step="1"
|
||||
v-model.number="dialogData.rowData!.alertCount"
|
||||
></el-input-number>
|
||||
<span class="input-help">{{ $t('alert.alertCountHelper') }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="dialogData.rowData!.hasAlert && !isProductPro">
|
||||
<span>{{ $t('alert.licenseHelper') }}</span>
|
||||
<el-button link type="primary" @click="toUpload">
|
||||
{{ $t('license.levelUpPro') }}
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item :label="$t('cronjob.retainCopies')" prop="retainCopies">
|
||||
<el-input-number
|
||||
style="width: 200px"
|
||||
@@ -361,6 +386,7 @@
|
||||
</el-button>
|
||||
</span>
|
||||
</template>
|
||||
<LicenseImport ref="licenseRef" />
|
||||
</el-drawer>
|
||||
</template>
|
||||
|
||||
@@ -382,6 +408,9 @@ import { listContainer } from '@/api/modules/container';
|
||||
import { Database } from '@/api/interface/database';
|
||||
import { ListAppInstalled } from '@/api/modules/app';
|
||||
import { loadDefaultSpec, specOptions, transObjToSpec, transSpecToObj, weekOptions } from './../helper';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { GlobalStore } from '@/store';
|
||||
import LicenseImport from '@/components/license-import/index.vue';
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
@@ -397,6 +426,10 @@ const dialogData = ref<DialogProps>({
|
||||
title: '',
|
||||
});
|
||||
|
||||
const globalStore = GlobalStore();
|
||||
const licenseRef = ref();
|
||||
const { isProductPro } = storeToRefs(globalStore);
|
||||
|
||||
const acceptParams = (params: DialogProps): void => {
|
||||
dialogData.value = params;
|
||||
if (dialogData.value.rowData?.spec) {
|
||||
@@ -423,6 +456,8 @@ const acceptParams = (params: DialogProps): void => {
|
||||
if (dialogData.value.rowData.dbName) {
|
||||
dialogData.value.rowData.dbNameList = dialogData.value.rowData.dbName.split(',');
|
||||
}
|
||||
dialogData.value.rowData.hasAlert = dialogData.value.rowData!.alertCount > 0;
|
||||
dialogData.value.rowData!.alertCount = dialogData.value.rowData!.alertCount || 3;
|
||||
dialogData.value.rowData!.command = dialogData.value.rowData!.command || 'sh';
|
||||
dialogData.value.rowData!.isCustom =
|
||||
dialogData.value.rowData!.command !== 'sh' &&
|
||||
@@ -560,6 +595,18 @@ const verifySpec = (rule: any, value: any, callback: any) => {
|
||||
callback();
|
||||
};
|
||||
|
||||
function checkSendCount(rule: any, value: any, callback: any) {
|
||||
if (value === '') {
|
||||
callback();
|
||||
}
|
||||
const regex = /^(?:[1-9]|[12][0-9]|30)$/;
|
||||
if (!regex.test(value)) {
|
||||
return callback(new Error(i18n.global.t('commons.rule.numberRange', [1, 30])));
|
||||
}
|
||||
|
||||
callback();
|
||||
}
|
||||
|
||||
const rules = reactive({
|
||||
name: [Rules.requiredInput, Rules.noSpace],
|
||||
type: [Rules.requiredSelect],
|
||||
@@ -578,6 +625,7 @@ const rules = reactive({
|
||||
backupAccounts: [Rules.requiredSelect],
|
||||
defaultDownload: [Rules.requiredSelect],
|
||||
retainCopies: [Rules.number],
|
||||
alertCount: [Rules.integerNumber, { validator: checkSendCount, trigger: 'blur' }],
|
||||
});
|
||||
|
||||
type FormInstance = InstanceType<typeof ElForm>;
|
||||
@@ -756,6 +804,15 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
|
||||
if (dialogData.value?.rowData?.exclusionRules) {
|
||||
dialogData.value.rowData.exclusionRules = dialogData.value.rowData.exclusionRules.replaceAll('\n', ',');
|
||||
}
|
||||
dialogData.value.rowData.alertCount =
|
||||
dialogData.value.rowData!.hasAlert && isProductPro.value ? dialogData.value.rowData.alertCount : 0;
|
||||
dialogData.value.rowData.alertTitle =
|
||||
dialogData.value.rowData!.hasAlert && isProductPro.value
|
||||
? i18n.global.t('cronjob.alertTitle', [
|
||||
i18n.global.t('cronjob.' + dialogData.value.rowData.type),
|
||||
dialogData.value.rowData.name,
|
||||
])
|
||||
: '';
|
||||
if (!dialogData.value.rowData) return;
|
||||
if (dialogData.value.title === 'create') {
|
||||
await addCronjob(dialogData.value.rowData);
|
||||
@@ -770,6 +827,10 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
|
||||
});
|
||||
};
|
||||
|
||||
const toUpload = () => {
|
||||
licenseRef.value.acceptParams();
|
||||
};
|
||||
|
||||
defineExpose({
|
||||
acceptParams,
|
||||
});
|
||||
|
||||
@@ -387,9 +387,7 @@ const onSetting = async () => {
|
||||
};
|
||||
|
||||
const changeDatabase = async () => {
|
||||
if (currentDB.value.from === 'local') {
|
||||
appStatusRef.value.onCheck();
|
||||
}
|
||||
appStatusRef.value.onCheck();
|
||||
for (const item of dbOptionsLocal.value) {
|
||||
if (item.database == currentDBName.value) {
|
||||
currentDB.value = item;
|
||||
|
||||
@@ -350,9 +350,7 @@ const onSetting = async () => {
|
||||
};
|
||||
|
||||
const changeDatabase = async () => {
|
||||
if (currentDB.value.from === 'local') {
|
||||
appStatusRef.value.onCheck();
|
||||
}
|
||||
appStatusRef.value.onCheck();
|
||||
for (const item of dbOptionsLocal.value) {
|
||||
if (item.database == currentDBName.value) {
|
||||
currentDB.value = item;
|
||||
|
||||
@@ -222,9 +222,7 @@ const goRouter = async (target: string) => {
|
||||
};
|
||||
|
||||
const changeDatabase = async () => {
|
||||
if (currentDB.value.from === 'local') {
|
||||
appStatusRef.value.onCheck();
|
||||
}
|
||||
appStatusRef.value.onCheck();
|
||||
for (const item of dbOptionsLocal.value) {
|
||||
if (item.database == currentDBName.value) {
|
||||
currentDB.value = item;
|
||||
|
||||
@@ -7,7 +7,17 @@
|
||||
path: '/',
|
||||
},
|
||||
]"
|
||||
/>
|
||||
>
|
||||
<template #route-button>
|
||||
<div class="router-button">
|
||||
<template v-if="!isProductPro">
|
||||
<el-button link type="primary" @click="toUpload">
|
||||
{{ $t('license.levelUpPro') }}
|
||||
</el-button>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
</RouterButton>
|
||||
|
||||
<el-alert
|
||||
v-if="!isSafety && globalStore.showEntranceWarn"
|
||||
@@ -249,6 +259,8 @@
|
||||
</CardWithHeader>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<LicenseImport ref="licenseRef" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -257,6 +269,7 @@ import { onMounted, onBeforeUnmount, ref, reactive } from 'vue';
|
||||
import Status from '@/views/home/status/index.vue';
|
||||
import App from '@/views/home/app/index.vue';
|
||||
import VCharts from '@/components/v-charts/index.vue';
|
||||
import LicenseImport from '@/components/license-import/index.vue';
|
||||
import CardWithHeader from '@/components/card-with-header/index.vue';
|
||||
import i18n from '@/lang';
|
||||
import { Dashboard } from '@/api/interface/dashboard';
|
||||
@@ -290,6 +303,9 @@ const timeNetDatas = ref<Array<string>>([]);
|
||||
const ioOptions = ref();
|
||||
const netOptions = ref();
|
||||
|
||||
const licenseRef = ref();
|
||||
const isProductPro = ref();
|
||||
|
||||
const searchInfo = reactive({
|
||||
ioOption: 'all',
|
||||
netOption: 'all',
|
||||
@@ -643,7 +659,12 @@ const onBlur = () => {
|
||||
isActive.value = false;
|
||||
};
|
||||
|
||||
const toUpload = () => {
|
||||
licenseRef.value.acceptParams();
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
isProductPro.value = globalStore.isProductPro;
|
||||
window.addEventListener('focus', onFocus);
|
||||
window.addEventListener('blur', onBlur);
|
||||
loadSafeStatus();
|
||||
|
||||
@@ -27,6 +27,10 @@ const buttons = [
|
||||
label: i18n.global.t('setting.snapshot'),
|
||||
path: '/settings/snapshot',
|
||||
},
|
||||
{
|
||||
label: i18n.global.t('setting.license'),
|
||||
path: '/settings/license',
|
||||
},
|
||||
{
|
||||
label: i18n.global.t('setting.about'),
|
||||
path: '/settings/about',
|
||||
|
||||
@@ -0,0 +1,261 @@
|
||||
<template>
|
||||
<div>
|
||||
<LayoutContent v-loading="loading" :title="$t('setting.license')" :divider="true">
|
||||
<template #main>
|
||||
<el-row :gutter="20" class="mt-5; mb-10">
|
||||
<el-col :xs="24" :sm="24" :md="15" :lg="15" :xl="15">
|
||||
<div class="descriptions" v-if="hasLicense">
|
||||
<el-descriptions :column="1" direction="horizontal" size="large" border>
|
||||
<el-descriptions-item :label="$t('license.authorizationId')">
|
||||
{{ license.licenseName || '-' }}
|
||||
<el-button
|
||||
type="primary"
|
||||
class="ml-3"
|
||||
plain
|
||||
@click="onSync"
|
||||
size="small"
|
||||
v-if="showSync()"
|
||||
>
|
||||
{{ $t('commons.button.sync') }}
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="!license.offline"
|
||||
type="primary"
|
||||
class="ml-3"
|
||||
plain
|
||||
@click="onUnBind()"
|
||||
size="small"
|
||||
>
|
||||
{{ $t('license.unbind') }}
|
||||
</el-button>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="$t('license.authorizedUser')">
|
||||
{{ license.assigneeName || '-' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="$t('license.productName')">
|
||||
{{ license.productName || '-' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="$t('license.trialInfo')">
|
||||
{{ license.trial ? $t('license.trial') : $t('license.office') }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="$t('license.expiresAt')">
|
||||
{{ license.expiresAt || '-' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="$t('license.productStatus')">
|
||||
<div v-if="license.status">
|
||||
<el-tooltip
|
||||
v-if="license.status.indexOf('Lost') !== -1"
|
||||
:content="$t('license.lostHelper')"
|
||||
>
|
||||
<el-tag type="info">
|
||||
{{ $t('license.' + license.status) }}
|
||||
</el-tag>
|
||||
</el-tooltip>
|
||||
<el-tag v-else>{{ $t('license.' + license.status) }}</el-tag>
|
||||
</div>
|
||||
<span v-else>-</span>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item class="descriptions" :label="$t('commons.table.message')">
|
||||
{{ license.message }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
|
||||
<CardWithHeader :header="$t('home.overview')" height="160px" v-if="!hasLicense">
|
||||
<template #body>
|
||||
<div class="h-app-card">
|
||||
<el-row>
|
||||
<el-col :span="6">
|
||||
<span>{{ $t('setting.license') }}</span>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<span>{{ $t('license.community2') }}</span>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
</CardWithHeader>
|
||||
</el-col>
|
||||
|
||||
<el-col :xs="24" :sm="24" :md="9" :lg="9" :xl="9">
|
||||
<CardWithHeader :header="$t('license.quickUpdate')" height="160px">
|
||||
<template #body>
|
||||
<div class="h-app-card">
|
||||
<el-row>
|
||||
<el-col :span="15">
|
||||
<div class="h-app-content">{{ $t('license.importLicense') }}:</div>
|
||||
</el-col>
|
||||
<el-col :span="5">
|
||||
<el-button type="primary" plain round size="small" @click="toUpload">
|
||||
{{ $t('license.import') }}
|
||||
</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
<div class="h-app-card">
|
||||
<el-row>
|
||||
<el-col :span="15">
|
||||
<div class="h-app-content">{{ $t('license.technicalAdvice') }}:</div>
|
||||
</el-col>
|
||||
<el-col :span="5">
|
||||
<el-button type="primary" plain round size="small" @click="toHalo()">
|
||||
{{ $t('license.advice') }}
|
||||
</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
</CardWithHeader>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
</LayoutContent>
|
||||
|
||||
<LicenseImport ref="licenseRef" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted } from 'vue';
|
||||
import { getLicense, syncLicense, unbindLicense } from '@/api/modules/setting';
|
||||
import CardWithHeader from '@/components/card-with-header/index.vue';
|
||||
import LicenseImport from '@/components/license-import/index.vue';
|
||||
import i18n from '@/lang';
|
||||
import { MsgSuccess } from '@/utils/message';
|
||||
import { GlobalStore } from '@/store';
|
||||
const loading = ref();
|
||||
const licenseRef = ref();
|
||||
const globalStore = GlobalStore();
|
||||
const hasLicense = ref();
|
||||
|
||||
const license = reactive({
|
||||
licenseName: '',
|
||||
trial: true,
|
||||
offline: true,
|
||||
expiresAt: '',
|
||||
assigneeName: '',
|
||||
productName: '',
|
||||
|
||||
status: '',
|
||||
message: '',
|
||||
});
|
||||
|
||||
const toHalo = () => {
|
||||
window.open('https://www.lxware.cn/1panel' + '', '_blank', 'noopener,noreferrer');
|
||||
};
|
||||
|
||||
const onSync = async () => {
|
||||
loading.value = true;
|
||||
await syncLicense()
|
||||
.then(() => {
|
||||
loading.value = false;
|
||||
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
|
||||
window.location.reload();
|
||||
})
|
||||
.catch(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
};
|
||||
|
||||
const onUnBind = async () => {
|
||||
ElMessageBox.confirm(i18n.global.t('license.unbindHelper'), i18n.global.t('license.unbind'), {
|
||||
confirmButtonText: i18n.global.t('commons.button.confirm'),
|
||||
cancelButtonText: i18n.global.t('commons.button.cancel'),
|
||||
type: 'info',
|
||||
}).then(async () => {
|
||||
loading.value = true;
|
||||
await unbindLicense()
|
||||
.then(() => {
|
||||
loading.value = false;
|
||||
globalStore.isProductPro = false;
|
||||
globalStore.themeConfig.isGold = false;
|
||||
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
|
||||
window.location.reload();
|
||||
})
|
||||
.catch(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const timestampToDate = (timestamp: number) => {
|
||||
const date = new Date(timestamp * 1000);
|
||||
const y = date.getFullYear();
|
||||
let m: string | number = date.getMonth() + 1;
|
||||
m = m < 10 ? `0${String(m)}` : m;
|
||||
let d: string | number = date.getDate();
|
||||
d = d < 10 ? `0${String(d)}` : d;
|
||||
let h: string | number = date.getHours();
|
||||
h = h < 10 ? `0${String(h)}` : h;
|
||||
let minute: string | number = date.getMinutes();
|
||||
minute = minute < 10 ? `0${String(minute)}` : minute;
|
||||
let second: string | number = date.getSeconds();
|
||||
second = second < 10 ? `0${String(second)}` : second;
|
||||
return `${y}-${m}-${d} ${h}:${minute}:${second}`;
|
||||
};
|
||||
|
||||
const search = async () => {
|
||||
loading.value = true;
|
||||
await getLicense()
|
||||
.then((res) => {
|
||||
loading.value = false;
|
||||
license.status = res.data.status;
|
||||
globalStore.isProductPro =
|
||||
res.data.status === 'Enable' || res.data.status === 'Lost01' || res.data.status === 'Lost02';
|
||||
if (res.data.status === '') {
|
||||
hasLicense.value = false;
|
||||
return;
|
||||
}
|
||||
hasLicense.value = true;
|
||||
if (globalStore.isProductPro) {
|
||||
globalStore.productProExpires = Number(res.data.productPro);
|
||||
globalStore.isTrial = res.data.trial;
|
||||
}
|
||||
license.licenseName = res.data.licenseName;
|
||||
license.message = res.data.message;
|
||||
license.assigneeName = res.data.assigneeName;
|
||||
license.trial = res.data.trial;
|
||||
license.offline = res.data.offline;
|
||||
if (res.data.productPro) {
|
||||
license.productName = 'product-1panel-pro';
|
||||
license.expiresAt =
|
||||
res.data.productPro === '0'
|
||||
? i18n.global.t('license.indefinitePeriod')
|
||||
: timestampToDate(Number(res.data.productPro));
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
};
|
||||
|
||||
const showSync = () => {
|
||||
return (license.status.indexOf('Lost') !== -1 || license.status === 'Disable') && !license.offline;
|
||||
};
|
||||
|
||||
const toUpload = () => {
|
||||
licenseRef.value.acceptParams();
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
search();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.h-app-card {
|
||||
padding: 10px 15px;
|
||||
margin-right: 10px;
|
||||
line-height: 18px;
|
||||
&:hover {
|
||||
background-color: rgba(0, 94, 235, 0.03);
|
||||
}
|
||||
}
|
||||
:deep(.el-descriptions__content) {
|
||||
max-width: 300px;
|
||||
}
|
||||
.descriptions {
|
||||
word-break: break-all;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
</style>
|
||||
@@ -126,6 +126,21 @@
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item :label="$t('setting.developerMode')" prop="developerMode">
|
||||
<el-radio-group
|
||||
@change="onSave('DeveloperMode', form.developerMode)"
|
||||
v-model="form.developerMode"
|
||||
>
|
||||
<el-radio-button value="enable">
|
||||
<span>{{ $t('commons.button.enable') }}</span>
|
||||
</el-radio-button>
|
||||
<el-radio-button value="disable">
|
||||
<span>{{ $t('commons.button.disable') }}</span>
|
||||
</el-radio-button>
|
||||
</el-radio-group>
|
||||
<span class="input-help">{{ $t('setting.developerModeHelper') }}</span>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item :label="$t('setting.advancedMenuHide')">
|
||||
<el-input disabled v-model="form.proHideMenus">
|
||||
<template #append>
|
||||
@@ -251,6 +266,7 @@ const search = async () => {
|
||||
form.defaultNetworkVal = res.data.defaultNetwork === 'all' ? i18n.t('commons.table.all') : res.data.defaultNetwork;
|
||||
form.proHideMenus = res.data.xpackHideMenu;
|
||||
form.hideMenuList = res.data.xpackHideMenu;
|
||||
form.developerMode = res.data.developerMode;
|
||||
|
||||
form.proxyUrl = res.data.proxyUrl;
|
||||
form.proxyType = res.data.proxyType;
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
<ul style="margin-left: -20px">
|
||||
<li v-if="isProductPro">{{ $t('setting.proxyHelper1') }}</li>
|
||||
<li v-if="isProductPro">{{ $t('setting.proxyHelper2') }}</li>
|
||||
<li>{{ $t('setting.proxyHelper3') }}</li>
|
||||
</ul>
|
||||
</template>
|
||||
</el-alert>
|
||||
|
||||
@@ -115,6 +115,30 @@
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="hasAlert">
|
||||
<el-checkbox v-model="dialogData.rowData!.hasAlert" :label="$t('alert.isAlert')" />
|
||||
<span class="input-help">{{ $t('alert.clamHelper') }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="(dialogData.rowData!.hasAlert || dialogData.rowData!.hasSpec) && !isProductPro">
|
||||
<span>{{ $t('toolbox.clam.alertHelper') }}</span>
|
||||
<el-button link type="primary" @click="toUpload">
|
||||
{{ $t('license.levelUpPro') }}
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
prop="alertCount"
|
||||
v-if="dialogData.rowData!.hasAlert && isProductPro"
|
||||
:label="$t('alert.alertCount')"
|
||||
>
|
||||
<el-input-number
|
||||
style="width: 200px"
|
||||
:min="1"
|
||||
step-strictly
|
||||
:step="1"
|
||||
v-model.number="dialogData.rowData!.alertCount"
|
||||
></el-input-number>
|
||||
<span class="input-help">{{ $t('alert.alertCountHelper') }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('commons.table.description')" prop="description">
|
||||
<el-input type="textarea" :rows="3" clearable v-model="dialogData.rowData!.description" />
|
||||
</el-form-item>
|
||||
@@ -129,6 +153,7 @@
|
||||
</el-button>
|
||||
</span>
|
||||
</template>
|
||||
<LicenseImport ref="licenseRef" />
|
||||
</el-drawer>
|
||||
</template>
|
||||
|
||||
@@ -138,6 +163,7 @@ import { Rules } from '@/global/form-rules';
|
||||
import FileList from '@/components/file-list/index.vue';
|
||||
import i18n from '@/lang';
|
||||
import { ElForm } from 'element-plus';
|
||||
import LicenseImport from '@/components/license-import/index.vue';
|
||||
import DrawerHeader from '@/components/drawer-header/index.vue';
|
||||
import { MsgError, MsgSuccess } from '@/utils/message';
|
||||
import { Toolbox } from '@/api/interface/toolbox';
|
||||
@@ -147,6 +173,7 @@ import { storeToRefs } from 'pinia';
|
||||
import { GlobalStore } from '@/store';
|
||||
|
||||
const globalStore = GlobalStore();
|
||||
const licenseRef = ref();
|
||||
const { isProductPro } = storeToRefs(globalStore);
|
||||
interface DialogProps {
|
||||
title: string;
|
||||
@@ -175,6 +202,8 @@ const acceptParams = (params: DialogProps): void => {
|
||||
second: 30,
|
||||
};
|
||||
}
|
||||
dialogData.value.rowData.hasAlert = dialogData.value.rowData!.alertCount > 0;
|
||||
dialogData.value.rowData!.alertCount = dialogData.value.rowData!.alertCount || 3;
|
||||
title.value = i18n.global.t('commons.button.' + dialogData.value.title);
|
||||
drawerVisible.value = true;
|
||||
};
|
||||
@@ -268,6 +297,19 @@ const verifySpec = (rule: any, value: any, callback: any) => {
|
||||
}
|
||||
callback();
|
||||
};
|
||||
|
||||
function checkSendCount(rule: any, value: any, callback: any) {
|
||||
if (value === '') {
|
||||
callback();
|
||||
}
|
||||
const regex = /^(?:[1-9]|[12][0-9]|30)$/;
|
||||
if (!regex.test(value)) {
|
||||
return callback(new Error(i18n.global.t('commons.rule.numberRange', [1, 30])));
|
||||
}
|
||||
|
||||
callback();
|
||||
}
|
||||
|
||||
const rules = reactive({
|
||||
name: [Rules.simpleName],
|
||||
path: [Rules.requiredInput, Rules.noSpace],
|
||||
@@ -275,6 +317,7 @@ const rules = reactive({
|
||||
{ validator: verifySpec, trigger: 'blur', required: true },
|
||||
{ validator: verifySpec, trigger: 'change', required: true },
|
||||
],
|
||||
alertCount: [Rules.integerNumber, { validator: checkSendCount, trigger: 'blur' }],
|
||||
});
|
||||
|
||||
type FormInstance = InstanceType<typeof ElForm>;
|
||||
@@ -298,6 +341,10 @@ const hasHour = (item: any) => {
|
||||
return item.specType !== 'perHour' && item.specType !== 'perNMinute' && item.specType !== 'perNSecond';
|
||||
};
|
||||
|
||||
const toUpload = () => {
|
||||
licenseRef.value.acceptParams();
|
||||
};
|
||||
|
||||
const changeSpecType = () => {
|
||||
let item = dialogData.value.rowData!.specObj;
|
||||
switch (item.specType) {
|
||||
@@ -343,6 +390,19 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
|
||||
}
|
||||
dialogData.value.rowData.spec = spec;
|
||||
|
||||
if (dialogData.value.rowData!.hasAlert) {
|
||||
dialogData.value.rowData.alertCount = dialogData.value.rowData!.hasAlert
|
||||
? dialogData.value.rowData.alertCount
|
||||
: 0;
|
||||
dialogData.value.rowData.alertTitle = i18n.global.t('toolbox.clam.alertTitle', [
|
||||
dialogData.value.rowData.name,
|
||||
]);
|
||||
} else {
|
||||
dialogData.value.rowData.alertTitle = '';
|
||||
dialogData.value.rowData.alertCount = 0;
|
||||
dialogData.value.rowData.hasAlert = false;
|
||||
}
|
||||
|
||||
if (dialogData.value.title === 'edit') {
|
||||
await updateClam(dialogData.value.rowData)
|
||||
.then(() => {
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
import { Codemirror } from 'vue-codemirror';
|
||||
import { javascript } from '@codemirror/lang-javascript';
|
||||
import { oneDark } from '@codemirror/theme-one-dark';
|
||||
import { computed, onUnmounted, reactive, ref, shallowRef, watch } from 'vue';
|
||||
import { computed, onUnmounted, reactive, ref, shallowRef } from 'vue';
|
||||
import { OperateSupervisorProcessFile } from '@/api/modules/host-tool';
|
||||
import i18n from '@/lang';
|
||||
import { TabsPaneContext } from 'element-plus';
|
||||
|
||||
Reference in New Issue
Block a user