diff --git a/src/layout/background/BackgroundSwtich.tsx b/src/layout/background/BackgroundSwtich.tsx index e947d8c..ed4d36a 100644 --- a/src/layout/background/BackgroundSwtich.tsx +++ b/src/layout/background/BackgroundSwtich.tsx @@ -152,6 +152,7 @@ export default defineComponent(() => { {wallpaperList.value.map(item =>
{ + layout.changeBackground(item.url) }} class="h-[156px] relative cursor-pointer group w-full flex-grow-0 rounded-xl overflow-hidden"> diff --git a/src/layout/layout.types.ts b/src/layout/layout.types.ts index 0d68d54..6fcfc08 100644 --- a/src/layout/layout.types.ts +++ b/src/layout/layout.types.ts @@ -30,9 +30,9 @@ export type LayoutPages = { list: Block[]; label: string; name: string }[] export interface Layout { content: [ - { background: ''; pages: LayoutPages }, - { background: ''; pages: LayoutPages }, - { background: ''; pages: LayoutPages } + { background: string; pages: LayoutPages }, + { background: string; pages: LayoutPages }, + { background: string; pages: LayoutPages } ] current: 0 | 1 | 2 // 游戏,工作,轻娱 currentPage: number diff --git a/src/layout/useLayoutStore.ts b/src/layout/useLayoutStore.ts index 2351fe1..2e3198e 100644 --- a/src/layout/useLayoutStore.ts +++ b/src/layout/useLayoutStore.ts @@ -98,7 +98,9 @@ export default defineStore('layout', () => { } return block.label || '' } - + const changeBackground = (url: string) => { + state.content[state.current].background = url + } return { state, ready, @@ -109,6 +111,7 @@ export default defineStore('layout', () => { addBlock, openDir, checkDir, - getLabel + getLabel, + changeBackground } })