diff --git a/public/icons/uploadImg.png b/public/icons/uploadImg.png new file mode 100644 index 0000000..1b309bd Binary files /dev/null and b/public/icons/uploadImg.png differ diff --git a/src/layout/background/BackgroundSwtich.tsx b/src/layout/background/BackgroundSwtich.tsx index e947d8c..020039d 100644 --- a/src/layout/background/BackgroundSwtich.tsx +++ b/src/layout/background/BackgroundSwtich.tsx @@ -1,193 +1,235 @@ -import { - computed, - defineComponent, - onMounted, - ref, - watch, -} from 'vue' +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'; +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' +import { Button } from 'ant-design-vue' +import CustomWallpaper from './CustomWallpaper' + addIcons(BiChevronLeft, BiChevronDown) - const typeList = [ - '热门', - 'COSPALY', - '二次元', - '风景', - '插画', - '热门', - 'COSPALY', - '二次元', - '风景', - '插画', - '热门', - 'COSPALY', - '二次元', - '风景', - '插画' -] -const wallpaperAttrList = [ - '动态壁纸', - '静态壁纸', - '自定义壁纸' + '热门', + 'COSPALY', + '二次元', + '风景', + '插画', + '热门', + 'COSPALY', + '二次元', + '风景', + '插画', + '热门', + 'COSPALY', + '二次元', + '风景', + '插画' ] +const wallpaperAttrList = ['动态壁纸', '静态壁纸', '自定义壁纸'] export type BackgroundType = { - id: string - oridinal: number - type: string - attr: number + id: string + oridinal: number + type: string + attr: number } export type WallpaperItem = { - id: string - hotNum: number - time: number - typeId: string - url: string + 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) => { + const layout = useLayoutStore() + const router = useRouterStore() + const isGame = computed(() => layout.state.current === 0) + const selectType = ref('') + const typeList = ref([]) + const wallpaperList = ref([]) + const selectAttr = ref(0) + const userStore = useUserStore() - selectType.value = typeList.value.filter(val => val.attr === e)[0].id || '' + const sortBy = ref<'hotNum' | 'time'>('hotNum') + onMounted(() => { + request('GET', '/api/backgroundTypes').then((res) => { + console.log(res) + typeList.value = res + selectType.value = res[0].id }) - return () => ( -
[selectType.value, sortBy.value], + (e) => { + if (!e[0]) return + 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 () => ( +
+
-
- - 壁纸库 - + > + + 壁纸库 + +
+