feat(KYC页面): pinia使用持久化

This commit is contained in:
hzj 2025-11-13 15:20:42 +08:00
parent 446d7cccd4
commit ccce20cf34
2 changed files with 26 additions and 2 deletions

View File

@ -7,10 +7,32 @@ export const useLastImgStore = defineStore('lastImg', {
actions: {
setLastImgUrl(lastImgUrl) {
this.imgUrl = lastImgUrl
// 添加持久化存储
if (lastImgUrl) {
localStorage.setItem('lastImgUrl', lastImgUrl)
} else {
localStorage.removeItem('lastImgUrl')
}
},
// 添加初始化方法
initFromStorage() {
const stored = localStorage.getItem('lastImgUrl')
if (stored) {
this.imgUrl = stored
}
},
clearCache() {
this.imgUrl = null
localStorage.removeItem('lastImgUrl')
},
},
// 可选:添加持久化插件配置
persist: {
key: 'lastImgUrl',
storage: localStorage,
},
})

View File

@ -200,8 +200,10 @@ import { storeToRefs } from 'pinia'
const { t, locale } = useI18n()
const router = useRouter()
const lastImgStore = useLastImgStore() //
const { imgUrl: lastImgUrl } = storeToRefs(lastImgStore) //
const lastImgStore = useLastImgStore()
// localStorage
lastImgStore.initFromStorage()
const { imgUrl: lastImgUrl } = storeToRefs(lastImgStore) //
//
locale.value && setDocumentDirection(locale.value)