Skip to content

Commit

Permalink
feat: 增加回收站文件夹限制 (1Panel-dev#4479)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengkunwang223 authored Apr 11, 2024
1 parent 8c7c6fd commit 5a79710
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 4 deletions.
3 changes: 3 additions & 0 deletions frontend/src/lang/modules/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,9 @@ const message = {
ignoreCertificateHelper:
'Ignoring untrusted certificates during downloads may lead to data leakage or tampering. Please use this option with caution, only when trusting the download source.',
uploadOverLimit: 'The number of files exceeds 1000! Please compress and upload',
clashDitNotSuppport: 'File names are prohibited from containing .1panel_clash',
clashDeleteAlert: 'The Recycle Bin folder cannot be deleted',
clashOpenAlert: 'Please click the [Recycle Bin] button to open the recycle bin directory',
},
ssh: {
autoStart: 'Auto Start',
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/lang/modules/tw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,9 @@ const message = {
ignoreCertificateHelper:
'下載時忽略不可信證書可能導致數據洩露或篡改請謹慎使用此選項僅在信任下載源的情況下啟用',
uploadOverLimit: '文件數量超過 1000請壓縮後上傳',
clashDitNotSuppport: '檔名禁止包含 .1panel_clash',
clashDleteAlert: '回收站資料夾不能刪除',
clashOpenAlert: '回收站目錄請點選回收站按鈕開啟',
},
ssh: {
autoStart: '開機自啟',
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/lang/modules/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,9 @@ const message = {
ignoreCertificateHelper:
'下载时忽略不可信证书可能导致数据泄露或篡改请谨慎使用此选项仅在信任下载源的情况下启用',
uploadOverLimit: '文件数量超过 1000请压缩后上传',
clashDitNotSuppport: '文件名禁止包含 .1panel_clash',
clashDleteAlert: '回收站文件夹不能删除',
clashOpenAlert: '回收站目录请点击回收站按钮打开',
},
ssh: {
autoStart: '开机自启',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ const initEditor = () => {
folding: true,
roundedSelection: false,
overviewRulerBorder: false,
wordWrap: 'on',
wordWrap: config.wordWrap,
});
editor.onDidChangeModelContent(() => {
if (editor) {
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/views/host/file-management/create/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ import i18n from '@/lang';
import FileRole from '@/components/file-role/index.vue';
import { Rules } from '@/global/form-rules';
import FileList from '@/components/file-list/index.vue';
import { MsgSuccess } from '@/utils/message';
import { MsgSuccess, MsgWarning } from '@/utils/message';
const fileForm = ref<FormInstance>();
let loading = ref(false);
Expand Down Expand Up @@ -120,6 +120,10 @@ const submit = async (formEl: FormInstance | undefined) => {
if (!valid) {
return;
}
if (getPath.value.indexOf('.1panel_clash') > -1) {
MsgWarning(i18n.global.t('file.clashDitNotSuppport'));
return;
}
let addItem = {};
Object.assign(addItem, addForm);
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/views/host/file-management/delete/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import { ref } from 'vue';
import { File } from '@/api/interface/file';
import { getIcon } from '@/utils/util';
import { DeleteFile, GetRecycleStatus } from '@/api/modules/files';
import { MsgSuccess } from '@/utils/message';
import { MsgSuccess, MsgWarning } from '@/utils/message';
const open = ref(false);
const files = ref();
Expand Down Expand Up @@ -85,6 +85,10 @@ const getStatus = async () => {
const onConfirm = () => {
const pros = [];
for (const s of files.value) {
if (s['path'].indexOf('.1panel_clash') > -1) {
MsgWarning(i18n.global.t('file.clashDleteAlert'));
return;
}
pros.push(DeleteFile({ path: s['path'], isDir: s['isDir'], forceDelete: forceDelete.value }));
}
loading.value = true;
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/views/host/file-management/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,10 @@ const handleSearchResult = (res: ResultData<File.File>) => {
const open = async (row: File.File) => {
if (row.isDir) {
if (row.name == '.1panel_clash') {
MsgWarning(i18n.global.t('file.clashOpenAlert'));
return;
}
const name = row.name;
if (req.path.endsWith('/')) {
req.path = req.path + name;
Expand Down Expand Up @@ -830,6 +834,9 @@ const buttons = [
},
{
label: i18n.global.t('commons.button.delete'),
disabled: (row: File.File) => {
return row.name == '.1panel_clash';
},
click: delFile,
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
</el-form-item>
<el-form-item label="API Token" prop="authorization.apiKey">
<el-input v-model.trim="account.authorization['apiKey']"></el-input>
<span class="input-help">
<span class="input-help text-red-500">
{{ $t('ssl.cfHelper') }}
</span>
</el-form-item>
Expand Down

0 comments on commit 5a79710

Please sign in to comment.