feat: latest code update

This commit is contained in:
yuzhiran
2026-06-16 13:18:36 +08:00
parent 5a49d15696
commit 96c367e0f8
17 changed files with 198 additions and 107 deletions
+24 -7
View File
@@ -134,6 +134,7 @@
<script setup>
import { ref, onMounted } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { api } from '../../config'
const stats = ref({ completedInterviews: 0, avgScore: 0, streak: 0 })
@@ -155,6 +156,16 @@ onMounted(async () => {
const t = token()
if (!t) return
await loadProgressData()
})
onShow(async () => {
if (token()) await loadProgressData()
})
async function loadProgressData() {
const t = token()
if (!t) return
try {
// Load progress
const res = await uni.request({
@@ -166,7 +177,7 @@ onMounted(async () => {
progress.value = d
dimensions.value = dimensions.value.map(dim => ({
...dim,
value: d.dimensions?.[dim.key] || Math.round(50 + Math.random() * 30),
value: d.dimensions?.[dim.key] || 0,
}))
}
} catch (e) { console.error(e) }
@@ -191,23 +202,29 @@ onMounted(async () => {
}
} catch (e) { console.error(e) }
// Build week days
buildWeekDays()
}
function buildWeekDays() {
const days = ['日', '一', '二', '三', '四', '五', '六']
const today = new Date()
const arr = []
const checkinDates = (progress.value.checkins || []).map((c) => {
const d = new Date(c.date || c.createdAt)
return `${d.getFullYear()}-${d.getMonth() + 1}-${d.getDate()}`
})
for (let i = 6; i >= 0; i--) {
const d = new Date(today)
d.setDate(d.getDate() - i)
const isToday = i === 0
// Mark days with interviews (simulate based on streak)
const key = `${d.getFullYear()}-${d.getMonth() + 1}-${d.getDate()}`
arr.push({
label: days[d.getDay()],
isToday,
done: i < (stats.value.streak || 0),
isToday: i === 0,
done: checkinDates.includes(key),
})
}
weekDays.value = arr
})
}
const formatDate = (d) => {
if (!d) return ''