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(() => {