@@ -5,6 +5,10 @@
|
|||||||
"ComputedRef": true,
|
"ComputedRef": true,
|
||||||
"DirectiveBinding": true,
|
"DirectiveBinding": true,
|
||||||
"EffectScope": true,
|
"EffectScope": true,
|
||||||
|
"ElLoading": true,
|
||||||
|
"ElMessage": true,
|
||||||
|
"ElMessageBox": true,
|
||||||
|
"ElNotification": true,
|
||||||
"ExtractDefaultPropTypes": true,
|
"ExtractDefaultPropTypes": true,
|
||||||
"ExtractPropTypes": true,
|
"ExtractPropTypes": true,
|
||||||
"ExtractPublicPropTypes": true,
|
"ExtractPublicPropTypes": true,
|
||||||
|
|||||||
29
src/api/video/index.ts
Normal file
29
src/api/video/index.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import request from '@/utils/request';
|
||||||
|
import { AxiosPromise } from 'axios';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开始一直播预览
|
||||||
|
* @param query
|
||||||
|
* post
|
||||||
|
* /haikang/isup/stream/live/start?deviceId=2057338485989367810
|
||||||
|
*/
|
||||||
|
export const listDemo = (deviceId?: string | number) => {
|
||||||
|
return request({
|
||||||
|
url: `/haikang/isup/stream/live/start?deviceId=${deviceId}`,
|
||||||
|
method: 'post'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 停止-直播预览
|
||||||
|
* @param query
|
||||||
|
* post
|
||||||
|
* /haikang/isup/stream/live/stop?id=2057338485989367810&channel=1
|
||||||
|
*/
|
||||||
|
export const addDemo = (data: any) => {
|
||||||
|
return request({
|
||||||
|
url: '/haikang/isup/stream/live/stop',
|
||||||
|
method: 'get',
|
||||||
|
params: data
|
||||||
|
});
|
||||||
|
};
|
||||||
0
src/api/video/types.ts
Normal file
0
src/api/video/types.ts
Normal file
41
src/store/modules/video.ts
Normal file
41
src/store/modules/video.ts
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import { defineStore } from 'pinia';
|
||||||
|
import { ref, computed } from 'vue';
|
||||||
|
import { addDemo, listDemo } from '@/api/video';
|
||||||
|
import Hls from 'hls.js';
|
||||||
|
|
||||||
|
export const useVideosStore = defineStore('videos', () => {
|
||||||
|
// --- State (状态) ---
|
||||||
|
// 相当于 Vuex 中的 state,用 ref 或 reactive 定义
|
||||||
|
const hisUrl = ref();
|
||||||
|
|
||||||
|
// --- Getters (计算属性) ---
|
||||||
|
// 相当于 Vuex 中的 getters,直接用 computed 定义
|
||||||
|
|
||||||
|
// --- Actions (动作) ---
|
||||||
|
// 相当于 Vuex 中的 actions/mutations,直接写同步或异步函数
|
||||||
|
async function getVideos(deviceId?: string | number) {
|
||||||
|
try {
|
||||||
|
const response = await listDemo(deviceId);
|
||||||
|
console.log('获取视频:', response);
|
||||||
|
hisUrl.value = response.data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取视频失败', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function stopVideos(query: any) {
|
||||||
|
try {
|
||||||
|
const response = await addDemo(query);
|
||||||
|
console.log('停止视频:', response);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('停止视频失败', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ⚠️ 核心点:必须把需要暴露出去的变量和方法 return 出去!
|
||||||
|
return {
|
||||||
|
hisUrl,
|
||||||
|
getVideos,
|
||||||
|
stopVideos
|
||||||
|
};
|
||||||
|
});
|
||||||
@@ -138,7 +138,9 @@ import { listDemo, getDemo, delDemo, addDemo, updateDemo } from '@/api/demo/demo
|
|||||||
import { DemoVO, DemoQuery, DemoForm } from '@/api/demo/demo/types';
|
import { DemoVO, DemoQuery, DemoForm } from '@/api/demo/demo/types';
|
||||||
import { log } from 'node:console';
|
import { log } from 'node:console';
|
||||||
import Hls from 'hls.js';
|
import Hls from 'hls.js';
|
||||||
|
import { useVideosStore } from '@/store/modules/video';
|
||||||
|
|
||||||
|
const videosStore = useVideosStore();
|
||||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||||
|
|
||||||
const demoList = ref([]);
|
const demoList = ref([]);
|
||||||
@@ -163,7 +165,7 @@ const dialog1 = reactive<DialogOption>({
|
|||||||
title: ''
|
title: ''
|
||||||
});
|
});
|
||||||
|
|
||||||
const monitorVideoUrl = 'http://192.168.0.214:8088/5a0db047943df198aff98b650ac9e001.mp4';
|
const monitorVideoUrl = ref('');
|
||||||
const monitorVideoRef = ref<HTMLVideoElement>();
|
const monitorVideoRef = ref<HTMLVideoElement>();
|
||||||
|
|
||||||
type MonitorPoint = { x: number; y: number };
|
type MonitorPoint = { x: number; y: number };
|
||||||
@@ -318,6 +320,7 @@ const resetMonitorDraw = () => {
|
|||||||
monitorRectPx.value = null;
|
monitorRectPx.value = null;
|
||||||
};
|
};
|
||||||
const handleSee = async (row?: any) => {
|
const handleSee = async (row?: any) => {
|
||||||
|
console.log('1111111111111111', row);
|
||||||
reset();
|
reset();
|
||||||
resetMonitorDraw();
|
resetMonitorDraw();
|
||||||
seeSee.value = row?.isDrawArea === 1 ? 1 : 0;
|
seeSee.value = row?.isDrawArea === 1 ? 1 : 0;
|
||||||
@@ -326,6 +329,9 @@ const handleSee = async (row?: any) => {
|
|||||||
Object.assign(form.value, res.data);
|
Object.assign(form.value, res.data);
|
||||||
dialog1.visible = true;
|
dialog1.visible = true;
|
||||||
dialog1.title = '修改设备';
|
dialog1.title = '修改设备';
|
||||||
|
videosStore.getVideos(row.id);
|
||||||
|
console.log('222222222222:', videosStore.hisUrl);
|
||||||
|
monitorVideoUrl.value = videosStore.hisUrl;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleMonitorDialogClose = (done: () => void) => {
|
const handleMonitorDialogClose = (done: () => void) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user