Skip to content

Commit

Permalink
✨ 使用后端提供的头像url
Browse files Browse the repository at this point in the history
  • Loading branch information
shoucandanghehe committed Sep 12, 2024
1 parent 55917ec commit e03dd06
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 51 deletions.
2 changes: 1 addition & 1 deletion src/shared/components/avatar.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts" setup>
import Avatar from '@/shared/types/avatar'
import Avatar from '@/shared/schemas/avatar.ts'
import Identicon from 'identicon.js'
import { isString } from 'remeda'
Expand Down
8 changes: 0 additions & 8 deletions src/shared/types/avatar.d.ts

This file was deleted.

28 changes: 0 additions & 28 deletions src/v2/components/common/avatar.vue

This file was deleted.

1 change: 1 addition & 0 deletions src/v2/components/tests/tetrio_user_list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const test = async () => {
return {
id: user._id,
name: user.username,
avatar: '',
country: user.country ?? null,
verified: user.verified,
Expand Down
6 changes: 4 additions & 2 deletions src/v2/pages/tetrio/record/40l/_user.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<script lang="ts" setup>
import avatar from '@/v2/components/common/avatar.vue'
import AvatarCard from '@/shared/components/avatar.vue'
import type AvatarType from '@/shared/schemas/avatar.ts'
defineProps<{
readonly id: string
readonly name: string
readonly avatar: AvatarType
}>()
</script>

<template>
<n-card class="w-fit">
<div class="flex flex-col justify-center items-center h-full">
<n-flex align="center" vertical>
<avatar :user_id="id" class="[&,&>img]:size-32"/>
<avatar-card :avatar="avatar" class="[&,&>img]:size-32"/>

<n-text class="text-(6 current) fw-bold leading-none">
{{ name }}
Expand Down
2 changes: 1 addition & 1 deletion src/v2/pages/tetrio/record/40l/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const type = computed(() => {
/>

<n-flex :wrap="false">
<sprint_user :id="data.user.id" :name="data.user.name"/>
<sprint_user :id="data.user.id" :avatar="data.user.avatar" :name="data.user.name"/>

<n-flex class="flex-1" vertical>
<n-flex :wrap="false">
Expand Down
6 changes: 4 additions & 2 deletions src/v2/pages/tetrio/record/blitz/_user.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<script lang="ts" setup>
import avatar from '@/v2/components/common/avatar.vue'
import AvatarCard from '@/shared/components/avatar.vue'
import type AvatarType from '@/shared/schemas/avatar.ts'
defineProps<{
readonly id: string
readonly name: string
readonly avatar: AvatarType
}>()
</script>

<template>
<n-card class="w-fit">
<div class="flex flex-col justify-center items-center h-full">
<n-flex align="center" vertical>
<avatar :user_id="id" class="[&,&>img]:size-32"/>
<avatar-card :avatar="avatar" class="[&,&>img]:size-32"/>

<n-text class="text-(6 current) fw-bold leading-none">
{{ name }}
Expand Down
4 changes: 2 additions & 2 deletions src/v2/pages/tetrio/record/blitz/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const type = computed(() => {
/>

<n-flex :wrap="false">
<blitz_user :id="data.user.id" :name="data.user.name"/>
<blitz_user :id="data.user.id" :avatar="data.user.avatar" :name="data.user.name"/>

<n-flex class="flex-1" vertical>
<n-flex :wrap="false">
Expand Down Expand Up @@ -105,4 +105,4 @@ const type = computed(() => {

<style lang="scss">
@import "@/v2/styles/main";
</style>
</style>
6 changes: 4 additions & 2 deletions src/v2/pages/tetrio/user/info/_header.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<script lang="ts" setup>
import AvatarCard from '@/shared/components/avatar.vue'
import type AvatarType from '@/shared/schemas/avatar.ts'
import logo from '@/v2/assets/images/logos/tetrio.svg'
import avatar from '@/v2/components/common/avatar.vue'
import country from '@/v2/components/common/country.vue'
import { HeartFilled, StarFilled } from '@vicons/antd'
import { isNonNullish } from 'remeda'
const props = defineProps<{
readonly banner: string | null
readonly avatar: AvatarType
readonly name: string
readonly id: string
Expand All @@ -28,7 +30,7 @@ const { define: LogoDefine, reuse: Logo } = createReusableTemplate()
<div>
<n-flex size="small" vertical>
<n-flex align="center" size="small">
<avatar :user_id="id" class="[&,&>img]:size-12"/>
<avatar-card :avatar="avatar" class="[&,&>img]:size-12"/>

<n-flex :size="0" vertical>
<n-text class="text-(6 current) fw-bold leading-none">
Expand Down
1 change: 1 addition & 0 deletions src/v2/pages/tetrio/user/info/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ import { isNonNullish } from 'remeda'
<layout content_class="max-w-320">
<info_header
:id="data.user.id"
:avatar="data.user.avatar"
:banner="data.user.banner"
:country="data.user.country"
:friend_count="data.user.friend_count"
Expand Down
7 changes: 4 additions & 3 deletions src/v2/pages/tetrio/user/list/_user.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts" setup>
import avatar from '@/v2/components/common/avatar.vue'
import AvatarCard from '@/shared/components/avatar.vue'
import type AvatarType from '@/shared/schemas/avatar.ts'
import country from '@/v2/components/common/country.vue'
import { calculateXpLevel } from '@/v2/core/utils/xp.ts'
import { isNonNullish } from 'remeda'
Expand All @@ -10,6 +10,7 @@ const props = defineProps<{
readonly id: string
readonly name: string
readonly avatar: AvatarType
readonly country: string | null
readonly xp: number
}>()
Expand All @@ -21,7 +22,7 @@ const props = defineProps<{
<n-text class="text-4 fw-bold" type="info">#{{ index }}</n-text>
</template>

<avatar :user_id="id" class="[&,&>img]:size-12"/>
<avatar-card :avatar="avatar" class="[&,&>img]:size-12"/>

<n-flex :size="0" vertical>
<n-text class="text-(5 current) leading-none fw-bold">
Expand Down
5 changes: 3 additions & 2 deletions src/v2/pages/tetrio/user/list/index.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<script lang="ts">
import User from '@/shared/schemas/user.ts'
import { z } from 'zod'
const Data = z
.object({
show_index: z.boolean(),
users: z.array(
z.object({
User.extend({
id: z.string(),
name: z.string(),
country: z.string().nullable(),
tetra_league: z.object({
Expand Down Expand Up @@ -63,6 +63,7 @@ const checkDecaying = (user: Data['users'][number]) => {
<n-flex justify="space-between">
<list_user
:id="user.id"
:avatar="user.avatar"
:country="user.country"
:index="data.show_index ? index + 1 : null"
:name="user.name"
Expand Down

0 comments on commit e03dd06

Please sign in to comment.