From fb6a63d7a55a9bf59623a969bbb6b50200271c66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=93=B2=E9=93=9C?= <9490856+zhangzhetong@user.noreply.gitee.com> Date: Wed, 24 Sep 2025 00:27:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=A6=96=E9=A1=B5=E6=95=99=E5=B8=88?= =?UTF-8?q?=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/index/index.vue | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 4a6e297..bda5a86 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -14,6 +14,7 @@ import { computed, onMounted, ref } from 'vue' import { teacherAnalysisRecentExamStatsUsingPost } from '@/service/laoshichengjifenxi' import { useHomeStore } from '@/store/home' +import { useUserStore } from '@/store/user' defineOptions({ name: 'Home', @@ -44,6 +45,7 @@ safeAreaInsets = systemInfo.safeAreaInsets // 使用store const homeStore = useHomeStore() +const userStore = useUserStore() // 分数线设置 const scoreSettings = ref({ @@ -78,10 +80,28 @@ const tempSettings = ref({ top_n: scoreSettings.value.top_n, }) -// TODO: 这些用户信息应该从用户store中获取 -const schoolName = ref('华师一附中') -const teacherName = ref('张信哲') -const teacherSubject = ref('语文') +// 从用户store中获取教师信息 +const schoolName = computed(() => { + const userInfo = userStore.getUserInfo + return userInfo.schools?.[0]?.name || '学校' +}) + +const teacherName = computed(() => { + const userInfo = userStore.getUserInfo + return userInfo.nickname || '教师' +}) + +const teacherSubject = computed(() => { + const userInfo = userStore.getUserInfo + // 从角色信息中获取学科,假设角色名包含学科信息 + const roleName = userInfo.roles?.[0]?.name + if (roleName) { + // 提取学科信息,例如"语文教师"中的"语文" + const subjectMatch = roleName.match(/^(.+?)教师$/) + return subjectMatch ? subjectMatch[1] : '学科' + } + return '学科' +}) // 计算当前选中的班级名称 const selectedClassName = computed(() => {