| | |
| | | <view class="avatar-container" @click="navigateToProfile"> |
| | | <image |
| | | class="avatar" |
| | | :src="isLogin ? userInfo!.avatar : defaultAvatar" |
| | | :src="isLogin ? userInfo?.avatar : defaultAvatar" |
| | | mode="aspectFill" |
| | | /> |
| | | <view v-if="isLogin" class="avatar-edit"> |
| | |
| | | </view> |
| | | <view class="user-details"> |
| | | <block v-if="isLogin"> |
| | | <view class="nickname">{{ userInfo!.nickname || "匿名用户" }}</view> |
| | | <view class="nickname">{{ userInfo?.nickname || "匿名用户" }}</view> |
| | | <view class="user-id">ID: {{ userInfo?.username || "0000000" }}</view> |
| | | </block> |
| | | <block v-else> |
| | |
| | | <wd-button class="logout-btn" @click="handleLogout">退出登录</wd-button> |
| | | </view> |
| | | |
| | | <!-- 版本号 --> |
| | | <view class="version"> |
| | | <text class="version-text">版本号:{{ versionName }}</text> |
| | | </view> |
| | | |
| | | <wd-toast /> |
| | | </view> |
| | | </template> |
| | |
| | | import { useToast } from "wot-design-uni"; |
| | | import { useUserStore } from "@/store/modules/user"; |
| | | import { useThemeStore } from "@/store/modules/theme"; |
| | | import { computed } from "vue"; |
| | | import { computed, ref, onMounted } from "vue"; |
| | | |
| | | const toast = useToast(); |
| | | const userStore = useUserStore(); |
| | |
| | | const userInfo = computed(() => userStore.userInfo); |
| | | const isLogin = computed(() => !!userInfo.value); |
| | | const defaultAvatar = "/static/images/default-avatar.png"; |
| | | |
| | | // 版本号 |
| | | const versionName = ref("1.0.16"); |
| | | |
| | | // 获取版本号 |
| | | onMounted(() => { |
| | | // #ifdef MP-WEIXIN |
| | | try { |
| | | const accountInfo = uni.getAccountInfoSync(); |
| | | if (accountInfo?.miniProgram?.version) { |
| | | versionName.value = accountInfo.miniProgram.version; |
| | | } |
| | | } catch (e) { |
| | | // 获取失败时使用默认值 |
| | | } |
| | | // #endif |
| | | |
| | | // #ifdef APP-PLUS |
| | | try { |
| | | // @ts-ignore |
| | | if (plus?.runtime?.version) { |
| | | // @ts-ignore |
| | | versionName.value = plus.runtime.version; |
| | | } |
| | | } catch (e) { |
| | | // 获取失败时使用默认值 |
| | | } |
| | | // #endif |
| | | }); |
| | | |
| | | // 登录 |
| | | const navigateToLoginPage = () => { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 版本号 |
| | | .version { |
| | | display: flex; |
| | | justify-content: center; |
| | | margin-top: 20rpx; |
| | | margin-bottom: 40rpx; |
| | | } |
| | | |
| | | .version-text { |
| | | font-size: 22rpx; |
| | | color: #9ca3af; |
| | | } |
| | | </style> |