fix: 新增删除功能

This commit is contained in:
奔跑的面条
2023-05-24 17:59:27 +08:00
parent fe06b55a56
commit c242a86e86
4 changed files with 39 additions and 21 deletions
@@ -1,6 +1,8 @@
import { defineStore } from 'pinia'
import { ConfigType, PackagesStoreType, PackagesType } from './packagesStore.d'
import { packagesList } from '@/packages/index'
import { StorageEnum } from '@/enums/storageEnum'
import { getLocalStorage, setLocalStorage } from '@/utils'
// 组件 packages
export const usePackagesStore = defineStore({
@@ -18,6 +20,13 @@ export const usePackagesStore = defineStore({
addPhotos(newPhoto: ConfigType, index: number) {
this.newPhoto = newPhoto
this.packagesList.Photos.splice(index, 0, newPhoto)
},
deletePhotos(photoInfo: ConfigType, index: number) {
this.packagesList.Photos.splice(index, 1)
const StoreKey = StorageEnum.GO_USER_MEDIA_PHOTOS
const userPhotosList = getLocalStorage(StoreKey)
userPhotosList.splice(index - 1, 1)
setLocalStorage(StoreKey, userPhotosList)
}
}
})