feat: add hide tip

pull/147/merge
moonrailgun 2 years ago
parent 146952d4f3
commit 0bb1c85f0d

@ -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<ElectronWebviewProps> = React.memo(
(props) => {
const containerRef = useRef<HTMLDivElement>(null);
const [isVisiable, setIsVisiable] = useState(true);
const key = props.src;
const url = props.src;
@ -59,6 +61,7 @@ export const ElectronWebview: React.FC<ElectronWebviewProps> = React.memo(
}
);
}
setIsVisiable(entry.isVisible);
});
},
{
@ -107,7 +110,11 @@ export const ElectronWebview: React.FC<ElectronWebviewProps> = React.memo(
ref={containerRef}
className={props.className}
style={{ width: '100%', height: '100%' }}
/>
>
{isVisiable === false && (
<span>{Translate.nativeWebviewRenderHideTip}</span>
)}
</div>
);
}
);

@ -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',
}),
};

Loading…
Cancel
Save