feat: 切换文件时不要触发 markdown code 的变更事件

This commit is contained in:
Frankie Huang 2025-05-20 23:13:43 +08:00
parent c590500d19
commit 8586dcc320

View File

@ -79,8 +79,10 @@ watch(rootFolderPath, (newRootPath) => {
// <FolderTree> currentFilePath
const currentFilePath = ref(localStorage.getItem('currentSelectedFilePath') || "");
let switchFilePath = false; // markdownCode watch
// currentFilePath MarkdownEditor
watch(currentFilePath, async (newFilePath) => {
switchFilePath = true;
localStorage.setItem('currentSelectedFilePath', newFilePath);
await readFileContent(newFilePath);
})
@ -94,6 +96,10 @@ const getFileNameFromFilePath = (filePath) => {
const mainEditor = ref(null);
const markdownCode = ref("# Hello Markdown");
watch(markdownCode, (newMarkdownCode) => {
if (switchFilePath === true) {
switchFilePath = false;
return;
}
console.log("code be updated");
})
async function readFileContent(filePath) {