修复登录后无法进入设置等“我的”页面下级页面

This commit is contained in:
2026-08-04 21:51:51 +08:00
parent bb45663ed6
commit ba62c9f930
2 changed files with 16 additions and 12 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+15 -11
View File
@@ -33,6 +33,12 @@ const MENU_ITEMS = [
{ label: '设置', path: '/pages/settings/index' } { label: '设置', path: '/pages/settings/index' }
] ]
// Stable no-op: Taro runtime crashes when an event handler is removed from a
// Text/Image element (pure-text is missing from componentsAlias). Keeping
// onTap as a function at all times avoids the removeEventListener side-effect
// that triggers the crash.
const noop = () => {}
export default function ProfilePage() { export default function ProfilePage() {
const { theme, resolvedTheme } = useThemeContext() const { theme, resolvedTheme } = useThemeContext()
const safe = useSafeArea() const safe = useSafeArea()
@@ -104,6 +110,7 @@ export default function ProfilePage() {
} }
const handleQuickClick = (type: string) => { const handleQuickClick = (type: string) => {
Taro.hideToast()
switch (type) { switch (type) {
case 'toDesign': case 'toDesign':
Taro.setStorageSync('designList:filter', 'toDesign') Taro.setStorageSync('designList:filter', 'toDesign')
@@ -129,6 +136,8 @@ export default function ProfilePage() {
} }
const handleMenuClick = (path: string, label: string) => { const handleMenuClick = (path: string, label: string) => {
// Clear any lingering toast that could intercept the subsequent navigateTo
Taro.hideToast()
if (!isLoggedIn && (path.includes('designList') || path.includes('orders'))) { if (!isLoggedIn && (path.includes('designList') || path.includes('orders'))) {
Taro.showToast({ title: '请先登录', icon: 'none' }) Taro.showToast({ title: '请先登录', icon: 'none' })
setShowLogin(true) setShowLogin(true)
@@ -181,17 +190,12 @@ export default function ProfilePage() {
</View> </View>
)} )}
<View className='user-meta'> <View className='user-meta'>
{isLoggedIn ? ( <Text className='user-name' onTap={isLoggedIn ? noop : handleOpenLogin}>
<> {isLoggedIn ? userInfo.nickName : '点击登录'}
<Text className='user-name'>{userInfo.nickName}</Text> </Text>
<Text className='user-level'></Text> <Text className='user-level'>
</> {isLoggedIn ? '智绘微刻会员' : '授权微信,开启专属定制'}
) : ( </Text>
<>
<Text className='user-name' onTap={handleOpenLogin}></Text>
<Text className='user-level'></Text>
</>
)}
</View> </View>
</View> </View>