mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-19 00:09:16 +08:00
feat: 迁移缓存清理代码 (#3186)
This commit is contained in:
parent
58b6a2de32
commit
1a400e7f81
@ -203,3 +203,34 @@ func (b *BaseApi) CheckDNS(c *gin.Context) {
|
||||
|
||||
helper.SuccessWithData(c, data)
|
||||
}
|
||||
|
||||
// @Tags Device
|
||||
// @Summary Scan system
|
||||
// @Description 扫描系统垃圾文件
|
||||
// @Success 200
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /toolbox/scan [post]
|
||||
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"扫描系统垃圾文件","formatEN":"scan System Junk Files"}
|
||||
func (b *BaseApi) ScanSystem(c *gin.Context) {
|
||||
helper.SuccessWithData(c, deviceService.Scan())
|
||||
}
|
||||
|
||||
// @Tags Device
|
||||
// @Summary Clean system
|
||||
// @Description 清理系统垃圾文件
|
||||
// @Accept json
|
||||
// @Param request body []dto.Clean true "request"
|
||||
// @Success 200
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /toolbox/clean [post]
|
||||
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"清理系统垃圾文件","formatEN":"Clean system junk files"}
|
||||
func (b *BaseApi) SystemClean(c *gin.Context) {
|
||||
var req []dto.Clean
|
||||
if err := helper.CheckBind(&req, c); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
deviceService.Clean(req)
|
||||
|
||||
helper.SuccessWithData(c, nil)
|
||||
}
|
||||
|
@ -251,37 +251,6 @@ func (b *BaseApi) CleanMonitor(c *gin.Context) {
|
||||
helper.SuccessWithData(c, nil)
|
||||
}
|
||||
|
||||
// @Tags System Setting
|
||||
// @Summary Scan system
|
||||
// @Description 扫描系统垃圾文件
|
||||
// @Success 200
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /settings/scan [post]
|
||||
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"扫描系统垃圾文件","formatEN":"scan System Junk Files"}
|
||||
func (b *BaseApi) ScanSystem(c *gin.Context) {
|
||||
helper.SuccessWithData(c, settingService.SystemScan())
|
||||
}
|
||||
|
||||
// @Tags System Setting
|
||||
// @Summary System clean
|
||||
// @Description 清理系统垃圾文件
|
||||
// @Accept json
|
||||
// @Param request body []dto.Clean true "request"
|
||||
// @Success 200
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /settings/clean [post]
|
||||
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"清理系统垃圾文件","formatEN":"Clean system junk files"}
|
||||
func (b *BaseApi) SystemClean(c *gin.Context) {
|
||||
var req []dto.Clean
|
||||
if err := helper.CheckBind(&req, c); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
settingService.SystemClean(req)
|
||||
|
||||
helper.SuccessWithData(c, nil)
|
||||
}
|
||||
|
||||
// @Tags System Setting
|
||||
// @Summary Load mfa info
|
||||
// @Description 获取 mfa 信息
|
||||
|
@ -584,7 +584,7 @@ func (u *CronjobService) handleSnapshot(cronjob *model.Cronjob, startTime time.T
|
||||
}
|
||||
|
||||
func (u *CronjobService) handleSystemClean() (string, error) {
|
||||
return NewISettingService().SystemCleanForCronjob()
|
||||
return NewIDeviceService().CleanForCronjob()
|
||||
}
|
||||
|
||||
func (u *CronjobService) handleSystemLog(cronjob model.Cronjob, startTime time.Time) (string, error) {
|
||||
|
@ -37,6 +37,10 @@ type IDeviceService interface {
|
||||
LoadTimeZone() ([]string, error)
|
||||
CheckDNS(key, value string) (bool, error)
|
||||
LoadConf(name string) (string, error)
|
||||
|
||||
Scan() dto.CleanData
|
||||
Clean(req []dto.Clean)
|
||||
CleanForCronjob() (string, error)
|
||||
}
|
||||
|
||||
func NewIDeviceService() IDeviceService {
|
||||
|
@ -33,7 +33,7 @@ const (
|
||||
taskPath = "1panel/task"
|
||||
)
|
||||
|
||||
func (u *SettingService) SystemScan() dto.CleanData {
|
||||
func (u *DeviceService) Scan() dto.CleanData {
|
||||
var (
|
||||
SystemClean dto.CleanData
|
||||
treeData []dto.CleanTree
|
||||
@ -133,7 +133,7 @@ func (u *SettingService) SystemScan() dto.CleanData {
|
||||
return SystemClean
|
||||
}
|
||||
|
||||
func (u *SettingService) SystemClean(req []dto.Clean) {
|
||||
func (u *DeviceService) Clean(req []dto.Clean) {
|
||||
size := uint64(0)
|
||||
restart := false
|
||||
for _, item := range req {
|
||||
@ -235,7 +235,7 @@ func (u *SettingService) SystemClean(req []dto.Clean) {
|
||||
continue
|
||||
}
|
||||
for _, file := range files {
|
||||
if file.Name() == "1Panel.log" {
|
||||
if file.Name() == "1Panel.log" || file.IsDir() {
|
||||
continue
|
||||
}
|
||||
dropFileOrDir(path.Join(global.CONF.System.BaseDir, logPath, file.Name()))
|
||||
@ -276,7 +276,7 @@ func (u *SettingService) SystemClean(req []dto.Clean) {
|
||||
}
|
||||
}
|
||||
|
||||
func (u *SettingService) SystemCleanForCronjob() (string, error) {
|
||||
func (u *DeviceService) CleanForCronjob() (string, error) {
|
||||
logs := ""
|
||||
size := int64(0)
|
||||
fileCount := 0
|
||||
@ -541,7 +541,7 @@ func loadTreeWithAllFile(isCheck bool, originalPath, treeType, pathItem string,
|
||||
return lists
|
||||
}
|
||||
for _, file := range files {
|
||||
if treeType == "system_log" && file.Name() == "1Panel.log" {
|
||||
if treeType == "system_log" && (file.Name() == "1Panel.log" || file.IsDir()) {
|
||||
continue
|
||||
}
|
||||
if (treeType == "upload" || treeType == "download") && file.IsDir() && (file.Name() == "app" || file.Name() == "database" || file.Name() == "website" || file.Name() == "directory") {
|
@ -6,7 +6,6 @@ import (
|
||||
"encoding/json"
|
||||
"encoding/pem"
|
||||
"fmt"
|
||||
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
||||
"net"
|
||||
"os"
|
||||
"path"
|
||||
@ -14,6 +13,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
||||
"github.com/1Panel-dev/1Panel/backend/buserr"
|
||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
||||
@ -38,10 +39,6 @@ type ISettingService interface {
|
||||
UpdateSSL(c *gin.Context, req dto.SSLUpdate) error
|
||||
LoadFromCert() (*dto.SSLInfo, error)
|
||||
HandlePasswordExpired(c *gin.Context, old, new string) error
|
||||
|
||||
SystemScan() dto.CleanData
|
||||
SystemClean(req []dto.Clean)
|
||||
SystemCleanForCronjob() (string, error)
|
||||
}
|
||||
|
||||
func NewISettingService() ISettingService {
|
||||
|
@ -32,8 +32,6 @@ func (s *SettingRouter) InitSettingRouter(Router *gin.RouterGroup) {
|
||||
settingRouter.POST("/monitor/clean", baseApi.CleanMonitor)
|
||||
settingRouter.POST("/mfa", baseApi.LoadMFA)
|
||||
settingRouter.POST("/mfa/bind", baseApi.MFABind)
|
||||
settingRouter.POST("/scan", baseApi.ScanSystem)
|
||||
settingRouter.POST("/clean", baseApi.SystemClean)
|
||||
|
||||
settingRouter.POST("/snapshot", baseApi.CreateSnapshot)
|
||||
settingRouter.POST("/snapshot/status", baseApi.LoadSnapShotStatus)
|
||||
|
@ -26,6 +26,9 @@ func (s *ToolboxRouter) InitToolboxRouter(Router *gin.RouterGroup) {
|
||||
toolboxRouter.POST("/device/check/dns", baseApi.CheckDNS)
|
||||
toolboxRouter.POST("/device/conf", baseApi.LoadDeviceConf)
|
||||
|
||||
toolboxRouter.POST("/scan", baseApi.ScanSystem)
|
||||
toolboxRouter.POST("/clean", baseApi.SystemClean)
|
||||
|
||||
toolboxRouter.GET("/fail2ban/base", baseApi.LoadFail2BanBaseInfo)
|
||||
toolboxRouter.GET("/fail2ban/load/conf", baseApi.LoadFail2BanConf)
|
||||
toolboxRouter.POST("/fail2ban/search", baseApi.SearchFail2Ban)
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Package docs GENERATED BY SWAG; DO NOT EDIT
|
||||
// This file was generated by swaggo/swag
|
||||
// Code generated by swaggo/swag. DO NOT EDIT.
|
||||
|
||||
package docs
|
||||
|
||||
import "github.com/swaggo/swag"
|
||||
@ -9212,49 +9212,6 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/settings/clean": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "清理系统垃圾文件",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"System Setting"
|
||||
],
|
||||
"summary": "System clean",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "request",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/dto.Clean"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
},
|
||||
"x-panel-log": {
|
||||
"BeforeFunctions": [],
|
||||
"bodyKeys": [],
|
||||
"formatEN": "Clean system junk files",
|
||||
"formatZH": "清理系统垃圾文件",
|
||||
"paramKeys": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"/settings/expired/handle": {
|
||||
"post": {
|
||||
"security": [
|
||||
@ -9501,32 +9458,6 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/settings/scan": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "扫描系统垃圾文件",
|
||||
"tags": [
|
||||
"System Setting"
|
||||
],
|
||||
"summary": "Scan system",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
},
|
||||
"x-panel-log": {
|
||||
"BeforeFunctions": [],
|
||||
"bodyKeys": [],
|
||||
"formatEN": "scan System Junk Files",
|
||||
"formatZH": "扫描系统垃圾文件",
|
||||
"paramKeys": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"/settings/search": {
|
||||
"post": {
|
||||
"security": [
|
||||
@ -10127,6 +10058,49 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/toolbox/clean": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "清理系统垃圾文件",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Device"
|
||||
],
|
||||
"summary": "Clean system",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "request",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/dto.Clean"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
},
|
||||
"x-panel-log": {
|
||||
"BeforeFunctions": [],
|
||||
"bodyKeys": [],
|
||||
"formatEN": "Clean system junk files",
|
||||
"formatZH": "清理系统垃圾文件",
|
||||
"paramKeys": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"/toolbox/device/base": {
|
||||
"get": {
|
||||
"security": [
|
||||
@ -10644,6 +10618,32 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/toolbox/scan": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "扫描系统垃圾文件",
|
||||
"tags": [
|
||||
"Device"
|
||||
],
|
||||
"summary": "Scan system",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
},
|
||||
"x-panel-log": {
|
||||
"BeforeFunctions": [],
|
||||
"bodyKeys": [],
|
||||
"formatEN": "scan System Junk Files",
|
||||
"formatZH": "扫描系统垃圾文件",
|
||||
"paramKeys": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"/websites": {
|
||||
"post": {
|
||||
"security": [
|
||||
@ -14850,6 +14850,9 @@ const docTemplate = `{
|
||||
"localTime": {
|
||||
"type": "string"
|
||||
},
|
||||
"maxSize": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ntp": {
|
||||
"type": "string"
|
||||
},
|
||||
|
@ -9205,49 +9205,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/settings/clean": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "清理系统垃圾文件",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"System Setting"
|
||||
],
|
||||
"summary": "System clean",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "request",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/dto.Clean"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
},
|
||||
"x-panel-log": {
|
||||
"BeforeFunctions": [],
|
||||
"bodyKeys": [],
|
||||
"formatEN": "Clean system junk files",
|
||||
"formatZH": "清理系统垃圾文件",
|
||||
"paramKeys": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"/settings/expired/handle": {
|
||||
"post": {
|
||||
"security": [
|
||||
@ -9494,32 +9451,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/settings/scan": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "扫描系统垃圾文件",
|
||||
"tags": [
|
||||
"System Setting"
|
||||
],
|
||||
"summary": "Scan system",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
},
|
||||
"x-panel-log": {
|
||||
"BeforeFunctions": [],
|
||||
"bodyKeys": [],
|
||||
"formatEN": "scan System Junk Files",
|
||||
"formatZH": "扫描系统垃圾文件",
|
||||
"paramKeys": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"/settings/search": {
|
||||
"post": {
|
||||
"security": [
|
||||
@ -10120,6 +10051,49 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/toolbox/clean": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "清理系统垃圾文件",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Device"
|
||||
],
|
||||
"summary": "Clean system",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "request",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/dto.Clean"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
},
|
||||
"x-panel-log": {
|
||||
"BeforeFunctions": [],
|
||||
"bodyKeys": [],
|
||||
"formatEN": "Clean system junk files",
|
||||
"formatZH": "清理系统垃圾文件",
|
||||
"paramKeys": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"/toolbox/device/base": {
|
||||
"get": {
|
||||
"security": [
|
||||
@ -10637,6 +10611,32 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/toolbox/scan": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "扫描系统垃圾文件",
|
||||
"tags": [
|
||||
"Device"
|
||||
],
|
||||
"summary": "Scan system",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
},
|
||||
"x-panel-log": {
|
||||
"BeforeFunctions": [],
|
||||
"bodyKeys": [],
|
||||
"formatEN": "scan System Junk Files",
|
||||
"formatZH": "扫描系统垃圾文件",
|
||||
"paramKeys": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"/websites": {
|
||||
"post": {
|
||||
"security": [
|
||||
@ -14843,6 +14843,9 @@
|
||||
"localTime": {
|
||||
"type": "string"
|
||||
},
|
||||
"maxSize": {
|
||||
"type": "integer"
|
||||
},
|
||||
"ntp": {
|
||||
"type": "string"
|
||||
},
|
||||
|
@ -987,6 +987,8 @@ definitions:
|
||||
type: array
|
||||
localTime:
|
||||
type: string
|
||||
maxSize:
|
||||
type: integer
|
||||
ntp:
|
||||
type: string
|
||||
swapDetails:
|
||||
@ -10610,34 +10612,6 @@ paths:
|
||||
formatEN: 'update system bind info => ipv6: [ipv6], 监听 IP: [bindAddress]'
|
||||
formatZH: '修改系统监听信息 => ipv6: [ipv6], 监听 IP: [bindAddress]'
|
||||
paramKeys: []
|
||||
/settings/clean:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 清理系统垃圾文件
|
||||
parameters:
|
||||
- description: request
|
||||
in: body
|
||||
name: request
|
||||
required: true
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/definitions/dto.Clean'
|
||||
type: array
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
security:
|
||||
- ApiKeyAuth: []
|
||||
summary: System clean
|
||||
tags:
|
||||
- System Setting
|
||||
x-panel-log:
|
||||
BeforeFunctions: []
|
||||
bodyKeys: []
|
||||
formatEN: Clean system junk files
|
||||
formatZH: 清理系统垃圾文件
|
||||
paramKeys: []
|
||||
/settings/expired/handle:
|
||||
post:
|
||||
consumes:
|
||||
@ -10795,23 +10769,6 @@ paths:
|
||||
formatEN: update system port => [serverPort]
|
||||
formatZH: 修改系统端口 => [serverPort]
|
||||
paramKeys: []
|
||||
/settings/scan:
|
||||
post:
|
||||
description: 扫描系统垃圾文件
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
security:
|
||||
- ApiKeyAuth: []
|
||||
summary: Scan system
|
||||
tags:
|
||||
- System Setting
|
||||
x-panel-log:
|
||||
BeforeFunctions: []
|
||||
bodyKeys: []
|
||||
formatEN: scan System Junk Files
|
||||
formatZH: 扫描系统垃圾文件
|
||||
paramKeys: []
|
||||
/settings/search:
|
||||
post:
|
||||
description: 加载系统配置信息
|
||||
@ -11192,6 +11149,34 @@ paths:
|
||||
formatEN: upgrade service => [version]
|
||||
formatZH: 更新系统 => [version]
|
||||
paramKeys: []
|
||||
/toolbox/clean:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 清理系统垃圾文件
|
||||
parameters:
|
||||
- description: request
|
||||
in: body
|
||||
name: request
|
||||
required: true
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/definitions/dto.Clean'
|
||||
type: array
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
security:
|
||||
- ApiKeyAuth: []
|
||||
summary: Clean system
|
||||
tags:
|
||||
- Device
|
||||
x-panel-log:
|
||||
BeforeFunctions: []
|
||||
bodyKeys: []
|
||||
formatEN: Clean system junk files
|
||||
formatZH: 清理系统垃圾文件
|
||||
paramKeys: []
|
||||
/toolbox/device/base:
|
||||
get:
|
||||
description: 获取设备基础信息
|
||||
@ -11514,6 +11499,23 @@ paths:
|
||||
summary: Update fail2ban conf by file
|
||||
tags:
|
||||
- Fail2ban
|
||||
/toolbox/scan:
|
||||
post:
|
||||
description: 扫描系统垃圾文件
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
security:
|
||||
- ApiKeyAuth: []
|
||||
summary: Scan system
|
||||
tags:
|
||||
- Device
|
||||
x-panel-log:
|
||||
BeforeFunctions: []
|
||||
bodyKeys: []
|
||||
formatEN: scan System Junk Files
|
||||
formatZH: 扫描系统垃圾文件
|
||||
paramKeys: []
|
||||
/websites:
|
||||
post:
|
||||
consumes:
|
||||
|
@ -87,23 +87,6 @@ export namespace Setting {
|
||||
interval: string;
|
||||
}
|
||||
|
||||
export interface CleanData {
|
||||
systemClean: Array<CleanTree>;
|
||||
uploadClean: Array<CleanTree>;
|
||||
downloadClean: Array<CleanTree>;
|
||||
systemLogClean: Array<CleanTree>;
|
||||
}
|
||||
export interface CleanTree {
|
||||
id: string;
|
||||
label: string;
|
||||
children: Array<CleanTree>;
|
||||
type: string;
|
||||
name: string;
|
||||
size: number;
|
||||
isCheck: boolean;
|
||||
isRecommend: boolean;
|
||||
}
|
||||
|
||||
export interface SnapshotCreate {
|
||||
id: number;
|
||||
from: string;
|
||||
|
@ -31,6 +31,23 @@ export namespace Toolbox {
|
||||
zones: Array<string>;
|
||||
}
|
||||
|
||||
export interface CleanData {
|
||||
systemClean: Array<CleanTree>;
|
||||
uploadClean: Array<CleanTree>;
|
||||
downloadClean: Array<CleanTree>;
|
||||
systemLogClean: Array<CleanTree>;
|
||||
}
|
||||
export interface CleanTree {
|
||||
id: string;
|
||||
label: string;
|
||||
children: Array<CleanTree>;
|
||||
type: string;
|
||||
name: string;
|
||||
size: number;
|
||||
isCheck: boolean;
|
||||
isRecommend: boolean;
|
||||
}
|
||||
|
||||
export interface Fail2banBaseInfo {
|
||||
isEnable: boolean;
|
||||
isActive: boolean;
|
||||
|
@ -47,13 +47,6 @@ export const handleExpired = (param: Setting.PasswordUpdate) => {
|
||||
return http.post(`/settings/expired/handle`, param);
|
||||
};
|
||||
|
||||
export const scanSystem = () => {
|
||||
return http.post<Setting.CleanData>(`/settings/scan`, {});
|
||||
};
|
||||
export const cleanSystem = (param: any) => {
|
||||
return http.post(`/settings/clean`, param);
|
||||
};
|
||||
|
||||
export const loadTimeZone = () => {
|
||||
return http.get<Array<string>>(`/settings/time/option`);
|
||||
};
|
||||
|
@ -33,6 +33,14 @@ export const loadDeviceConf = (name: string) => {
|
||||
return http.post(`/toolbox/device/conf`, { name: name });
|
||||
};
|
||||
|
||||
// clean
|
||||
export const scan = () => {
|
||||
return http.post<Toolbox.CleanData>(`/toolbox/scan`, {});
|
||||
};
|
||||
export const clean = (param: any) => {
|
||||
return http.post(`/toolbox/clean`, param);
|
||||
};
|
||||
|
||||
// fail2ban
|
||||
export const getFail2banBase = () => {
|
||||
return http.get<Toolbox.Fail2banBaseInfo>(`/toolbox/fail2ban/base`);
|
||||
|
@ -192,6 +192,9 @@ const loadDetail = (log: string) => {
|
||||
if (log.indexOf('[get]') !== -1) {
|
||||
log = log.replace('[get]', '[' + i18n.global.t('commons.button.get') + ']');
|
||||
}
|
||||
if (log.indexOf('[operate]') !== -1) {
|
||||
log = log.replace('[operate]', '[' + i18n.global.t('commons.table.operate') + ']');
|
||||
}
|
||||
if (log.indexOf('[UserName]') !== -1) {
|
||||
return log.replace('[UserName]', '[' + i18n.global.t('commons.login.username') + ']');
|
||||
}
|
||||
|
@ -228,7 +228,8 @@
|
||||
<script lang="ts" setup>
|
||||
import { onMounted, reactive, ref } from 'vue';
|
||||
import { computeSize } from '@/utils/util';
|
||||
import { cleanSystem, scanSystem, getSettingInfo } from '@/api/modules/setting';
|
||||
import { getSettingInfo } from '@/api/modules/setting';
|
||||
import { clean, scan } from '@/api/modules/toolbox';
|
||||
import i18n from '@/lang';
|
||||
import { MsgSuccess } from '@/utils/message';
|
||||
import { GlobalStore } from '@/store';
|
||||
@ -270,7 +271,7 @@ const form = reactive({
|
||||
|
||||
const scanData = async () => {
|
||||
loading.value = true;
|
||||
await scanSystem()
|
||||
await scan()
|
||||
.then((res) => {
|
||||
loading.value = false;
|
||||
selectSize.value = 0;
|
||||
@ -321,7 +322,7 @@ const onSubmitClean = async () => {
|
||||
break;
|
||||
}
|
||||
}
|
||||
await cleanSystem(submitCleans.value)
|
||||
await clean(submitCleans.value)
|
||||
.then(() => {
|
||||
form.lastCleanSize = selectSize.value + '';
|
||||
form.lastCleanData = submitCleans.value.length + '';
|
||||
|
Loading…
x
Reference in New Issue
Block a user