VideoDetails.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  1. <template>
  2. <div>
  3. <h1>{{ resName }}</h1>
  4. <div class="user-info-container">
  5. <a-card :bordered="false" class="boxShadow cardBox mr-3 flex-3">
  6. <!-- <div style="height: 600px">-->
  7. <!-- <div v-if="isImageFile(resSrc)" style="width: 100%; height: 100%">-->
  8. <!-- <a-image width="100%" height="100%" :src="fileSrc(resSrc)" :preview="true" />-->
  9. <!-- </div>-->
  10. <!-- <div v-if="isVideoFile(resSrc)" style="width: 100%; height: 100%">-->
  11. <!-- <video :src="fileSrc(resSrc)" controls style="width: 100%; height: 100%" />-->
  12. <!-- </div>-->
  13. <!-- <div v-if="isDocumentFile(resSrc)" style="width: 100%; height: 100%">-->
  14. <!-- <FilePreviewer v-if="resSrc" :fileUrl="fileSrc(resSrc)" :fileName="resName" :fileType="fileType" />-->
  15. <!-- </div>-->
  16. <!-- <div class="imgBox" v-if="itemData.id && unknownFile">-->
  17. <!-- <a-image height="100%" :src="unknownFile" :preview="false" />-->
  18. <!-- </div>-->
  19. <!-- </div>-->
  20. <div class="video-info" style="width: 850px">
  21. <div
  22. v-if="['jpg', 'bmp', 'png', 'jpeg'].includes(videoFormat)"
  23. style="width: 850px; height: 350px"
  24. >
  25. <!-- <img :src="imgs + itemData.coverImagePath" style="width: 100%; height: 100%" /> -->
  26. <!-- <img :v-lazy="imagess" style="width: 100%; height: 100%" /> -->
  27. <a-image width="850px" height="350px" :src="resSrc" :preview="true"/>
  28. <!-- <image :src="resSrc" style="object-fit: cover" /> -->
  29. </div>
  30. <!-- "wmv","avi","flv","mpeg","mpg","rmvb","mov","mkv" -->
  31. <div
  32. v-else-if="['mkv', 'mp4', 'wmv', 'avi', 'flv', 'mpeg', 'mpg', 'rmvb', 'mov'].includes(videoFormat)"
  33. style="width: 850px; height: 350px"
  34. >
  35. <video :src="resSrc" controls style="width: 100%; height: 100%"/>
  36. </div>
  37. <!-- "doc","docx","ppt","pptx","xls","xlsx" -->
  38. <div
  39. v-else-if="['docx', 'doc', 'ppt', 'pptx', 'xls', 'xlsx', 'pdf'].includes(videoFormat)"
  40. style="width: 850px; height: 350px"
  41. >
  42. <!-- <PDF :src="resSrc" :width="850" :height="350" /> -->
  43. <FilePreviewer :fileUrl="resSrc" :fileName="resName" :fileType="fileType"/>
  44. <!-- <a-image width="200px" height="220px" :src="pdfRes" :preview="false" @click="handleDownload(resSrc)" /> -->
  45. <!-- <a-button type="primary" @click="handleDownload(resSrc)">去预览</a-button> -->
  46. </div>
  47. <div
  48. v-else
  49. style="width: 850px; height: 350px; border: 1px solid #dfe2e5; display: flex; justify-content: center; align-items: center"
  50. >
  51. <span style="display: block">本资源格式不可预览</span>
  52. <!-- <PDF :src="resSrc" :width="850" :height="350" /> -->
  53. <!-- <a-image width="200px" height="220px" :src="pdfRes" :preview="false" @click="handleDownload(resSrc)" /> -->
  54. <!-- <a-button type="primary" @click="handleDownload(resSrc)">去预览</a-button> -->
  55. </div>
  56. <div class="imgBox" v-if="itemData.id && unknownFile">
  57. <a-image height="100%" :src="unknownFile" :preview="false"/>
  58. </div>
  59. <div style="height: 20px"></div>
  60. <!-- 用户信息部分 -->
  61. <div class="user-info" style="display: flex; flex-direction: column">
  62. <div style="display: flex; align-items: center; justify-content: space-between; width: 100%">
  63. <div style="display: flex; align-items: center">
  64. <div class="user-avatar"></div>
  65. <div class="user-details">
  66. <div class="user-name">{{ itemData.resourceCreaterUserName }}</div>
  67. <div class="publish-time">{{ itemData.uploadTime }}</div>
  68. </div>
  69. </div>
  70. <div style="display: flex; align-items: center" v-if="!isState">
  71. <div class="metrics">
  72. <div class="metric-item">
  73. <span>{{ itemData.viewCount }}</span>
  74. <span>播放量</span>
  75. </div>
  76. <div class="liene"></div>
  77. <div class="metric-item">
  78. <span>{{ talkNum }}</span>
  79. <span>评论</span>
  80. </div>
  81. <div class="liene"></div>
  82. <div class="metric-item">
  83. <span>{{ collectNum }}</span>
  84. <span>收藏</span>
  85. </div>
  86. </div>
  87. <div style="width: 10px"></div>
  88. <div class="actions">
  89. <div
  90. style="display: flex; align-items: center; cursor: pointer; margin-right: 5px"
  91. @click="handlerShareDialog"
  92. >
  93. <ExportOutlined/>
  94. <div style="width: 10px"></div>
  95. <button class="share-btn">分享资源</button>
  96. </div>
  97. <div style="display: flex; align-items: center; cursor: pointer"
  98. @click="handlerCollection">
  99. <StarOutlined v-if="starTag == false"/>
  100. <StarFilled v-if="starTag == true"/>
  101. <div style="width: 10px"></div>
  102. <button class="favorite-btn">收藏资源</button>
  103. </div>
  104. </div>
  105. </div>
  106. </div>
  107. </div>
  108. </div>
  109. </a-card>
  110. <a-card class="flex-1">
  111. <div class="resInfo">
  112. <div class="titleBox">
  113. <span style="display: block; font-weight: bold; font-size: 20px">资源信息</span>
  114. </div>
  115. <div class="lableBox">
  116. <span style="display: block; font-weight: bold; font-size: 18px">{{ resName }}</span>
  117. </div>
  118. <div class="lableBox">
  119. <span class="lableName">所属院系: </span>
  120. <span class="lableVal">{{ department }}</span>
  121. </div>
  122. <div class="lableBox">
  123. <span class="lableName">资源类型: </span>
  124. <span class="lableVal">{{ courseType }}</span>
  125. </div>
  126. <div class="lableBox">
  127. <span class="lableName">资源格式: </span>
  128. <span class="lableVal">{{ videoFormat }}</span>
  129. </div>
  130. <div class="lableBox">
  131. <span class="lableName">容量大小: </span>
  132. <span class="lableVal">{{ videoSize }}</span>
  133. </div>
  134. <div class="lableBox">
  135. <span class="lableName">发布时间: </span>
  136. <span class="lableVal">{{ releaseTime }}</span>
  137. </div>
  138. <div class="lableBox">
  139. <span class="lableName">资源描述: </span>
  140. <span class="lableVal">{{ itemData.resourceDesc }}</span>
  141. </div>
  142. <span>资源标签</span>
  143. <div style="display: flex; width: 100%; flex-wrap: wrap">
  144. <a-tag style="margin-top: 5px" v-for="tag in tags" :key="tag">{{ tag }}</a-tag>
  145. </div>
  146. </div>
  147. </a-card>
  148. </div>
  149. <ShareDialog ref="ShareDialogRef"></ShareDialog>
  150. </div>
  151. </template>
  152. <script setup>
  153. import {ref} from 'vue'
  154. import {Tag, Typography, Space, message} from 'ant-design-vue'
  155. import ShareDialog from './ShareDialog.vue'
  156. import {addViewCount, detail, add, cancel, queryList, resourcecentreDetail, getShareLink} from '@/api/portal'
  157. import {useRoute, useRouter} from 'vue-router'
  158. import sysConfig from '@/config/index'
  159. import pdfRes from '@/assets/images/pdf.png'
  160. import FilePreviewer from './FilePreviewer.vue'
  161. import EventBus from '@/utils/EventBus'
  162. import tool from '@/utils/tool'
  163. import {isVideoFile, isImageFile, isDocumentFile} from '@/utils/fileUtil'
  164. const route = useRoute()
  165. const router = useRouter()
  166. const props = defineProps({
  167. isState: {
  168. type: Number,
  169. default: () => null
  170. }
  171. })
  172. const itemData = ref({})
  173. const starTag = ref(false)
  174. const ShareDialogRef = ref(null)
  175. const resSrc = ref('')
  176. const fileType = ref('')
  177. const resName = ref('资源名称')
  178. const teacherName = ref('王某某')
  179. const department = ref('学院本级-航空机务教研室-三级架构名')
  180. const major = ref('初级飞行训练')
  181. const courseType = ref('必修')
  182. const videoFormat = ref('MP4')
  183. const videoDuration = ref('59:34')
  184. const videoSize = ref('598M')
  185. const releaseTime = ref('2025-10-01 11:33:59')
  186. const talkNum = ref(0)
  187. const collectNum = ref(0)
  188. const tags = ref(['标签名称1', '标签名称2', '标签名称3', '标签名称4', '标签名称5'])
  189. const emit = defineEmits(['selectTab', 'onGetPageCommentNew'])
  190. const listUnpublishedView = ref(null)
  191. const handleDownload = (src) => {
  192. window.open(src)
  193. }
  194. const handlerShareDialog = () => {
  195. getShareLink({id: route.query.id})
  196. .then((res) => {
  197. if (res.code == 200) {
  198. ShareDialogRef.value.open(res.data.shareLink)
  199. }
  200. })
  201. .catch((err) => {
  202. })
  203. }
  204. const handlerCollection = async () => {
  205. const id = route.query.id
  206. if (id != undefined && id != '') {
  207. if (starTag.value == true) {
  208. await cancel({resourceId: id})
  209. message.success('取消收藏')
  210. upDataDetailsNum()
  211. } else {
  212. await add({resourceId: id})
  213. message.success('收藏成功')
  214. upDataDetailsNum()
  215. }
  216. queryList({resourceId: id})
  217. .then((ress) => {
  218. if (ress.data == true) {
  219. starTag.value = true
  220. } else {
  221. starTag.value = false
  222. }
  223. })
  224. .catch((err) => {
  225. console.log(err)
  226. })
  227. }
  228. }
  229. const setData = (data) => {
  230. itemData.value = data
  231. }
  232. const fileSrc = computed(() => (e) => sysConfig.FILE_URL + e)
  233. const imageUrl = new URL(`@/assets/images/fileImg/file.png`, import.meta.url).href
  234. const unknownFile = computed((e) => {
  235. if (!isImageFile(resSrc.value) && !isVideoFile(resSrc.value) && !isDocumentFile(resSrc.value)) {
  236. return imageUrl
  237. }
  238. })
  239. const getData = (item) => {
  240. detail({id: item.id})
  241. .then((res) => {
  242. if (res.code == 200) {
  243. itemData.value = res.data
  244. courseType.value = itemData.value.resourceALLTypeName.split(',').join('/')
  245. department.value = itemData.value.collegeAllIdName.split(',').join('/')
  246. teacherName.value = itemData.value.resourceCreaterUserName
  247. resName.value = itemData.value.fileName
  248. videoFormat.value = itemData.value.suffix
  249. releaseTime.value = itemData.value.uploadTime
  250. videoSize.value = itemData.value.FILESIZE ? itemData.value.FILESIZE + 'b' : ''
  251. tags.value = []
  252. itemData.value.keywordList.forEach((item) => {
  253. tags.value.push(item.wordName)
  254. })
  255. resSrc.value = itemData.value.priviewFileUrl
  256. fileType.value = itemData.value.suffix
  257. emit('onGetPageCommentNew', {
  258. resourceType: itemData.value.resourceType,
  259. resourceTwoType: itemData.value.resourceTwoType
  260. })
  261. const isDump = route.query.isDump
  262. const id = route.query.id
  263. const resourceInfo = itemData.value
  264. if (isDump == 1) {
  265. coursestudentburialpoint({
  266. userFileId: resourceInfo.id, //文件资源id
  267. fileName: resourceInfo.fileName, //文件名称
  268. fileId: resourceInfo.fileId, //文件id
  269. filePath: resourceInfo.fileUrl, //文件路经
  270. funcType: '3', //3
  271. type: '5', //5
  272. resourceRecord: id //资源记录id
  273. })
  274. }
  275. }
  276. })
  277. .catch((err) => {
  278. })
  279. }
  280. const upDataList = (item) => {
  281. resourcecentreDetail({id: item.id})
  282. .then((res) => {
  283. if (res.code == 200) {
  284. talkNum.value = res.data.commentNum
  285. collectNum.value = res.data.collectNum
  286. }
  287. })
  288. .catch((err) => {
  289. })
  290. }
  291. const fetchData = () => {
  292. const id = route.query.id
  293. if (id != undefined && id != '') {
  294. queryList({resourceId: id})
  295. .then((res) => {
  296. if (res.data == true) {
  297. starTag.value = true
  298. } else {
  299. starTag.value = false
  300. }
  301. })
  302. .catch((err) => {
  303. console.log(err)
  304. })
  305. getData({id: id})
  306. upDataList({id: id})
  307. }
  308. }
  309. watch(
  310. () => route,
  311. (newRoute) => {
  312. fetchData() // 手动刷新数据的方法
  313. },
  314. {deep: true, immediate: true}
  315. )
  316. onMounted(() => {
  317. fetchData()
  318. })
  319. const upDataDetailsNum = () => {
  320. const id = route.query.id
  321. if (id != undefined && id != '') {
  322. upDataList({id: id})
  323. }
  324. }
  325. const openResourceDetailsInner = (data) => {
  326. router.push({
  327. path: '/student/resourceDetails',
  328. query: {
  329. id: data.id,
  330. t: new Date().getTime()
  331. }
  332. })
  333. }
  334. defineExpose({
  335. setData
  336. })
  337. EventBus.off('upDataDetailsNum', upDataDetailsNum)
  338. EventBus.on('upDataDetailsNum', upDataDetailsNum)
  339. EventBus.off('openResourceDetailsInner', openResourceDetailsInner)
  340. EventBus.on('openResourceDetailsInner', openResourceDetailsInner)
  341. </script>
  342. <style scoped>
  343. .tab-switcher {
  344. display: flex;
  345. border-radius: 20px;
  346. border: 1px solid #1e90ff;
  347. overflow: hidden;
  348. }
  349. .tab-switcher div {
  350. padding: 2px 20px;
  351. background-color: #f5f5f5;
  352. cursor: pointer;
  353. }
  354. .tab-switcher div.active {
  355. background-color: #1e90ff;
  356. color: white;
  357. }
  358. .user-info {
  359. display: flex;
  360. align-items: center;
  361. width: 100%;
  362. padding: 20px;
  363. }
  364. .resource-container {
  365. width: 100%;
  366. margin: 0 auto;
  367. padding: 20px;
  368. border: 1px solid #dfe2e5;
  369. }
  370. .user-avatar {
  371. width: 40px;
  372. height: 40px;
  373. background: #1e90ff;
  374. border-radius: 50%;
  375. margin-right: 10px;
  376. }
  377. .user-details {
  378. flex: 1;
  379. }
  380. .user-name {
  381. font-size: 13px;
  382. font-weight: bold;
  383. }
  384. .publish-time {
  385. font-size: 12px;
  386. color: #999;
  387. margin-top: 5px;
  388. }
  389. .metrics {
  390. display: flex;
  391. align-items: center;
  392. justify-content: center;
  393. }
  394. .metric-item {
  395. display: flex;
  396. flex-direction: column;
  397. align-items: center;
  398. padding-left: 10px;
  399. padding-right: 10px;
  400. }
  401. .metric-item span:first-child {
  402. font-size: 18px;
  403. font-weight: bold;
  404. }
  405. .metric-item span:last-child {
  406. font-size: 12px;
  407. color: #666;
  408. }
  409. .actions {
  410. display: flex;
  411. }
  412. .share-btn,
  413. .favorite-btn {
  414. background-color: transparent;
  415. border: none;
  416. cursor: pointer;
  417. }
  418. .course-info {
  419. margin-top: 20px;
  420. line-height: 1.6;
  421. display: flex;
  422. width: 100%;
  423. }
  424. .liene {
  425. height: 35px;
  426. width: 1px;
  427. background: #00000018;
  428. }
  429. .resource-container {
  430. width: 100%;
  431. margin: 0 auto;
  432. padding: 20px;
  433. border: 1px solid #dfe2e5;
  434. }
  435. h1 {
  436. margin-bottom: 20px;
  437. }
  438. .ant-descriptions {
  439. margin-top: 20px;
  440. }
  441. .ant-typography-title {
  442. margin-top: 20px;
  443. }
  444. .ant-typography-paragraph {
  445. margin-top: 10px;
  446. }
  447. .ant-space {
  448. margin-top: 10px;
  449. }
  450. .video-info {
  451. height: 100%; /* 确保填满容器高度 */
  452. flex: 1;
  453. }
  454. .user-info-container {
  455. display: flex;
  456. align-items: stretch;
  457. }
  458. .resInfoTitile {
  459. width: 5px;
  460. height: 20px;
  461. background-color: #1e90ff;
  462. margin-right: 5px;
  463. }
  464. .tallList {
  465. display: flex;
  466. flex-direction: column;
  467. width: 100%;
  468. height: 200px;
  469. border: 1px solid #dfe2e5;
  470. padding: 20px;
  471. margin-top: 10px;
  472. }
  473. .tallListInfo {
  474. color: rgba(0, 0, 0, 0.116);
  475. font-size: 12px;
  476. }
  477. .titleBox {
  478. display: flex;
  479. align-items: center;
  480. }
  481. .lableBox {
  482. display: flex;
  483. align-items: center;
  484. margin: 16px 0;
  485. }
  486. .lableName {
  487. font-weight: bold;
  488. margin-right: 10px;
  489. }
  490. .lableVal {
  491. display: block;
  492. width: 200px;
  493. margin-left: 6px;
  494. }
  495. .boxShadow {
  496. border: 1px solid rgba(0, 0, 0, 0.04);
  497. border-radius: 4px;
  498. }
  499. :deep(.cardBox .ant-card-body) {
  500. padding: 0;
  501. }
  502. .flex-3 {
  503. flex: 3;
  504. }
  505. .flex-1 {
  506. flex: 1;
  507. }
  508. .imgBox {
  509. height: 100%;
  510. display: flex;
  511. justify-content: center;
  512. align-items: center;
  513. }
  514. </style>