import { computed, defineComponent, onMounted, ref, watch, } from 'vue' import useLayoutStore from '../useLayoutStore' import { OhVueIcon, addIcons } from 'oh-vue-icons' import clsx from 'clsx' import { BiChevronLeft } from "oh-vue-icons/icons"; import CategoryTab from '@/utils/CategoryTab'; import { BiChevronDown } from "oh-vue-icons/icons"; import request from '@/utils/request'; import useUserStore from '@/user/useUserStore'; import useRouterStore from '@/useRouterStore'; import useBackgroundStore from './useBackgroundStore'; addIcons(BiChevronLeft, BiChevronDown) const typeList = [ '热门', 'COSPALY', '二次元', '风景', '插画', '热门', 'COSPALY', '二次元', '风景', '插画', '热门', 'COSPALY', '二次元', '风景', '插画' ] const wallpaperAttrList = [ '动态壁纸', '静态壁纸', '自定义壁纸' ] export type BackgroundType = { id: string oridinal: number type: string attr: number } export type WallpaperItem = { id: string hotNum: number time: number typeId: string url: string } export default defineComponent(() => { const layout = useLayoutStore() const router = useRouterStore() const isGame = computed(() => layout.state.current === 0) const selectType = ref('') const addTo = ref(layout.state.currentPage) const typeList = ref([]) const wallpaperList = ref([]) const selectAttr = ref(0) const userStore = useUserStore() const backgroundStore = useBackgroundStore() const sortBy = ref<'hotNum' | 'time'>('hotNum') onMounted(() => { request("GET", "/api/backgroundTypes").then(res => { console.log(res); typeList.value = res selectType.value = res[0].id }) }) watch(() => [selectType.value, sortBy.value], (e) => { wallpaperList.value = [] request("GET", `/api/backgrounds?typeId=${e[0]}&sort=${sortBy.value}`).then(res => { console.log(res); wallpaperList.value = res }) }, { immediate: true }) watch(selectAttr, (e) => { selectType.value = typeList.value.filter(val => val.attr === e)[0].id || '' }) return () => (
壁纸库
) })