修复表单弹窗误关闭
This commit is contained in:
@@ -24,7 +24,12 @@
|
||||
</button>
|
||||
</section>
|
||||
|
||||
<BaseModal v-model="editModalVisible" title="个人信息" :close-disabled="profileSaving || avatarUploading">
|
||||
<BaseModal
|
||||
v-model="editModalVisible"
|
||||
title="个人信息"
|
||||
:close-disabled="profileSaving || avatarUploading"
|
||||
:has-unsaved-changes="profileFormChanged"
|
||||
>
|
||||
<div class="profile-avatar-row">
|
||||
<img v-if="profileForm.avatar" class="profile-avatar profile-avatar--image" :src="profileForm.avatar" alt="头像" />
|
||||
<div v-else class="profile-avatar">头像</div>
|
||||
@@ -109,6 +114,13 @@ const profileForm = reactive({
|
||||
wechatId: '',
|
||||
signature: ''
|
||||
})
|
||||
const profileBaseline = reactive({
|
||||
nickname: '',
|
||||
avatar: '',
|
||||
contactPhone: '',
|
||||
wechatId: '',
|
||||
signature: ''
|
||||
})
|
||||
|
||||
const menus: ProfileMenu[] = [
|
||||
{ title: '个人信息', action: 'editProfile' },
|
||||
@@ -164,9 +176,22 @@ const openEditProfile = (): void => {
|
||||
profileForm.contactPhone = profile.contactPhone || ''
|
||||
profileForm.wechatId = profile.wechatId || ''
|
||||
profileForm.signature = profile.signature || ''
|
||||
profileBaseline.nickname = profileForm.nickname
|
||||
profileBaseline.avatar = profileForm.avatar
|
||||
profileBaseline.contactPhone = profileForm.contactPhone
|
||||
profileBaseline.wechatId = profileForm.wechatId
|
||||
profileBaseline.signature = profileForm.signature
|
||||
editModalVisible.value = true
|
||||
}
|
||||
|
||||
const profileFormChanged = computed(() => {
|
||||
return profileForm.nickname !== profileBaseline.nickname
|
||||
|| profileForm.avatar !== profileBaseline.avatar
|
||||
|| profileForm.contactPhone !== profileBaseline.contactPhone
|
||||
|| profileForm.wechatId !== profileBaseline.wechatId
|
||||
|| profileForm.signature !== profileBaseline.signature
|
||||
})
|
||||
|
||||
const go = async (item: ProfileMenu): Promise<void> => {
|
||||
if (item.action === 'editProfile') {
|
||||
openEditProfile()
|
||||
|
||||
Reference in New Issue
Block a user