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

chore: update

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