fix: open url file render error
This commit is contained in:
@@ -39,7 +39,7 @@ const router = createRouter({
|
|||||||
children: [
|
children: [
|
||||||
{ path: '', name: 'dashboard', component: () => import('@/views/dashboard/Dashboard.vue') },
|
{ path: '', name: 'dashboard', component: () => import('@/views/dashboard/Dashboard.vue') },
|
||||||
{ path: 'tasks', name: 'tasks', component: () => import('@/views/tasks/Tasks.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: 'environments', name: 'environments', component: () => import('@/views/environments/Environments.vue') },
|
||||||
{ path: 'dependencies', name: 'dependencies', component: () => import('@/views/dependencies/Dependencies.vue') },
|
{ path: 'dependencies', name: 'dependencies', component: () => import('@/views/dependencies/Dependencies.vue') },
|
||||||
{ path: 'agents', name: 'agents', component: () => import('@/views/agents/Agents.vue') },
|
{ path: 'agents', name: 'agents', component: () => import('@/views/agents/Agents.vue') },
|
||||||
|
|||||||
@@ -76,8 +76,8 @@ async function loadTree() {
|
|||||||
|
|
||||||
async function handleSelect(node: FileNode) {
|
async function handleSelect(node: FileNode) {
|
||||||
selectedPath.value = node.path
|
selectedPath.value = node.path
|
||||||
// 更新 URL
|
// 更新 URL 使用 query 参数
|
||||||
router.replace({ name: 'editor', params: { path: node.path } })
|
router.replace({ name: 'editor', query: { file: node.path } })
|
||||||
|
|
||||||
if (node.isDir) {
|
if (node.isDir) {
|
||||||
if (expandedDirs.value.has(node.path)) {
|
if (expandedDirs.value.has(node.path)) {
|
||||||
@@ -217,10 +217,10 @@ async function handleMove(oldPath: string, newPath: string) {
|
|||||||
if (selectedFile.value === oldPath) {
|
if (selectedFile.value === oldPath) {
|
||||||
selectedFile.value = newPath
|
selectedFile.value = newPath
|
||||||
selectedPath.value = newPath
|
selectedPath.value = newPath
|
||||||
router.replace({ name: 'editor', params: { path: newPath } })
|
router.replace({ name: 'editor', query: { file: newPath } })
|
||||||
} else if (selectedPath.value === oldPath) {
|
} else if (selectedPath.value === oldPath) {
|
||||||
selectedPath.value = newPath
|
selectedPath.value = newPath
|
||||||
router.replace({ name: 'editor', params: { path: newPath } })
|
router.replace({ name: 'editor', query: { file: newPath } })
|
||||||
}
|
}
|
||||||
await loadTree()
|
await loadTree()
|
||||||
} catch {
|
} catch {
|
||||||
@@ -314,7 +314,7 @@ function expandParentDirs(path: string) {
|
|||||||
// 从 URL 初始化选中状态
|
// 从 URL 初始化选中状态
|
||||||
async function initFromUrl() {
|
async function initFromUrl() {
|
||||||
await loadTree()
|
await loadTree()
|
||||||
const urlPath = route.params.path as string
|
const urlPath = route.query.file as string
|
||||||
if (urlPath) {
|
if (urlPath) {
|
||||||
selectedPath.value = urlPath
|
selectedPath.value = urlPath
|
||||||
expandParentDirs(urlPath)
|
expandParentDirs(urlPath)
|
||||||
@@ -324,6 +324,7 @@ async function initFromUrl() {
|
|||||||
selectedFile.value = urlPath
|
selectedFile.value = urlPath
|
||||||
fileContent.value = res.content
|
fileContent.value = res.content
|
||||||
originalContent.value = res.content
|
originalContent.value = res.content
|
||||||
|
isEditMode.value = false
|
||||||
} catch {
|
} catch {
|
||||||
// 可能是文件夹,忽略错误
|
// 可能是文件夹,忽略错误
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user