feat(FileTree): 为重命名/新建弹窗添加自动聚焦和回车确认功能

- 使用 ref 引用输入框并在弹窗显示时自动聚焦
- 为输入框添加 pressEnter 事件监听以支持回车确认
- 统一背景菜单中字符串的引号格式
This commit is contained in:
cfq 2026-01-30 16:04:29 +08:00
parent 07d2134f8c
commit 49b89d7ea1
1 changed files with 13 additions and 4 deletions

View File

@ -76,7 +76,7 @@
<!-- 重命名/新建弹窗 -->
<a-modal v-model:open="modalVisible" :title="modalTitle" @ok="handleModalOk">
<a-input v-model:value="modalInputValue" :placeholder="modalPlaceholder" />
<a-input ref="modalInputRef" v-model:value="modalInputValue" :placeholder="modalPlaceholder" @pressEnter="handleModalOk" />
</a-modal>
</div>
</template>
@ -102,6 +102,15 @@ const currentNode = ref(null);
const searchKeyword = ref("");
const selectedKeys = ref([]);
const treeContentRef = ref(null);
const modalInputRef = ref(null);
watch(modalVisible, (val) => {
if (val) {
nextTick(() => {
modalInputRef.value?.focus();
});
}
});
// activeTab
watch(
@ -374,7 +383,7 @@ const handleMenuClick = async ({ key }, node) => {
};
const handleBackgroundMenuClick = ({ key }) => {
if (key === 'refresh') {
if (key === "refresh") {
handleRefresh();
return;
}
@ -383,11 +392,11 @@ const handleBackgroundMenuClick = ({ key }) => {
const separator = window.utools.isWindows() ? "\\" : "/";
// C:\pop() state.rootPath
const rootName = state.rootPath.split(separator).pop() || state.rootPath;
const rootNode = {
name: rootName,
path: state.rootPath,
type: "directory"
type: "directory",
};
handleMenuClick({ key }, rootNode);