提交 ab2d3548 authored 作者: 王鹏飞's avatar 王鹏飞

chore: update

上级 e22f07ca
......@@ -2,7 +2,7 @@
import type { PaperQuestionType } from '@/types'
import CourseExamQuestionItem from './CourseExamQuestionItem.vue'
import { questionType } from '@/utils/dictionary'
import { formatQuestionType } from '@/utils/index'
interface Props {
index: number
......@@ -13,7 +13,7 @@ const props = defineProps<Props>()
// 试题类型
const questionTypeText = computed(() => {
return questionType[props.question.question_type] || props.question.question_type
return formatQuestionType(props.question.question_type)
})
</script>
......
<script setup lang="ts">
import type { CourseResourceType } from '../types'
import { formatLiveDate, formatLiveStatus } from '@/utils/index'
import ResourceIcon from '@/components/ResourceIcon.vue'
import { Download } from '@element-plus/icons-vue'
......@@ -22,13 +23,18 @@ const targetUrl = computed(() => {
const info = props.data.info
if (props.data.resource_type === 3 || props.data.resource_type === 9) {
return `/course/exam?course_id=${courseId}&semester_id=${semesterId}&paper_id=${props.data.resource_id}&type=2&paper_title=${props.data.name}`
} else if (props.data.resource_type === 6) {
return info.join_url
} else if (['pptx', 'doc', 'docx', 'xls', 'xlsx'].includes(info.type)) {
return `https://view.officeapps.live.com/op/view.aspx?src=${info.url}`
} else {
return info.url
}
})
// 是否可以收藏
function canCollection(type: number) {
return [3, 4, 9, 10, 11].includes(type)
}
// 收藏/取消收藏
function toggleCollection(data: CourseResourceType) {
// 资源类型: 1章节,2视频,3作业,4其他,6腾讯会议,9考试,10课件,11教案
......@@ -77,8 +83,17 @@ function downloadFile(data: CourseResourceType) {
>
<el-button round size="small">查看报告</el-button>
</router-link>
<template v-if="data.resource_type === 6">
<span>{{ formatLiveDate(data.info.start_time) }}</span>
<span style="margin-left: 10px">{{ formatLiveStatus(data.info.status) }}</span>
</template>
<div class="actions">
<i class="icon-star" :class="!!data.collection_count ? 'is-active' : ''" @click="toggleCollection(data)"></i>
<i
class="icon-star"
:class="!!data.collection_count ? 'is-active' : ''"
@click="toggleCollection(data)"
v-if="canCollection(data.resource_type)"
></i>
<i class="icon-download" @click="downloadFile(data)" v-if="canDownload(data.resource_type)"><Download /></i>
</div>
</div>
......@@ -100,10 +115,13 @@ function downloadFile(data: CourseResourceType) {
}
.actions {
width: 60px;
min-width: 60px;
display: flex;
align-items: center;
justify-content: space-between;
&:empty {
min-width: auto;
}
}
}
.icon-star {
......
<script setup lang="ts">
import type { LiveType } from '@/types'
import dayjs from 'dayjs'
import { formatLiveDate, formatLiveStatus } from '@/utils/index'
import { VideoPlay } from '@element-plus/icons-vue'
interface Props {
data: LiveType
}
defineProps<Props>()
function formatDate(startTime: number) {
return dayjs(startTime * 1000).format('YYYY-MM-DD HH:mm')
}
</script>
<template>
......@@ -21,7 +18,10 @@ function formatDate(startTime: number) {
{{ data.subject }}
</a>
</p>
<div class="actions">{{ formatDate(data.start_time) }}</div>
<div class="actions">
<span> {{ formatLiveDate(data.start_time) }}</span>
<span style="margin-left: 10px">{{ formatLiveStatus(data.status) }}</span>
</div>
</div>
</template>
......
......@@ -23,7 +23,8 @@ const detail = reactive<{
jobs: CourseResourceType[]
lesson_plans: CourseResourceType[]
other_infos: CourseResourceType[]
}>({ course_name: '', coursewares: [], exams: [], jobs: [], lesson_plans: [], other_infos: [] })
meetings: CourseResourceType[]
}>({ course_name: '', coursewares: [], exams: [], jobs: [], lesson_plans: [], other_infos: [], meetings: [] })
let loading = $ref<boolean>(false)
// 获取详情信息
function fetchInfo() {
......@@ -94,7 +95,13 @@ onMounted(() => {
:key="item.id"
></CoursePlayerResourceItem>
</el-tab-pane>
<!-- <el-tab-pane label="直播" lazy></el-tab-pane> -->
<el-tab-pane label="直播" lazy>
<CoursePlayerResourceItem
v-for="item in detail.meetings"
:data="item"
:key="item.id"
></CoursePlayerResourceItem>
</el-tab-pane>
</el-tabs>
</div>
<div class="course-player-aside">
......
import type { Component } from 'vue'
import type { questionType } from '@/utils/dictionary'
import type { questionType, liveStatus } from '@/utils/dictionary'
export interface IMenuItem {
tag?: string
......@@ -69,7 +69,10 @@ export interface LecturerType {
}
// 资源类型
export interface ResourceType {
export type ResourceType = FileType & LiveType & PaperType
// 资源类型
export interface FileType {
id: string
knowledge_points: string
name: string
......@@ -80,11 +83,7 @@ export interface ResourceType {
length?: number
size: number
source_id: string
paper_title?: string
paper_type?: number
paper_status?: number
}
// 直播类型
export interface LiveType {
end_time: number
......@@ -95,10 +94,11 @@ export interface LiveType {
meeting_id: string
meeting_type: number
start_time: number
status: number
status: LiveStatusType
sub_meetings: []
subject: string
}
export type LiveStatusType = keyof typeof liveStatus
// 试卷类型
export interface PaperType {
......
......@@ -3,15 +3,6 @@ export const json2Array = function (data: any, isValueToNumber = true) {
return Object.keys(data).map(value => ({ label: data[value], value: isValueToNumber ? parseInt(value) : value }))
}
// 组卷模式
export const paperType = {
1: '选题组卷',
2: '自动组卷',
3: '自由组卷'
}
// 组卷模式列表
export const paperTypeList = json2Array(paperType)
// 试题类型
export const questionType = {
1: '单选题',
......@@ -25,12 +16,12 @@ export const questionType = {
// 试题类型列表
export const questionTypeList = json2Array(questionType, false)
// 试题难度
export const questionDifficulty = {
1: '易',
2: '中',
3: '难',
0: '无'
// 直播状态
export const liveStatus = {
0: '未知',
1: '直播未开始',
2: '直播中',
3: '直播已结束'
}
// 试题难度列表
export const questionDifficultyList = json2Array(questionDifficulty, false)
// 试题类型列表
export const liveStatusList = json2Array(liveStatus, false)
import dayjs from 'dayjs'
import { liveStatus, questionType } from './dictionary'
import type { LiveStatusType, QuestionType } from '@/types'
// 直播时间
export function formatLiveDate(startTime: number) {
return dayjs(startTime * 1000).format('YYYY-MM-DD HH:mm')
}
// 直播状态
export function formatLiveStatus(status: LiveStatusType) {
return liveStatus[status] || status
}
// 试题类型
export function formatQuestionType(type: QuestionType) {
return questionType[type] || type
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论