feat:精选资源视频解析修复
This commit is contained in:
parent
d5bbc38ddf
commit
4f9f8d0a88
@ -8,11 +8,11 @@ export interface MainTitleData {
|
||||
|
||||
// 内容API
|
||||
export class ContentApi {
|
||||
// 获取内容 - 使用路径参数 contentKey
|
||||
// 获取内容 - 使用查询参数 contentKey
|
||||
static async getContent(contentKey: string): Promise<any> {
|
||||
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<any> {
|
||||
return this.getContent('main_title')
|
||||
}
|
||||
|
||||
// 获取副标题内容
|
||||
static async getMainSubTitle(): Promise<any> {
|
||||
return this.getContent('main_sub_title')
|
||||
}
|
||||
|
||||
// 获取统计数据
|
||||
static async getStatistics(): Promise<any> {
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 || '获取学生菜单失败'
|
||||
|
@ -4,8 +4,8 @@
|
||||
<section class="hero-banner">
|
||||
<img :src="bannerImage" :alt="bannerAlt" class="banner-image" />
|
||||
<div class="hero-content">
|
||||
<h2>云南省{{ mainTitle }}<span>{{ mainTitleHighlight }}</span>在线学习平台</h2>
|
||||
<p>为教师量身定制,帮助教师快速掌握AI技术、教学应用与伦理规范,赋能智慧课堂</p>
|
||||
<h2 v-html="formattedMainTitle"></h2>
|
||||
<p>{{ mainSubTitle }}</p>
|
||||
<button @click="goToCoursesPage">立即学习</button>
|
||||
</div>
|
||||
</section>
|
||||
@ -18,7 +18,7 @@
|
||||
<img src="/top/顶部icon1.png" alt="学习视频" />
|
||||
</div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-number">1000 +</div>
|
||||
<div class="stat-number">{{ statistics.xxsp }} +</div>
|
||||
<div class="stat-label">{{ t('home.stats.learningVideos') }}</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -28,7 +28,7 @@
|
||||
<img src="/top/顶部icon2.png" alt="名师专家" />
|
||||
</div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-number">109 +</div>
|
||||
<div class="stat-number">{{ statistics.mszj }} +</div>
|
||||
<div class="stat-label">{{ t('home.stats.expertTeachers') }}</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -38,7 +38,7 @@
|
||||
<img src="/top/顶部icon3.png" alt="培训教材" />
|
||||
</div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-number">3549 +</div>
|
||||
<div class="stat-number">{{ statistics.pxjc }} +</div>
|
||||
<div class="stat-label">{{ t('home.stats.trainingMaterials') }}</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -48,7 +48,7 @@
|
||||
<img src="/top/顶部icon4.png" alt="资源素材" />
|
||||
</div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-number">6532 +</div>
|
||||
<div class="stat-number">{{ statistics.zysc }} +</div>
|
||||
<div class="stat-label">{{ t('home.stats.resourceMaterials') }}</div>
|
||||
</div>
|
||||
|
||||
@ -59,7 +59,7 @@
|
||||
<img src="/top/顶部icon5.png" alt="在线实验" />
|
||||
</div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-number">2652 +</div>
|
||||
<div class="stat-number">{{ statistics.zxsy }} +</div>
|
||||
<div class="stat-label">{{ t('home.stats.onlineExperiments') }}</div>
|
||||
</div>
|
||||
|
||||
@ -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] 转换为 <span>...</span>
|
||||
const formattedMainTitle = computed(() => {
|
||||
// 将 [blue]...[/blue] 替换为 <span>...</span>
|
||||
return mainTitleRaw.value.replace(/\[blue\](.*?)\[\/blue\]/g, '<span>$1</span>')
|
||||
})
|
||||
|
||||
// 加载主标题数据
|
||||
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;
|
||||
}
|
||||
|
@ -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 || ''
|
||||
};
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user