feat: web panel support add background color which useful for transparent background website

pull/147/merge
moonrailgun 2 years ago
parent 3b7973e9e1
commit 5fe0ff06d7

@ -1,4 +1,4 @@
import React, { useEffect } from 'react'; import React from 'react';
import { Form, Checkbox } from 'antd'; import { Form, Checkbox } from 'antd';
import type { FastifyFormFieldComponent } from 'react-fastify-form'; import type { FastifyFormFieldComponent } from 'react-fastify-form';
import { getValidateStatus } from '../utils'; import { getValidateStatus } from '../utils';

@ -20,10 +20,15 @@ const GroupWebPanelRender: React.FC<{ panelInfo: any }> = (props) => {
// 不包含协议, 但是是个网址 // 不包含协议, 但是是个网址
url = 'https://' + url; url = 'https://' + url;
} }
const background = panelInfo?.meta?.background ?? false;
return ( return (
<GroupPanelContainer groupId={groupId} panelId={panelId}> <GroupPanelContainer groupId={groupId} panelId={panelId}>
<WebviewKeepAlive key={String(url)} className="w-full h-full" url={url} /> <WebviewKeepAlive
key={String(url)}
className={`w-full h-full ${background ? 'bg-white' : ''}`}
url={url}
/>
</GroupPanelContainer> </GroupPanelContainer>
); );
}; };

@ -13,6 +13,11 @@ regGroupPanel({
name: 'url', name: 'url',
label: Translate.website, label: Translate.website,
}, },
{
type: 'checkbox',
name: 'background',
label: Translate.addBackground,
},
], ],
render: Loadable(() => import('./group/GroupWebPanelRender')), render: Loadable(() => import('./group/GroupWebPanelRender')),
menus: [ menus: [

@ -14,6 +14,10 @@ export const Translate = {
'zh-CN': '网址', 'zh-CN': '网址',
'en-US': 'Website', 'en-US': 'Website',
}), }),
addBackground: localTrans({
'zh-CN': '添加背景色',
'en-US': 'Add Background Color',
}),
htmlcode: localTrans({ htmlcode: localTrans({
'zh-CN': 'HTML代码', 'zh-CN': 'HTML代码',
'en-US': 'HTML Code', 'en-US': 'HTML Code',

@ -56,7 +56,7 @@ export const ModalModifyGroupPanel: React.FC<{
} }
return ( return (
<ModalWrapper title={t('编辑群组面板')} style={{ maxWidth: 600 }}> <ModalWrapper title={t('编辑群组面板')} style={{ width: 600 }}>
<WebMetaForm <WebMetaForm
schema={schema} schema={schema}
fields={fields.filter((f) => f.type !== 'type')} // 变更时不显示类型 fields={fields.filter((f) => f.type !== 'type')} // 变更时不显示类型

@ -64,7 +64,7 @@ export interface GroupPanel {
/** /**
* *
*/ */
meta?: object; meta?: Record<string, any>;
/** /**
* *

Loading…
Cancel
Save