From ccce20cf3478475d1bec9e032acd4d05477a8d7b Mon Sep 17 00:00:00 2001 From: hzj <1304805162@qq.com> Date: Thu, 13 Nov 2025 15:20:42 +0800 Subject: [PATCH] =?UTF-8?q?feat(KYC=E9=A1=B5=E9=9D=A2):=20pinia=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E6=8C=81=E4=B9=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/lastImg.js | 22 ++++++++++++++++++++++ src/views/Wallet/CashOut/KYC.vue | 6 ++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/stores/lastImg.js b/src/stores/lastImg.js index 229bbad..9791d29 100644 --- a/src/stores/lastImg.js +++ b/src/stores/lastImg.js @@ -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, + }, }) diff --git a/src/views/Wallet/CashOut/KYC.vue b/src/views/Wallet/CashOut/KYC.vue index f8c863e..03db8a1 100644 --- a/src/views/Wallet/CashOut/KYC.vue +++ b/src/views/Wallet/CashOut/KYC.vue @@ -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)