This commit is contained in:
Baobhan Sith
2025-05-07 09:45:18 +08:00
parent 2a0cf41dc7
commit dccc106afd
7 changed files with 103 additions and 21 deletions
@@ -105,9 +105,10 @@ const {
fileManagerRowSizeMultiplierNumber, // +++ 获取行大小 getter +++
fileManagerColWidthsObject, // +++ 获取列宽 getter +++
showPopupFileEditorBoolean, // +++ 获取弹窗设置状态 +++
fileManagerShowDeleteConfirmationBoolean, // +++ 获取删除确认设置状态 +++
} = storeToRefs(settingsStore); // 使用 storeToRefs 保持响应性
// --- UI 状态 Refs (Remain mostly the same) ---
const fileInputRef = ref<HTMLInputElement | null>(null);
@@ -377,10 +378,19 @@ const handleDeleteSelectedClick = () => {
.map(filename => currentSftpManager.value?.fileList.value.find((f: FileListItem) => f.filename === filename))
.filter((item): item is FileListItem => item !== undefined);
if (itemsToDelete.length === 0) return;
openActionModal('delete', null, itemsToDelete);
// 根据设置决定是否显示确认模态框
if (settingsStore.fileManagerShowDeleteConfirmationBoolean) {
openActionModal('delete', null, itemsToDelete);
} else {
// 直接执行删除
if (currentSftpManager.value) {
currentSftpManager.value.deleteItems(itemsToDelete);
selectedItems.value.clear(); // Clear selection after delete
}
}
};
const handleRenameContextMenuClick = (item: FileListItem) => { // item 已有类型
if (!props.wsDeps.isConnected.value || !item) return; // 恢复使用 props.wsDeps
if (!currentSftpManager.value) return;
+5 -1
View File
@@ -676,7 +676,11 @@
"showConnectionTagsDescription": "Disable to hide tags in the connection list and exclude them from search.",
"showQuickCommandTagsTitle": "Show Quick Command Tags",
"showQuickCommandTagsLabel": "Show tags in quick command list",
"showQuickCommandTagsDescription": "Disable to hide tags in the quick command list and exclude them from search."
"showQuickCommandTagsDescription": "Disable to hide tags in the quick command list and exclude them from search.",
"fileManagerDeleteConfirmTitle": "File Manager Delete Confirmation",
"fileManagerShowDeleteConfirmationLabel": "Show confirmation dialog when deleting files or folders",
"fileManagerDeleteConfirmSuccess": "File manager delete confirmation setting saved.",
"fileManagerDeleteConfirmError": "Failed to save file manager delete confirmation setting."
},
"terminalScrollback": {
"title": "Terminal Scrollback Limit",
+5 -1
View File
@@ -914,7 +914,11 @@
"showConnectionTagsDescription": "無効にすると、接続リストのタグが非表示になり、検索から除外されます。",
"showQuickCommandTagsTitle": "クイックコマンドタグを表示",
"showQuickCommandTagsLabel": "クイックコマンドリストにタグを表示",
"showQuickCommandTagsDescription": "無効にすると、クイックコマンドリストのタグが非表示になり、検索から除外されます。"
"showQuickCommandTagsDescription": "無効にすると、クイックコマンドリストのタグが非表示になり、検索から除外されます。",
"fileManagerDeleteConfirmTitle": "ファイルマネージャー削除確認",
"fileManagerShowDeleteConfirmationLabel": "ファイルまたはフォルダーを削除する際に確認ダイアログを表示する",
"fileManagerDeleteConfirmSuccess": "ファイルマネージャーの削除確認設定を保存しました。",
"fileManagerDeleteConfirmError": "ファイルマネージャーの削除確認設定の保存に失敗しました。"
},
"terminalScrollback": {
"title": "ターミナルスクロールバック制限",
+5 -1
View File
@@ -676,7 +676,11 @@
"showConnectionTagsDescription": "关闭后将隐藏连接列表中的标签,并从搜索中排除标签。",
"showQuickCommandTagsTitle": "显示快捷指令标签",
"showQuickCommandTagsLabel": "在快捷指令列表中显示标签",
"showQuickCommandTagsDescription": "关闭后将隐藏快捷指令列表中的标签,并从搜索中排除标签。"
"showQuickCommandTagsDescription": "关闭后将隐藏快捷指令列表中的标签,并从搜索中排除标签。",
"fileManagerDeleteConfirmTitle": "文件管理器删除确认",
"fileManagerShowDeleteConfirmationLabel": "删除文件或文件夹时显示确认提示框",
"fileManagerDeleteConfirmSuccess": "文件管理器删除确认设置已保存。",
"fileManagerDeleteConfirmError": "保存文件管理器删除确认设置失败。"
},
"terminalScrollback": {
"title": "终端回滚行数",
+18 -4
View File
@@ -57,6 +57,7 @@ interface SettingsState {
showQuickCommandTags?: string; // 'true' or 'false'
layoutLocked?: string; // 'true' or 'false' - NEW: 布局锁定状态
terminalScrollbackLimit?: string; // NEW: 终端回滚行数上限 (e.g., '5000', '0' for unlimited)
fileManagerShowDeleteConfirmation?: string; // NEW: 'true' or 'false' - 文件管理器删除确认提示
[key: string]: string | undefined;
}
@@ -276,8 +277,13 @@ export const useSettingsStore = defineStore('settings', () => {
settings.value.terminalScrollbackLimit = '5000'; // 默认 5000 行
console.log(`[SettingsStore] terminalScrollbackLimit not found, set to default: ${settings.value.terminalScrollbackLimit}`);
}
// NEW: File Manager Delete Confirmation default
if (settings.value.fileManagerShowDeleteConfirmation === undefined) {
settings.value.fileManagerShowDeleteConfirmation = 'true'; // 默认显示删除确认
console.log(`[SettingsStore] fileManagerShowDeleteConfirmation not found, set to default: ${settings.value.fileManagerShowDeleteConfirmation}`);
}
// --- 语言设置 ---
const langFromSettings = settings.value.language;
console.log(`[SettingsStore] Language from fetched settings: ${langFromSettings}`); // <-- 添加日志
@@ -364,7 +370,8 @@ export const useSettingsStore = defineStore('settings', () => {
'showConnectionTags', // NEW
'showQuickCommandTags', // NEW
'layoutLocked', // NEW
'terminalScrollbackLimit' // NEW
'terminalScrollbackLimit', // NEW
'fileManagerShowDeleteConfirmation' // NEW
];
if (!allowedKeys.includes(key)) {
console.error(`[SettingsStore] 尝试更新不允许的设置键: ${key}`);
@@ -450,7 +457,8 @@ export const useSettingsStore = defineStore('settings', () => {
'showConnectionTags', // NEW
'showQuickCommandTags', // NEW
'layoutLocked', // NEW
'terminalScrollbackLimit' // NEW
'terminalScrollbackLimit', // NEW
'fileManagerShowDeleteConfirmation' // NEW
];
const filteredUpdates: Partial<SettingsState> = {};
let languageUpdate: string | undefined = undefined;
@@ -738,6 +746,11 @@ export const useSettingsStore = defineStore('settings', () => {
return val; // Return 0 if it's 0, or the positive number
});
// NEW: Getter for File Manager delete confirmation, returning boolean
const fileManagerShowDeleteConfirmationBoolean = computed(() => {
return settings.value.fileManagerShowDeleteConfirmation !== 'false'; // Default to true
});
return {
settings, // 只包含通用设置
isLoading,
@@ -779,5 +792,6 @@ export const useSettingsStore = defineStore('settings', () => {
// NEW: Expose layout locked getter
layoutLockedBoolean,
terminalScrollbackLimitNumber, // NEW: Expose terminal scrollback limit getter
fileManagerShowDeleteConfirmationBoolean, // NEW: Expose file manager delete confirmation getter
};
});
+53 -8
View File
@@ -504,6 +504,25 @@
</div>
</form>
</div>
<hr class="border-border/50"> <!-- NEW: Separator -->
<!-- File Manager Delete Confirmation -->
<div class="settings-section-content">
<h3 class="text-base font-semibold text-foreground mb-3">{{ $t('settings.workspace.fileManagerDeleteConfirmTitle', '文件管理器删除确认') }}</h3>
<form @submit.prevent="handleUpdateFileManagerDeleteConfirmation" class="space-y-4">
<div class="flex items-center">
<input type="checkbox" id="fileManagerShowDeleteConfirmation" v-model="fileManagerShowDeleteConfirmationLocal"
class="h-4 w-4 rounded border-border text-primary focus:ring-primary mr-2 cursor-pointer">
<label for="fileManagerShowDeleteConfirmation" class="text-sm text-foreground cursor-pointer select-none">{{ $t('settings.workspace.fileManagerShowDeleteConfirmationLabel', '删除文件或文件夹时显示确认提示框') }}</label>
</div>
<div class="flex items-center justify-between pt-2">
<button type="submit"
class="px-4 py-2 bg-button text-button-text rounded-md shadow-sm hover:bg-button-hover focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary transition duration-150 ease-in-out text-sm font-medium">
{{ $t('common.save') }}
</button>
<p v-if="fileManagerShowDeleteConfirmationMessage" :class="['text-sm', fileManagerShowDeleteConfirmationSuccess ? 'text-success' : 'text-error']">{{ fileManagerShowDeleteConfirmationMessage }}</p>
</div>
</form>
</div>
</div>
</div>
@@ -687,9 +706,10 @@ const {
showConnectionTagsBoolean, // NEW: Import connection tag visibility getter
showQuickCommandTagsBoolean, // NEW: Import quick command tag visibility getter
terminalScrollbackLimitNumber, // NEW: Import terminal scrollback limit getter
fileManagerShowDeleteConfirmationBoolean, // NEW: Import file manager delete confirmation getter
} = storeToRefs(settingsStore);
// Removed Passkey state import from authStore
// Removed Passkey state import from authStore
// --- Local state for forms ---
@@ -714,8 +734,9 @@ const ipBlacklistEnabled = ref(true); // <-- Local state for IP Blacklist switch
const showConnectionTagsLocal = ref(true); // NEW: Local state for connection tags switch
const showQuickCommandTagsLocal = ref(true); // NEW: Local state for quick command tags switch
const terminalScrollbackLimitLocal = ref<number | null>(null); // NEW: Local state for terminal scrollback limit input (allow null for empty input)
// --- Local UI feedback state ---
const fileManagerShowDeleteConfirmationLocal = ref(true); // NEW: Local state for file manager delete confirmation
// --- Local UI feedback state ---
const ipWhitelistLoading = ref(false);
const ipWhitelistMessage = ref('');
const ipWhitelistSuccess = ref(false);
@@ -767,6 +788,9 @@ const showQuickCommandTagsSuccess = ref(false); // NEW
const terminalScrollbackLimitLoading = ref(false); // NEW
const terminalScrollbackLimitMessage = ref(''); // NEW
const terminalScrollbackLimitSuccess = ref(false); // NEW
const fileManagerShowDeleteConfirmationLoading = ref(false); // NEW
const fileManagerShowDeleteConfirmationMessage = ref(''); // NEW
const fileManagerShowDeleteConfirmationSuccess = ref(false); // NEW
// CAPTCHA Form State
const captchaForm = reactive<UpdateCaptchaSettingsDto>({ // Use reactive for the form object
enabled: false,
@@ -819,7 +843,9 @@ watch(settings, (newSettings, oldSettings) => {
showQuickCommandTagsLocal.value = showQuickCommandTagsBoolean.value; // NEW: Sync quick command tags state
// NEW: Directly sync terminal scrollback limit from store getter to local state
terminalScrollbackLimitLocal.value = terminalScrollbackLimitNumber.value;
// NEW: Sync file manager delete confirmation
fileManagerShowDeleteConfirmationLocal.value = fileManagerShowDeleteConfirmationBoolean.value;
}, { deep: true, immediate: true }); // immediate: true to run on initial load
// Watcher for CAPTCHA settings
@@ -1076,9 +1102,28 @@ const handleUpdateTerminalScrollbackLimit = async () => {
} finally {
terminalScrollbackLimitLoading.value = false;
}
};
// --- ---
};
// --- File Manager Delete Confirmation setting method ---
const handleUpdateFileManagerDeleteConfirmation = async () => {
fileManagerShowDeleteConfirmationLoading.value = true;
fileManagerShowDeleteConfirmationMessage.value = '';
fileManagerShowDeleteConfirmationSuccess.value = false;
try {
const valueToSave = fileManagerShowDeleteConfirmationLocal.value ? 'true' : 'false';
await settingsStore.updateSetting('fileManagerShowDeleteConfirmation', valueToSave);
fileManagerShowDeleteConfirmationMessage.value = t('settings.workspace.fileManagerDeleteConfirmSuccess', '文件管理器删除确认设置已保存。'); //
fileManagerShowDeleteConfirmationSuccess.value = true;
} catch (error: any) {
console.error('更新文件管理器删除确认设置失败:', error);
fileManagerShowDeleteConfirmationMessage.value = error.message || t('settings.workspace.fileManagerDeleteConfirmError', '保存文件管理器删除确认设置失败。'); //
fileManagerShowDeleteConfirmationSuccess.value = false;
} finally {
fileManagerShowDeleteConfirmationLoading.value = false;
}
};
// --- ---
const openStyleCustomizer = () => {
appearanceStore.toggleStyleCustomizer(true);
};