feat:新评论
This commit is contained in:
parent
06dfacc074
commit
537a7f8fe6
28
src/api/modules/content.ts
Normal file
28
src/api/modules/content.ts
Normal file
@ -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<any> {
|
||||||
|
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<any> {
|
||||||
|
return this.getContent('main_title')
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,7 @@
|
|||||||
<section class="hero-banner">
|
<section class="hero-banner">
|
||||||
<img :src="bannerImage" :alt="bannerAlt" class="banner-image" />
|
<img :src="bannerImage" :alt="bannerAlt" class="banner-image" />
|
||||||
<div class="hero-content">
|
<div class="hero-content">
|
||||||
<h2>中小学教师人工智能素养<span>提升</span>在线学习平台</h2>
|
<h2>{{ mainTitle }}<span>{{ mainTitleHighlight }}</span>在线学习平台</h2>
|
||||||
<p>为教师量身定制,帮助教师快速掌握AI技术、教学应用与伦理规范,赋能智慧课堂</p>
|
<p>为教师量身定制,帮助教师快速掌握AI技术、教学应用与伦理规范,赋能智慧课堂</p>
|
||||||
<button @click="goToCoursesPage">立即学习</button>
|
<button @click="goToCoursesPage">立即学习</button>
|
||||||
</div>
|
</div>
|
||||||
@ -530,6 +530,7 @@ import LoginModal from '@/components/auth/LoginModal.vue'
|
|||||||
import RegisterModal from '@/components/auth/RegisterModal.vue'
|
import RegisterModal from '@/components/auth/RegisterModal.vue'
|
||||||
import { enrollCourseExample } from '@/api/examples/usage'
|
import { enrollCourseExample } from '@/api/examples/usage'
|
||||||
import { CourseApi } from '@/api/modules/course'
|
import { CourseApi } from '@/api/modules/course'
|
||||||
|
import { ContentApi } from '@/api/modules/content'
|
||||||
|
|
||||||
// import { getPopularCourses } from '@/data/mockCourses'
|
// import { getPopularCourses } from '@/data/mockCourses'
|
||||||
|
|
||||||
@ -680,6 +681,37 @@ const showAdvertisement = ref(true)
|
|||||||
// 控制固定按钮组显示状态
|
// 控制固定按钮组显示状态
|
||||||
const showFixedButtons = ref(false)
|
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 = () => {
|
const closeAdvertisement = () => {
|
||||||
showAdvertisement.value = false
|
showAdvertisement.value = false
|
||||||
@ -868,6 +900,7 @@ let scrollHandler: (() => void) | null = null
|
|||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await courseStore.fetchCourses()
|
await courseStore.fetchCourses()
|
||||||
|
await loadMainTitle() // 加载主标题数据
|
||||||
|
|
||||||
// 创建滚动事件处理函数
|
// 创建滚动事件处理函数
|
||||||
scrollHandler = () => {
|
scrollHandler = () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user