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