hookehuyr

refactor(profile): 替换生命周期钩子以优化页面数据加载

将editProfile页面的useDidShow替换为onMounted,同时在profile页面将onMounted改为useDidShow
确保在不同场景下正确触发用户数据加载
...@@ -172,7 +172,7 @@ ...@@ -172,7 +172,7 @@
172 172
173 <script setup> 173 <script setup>
174 import { ref, reactive, onMounted } from 'vue' 174 import { ref, reactive, onMounted } from 'vue'
175 -import Taro, { useDidShow } from '@tarojs/taro' 175 +import Taro from '@tarojs/taro'
176 import './index.less' 176 import './index.less'
177 import { Right } from '@nutui/icons-vue-taro' 177 import { Right } from '@nutui/icons-vue-taro'
178 import BASE_URL from '@/utils/config'; 178 import BASE_URL from '@/utils/config';
...@@ -511,7 +511,7 @@ const handleSave = async () => { ...@@ -511,7 +511,7 @@ const handleSave = async () => {
511 } 511 }
512 512
513 // 初始化 513 // 初始化
514 -useDidShow(async () => { 514 +onMounted(async () => {
515 // 获取用户信息 515 // 获取用户信息
516 const user = await getProfileAPI() 516 const user = await getProfileAPI()
517 if (user.code) { 517 if (user.code) {
......
...@@ -81,7 +81,7 @@ ...@@ -81,7 +81,7 @@
81 import { ref, onMounted } from 'vue' 81 import { ref, onMounted } from 'vue'
82 import { getProfileAPI } from '@/api/index' 82 import { getProfileAPI } from '@/api/index'
83 import { Heart, Clock, Notice, Cart, Message, Tips, Right, StarN } from '@nutui/icons-vue-taro' 83 import { Heart, Clock, Notice, Cart, Message, Tips, Right, StarN } from '@nutui/icons-vue-taro'
84 -import Taro from '@tarojs/taro' 84 +import Taro, { useDidShow } from '@tarojs/taro'
85 import TabBar from '@/components/TabBar.vue' 85 import TabBar from '@/components/TabBar.vue'
86 86
87 // 默认头像 87 // 默认头像
...@@ -97,7 +97,7 @@ const userInfo = ref({ ...@@ -97,7 +97,7 @@ const userInfo = ref({
97 favorite_count: 0 97 favorite_count: 0
98 }) 98 })
99 99
100 -onMounted(async () => { 100 +useDidShow(async () => {
101 const user = await getProfileAPI() 101 const user = await getProfileAPI()
102 if (user.code) { 102 if (user.code) {
103 userInfo.value = user.data 103 userInfo.value = user.data
......