<template>
  <view class="px-20 py-14 bg-back flex justify-between items-center gap-x-20">
    <text class="flex-1 min-w-1 text-26 ellipsis-1">{{ pageSubtitle }}</text>
    <view class="flex items-baseline">
      <text class="text-34 text-primary font-bold">{{ virtualCurrentIndex + 1 }}</text>/
      <text class="text-28 text-fore-subtitle">{{ virtualTotalCount }}</text>
    </view>
  </view>
</template>
<script lang="ts" setup>
import { useUserStore } from '@/store/userStore';
import { Transfer } from '@/types';
import { EXAM_PAGE_OPTIONS, EXAM_DATA } from '@/types/injectionSymbols';
import { useExam } from '@/composables/useExam';

const userStore = useUserStore();
const examPageOptions = inject(EXAM_PAGE_OPTIONS) || {} as Transfer.ExamAnalysisPageOptions;
const examData = inject(EXAM_DATA) || {} as ReturnType<typeof useExam>;
const { virtualCurrentIndex, virtualTotalCount } = examData;

const pageSubtitle = computed(() => {
  if (examPageOptions && examPageOptions.practiceInfo) {
    const { practiceInfo: { directed, questionType, name } } = examPageOptions;
    let titlePrefix = '';
    if (userStore.isVHS) {
      if (questionType === 0) {
        titlePrefix = '知识点练习';
      } else if (questionType === 2) {
        titlePrefix = '必刷题';
      }
    } else {
      if (directed) {
        titlePrefix = '定向刷题';
      } else {
        titlePrefix = '全量刷题';
      }
    }
    return titlePrefix + '-' + name;
  } else if (examPageOptions && examPageOptions.simulationInfo) {
    const { simulationInfo: { name } } = examPageOptions;
    return '模拟考试' + '-' + name || '模拟考试';
  }
  return '知识点练习';
});
</script>
<style lang="scss" scoped></style>