<template>
  <div class="page">
    <div class="page-content">
      <div class="head-box">
        <div style="display: flex; align-items: center; justify-content: flex-start">
          <span class="name">Hi {{ teacherName }}, 请选择课程!</span>
        </div>
      </div>
      <div class="content-box">
        <student-course-room v-if="role === 'student'"></student-course-room>
        <teacher-course-room v-if="role === 'teacher'"></teacher-course-room>
      </div>
    </div>
    <div class="footer-bottom-box">
      <el-space alignment="center" :size="25">
        <div></div>
      </el-space>
      <el-space alignment="center" :size="25">
        <app-button-full-screen></app-button-full-screen>
        <app-button-back-page></app-button-back-page>
      </el-space>
    </div>
  </div>
</template>

<script setup lang="ts">
  import { onMounted, ref } from 'vue';
  import StudentCourseRoom from './aa-components/student-course-room.vue';
  import TeacherCourseRoom from './aa-components/teacher-course-room.vue';
  const meetingStore = useMeetingStore();
  const route = useRoute();
  const role = ref<'student' | 'teacher'>(String(route.query.role) === 'student' ? 'student' : 'teacher');
  const userStore = useUserStore();
  const teacherName = ref(userStore.userInfo?.name);

  onMounted(() => {
    role.value = String(route.query.role) === 'student' ? 'student' : 'teacher';
    meetingStore.clear();
  });
</script>

<style lang="scss" scoped>
  .page {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 15px;
    overflow: hidden;

    .page-content {
      position: relative;
      box-sizing: border-box;
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      justify-content: flex-start;
      width: 100%;
      height: 100%;
      overflow: hidden;
      background: rgba(255, 255, 255, 0.4);
      border: 1px solid rgba(255, 255, 255, 0.2);
      border-radius: 20px;
      box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);

      .head-box {
        box-sizing: border-box;
        display: grid;
        grid-template-columns: 1fr 0.5fr 1fr;
        width: 100%;
        padding: 15px;
        overflow: hidden;

        .name {
          font-size: 2vw;
          font-weight: bold;
        }
      }

      .content-box {
        box-sizing: border-box;
        display: flex;
        flex: 1;
        align-items: center;
        justify-content: center;
        width: 100%;
        overflow: hidden;

        .marquee-wrapper {
          position: relative;
          width: 100%;
          height: 100%;
        }
      }
    }
  }

  .footer-bottom-box {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 15px;
    padding-bottom: 10px;
  }
</style>
