From fed4110565eb8ee2f1d6c5ac9beb0115205dc4b8 Mon Sep 17 00:00:00 2001 From: cirry <812852553@qq.com> Date: Fri, 10 Jul 2026 16:58:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .reasonix/desktop-topic-auto-title-meta.json | 8 +- src/components/DirectorySidebar.vue | 113 ++++++++++++++++++- src/components/TreeEntry.vue | 92 --------------- 3 files changed, 116 insertions(+), 97 deletions(-) diff --git a/.reasonix/desktop-topic-auto-title-meta.json b/.reasonix/desktop-topic-auto-title-meta.json index 2811b3e..69570b6 100644 --- a/.reasonix/desktop-topic-auto-title-meta.json +++ b/.reasonix/desktop-topic-auto-title-meta.json @@ -30,10 +30,10 @@ "updatedAt": 1783653328367 }, "topic_20260710-032907_600adc6b00791607": { - "stage": 1, - "userTurns": 1, - "basisHash": "60a646e63a54c3bf", - "updatedAt": 1783669646165 + "stage": 3, + "userTurns": 3, + "basisHash": "179afc4a827fe6eb", + "updatedAt": 1783671091019 }, "topic_20260710-034033_6432ee6566f7b432": { "stage": 1, diff --git a/src/components/DirectorySidebar.vue b/src/components/DirectorySidebar.vue index 192d818..5fff412 100644 --- a/src/components/DirectorySidebar.vue +++ b/src/components/DirectorySidebar.vue @@ -3,6 +3,7 @@ import {ref, computed, onBeforeUnmount, watch, nextTick} from "vue"; import { invoke } from "@tauri-apps/api/core"; import SettingsModal from "./SettingsModal.vue"; import TreeEntry from "./TreeEntry.vue"; +import PromptDialog from "./PromptDialog.vue"; type SettingsPage = "about" | "editor"; type DocumentMode = "preview" | "edit" | "mixed"; @@ -524,6 +525,59 @@ function openSettings(page: SettingsPage) { showSettings.value = true; } +// ---- root create prompt ---- +const promptShow = ref(false); +const promptTitle = ref(""); +const promptMessage = ref(""); +const promptPlaceholder = ref(""); +const promptDefaultValue = ref(""); +let promptCallback: ((value: string) => void) | null = null; + +function openPrompt( + title: string, + message: string, + placeholder: string, + defaultValue: string, + cb: (value: string) => void, +) { + promptTitle.value = title; + promptMessage.value = message; + promptPlaceholder.value = placeholder; + promptDefaultValue.value = defaultValue; + promptCallback = cb; + promptShow.value = true; +} + +function onPromptConfirm(value: string) { + promptShow.value = false; + promptCallback?.(value); + promptCallback = null; +} + +function onPromptCancel() { + promptShow.value = false; + promptCallback = null; +} + +function joinWorkspacePath(name: string) { + const base = props.folderPath.replace(/[\\/]+$/, ""); + return `${base}/${name}`; +} + +function handleCreateRootFolder() { + if (!props.folderPath) return; + openPrompt("新建文件夹", "", "输入文件夹名称", "", (name) => { + emit("createFolder", joinWorkspacePath(name)); + }); +} + +function handleCreateRootFile() { + if (!props.folderPath) return; + openPrompt("新建 MD 文件", "", "输入文件名称(无需 .md 后缀)", "", (name) => { + emit("createFile", joinWorkspacePath(`${name}.md`)); + }); +} + @@ -568,10 +622,32 @@ function openSettings(page: SettingsPage) {