From 583b296acefdac93588dfc379870e6238f327ebc Mon Sep 17 00:00:00 2001 From: expdsn <18111002318@163.com> Date: Mon, 28 Oct 2024 18:51:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=B8=B8=E6=88=8F=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=EF=BC=8C=E6=8E=A5=E5=85=A5=E7=AC=AC=E4=B8=89=E6=96=B9?= =?UTF-8?q?=E6=B8=B8=E6=88=8F=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/adder/GameAdder.tsx | 114 ++++++++++++++++++++++++++------- src/utils/tool.ts | 16 +++++ 2 files changed, 107 insertions(+), 23 deletions(-) diff --git a/src/layout/adder/GameAdder.tsx b/src/layout/adder/GameAdder.tsx index f2c712a..61df251 100644 --- a/src/layout/adder/GameAdder.tsx +++ b/src/layout/adder/GameAdder.tsx @@ -7,6 +7,11 @@ import useLayoutStore from '../useLayoutStore' import { AddToToken } from './AdderPage' import { v4 as uuid } from 'uuid' import { Button } from 'ant-design-vue' +import { frontAddress, ossBase } from '@/config' +import dayjs from 'dayjs' +import { generateRandomString } from '@/utils/tool' +import MD5 from 'crypto-js/md5' +const SECRET = 'A1Cv12olxT12dOE3xA1vPA==' const URL_ADDRESS = 'http://newfatfox.oss-cn-beijing.aliyuncs.com' interface GameType { id: string @@ -18,6 +23,18 @@ interface GameType { despt: string icon: string } +interface OtherGame { + id: number // 游戏ID + category_ids: number[] // 分类ID数组 + rank: number // 排名 + name: string // 游戏名称 + short_description: string // 简短描述 + description: string // 详细描述 + url: string // 游戏详情链接 + icon: string // 图标URL + cover_url: string // 封面URL + corner_mark: number // 角标标识 +} export const GameItem = defineComponent({ props: { content: { @@ -31,7 +48,7 @@ export const GameItem = defineComponent({ const addTo = inject(AddToToken) return () => (
{ const isGame = computed(() => layout.state.current === 0) const appList = ref([]) const selectType = ref('fc') - + const fetchGame = async (page: number) => { + const parems = `nonce=${generateRandomString(8)}&pid=PIDc8uT24mpo×tamp=${dayjs().unix()}` + const sign = MD5(parems + SECRET).toString() + const response = await fetch( + `https://ge.yiqiyoo.com/game/v2/third-part/games?${parems}&sign=${sign}&paginate.limit=99&paginate.page=${page}` + ) + const res = await response.json() + return res.data.items + } watch( selectType, (val) => { loading.value = true - - request('GET', `/api/games?type=${val}`) - .then((res) => { - appList.value = res - }) - .finally(() => { + if (val !== 'yiqiyoo') { + request('GET', `/api/games?type=${val}`) + .then((res) => { + appList.value = res + }) + .finally(() => { + setTimeout(() => { + loading.value = false + }, 200) + }) + } else { + try { + Promise.all([fetchGame(1), fetchGame(2), fetchGame(3)]).then((res) => { + console.log(res.flat()) + const resData = res.flat() as OtherGame[] + appList.value = resData.map((el) => ({ + id: el.id.toString(), + name: el.name, + despt: el.short_description, + icon: el.icon, + rom: el.url, + playstation: el.url, + hot: el.rank, + category: el.category_ids[0].toString() + })) + }) + } catch (err) { + console.error(err) + } finally { setTimeout(() => { loading.value = false }, 200) - }) + } + } }, { immediate: true @@ -144,7 +205,13 @@ export default defineComponent(() => { oridinal: 1 }, { - id: 'gma', + id: 'yiqiyoo', + type: '休闲游戏', + attr: 1, + oridinal: 2 + }, + { + id: 'gba', type: '经典GBA', attr: 3, oridinal: 3 @@ -158,10 +225,10 @@ export default defineComponent(() => { select: (text: string) => (