Skip to content

Commit

Permalink
feat: add hide tip
Browse files Browse the repository at this point in the history
  • Loading branch information
moonrailgun committed Oct 12, 2023
1 parent 146952d commit 0bb1c85
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -59,6 +61,7 @@ export const ElectronWebview: React.FC<ElectronWebviewProps> = React.memo(
}
);
}
setIsVisiable(entry.isVisible);
});
},
{
Expand Down Expand Up @@ -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>
);
}
);
Expand Down
4 changes: 4 additions & 0 deletions client/web/plugins/com.msgbyte.env.electron/src/translate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}),
};

0 comments on commit 0bb1c85

Please sign in to comment.