From 5422df60ff6a9751c52dc21d145b6e1d88c514ae Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期三, 26 十一月 2025 10:18:15 +0800
Subject: [PATCH] fix: 添加版本可见
---
src/pages/mine/index.vue | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 50 insertions(+), 3 deletions(-)
diff --git a/src/pages/mine/index.vue b/src/pages/mine/index.vue
index b164c37..5772f62 100644
--- a/src/pages/mine/index.vue
+++ b/src/pages/mine/index.vue
@@ -7,7 +7,7 @@
<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">
@@ -16,7 +16,7 @@
</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>
@@ -215,6 +215,11 @@
<wd-button class="logout-btn" @click="handleLogout">閫�鍑虹櫥褰�</wd-button>
</view>
+ <!-- 鐗堟湰鍙� -->
+ <view class="version">
+ <text class="version-text">鐗堟湰鍙凤細{{ versionName }}</text>
+ </view>
+
<wd-toast />
</view>
</template>
@@ -223,7 +228,7 @@
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();
@@ -231,6 +236,35 @@
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 = () => {
@@ -661,4 +695,17 @@
}
}
}
+
+// 鐗堟湰鍙�
+.version {
+ display: flex;
+ justify-content: center;
+ margin-top: 20rpx;
+ margin-bottom: 40rpx;
+}
+
+.version-text {
+ font-size: 22rpx;
+ color: #9ca3af;
+}
</style>
--
Gitblit v1.9.3