fix: fix url problem about avatar url in popover

pull/90/head
moonrailgun 3 years ago
parent 3a328beb82
commit dcaa2799aa

@ -1,3 +1,4 @@
import { parseUrlStr } from 'node_modules/tailchat-shared';
import React, { useState } from 'react'; import React, { useState } from 'react';
import { Avatar, AvatarProps } from '../Avatar'; import { Avatar, AvatarProps } from '../Avatar';
import { Image } from '../Image'; import { Image } from '../Image';
@ -27,7 +28,7 @@ export const AvatarWithPreview: React.FC<AvatarProps> = React.memo((props) => {
<Image <Image
preview={{ preview={{
visible, visible,
src: String(props.src), src: parseUrlStr(String(props.src)),
onVisibleChange: (value) => { onVisibleChange: (value) => {
setVisible(value); setVisible(value);
}, },

@ -1,7 +1,7 @@
import { fetchImagePrimaryColor } from '@/utils/image-helper'; import { fetchImagePrimaryColor } from '@/utils/image-helper';
import React, { PropsWithChildren } from 'react'; import React, { PropsWithChildren } from 'react';
import { AvatarWithPreview, getTextColorHex } from 'tailchat-design'; import { AvatarWithPreview, getTextColorHex } from 'tailchat-design';
import { useAsync, UserBaseInfo } from 'tailchat-shared'; import { parseUrlStr, useAsync, UserBaseInfo } from 'tailchat-shared';
/** /**
* *

@ -1,3 +1,5 @@
import { parseUrlStr } from 'tailchat-shared';
/** /**
* *
*/ */
@ -6,7 +8,7 @@ async function loadImage(url: string): Promise<HTMLImageElement> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
el.onload = () => resolve(el); el.onload = () => resolve(el);
el.onerror = reject; el.onerror = reject;
el.src = url; el.src = parseUrlStr(url);
el.crossOrigin = 'Anonymous'; el.crossOrigin = 'Anonymous';
}); });
} }

Loading…
Cancel
Save