From 4f9f8d0a88dd556f3a76a2346e8d34c465b3b239 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=BC=A0?= <2091066548@qq.com> Date: Fri, 17 Oct 2025 18:20:56 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E7=B2=BE=E9=80=89=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E8=A7=86=E9=A2=91=E8=A7=A3=E6=9E=90=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/modules/content.ts | 22 +++- src/stores/menu.ts | 20 ++-- src/views/Home.vue | 113 +++++++++++++++++--- src/views/teacher/ExamPages/ExamLibrary.vue | 2 +- 4 files changed, 134 insertions(+), 23 deletions(-) diff --git a/src/api/modules/content.ts b/src/api/modules/content.ts index 1702e25..b4f2d33 100644 --- a/src/api/modules/content.ts +++ b/src/api/modules/content.ts @@ -8,11 +8,11 @@ export interface MainTitleData { // 内容API export class ContentApi { - // 获取内容 - 使用路径参数 contentKey + // 获取内容 - 使用查询参数 contentKey static async getContent(contentKey: string): Promise { try { console.log(`🚀 调用内容API,contentKey: ${contentKey}`) - const response = await ApiRequest.get(`/aiol/index/content/${contentKey}`) + const response = await ApiRequest.get(`/aiol/index/content?contentKey=${contentKey}`) console.log('📋 内容API响应:', response) return response } catch (error) { @@ -25,4 +25,22 @@ export class ContentApi { static async getMainTitle(): Promise { return this.getContent('main_title') } + + // 获取副标题内容 + static async getMainSubTitle(): Promise { + return this.getContent('main_sub_title') + } + + // 获取统计数据 + static async getStatistics(): Promise { + try { + console.log('🚀 调用统计数据API') + const response = await ApiRequest.get('/aiol/index/statistics') + console.log('📋 统计数据API响应:', response) + return response + } catch (error) { + console.error('❌ 获取统计数据失败', error) + throw error + } + } } diff --git a/src/stores/menu.ts b/src/stores/menu.ts index 29c8438..105f543 100644 --- a/src/stores/menu.ts +++ b/src/stores/menu.ts @@ -34,11 +34,15 @@ export const useMenuStore = defineStore('menu', () => { error.value = null const response = await MenuApi.getIndexMenus() - if (response.code === 200) { - indexMenus.value = response.data || [] + + // response.data 是 axios 的响应数据,response.data.data 才是我们的业务数据 + const businessData = response.data + + if (businessData.code === 200) { + indexMenus.value = businessData.result || [] console.log('✅ 首页菜单加载成功:', indexMenus.value) } else { - throw new Error(response.message || '获取首页菜单失败') + throw new Error(businessData.message || '获取首页菜单失败') } } catch (err: any) { error.value = err.message || '获取首页菜单失败' @@ -54,11 +58,15 @@ export const useMenuStore = defineStore('menu', () => { error.value = null const response = await MenuApi.getStudentMenus() - if (response.code === 200) { - studentMenus.value = response.data.result || [] + + // response.data 是 axios 的响应数据,response.data.data 才是我们的业务数据 + const businessData = response.data + + if (businessData.code === 200) { + studentMenus.value = businessData.result || [] console.log('✅ 学生菜单加载成功:', studentMenus.value) } else { - throw new Error(response.message || '获取学生菜单失败') + throw new Error(businessData.message || '获取学生菜单失败') } } catch (err: any) { error.value = err.message || '获取学生菜单失败' diff --git a/src/views/Home.vue b/src/views/Home.vue index e1dfa1c..f043cae 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -4,8 +4,8 @@
-

云南省{{ mainTitle }}{{ mainTitleHighlight }}在线学习平台

-

为教师量身定制,帮助教师快速掌握AI技术、教学应用与伦理规范,赋能智慧课堂

+

+

{{ mainSubTitle }}

@@ -18,7 +18,7 @@ 学习视频
-
1000 +
+
{{ statistics.xxsp }} +
{{ t('home.stats.learningVideos') }}
@@ -28,7 +28,7 @@ 名师专家
-
109 +
+
{{ statistics.mszj }} +
{{ t('home.stats.expertTeachers') }}
@@ -38,7 +38,7 @@ 培训教材
-
3549 +
+
{{ statistics.pxjc }} +
{{ t('home.stats.trainingMaterials') }}
@@ -48,7 +48,7 @@ 资源素材
-
6532 +
+
{{ statistics.zysc }} +
{{ t('home.stats.resourceMaterials') }}
@@ -59,7 +59,7 @@ 在线实验
-
2652 +
+
{{ statistics.zxsy }} +
{{ t('home.stats.onlineExperiments') }}
@@ -759,10 +759,29 @@ const showAdvertisement = ref(true) const showFixedButtons = ref(false) // 主标题数据 -const mainTitle = ref('中小学教师人工智能素养') -const mainTitleHighlight = ref('提升') +const mainTitleRaw = ref('云南省中小学教师人工智能素养 [blue]提升[/blue] 在线学习平台') const mainTitleLoading = ref(false) +// 副标题数据 +const mainSubTitle = ref('为教师量身定制,帮助教师快速掌握AI技术、教学应用与伦理规范,赋能智慧课堂') +const mainSubTitleLoading = ref(false) + +// 统计数据 +const statistics = ref({ + xxsp: 1000, // 学习视频 + mszj: 109, // 名师专家 + pxjc: 3549, // 培训教材 + zysc: 6532, // 资源素材 + zxsy: 2652 // 在线实验 +}) +const statisticsLoading = ref(false) + +// 格式化主标题 - 将 [blue]...[/blue] 转换为 ... +const formattedMainTitle = computed(() => { + // 将 [blue]...[/blue] 替换为 ... + return mainTitleRaw.value.replace(/\[blue\](.*?)\[\/blue\]/g, '$1') +}) + // 加载主标题数据 const loadMainTitle = async () => { try { @@ -773,10 +792,13 @@ const loadMainTitle = async () => { console.log('📋 主标题API响应:', response) if (response.code === 0 || response.code === 200) { - if (response.data) { - // 根据您后续提供的解析规则来处理数据 - console.log('✅ 主标题数据获取成功:', response.data) - // 暂时保持默认值,等待您提供具体的解析规则 + // 优先使用 result 字段,如果没有则使用 message 字段 + const titleText = response.data?.result || response.data?.message || response.message + + if (titleText) { + console.log('✅ 主标题数据获取成功:', titleText) + mainTitleRaw.value = titleText + console.log('✅ 格式化后的标题:', formattedMainTitle.value) } } else { console.log('⚠️ 主标题API返回错误:', response.message) @@ -789,6 +811,67 @@ const loadMainTitle = async () => { } } +// 加载副标题数据 +const loadMainSubTitle = async () => { + try { + mainSubTitleLoading.value = true + console.log('🚀 开始加载副标题数据...') + + const response = await ContentApi.getMainSubTitle() + console.log('📋 副标题API响应:', response) + + if (response.code === 0 || response.code === 200) { + // 优先使用 result 字段,如果没有则使用 message 字段 + const subTitleText = response.data?.result || response.data?.message || response.message + + if (subTitleText) { + console.log('✅ 副标题数据获取成功:', subTitleText) + mainSubTitle.value = subTitleText + } + } else { + console.log('⚠️ 副标题API返回错误:', response.message) + } + } catch (error) { + console.error('❌ 加载副标题数据失败:', error) + // 保持默认值 + } finally { + mainSubTitleLoading.value = false + } +} + +// 加载统计数据 +const loadStatistics = async () => { + try { + statisticsLoading.value = true + console.log('🚀 开始加载统计数据...') + + const response = await ContentApi.getStatistics() + console.log('📋 统计数据API响应:', response) + + if (response.code === 0 || response.code === 200) { + const statsData = response.data?.result || response.data + + if (statsData) { + console.log('✅ 统计数据获取成功:', statsData) + statistics.value = { + xxsp: statsData.xxsp || 1000, + mszj: statsData.mszj || 109, + pxjc: statsData.pxjc || 3549, + zysc: statsData.zysc || 6532, + zxsy: statsData.zxsy || 2652 + } + } + } else { + console.log('⚠️ 统计数据API返回错误:', response.message) + } + } catch (error) { + console.error('❌ 加载统计数据失败:', error) + // 保持默认值 + } finally { + statisticsLoading.value = false + } +} + // 关闭广告函数 const closeAdvertisement = () => { showAdvertisement.value = false @@ -989,6 +1072,8 @@ let scrollHandler: (() => void) | null = null onMounted(async () => { await courseStore.fetchCourses() await loadMainTitle() // 加载主标题数据 + await loadMainSubTitle() // 加载副标题数据 + await loadStatistics() // 加载统计数据 // 创建滚动事件处理函数 scrollHandler = () => { @@ -1240,7 +1325,7 @@ onUnmounted(() => { color: #000F3D; } -.hero-content h2 span { +.hero-content h2 :deep(span) { color: #39A8E8; font-weight: 700; } diff --git a/src/views/teacher/ExamPages/ExamLibrary.vue b/src/views/teacher/ExamPages/ExamLibrary.vue index 6840265..4004d07 100644 --- a/src/views/teacher/ExamPages/ExamLibrary.vue +++ b/src/views/teacher/ExamPages/ExamLibrary.vue @@ -362,7 +362,7 @@ const loadExamPaperList = async () => { status: getStatus(item), startTime: formatTime(item.startTime || '', item.endTime || ''), endTime: item.endTime || '', - creator: item.createBy || '未知', + creator: item.createByName || '未知', creationTime: item.createTime || '' }; });