feat: 粒子背景+动起来了

This commit is contained in:
ex_zhangwenlei@exiot.cmcc
2024-01-07 00:05:55 +08:00
parent ae2f21daaf
commit 18c5429b58
25 changed files with 1073 additions and 2798 deletions

View File

@@ -2,9 +2,14 @@
import { ref, onMounted, watch } from 'vue'
import { readImage } from '@/utils/file'
import localforage from 'localforage'
import useStore from '@/store'
import { storeToRefs } from 'pinia'
import ImageSync from '@/components/ImageSync/index.vue'
const globalConfig= useStore().globalConfig
const { getImageList:localImageList} = storeToRefs(globalConfig)
const limitType = ref('image/*')
const imgList = ref<any>([])
const imgUploadToast = ref(0) //0是不显示1是成功2是失败,3是不是图片
const imageDbStore = localforage.createInstance({
name: 'imgStore'
@@ -28,20 +33,28 @@ const handleFileChange = async (e: any) => {
}
const getImageDbStore =async () => {
imgList.value = []
const keys =await imageDbStore.keys()
if(keys.length>0){
imageDbStore.iterate((value, key) => {
imgList.value.push({
key,
value
globalConfig.addImage({
id:key,
name:key,
url:'Storage'
})
})
}
}
const removeImage=(item:any)=>{
if(item.url=='Storage'){
imageDbStore.removeItem(item.id).then(() => {
globalConfig.removeImage(item.id)
})
}
globalConfig.removeImage(item.id)
}
onMounted(() => {
getImageDbStore()
// getImageDbStore()
})
watch(() => imgUploadToast.value, (val) => {
if (val !== 0) {
@@ -73,16 +86,20 @@ watch(() => imgUploadToast.value, (val) => {
<span class="btn btn-primary btn-sm">上传图片</span>
</label>
</div>
<ul>
<li v-for="item in imgList" :key="item">
<div class="flex items-center gap-3">
<div class="avatar">
<div class="w-12 h-12 mask mask-squircle">
<img :src="item.value" alt="Avatar Tailwind CSS Component" />
<ul class="p-0">
<li v-for="item in localImageList" :key="item.id" class="mb-3">
<div class="flex items-center gap-8">
<div class="avatar h-14">
<div class="w-12 h-12 mask mask-squircle hover:w-14 hover:h-14">
<img v-if="item.url!=='Storage'" :src="item.url" alt="Avatar Tailwind CSS Component" />
<ImageSync v-else :imgItem="item"></ImageSync>
</div>
</div>
<div class="w-64">
<div class="overflow-hidden font-bold whitespace-nowrap text-ellipsis">{{ item.name}}</div>
</div>
<div>
<div class="font-bold">{{ item.key.split('+')[1] }}</div>
<button class="btn btn-error btn-xs" @click="removeImage(item)">删除</button>
</div>
</div>
</li>