feat: add discord field icon

zio/stable
三咲智子 2022-12-10 20:43:45 +08:00
parent ebe7b85cf9
commit 413e7b1a00
No known key found for this signature in database
GPG Key ID: 69992F2250DFD93E
2 changed files with 25 additions and 25 deletions

View File

@ -17,33 +17,9 @@ const createdAt = $(useFormattedDateTime(() => account.createdAt, {
const namedFields = ref<Field[]>([])
const iconFields = ref<Field[]>([])
const fieldNameIcons: Record<string, string> = {
github: 'i-ri:github-fill',
twitter: 'i-ri:twitter-line',
mastodon: 'i-ri:mastodon-line',
youtube: 'i-ri:youtube-line',
twitch: 'i-ri:twitch-line',
instagram: 'i-ri:instagram-line',
website: 'i-ri:link',
site: 'i-ri:link',
portfolio: 'i-ri:link',
blog: 'i-ri:newspaper-line',
home: 'i-ri:home-2-line',
sponsors: 'i-ri:heart-3-line',
location: 'i-ri:map-pin-2-line',
city: 'i-ri:map-pin-2-line',
joined: 'i-ri:user-add-line',
birth: 'i-ri:calendar-line',
tumblr: 'i-ri:tumblr-fill',
linkedin: 'i-ri:linkedin-box-fill',
facebook: 'i-ri:facebook-fill',
patreon: 'i-ri:patreon-fill',
}
function getFieldNameIcon(fieldName: string) {
const name = fieldName.trim().toLowerCase()
if (fieldNameIcons[name])
return fieldNameIcons[name]
return ACCOUNT_FIELD_ICONS[name] || undefined
}
function getFieldIconTitle(fieldName: string) {
return fieldName === 'Joined' ? t('account.joined') : fieldName

View File

@ -28,6 +28,30 @@ export const STATUS_VISIBILITIES = [
},
] as const
export const ACCOUNT_FIELD_ICONS: Record<string, string> = {
github: 'i-ri:github-fill',
twitter: 'i-ri:twitter-line',
mastodon: 'i-ri:mastodon-line',
youtube: 'i-ri:youtube-line',
twitch: 'i-ri:twitch-line',
instagram: 'i-ri:instagram-line',
website: 'i-ri:link',
site: 'i-ri:link',
portfolio: 'i-ri:link',
blog: 'i-ri:newspaper-line',
home: 'i-ri:home-2-line',
sponsors: 'i-ri:heart-3-line',
location: 'i-ri:map-pin-2-line',
city: 'i-ri:map-pin-2-line',
joined: 'i-ri:user-add-line',
birth: 'i-ri:calendar-line',
tumblr: 'i-ri:tumblr-fill',
linkedin: 'i-ri:linkedin-box-fill',
facebook: 'i-ri:facebook-fill',
patreon: 'i-ri:patreon-fill',
discord: 'i-ri:discord-fill',
}
export function getDisplayName(account?: Account, options?: { rich?: boolean }) {
const displayName = account?.displayName || account?.username || ''
if (options?.rich)