fix: fix linkmeta plugin dont parse {BACKEND} problem

pull/146/head
moonrailgun 2 years ago
parent 5484cb7df1
commit 2b923b40b6

@ -1,11 +1,15 @@
import React from 'react'; import React from 'react';
import _get from 'lodash/get'; import _get from 'lodash/get';
import type { LinkMeta } from './types'; import type { LinkMeta } from './types';
import { parseUrlStr } from '@capital/common';
import { Image, Icon } from '@capital/component'; import { Image, Icon } from '@capital/component';
export const UrlMetaBase: React.FC<{ export const UrlMetaBase: React.FC<{
meta: LinkMeta; meta: LinkMeta;
}> = React.memo(({ meta }) => { }> = React.memo(({ meta }) => {
const imageUrl = _get(meta, 'images.0');
const videoUrl = _get(meta, 'videos.0');
return ( return (
<> <>
<div className="basic"> <div className="basic">
@ -13,24 +17,24 @@ export const UrlMetaBase: React.FC<{
<div className="title">{_get(meta, 'title')}</div> <div className="title">{_get(meta, 'title')}</div>
<div className="description">{_get(meta, 'description')}</div> <div className="description">{_get(meta, 'description')}</div>
</div> </div>
{_get(meta, 'images.0') && ( {imageUrl && (
<div className="image"> <div className="image">
<Image preview={true} src={_get(meta, 'images.0')} /> <Image preview={true} src={parseUrlStr(imageUrl)} />
</div> </div>
)} )}
</div> </div>
{_get(meta, 'videos.0') && ( {videoUrl && (
<div className="video"> <div className="video">
<div <div
className="openfull" className="openfull"
onClick={(e) => { onClick={(e) => {
e.stopPropagation(); e.stopPropagation();
window.open(_get(meta, 'videos.0')); window.open(videoUrl);
}} }}
> >
<Icon icon="mdi:open-in-new" /> <Icon icon="mdi:open-in-new" />
</div> </div>
<iframe src={_get(meta, 'videos.0')} /> <iframe src={videoUrl} />
</div> </div>
)} )}
</> </>

@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import _get from 'lodash/get'; import { parseUrlStr } from '@capital/common';
import { Image } from '@capital/component'; import { Image } from '@capital/component';
import type { LinkMeta } from './types'; import type { LinkMeta } from './types';
@ -12,7 +12,7 @@ export const UrlMetaImage: React.FC<{
return ( return (
<Image <Image
preview={true} preview={true}
src={meta.url} src={parseUrlStr(meta.url)}
style={{ style={{
maxHeight: MAX_HEIGHT, maxHeight: MAX_HEIGHT,
maxWidth: MAX_WIDTH, maxWidth: MAX_WIDTH,

Loading…
Cancel
Save