diff --git a/public/icons/classicPlay.png b/public/icons/classicPlay.png new file mode 100644 index 0000000..d801928 Binary files /dev/null and b/public/icons/classicPlay.png differ diff --git a/src/App.vue b/src/App.vue index ae94a70..732fce1 100644 --- a/src/App.vue +++ b/src/App.vue @@ -34,7 +34,7 @@ const layout = useLayoutStore() - +
diff --git a/src/layout/adder/GameAdder.tsx b/src/layout/adder/GameAdder.tsx index ba7b19c..3bcc421 100644 --- a/src/layout/adder/GameAdder.tsx +++ b/src/layout/adder/GameAdder.tsx @@ -1,6 +1,6 @@ import CategoryTab from '@/utils/CategoryTab' import request from '@/utils/request' -import { computed, defineComponent, inject, ref, watch } from 'vue' +import { computed, defineComponent, inject, ref, watch } from 'vue' import clsx from 'clsx' import useLayoutStore from '../useLayoutStore' import { AddToToken } from './AdderPage' @@ -9,9 +9,9 @@ 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 { +export const SECRET = 'A1Cv12olxT12dOE3xA1vPA==' +export const URL_ADDRESS = 'http://newfatfox.oss-cn-beijing.aliyuncs.com' +export interface GameType { id: string name: string rom: string @@ -21,7 +21,7 @@ interface GameType { despt: string icon: string } -interface OtherGame { +export interface OtherGame { id: number // 游戏ID category_ids: number[] // 分类ID数组 rank: number // 排名 @@ -33,6 +33,32 @@ interface OtherGame { cover_url: string // 封面URL corner_mark: number // 角标标识 } +export const DefautGameTypeList = [ + { + id: 'fc', + type: '经典红白机', + attr: 0, + oridinal: 0 + }, + { + id: 'md', + type: '经典世嘉', + attr: 1, + oridinal: 1 + }, + { + id: 'yiqiyoo', + type: '休闲游戏', + attr: 1, + oridinal: 2 + }, + { + id: 'gba', + type: '经典GBA', + attr: 3, + oridinal: 3 + } +] export const GameItem = defineComponent({ props: { content: { @@ -100,9 +126,9 @@ export const GameItem = defineComponent({ id: uuid(), link: !props.content.rom.startsWith('http') ? `${frontAddress}/emu/#/home?params=${JSON.stringify({ - ...props.content, - rom: ossBase + '/' + props.content.rom - })}` + ...props.content, + rom: ossBase + '/' + props.content.rom + })}` : props.content.rom, name: '', label: props.content.name, @@ -188,32 +214,7 @@ export default defineComponent(() => {
{ selectType.value = e diff --git a/src/layout/grid/TomatoPage.tsx b/src/layout/grid/TomatoPage.tsx index 6601cd9..0b658d9 100644 --- a/src/layout/grid/TomatoPage.tsx +++ b/src/layout/grid/TomatoPage.tsx @@ -10,6 +10,7 @@ import useTomatoStore, { musicList } from '@/widgets/work/useTomatoStore' import Search from '../header/search' import { Modal, Tooltip } from 'ant-design-vue' import { formatSeconds } from '@/utils/tool' +import clsx from 'clsx' export const DefaultPageSetting = [ { name: '游戏', @@ -55,7 +56,6 @@ export default defineComponent(() => { watch(() => store.remainingTime , (val) => { - console.log(val); if (val <= 0) { store.stopTomatoTime() @@ -123,28 +123,33 @@ export default defineComponent(() => { }}>确定
- { - Array.from({ length: 60 }).map((_, idx) => ( -
+ { + Array.from({ length: 60 }).map((_, idx) => ( +
= idx) ? "bg-white" : "bg-white/50" + )} style={{ + transformOrigin: '250px', + borderRadius: '3px', + transform: `rotateZ(${idx * 6}deg)` - }}> + }}> + +
+ )) + } +
-
- )) - }
专注中 {!store.state.isStart ? '15:00' : formatSeconds(store.remainingTime)}
-
+
-
+
{ diff --git a/src/layout/header/search/SearchConfig.tsx b/src/layout/header/search/SearchConfig.tsx index 736fa07..9577b14 100644 --- a/src/layout/header/search/SearchConfig.tsx +++ b/src/layout/header/search/SearchConfig.tsx @@ -14,7 +14,7 @@ export default defineComponent({ const router = useRouterStore() return () => (
{ search.showSearchConfig = false }} diff --git a/src/layout/header/search/SearchHistory.tsx b/src/layout/header/search/SearchHistory.tsx index bca4c44..01239dc 100644 --- a/src/layout/header/search/SearchHistory.tsx +++ b/src/layout/header/search/SearchHistory.tsx @@ -11,7 +11,7 @@ export default defineComponent(() => { const settings = useSettingsStore() return () => settings.state.showHistory && ( -
+
{searchConfig.history.map((item, idx) => (
{ + const selectType = ref('fc') + const appList = ref([]) + const hoverId = ref(0) + const loading = ref(false) + 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) => { + console.log(val); + appList.value = [] + loading.value = true + + if (val !== 'yiqiyoo') { + request('GET', `/api/games?type=${val}`) + .then((res) => { + appList.value = res + }) + .finally(() => { + loading.value = false + }) + } else { + try { + Promise.all([fetchGame(1)]).then((res) => { + 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 { + loading.value = false + } + } + }, + { + immediate: true + } + ) return () => ( -
- large +
{ + + }} + > +
+
+
+ { + DefautGameTypeList.map(item => ( +
{ + selectType.value = item.id + }} + class={clsx("flex items-center jusitfy-center relative py-4 text-[13px]", + selectType.value === item.id ? "text-[#589fff]" : " text-[#589fffcc]" + )} > + {item.type} + { + selectType.value === item.id && +
+ } +
+ )) + } +
+ 查看更多 + +
+ { + !loading.value && + +
+
+ { + appList.value.filter((_, index) => index < 10).map((item, idx) => ( +
{ + hoverId.value = idx + }} + style={{ + background: hoverId.value === idx ? "rgba(61,80,105,.8)" : "transparent" + }}> +
{idx + 1}
+
+ { + hoverId.value === idx ? +
+
+ +
+ {item.name} + {item.despt} + +
+
+ +
: +
+ {item.name} + {item.despt} + +
+ } + +
+
+ )) + } +
+
+ } +
) }) diff --git a/src/widgets/game/Middle.tsx b/src/widgets/game/Middle.tsx deleted file mode 100644 index 53edc23..0000000 --- a/src/widgets/game/Middle.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { defineComponent } from 'vue' - -export default defineComponent(() => { - - return () => ( -
- middle -
- ) -}) diff --git a/src/widgets/game/Modal.tsx b/src/widgets/game/Modal.tsx deleted file mode 100644 index 9890740..0000000 --- a/src/widgets/game/Modal.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import { defineComponent } from 'vue' - -export default defineComponent(() => { - return () => ( -
- ) -}) diff --git a/src/widgets/game/Small.tsx b/src/widgets/game/Small.tsx deleted file mode 100644 index bf0a763..0000000 --- a/src/widgets/game/Small.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import { defineComponent } from 'vue' - -export default defineComponent(() => { - return () => ( -
- -
- ) -}) diff --git a/src/widgets/game/index.ts b/src/widgets/game/index.ts index 5f92e14..6cd4ee7 100644 --- a/src/widgets/game/index.ts +++ b/src/widgets/game/index.ts @@ -3,23 +3,11 @@ import type { Widget } from '..' export default { name: 'gameNews', - label: '游戏资讯', - description: '游戏资讯', - icon: '/tab/icons/game_news_icon.png', - modal: asyncLoader(() => import('./Modal')), + label: '经典即玩游戏', + description: '经典即玩游戏', + icon: '/tab/icons/classicPlay.png', + modal: null, list: [ - { - w: 2, - h: 1, - label: '小', - component: asyncLoader(() => import('./Small')) - }, - { - w: 2, - h: 2, - label: '中', - component: asyncLoader(() => import('./Middle')) - }, { w: 4, h: 2, diff --git a/src/widgets/index.ts b/src/widgets/index.ts index 88d59c7..3cb7e39 100644 --- a/src/widgets/index.ts +++ b/src/widgets/index.ts @@ -9,6 +9,7 @@ import hotspot from './hotspot' import constellation from './constellation' import gameVideo from './gameVideo' import work from './work' +import game from './game' export interface Widget { name: string // 小组件类型唯一标识 label: string // 小组件名称 @@ -23,4 +24,4 @@ export interface Widget { }[] // 不同尺寸小组件块 } -export default [calendar, weather, weApply, gameNews, eat, discount, hotspot, constellation, gameVideo, work] as Widget[] +export default [game, calendar, weather, weApply, gameNews, eat, discount, hotspot, constellation, gameVideo, work] as Widget[] diff --git a/src/widgets/work/index.ts b/src/widgets/work/index.ts index 891fd6d..f3394fa 100644 --- a/src/widgets/work/index.ts +++ b/src/widgets/work/index.ts @@ -8,17 +8,18 @@ export default { icon: '/tab/icons/work/tomato_work_icon.png', modal: asyncLoader(() => import('./Modal')), list: [ + { + w: 4, + h: 2, + label: '大', + component: asyncLoader(() => import('./Large')) + }, { w: 2, h: 1, label: '小', component: asyncLoader(() => import('./Small')) }, - { - w: 4, - h: 2, - label: '大', - component: asyncLoader(() => import('./Large')) - } + ] } as Widget