From 6396032e55c56c758f4e79189e6eea66cfab16e1 Mon Sep 17 00:00:00 2001 From: nekosu Date: Tue, 15 Aug 2023 00:14:44 +0800 Subject: [PATCH] feat: view png --- .../src/components/atomic/ImageHover.vue | 23 ++++-------------- .../client/src/components/tree/TaskTree.vue | 3 +-- packages/client/src/data/filesystem.ts | 24 ++++++++++++++++++- packages/client/src/views/EditView.vue | 19 ++++++++++++--- 4 files changed, 44 insertions(+), 25 deletions(-) diff --git a/packages/client/src/components/atomic/ImageHover.vue b/packages/client/src/components/atomic/ImageHover.vue index 87035d1..9e8151a 100644 --- a/packages/client/src/components/atomic/ImageHover.vue +++ b/packages/client/src/components/atomic/ImageHover.vue @@ -2,27 +2,12 @@ import { NAvatar, NPopover } from 'naive-ui' import { computed } from 'vue' -import { type Path, fs, pool } from '@/filesystem' +import { makePngUrl } from '@/data' const props = defineProps<{ url: string | string[] }>() -function makeUrl(v: string | null) { - const fallback = '/favicon-32x32.png' - if (v && v.endsWith('.png')) { - // TODO: maybe check? - const hash = fs.tree.readFile(v as Path) - if (hash) { - const url = pool.query(hash) - if (url) { - return url - } - } - } - return fallback -} - const first = computed(() => { return props.url instanceof Array ? props.url.length > 0 @@ -37,15 +22,15 @@ const first = computed(() => {
- +
diff --git a/packages/client/src/components/tree/TaskTree.vue b/packages/client/src/components/tree/TaskTree.vue index 7eae646..028f23a 100644 --- a/packages/client/src/components/tree/TaskTree.vue +++ b/packages/client/src/components/tree/TaskTree.vue @@ -53,7 +53,6 @@ function handleDrop({ node, dragNode, dropPosition }: TreeDropInfo) { const [td, tf, th] = path.divide(toKey) if (path.key_is_dir(fromKey)) { // dragging directory - switch (dropPosition) { case 'inside': { if (!path.key_is_dir(toKey)) { @@ -160,7 +159,7 @@ function handleDrop({ node, dragNode, dropPosition }: TreeDropInfo) {