From 743d820bc873f7d0230cfa5529b8a55c58cf3920 Mon Sep 17 00:00:00 2001 From: expdsn <18111002318@163.com> Date: Tue, 19 Nov 2024 18:58:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A4=B9=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E7=BC=BA=E5=B0=91=E5=BF=AB=E6=8D=B7=E6=B7=BB=E5=8A=A0=E5=9B=BE?= =?UTF-8?q?=E6=A0=87=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/adder/HotAdder.tsx | 31 +++++++++++++++++++++------- src/layout/grid/BlockWrapper.tsx | 2 +- src/layout/grid/DirBlock.tsx | 10 ++++++--- src/layout/grid/DirModal.tsx | 35 +++++++++++++++++++++++++++++--- src/layout/grid/LinkBlock.tsx | 7 +++++++ 5 files changed, 71 insertions(+), 14 deletions(-) diff --git a/src/layout/adder/HotAdder.tsx b/src/layout/adder/HotAdder.tsx index 789acff..c005ff0 100644 --- a/src/layout/adder/HotAdder.tsx +++ b/src/layout/adder/HotAdder.tsx @@ -5,6 +5,7 @@ import useLayoutStore from '../useLayoutStore' import { AddToToken } from './AdderPage' import { v4 as uuid } from 'uuid' import useAdderPageStore, { type HotAppType } from './useAdderPageStore' +import { globalToast } from '@/main' export const LinkItem = defineComponent({ props: { @@ -83,8 +84,8 @@ export const LinkItem = defineComponent({ } )} onClick={() => { - layout.addBlock( - { + if (layout.openDir) { + layout.state.dir[layout.openDir].list.push({ id: uuid(), link: props.content.url, name: props.content.name, @@ -95,11 +96,27 @@ export const LinkItem = defineComponent({ color: '', w: 1, h: 1 - }, - addTo?.value - ) - if (addTo?.value) { - layout.state.currentPage = addTo?.value + }) + globalToast.success('添加成功') + } else { + layout.addBlock( + { + id: uuid(), + link: props.content.url, + name: props.content.name, + label: props.content.name, + icon: props.content.icon, + text: '', + background: '', + color: '', + w: 1, + h: 1 + }, + addTo?.value + ) + if (addTo?.value) { + layout.state.currentPage = addTo?.value + } } }} > diff --git a/src/layout/grid/BlockWrapper.tsx b/src/layout/grid/BlockWrapper.tsx index 0748b65..908202f 100644 --- a/src/layout/grid/BlockWrapper.tsx +++ b/src/layout/grid/BlockWrapper.tsx @@ -170,7 +170,7 @@ export default defineComponent({ {props.block.link ? ( props.block.link.startsWith('id:') ? ( // 文件夹 - + ) : ( // 链接 diff --git a/src/layout/grid/DirBlock.tsx b/src/layout/grid/DirBlock.tsx index 27490c0..4df2447 100644 --- a/src/layout/grid/DirBlock.tsx +++ b/src/layout/grid/DirBlock.tsx @@ -32,8 +32,9 @@ export default defineComponent({ const menu = useMenuStore() return () => (
{ + onClick={(e) => { layout.openDir = props.block.link.slice(3) + e.stopPropagation() }} class={clsx('w-full h-full bg-white/60 backdrop-blur grid', { 'grid-rows-3 grid-cols-3 gap-[6%] p-[8%]': props.big, @@ -46,8 +47,11 @@ export default defineComponent({ {selectedDir.value.list .filter((_, idx) => idx < (props.big ? 9 : 4)) .map((el) => ( -
- +
+
))}
diff --git a/src/layout/grid/DirModal.tsx b/src/layout/grid/DirModal.tsx index f66f7e5..5a536e5 100644 --- a/src/layout/grid/DirModal.tsx +++ b/src/layout/grid/DirModal.tsx @@ -3,9 +3,17 @@ import useLayoutStore from '../useLayoutStore' import useSortable from './useSortable' import LinkBlock from './LinkBlock' import type { Block } from '../layout.types' +import useRouterStore from '@/useRouterStore' +import { globalToast } from '@/main' +import { addIcons, OhVueIcon } from 'oh-vue-icons' +import { MdAdd } from 'oh-vue-icons/icons' +import useAdderPageStore from '../adder/useAdderPageStore' +addIcons(MdAdd) export default defineComponent(() => { const layout = useLayoutStore() + const router = useRouterStore() + const addStore = useAdderPageStore() const dir = ref({ label: '', list: [] as Block[] }) // 因为有拖拽,关闭弹框不能使内容消失 watch( @@ -18,16 +26,18 @@ export default defineComponent(() => { computed(() => dir.value.list), computed(() => layout.openDir) ) + return () => (
{ + onClick={(e) => { + e.stopPropagation() layout.openDir = '' }} onDragenter={() => { @@ -63,14 +73,33 @@ export default defineComponent(() => { style={{ borderRadius: `calc(var(--block-radius) * var(--block-size))` }} + onClick={(e) => { + e.stopPropagation() + }} > - +
{block.label}
))} +
+
{ + router.go('global-adder') + }} + > + + + +
+
diff --git a/src/layout/grid/LinkBlock.tsx b/src/layout/grid/LinkBlock.tsx index 4786be4..84bdef0 100644 --- a/src/layout/grid/LinkBlock.tsx +++ b/src/layout/grid/LinkBlock.tsx @@ -16,6 +16,10 @@ export default defineComponent({ dock: { type: Boolean, default: false + }, + disable: { + type: Boolean, + default: false } }, setup(props) { @@ -25,9 +29,12 @@ export default defineComponent({
{ + if (props.disable) return menu.open(props.block) }} onClick={() => { + if (props.disable) return + jump(props.block.link) }} style={{