feat: 微信分享钩子全页面接入 + 订阅信息结构化映射 + JWT 错误处理加强

- client: 全部页面接入 onShareAppMessage/onShareTimeline 分享钩子
- client: login 页增强、profile 订阅展示优化
- client/stores: 订阅字段扁平结构映射为 subInfo(plan/expiresAt/startDate)
- server: auth 路由 JWT 无效/过期统一返回 401 未授权响应
- server: models/tests 同步更新
This commit is contained in:
Yuzhiran Dev
2026-09-04 11:47:29 +08:00
parent de8ca9c420
commit 66de1dc396
37 changed files with 2138 additions and 1830 deletions
+10 -10
View File
@@ -17,7 +17,7 @@
</view>
<view class="stats-row">
<view class="stat-item">
<text class="stat-value">{{ stats?.totalPoints || 0 }}</text>
<text class="stat-value">{{ stats?.totalScore || 0 }}</text>
<text class="stat-label">累计积分</text>
</view>
<view class="stat-divider"></view>
@@ -122,6 +122,8 @@
</template>
<script setup>
import { onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
import { ref, computed, onMounted } from 'vue'
import { knowledgeApi, userApi } from '@/utils/api'
import { useUserStore } from '@/stores/user'
@@ -134,7 +136,7 @@ const loading = ref(true)
// 学习时长(小时)
const studyHours = computed(() => {
const hours = stats.value?.studyHours || 0
const hours = stats.value?.totalPlayTime || 0
if (hours < 1) return `${Math.round(hours * 60)}分`
return hours.toFixed(1) + 'h'
})
@@ -156,7 +158,7 @@ function initDimData() {
color: dim.color,
bg: dim.bg,
total: 0,
done: exploreData[dim.id] || 0,
done: exploreData['dim' + dim.id]?.completed ? 1 : 0,
percent: 0,
expanded: false
}))
@@ -167,11 +169,7 @@ async function fetchDimTotals() {
for (const dim of dimProgress.value) {
try {
const data = await knowledgeApi.list({ dim: dim.id, limit: 1 })
dim.total = data?.total || data?.length || (Array.isArray(data) ? data.length : 0)
// 如果 list 返回的是数组而不是带 total 的对象,直接用数组长度
if (Array.isArray(data) && dim.total === 0) {
dim.total = data.length
}
dim.total = data?.pagination?.total || data?.items?.length || 0
// 计算百分比
if (dim.total > 0) {
dim.percent = Math.round((dim.done / dim.total) * 100)
@@ -200,10 +198,10 @@ async function loadData() {
userApi.progress(userStore.token).catch(() => ({ exploreData: {} }))
])
// 合并 exploreData
// 合并 exploreData(进度接口返回 {isNewUser, data: user},exploreData 在 data 下)
stats.value = {
...statsData,
exploreData: { ...statsData?.exploreData, ...progressData?.exploreData }
exploreData: progressData?.data?.exploreData || {}
}
dimProgress.value = initDimData()
@@ -225,10 +223,12 @@ function goBack() {
}
// 微信小程序分享
// #ifdef MP-WEIXIN
onShareAppMessage(() => ({
title: 'AI 维度 - 你的AI知识助手',
path: '/pages/index/index'
}))
// #endif
</script>
<style lang="scss" scoped>