mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-31 14:08:06 +08:00
feat: 移除多余代码
This commit is contained in:
parent
65da51a478
commit
fcb8a9c860
@ -1,20 +0,0 @@
|
||||
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,7 +33,6 @@ type ClamInfo struct {
|
||||
LastHandleDate string `json:"lastHandleDate"`
|
||||
Spec string `json:"spec"`
|
||||
Description string `json:"description"`
|
||||
AlertCount uint `json:"alertCount"`
|
||||
}
|
||||
|
||||
type ClamLogSearch struct {
|
||||
@ -72,8 +71,6 @@ 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 {
|
||||
|
@ -31,13 +31,10 @@ 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"`
|
||||
|
||||
@ -56,8 +53,6 @@ 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 {
|
||||
@ -104,7 +99,6 @@ type CronjobInfo struct {
|
||||
LastRecordTime string `json:"lastRecordTime"`
|
||||
Status string `json:"status"`
|
||||
Secret string `json:"secret"`
|
||||
AlertCount uint `json:"alertCount"`
|
||||
}
|
||||
|
||||
type SearchRecord struct {
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -21,7 +20,6 @@ import (
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/common"
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/systemctl"
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/xpack"
|
||||
"github.com/1Panel-dev/1Panel/backend/xpack/utils/alert"
|
||||
"github.com/jinzhu/copier"
|
||||
"github.com/robfig/cron/v3"
|
||||
|
||||
@ -156,16 +154,6 @@ 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
|
||||
}
|
||||
@ -192,19 +180,6 @@ 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
|
||||
}
|
||||
|
||||
@ -250,16 +225,6 @@ 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
|
||||
}
|
||||
|
||||
@ -300,14 +265,6 @@ 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
|
||||
}
|
||||
@ -348,7 +305,6 @@ 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)
|
||||
}
|
||||
@ -629,28 +585,3 @@ 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 := alert.PushAlert(pushAlert)
|
||||
if err != nil {
|
||||
global.LOG.Errorf("clamdscan push failed, err: %v", err)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ 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"
|
||||
@ -54,16 +53,6 @@ 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
|
||||
@ -201,18 +190,6 @@ 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
|
||||
}
|
||||
|
||||
@ -255,14 +232,6 @@ 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
|
||||
@ -312,21 +281,7 @@ func (u *CronjobService) Update(id uint, req dto.CronjobUpdate) error {
|
||||
upMap["default_download"] = req.DefaultDownload
|
||||
upMap["retain_copies"] = req.RetainCopies
|
||||
upMap["secret"] = req.Secret
|
||||
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
|
||||
return cronjobRepo.Update(id, upMap)
|
||||
}
|
||||
|
||||
func (u *CronjobService) UpdateStatus(id uint, status string) error {
|
||||
@ -338,7 +293,6 @@ 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,7 +12,6 @@ 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"
|
||||
@ -21,12 +20,9 @@ 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"
|
||||
)
|
||||
|
||||
var alertTypes = map[string]bool{"app": true, "website": true, "database": true, "directory": true, "log": true, "snapshot": true}
|
||||
|
||||
func (u *CronjobService) HandleJob(cronjob *model.Cronjob) {
|
||||
var (
|
||||
message []byte
|
||||
@ -94,7 +90,6 @@ 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 {
|
||||
@ -396,19 +391,3 @@ 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) {
|
||||
if alertTypes[cronjob.Type] {
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -178,6 +178,8 @@ 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") {
|
||||
|
@ -8,7 +8,6 @@ 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"
|
||||
@ -40,23 +39,3 @@ 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
|
||||
repo_url: https://resource.fit2cloud.com/1panel/package/aliyun
|
||||
app_repo: https://apps-assets.fit2cloud.com
|
||||
is_demo: false
|
||||
port: 9999
|
||||
|
@ -30,9 +30,6 @@ export namespace Cronjob {
|
||||
retainCopies: number;
|
||||
status: string;
|
||||
secret: string;
|
||||
hasAlert: boolean;
|
||||
alertCount: number;
|
||||
alertTitle: string;
|
||||
}
|
||||
export interface CronjobCreate {
|
||||
name: string;
|
||||
|
@ -139,9 +139,6 @@ export namespace Toolbox {
|
||||
spec: string;
|
||||
specObj: Cronjob.SpecObj;
|
||||
description: string;
|
||||
hasAlert: boolean;
|
||||
alertCount: number;
|
||||
alertTitle: string;
|
||||
}
|
||||
export interface ClamCreate {
|
||||
name: string;
|
||||
|
@ -1,119 +0,0 @@
|
||||
<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,11 +16,6 @@
|
||||
<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">
|
||||
@ -126,10 +121,6 @@ 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');
|
||||
};
|
||||
|
@ -1094,7 +1094,6 @@ 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?',
|
||||
@ -1655,49 +1654,6 @@ 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',
|
||||
|
@ -1034,7 +1034,6 @@ const message = {
|
||||
clam: {
|
||||
clam: '病毒掃描',
|
||||
cron: '定時掃描',
|
||||
cronHelper: '專業版支持定時掃描功能',
|
||||
specErr: '執行周期格式錯誤,請檢查後重試!',
|
||||
disableMsg: '停止定時執行會導致該掃描任務不再自動執行。是否繼續?',
|
||||
enableMsg: '啟用定時執行會讓該掃描任務定期自動執行。是否繼續?',
|
||||
@ -1308,8 +1307,8 @@ const message = {
|
||||
systemIP: '伺服器地址',
|
||||
proxy: '代理伺服器',
|
||||
proxyHelper: '設置代理伺服器後,將在以下場景中生效:',
|
||||
proxyHelper1: '應用商店的安裝包下載和同步(專業版功能)',
|
||||
proxyHelper2: '系統版本升級及獲取更新說明(專業版功能)',
|
||||
proxyHelper1: '應用商店的安裝包下載和同步',
|
||||
proxyHelper2: '系統版本升級及獲取更新說明',
|
||||
proxyHelper3: '系統許可證的驗證和同步',
|
||||
proxyType: '代理類型',
|
||||
proxyUrl: '代理地址',
|
||||
@ -1538,46 +1537,6 @@ 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 運行期間積累的垃圾文件',
|
||||
|
@ -1035,7 +1035,6 @@ const message = {
|
||||
clam: {
|
||||
clam: '病毒扫描',
|
||||
cron: '定时扫描',
|
||||
cronHelper: '专业版支持定时扫描功能 ',
|
||||
specErr: '执行周期格式错误,请检查后重试!',
|
||||
disableMsg: '停止定时执行会导致该扫描任务不再自动执行。是否继续?',
|
||||
enableMsg: '启用定时执行会让该扫描任务定期自动执行。是否继续?',
|
||||
@ -1310,8 +1309,8 @@ const message = {
|
||||
systemIP: '服务器地址',
|
||||
proxy: '代理服务器',
|
||||
proxyHelper: '设置代理服务器后,将在以下场景中生效:',
|
||||
proxyHelper1: '应用商店的安装包下载和同步(专业版功能)',
|
||||
proxyHelper2: '系统版本升级及获取更新说明(专业版功能)',
|
||||
proxyHelper1: '应用商店的安装包下载和同步',
|
||||
proxyHelper2: '系统版本升级及获取更新说明',
|
||||
proxyHelper3: '系统许可证的验证和同步',
|
||||
proxyType: '代理类型',
|
||||
proxyUrl: '代理地址',
|
||||
@ -1540,46 +1539,6 @@ 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 运行期间积累的垃圾文件',
|
||||
|
@ -37,16 +37,6 @@ 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',
|
||||
|
@ -22,9 +22,4 @@ body,
|
||||
|
||||
.el-switch--small,.is-checked .el-switch__core::after {
|
||||
margin-left: 12px !important;
|
||||
}
|
||||
|
||||
.el-alert__title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
@ -336,31 +336,6 @@
|
||||
<el-input clearable v-model.trim="dialogData.rowData!.url" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item prop="hasAlert" v-if="alertTypes.includes(dialogData.rowData!.type)">
|
||||
<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
|
||||
v-if="hasExclusionRules()"
|
||||
:label="$t('cronjob.exclusionRules')"
|
||||
@ -386,7 +361,6 @@
|
||||
</el-button>
|
||||
</span>
|
||||
</template>
|
||||
<LicenseImport ref="licenseRef" />
|
||||
</el-drawer>
|
||||
</template>
|
||||
|
||||
@ -408,9 +382,6 @@ 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();
|
||||
|
||||
@ -426,11 +397,6 @@ const dialogData = ref<DialogProps>({
|
||||
title: '',
|
||||
});
|
||||
|
||||
const globalStore = GlobalStore();
|
||||
const licenseRef = ref();
|
||||
const { isProductPro } = storeToRefs(globalStore);
|
||||
const alertTypes = ['app', 'website', 'database', 'directory', 'log', 'snapshot'];
|
||||
|
||||
const acceptParams = (params: DialogProps): void => {
|
||||
dialogData.value = params;
|
||||
if (dialogData.value.rowData?.spec) {
|
||||
@ -457,8 +423,6 @@ 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' &&
|
||||
@ -596,18 +560,6 @@ 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],
|
||||
@ -626,7 +578,6 @@ const rules = reactive({
|
||||
backupAccounts: [Rules.requiredSelect],
|
||||
defaultDownload: [Rules.requiredSelect],
|
||||
retainCopies: [Rules.number],
|
||||
alertCount: [Rules.integerNumber, { validator: checkSendCount, trigger: 'blur' }],
|
||||
});
|
||||
|
||||
type FormInstance = InstanceType<typeof ElForm>;
|
||||
@ -805,17 +756,6 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
|
||||
if (dialogData.value?.rowData?.exclusionRules) {
|
||||
dialogData.value.rowData.exclusionRules = dialogData.value.rowData.exclusionRules.replaceAll('\n', ',');
|
||||
}
|
||||
if (alertTypes.includes(dialogData.value.rowData.type)) {
|
||||
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);
|
||||
@ -830,10 +770,6 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
|
||||
});
|
||||
};
|
||||
|
||||
const toUpload = () => {
|
||||
licenseRef.value.acceptParams();
|
||||
};
|
||||
|
||||
defineExpose({
|
||||
acceptParams,
|
||||
});
|
||||
|
@ -7,17 +7,7 @@
|
||||
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"
|
||||
@ -259,8 +249,6 @@
|
||||
</CardWithHeader>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<LicenseImport ref="licenseRef" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -269,7 +257,6 @@ 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';
|
||||
@ -303,9 +290,6 @@ const timeNetDatas = ref<Array<string>>([]);
|
||||
const ioOptions = ref();
|
||||
const netOptions = ref();
|
||||
|
||||
const licenseRef = ref();
|
||||
const isProductPro = ref();
|
||||
|
||||
const searchInfo = reactive({
|
||||
ioOption: 'all',
|
||||
netOption: 'all',
|
||||
@ -659,12 +643,7 @@ 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,10 +27,6 @@ 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',
|
||||
|
@ -1,261 +0,0 @@
|
||||
<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,21 +126,6 @@
|
||||
</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>
|
||||
@ -266,7 +251,6 @@ 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,7 +19,6 @@
|
||||
<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>
|
||||
|
@ -53,12 +53,6 @@
|
||||
<el-form-item prop="hasSpec">
|
||||
<el-checkbox v-model="dialogData.rowData!.hasSpec" :label="$t('toolbox.clam.cron')" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="dialogData.rowData!.hasSpec && !isProductPro">
|
||||
<span>{{ $t('toolbox.clam.cronHelper') }}</span>
|
||||
<el-button link type="primary" @click="toUpload">
|
||||
{{ $t('license.levelUpPro') }}
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item prop="spec" v-if="dialogData.rowData!.hasSpec && isProductPro">
|
||||
<el-select
|
||||
class="specTypeClass"
|
||||
@ -121,30 +115,6 @@
|
||||
</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 && !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>
|
||||
@ -159,7 +129,6 @@
|
||||
</el-button>
|
||||
</span>
|
||||
</template>
|
||||
<LicenseImport ref="licenseRef" />
|
||||
</el-drawer>
|
||||
</template>
|
||||
|
||||
@ -169,7 +138,6 @@ 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';
|
||||
@ -179,7 +147,6 @@ import { storeToRefs } from 'pinia';
|
||||
import { GlobalStore } from '@/store';
|
||||
|
||||
const globalStore = GlobalStore();
|
||||
const licenseRef = ref();
|
||||
const { isProductPro } = storeToRefs(globalStore);
|
||||
interface DialogProps {
|
||||
title: string;
|
||||
@ -208,8 +175,6 @@ 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;
|
||||
};
|
||||
@ -303,19 +268,6 @@ 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],
|
||||
@ -323,7 +275,6 @@ 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>;
|
||||
@ -347,10 +298,6 @@ 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) {
|
||||
@ -393,16 +340,6 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
|
||||
MsgError(i18n.global.t('cronjob.cronSpecHelper'));
|
||||
return;
|
||||
}
|
||||
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;
|
||||
}
|
||||
dialogData.value.rowData.spec = spec;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user