update: 添加注释

This commit is contained in:
JiangQiming 2023-03-04 11:01:22 +08:00
parent 94bef052bc
commit d8ceb8e8e8
3 changed files with 81 additions and 15 deletions

View File

@ -186,25 +186,39 @@ const props = defineProps<ScreenProps>();
const DEFAULT_SAVE_CODE = 'screen-save'; const DEFAULT_SAVE_CODE = 'screen-save';
// 1/4/9/0
const screen = ref(1); const screen = ref(1);
//
const players = ref<Player[]>([]); const players = ref<Player[]>([]);
//
const playerActive = ref(0); const playerActive = ref(0);
const historyList = ref<any[]>([]); //
const visible = ref(false);
const loading = ref(false);
const fullscreenRef = ref(null);
const screenWidth = ref(''); const screenWidth = ref('');
const screenHeight = ref(''); const screenHeight = ref('');
//
const { isFullscreen, enter, exit, toggle } = useFullscreen( const historyList = ref<any[]>([]);
fullscreenRef.value, //
); const visible = ref(false);
const loading = ref(false);
//
const formRef = ref(); const formRef = ref();
const formData = ref({ const formData = ref({
name: '', name: '',
}); });
//
const fullscreenRef = ref(null);
const { isFullscreen, enter, exit, toggle } = useFullscreen(
fullscreenRef.value,
);
/**
* 刷新视频
* @param id
* @param channelId
* @param url
* @param index
*/
const reloadPlayer = ( const reloadPlayer = (
id: string, id: string,
channelId: string, channelId: string,
@ -233,6 +247,12 @@ const reloadPlayer = (
}, 1000); }, 1000);
}; };
/**
* 视频链接变化, 更新播放内容
* @param id
* @param channelId
* @param url
*/
const replaceVideo = (id: string, channelId: string, url: string) => { const replaceVideo = (id: string, channelId: string, url: string) => {
const olPlayers = [...players.value]; const olPlayers = [...players.value];
const newPlayer = { const newPlayer = {
@ -258,6 +278,10 @@ const replaceVideo = (id: string, channelId: string, url: string) => {
} }
}; };
/**
* 点击分屏历史记录
* @param item
*/
const handleHistory = (item: any) => { const handleHistory = (item: any) => {
if (props.historyHandle) { if (props.historyHandle) {
const log = JSON.parse(item.content || '{}'); const log = JSON.parse(item.content || '{}');
@ -283,12 +307,20 @@ const handleHistory = (item: any) => {
} }
}; };
/**
* 获取历史分屏
*/
const getHistory = async () => { const getHistory = async () => {
const res = await getSearchHistory(DEFAULT_SAVE_CODE); const res = await getSearchHistory(DEFAULT_SAVE_CODE);
if (res.success) { if (res.success) {
historyList.value = res.result; historyList.value = res.result;
} }
}; };
/**
* 删除历史分屏
* @param id
*/
const deleteHistory = async (id: string) => { const deleteHistory = async (id: string) => {
const res = await deleteSearchHistory(DEFAULT_SAVE_CODE, id); const res = await deleteSearchHistory(DEFAULT_SAVE_CODE, id);
if (res.success) { if (res.success) {
@ -297,6 +329,9 @@ const deleteHistory = async (id: string) => {
} }
}; };
/**
* 保存分屏
*/
const saveHistory = async () => { const saveHistory = async () => {
formRef.value formRef.value
.validate() .validate()
@ -328,6 +363,9 @@ const saveHistory = async () => {
}); });
}; };
/**
* 初始化
*/
const mediaInit = () => { const mediaInit = () => {
const newArr = []; const newArr = [];
for (let i = 0; i < 9; i++) { for (let i = 0; i < 9; i++) {
@ -342,6 +380,10 @@ const mediaInit = () => {
players.value = newArr; players.value = newArr;
}; };
/**
* 改变分屏数量
* @param e
*/
const handleScreenChange = (e: any) => { const handleScreenChange = (e: any) => {
if (e.target.value) { if (e.target.value) {
screenChange(e.target.value); screenChange(e.target.value);
@ -368,6 +410,12 @@ const screenChange = (index: number) => {
// } // }
}; };
/**
* 刷新
* @param e
* @param item
* @param index
*/
const handleRefresh = (e: any, item: any, index: number) => { const handleRefresh = (e: any, item: any, index: number) => {
e.stopPropagation(); e.stopPropagation();
if (item.url) { if (item.url) {
@ -381,10 +429,6 @@ const handleRefresh = (e: any, item: any, index: number) => {
*/ */
const handleMouseDown = (type: string) => { const handleMouseDown = (type: string) => {
const { id, channelId } = players.value[playerActive.value]; const { id, channelId } = players.value[playerActive.value];
console.log('players.value: ', players.value);
console.log('playerActive.value: ', playerActive.value);
console.log('id: ', id);
console.log('channelId: ', channelId);
if (id && channelId && props.onMouseDown) { if (id && channelId && props.onMouseDown) {
props.onMouseDown(id, channelId, type); props.onMouseDown(id, channelId, type);
} }

View File

@ -30,10 +30,19 @@ const deviceId = ref('');
const channelId = ref(''); const channelId = ref('');
const player = ref(); const player = ref();
/**
* 获取视频链接
* @param dId
* @param cId
*/
const getMediaUrl = (dId: string, cId: string): string => { const getMediaUrl = (dId: string, cId: string): string => {
return channelApi.ptzStart(dId, cId, 'mp4'); return channelApi.ptzStart(dId, cId, 'mp4');
}; };
/**
* 点击左侧摄像头, 播放对应视频
* @param e
*/
const mediaStart = (e: { cId: string; dId: string }) => { const mediaStart = (e: { cId: string; dId: string }) => {
channelId.value = e.cId; channelId.value = e.cId;
deviceId.value = e.dId; deviceId.value = e.dId;

View File

@ -41,8 +41,12 @@ interface DataNode {
children?: DataNode[]; children?: DataNode[];
} }
/**
* 点击节点
* @param _
* @param param1
*/
const onSelect = (_: any, { node }: any) => { const onSelect = (_: any, { node }: any) => {
console.log('node: ', node);
emit('onSelect', { dId: node.deviceId, cId: node.channelId }); emit('onSelect', { dId: node.deviceId, cId: node.channelId });
}; };
@ -76,6 +80,12 @@ const getDeviceList = async () => {
}; };
getDeviceList(); getDeviceList();
/**
* 更新数据
* @param list
* @param key
* @param children
*/
const updateTreeData = ( const updateTreeData = (
list: DataNode[], list: DataNode[],
key: any, key: any,
@ -129,12 +139,15 @@ const getChildren = (key: any, params: any): Promise<any> => {
}); });
}, 50); }, 50);
} }
console.log('treeData.value: ', treeData.value);
resolve(res.result); resolve(res.result);
} }
}); });
}; };
/**
* 异步加载子节点数据
* @param param0
*/
const onLoadData = ({ key, children }: any): Promise<void> => { const onLoadData = ({ key, children }: any): Promise<void> => {
return new Promise(async (resolve) => { return new Promise(async (resolve) => {
if (children) { if (children) {