diff --git a/src/api/modules/content.ts b/src/api/modules/content.ts new file mode 100644 index 0000000..d6ce017 --- /dev/null +++ b/src/api/modules/content.ts @@ -0,0 +1,28 @@ +import { ApiRequest } from '../request' + +// 主标题数据类型 +export interface MainTitleData { + title: string + highlightText?: string +} + +// 内容API +export class ContentApi { + // 获取内容 - 使用路径参数 contentKey + static async getContent(contentKey: string): Promise { + try { + console.log(`🚀 调用内容API,contentKey: ${contentKey}`) + const response = await ApiRequest.get(`/biz/index/content/${contentKey}`) + console.log('📋 内容API响应:', response) + return response + } catch (error) { + console.error(`❌ 获取内容失败,contentKey: ${contentKey}`, error) + throw error + } + } + + // 获取主标题内容 + static async getMainTitle(): Promise { + return this.getContent('main_title') + } +} diff --git a/src/views/Home.vue b/src/views/Home.vue index 3e8c063..31b9d59 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -4,7 +4,7 @@
-

中小学教师人工智能素养提升在线学习平台

+

{{ mainTitle }}{{ mainTitleHighlight }}在线学习平台

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

@@ -530,6 +530,7 @@ import LoginModal from '@/components/auth/LoginModal.vue' import RegisterModal from '@/components/auth/RegisterModal.vue' import { enrollCourseExample } from '@/api/examples/usage' import { CourseApi } from '@/api/modules/course' +import { ContentApi } from '@/api/modules/content' // import { getPopularCourses } from '@/data/mockCourses' @@ -680,6 +681,37 @@ const showAdvertisement = ref(true) // 控制固定按钮组显示状态 const showFixedButtons = ref(false) +// 主标题数据 +const mainTitle = ref('中小学教师人工智能素养') +const mainTitleHighlight = ref('提升') +const mainTitleLoading = ref(false) + +// 加载主标题数据 +const loadMainTitle = async () => { + try { + mainTitleLoading.value = true + console.log('🚀 开始加载主标题数据...') + + const response = await ContentApi.getMainTitle() + console.log('📋 主标题API响应:', response) + + if (response.code === 0 || response.code === 200) { + if (response.data) { + // 根据您后续提供的解析规则来处理数据 + console.log('✅ 主标题数据获取成功:', response.data) + // 暂时保持默认值,等待您提供具体的解析规则 + } + } else { + console.log('⚠️ 主标题API返回错误:', response.message) + } + } catch (error) { + console.error('❌ 加载主标题数据失败:', error) + // 保持默认值 + } finally { + mainTitleLoading.value = false + } +} + // 关闭广告函数 const closeAdvertisement = () => { showAdvertisement.value = false @@ -868,6 +900,7 @@ let scrollHandler: (() => void) | null = null onMounted(async () => { await courseStore.fetchCourses() + await loadMainTitle() // 加载主标题数据 // 创建滚动事件处理函数 scrollHandler = () => {