feat:编辑资料页保存携带库字段,onShow 监听管理页更新事件
This commit is contained in:
@@ -187,7 +187,8 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { computed, onMounted, onUnmounted, reactive, ref } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import { useAppStore } from '../../stores/app.js'
|
||||
import { useMenuButtonSafeArea } from '../../composables/useMenuButtonSafeArea.js'
|
||||
|
||||
@@ -296,6 +297,37 @@ const syncFromStore = () => {
|
||||
birthday.value = source.birthday || ''
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理管理页发回的库更新事件
|
||||
*/
|
||||
const handleTagLibraryUpdated = (payload) => {
|
||||
if (!payload || !payload.type) return
|
||||
if (payload.type === 'personality') {
|
||||
if (Array.isArray(payload.library)) {
|
||||
form.personalityTagLibrary = [...payload.library]
|
||||
// 同步移除已选中已被删除的标签
|
||||
form.personalityTags = form.personalityTags.filter(
|
||||
(tag) => payload.library.includes(tag)
|
||||
)
|
||||
}
|
||||
} else if (payload.type === 'hobby') {
|
||||
if (Array.isArray(payload.library)) {
|
||||
form.hobbyLibrary = [...payload.library]
|
||||
form.hobbies = form.hobbies.filter(
|
||||
(tag) => payload.library.includes(tag)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
uni.$on('tag-library-updated', handleTagLibraryUpdated)
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
uni.$off('tag-library-updated', handleTagLibraryUpdated)
|
||||
})
|
||||
|
||||
/**
|
||||
* 性格标签有序展示列表:
|
||||
* 1. 新增的自定义标签(不在预设中)按库顺序排在最前
|
||||
|
||||
Reference in New Issue
Block a user