Skip to content

Commit 4eacff5

Browse files
committed
feat: 增加 changeWndNum 脚本
1 parent 4b88539 commit 4eacff5

2 files changed

Lines changed: 32 additions & 10 deletions

File tree

src/components/BootstrapBlazor.HikVision/Components/HikVisionWebPlugin.razor.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { init as initVision, login as loginVision, logout, startRealPlay, stopRealPlay, openSound, closeSound, setVolume, capturePicture, capturePictureAndDownload, startRecord, stopRecord, dispose as disposeVision } from '../hikvision.js';
1+
import { init as initVision, login as loginVision, logout, startRealPlay, stopRealPlay, openSound, closeSound, setVolume, capturePicture, capturePictureAndDownload, startRecord, stopRecord, changeWndNum, dispose as disposeVision } from '../hikvision.js';
22
import Data from '../../BootstrapBlazor/modules/data.js';
33

44
export async function init(id, invoke) {
@@ -8,7 +8,8 @@ export async function init(id, invoke) {
88
}
99

1010
Data.set(id, {
11-
invoke
11+
invoke,
12+
iWndIndex: 0
1213
});
1314

1415
const inited = await initVision(id);
@@ -29,7 +30,7 @@ export async function login(id, ip, port, userName, password, loginType) {
2930
return logined;
3031
}
3132

32-
export { logout, startRealPlay, stopRealPlay, openSound, closeSound, setVolume, capturePicture, capturePictureAndDownload, startRecord, stopRecord }
33+
export { logout, startRealPlay, stopRealPlay, openSound, closeSound, setVolume, capturePicture, capturePictureAndDownload, startRecord, stopRecord, changeWndNum }
3334

3435
export function dispose(id) {
3536
disposeVision(id);

src/components/BootstrapBlazor.HikVision/wwwroot/hikvision.js

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@ export async function init(id) {
1313
return false;
1414
}
1515

16-
const result = await initWindow(id);
16+
const vision = Data.get(id);
17+
const result = await initWindow(id, iWndIndex => vision.iWndIndex = iWndIndex);
1718
if (result.inited === false) {
1819
return false;
1920
}
20-
21-
const vision = Data.get(id);
22-
vision.iWndIndex = result.iWndIndex;
2321
vision.inited = true;
2422

2523
const observer = new IntersectionObserver(() => {
@@ -103,14 +101,14 @@ const removePlugin = () => {
103101
}
104102
}
105103

106-
const initWindow = id => {
107-
const result = { inited: null, iWndIndex: -1 };
104+
const initWindow = (id, cb) => {
105+
const result = { inited: null };
108106
WebVideoCtrl.I_InitPlugin({
109107
szBasePath: './_content/BootstrapBlazor.HikVision',
110108
bWndFull: true,
111109
iWndowType: 1,
112110
cbSelWnd: function (xmlDoc) {
113-
result.iWndIndex = parseInt(getTagNameFirstValue(xmlDoc, "SelectWnd"));
111+
cb(parseInt(getTagNameFirstValue(xmlDoc, "SelectWnd")));
114112
},
115113
cbDoubleClickWnd: function (iWndIndex, bFullScreen) {
116114

@@ -553,6 +551,29 @@ export async function stopRecord(id) {
553551
});
554552
}
555553

554+
export async function changeWndNum(id, iWndType) {
555+
const vision = Data.get(id);
556+
if (!iWndType) {
557+
iWndType = "1";
558+
}
559+
560+
let ret = false;
561+
try {
562+
if ("1*2" === iWndType || "2*1" === iWndType) {
563+
await WebVideoCtrl.I_ArrangeWindow(iWndType);
564+
}
565+
else {
566+
const iType = parseInt(iWndType, 10);
567+
await WebVideoCtrl.I_ChangeWndNum(iType);
568+
}
569+
ret = true;
570+
}
571+
catch (oError) {
572+
console.log(oError);
573+
}
574+
return ret;
575+
}
576+
556577
export function dispose(id) {
557578
const vision = Data.get(id);
558579
const { realPlaying, logined, observer } = vision;

0 commit comments

Comments
 (0)