From b37eaf02fb0f7d951ea68854ab6992412954e690 Mon Sep 17 00:00:00 2001 From: engigu Date: Wed, 14 Jan 2026 19:46:25 +0800 Subject: [PATCH] fix: open url file render error --- web/src/router/index.ts | 2 +- web/src/views/editor/Editor.vue | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/web/src/router/index.ts b/web/src/router/index.ts index 7bf0afd..08fae73 100644 --- a/web/src/router/index.ts +++ b/web/src/router/index.ts @@ -39,7 +39,7 @@ const router = createRouter({ children: [ { path: '', name: 'dashboard', component: () => import('@/views/dashboard/Dashboard.vue') }, { path: 'tasks', name: 'tasks', component: () => import('@/views/tasks/Tasks.vue') }, - { path: 'editor/:path(.*)?', name: 'editor', component: () => import('@/views/editor/Editor.vue') }, + { path: 'editor', name: 'editor', component: () => import('@/views/editor/Editor.vue') }, { path: 'environments', name: 'environments', component: () => import('@/views/environments/Environments.vue') }, { path: 'dependencies', name: 'dependencies', component: () => import('@/views/dependencies/Dependencies.vue') }, { path: 'agents', name: 'agents', component: () => import('@/views/agents/Agents.vue') }, diff --git a/web/src/views/editor/Editor.vue b/web/src/views/editor/Editor.vue index 9876e0b..19d5565 100644 --- a/web/src/views/editor/Editor.vue +++ b/web/src/views/editor/Editor.vue @@ -76,8 +76,8 @@ async function loadTree() { async function handleSelect(node: FileNode) { selectedPath.value = node.path - // 更新 URL - router.replace({ name: 'editor', params: { path: node.path } }) + // 更新 URL 使用 query 参数 + router.replace({ name: 'editor', query: { file: node.path } }) if (node.isDir) { if (expandedDirs.value.has(node.path)) { @@ -217,10 +217,10 @@ async function handleMove(oldPath: string, newPath: string) { if (selectedFile.value === oldPath) { selectedFile.value = newPath selectedPath.value = newPath - router.replace({ name: 'editor', params: { path: newPath } }) + router.replace({ name: 'editor', query: { file: newPath } }) } else if (selectedPath.value === oldPath) { selectedPath.value = newPath - router.replace({ name: 'editor', params: { path: newPath } }) + router.replace({ name: 'editor', query: { file: newPath } }) } await loadTree() } catch { @@ -314,7 +314,7 @@ function expandParentDirs(path: string) { // 从 URL 初始化选中状态 async function initFromUrl() { await loadTree() - const urlPath = route.params.path as string + const urlPath = route.query.file as string if (urlPath) { selectedPath.value = urlPath expandParentDirs(urlPath) @@ -324,6 +324,7 @@ async function initFromUrl() { selectedFile.value = urlPath fileContent.value = res.content originalContent.value = res.content + isEditMode.value = false } catch { // 可能是文件夹,忽略错误 }