From 1194d56d094c4db4093b6c31f09b32baae8e6acf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90=20Kevin=20Deng?= Date: Sat, 26 Nov 2022 16:33:32 +0800 Subject: [PATCH] feat: always show account server (#119) --- components/account/AccountHandle.vue | 16 ++++++++++++++++ components/account/AccountHeader.vue | 10 ++++------ components/account/AccountInfo.vue | 4 +--- composables/masto.ts | 6 +++++- 4 files changed, 26 insertions(+), 10 deletions(-) create mode 100644 components/account/AccountHandle.vue diff --git a/components/account/AccountHandle.vue b/components/account/AccountHandle.vue new file mode 100644 index 00000000..2f3b1981 --- /dev/null +++ b/components/account/AccountHandle.vue @@ -0,0 +1,16 @@ + + + diff --git a/components/account/AccountHeader.vue b/components/account/AccountHeader.vue index 97d22e68..c291f2de 100644 --- a/components/account/AccountHeader.vue +++ b/components/account/AccountHeader.vue @@ -66,9 +66,7 @@ function previewAvatar() {
-

- {{ getShortHandle(account) }} -

+
@@ -94,13 +92,13 @@ function previewAvatar() {
- + {{ formattedNumber(account.statusesCount) }} Posts - + {{ humanReadableNumber(account.followingCount) }} Following - + {{ humanReadableNumber(account.followersCount) }} Followers
diff --git a/components/account/AccountInfo.vue b/components/account/AccountInfo.vue index 3ea73f72..fd384d23 100644 --- a/components/account/AccountInfo.vue +++ b/components/account/AccountInfo.vue @@ -20,9 +20,7 @@ const accountHandle = $(useAccountHandle(account, fullServer)) -

- {{ accountHandle }} -

+
diff --git a/composables/masto.ts b/composables/masto.ts index fc319a94..caf04639 100644 --- a/composables/masto.ts +++ b/composables/masto.ts @@ -35,6 +35,10 @@ export const STATUS_VISIBILITIES = [ }, ] as const +export function getServerName(account: Account) { + return account.url.match(UserLinkRE)?.[1] || currentUser.value?.server || '' +} + export function getDisplayName(account: Account) { return account.displayName || account.username } @@ -47,7 +51,7 @@ export function getFullHandle(account: Account) { const handle = `@${account.acct}` if (!currentUser.value || account.acct.includes('@')) return handle - return `${handle}@${account.url.match(UserLinkRE)?.[1] || currentUser.value.server}` + return `${handle}@${getServerName(account)}` } export function toShortHandle(fullHandle: string) {