From ed54cb1f976fbb5a54a6dd8e7f715e1a80d9ba63 Mon Sep 17 00:00:00 2001
From: expdsn <18111002318@163.com>
Date: Tue, 19 Nov 2024 10:50:48 +0800
Subject: [PATCH] =?UTF-8?q?=E5=8A=A8=E6=80=81=E5=A3=81=E7=BA=B8=E6=97=A0?=
=?UTF-8?q?=E6=B3=95=E6=AD=A3=E5=B8=B8=E5=8A=A0=E8=BD=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/layout/background/BackgroundPage.tsx | 2 +-
src/layout/background/CustomWallpaper.tsx | 2 +-
src/layout/background/useResource.ts | 6 ++++
src/layout/grid/WelcomePage.tsx | 42 ++++++++++++++++++-----
src/layout/grid/index.tsx | 3 ++
src/utils/upload.ts | 2 +-
6 files changed, 46 insertions(+), 11 deletions(-)
diff --git a/src/layout/background/BackgroundPage.tsx b/src/layout/background/BackgroundPage.tsx
index 7c45d43..2dd02ef 100644
--- a/src/layout/background/BackgroundPage.tsx
+++ b/src/layout/background/BackgroundPage.tsx
@@ -27,7 +27,7 @@ export default defineComponent(() => {
{layout.background.video && layout.background.type !== 'own' ? (
-
+
) : (
{
tempBackground.value ? 'bg-black/50 hidden group-hover:flex' : 'flex'
)}
>
-
+
diff --git a/src/layout/background/useResource.ts b/src/layout/background/useResource.ts
index 2f07750..b065049 100644
--- a/src/layout/background/useResource.ts
+++ b/src/layout/background/useResource.ts
@@ -98,7 +98,13 @@ export default function useResource(tag: Ref, type: string) {
if (!res) return
const item = res.find((item) => item.tag === val)
if (!item) return
+ console.log(item);
+
const url = URL.createObjectURL(item.file)
+ console.log('本地资源');
+ console.log(url);
+
+
resource.image = item.type === 'image' ? url : ''
resource.video = item.type === 'video' ? url : ''
resource.brief = url
diff --git a/src/layout/grid/WelcomePage.tsx b/src/layout/grid/WelcomePage.tsx
index 4057f85..4137639 100644
--- a/src/layout/grid/WelcomePage.tsx
+++ b/src/layout/grid/WelcomePage.tsx
@@ -5,6 +5,9 @@ import startUseImg from '~/icons/welcome/startUse.png'
import useLayoutStore from '../useLayoutStore'
import request from '@/utils/request'
import useStatisticStore from '@/utils/useStatisticStore'
+import { v4 as uuid } from 'uuid'
+import { uploadLocal } from '@/utils/upload'
+import { videoArr } from '@/config'
export const DefaultPageSetting = [
{
name: '游戏',
@@ -47,7 +50,7 @@ export default defineComponent(() => {
useStatisticStore().send({
widget: 'WELCOME',
action: 'OPEN',
- space: 'TAB',
+ space: 'TAB'
})
}
})
@@ -58,7 +61,7 @@ export default defineComponent(() => {
{show.value && (
{ }}
+ onClick={() => {}}
style={{
backgroundImage: `url('${DefaultPageSetting[selectMode.value].backgroundUrl}')`,
backgroundSize: '100% 100%',
@@ -66,7 +69,7 @@ export default defineComponent(() => {
backgroundRepeat: 'no-repeat'
}}
>
-
{ }}>
+
{}}>
)}
@@ -93,11 +96,11 @@ export default defineComponent(() => {
}
onClick={() => {
selectMode.value = idx
-
}}
style={{
- transform: `translate(${idx === selectMode.value ? 80 : (((selectMode.value === 2 && idx === 0) || (selectMode.value + 1 === idx)) ? 219 : -52)}px) scale(${idx === selectMode.value ? 1 : 0.85
- })`,
+ transform: `translate(${idx === selectMode.value ? 80 : (selectMode.value === 2 && idx === 0) || selectMode.value + 1 === idx ? 219 : -52}px) scale(${
+ idx === selectMode.value ? 1 : 0.85
+ })`,
backgroundImage: `url('${DivBgImg}')`,
backgroundSize: '100% 100%',
zIndex: selectMode.value === idx ? 10 : 0
@@ -135,13 +138,36 @@ export default defineComponent(() => {
if (!res) return
layout.state.dir = res.dir
layout.state.content = res.content
+ layout.state.content.forEach(async (val) => {
+ const res = await fetch(val.background).then((res) => res.blob())
+ if (res) {
+ const affix = val.background.split('.').pop()
+ if (!affix) return
+
+ console.log(`background${uuid()}.${affix}`);
+ console.log(`${res.type}`);
+
+
+ const file = new File([res], `${uuid()}.${affix}`, {
+ type: `${res.type}`
+ })
+ uploadLocal(file).then((res2) => {
+ val.background = res2
+ })
+ }
+ })
})
layout.state.current = selectMode.value as 0 | 1 | 2
useStatisticStore().send({
- widget: selectMode.value === 0 ? "WELCOME_GAME" : selectMode.value === 1 ? "WELCOME_WORK" : "WELCOME_RELAX",
+ widget:
+ selectMode.value === 0
+ ? 'WELCOME_GAME'
+ : selectMode.value === 1
+ ? 'WELCOME_WORK'
+ : 'WELCOME_RELAX',
action: 'CLICK',
- space: 'TAB',
+ space: 'TAB'
})
}}
style={{
diff --git a/src/layout/grid/index.tsx b/src/layout/grid/index.tsx
index 3147c05..92211ba 100644
--- a/src/layout/grid/index.tsx
+++ b/src/layout/grid/index.tsx
@@ -51,6 +51,9 @@ export default defineComponent(() => {
layout.isCompact = false
}
}}
+ onDblclick={() => {
+ layout.state.simple = !layout.state.simple
+ }}
onDragover={(e) => e.preventDefault()}
onDrop={() => {
// 处理移入
diff --git a/src/utils/upload.ts b/src/utils/upload.ts
index f38446e..969ba64 100644
--- a/src/utils/upload.ts
+++ b/src/utils/upload.ts
@@ -41,7 +41,7 @@ export async function uploadLocal(file: File) {
list.push({
tag: id,
file: file,
- type: 'image'
+ type: file.type.split('/')[0] === 'video'? 'video' : 'image'
})
await db.setItem('localList', list)
return id