util.tsx
1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import React, { useEffect, useMemo, useRef, useState } from 'react';
import { Button, Image, message, Modal, Tooltip, Upload } from 'antd';
import { QxIcon } from '@/components';
import defaultImg from '@/components/default/default_cover.png';
const defaultIcon: Record<string, string> = {
form: 'icon-app-file-fill',
group: 'icon-app-folder-2-fill',
report: 'icon-app-performance-fill',
url: 'icon-app-share-forward-fill',
page: 'icon-app-tablicon-app-fill',
dataset: 'icon-app-presentation-2-fill',
datasetCube: 'icon-app-box-3-fill',
app: 'icon-app-grid-2-fill',
};
// 数据流 图标展示
export const getIcon = (icon: string, type?: string) => {
if ((icon as string)?.startsWith('http')) {
return (
<Image
className={'qx-data-flow__img'}
src={icon}
fallback={defaultImg}
preview={false}
width={'16px'}
height={'16px'}
style={{
width: '16px',
height: '16px',
borderRadius: '4px',
}}
alt=""
/>
);
} else {
return (
<QxIcon
className={'qx-data-flow__icon'}
type={icon || defaultIcon[type || 'form']}
/>
);
}
};