Browse Source

视频

master
zhang_li 12 months ago
parent
commit
d875196da8
  1. 4
      .env.development
  2. 3
      package.json
  3. 94
      src/components/UploadFile/src/Preview.vue
  4. 9
      src/components/UploadFile/src/UploadFile.vue
  5. 5
      src/main.ts
  6. 3
      src/utils/globalConst.js
  7. 11
      src/views/spc/detectiontemplate/templateItemDetails.data.ts

4
.env.development

@ -4,11 +4,11 @@ NODE_ENV=development
VITE_DEV=false VITE_DEV=false
# 请求路径 # 请求路径
VITE_BASE_URL='http://localhost:12080' VITE_BASE_URL='http://192.168.0.165:12080'
# 上传路径 # 上传路径
#VITE_UPLOAD_URL='http://localhost:12080/admin-api/spc/template-item-details/upload' #VITE_UPLOAD_URL='http://localhost:12080/admin-api/spc/template-item-details/upload'
VITE_UPLOAD_URL='http://localhost:12080/admin-api/infra/file/upload' VITE_UPLOAD_URL='http://192.168.0.165:12080/admin-api/infra/file/upload'
# 接口前缀 # 接口前缀
VITE_API_BASEPATH=/dev-api VITE_API_BASEPATH=/dev-api

3
package.json

@ -30,6 +30,7 @@
"crypto-js": "^4.1.1", "crypto-js": "^4.1.1",
"dayjs": "^1.11.10", "dayjs": "^1.11.10",
"diagram-js": "^12.3.0", "diagram-js": "^12.3.0",
"docx-preview": "^0.1.4",
"echarts": "^5.4.3", "echarts": "^5.4.3",
"echarts-wordcloud": "^2.1.0", "echarts-wordcloud": "^2.1.0",
"element-plus": "2.3.14", "element-plus": "2.3.14",
@ -37,6 +38,7 @@
"highlight.js": "^11.8.0", "highlight.js": "^11.8.0",
"intro.js": "^7.2.0", "intro.js": "^7.2.0",
"jsencrypt": "^3.3.2", "jsencrypt": "^3.3.2",
"jszip": "^3.10.1",
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"min-dash": "^4.1.1", "min-dash": "^4.1.1",
"mitt": "^3.0.1", "mitt": "^3.0.1",
@ -54,6 +56,7 @@
"vue-router": "^4.2.5", "vue-router": "^4.2.5",
"vue-types": "^5.1.1", "vue-types": "^5.1.1",
"vue-video-player": "^5.0.1", "vue-video-player": "^5.0.1",
"vue3-video-play": "^1.3.2",
"vuedraggable": "^4.1.0", "vuedraggable": "^4.1.0",
"web-storage-cache": "^1.1.1", "web-storage-cache": "^1.1.1",
"xml-js": "^1.6.11" "xml-js": "^1.6.11"

94
src/components/UploadFile/src/Preview.vue

@ -1,10 +1,15 @@
<template> <template>
<div class="preview"> <div class="preview">
<div class="file" v-for="(item, index) in fileList" :key="index" size="18"> <div class="file" v-for="(item, index) in fileList" :key="index" size="18" >
<Icon icon="fa:file-word-o" class="cursor-pointer mr-6px color-#409eff" v-if="isWord(item)"/>
<Icon icon="fa:file-image-o" class="cursor-pointer mr-6px color-#409eff" v-if="isImg(item)"/>
<Icon icon="ep:video-camera" class="cursor-pointer mr-6px color-#409eff" v-if="isVideo(item)"/>
<div class="name" @click="preview(item)">{{ item.name }}</div> <div class="name" @click="preview(item)">{{ item.name }}</div>
<Icon icon="ep:delete" class="cursor-pointer" /> <Icon icon="ep:close" class="cursor-pointer" @click="deleteFile(item, index)" />
<VueVideoPlayer />
</div> </div>
<el-dialog v-model="dialogTableVisible" title="" width="80%"> <el-dialog v-model="dialogTableVisible" title="" min-width="80%">
<div class="dialog"> <div class="dialog">
<Icon <Icon
icon="ep:close" icon="ep:close"
@ -14,7 +19,13 @@
@click="dialogTableVisible = false" @click="dialogTableVisible = false"
/> />
<img :src="chooseItem.url" alt="" v-if="isImg(chooseItem)" /> <img :src="chooseItem.url" alt="" v-if="isImg(chooseItem)" />
<!-- <video-player :options="playerOptions"/> --> <video controls muted loop width="80%" v-if="isVideo(chooseItem)">
<source :src="chooseItem.url" />
</video>
<!-- <iframe frameborder="0"
:src="'https://view.officeapps.live.com/op/view.aspx?src=' +chooseItem.url" width='100%' height="600" v-if="isWord(chooseItem)">
</iframe>] -->
<!-- <div ref="word" class="childRef" v-if="isWord(chooseItem)"></div> -->
</div> </div>
</el-dialog> </el-dialog>
</div> </div>
@ -23,59 +34,74 @@
import { import {
FILE_IMG_MAP, FILE_IMG_MAP,
FILE_TYPE_LIST, FILE_TYPE_LIST,
FILE_WORD_TYPE_LIST,
IMG_TYPE_LIST, IMG_TYPE_LIST,
VIDEO_TYPE_LIST, VIDEO_TYPE_LIST,
MUSIC_TYPE_LIST MUSIC_TYPE_LIST
} from '@/utils/globalConst.js' } from '@/utils/globalConst.js'
// import axios from 'axios'
// import { renderAsync } from 'docx-preview'
// import request from '@/config/axios'
// import JSZip from 'jszip'
// let docx = import.meta.glob('docx-preview');
const props = defineProps({ const props = defineProps({
fileList: { fileList: {
type: Array, type: Array,
required: true required: true
} }
}) })
console.log(props.fileList)
const dialogTableVisible = ref(false) const dialogTableVisible = ref(false)
const chooseItem = ref() const chooseItem = ref()
const preview = (item) => { let word = ref(null)
const preview = async (item) => {
if (isImg(item) || isVideo(item)) {
chooseItem.value = item chooseItem.value = item
console.log(chooseItem.value)
dialogTableVisible.value = true dialogTableVisible.value = true
} else {
window.open(item.url)
}
// request.get({
// url: chooseItem.value.url,
// responseType: 'blob',
// needLoading: true,
// }).then((res) => {
// nextTick(() => {
// renderAsync(res, word.value)
// })
// })
} }
const isImg = (item) => { const isImg = (item) => {
// console.log('item',item)
const lastDotIndex = item.name.lastIndexOf('.') const lastDotIndex = item.name.lastIndexOf('.')
const result = item.name.substring(lastDotIndex + 1) const result = item.name.substring(lastDotIndex + 1)
console.log(11)
console.log(result)
console.log(IMG_TYPE_LIST)
console.log(22)
return IMG_TYPE_LIST.includes(result) return IMG_TYPE_LIST.includes(result)
} }
const isVideo = (item) => { const isVideo = (item) => {
return VIDEO_TYPE_LIST.includes(item.name) const lastDotIndex = item.name.lastIndexOf('.')
const result = item.name.substring(lastDotIndex + 1)
return VIDEO_TYPE_LIST.includes(result)
} }
const playerOptions = ref({ const isWord = (item) => {
playbackRates: [0.5, 1.0, 1.5, 2.0], // const lastDotIndex = item.name.lastIndexOf('.')
autoplay: false, // true, const result = item.name.substring(lastDotIndex + 1)
muted: false, // return FILE_WORD_TYPE_LIST.includes(result)
loop: false, // }
preload: 'auto', // <video>auto, const deleteFile = (item, index) => {
language: 'zh-CN', emit('deleteFile', item, index)
aspectRatio: '16:9', // 使 - "16:9""4:3" }
fluid: true, // trueVideo.js player //
sources: [{ const emit = defineEmits(['deleteFile'])
// type: 'video/mp4', //
src: 'https://tx.dogevideo.com/vcloud/17/v/20190424/1556036075_818c4125ec9c8cbc7a7a8a7cc1601512/1037/7d515b22c4958598c0fbd1e6290a5ca5.mp4?vkey=FFA4A7&tkey=16492405502eb7beec64&auth_key=1649254950-Ubt0D7z0CUeXs871-0-432e03b97493872cf0bf1f8a37d812db' // url
}],
poster: '', //
notSupportedMessage: '此视频暂无法播放,请稍后再试', // Video.js
controlBar: {
timeDivider: true, //
durationDisplay: true, //
remainingTimeDisplay: false, //
fullscreenToggle: true //
}
})
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.file { .file {
display: flex; display: flex;
align-items: center; align-items: center;
cursor: pointer;
.name { .name {
flex: 1; flex: 1;
overflow: hidden; overflow: hidden;
@ -83,6 +109,11 @@ const playerOptions = ref({
white-space: nowrap; white-space: nowrap;
width: 140px; width: 140px;
} }
&:hover{
.name {
color: #409eff;
}
}
} }
img { img {
width: 100%; width: 100%;
@ -95,6 +126,9 @@ img {
} }
.dialog { .dialog {
position: relative; position: relative;
display: flex;
align-items: center;
justify-content: center;
} }
.close { .close {
position: absolute; position: absolute;

9
src/components/UploadFile/src/UploadFile.vue

@ -29,7 +29,7 @@
<div style="font-size: 8px;line-height: initial;"> <div style="font-size: 8px;line-height: initial;">
格式为 <b style="color: #f56c6c">{{ fileType.join(',') }}</b> 的文件 格式为 <b style="color: #f56c6c">{{ fileType.join(',') }}</b> 的文件
</div> </div>
<Preview :fileList="fileList" v-if="!isShowFileList"/> <Preview :fileList="fileList" v-if="!isShowFileList" @deleteFile="deleteFile"/>
</template> </template>
<template v-if="!isShowFile" #file > <template v-if="!isShowFile" #file >
<div> <div>
@ -65,10 +65,10 @@ const props = defineProps({
autoUpload: propTypes.bool.def(true), // autoUpload: propTypes.bool.def(true), //
isShowTip: propTypes.bool.def(true), // isShowTip: propTypes.bool.def(true), //
isShowFile: propTypes.bool.def(true), // isShowFile: propTypes.bool.def(true), //
isShowFileList: propTypes.bool.def(false), // isShowFileList: propTypes.bool.def(true), //
}) })
console.log('props.upData',props.upData) console.log('props.upData',props.fileType)
// ========== ========== // ========== ==========
const valueRef = ref(props.modelValue) const valueRef = ref(props.modelValue)
const uploadRef = ref<UploadInstance>() const uploadRef = ref<UploadInstance>()
@ -154,6 +154,9 @@ const listToString = (list: UploadUserFile[], separator?: string) => {
} }
return strs != '' ? strs.substr(0, strs.length - 1) : '' return strs != '' ? strs.substr(0, strs.length - 1) : ''
} }
const deleteFile=(item,index)=>{
fileList.value.splice(index,1)
}
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.upload-file-uploader { .upload-file-uploader {

5
src/main.ts

@ -49,7 +49,8 @@ import VueVideoPlayer from 'vue-video-player/src'
import 'video.js/dist/video-js.css' import 'video.js/dist/video-js.css'
import 'vue-video-player/src/custom-theme.css' import 'vue-video-player/src/custom-theme.css'
// import vue3videoPlay from 'vue3-video-play' // 引入组件
// import 'vue3-video-play/dist/style.css' // 引入css
@ -74,7 +75,7 @@ const setupAll = async () => {
await router.isReady() await router.isReady()
app.use(VueDOMPurifyHTML) app.use(VueDOMPurifyHTML)
// app.use(vue3videoPlay)
app.mount('#app') app.mount('#app')
app.config.warnHandler = () => null; app.config.warnHandler = () => null;
} }

3
src/utils/globalConst.js

@ -87,4 +87,5 @@ export const FILE_TYPE_LIST = [
export const IMG_TYPE_LIST = ["bmp", "jpg", "png", "tif", "gif", "jpeg"] export const IMG_TYPE_LIST = ["bmp", "jpg", "png", "tif", "gif", "jpeg"]
export const VIDEO_TYPE_LIST = ["avi", "mp4", "mpg", "mov", "swf", "flv", "webm", "ogg", "mkv", "ts", "wmv", "vob", "mxf", "rm"] export const VIDEO_TYPE_LIST = ["avi", "mp4", "mpg", "mov", "swf", "flv", "webm", "ogg", "mkv", "ts", "wmv", "vob", "mxf", "rm"]
export const MUSIC_TYPE_LIST = ["wav", "aif", "au", "mp3", "ram", "wma", "mmf", "amr", "aac", "flac"] export const MUSIC_TYPE_LIST = ["wav", "aif", "au", "mp3", "ram", "wma", "mmf", "amr", "aac", "flac"]
// 可以识别的文件类型
export const FILE_WORD_TYPE_LIST = ['docx','doc','ppt','pptx','xls','xlsx','pdf','txt']

11
src/views/spc/detectiontemplate/templateItemDetails.data.ts

@ -109,13 +109,14 @@ export const TemplateItemDetails = useCrudSchemas(reactive<CrudSchema[]>([
form:{ form:{
component:'UploadFile', component:'UploadFile',
componentProps:{ componentProps:{
fileType:['image/jpeg', 'image/png', 'image/gif','video/mp4','video/webm'], fileType:['image/jpeg', 'image/png', 'image/gif','video/mp4','video/webm','doc','docx', 'xls', 'ppt', 'txt', 'pdf'],
fileSize:20, fileSize:20,
limit:1, limit:1,
upData:{ upData:{
tableId:0,tableName:"detection_template_item_details" tableId:0,tableName:"detection_template_item_details"
}, },
modelValue:[] modelValue:[],
isShowFileList:false
} }
} }
}, },
@ -133,7 +134,8 @@ export const TemplateItemDetails = useCrudSchemas(reactive<CrudSchema[]>([
limit:1, limit:1,
upData:{ upData:{
tableId:0,tableName:"detection_template_item_details" tableId:0,tableName:"detection_template_item_details"
} },
isShowFileList:false
} }
} }
}, },
@ -151,7 +153,8 @@ export const TemplateItemDetails = useCrudSchemas(reactive<CrudSchema[]>([
limit:1, limit:1,
upData:{ upData:{
tableId:0,tableName:"detection_template_item_details" tableId:0,tableName:"detection_template_item_details"
} },
isShowFileList:false
} }
} }
}, },

Loading…
Cancel
Save