diff --git a/client/web/plugins/com.msgbyte.snapdrop/src/index.tsx b/client/web/plugins/com.msgbyte.snapdrop/src/index.tsx
index 3b7b06ba..29d4c62f 100644
--- a/client/web/plugins/com.msgbyte.snapdrop/src/index.tsx
+++ b/client/web/plugins/com.msgbyte.snapdrop/src/index.tsx
@@ -1,4 +1,5 @@
import { regCustomPanel } from '@capital/common';
+import { WebviewKeepAlive } from '@capital/component';
import React from 'react';
import { Translate } from './translate';
@@ -10,6 +11,9 @@ regCustomPanel({
label: Translate.panelName,
icon: 'mdi:radio-tower',
render: () => (
-
+
),
});
diff --git a/client/web/plugins/com.msgbyte.webview/src/group/GroupCustomWebPanelRender.tsx b/client/web/plugins/com.msgbyte.webview/src/group/GroupCustomWebPanelRender.tsx
index 30d4614c..3d714a6b 100644
--- a/client/web/plugins/com.msgbyte.webview/src/group/GroupCustomWebPanelRender.tsx
+++ b/client/web/plugins/com.msgbyte.webview/src/group/GroupCustomWebPanelRender.tsx
@@ -3,6 +3,7 @@ import { encode } from 'js-base64';
import { isValidStr } from '@capital/common';
import { Translate } from '../translate';
import { sanitize } from 'script_sanitize';
+import { WebviewKeepAlive } from '@capital/component';
function getInjectedStyle() {
try {
@@ -25,7 +26,7 @@ const GroupCustomWebPanelRender: React.FC<{ panelInfo: any }> = (props) => {
}
const html = panelInfo?.meta?.html;
- const src = useMemo(() => {
+ const url = useMemo(() => {
if (isValidStr(html)) {
const appendHtml = getInjectedStyle(); // 额外追加的样式
try {
@@ -40,7 +41,7 @@ const GroupCustomWebPanelRender: React.FC<{ panelInfo: any }> = (props) => {
}
}, [html]);
- return ;
+ return ;
};
GroupCustomWebPanelRender.displayName = 'GroupCustomWebPanelRender';
diff --git a/client/web/plugins/com.msgbyte.webview/src/group/GroupWebPanelRender.tsx b/client/web/plugins/com.msgbyte.webview/src/group/GroupWebPanelRender.tsx
index f7e5abae..ad425999 100644
--- a/client/web/plugins/com.msgbyte.webview/src/group/GroupWebPanelRender.tsx
+++ b/client/web/plugins/com.msgbyte.webview/src/group/GroupWebPanelRender.tsx
@@ -1,6 +1,6 @@
import React from 'react';
import { Translate } from '../translate';
-import { Webview } from '@capital/component';
+import { WebviewKeepAlive } from '@capital/component';
const GroupWebPanelRender: React.FC<{ panelInfo: any }> = (props) => {
const panelInfo = props.panelInfo;
@@ -11,7 +11,9 @@ const GroupWebPanelRender: React.FC<{ panelInfo: any }> = (props) => {
const url = panelInfo?.meta?.url;
- return ;
+ return (
+
+ );
};
GroupWebPanelRender.displayName = 'GroupWebPanelRender';
diff --git a/client/web/src/components/Webview.tsx b/client/web/src/components/Webview.tsx
index bebc761b..7b42933a 100644
--- a/client/web/src/components/Webview.tsx
+++ b/client/web/src/components/Webview.tsx
@@ -10,11 +10,17 @@ interface WebviewProps {
/**
* 网页渲染容器
*/
-export const Webview: React.FC =
- withKeepAliveOverlay(
- (props) => {
- return ;
- },
- { cacheId: (props) => props.url }
- );
+export const Webview: React.FC = (props) => {
+ return ;
+};
Webview.displayName = 'Webview';
+
+/**
+ * 带缓存的网页渲染容器
+ * 用于需要在切换时依旧保持加载的case
+ */
+export const WebviewKeepAlive: React.FC =
+ withKeepAliveOverlay(Webview, {
+ cacheId: (props) => props.url,
+ });
+WebviewKeepAlive.displayName = 'WebviewKeepAlive';
diff --git a/client/web/src/plugin/component/index.tsx b/client/web/src/plugin/component/index.tsx
index 5cca67f7..a043ea4f 100644
--- a/client/web/src/plugin/component/index.tsx
+++ b/client/web/src/plugin/component/index.tsx
@@ -56,4 +56,4 @@ export { ErrorBoundary } from '@/components/ErrorBoundary';
export { UserAvatar } from '@/components/UserAvatar';
export { UserName } from '@/components/UserName';
export { Markdown } from '@/components/Markdown';
-export { Webview } from '@/components/Webview';
+export { Webview, WebviewKeepAlive } from '@/components/Webview';