-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathAuthorCard.vue
More file actions
93 lines (82 loc) · 2.37 KB
/
Copy pathAuthorCard.vue
File metadata and controls
93 lines (82 loc) · 2.37 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<template lang="pug">
.author-card
.author-inner(v-if='user')
.flex-center
.left
RouterLink(
:aria-label='"查看作者: " + user.name',
:to='"/users/" + user.userId'
)
img(:alt='user.name + " 的头像"', :src='user.imageBig')
.right
.flex
h4.plain
RouterLink(:to='"/users/" + user.userId') {{ user.name }}
NButton(
:loading='loadingUserFollow',
:type='user.isFollowed ? "success" : undefined'
@click='handleUserFollow'
round
secondary
size='small'
v-if='user.userId !== userStore.userId'
)
template(#icon)
IFasCheck(v-if='user.isFollowed')
IFasPlus(v-else)
| {{ user.isFollowed ? '已关注' : '关注' }}
NEllipsis.description.pre(:line-clamp='3', :tooltip='false') {{ user.comment }}
ArtworkList.tiny(:list='user.illusts' inline)
.author-placeholder(v-else)
.flex-center
.left: a: NSkeleton(circle height='80px' text width='80px')
.right
h4.plain: NSkeleton(height='1.6em' text width='12em')
NSkeleton(block height='3em' width='100%')
ArtworkList.tiny(:list='[]' inline loading)
</template>
<script lang="ts" setup>
import ArtworkList from './Artwork/ArtworkList.vue'
import type { User } from '~/types'
import { NButton, NEllipsis, NSkeleton } from 'naive-ui'
import IFasCheck from '~icons/fa-solid/check'
import IFasPlus from '~icons/fa-solid/plus'
import { useUserStore } from '~/composables/session'
const userStore = useUserStore()
const props = defineProps<{
user?: User
}>()
const loadingUserFollow = ref(false)
function handleUserFollow() {
if (!props.user || loadingUserFollow.value) return
const user = props.user
loadingUserFollow.value = true
const isFollowed = user.isFollowed
const handler = isFollowed
? pixivClient.unfollowUser(user.userId)
: pixivClient.followUser(user.userId)
handler
.then(() => {
user.isFollowed = !isFollowed
})
.finally(() => {
loadingUserFollow.value = false
})
}
</script>
<style scoped lang="sass">
.left
margin-right: 1rem
img
border-radius: 50%
width: 80px
height: 80px
.right
flex: 1
h4
margin: 0.2rem 0
flex: 1
font-weight: 700
:deep(.artworks-list .author)
display: none
</style>