import React from 'react' import { View, Text } from '@tarojs/components' import Taro from '@tarojs/taro' import { useUser } from '@/hooks/useUser' definePageConfig({ navigationBarTitleText: '设置', }) const SettingPage: React.FC = () => { const { isLoggedIn, logoutUser } = useUser() const handleClearCache = () => { Taro.showModal({ title: '提示', content: '确定要清除缓存吗?', success: (res) => { if (res.confirm) { Taro.clearStorageSync() Taro.showToast({ title: '缓存已清除', icon: 'success' }) } }, }) } const handleLogout = () => { if (!isLoggedIn) return Taro.showModal({ title: '提示', content: '确定要退出登录吗?', success: (res) => { if (res.confirm) { logoutUser() Taro.reLaunch({ url: '/pages/index/index' }) } }, }) } const menuItems = [ { label: '清除缓存', action: handleClearCache }, { label: '关于我们', action: () => Taro.navigateTo({ url: '/pages/user/about/index' }) }, { label: '用户协议', action: () => Taro.navigateTo({ url: '/passport/agreement' }) }, { label: '隐私政策', action: () => Taro.navigateTo({ url: '/passport/agreement' }) }, ] return ( {menuItems.map((item, idx) => ( {item.label} {'>'} ))} {isLoggedIn && ( 退出登录 )} ) } export default SettingPage