|
|
@@ -229,12 +229,14 @@ const setDocumentTitle = () => {
|
|
|
}
|
|
|
|
|
|
const fetchQrDetails = async () => {
|
|
|
- if (!qrCode.value) return
|
|
|
+ // 保存 qrCode 到局部变量,避免在异步操作过程中被改变
|
|
|
+ const currentQrCode = qrCode.value?.toString().trim()
|
|
|
+ if (!currentQrCode) return
|
|
|
loading.info = true
|
|
|
infoStatus.state = 'loading'
|
|
|
infoStatus.message = ''
|
|
|
try {
|
|
|
- const data = await fetchQrInfoApi(qrCode.value)
|
|
|
+ const data = await fetchQrInfoApi(currentQrCode)
|
|
|
qrDetail.value = data
|
|
|
|
|
|
// 如果是 link 类型且已激活且有 jumpUrl,直接跳转
|
|
|
@@ -247,9 +249,9 @@ const fetchQrDetails = async () => {
|
|
|
if (!data.isActivated && (data.info === null || data.info === undefined) && !data.isBind) {
|
|
|
// 如果用户已登录,跳转到管理页面;否则跳转到登录页面
|
|
|
if (userStore.token) {
|
|
|
- await router.replace({ name: 'qrmanagerHome', query: { qrCode: qrCode.value } })
|
|
|
+ await router.replace({ name: 'qrmanagerHome', query: { qrCode: currentQrCode } })
|
|
|
} else {
|
|
|
- await router.replace({ name: 'qrmanagerAuth', query: { qrCode: qrCode.value } })
|
|
|
+ await router.replace({ name: 'qrmanagerAuth', query: { qrCode: currentQrCode } })
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
@@ -438,7 +440,9 @@ const buildProfilePayload = () => {
|
|
|
}
|
|
|
|
|
|
const handleSaveProfile = async () => {
|
|
|
- if (!qrCode.value) return
|
|
|
+ // 保存 qrCode 到局部变量,避免在异步操作过程中被改变
|
|
|
+ const currentQrCode = qrCode.value?.toString().trim()
|
|
|
+ if (!currentQrCode) return
|
|
|
|
|
|
// 对于 link 类型,验证 URL
|
|
|
if (isLink.value) {
|
|
|
@@ -461,6 +465,8 @@ const handleSaveProfile = async () => {
|
|
|
loading.saving = true
|
|
|
try {
|
|
|
const payload = buildProfilePayload()
|
|
|
+ // 确保 payload 中的 qrCode 使用局部变量
|
|
|
+ payload.qrCode = currentQrCode
|
|
|
const updater = profileApiMap[qrType.value] || profileApiMap.person
|
|
|
const response = await updater(payload)
|
|
|
toast.add({
|
|
|
@@ -469,7 +475,10 @@ const handleSaveProfile = async () => {
|
|
|
detail: response?.message || (isLink.value ? 'Link information has been updated.' : 'Profile has been updated.'),
|
|
|
life: 3000
|
|
|
})
|
|
|
- await fetchQrDetails()
|
|
|
+ // 只有在 qrCode 仍然有效时才刷新数据
|
|
|
+ if (qrCode.value === currentQrCode) {
|
|
|
+ await fetchQrDetails()
|
|
|
+ }
|
|
|
isEditing.value = false
|
|
|
maintenancePassed.value = false
|
|
|
maintenanceCode.value = ''
|
|
|
@@ -602,6 +611,7 @@ watch(
|
|
|
)
|
|
|
|
|
|
watch([qrType, profile], () => {
|
|
|
+ if (!qrCode.value) return
|
|
|
resetForm(profile.value)
|
|
|
setDocumentTitle()
|
|
|
})
|