From 66fd04b4e890a3463d739a6635077d7508069925 Mon Sep 17 00:00:00 2001 From: nekosu Date: Tue, 15 Aug 2023 19:51:54 +0800 Subject: [PATCH] feat: some optimize --- packages/client/src/components/tree/TaskTreeRender.tsx | 6 +++++- packages/client/src/data/filesystem.ts | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/client/src/components/tree/TaskTreeRender.tsx b/packages/client/src/components/tree/TaskTreeRender.tsx index 8cfb785..173903d 100644 --- a/packages/client/src/components/tree/TaskTreeRender.tsx +++ b/packages/client/src/components/tree/TaskTreeRender.tsx @@ -51,7 +51,11 @@ export function renderLabel({ option }: { option: TreeOption }) { } } } else { - return {option.key === '/' ? '[ROOT]' : option.label} + return ( + + {option.key === '/' ? '[ROOT]' : option.label} + + ) } } diff --git a/packages/client/src/data/filesystem.ts b/packages/client/src/data/filesystem.ts index 99bade8..394c8f9 100644 --- a/packages/client/src/data/filesystem.ts +++ b/packages/client/src/data/filesystem.ts @@ -1,5 +1,5 @@ import type { TreeOption, TreeSelectOption } from 'naive-ui' -import { computed, ref } from 'vue' +import { computed, ref, watch } from 'vue' import { type Path, @@ -15,6 +15,12 @@ export const expandKey = ref(['/' as PathKey]) export const renameKey = ref(null) export const renameInto = ref(null) +watch(expandKey, nv => { + if (!nv.includes('/' as PathKey)) { + expandKey.value = ['/' as PathKey, ...nv] + } +}) + export function makePngUrl(v: string | null) { const fallback = '/favicon-32x32.png' if (v && v.endsWith('.png')) {