From b34920f5c04284616e4193f94015044576c2f133 Mon Sep 17 00:00:00 2001 From: expdsn <18111002318@163.com> Date: Tue, 19 Nov 2024 18:38:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=B8=E6=88=8F=E8=A7=86=E9=A2=91=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E4=B8=8D=E6=94=AF=E6=8C=81=E5=A4=A7=E4=B8=AD=E5=B0=8F?= =?UTF-8?q?=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/grid/BlockWrapper.tsx | 3 + src/layout/grid/index.tsx | 3 +- src/widgets/gameVideo/Middle.tsx | 115 +++++++++++++++++++++++++++++++ src/widgets/gameVideo/Small.tsx | 42 +++++++++++ src/widgets/gameVideo/index.ts | 12 ++++ 5 files changed, 174 insertions(+), 1 deletion(-) create mode 100644 src/widgets/gameVideo/Middle.tsx create mode 100644 src/widgets/gameVideo/Small.tsx diff --git a/src/layout/grid/BlockWrapper.tsx b/src/layout/grid/BlockWrapper.tsx index 72381b9..0748b65 100644 --- a/src/layout/grid/BlockWrapper.tsx +++ b/src/layout/grid/BlockWrapper.tsx @@ -42,6 +42,9 @@ export default defineComponent({ transition: 'border .3s, transform .2s' // border: hover.value ? '2px solid rgba(255,255,255,.5)' : '2px solid rgba(255,255,255,0)' }} + onDblclick={e=> { + e.stopPropagation() + }} data-transportable={props.block.link && !props.block.link.startsWith('id:') ? '1' : ''} onDragover={(e) => { e.preventDefault() diff --git a/src/layout/grid/index.tsx b/src/layout/grid/index.tsx index 7743145..b7a8900 100644 --- a/src/layout/grid/index.tsx +++ b/src/layout/grid/index.tsx @@ -51,7 +51,8 @@ export default defineComponent(() => { layout.isCompact = false } }} - onDblclick={() => { + onDblclick={(e) => { + e.stopPropagation() layout.state.simple = !layout.state.simple }} onDragover={(e) => e.preventDefault()} diff --git a/src/widgets/gameVideo/Middle.tsx b/src/widgets/gameVideo/Middle.tsx new file mode 100644 index 0000000..71301f8 --- /dev/null +++ b/src/widgets/gameVideo/Middle.tsx @@ -0,0 +1,115 @@ +import useLayoutStore from '@/layout/useLayoutStore' +import request from '@/utils/request' +import { addIcons, OhVueIcon } from 'oh-vue-icons' +import { computed, defineComponent, onMounted, ref, watch, type CSSProperties } from 'vue' +import { FaChevronLeft } from 'oh-vue-icons/icons' +import PlayImg from '~/icons/game_video_bg_play.png' +import type { CarouselRef } from 'ant-design-vue/es/carousel' +import { randomNum } from '@/utils/tool' +import jump from '@/utils/jump' +addIcons(FaChevronLeft) +interface Owner { + face: string + mid: number + name: string +} + +interface GameData { + _id: string + aid: number + ctime: number + duration: number + owner: Owner + pic: string + rid: string + time: string + title: string + type: string +} +export default defineComponent(() => { + const list = ref([]) + const currentIndex = ref(-1) + + const current = computed(() => { + if (currentIndex.value === -1) { + return null + } else { + return list.value[currentIndex.value] + } + }) + watch( + () => useLayoutStore().state.current, + (val) => { + const type = val === 0 ? 'game' : val === 1 ? 'know' : 'ent' + request('GET', `/api/hotVideo?type=${type}`).then((res) => { + list.value = res + currentIndex.value = randomNum(0, res.length) + }) + }, + { + immediate: true + } + ) + onMounted(() => { + setInterval(() => { + currentIndex.value = currentIndex.value === list.value.length - 1 ? 0 : currentIndex.value + 1 + }, 7000) + }) + return () => ( +
+ + + { +
{ + jump('https://www.bilibili.com/video/av' + current.value?.aid) + }} + style={{ + backgroundImage: `url('${current.value?.pic}')`, + backgroundSize: 'cover', + backgroundPosition: 'center', + backgroundRepeat: 'no-repeat' + }} + > +
+
{ + e.stopPropagation() + + currentIndex.value = + currentIndex.value === 0 ? list.value.length - 1 : currentIndex.value - 1 + }} + class="absolute hidden bottom-[20px] group-hover:flex items-center justify-center left-[0px] w-[22px] h-[22px] bg-white/30 rounded" + > + +
+
{ + e.stopPropagation() + currentIndex.value = + currentIndex.value === list.value.length - 1 ? 0 : currentIndex.value + 1 + }} + class="absolute hidden bottom-[20px] group-hover:flex items-center justify-center right-[0px] rotate-180 w-[22px] h-[22px] bg-white/30 rounded" + > + +
+
+ } + + + {current.value?.title} + + {current.value?.owner.name} +
+ ) +}) diff --git a/src/widgets/gameVideo/Small.tsx b/src/widgets/gameVideo/Small.tsx new file mode 100644 index 0000000..8e50a61 --- /dev/null +++ b/src/widgets/gameVideo/Small.tsx @@ -0,0 +1,42 @@ +import useLayoutStore from '@/layout/useLayoutStore' +import jump from '@/utils/jump' +import { defineComponent } from 'vue' + +export default defineComponent(() => { + const layout = useLayoutStore() + return () => ( +
{ + jump( + 'https://www.bilibili.com/v' + + (layout.state.current === 0 ? '/game' : layout.state.current === 1 ? '/knowledge' : '/ent') + ) + }} + > + +
+
+ + {useLayoutStore().state.current === 0 + ? '游戏' + : useLayoutStore().state.current === 1 + ? '学习' + : '娱乐'} + 视频 + +
+ 立即查看 +
+ +
+
+
+
+
+ ) +}) diff --git a/src/widgets/gameVideo/index.ts b/src/widgets/gameVideo/index.ts index 5a8d17c..6423574 100644 --- a/src/widgets/gameVideo/index.ts +++ b/src/widgets/gameVideo/index.ts @@ -13,6 +13,18 @@ export default { h: 2, label: '大', component: asyncLoader(() => import('./Large')) + }, + { + w: 2, + h: 2, + label: '中', + component: asyncLoader(() => import('./Middle')) + }, + { + w: 2, + h: 1, + label: '小', + component: asyncLoader(() => import('./Small')) } ] } as Widget