From aa877662be7e8ff82a7d75b4722132fb3d86d9b3 Mon Sep 17 00:00:00 2001 From: plightfield <1207120484@qq.com> Date: Mon, 4 Nov 2024 14:53:07 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=8F=92=E4=BB=B6=E4=BA=A4=E4=BA=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/fox/index.tsx | 2 ++ src/utils/parent.ts | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 src/utils/parent.ts diff --git a/src/fox/index.tsx b/src/fox/index.tsx index 3bba3d0..2d54d14 100644 --- a/src/fox/index.tsx +++ b/src/fox/index.tsx @@ -8,6 +8,7 @@ import { defineComponent, onMounted, onUnmounted, ref, watch } from 'vue' import useRouterStore from '@/useRouterStore' import useSearchStore from '@/layout/header/search/useSearchStore' import useLayoutStore from '@/layout/useLayoutStore' +import { sendParent } from '@/utils/parent' const stageStrList = [ 'dazhaohu', @@ -128,6 +129,7 @@ export default defineComponent(() => { }} onClick={() => { run('aixin') + sendParent(['openSide']) }} /> ) diff --git a/src/utils/parent.ts b/src/utils/parent.ts new file mode 100644 index 0000000..b937712 --- /dev/null +++ b/src/utils/parent.ts @@ -0,0 +1,19 @@ +// 发送消息 +export function sendParent(data: ['openSide']) { + parent.window.postMessage( + { + type: data[0], + data: (data as any)[1] + }, + '*' + ) +} + +// 接收消息 +export function listenParent(type: string, cb: (data: T) => void) { + window.addEventListener('message', (e) => { + if (e.data?.type === 'uitab-' + type) { + cb(e.data.data) + } + }) +} From ed10c2b118f716893318201bb4ef485c35bd7e16 Mon Sep 17 00:00:00 2001 From: plightfield <1207120484@qq.com> Date: Fri, 8 Nov 2024 17:35:33 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E9=BB=98=E8=AE=A4=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E5=92=8C=E5=B9=BF=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/grid/LinkBlock.tsx | 9 ++++++-- src/layout/grid/WelcomePage.tsx | 11 +++++++-- src/utils/jump.ts | 41 ++++++++++++++------------------- src/widgets/game/index.ts | 2 +- 4 files changed, 34 insertions(+), 29 deletions(-) diff --git a/src/layout/grid/LinkBlock.tsx b/src/layout/grid/LinkBlock.tsx index cec8f0a..a9d5342 100644 --- a/src/layout/grid/LinkBlock.tsx +++ b/src/layout/grid/LinkBlock.tsx @@ -1,6 +1,7 @@ import { defineComponent } from 'vue' import type { Block } from '../layout.types' import { useMenuStore } from '../GlobalMenu' +import jump from '@/utils/jump' export default defineComponent({ props: { @@ -28,7 +29,7 @@ export default defineComponent({ menu.open(props.block) }} onClick={() => { - window.open(props.block.link, '_blank') + jump(props.block.link) }} style={{ backgroundColor: props.block.background || 'white', @@ -61,7 +62,11 @@ export default defineComponent({ {props.block.label} - game_icon + game_icon ) } diff --git a/src/layout/grid/WelcomePage.tsx b/src/layout/grid/WelcomePage.tsx index 48d7ac7..d9c70cf 100644 --- a/src/layout/grid/WelcomePage.tsx +++ b/src/layout/grid/WelcomePage.tsx @@ -4,6 +4,7 @@ import DivBgImg from '~/icons/welcome/back.png' import startUseImg from '~/icons/welcome/startUse.png' import useBackgroundStore from '../background/useBackgroundStore' import useLayoutStore from '../useLayoutStore' +import request from '@/utils/request' export const DefaultPageSetting = [ { name: '游戏', @@ -43,7 +44,6 @@ export default defineComponent(() => { if (!visited) { // 如果没有记录,说明是第一次访问 isFirst.value = true - // 设置标记,后续访问不会再次显示 } }) return () => @@ -123,7 +123,14 @@ export default defineComponent(() => { onClick={() => { localStorage.setItem('hasVisited', 'true') isFirst.value = false - layout.changeBackground(DefaultPageSetting[selectMode.value].backgroundUrl) + + // 设置标记,后续访问不会再次显示 + // 获取默认界面 + request('GET', '/api/app/desktop').then((res: any) => { + if (!res) return + layout.state.dir = res.dir + layout.state.content = res.content + }) }} style={{ backgroundImage: `url('${startUseImg}')`, diff --git a/src/utils/jump.ts b/src/utils/jump.ts index 7c5454e..c676f8e 100644 --- a/src/utils/jump.ts +++ b/src/utils/jump.ts @@ -1,25 +1,20 @@ import db from '@/db' +import request from './request' -interface AdverLink { - id: string - tag: string - adverLink: string -} -type AdverParams = Omit & { - adverParams: string -} +type AdverContent = { id: string; tag: string; content: string } type AdverData = { - links: AdverLink[] - params: AdverParams[] + links: AdverContent[] + params: AdverContent[] expiration: number } const fetchAdverConfig = async () => { return Promise.allSettled([ - fetch('https://api.iyuntab.com/adverLink/params').then((res) => res.json()), - fetch('https://api.iyuntab.com/adverLink/link').then((res) => res.json()) - ]).then((res) => { + request('GET', '/api/app/adverLinks/params'), + request('GET', '/api/app/adverLinks/link') + ]).then((res: any) => { + console.log('----', res) const result: AdverData = { links: [], params: [], expiration: Date.now() + 1000 * 60 * 60 * 4 } if (res[0].status === 'fulfilled') { result.params = res[0].value @@ -31,14 +26,12 @@ const fetchAdverConfig = async () => { }) } export function getAdverConfig() { - return db - .getItem<{ links: AdverLink[]; params: AdverParams[]; expiration: number }>('adverInfo') - .then((res) => { - if (!res || res.expiration < Date.now()) { - return fetchAdverConfig() - } - return Promise.resolve(res) - }) + return db.getItem('adverInfo').then((res) => { + if (!res || res.expiration < Date.now()) { + return fetchAdverConfig() + } + return Promise.resolve(res) + }) } async function checkWithAdver(_url: string) { @@ -47,7 +40,7 @@ async function checkWithAdver(_url: string) { const tag = _url.match(/(?<=http(s?):\/\/).*/g)?.[0] || _url for (const item of config.params) { if (tag.startsWith(item.tag)) { - const params = new URLSearchParams(item.adverParams) + const params = new URLSearchParams(item.content) const origin = new URLSearchParams(_url.includes('?') ? _url : _url + '?') for (const key of params.keys()) { const value = params.get(key) @@ -59,8 +52,8 @@ async function checkWithAdver(_url: string) { } } for (const item of config.links) { - if (item.tag.startsWith(tag)) { - return item.adverLink + if (_url.startsWith(item.tag)) { + return item.content } } return _url diff --git a/src/widgets/game/index.ts b/src/widgets/game/index.ts index 6cd4ee7..99fed72 100644 --- a/src/widgets/game/index.ts +++ b/src/widgets/game/index.ts @@ -2,7 +2,7 @@ import asyncLoader from '@/utils/asyncLoader' import type { Widget } from '..' export default { - name: 'gameNews', + name: 'gamePlay', label: '经典即玩游戏', description: '经典即玩游戏', icon: '/tab/icons/classicPlay.png', From f7a99e7a6504dcc3ad42748b7a5e715497358165 Mon Sep 17 00:00:00 2001 From: plightfield <1207120484@qq.com> Date: Fri, 8 Nov 2024 19:51:42 +0800 Subject: [PATCH 3/4] change --- src/user/useUserStore.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/user/useUserStore.ts b/src/user/useUserStore.ts index 3a299dd..97b1f65 100644 --- a/src/user/useUserStore.ts +++ b/src/user/useUserStore.ts @@ -30,7 +30,6 @@ export default defineStore('user', () => { if (!val) return request('GET', '/api/profile').then((res) => { Object.assign(profile, res) - }) }, { immediate: true } @@ -41,6 +40,7 @@ export default defineStore('user', () => { Object.assign(profile, { ...defaultUserInfo }) // profile.avatar = '' } + // 自动备份 return { token, profile, From 245f5931f7495cf1a2261923976933d65075e21b Mon Sep 17 00:00:00 2001 From: plightfield <1207120484@qq.com> Date: Mon, 11 Nov 2024 11:53:26 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=8F=B3=E9=94=AE=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- src/GlobalModal.tsx | 6 +- src/index.html | 12 --- src/layout/GlobalMenu.tsx | 101 +++++++++++++++++++-- src/layout/adder/AdderPage.tsx | 19 ++-- src/layout/dock/index.tsx | 27 +++--- src/layout/grid/BlockWrapper.tsx | 4 + src/layout/grid/DirBlock.tsx | 5 +- src/layout/grid/DirModal.tsx | 9 +- src/layout/grid/LinkBlock.tsx | 6 +- src/layout/grid/WidgetBlock.tsx | 15 ++-- src/layout/header/search/SearchPage.tsx | 5 +- src/layout/header/search/index.tsx | 113 +++++++++++++----------- src/layout/useLayoutStore.ts | 22 ++++- src/settings/useSettingsStore.ts | 5 +- 15 files changed, 237 insertions(+), 114 deletions(-) delete mode 100644 src/index.html diff --git a/index.html b/index.html index 46fc7ef..b9daaf6 100644 --- a/index.html +++ b/index.html @@ -7,7 +7,7 @@ name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> - Vite App + Fatfox 新标签页
diff --git a/src/GlobalModal.tsx b/src/GlobalModal.tsx index 9dcc468..c9d8634 100644 --- a/src/GlobalModal.tsx +++ b/src/GlobalModal.tsx @@ -25,7 +25,11 @@ export default defineComponent(() => { full.value = false }) return () => ( -
+
e.stopPropagation()} + onKeydown={(e) => e.stopPropagation()} + > {/* 背景遮罩 */} {show.value && ( diff --git a/src/index.html b/src/index.html deleted file mode 100644 index 4813512..0000000 --- a/src/index.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - Document - - -
要什么服务器,直接 oss
-