From eb37d58b00bc8b6cda8331c8b1283632328a0b7b Mon Sep 17 00:00:00 2001 From: ce-amtic Date: Sun, 7 Apr 2024 16:11:18 +0800 Subject: [PATCH 1/9] style(users): added blank-page on question and answer --- src/components/user/UserCard.vue | 2 +- src/views/user/Answer.vue | 106 +++++++++++++++++++------------ src/views/user/Question.vue | 11 +++- 3 files changed, 74 insertions(+), 45 deletions(-) diff --git a/src/components/user/UserCard.vue b/src/components/user/UserCard.vue index 8b2f0e4..46816ec 100644 --- a/src/components/user/UserCard.vue +++ b/src/components/user/UserCard.vue @@ -104,7 +104,7 @@ color="black" :to="{ name: 'UserFollowing', params: { id: $route.params.id } }" > - {{ profile.fans_count }}
关注 + {{ profile.fans_count }}
关注 | - - {{ item.id }} - -

{{ item.author.nickname }}:{{ item.content }}

-
- - - mdi-menu-up - {{ item.attitudes.difference }} - - - mdi-menu-down - - - mdi-comment-outline - {{ item.comment_count }}评论 - - - mdi-star-outline - {{ item.favorite_count }}收藏 - - - mdi-dots-horizontal - - + + + + @@ -33,28 +41,42 @@ import { ref, onMounted, computed } from 'vue' import { UserApi } from '@/network/api/users' import { useRoute } from 'vue-router' -import { Answer } from '@/types' -import { Page } from '@/types' +import { usePaging } from '@/utils/paging' +import BlankPage from '@/components/common/BlankPage.vue' const route = useRoute() const userID = computed(() => parseInt(route.params.id[0], 10)) -const answerList = ref([]) -const pageData = ref() -const loaded = ref(false) +const isEmpty = ref(true) -onMounted(async () => { - await fetchData() -}) - -async function fetchData() { +const { + data: answerList, + refresh, + refreshing, +} = usePaging(async () => { const { - data: { answers, page }, + data: { answers: data, page }, } = await UserApi.getAnswerList(userID.value, { pageStart: 0, pageSize: 10, }) - answerList.value = answers - pageData.value = page - loaded.value = true -} + isEmpty.value = data.length === 0 + return { data, page } +}) + +onMounted(refresh) +// onMounted(async () => { +// await fetchData() +// }) + +// async function fetchData() { +// const { +// data: { answers, page }, +// } = await UserApi.getAnswerList(userID.value, { +// pageStart: 0, +// pageSize: 10, +// }) +// answerList.value = answers +// pageData.value = page +// isEmpty.value = answers.length === 0 +// } diff --git a/src/views/user/Question.vue b/src/views/user/Question.vue index 3770aee..f1c949c 100644 --- a/src/views/user/Question.vue +++ b/src/views/user/Question.vue @@ -5,18 +5,24 @@ + + + @@ -264,4 +347,19 @@ const submit = handleSubmit((values) => { padding-top: 0; padding-bottom: 0; } +.overlay { + position: absolute; + z-index: 10; + width: 175px; + height: 175px; + background-color: rgba(0, 0, 0, 0); + display: flex; + justify-content: center; + align-items: center; + transition: background-color 0.3s; +} + +.overlay:hover { + background-color: rgba(0, 0, 0, 0.5); +} From c9d68363a1303e6df0f4c5810d22920ac9fe4d2f Mon Sep 17 00:00:00 2001 From: ce-amtic Date: Mon, 8 Apr 2024 15:09:45 +0800 Subject: [PATCH 8/9] fix(users): switch from avatar url to avatarId --- src/layouts/user/User.vue | 6 ++++++ src/utils/user.ts | 6 ++++++ 2 files changed, 12 insertions(+) create mode 100644 src/utils/user.ts diff --git a/src/layouts/user/User.vue b/src/layouts/user/User.vue index e579b35..84afe3f 100644 --- a/src/layouts/user/User.vue +++ b/src/layouts/user/User.vue @@ -42,6 +42,7 @@ const fetchData = async (userId: number) => { data: { user }, } = await UserApi.getUserInfo(userId) userData.value = user + // console.log(user) loaded.value = true } @@ -54,9 +55,14 @@ onBeforeRouteUpdate(async (to, from) => { } }) +const userRefresh = async () => { + await fetchData(userId.value) +} + console.log(route) provide('userData', userData) +provide('userRefresh', userRefresh) const links = [ { diff --git a/src/utils/user.ts b/src/utils/user.ts new file mode 100644 index 0000000..6b37baf --- /dev/null +++ b/src/utils/user.ts @@ -0,0 +1,6 @@ +// import { AvatarApi } from '@/network/api/avatars' +import { API_BASE_URL } from '@/network/utils' + +export const getUrlByAvatarId = (avatarId: number) => { + return API_BASE_URL + '/avatars/' + avatarId +} From dee12b22827c3d4fe3661e1b7c572dafc1cf6f14 Mon Sep 17 00:00:00 2001 From: ce-amtic Date: Mon, 8 Apr 2024 15:10:25 +0800 Subject: [PATCH 9/9] refactor(users): added loading animations --- src/components/answer/AnswerCard.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/answer/AnswerCard.vue b/src/components/answer/AnswerCard.vue index d3cab98..77bc212 100644 --- a/src/components/answer/AnswerCard.vue +++ b/src/components/answer/AnswerCard.vue @@ -5,7 +5,7 @@ {{ answer.author.nickname }} {{ answer.author.intro }}