From b8766b06cac10a7e6bbd9f97607fbaaeb20cbc9c Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 7 Dec 2025 14:54:00 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E5=8F=AF?= =?UTF-8?q?=E8=A7=81=E6=80=A7=E7=9B=91=E6=8E=A7=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BootstrapBlazor.HikVision/wwwroot/hikvision.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/BootstrapBlazor.HikVision/wwwroot/hikvision.js b/src/components/BootstrapBlazor.HikVision/wwwroot/hikvision.js index 85bea03a..8fd35d25 100644 --- a/src/components/BootstrapBlazor.HikVision/wwwroot/hikvision.js +++ b/src/components/BootstrapBlazor.HikVision/wwwroot/hikvision.js @@ -22,6 +22,15 @@ export async function init(id) { vision.iWndIndex = result.iWndIndex; vision.inited = true; + const observer = new IntersectionObserver(() => { + console.log('IntersectionObserver callback'); + if (checkVisibility(el)) { + WebVideoCtrl.I_Resize(el.offsetWidth, el.offsetHeight); + } + }); + observer.observe(el); + vision.observer = observer; + return true; } @@ -309,7 +318,10 @@ export function dispose(id) { const vision = Data.get(id); Data.remove(id); - const { realPlaying, logined } = vision; + const { realPlaying, logined, observer } = vision; + if (observer) { + observer.disconnect(); + } if (realPlaying === true) { stopRealPlay(id); } From cdcbfcf6b2da0489ee57a2aae3152185ea9f5417 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 7 Dec 2025 14:55:58 +0800 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E9=9A=90?= =?UTF-8?q?=E8=97=8F=20Wnd=20=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wwwroot/hikvision.js | 66 ++++++++++++++++++- 1 file changed, 63 insertions(+), 3 deletions(-) diff --git a/src/components/BootstrapBlazor.HikVision/wwwroot/hikvision.js b/src/components/BootstrapBlazor.HikVision/wwwroot/hikvision.js index 8fd35d25..b4259f1e 100644 --- a/src/components/BootstrapBlazor.HikVision/wwwroot/hikvision.js +++ b/src/components/BootstrapBlazor.HikVision/wwwroot/hikvision.js @@ -23,7 +23,6 @@ export async function init(id) { vision.inited = true; const observer = new IntersectionObserver(() => { - console.log('IntersectionObserver callback'); if (checkVisibility(el)) { WebVideoCtrl.I_Resize(el.offsetWidth, el.offsetHeight); } @@ -38,8 +37,68 @@ const hackJSResize = function () { const originalResize = JSVideoPlugin.prototype.JS_Resize; JSVideoPlugin.prototype.JS_Resize = function (e, t) { const { szId } = this.oOptions; - if (document.getElementById(szId)) { - return originalResize.call(this, e, t); + const el = document.getElementById(szId); + if (el) { + const visible = checkVisibility(el); + if (visible) { + return originalResize.call(this, e, t); + } + else { + WebVideoCtrl.I_HidPlugin(); + } + } + } +} + +const checkVisibility = el => { + if (el.checkVisibility) { + return el.checkVisibility(); + } + else { + return isVisible(el); + } +} + +const isVisible = (element) => { + if (!element) return false; + + const style = window.getComputedStyle(element); + if (style.display === 'none' || style.visibility === 'hidden' || parseFloat(style.opacity) < 0.01) { + return false; + } + + const rect = element.getBoundingClientRect(); + if (rect.width === 0 || rect.height === 0) { + return false; + } + + let parent = element.parentElement; + while (parent) { + const parentStyle = window.getComputedStyle(parent); + if (parentStyle.display === 'none' || parentStyle.visibility === 'hidden') { + return false; + } + parent = parent.parentElement; + } + + return true; +} + +const hackJSShowWnd = function () { + const originalShowWnd = JSVideoPlugin.prototype.JS_ShowWnd; + JSVideoPlugin.prototype.JS_ShowWnd = function () { + const { szId } = this.oOptions; + const el = document.getElementById(szId); + if (el) { + const visible = checkVisibility(el); + if (visible) { + return originalShowWnd.call(this); + } + else { + return new Promise((resolve, reject) => { + resolve(); + }); + } } } } @@ -100,6 +159,7 @@ const initWindow = id => { if (result.inited === false || (result.inited && result.iWndIndex !== -1)) { clearInterval(handler); hackJSResize(); + hackJSShowWnd(); hackJSDestroyPlugin(); resolve(result); } From 678b91a91a82e6e6699269a7750efbd1d656c405 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 7 Dec 2025 14:56:55 +0800 Subject: [PATCH 3/4] =?UTF-8?q?refactor:=20=E8=B0=83=E6=95=B4=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E6=96=B9=E6=B3=95=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wwwroot/hikvision.js | 68 +++++++++---------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/src/components/BootstrapBlazor.HikVision/wwwroot/hikvision.js b/src/components/BootstrapBlazor.HikVision/wwwroot/hikvision.js index b4259f1e..71de5fc5 100644 --- a/src/components/BootstrapBlazor.HikVision/wwwroot/hikvision.js +++ b/src/components/BootstrapBlazor.HikVision/wwwroot/hikvision.js @@ -50,40 +50,6 @@ const hackJSResize = function () { } } -const checkVisibility = el => { - if (el.checkVisibility) { - return el.checkVisibility(); - } - else { - return isVisible(el); - } -} - -const isVisible = (element) => { - if (!element) return false; - - const style = window.getComputedStyle(element); - if (style.display === 'none' || style.visibility === 'hidden' || parseFloat(style.opacity) < 0.01) { - return false; - } - - const rect = element.getBoundingClientRect(); - if (rect.width === 0 || rect.height === 0) { - return false; - } - - let parent = element.parentElement; - while (parent) { - const parentStyle = window.getComputedStyle(parent); - if (parentStyle.display === 'none' || parentStyle.visibility === 'hidden') { - return false; - } - parent = parent.parentElement; - } - - return true; -} - const hackJSShowWnd = function () { const originalShowWnd = JSVideoPlugin.prototype.JS_ShowWnd; JSVideoPlugin.prototype.JS_ShowWnd = function () { @@ -402,3 +368,37 @@ const getTagNameFirstValue = (xmlDoc, tagName, defaultValue = '0') => { const getTagNameValues = (xmlDoc, tagName) => { return xmlDoc.getElementsByTagName(tagName); } + +const checkVisibility = el => { + if (el.checkVisibility) { + return el.checkVisibility(); + } + else { + return isVisible(el); + } +} + +const isVisible = (element) => { + if (!element) return false; + + const style = window.getComputedStyle(element); + if (style.display === 'none' || style.visibility === 'hidden' || parseFloat(style.opacity) < 0.01) { + return false; + } + + const rect = element.getBoundingClientRect(); + if (rect.width === 0 || rect.height === 0) { + return false; + } + + let parent = element.parentElement; + while (parent) { + const parentStyle = window.getComputedStyle(parent); + if (parentStyle.display === 'none' || parentStyle.visibility === 'hidden') { + return false; + } + parent = parent.parentElement; + } + + return true; +} From 79756579ebe455f33769644f28f77447be23c183 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 7 Dec 2025 15:00:27 +0800 Subject: [PATCH 4/4] chore: bump version 10.0.1 --- .../BootstrapBlazor.HikVision/BootstrapBlazor.HikVision.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/BootstrapBlazor.HikVision/BootstrapBlazor.HikVision.csproj b/src/components/BootstrapBlazor.HikVision/BootstrapBlazor.HikVision.csproj index 16cdc55e..a61ed93f 100644 --- a/src/components/BootstrapBlazor.HikVision/BootstrapBlazor.HikVision.csproj +++ b/src/components/BootstrapBlazor.HikVision/BootstrapBlazor.HikVision.csproj @@ -1,7 +1,7 @@ - 10.0.0 + 10.0.1