| | |
| | | <div class="card-wrapper w-full h-full flex flex-col px-8 box-border"> |
| | | <div class="card-header flex justify-between items-center shrink-0"> |
| | | <div class="header-search flex items-center"> |
| | | <el-input v-model="searchText" placeholder="请输入搜索内容" :prefix-icon="Search" /> |
| | | <el-button type="primary" class="ml-4">搜索</el-button> |
| | | <el-input v-model="searchText" placeholder="请输入搜索内容" :prefix-icon="Search" maxlength="20" /> |
| | | <el-button type="primary" class="ml-4" @click="searchFile">搜索</el-button> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="card-main flex-1 my-5 relative"> |
| | | <div class="main-content absolute top-0 bottom-0 left-0 right-0"> |
| | | <el-table :data="fileList" height="100%"> |
| | | <el-table :data="fileList" height="100%" v-loading="loading"> |
| | | <el-table-column label="文件名称"> |
| | | <template #default="scope"> |
| | | <div class="row-info"> |
| | | <div class="icon"> |
| | | <img :src="fileType[scope.row.type].iconPath" class="width-img" /> |
| | | <img :src="getIcon(scope.row.contentType)" class="width-img" /> |
| | | </div> |
| | | <div class="label">{{ scope.row.name }}</div> |
| | | <div class="label">{{ scope.row.introduction }}</div> |
| | | </div> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="class" label="班级" align="center" /> |
| | | <el-table-column prop="subject" label="科目" align="center" /> |
| | | <el-table-column prop="date" label="上传时间" align="center" /> |
| | | <el-table-column prop="className" label="班级" align="center" /> |
| | | <el-table-column prop="typeName" label="科目" align="center" /> |
| | | <el-table-column prop="updateTime" label="上传时间" align="center" /> |
| | | <el-table-column> |
| | | <template #default="scope"> |
| | | <el-button link type="primary" @click.prevent="checkRow(scope.row)"> |
| | |
| | | </div> |
| | | |
| | | <div class="card-footer flex justify-center mb-7 shrink-0"> |
| | | <el-pagination background layout="prev, pager, next" :total="1000" /> |
| | | <el-pagination background layout="prev, pager, next" :total="fileList.length" |
| | | :default-page-size="20" |
| | | :currentPage="currentIndex" |
| | | :hide-on-single-page="true" |
| | | @current-change="handleCurrentChange" /> |
| | | </div> |
| | | </div> |
| | | </el-card> |
| | |
| | | |
| | | <!-- pdf查看 --> |
| | | <div class="pdf-container" v-show="pdfViewer"> |
| | | <PDFViewer :pdfUrl="'/test.pdf'"></PDFViewer> |
| | | <PDFViewer :pdfUrl="pdfFile"></PDFViewer> |
| | | <div class="close-btn"> |
| | | <el-button type="danger" size="large" circle @click="closeViewer"> |
| | | <template #icon> |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, onMounted } from 'vue'; |
| | | import { ref, onMounted, onBeforeUnmount } from 'vue'; |
| | | import { storeToRefs } from 'pinia'; |
| | | import { Close } from '@element-plus/icons-vue'; |
| | | import NormalHeader from '@/components/NormalHeader/index.vue'; |
| | |
| | | heartBeatData: 'ping' |
| | | }); |
| | | |
| | | const time = ref(null); |
| | | |
| | | |
| | | const fileType = { |
| | | 'img': { |
| | |
| | | handle: (item) => { |
| | | console.log(item); |
| | | imageViewer.value = true; |
| | | sendMessage({ id: userInfo.value.id, command: 'startRecordTime' }); |
| | | imageList.value = [item.contentUrl.url]; |
| | | resendMessage(); |
| | | } |
| | | }, |
| | | 'video': { |
| | | iconPath: '/static/icons/file_type_video.png', |
| | | handle: (item) => { |
| | | console.log(item); |
| | | sendMessage({ id: userInfo.value.id, command: 'startRecordTime' }); |
| | | resendMessage(); |
| | | } |
| | | }, |
| | | 'pdf': { |
| | |
| | | handle: (item) => { |
| | | console.log(item); |
| | | pdfViewer.value = true; |
| | | sendMessage({ id: userInfo.value.id, command: 'startRecordTime' }); |
| | | pdfFile.value = item.contentUrl.url; |
| | | resendMessage(); |
| | | } |
| | | }, |
| | | }; |
| | |
| | | const videoViewer = ref(false); |
| | | |
| | | const imageList = ref([]); |
| | | const pdfFile = ref(''); |
| | | |
| | | const fileList = ref([ |
| | | { |
| | | id: 1, |
| | | name: '测试测试测试', |
| | | url: '/test_question.png', |
| | | date: '2024-12-12', |
| | | class: 'test', |
| | | subject: '测试', |
| | | type: 'img' |
| | | }, |
| | | { |
| | | id: 2, |
| | | name: '测试测试测试', |
| | | url: '', |
| | | date: '2024-12-12', |
| | | class: 'test', |
| | | subject: '测试', |
| | | type: 'video' |
| | | }, |
| | | { |
| | | id: 3, |
| | | name: '测试测试测试', |
| | | url: '/test.pdf', |
| | | date: '2024-12-12', |
| | | class: 'test', |
| | | subject: '测试', |
| | | type: 'pdf' |
| | | } |
| | | ]); |
| | | const fileList = ref([]); |
| | | |
| | | const currentIndex = ref(1); |
| | | |
| | | |
| | | const checkRow = (item) => { |
| | | fileType[item.type] && fileType[item.type].handle(item); |
| | | |
| | | fileType[item.contentType] && fileType[item.contentType].handle(item); |
| | | }; |
| | | |
| | | const closeViewer = () => { |
| | | pdfViewer.value = false; |
| | | imageViewer.value = false; |
| | | videoViewer.value = false; |
| | | sendMessage({ id: userInfo.value.id, command: 'endRecordTime' }); |
| | | clearInterval(time.value); |
| | | }; |
| | | |
| | | const getData = () => { |
| | | loading.value = true; |
| | | getFileList().then(res => { |
| | | |
| | | loading.value = false; |
| | | fileList.value = res.data; |
| | | }).catch(() => { |
| | | loading.value = false; |
| | | }); |
| | | }; |
| | | getData(); |
| | | |
| | | const resendMessage = () => { |
| | | if (time.value) { |
| | | clearInterval(time.value); |
| | | } |
| | | sendMessage({ id: userInfo.value.id, command: 'recordStudyTime' }); |
| | | time.value = setInterval(() => { |
| | | sendMessage({ id: userInfo.value.id, command: 'recordStudyTime' }); |
| | | }, 5000); |
| | | }; |
| | | |
| | | const getIcon = (type) => { |
| | | if (fileType[type]) { |
| | | return fileType[type].iconPath; |
| | | } |
| | | }; |
| | | |
| | | const handleCurrentChange = (val) => { |
| | | getData(); |
| | | } |
| | | |
| | | |
| | | const searchFile = () => { |
| | | getData(); |
| | | } |
| | | |
| | | // -----------------------------------生命周期 |
| | | onMounted(() => { |
| | | // 连接webscoket |
| | | connect(); |
| | | }); |
| | | |
| | | onBeforeUnmount(() => { |
| | | clearInterval(time.value); |
| | | }); |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |