VideoDetails.vue 12 KB

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