refactor: 项目架构重构 - 目录标准化 + 清理冗余

- 目录重命名: backend/wdkj-server/ → server/, frontend/ai-dimension/ → client/
- 删除 20+ 冗余文件(WDKJ 旧脚本、Windows 脚本、过时文档、设计稿)
- 更新 package.json 元数据(移除 wdkj 命名)
- 完善三级 .gitignore(根 + server + client)
- 重写 README.md 和 CHANGELOG.md
- 工具脚本移至 scripts/
This commit is contained in:
Yuzhiran Dev
2026-07-11 12:45:37 +08:00
parent 66ac576082
commit c1d6dd3b29
106 changed files with 17436 additions and 2311 deletions
+484
View File
@@ -0,0 +1,484 @@
<template>
<view class="progress-page">
<!-- 顶部导航 -->
<view class="nav-bar">
<view class="nav-back" @click="goBack">‹</view>
<text class="nav-title">学习进度</text>
<view class="nav-spacer"></view>
</view>
<!-- 用户等级卡片 -->
<view class="stats-header">
<view class="level-badge">
<text class="level-num">{{ stats?.level || '--' }}</text>
<text class="level-name">{{ stats?.levelName || '探索者' }}</text>
</view>
<view class="stats-row">
<view class="stat-item">
<text class="stat-value">{{ stats?.totalPoints || 0 }}</text>
<text class="stat-label">累计积分</text>
</view>
<view class="stat-divider"></view>
<view class="stat-item">
<text class="stat-value">{{ studyHours }}</text>
<text class="stat-label">学习时长</text>
</view>
</view>
</view>
<!-- 维度进度列表 -->
<view class="section-title">
<text>维度进度</text>
</view>
<scroll-view class="progress-list" scroll-y>
<view
class="dim-card"
v-for="dimData in dimProgress"
:key="dimData.id"
:class="{ expanded: dimData.expanded }"
@click="toggleExpand(dimData.id)"
>
<!-- 卡片头部(可点击展开) -->
<view class="dim-card-head">
<view class="dim-info">
<view
class="dim-icon-circle"
:style="{ background: dimData.bg, color: dimData.color }"
>
<text>{{ dimData.icon }}</text>
</view>
<view class="dim-text">
<text class="dim-name">{{ dimData.name }}</text>
<text class="dim-desc">{{ dimData.desc }}</text>
</view>
</view>
<!-- 环形进度 -->
<view class="dim-ring" v-if="dimData.total > 0">
<view
class="ring"
:style="{
background: `conic-gradient(${dimData.color} 0% ${dimData.percent}%, rgba(255,255,255,0.08) ${dimData.percent}% 100%)`
}"
>
<view class="ring-inner">
<text class="ring-text">{{ dimData.percent }}%</text>
</view>
</view>
</view>
<view class="dim-ring" v-else>
<view class="ring ring-empty">
<view class="ring-inner">
<text class="ring-text">--</text>
</view>
</view>
</view>
</view>
<!-- 展开内容 -->
<view class="dim-card-body" v-if="dimData.expanded">
<view class="progress-detail">
<view class="detail-item">
<text class="detail-label">已完成</text>
<text class="detail-value" :style="{ color: dimData.color }">
{{ dimData.done }}
</text>
</view>
<view class="detail-item">
<text class="detail-label">总知识</text>
<text class="detail-value">{{ dimData.total }}</text>
</view>
<view class="detail-item">
<text class="detail-label">进度</text>
<text class="detail-value">
{{ dimData.done }}/{{ dimData.total }}
</text>
</view>
</view>
<!-- 进度条 -->
<view class="progress-bar-bg">
<view
class="progress-bar-fill"
:style="{
width: `${dimData.percent}%`,
background: `linear-gradient(90deg, ${dimData.color}, ${dimData.color}dd)`
}"
></view>
</view>
<text class="progress-bar-text">
{{ dimData.done }} / {{ dimData.total }} 已探索
</text>
</view>
</view>
<!-- 底部间距 -->
<view class="list-spacer"></view>
</scroll-view>
</view>
</template>
<script setup>
import { ref, computed, onMounted } from 'vue'
import { knowledgeApi, userApi } from '@/utils/api'
import { useUserStore } from '@/stores/user'
import { DIMENSIONS } from '@/utils/dimensions'
const userStore = useUserStore()
const stats = ref(null)
const dimProgress = ref([])
const loading = ref(true)
// 学习时长(小时)
const studyHours = computed(() => {
const hours = stats.value?.studyHours || 0
if (hours < 1) return `${Math.round(hours * 60)}分`
return hours.toFixed(1) + 'h'
})
// 展开/收起维度
function toggleExpand(id) {
const dim = dimProgress.value.find(d => d.id === id)
if (dim) dim.expanded = !dim.expanded
}
// 初始化维度数据
function initDimData() {
const exploreData = stats.value?.exploreData || {}
return DIMENSIONS.map(dim => ({
id: dim.id,
name: dim.name,
desc: dim.desc,
icon: dim.icon,
color: dim.color,
bg: dim.bg,
total: 0,
done: exploreData[dim.id] || 0,
percent: 0,
expanded: false
}))
}
// 获取维度知识总数
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
}
// 计算百分比
if (dim.total > 0) {
dim.percent = Math.round((dim.done / dim.total) * 100)
}
} catch (err) {
console.error(`[progress] 获取维度 ${dim.id} 数据失败:`, err)
}
}
}
// 加载数据
async function loadData() {
if (!userStore.isLoggedIn) {
// 未登录也展示基础信息,但用户相关数据为空
stats.value = { exploreData: {} }
dimProgress.value = initDimData()
await fetchDimTotals()
loading.value = false
return
}
try {
// 获取用户统计和进度
const [statsData, progressData] = await Promise.all([
userApi.stats(userStore.token).catch(() => ({ exploreData: {} })),
userApi.progress(userStore.token).catch(() => ({ exploreData: {} }))
])
// 合并 exploreData
stats.value = {
...statsData,
exploreData: { ...statsData?.exploreData, ...progressData?.exploreData }
}
dimProgress.value = initDimData()
await fetchDimTotals()
} catch (err) {
console.error('[progress] 加载失败:', err)
uni.showToast({ title: '加载失败,请重试', icon: 'none' })
} finally {
loading.value = false
}
}
onMounted(() => {
loadData()
})
function goBack() {
uni.navigateBack()
}
</script>
<style lang="scss" scoped>
.progress-page {
width: 100%;
height: 100vh;
display: flex;
flex-direction: column;
background: var(--bg-primary);
}
// 顶部导航
.nav-bar {
display: flex;
align-items: center;
justify-content: space-between;
padding: 50px 20px 12px;
flex-shrink: 0;
.nav-back {
width: 30px;
height: 30px;
display: flex;
align-items: center;
justify-content: center;
font-size: 22px;
color: var(--text-primary);
}
.nav-title {
font-size: 16px;
font-weight: 600;
color: var(--text-primary);
}
.nav-spacer { width: 30px; }
}
// 用户等级卡片
.stats-header {
margin: 0 20px 16px;
padding: 20px;
background: linear-gradient(135deg, rgba(179, 136, 255, 0.1), rgba(77, 182, 172, 0.08));
border: 1px solid rgba(179, 136, 255, 0.15);
border-radius: 16px;
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
flex-shrink: 0;
}
.level-badge {
display: flex;
align-items: baseline;
gap: 12px;
margin-bottom: 16px;
.level-num {
font-size: 36px;
font-weight: 800;
background: linear-gradient(135deg, var(--dim1-color), var(--dim2-color));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.level-name {
font-size: 15px;
color: var(--text-secondary);
font-weight: 500;
}
}
.stats-row {
display: flex;
align-items: center;
justify-content: space-around;
padding-top: 14px;
border-top: 1px solid rgba(255, 255, 255, 0.06);
.stat-item {
display: flex;
flex-direction: column;
align-items: center;
.stat-value {
font-size: 22px;
font-weight: 700;
color: var(--text-primary);
}
.stat-label {
font-size: 12px;
color: var(--text-secondary);
margin-top: 4px;
}
}
.stat-divider {
width: 1px;
height: 30px;
background: rgba(255, 255, 255, 0.08);
}
}
// 章节标题
.section-title {
padding: 10px 20px 0;
font-size: 16px;
font-weight: 600;
color: var(--text-primary);
flex-shrink: 0;
}
// 进度列表
.progress-list {
flex: 1;
padding: 8px 20px 0;
overflow-y: auto;
}
.list-spacer {
height: 40px;
}
// 维度卡片
.dim-card {
background: rgba(255, 255, 255, 0.03);
border: 1px solid rgba(255, 255, 255, 0.06);
border-radius: 14px;
margin-bottom: 10px;
overflow: hidden;
transition: all 0.3s;
}
.dim-card-head {
display: flex;
align-items: center;
justify-content: space-between;
padding: 14px 16px;
}
.dim-info {
display: flex;
align-items: center;
gap: 12px;
}
.dim-icon-circle {
width: 40px;
height: 40px;
border-radius: 12px;
display: flex;
align-items: center;
justify-content: center;
font-size: 18px;
border: 1px solid rgba(255, 255, 255, 0.08);
}
.dim-text {
display: flex;
flex-direction: column;
}
.dim-name {
font-size: 14px;
font-weight: 600;
color: var(--text-primary);
}
.dim-desc {
font-size: 11px;
color: var(--text-secondary);
margin-top: 2px;
}
// 环形进度
.dim-ring {
width: 48px;
height: 48px;
}
.ring {
width: 100%;
height: 100%;
border-radius: 50%;
padding: 3px;
display: flex;
align-items: center;
justify-content: center;
position: relative;
.ring-inner {
width: 100%;
height: 100%;
background: var(--bg-primary);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
.ring-text {
font-size: 10px;
font-weight: 600;
color: var(--text-primary);
}
}
}
.ring-empty {
background: rgba(255, 255, 255, 0.08);
}
// 展开内容
.dim-card-body {
padding: 0 16px 16px;
border-top: 1px solid rgba(255, 255, 255, 0.04);
}
.progress-detail {
display: flex;
gap: 24px;
margin-top: 14px;
.detail-item {
display: flex;
flex-direction: column;
align-items: center;
.detail-label {
font-size: 11px;
color: var(--text-secondary);
margin-bottom: 4px;
}
.detail-value {
font-size: 16px;
font-weight: 600;
color: var(--text-primary);
}
}
}
// 进度条
.progress-bar-bg {
width: 100%;
height: 6px;
background: rgba(255, 255, 255, 0.06);
border-radius: 3px;
overflow: hidden;
margin-top: 14px;
}
.progress-bar-fill {
height: 100%;
border-radius: 3px;
transition: width 0.5s ease;
box-shadow: 0 0 8px rgba(179, 136, 255, 0.4);
}
.progress-bar-text {
display: block;
font-size: 11px;
color: var(--text-secondary);
margin-top: 6px;
text-align: right;
}
</style>