From 54849757852f6ab40eb17afbd03d1d839b60a38d Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Mon, 13 Nov 2023 17:09:15 +0800
Subject: [PATCH] 重复定时和连续执行
---
src/components/MediaPanel.vue | 326 ++++++++++++++++++++++++++++-------------------------
1 files changed, 173 insertions(+), 153 deletions(-)
diff --git a/src/components/MediaPanel.vue b/src/components/MediaPanel.vue
index a20952c..f9e5d7d 100644
--- a/src/components/MediaPanel.vue
+++ b/src/components/MediaPanel.vue
@@ -1,96 +1,98 @@
<template>
- <!-- <div class="header">媒体文件</div>-->
- <!--搜索栏-->
+ <!-- <div class="header">媒体文件</div>-->
+ <!--搜索栏-->
<div class="search-panel-wrapper">
- <div class="search-part">
- <a-range-picker :size="searchPanelOptions.size" :format="searchPanelOptions.dateFormat"
- :valueFormat="searchPanelOptions.valueFormat" v-model:value="timeRangeArr.data"
- @change="dateChange" style="width: 300px"/>
- </div>
+ <div class="search-part">
+ <a-range-picker :size="searchPanelOptions.size" :format="searchPanelOptions.dateFormat"
+ :valueFormat="searchPanelOptions.valueFormat" v-model:value="timeRangeArr.data"
+ @change="dateChange" style="width: 300px"/>
+ </div>
- <div class="search-part">
- <a-select v-model:value="subFileTypeArr" allowClear @change="subFileTypeChange" :options="subFileTypeOptions"
- :maxTagCount="searchPanelOptions.maxTagCount" mode="multiple"
- :size="searchPanelOptions.size" placeholder="所有类型" style="width: 300px">
- </a-select>
- </div>
+ <div class="search-part">
+ <a-select v-model:value="subFileTypeArr" allowClear @change="subFileTypeChange"
+ :options="subFileTypeOptions"
+ :maxTagCount="searchPanelOptions.maxTagCount" mode="multiple"
+ :size="searchPanelOptions.size" placeholder="所有类型" style="width: 300px">
+ </a-select>
+ </div>
- <div class="search-part">
- <a-select v-model:value="payloadArr" allowClear @change="payloadChange" :options="payloadOptions"
- :maxTagCount="searchPanelOptions.maxTagCount" mode="multiple"
- :size="searchPanelOptions.size" placeholder="所有负载" style="width: 300px">
- </a-select>
- </div>
+ <div class="search-part">
+ <a-select v-model:value="payloadArr" allowClear @change="payloadChange" :options="payloadOptions"
+ :maxTagCount="searchPanelOptions.maxTagCount" mode="multiple"
+ :size="searchPanelOptions.size" placeholder="所有负载" style="width: 300px">
+ </a-select>
+ </div>
- <div class="search-part">
- <a-input-search :size="searchPanelOptions.size" v-model:value="searchQuery.name" @change="inputChange"
- placeholder="按文件名称搜索" style="width: 300px"/>
- </div>
+ <div class="search-part">
+ <a-input-search :size="searchPanelOptions.size" v-model:value="searchQuery.name" @change="inputChange"
+ placeholder="按文件名称搜索" style="width: 300px"/>
+ </div>
</div>
<div class="button-wrapper">
- <a-button type="primary" @click="compress">压缩打包</a-button>
+ <a-button type="primary" @click="compress">压缩打包</a-button>
</div>
- <a-spin :spinning="loading" :delay="1000" tip="downloading" size="large">
- <div class="media-panel-wrapper">
- <a-table class="media-table" :columns="columns" :data-source="mediaData.data" row-key="fingerprint" rowKey="file_id" :row-selection="rowSelection"
- :pagination="paginationProp" :scroll="{ x: '100%', y: 600 }" @change="refreshData">
- <template v-for="col in ['name']" #[col]="{text, record}" :key="col">
+ <a-spin :spinning="loading" :delay="1000" tip="加载中" size="large">
+ <div class="media-panel-wrapper">
+ <a-table class="media-table" :columns="columns" :data-source="mediaData.data" row-key="fingerprint"
+ rowKey="file_id" :row-selection="rowSelection"
+ :pagination="paginationProp" :scroll="{ x: '100%', y: 600 }" @change="refreshData">
+ <template v-for="col in ['name']" #[col]="{text, record}" :key="col">
- <div>
- <a-input
- v-if="editableData[record.file_id]"
- v-model:value="editableData[record.file_id]['file_name']"
- style="margin: -5px 0"
- />
- <template v-else>
- <a-tooltip :title="text">
- <a @click="viewFile(record.object_key)">{{ text }}</a>
- </a-tooltip>
- </template>
- </div>
+ <div>
+ <a-input
+ v-if="editableData[record.file_id]"
+ v-model:value="editableData[record.file_id]['file_name']"
+ style="margin: -5px 0"
+ />
+ <template v-else>
+ <a-tooltip :title="text">
+ <a @click="viewFile(record.object_key)">{{ text }}</a>
+ </a-tooltip>
+ </template>
+ </div>
- </template>
- <template #original="{ text }">
- {{ text }}
- </template>
- <template #action="{ record }">
+ </template>
+ <template #original="{ text }">
+ {{ text }}
+ </template>
+ <template #action="{ record }">
- <div class="editable-row-operations">
- <!-- 编辑态操作 -->
- <div v-if="editableData[record.file_id]">
- <a-tooltip title="保存">
- <span @click="save(record)" style="color: #28d445;"><CheckOutlined/></span>
- </a-tooltip>
- <a-tooltip title="取消">
- <span @click="() => delete editableData[record.file_id]" style="color: #e70102;"><CloseOutlined/></span>
- </a-tooltip>
- </div>
- <!-- 非编辑态操作 -->
- <div v-else class="flex-align-center flex-row" style="color: #2d8cf0">
- <a-tooltip title="下载">
- <a class="fz18" @click="downloadMedia(record)">
- <DownloadOutlined/>
- </a>
- </a-tooltip>
+ <div class="editable-row-operations">
+ <!-- 编辑态操作 -->
+ <div v-if="editableData[record.file_id]">
+ <a-tooltip title="保存">
+ <span @click="save(record)" style="color: #28d445;"><CheckOutlined/></span>
+ </a-tooltip>
+ <a-tooltip title="取消">
+ <span @click="() => delete editableData[record.file_id]" style="color: #e70102;"><CloseOutlined/></span>
+ </a-tooltip>
+ </div>
+ <!-- 非编辑态操作 -->
+ <div v-else class="flex-align-center flex-row" style="color: #2d8cf0">
+ <a-tooltip title="下载">
+ <a class="fz18" @click="downloadMedia(record)">
+ <DownloadOutlined/>
+ </a>
+ </a-tooltip>
- <a-tooltip title="编辑">
- <a class="fz18" @click="edit(record)">
- <EditOutlined />
- </a>
- </a-tooltip>
- </div>
- </div>
+ <a-tooltip title="编辑">
+ <a class="fz18" @click="edit(record)">
+ <EditOutlined/>
+ </a>
+ </a-tooltip>
+ </div>
+ </div>
- </template>
- </a-table>
- </div>
+ </template>
+ </a-table>
+ </div>
</a-spin>
<div @click.self="showVideo = false" v-if="showVideo" class="modal">
- <video class="video-js" :id="videoPlayerId"></video>
+ <video class="video-js" :id="videoPlayerId"></video>
</div>
</template>
@@ -121,7 +123,7 @@
const showVideo = ref(false)
const videoPlayerId = ref('videoPlayerId')
// 文件前缀
-const prefix = 'http://dev.jxpskj.com:9000/cloud-bucket'
+const prefix = 'https://dev.jxpskj.com:8026/cloud-bucket'
// 搜索栏配置项
const searchPanelOptions = reactive({
size: 'large',
@@ -129,21 +131,22 @@
dateFormat: 'YYYY-MM-DD',
valueFormat: 'YYYY-MM-DD'
})
+
interface MediaFile {
- fingerprint: string,
- drone: string,
- payload: string,
- is_original: string,
- file_name: string,
- file_path: string,
- create_time: string,
- file_id: string,
- object_key:string
+ fingerprint: string,
+ drone: string,
+ payload: string,
+ is_original: string,
+ file_name: string,
+ file_path: string,
+ create_time: string,
+ file_id: string,
+ object_key: string
}
const subFileTypeOptions = [
- { value: 0, label: '普通图片' },
- { value: 1, label: '全景图' },
+ // { value: 0, label: '普通图片' },
+ // { value: 1, label: '全景图' },
]
const payloadOptions = [
@@ -241,13 +244,16 @@
})
}
-function viewFile (objectKey:string) {
+function viewFile (objectKey: string) {
const ext = objectKey.split('.')[1]
const fileType = getFileType(ext)
let url = ''
if (!objectKey.startsWith('/')) {
url = prefix + '/' + objectKey
+ } else {
+ url = prefix + objectKey
}
+ console.log('文件地址:', url)
if (fileType === 'image') {
viewImage(url)
@@ -256,7 +262,7 @@
}
}
-function getFileType (ext:string) {
+function getFileType (ext: string) {
// 获取类型结果
let result = ''
// fileName无后缀返回 false
@@ -317,23 +323,35 @@
return 'other'
}
-function viewImage (url:string) {
+function viewImage (url: string) {
viewerApi({
images: [url]
})
}
-async function viewVideo (url:string) {
+async function viewVideo (url: string) {
showVideo.value = true
await nextTick()
const player = videojs(videoPlayerId.value, {
- autoplay: true,
- controls: true,
+ autoplay: true, // 自动播放
+ controls: true, // 控件 设置为true,控件才会显示
+ fullscreenToggle: true, // 是否显示全屏按钮
+ playToggle: true, // 是否显示播放按钮
+ progressControl: true, // 是否显示进度条。除了boolean,还可以设置一个ProgressControlOptions对象,更详细的配置进度条。
+ volumePanel: true, // 是否显示音量。除了boolean,还可以设置一个VolumePanelOptions对象,更详细的配置音量组件。
+ pictureInPictureToggle: false, // 是否显示画中画按钮
+ remainingTimeDisplay: true, // 是否显示时长
+
})
player.src(url)
player.on('ended', () => {
showVideo.value = false
+ })
+
+ player.on('error', () => {
+ const error = player.error()
+ console.log('video error:' + error.code + '-' + error.message)
})
}
@@ -347,12 +365,12 @@
const promiseList = [] as any
selectedRow.list.forEach(e => {
const url = prefix + e.object_key
-
const promise = getFile(url, e.file_name)
promiseList.push(promise)
})
Promise.all(promiseList).then(res => {
+ console.log(res, '+++++++++++')
res.forEach(e => {
zip.file(e.name, e.data, { base64: true })
})
@@ -366,7 +384,7 @@
}
// 获取文件的blob
-function getFile (url:string, name:string) {
+function getFile (url: string, name: string) {
return new Promise((resolve, reject) => {
axios({
method: 'get',
@@ -376,10 +394,6 @@
.then((response) => {
const ext = url.split('.')[1]
// 若文件名不以后缀结尾,则手动添加后缀
- if (!name.endsWith(ext)) {
- name = name + '.' + ext
- }
-
resolve({
name: name,
data: response.data
@@ -427,86 +441,92 @@
function downloadMedia (media: MediaFile) {
loading.value = true
- downloadMediaFile(workspaceId, media.file_id).then(res => {
- if (!res) {
- return
- }
-
- const data = new Blob([res])
- downloadFile(data, media.file_name)
+ const url = prefix + '/' + media.object_key
+ getFile(url, media.file_name).then(res => {
+ downloadFile(res.data, res.name)
loading.value = false
- }).finally(() => {
-
})
+
+ // downloadMediaFile(workspaceId, media.file_id).then(res => {
+ // if (!res) {
+ // return
+ // }
+ //
+ // const data = new Blob([url])
+ // downloadFile(data, media.file_name)
+ // loading.value = false
+ // }).finally(() => {
+ // loading.value = false
+ // })
}
</script>
<style lang="scss" scoped>
.media-panel-wrapper {
- width: 100%;
- padding: 16px;
+ width: 100%;
+ padding: 16px;
- .media-table {
- background: #fff;
- margin-top: 10px;
- }
+ .media-table {
+ background: #fff;
+ margin-top: 10px;
+ }
- .action-area {
- color: $primary;
- cursor: pointer;
- }
+ .action-area {
+ color: $primary;
+ cursor: pointer;
+ }
}
.header {
- width: 100%;
- height: 60px;
- background: #fff;
- padding: 16px;
- font-size: 20px;
- font-weight: bold;
- text-align: start;
- color: #000;
+ width: 100%;
+ height: 60px;
+ background: #fff;
+ padding: 16px;
+ font-size: 20px;
+ font-weight: bold;
+ text-align: start;
+ color: #000;
}
.search-panel-wrapper {
- height: 85px;
- background: #ffffff;
- padding: 0 20px;
- display: flex;
- align-items: center;
+ height: 85px;
+ background: #ffffff;
+ padding: 0 20px;
+ display: flex;
+ align-items: center;
- .search-part {
- margin-right: 10px;
- }
+ .search-part {
+ margin-right: 10px;
+ }
}
-.button-wrapper{
- background: #ffffff;
- padding-left: 20px;
+.button-wrapper {
+ background: #ffffff;
+ padding-left: 20px;
}
.editable-row-operations {
- div > span {
- margin-right: 10px;
- }
+ div > span {
+ margin-right: 10px;
+ }
}
-.modal{
- position: absolute;
- top: 0;
- left: 0;
- bottom: 0;
- right: 0;
- background-color: rgba(0, 0, 0, 0.5);
- display: flex;
- align-items: center;
- justify-content: center;
+.modal {
+ position: absolute;
+ top: 0;
+ left: 0;
+ bottom: 0;
+ right: 0;
+ background-color: rgba(0, 0, 0, 0.5);
+ display: flex;
+ align-items: center;
+ justify-content: center;
- #videoPlayerId{
- width: 70%;
- height: 80%;
- }
+ #videoPlayerId {
+ width: 70%;
+ height: 80%;
+ }
}
</style>
--
Gitblit v1.9.3