diff --git a/src/layout/header/search/index.tsx b/src/layout/header/search/index.tsx
index cd2b76a..7bd8786 100644
--- a/src/layout/header/search/index.tsx
+++ b/src/layout/header/search/index.tsx
@@ -8,68 +8,73 @@ import SearchSuggestion from './SearchSuggestion'
import useLayoutStore from '@/layout/useLayoutStore'
import clsx from 'clsx'
-export default defineComponent((props: {
- isMini?: boolean
-}) => {
- const settings = useSettingsStore()
- const search = useSearchStore()
- const searchConfig = useSearchConfigStore()
- const layout = useLayoutStore()
- return () => (
-
+export default defineComponent(
+ (props: { isMini?: boolean }) => {
+ const settings = useSettingsStore()
+ const search = useSearchStore()
+ const searchConfig = useSearchConfigStore()
+ const layout = useLayoutStore()
+ return () => (
{
- search.showSearchConfig = true
+ class={clsx(
+ 'w-full h-11 shadow-content overflow-hidden px-1 transition-all flex justify-between items-center gap-4 ',
+ search.focus ? 'bg-white/60' : 'bg-white/40 hover:bg-white/60',
+ props.isMini ? '' : 'max-w-[90vw] w-full'
+ )}
+ style={{
+ borderRadius: settings.state.searchRadius + 'px'
}}
>
{
+ search.showSearchConfig = true
}}
+ >
+
+
+
(search.searchRef = el as any)}
+ onContextmenu={(e) => e.stopPropagation()}
+ onKeydown={(e) => e.stopPropagation()}
+ class="flex-1 h-full outline-none bg-transparent placeholder:text-slate-600 placeholder:tracking-widest text-slate-800 pr-4"
+ placeholder={`输入搜索 ${searchConfig.current.name}`}
/>
-
(search.searchRef = el as any)}
- onContextmenu={(e) => e.stopPropagation()}
- class="flex-1 h-full outline-none bg-transparent placeholder:text-slate-600 placeholder:tracking-widest text-slate-800 pr-4"
- placeholder={`输入搜索 ${searchConfig.current.name}`}
- />
+
{search.showSearchConfig && }
+
+ {search.focus && !search.searchStr && searchConfig.history.length > 0 && (
+
+ )}
+
+
+ {search.focus && search.searchStr && }
+
-
{search.showSearchConfig && }
-
- {search.focus && !search.searchStr && searchConfig.history.length > 0 && }
-
-
- {search.focus && search.searchStr && }
-
-
- )
-}, {
- name: 'SearchComponent',
- props: ['isMini']
-})
+ )
+ },
+ {
+ name: 'SearchComponent',
+ props: ['isMini']
+ }
+)
diff --git a/src/layout/useLayoutStore.ts b/src/layout/useLayoutStore.ts
index 5341442..3109a6e 100644
--- a/src/layout/useLayoutStore.ts
+++ b/src/layout/useLayoutStore.ts
@@ -4,6 +4,8 @@ import { computed, reactive, ref, toRaw, watch } from 'vue'
import db from '@/db'
import useResource from './background/useResource'
import { globalToast } from '@/main'
+import jump from '@/utils/jump'
+import useSettingsStore from '@/settings/useSettingsStore'
const defaultLayout: Layout = {
content: [
@@ -20,6 +22,7 @@ const defaultLayout: Layout = {
}
export default defineStore('layout', () => {
+ const settings = useSettingsStore()
const state = reactive(defaultLayout)
const ready = ref(false)
@@ -86,6 +89,12 @@ export default defineStore('layout', () => {
if (openDir.value === id) {
openDir.value = ''
}
+ } else if (dir && dir.list.length === 0) {
+ const idx = currentPage.value.list.findIndex((el) => el.link === 'id:' + id)
+ if (idx < 0) return
+ currentPage.value.list.splice(idx, 1)
+ delete state.dir[id]
+ openDir.value = ''
}
}
@@ -96,7 +105,6 @@ export default defineStore('layout', () => {
}
// 处理不同的组件的名称
if (block.name === 'gameVideo') {
-
return state.current === 0 ? '游戏视频' : state.current === 1 ? '学习视频' : '娱乐视频'
}
return block.label || ''
@@ -105,6 +113,18 @@ export default defineStore('layout', () => {
const changeBackground = (url: string) => {
state.content[state.current].background = url
}
+ document.addEventListener('keydown', (e) => {
+ if (settings.state.disabledShortcut) return
+ const arr = state.dockLabels.split('')
+ for (const key in arr) {
+ if (arr[key] === e.key.toLocaleUpperCase()) {
+ const block = state.dock[key]
+ if (block) {
+ jump(block.link)
+ }
+ }
+ }
+ })
return {
state,
ready,
diff --git a/src/settings/useSettingsStore.ts b/src/settings/useSettingsStore.ts
index 63ac234..f397d60 100644
--- a/src/settings/useSettingsStore.ts
+++ b/src/settings/useSettingsStore.ts
@@ -2,7 +2,7 @@ import { defineStore } from 'pinia'
import { computed, reactive } from 'vue'
export type VisibleState = 'show' | 'auto' | ''
-export type TimeUnit = 'date' | 'week' | '12hour' | 'lunal' | 'second';
+export type TimeUnit = 'date' | 'week' | '12hour' | 'lunal' | 'second'
export default defineStore(
'settings',
() => {
@@ -32,7 +32,8 @@ export default defineStore(
searchOpacity: 0.75,
// 侧边栏
siderDirection: 'left' as 'left' | 'right',
-
+ // 禁用快捷键
+ disabledShortcut: false
})
return { state, blockInner: computed(() => state.blockSize - 2 * state.blockPadding) }
},
diff --git a/src/user/useUserStore.ts b/src/user/useUserStore.ts
index bf8c7d4..bf95f8b 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,
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/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)
+ }
+ })
+}
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',