-
-
- {type.value === 0 ? '' : type.value === 1 ? '' : }
-
+
+
+ {isGame.value && }
+
+ {
+ type.value = 0
+ }}
+ />
+ {
+ type.value = 1
+ }}
+ />
+ {
+ type.value = 2
+ }}
+ />
+
+ e.stopPropagation()}
+ >
+
+
+
+
+ {type.value === 0 ? '' : type.value === 1 ? '' : }
+
+
-
+
)
})
diff --git a/src/layout/adder/CustomAdder.tsx b/src/layout/adder/CustomAdder.tsx
index 32db55f..d8a2f9d 100644
--- a/src/layout/adder/CustomAdder.tsx
+++ b/src/layout/adder/CustomAdder.tsx
@@ -1,11 +1,11 @@
import { computed, defineComponent, reactive, ref, watch } from 'vue'
import useLayoutStore from '../useLayoutStore'
-import { ConfigProvider, Form, Input, theme } from 'ant-design-vue'
+import { Button, Form, Input, InputGroup } from 'ant-design-vue'
import { OhVueIcon, addIcons } from 'oh-vue-icons'
import { MdUpload, MdImage, MdCheck } from 'oh-vue-icons/icons'
-import clsx from 'clsx'
import ImageUploader from '@/utils/ImageUploader'
import useLink from './useLink'
+import { CheckOutlined } from '@ant-design/icons-vue'
addIcons(MdUpload, MdImage, MdCheck)
@@ -108,112 +108,76 @@ const TypeSelector = defineComponent({
)
}
})
-
-export default defineComponent({
- props: {
- mode: {
- type: Number,
- default: 0
- },
- page: {
- type: Number,
- default: 0
+export default defineComponent(() => {
+ const layout = useLayoutStore()
+ const form = reactive({
+ link: '',
+ name: '',
+ text: '',
+ background: '#f7a94e',
+ color: 'rgba(255,255,255,1)',
+ icon: '',
+ type: 0 // 0 默认,1 文字
+ })
+ const isGame = computed(() => layout.state.current === 0)
+ const debounced = ref('')
+ watch(
+ () => form.link,
+ (val, _, onCleanup) => {
+ const it = setTimeout(() => {
+ debounced.value = val
+ }, 500)
+ onCleanup(() => {
+ clearTimeout(it)
+ })
}
- },
- setup(props, ctx) {
- const layout = useLayoutStore()
- const form = reactive({
- link: '',
- name: '',
- text: '',
- background: '#f7a94e',
- color: 'rgba(255,255,255,1)',
- icon: '',
- type: 0 // 0 默认,1 文字
- })
- const isGame = computed(() => layout.state.current === 0)
- const debounced = ref('')
- watch(
- () => form.link,
- (val, _, onCleanup) => {
- const it = setTimeout(() => {
- debounced.value = val
- }, 500)
- onCleanup(() => {
- clearTimeout(it)
- })
+ )
+
+ const info = useLink(debounced)
+ console.log(info)
+
+ watch(info, (val) => {
+ console.log(val)
+
+ if (val.name) form.name = val.name
+ if (val.icon) form.icon = val.icon
+ })
+ return () => (
+
{
- console.log(val);
-
- if (val.name) form.name = val.name
- if (val.icon) form.icon = val.icon
-
- })
- return () => (
-
-
-
-
- 地址
-
+
+
+
- 获取地址
-
-
- 名称
-
-
-
- 图标
-
-
-
-
-
-
-
-
- )
- }
+
+
+
+
+
+
+
+
+
+
+ }>
+ 确定
+
+
+
+
+ )
})
diff --git a/src/layout/background/BackgroundPage.tsx b/src/layout/background/BackgroundPage.tsx
index 7d5765d..322d165 100644
--- a/src/layout/background/BackgroundPage.tsx
+++ b/src/layout/background/BackgroundPage.tsx
@@ -1,5 +1,5 @@
import { defineComponent } from 'vue'
export default defineComponent(() => {
- return () =>
this is background
+ return () =>
})
diff --git a/src/layout/background/getResource.ts b/src/layout/background/getResource.ts
new file mode 100644
index 0000000..cb0932a
--- /dev/null
+++ b/src/layout/background/getResource.ts
@@ -0,0 +1,97 @@
+import { ossCdnBase, videoArr } from '@/config'
+import db from '@/db'
+import { reactive, watch, type Ref } from 'vue'
+
+const defaultBackground =
+ 'https://aihlp.com.cn/admin/wallpaper/508d3994-3727-4839-bfe9-41b97ccf4fba_66a3272c874d41e5b9ec7562fe5822cd (1).jpg'
+
+const defaultResource = {
+ image: '',
+ video: '',
+ brief: ''
+}
+export default function useResource(tag: Ref
, type: string) {
+ const resource = reactive(defaultResource)
+ watch(
+ tag,
+ (val) => {
+ // '' 表示使用默认,如果是背景,使用默认背景图片
+ if (!val) {
+ Object.assign(resource, {
+ ...defaultResource,
+ image: type === 'background' ? defaultBackground : ''
+ })
+ return
+ }
+ if (val.startsWith('http')) {
+ // 内源
+ if (val.startsWith(ossCdnBase)) {
+ // 地址后缀
+ const suffix = val.split('.').pop()
+ if (!suffix) {
+ return
+ }
+ if (videoArr.includes(suffix)) {
+ // 内部视频
+ // 先显示截图,再去数据库看是否有存货
+ resource.video = ''
+ resource.image = val + '?x-oss-process=video/snapshot,t_0,f_jpg,m_fast'
+ resource.brief = val + '?x-oss-process=video/snapshot,t_0,f_jpg,w_400,h_225,m_fast'
+ db.getItem<{ tag: string; file: Blob }[]>('videoList').then((res) => {
+ if (!res) return
+ const item = res.find((item) => item.tag === val)
+ if (item) {
+ resource.video = URL.createObjectURL(item.file)
+ resource.image = ''
+ } else {
+ // 不存在,需要存入
+ fetch(val)
+ .then((res) => res.blob())
+ .then((blob) => {
+ if (res.length > 10) {
+ res.pop()
+ }
+ res.unshift({ tag: val, file: blob })
+ resource.video = URL.createObjectURL(blob)
+ resource.image = ''
+ })
+ }
+ })
+ } else {
+ // 图片
+ resource.image = val
+ resource.video = ''
+ resource.brief = val + '?x-oss-process=image/resize,w_400,h_225'
+ }
+ return
+ }
+ // 外部资源
+ const suffix = val.split('.').pop()
+ if (!suffix) {
+ resource.image = val
+ resource.video = ''
+ resource.brief = val
+ return
+ }
+ resource.image = videoArr.includes(suffix) ? '' : val
+ resource.video = videoArr.includes(suffix) ? val : ''
+ resource.brief = val
+ return
+ }
+ // 本地
+ db.getItem<{ tag: string; file: Blob; type: 'image' | 'video' }[]>('localList').then(
+ (res) => {
+ if (!res) return
+ const item = res.find((item) => item.tag === val)
+ if (!item) return
+ const url = URL.createObjectURL(item.file)
+ resource.image = item.type === 'image' ? url : ''
+ resource.video = item.type === 'video' ? url : ''
+ resource.brief = url
+ }
+ )
+ },
+ { immediate: true }
+ )
+ return resource
+}
diff --git a/src/layout/background/index.tsx b/src/layout/background/index.tsx
index 0c55939..eca9ddc 100644
--- a/src/layout/background/index.tsx
+++ b/src/layout/background/index.tsx
@@ -1,20 +1,20 @@
import { defineComponent } from 'vue'
-import useBackgroundStore from './useBackgroundStore'
+import useLayoutStore from '../useLayoutStore'
export default defineComponent({
setup() {
- const background = useBackgroundStore()
+ const layout = useLayoutStore()
return () => (
- {background.resource.type === 'image' ? (
+ {layout.background.video ? (
+
+ ) : (
- ) : (
-
)}
)
diff --git a/src/layout/header/search/SearchPage.tsx b/src/layout/header/search/SearchPage.tsx
index 4ee594e..d909aad 100644
--- a/src/layout/header/search/SearchPage.tsx
+++ b/src/layout/header/search/SearchPage.tsx
@@ -1,8 +1,9 @@
import { defineComponent, ref } from 'vue'
-import { Button, Checkbox, ConfigProvider, Divider, message, Modal, theme } from 'ant-design-vue'
+import { Button, Checkbox, Divider, message, Modal } from 'ant-design-vue'
import useSearchConfigStore from './useSearchConfigStore'
import { EditOutlined, DeleteOutlined, PlusOutlined } from '@ant-design/icons-vue'
import asyncLoader from '@/utils/asyncLoader'
+import ThemeProvider from '@/utils/ThemeProvider'
const SearchAdder = asyncLoader(() => import('./SearchAdder'))
const SearchItem = defineComponent({
props: {
@@ -118,7 +119,7 @@ export default defineComponent(() => {
class="w-full h-full bg-white/80 backdrop-blur p-4 flex flex-col select-text"
onContextmenu={(e) => e.stopPropagation()}
>
-
+
管理搜索引擎
默认
@@ -177,7 +178,7 @@ export default defineComponent(() => {
>
-
+
)
})
diff --git a/src/layout/layout.types.ts b/src/layout/layout.types.ts
index abfae6b..a431c63 100644
--- a/src/layout/layout.types.ts
+++ b/src/layout/layout.types.ts
@@ -25,7 +25,11 @@ export interface Block {
export type LayoutPages = { list: Block[]; label: string; name: string }[]
export interface Layout {
- content: [LayoutPages, LayoutPages, LayoutPages]
+ content: [
+ { background: ''; pages: LayoutPages },
+ { background: ''; pages: LayoutPages },
+ { background: ''; pages: LayoutPages }
+ ]
current: 0 | 1 | 2 // 游戏,工作,轻娱
currentPage: number
dir: { [key: string]: Block[] }
diff --git a/src/layout/sider/index.tsx b/src/layout/sider/index.tsx
index d8ec5a6..aec843e 100644
--- a/src/layout/sider/index.tsx
+++ b/src/layout/sider/index.tsx
@@ -77,7 +77,7 @@ export default defineComponent(() => {