修复视频文件报错
parent
2d5a73478f
commit
7ab401f0a4
|
@ -14,7 +14,12 @@
|
||||||
@submit.prevent="fnResetPagination"
|
@submit.prevent="fnResetPagination"
|
||||||
>
|
>
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="8">
|
<el-col :span="6">
|
||||||
|
<el-form-item label="监测节点名称" prop="KEYWORDS">
|
||||||
|
<el-input v-model="searchForm.KEYWORDS" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="6">
|
||||||
<el-form-item label="开始时间" prop="START_TIME">
|
<el-form-item label="开始时间" prop="START_TIME">
|
||||||
<el-date-picker
|
<el-date-picker
|
||||||
v-model="searchForm.START_TIME"
|
v-model="searchForm.START_TIME"
|
||||||
|
@ -24,8 +29,8 @@
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="8">
|
<el-col :span="6">
|
||||||
<el-form-item label="结束时间" prop="START_TIME">
|
<el-form-item label="结束时间" prop="END_TIME">
|
||||||
<el-date-picker
|
<el-date-picker
|
||||||
v-model="searchForm.END_TIME"
|
v-model="searchForm.END_TIME"
|
||||||
format="YYYY-MM-DD HH:mm:ss"
|
format="YYYY-MM-DD HH:mm:ss"
|
||||||
|
@ -34,7 +39,7 @@
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="8">
|
<el-col :span="6">
|
||||||
<el-form-item label-width="10px">
|
<el-form-item label-width="10px">
|
||||||
<el-button type="primary" native-type="submit">搜索</el-button>
|
<el-button type="primary" native-type="submit">搜索</el-button>
|
||||||
<el-button native-type="reset" @click="fnResetPagination">
|
<el-button native-type="reset" @click="fnResetPagination">
|
||||||
|
@ -62,8 +67,7 @@
|
||||||
{{ row.CURRENT_VALUE }}
|
{{ row.CURRENT_VALUE }}
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="TARGET_UNIT" label="单位" />
|
<el-table-column prop="PROCESSING_BATCH_ID" label="取值时间批次" />
|
||||||
<el-table-column prop="GATHER_TIME" label="采集时间(每5秒采集一次)" />
|
|
||||||
</layout-table>
|
</layout-table>
|
||||||
</layout-card>
|
</layout-card>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
|
|
|
@ -1,55 +1,82 @@
|
||||||
<template>
|
<template>
|
||||||
<el-dialog v-model="visible" title="视频" :append-to-body="appendToBody">
|
<el-dialog v-model="visible" title="视频" :append-to-body="appendToBody">
|
||||||
<!-- 原生video标签,支持大部分基础格式(如MP4) -->
|
<ali-player
|
||||||
<video controls :src="fnSrc(src)" autoplay></video>
|
ref="playerRef"
|
||||||
|
:source="fnSrc(src)"
|
||||||
|
:vid="vid"
|
||||||
|
:play-auth="playAuth"
|
||||||
|
:visible="visible"
|
||||||
|
:cover="cover"
|
||||||
|
:autoplay="autoplay"
|
||||||
|
:show-progress="showProgress"
|
||||||
|
:play-time="playTime"
|
||||||
|
/>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { useVModel } from "@vueuse/core";
|
import { useVModel } from "@vueuse/core";
|
||||||
import { watchEffect } from "vue";
|
import AliPlayer from "@/components/ali-player/index.vue";
|
||||||
|
import { ref, watchEffect } from "vue";
|
||||||
// 更安全的环境变量访问方式
|
|
||||||
const getEnvVar = (name) => {
|
|
||||||
try {
|
|
||||||
// 优先尝试 Vite 的环境变量
|
|
||||||
if (typeof import !== 'undefined' && import.meta && import.meta.env) {
|
|
||||||
return import.meta.env[name];
|
|
||||||
}
|
|
||||||
// 回退到 process.env
|
|
||||||
if (typeof process !== 'undefined' && process.env) {
|
|
||||||
return process.env[name];
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
} catch (error) {
|
|
||||||
console.warn(`获取环境变量 ${name} 时出错:`, error);
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const VITE_FILE_URL = getEnvVar('VITE_FILE_URL') || "";
|
|
||||||
|
|
||||||
|
const VITE_FILE_URL = import.meta.env.VITE_FILE_URL;
|
||||||
|
defineOptions({
|
||||||
|
name: "LayoutVideo",
|
||||||
|
});
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
src: { type: String, default: "" },
|
src: {
|
||||||
visible: { type: Boolean, required: true, default: false },
|
type: String,
|
||||||
appendToBody: { type: Boolean, default: false },
|
default: "",
|
||||||
autoplay: { type: Boolean, default: true },
|
},
|
||||||
|
vid: {
|
||||||
|
type: String,
|
||||||
|
default: "",
|
||||||
|
},
|
||||||
|
playAuth: {
|
||||||
|
type: String,
|
||||||
|
default: "",
|
||||||
|
},
|
||||||
|
visible: {
|
||||||
|
type: Boolean,
|
||||||
|
required: true,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
appendToBody: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
cover: {
|
||||||
|
type: String,
|
||||||
|
default: "",
|
||||||
|
},
|
||||||
|
autoplay: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
showProgress: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
playTime: {
|
||||||
|
type: Number,
|
||||||
|
default: 0,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
const emits = defineEmits(["update:visible"]);
|
const emits = defineEmits(["update:visible"]);
|
||||||
const visible = useVModel(props, "visible", emits);
|
const visible = useVModel(props, "visible", emits);
|
||||||
|
const playerRef = ref(null);
|
||||||
const fnSrc = (src) => {
|
const fnSrc = (src) => {
|
||||||
if (!src) return;
|
if (!src) return;
|
||||||
if (src.includes("http") || src.includes("https")) return src;
|
if (src.indexOf("http") !== -1 || src.indexOf("https") !== -1) return src;
|
||||||
return VITE_FILE_URL + src;
|
else return VITE_FILE_URL + src;
|
||||||
};
|
};
|
||||||
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
const video = document.querySelector("video");
|
if (visible.value) {
|
||||||
if (visible.value && video) {
|
playerRef.value && playerRef.value.play();
|
||||||
video.play().catch((err) => console.error("自动播放失败:", err));
|
} else {
|
||||||
} else if (video) {
|
playerRef.value && playerRef.value.pause();
|
||||||
video.pause();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss"></style>
|
||||||
|
|
Loading…
Reference in New Issue