From 0bb1c85f0d23d24d522773ac8c4333792ccf2258 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Thu, 12 Oct 2023 19:53:43 +0800 Subject: [PATCH] feat: add hide tip --- .../com.msgbyte.env.electron/src/ElectronWebview.tsx | 11 +++++++++-- .../plugins/com.msgbyte.env.electron/src/translate.ts | 4 ++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/client/web/plugins/com.msgbyte.env.electron/src/ElectronWebview.tsx b/client/web/plugins/com.msgbyte.env.electron/src/ElectronWebview.tsx index ed371e6e78f..433dcb12204 100644 --- a/client/web/plugins/com.msgbyte.env.electron/src/ElectronWebview.tsx +++ b/client/web/plugins/com.msgbyte.env.electron/src/ElectronWebview.tsx @@ -1,4 +1,5 @@ -import React, { useEffect, useRef } from 'react'; +import React, { useEffect, useRef, useState } from 'react'; +import { Translate } from './translate'; interface ElectronWebviewProps { className?: string; @@ -7,6 +8,7 @@ interface ElectronWebviewProps { export const ElectronWebview: React.FC = React.memo( (props) => { const containerRef = useRef(null); + const [isVisiable, setIsVisiable] = useState(true); const key = props.src; const url = props.src; @@ -59,6 +61,7 @@ export const ElectronWebview: React.FC = React.memo( } ); } + setIsVisiable(entry.isVisible); }); }, { @@ -107,7 +110,11 @@ export const ElectronWebview: React.FC = React.memo( ref={containerRef} className={props.className} style={{ width: '100%', height: '100%' }} - /> + > + {isVisiable === false && ( + {Translate.nativeWebviewRenderHideTip} + )} + ); } ); diff --git a/client/web/plugins/com.msgbyte.env.electron/src/translate.ts b/client/web/plugins/com.msgbyte.env.electron/src/translate.ts index 1bd1f901550..e7c987e2468 100644 --- a/client/web/plugins/com.msgbyte.env.electron/src/translate.ts +++ b/client/web/plugins/com.msgbyte.env.electron/src/translate.ts @@ -46,4 +46,8 @@ export const Translate = { 'en-US': 'Lift default web page access restrictions and allow any website content to be embedded in Tailchat', }), + nativeWebviewRenderHideTip: localTrans({ + 'zh-CN': '组件被遮挡,暂时隐藏网页视图', + 'en-US': 'The component is obscured, temporarily hiding the web view', + }), };