默认界面和广告
This commit is contained in:
parent
4b6d28c392
commit
ed10c2b118
|
@ -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}
|
||||
</span>
|
||||
</div>
|
||||
<img src="/tab/icons/gameicon.webp" alt="game_icon" class={'absolute right-0 bottom-0 w-[36px]'} />
|
||||
<img
|
||||
src="/tab/icons/gameicon.webp"
|
||||
alt="game_icon"
|
||||
class={'absolute right-0 bottom-0 w-[36px]'}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -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}')`,
|
||||
|
|
|
@ -1,25 +1,20 @@
|
|||
import db from '@/db'
|
||||
import request from './request'
|
||||
|
||||
interface AdverLink {
|
||||
id: string
|
||||
tag: string
|
||||
adverLink: string
|
||||
}
|
||||
type AdverParams = Omit<AdverLink, 'adverLink'> & {
|
||||
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<AdverData>('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
|
||||
|
|
|
@ -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',
|
||||
|
|
Loading…
Reference in New Issue