diff --git a/src/layout/background/BackgroundPage.tsx b/src/layout/background/BackgroundPage.tsx index b5e63ce..fb93a49 100644 --- a/src/layout/background/BackgroundPage.tsx +++ b/src/layout/background/BackgroundPage.tsx @@ -21,7 +21,6 @@ export default defineComponent(() => { }, { immediate: true } ) - watch(() => layout.state.content[selected.value].background, console.log, { immediate: true }) const resource = useResource( computed(() => layout.state.content[selected.value].background), 'background' diff --git a/src/layout/background/useResource.ts b/src/layout/background/useResource.ts index df12f17..213c987 100644 --- a/src/layout/background/useResource.ts +++ b/src/layout/background/useResource.ts @@ -1,5 +1,6 @@ import { ossCdnBase, videoArr } from '@/config' import db from '@/db' +import useSettingsStore from '@/settings/useSettingsStore' import { reactive, watch, type Ref } from 'vue' const defaultBackground = @@ -13,15 +14,17 @@ const defaultResource = { } export default function useResource(tag: Ref, type: string) { const resource = reactive(defaultResource) + const settings = useSettingsStore() watch( tag, (val) => { // '' 表示使用默认,如果是背景,使用默认背景图片 if (!val) { - Object.assign(resource, { - ...defaultResource, - image: type === 'background' ? defaultBackground : '' - }) + if (type === 'background' && !settings.state.used) { + Object.assign(resource, { ...defaultResource, image: defaultBackground }) + } else { + Object.assign(resource, defaultResource) + } return } if (val.startsWith('http')) { diff --git a/src/settings/useSettingsStore.ts b/src/settings/useSettingsStore.ts index 74d85c3..996f4a5 100644 --- a/src/settings/useSettingsStore.ts +++ b/src/settings/useSettingsStore.ts @@ -7,6 +7,8 @@ export default defineStore( 'settings', () => { const state = reactive({ + // 是否用过 + used: false, maskOpacity: 0, maskFilter: 0, // 显示隐藏