diff --git a/package.json b/package.json index 96260bd..1c1b3ae 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "ant-design-vue": "4.x", "clsx": "^2.1.1", "dayjs": "^1.11.13", + "gsap": "^3.12.5", "localforage": "^1.10.0", "lunar-typescript": "^1.7.5", "oh-vue-icons": "^1.0.0-rc3", diff --git a/public/bg/gameModel.png b/public/bg/gameModel.png new file mode 100644 index 0000000..0261d01 Binary files /dev/null and b/public/bg/gameModel.png differ diff --git a/src/GlobalModal.tsx b/src/GlobalModal.tsx index 303062b..8db28a9 100644 --- a/src/GlobalModal.tsx +++ b/src/GlobalModal.tsx @@ -7,8 +7,9 @@ import widgetList from '@/widgets' addIcons(MdClose, MdOpeninfull, MdClosefullscreen) const SearchPage = asyncLoader(() => import('@/layout/header/search/SearchPage')) const AdderPage = asyncLoader(() => import('@/layout/adder/AdderPage')) +const BackgroundSwtich = asyncLoader(() => import('@/layout/background/BackgroundSwtich')) -const noFullList: RouteStr[] = ['global-search', 'global-adder'] +const noFullList: RouteStr[] = ['global-search', 'global-adder', 'global-background'] export default defineComponent(() => { const router = useRouterStore() @@ -16,7 +17,8 @@ export default defineComponent(() => { () => router.path.startsWith('widget-') || router.path === 'global-search' || - router.path === 'global-adder' + router.path === 'global-adder' || + router.path === 'global-background' ) const full = ref(false) watch(router, () => { @@ -41,7 +43,7 @@ export default defineComponent(() => {
{ ) : router.path === 'global-adder' ? ( - ) : router.path.startsWith('widget-') ? ( - (() => { - const name = router.path.split('-')[1] - const selected = widgetList.find((el) => el.name === name) - if (!selected) - return ( -
- 组件维护中 -
- ) - const compo = selected.modal - console.log(compo) - return - })() - ) : null} + ) : router.path === 'global-background' ? ( + + ) : + router.path.startsWith('widget-') ? ( + (() => { + const name = router.path.split('-')[1] + const selected = widgetList.find((el) => el.name === name) + if (!selected) + return ( +
+ 组件维护中 +
+ ) + const compo = selected.modal + console.log(compo) + return + })() + ) : null}
diff --git a/src/layout/background/BackgroundPage.tsx b/src/layout/background/BackgroundPage.tsx index d909187..edb4cb3 100644 --- a/src/layout/background/BackgroundPage.tsx +++ b/src/layout/background/BackgroundPage.tsx @@ -60,7 +60,7 @@ export default defineComponent(() => {
- ) - } -}) \ No newline at end of file + + ) +}) diff --git a/src/main.css b/src/main.css index 8c3b320..869890c 100644 --- a/src/main.css +++ b/src/main.css @@ -157,3 +157,30 @@ body { scrollbar-width: none; -ms-overflow-style: none; } +@layer utilities { + .scrollbar-transparent::-webkit-scrollbar { + width: 0; + height: 0; + } + .scrollbar-hide::-webkit-scrollbar { + width: 0; + height: 0; + } + + .scrollbar-hide { + -ms-overflow-style: none; /* Internet Explorer 10+ */ + scrollbar-width: none; /* Firefox */ + } + .scrollbar-transparent::-webkit-scrollbar-thumb { + background-color: transparent; + } + + .scrollbar-transparent::-webkit-scrollbar-track { + background-color: transparent; + } + + .scrollbar-transparent { + scrollbar-width: thin; + scrollbar-color: transparent transparent; + } +} \ No newline at end of file diff --git a/src/utils/CategoryTab.tsx b/src/utils/CategoryTab.tsx new file mode 100644 index 0000000..9317599 --- /dev/null +++ b/src/utils/CategoryTab.tsx @@ -0,0 +1,94 @@ +import type { BackgroundType } from "@/layout/background/BackgroundSwtich"; +import clsx from "clsx"; +import gsap from "gsap"; +import { defineComponent, reactive, ref, watch, type SlotsType, type VNode } from "vue"; + +export default defineComponent({ + props: { + list: { + type: Array, + required: true + }, + selectType: { + type: String, + required: true, + }, + + }, + slots: {} as SlotsType<{ + select?: (text: string) => VNode[] + unSelect?: (text: string) => VNode[] + }>, + emits: ['update:type'], + setup(props, ctx) { + const tabRefs = ref<(Element | null)[]>([]) + const parentRef = ref(null) + const number = ref(0) + const tweened = reactive({ + number: 0 + }) + + + watch(number, (n) => { + gsap.to(tweened, { + number: n, + duration: .5, + onUpdate: () => { + if (parentRef.value) + parentRef.value.scrollLeft = tweened.number + }, + }); + }) + + watch(() => [props.selectType], () => { + const idx = props.list.findIndex((item) => item.id === props.selectType) + if (idx === -1) return + if (tabRefs.value[idx]) { + const childRef = tabRefs.value[idx] + if (!childRef) return + if (!childRef.parentElement) return + const parentRect = childRef.parentElement.getBoundingClientRect() + const childRect = childRef.getBoundingClientRect() + const distance = childRect.left - parentRect.left + if (!parentRef.value) return + if (idx > 3) { + number.value = distance - 350 + } else { + number.value = 0 + + } + } else { + number.value = 0 + + } + } + ) + return () => ( +
{ + e.preventDefault() + if (parentRef.value) + parentRef.value.scrollLeft += e.deltaY + + }}> + < div class="w-full flex gap-x-2 " > + { + + props.list.map((item, index) => ( + item.id === props.selectType ? +
+ {ctx.slots.select?.(item.type) || } +
+ :
{ + ctx.emit('update:type', item.id) + }}> + {ctx.slots.unSelect?.(item.type) || } +
+ )) + } +
+ + ) + }, +}) \ No newline at end of file