import upload, { localPrefix, uploadLocal } from '@/utils/upload' import clsx from 'clsx' import { computed, defineComponent, ref, toRef } from 'vue' import useBackgroundStore from './useBackgroundStore' import useResource from './useResource' import useLayoutStore from '../useLayoutStore' import { message } from 'ant-design-vue' import { BgContent } from '.' export default defineComponent(() => { const dragging = ref(false) const fileInput = ref(null) const backgroundStore = useBackgroundStore() const tempFile = ref(null) const layout = useLayoutStore() const tempBackground = ref('') const handleDrop = (e: DragEvent) => { e.preventDefault() e.stopPropagation() const file = e.dataTransfer?.files?.[0] if (!file) return tempBackground.value = URL.createObjectURL(file) tempFile.value = file } const showImg = computed(() => { if (tempBackground.value) { return tempBackground.value } if (backgroundStore.state.isCustom) { return layout.background.video? layout.background.video: layout.background.image } return '' }) return () => (
您可以使用图片或视频作为您的自定义壁纸 自定义壁纸不会同步到您的账号数据
{ dragging.value = true e.stopPropagation() e.preventDefault() }} onDragleave={(e) => { dragging.value = false e.stopPropagation() e.preventDefault() }} onDrop={handleDrop} onClick={() => { fileInput.value?.click() }} class={clsx( 'w-[440px] h-[250px] relative items-center cursor-pointer justify-center border-dashed border-[1px] hover:bg-[#6b9dff1a] hover:border-[#3f80ff] rounded-lg', dragging.value ? 'border-[#3f80ff] bg-[#6b9dff1a]' : 'border-transparent bg-[#ebebeb]' )} // style={ // tempBackground.value // ? { // backgroundImage: `url(${tempBackground.value})`, // backgroundSize: 'cover', // backgroundRepeat: 'no-repeat' // } // : backgroundStore.state.isCustom // ? { // backgroundImage: `url(${backgroundStore.tag})`, // backgroundSize: 'cover', // backgroundRepeat: 'no-repeat' // } // : null // } >
) })