| | |
| | | QuarkIcon, |
| | | SafariIcon, |
| | | UcIcon, |
| | | WindowsIcon, |
| | | WindowsIcon |
| | | } from '@vben/icons'; |
| | | |
| | | import { Tag } from 'ant-design-vue'; |
| | | import { Rate, Tag } from 'ant-design-vue'; |
| | | |
| | | import { DictTag } from '#/components/dict'; |
| | | |
| | |
| | | DELETE: 'red', |
| | | GET: 'green', |
| | | POST: 'blue', |
| | | PUT: 'orange', |
| | | PUT: 'orange' |
| | | }; |
| | | |
| | | const color = colors[method] ?? 'default'; |
| | |
| | | * @param [gap] 间隔 |
| | | * @returns render |
| | | */ |
| | | export function renderDictTags( |
| | | value: string[], |
| | | dicts: DictData[], |
| | | wrap = true, |
| | | gap = 1, |
| | | ) { |
| | | export function renderDictTags(value: string[], dicts: DictData[], wrap = true, gap = 1) { |
| | | if (!Array.isArray(value)) { |
| | | return <div>{value}</div>; |
| | | } |
| | |
| | | const dictInfo = getDict(dictName); |
| | | return renderDictTag(value, dictInfo); |
| | | } |
| | | export function renderIconSpan( |
| | | icon: ComponentType, |
| | | value: string, |
| | | center = false, |
| | | marginLeft = '2px', |
| | | ) { |
| | | export function renderIconSpan(icon: ComponentType, value: string, center = false, marginLeft = '2px') { |
| | | const justifyCenter = center ? 'justify-center' : ''; |
| | | |
| | | return ( |
| | |
| | | { icon: LinuxIcon, value: 'linux' }, |
| | | { icon: OSXIcon, value: 'osx' }, |
| | | { icon: AndroidIcon, value: 'android' }, |
| | | { icon: IPhoneIcon, value: 'iphone' }, |
| | | { icon: IPhoneIcon, value: 'iphone' } |
| | | ]; |
| | | |
| | | /** |
| | |
| | | { icon: QQIcon, value: 'qq' }, |
| | | { icon: DingtalkIcon, value: 'dingtalk' }, |
| | | { icon: UcIcon, value: 'uc' }, |
| | | { icon: BaiduIcon, value: 'baidu' }, |
| | | { icon: BaiduIcon, value: 'baidu' } |
| | | ]; |
| | | |
| | | export function renderOsIcon(os: string, center = false) { |
| | | if (!os) { |
| | | return; |
| | | } |
| | | let current = osOptions.find((item) => |
| | | os.toLocaleLowerCase().includes(item.value), |
| | | ); |
| | | let current = osOptions.find((item) => os.toLocaleLowerCase().includes(item.value)); |
| | | // windows要特殊处理 |
| | | if (os.toLocaleLowerCase().includes('windows')) { |
| | | current = osOptions[0]; |
| | |
| | | if (!browser) { |
| | | return; |
| | | } |
| | | const current = browserOptions.find((item) => |
| | | browser.toLocaleLowerCase().includes(item.value), |
| | | ); |
| | | const current = browserOptions.find((item) => browser.toLocaleLowerCase().includes(item.value)); |
| | | if (current) { |
| | | return renderIconSpan(current.icon, browser, center, '5px'); |
| | | } |
| | |
| | | const defaultIcon = DefaultBrowserIcon; |
| | | return renderIconSpan(defaultIcon, browser, center, '5px'); |
| | | } |
| | | |
| | | export function renderRate(value: string) { |
| | | if (!value) { |
| | | return null; |
| | | } |
| | | |
| | | return <Rate disabled value={Number(value)}></Rate>; |
| | | } |