mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-27 12:39:01 +08:00
parent
7d4230ecfb
commit
0b87025c52
@ -211,6 +211,10 @@ func (f *FileService) Create(op request.FileCreate) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *FileService) Delete(op request.FileDelete) error {
|
func (f *FileService) Delete(op request.FileDelete) error {
|
||||||
|
excludeDir := global.CONF.System.DataDir
|
||||||
|
if strings.Contains(op.Path, ".1panel_clash") || op.Path == excludeDir {
|
||||||
|
return buserr.New(constant.ErrPathNotDelete)
|
||||||
|
}
|
||||||
fo := files.NewFileOp()
|
fo := files.NewFileOp()
|
||||||
recycleBinStatus, _ := settingRepo.Get(settingRepo.WithByKey("FileRecycleBin"))
|
recycleBinStatus, _ := settingRepo.Get(settingRepo.WithByKey("FileRecycleBin"))
|
||||||
if recycleBinStatus.Value == "disable" {
|
if recycleBinStatus.Value == "disable" {
|
||||||
|
@ -100,6 +100,7 @@ var (
|
|||||||
ErrFileDownloadDir = "ErrFileDownloadDir"
|
ErrFileDownloadDir = "ErrFileDownloadDir"
|
||||||
ErrCmdNotFound = "ErrCmdNotFound"
|
ErrCmdNotFound = "ErrCmdNotFound"
|
||||||
ErrFavoriteExist = "ErrFavoriteExist"
|
ErrFavoriteExist = "ErrFavoriteExist"
|
||||||
|
ErrPathNotDelete = "ErrPathNotDelete"
|
||||||
)
|
)
|
||||||
|
|
||||||
// mysql
|
// mysql
|
||||||
|
@ -81,6 +81,8 @@ ErrCmdNotFound: "{{ .name}} command does not exist, please install this command
|
|||||||
ErrSourcePathNotFound: "Source directory does not exist"
|
ErrSourcePathNotFound: "Source directory does not exist"
|
||||||
ErrFavoriteExist: "This path has been collected"
|
ErrFavoriteExist: "This path has been collected"
|
||||||
ErrInvalidChar: "Illegal characters are prohibited"
|
ErrInvalidChar: "Illegal characters are prohibited"
|
||||||
|
ErrPathNotDelete: "The selected directory cannot be deleted"
|
||||||
|
|
||||||
|
|
||||||
#website
|
#website
|
||||||
ErrDomainIsExist: "Domain is already exist"
|
ErrDomainIsExist: "Domain is already exist"
|
||||||
|
@ -81,6 +81,7 @@ ErrFileDownloadDir: "不支持下載文件夾"
|
|||||||
ErrCmdNotFound: "{{ .name}} 命令不存在,請先在宿主機安裝此命令"
|
ErrCmdNotFound: "{{ .name}} 命令不存在,請先在宿主機安裝此命令"
|
||||||
ErrSourcePathNotFound: "源目錄不存在"
|
ErrSourcePathNotFound: "源目錄不存在"
|
||||||
ErrFavoriteExist: "已收藏此路徑"
|
ErrFavoriteExist: "已收藏此路徑"
|
||||||
|
ErrPathNotDelete: "所選目錄不可删除"
|
||||||
|
|
||||||
#website
|
#website
|
||||||
ErrDomainIsExist: "域名已存在"
|
ErrDomainIsExist: "域名已存在"
|
||||||
|
@ -81,6 +81,8 @@ ErrCmdNotFound: "{{ .name}} 命令不存在,请先在宿主机安装此命令"
|
|||||||
ErrSourcePathNotFound: "源目录不存在"
|
ErrSourcePathNotFound: "源目录不存在"
|
||||||
ErrFavoriteExist: "已收藏此路径"
|
ErrFavoriteExist: "已收藏此路径"
|
||||||
ErrInvalidChar: "禁止使用非法字符"
|
ErrInvalidChar: "禁止使用非法字符"
|
||||||
|
ErrPathNotDelete: "所选目录不可删除"
|
||||||
|
|
||||||
|
|
||||||
#website
|
#website
|
||||||
ErrDomainIsExist: "域名已存在"
|
ErrDomainIsExist: "域名已存在"
|
||||||
|
@ -1298,6 +1298,7 @@ const message = {
|
|||||||
noNameFile: 'Untitled File',
|
noNameFile: 'Untitled File',
|
||||||
minimap: 'Code Mini Map',
|
minimap: 'Code Mini Map',
|
||||||
fileCanNotRead: 'File can not read',
|
fileCanNotRead: 'File can not read',
|
||||||
|
panelInstallDir: '1Panel installation directory cannot be deleted',
|
||||||
},
|
},
|
||||||
ssh: {
|
ssh: {
|
||||||
autoStart: 'Auto Start',
|
autoStart: 'Auto Start',
|
||||||
|
@ -1228,6 +1228,7 @@ const message = {
|
|||||||
noNameFile: '未命名檔案',
|
noNameFile: '未命名檔案',
|
||||||
minimap: '縮略圖',
|
minimap: '縮略圖',
|
||||||
fileCanNotRead: '此文件不支持預覽',
|
fileCanNotRead: '此文件不支持預覽',
|
||||||
|
panelInstallDir: '1Panel 安裝目錄不能删除',
|
||||||
},
|
},
|
||||||
ssh: {
|
ssh: {
|
||||||
autoStart: '開機自啟',
|
autoStart: '開機自啟',
|
||||||
|
@ -1230,6 +1230,7 @@ const message = {
|
|||||||
noNameFile: '未命名文件',
|
noNameFile: '未命名文件',
|
||||||
minimap: '缩略图',
|
minimap: '缩略图',
|
||||||
fileCanNotRead: '此文件不支持预览',
|
fileCanNotRead: '此文件不支持预览',
|
||||||
|
panelInstallDir: '1Panel 安装目录不能删除',
|
||||||
},
|
},
|
||||||
ssh: {
|
ssh: {
|
||||||
autoStart: '开机自启',
|
autoStart: '开机自启',
|
||||||
|
@ -60,6 +60,7 @@ import { File } from '@/api/interface/file';
|
|||||||
import { getIcon } from '@/utils/util';
|
import { getIcon } from '@/utils/util';
|
||||||
import { DeleteFile, GetRecycleStatus } from '@/api/modules/files';
|
import { DeleteFile, GetRecycleStatus } from '@/api/modules/files';
|
||||||
import { MsgSuccess, MsgWarning } from '@/utils/message';
|
import { MsgSuccess, MsgWarning } from '@/utils/message';
|
||||||
|
import { loadBaseDir } from '@/api/modules/setting';
|
||||||
|
|
||||||
const open = ref(false);
|
const open = ref(false);
|
||||||
const files = ref();
|
const files = ref();
|
||||||
@ -85,13 +86,21 @@ const getStatus = async () => {
|
|||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onConfirm = () => {
|
const onConfirm = async () => {
|
||||||
const pros = [];
|
const pros = [];
|
||||||
for (const s of files.value) {
|
for (const s of files.value) {
|
||||||
if (s['path'].indexOf('.1panel_clash') > -1) {
|
if (s['path'].indexOf('.1panel_clash') > -1) {
|
||||||
MsgWarning(i18n.global.t('file.clashDeleteAlert'));
|
MsgWarning(i18n.global.t('file.clashDeleteAlert'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (s['isDir']) {
|
||||||
|
const pathRes = await loadBaseDir();
|
||||||
|
if (s['path'] === pathRes.data) {
|
||||||
|
MsgWarning(i18n.global.t('file.panelInstallDir'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pros.push(DeleteFile({ path: s['path'], isDir: s['isDir'], forceDelete: forceDelete.value }));
|
pros.push(DeleteFile({ path: s['path'], isDir: s['isDir'], forceDelete: forceDelete.value }));
|
||||||
}
|
}
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user