From 306d709cc7525cc316b83a1011b767c967d6facb Mon Sep 17 00:00:00 2001 From: Mplan Date: Fri, 21 Aug 2026 02:46:28 +0800 Subject: [PATCH] =?UTF-8?q?refactor(api):=20=E5=AF=B9=E9=BD=90=E5=90=8E?= =?UTF-8?q?=E7=AB=AF=E5=AD=97=E6=AE=B5=EF=BC=8C=E7=A7=BB=E9=99=A4=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=E8=87=86=E9=80=A0=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/cloud/CloudEditModal.vue | 2 +- src/components/cloud/QuickUploadModal.vue | 2 +- src/lib/api.ts | 15 ++------------- src/lib/cloudTypes.ts | 20 ++++++++++---------- src/stores/auth.ts | 2 +- src/stores/profile.ts | 12 +++--------- src/types/api.ts | 9 ++------- src/types/database.ts | 6 +----- src/views/admin/AdminView.vue | 6 +++--- src/views/encyclopedia/CloudTypeView.vue | 2 +- src/views/encyclopedia/EncyclopediaView.vue | 2 +- src/views/gallery/GalleryView.vue | 7 +------ src/views/map/MapView.vue | 5 +---- src/views/profile/ProfileView.vue | 5 ++--- src/views/upload/UploadView.vue | 2 +- 15 files changed, 31 insertions(+), 66 deletions(-) diff --git a/src/components/cloud/CloudEditModal.vue b/src/components/cloud/CloudEditModal.vue index 4a68bd1..936fe71 100644 --- a/src/components/cloud/CloudEditModal.vue +++ b/src/components/cloud/CloudEditModal.vue @@ -141,7 +141,7 @@ watch(() => props.initialValue, value => { > diff --git a/src/components/cloud/QuickUploadModal.vue b/src/components/cloud/QuickUploadModal.vue index 2e99a20..f4249d6 100644 --- a/src/components/cloud/QuickUploadModal.vue +++ b/src/components/cloud/QuickUploadModal.vue @@ -271,7 +271,7 @@ onBeforeUnmount(() => { >

{{ activeItem.errors.cloudCategory }}

diff --git a/src/lib/api.ts b/src/lib/api.ts index ab3cfa1..92ccb03 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -141,16 +141,11 @@ export function toAuthUser(profile: BackendUserProfile): AuthUser { return { id: profile.id, email: profile.email, - // Protected profile routes reject unverified accounts, so a successfully - // loaded current profile is necessarily email-verified. - email_verified: true, username: profile.name, - avatar_url: null, + avatar_id: profile.avatar_id, role: profile.role, is_disabled: profile.is_disabled, cloud_count: profile.cloud_count, - public_cloud_count: profile.cloud_count, - collection_count: 0, received_like_count: profile.received_like_count, created_at: profile.created_at, } @@ -160,14 +155,12 @@ export function toCloudType(row: BackendCloudType): CloudType { return { id: row.id, name: row.name, - name_en: row.genus || '', genus: row.genus || '', // Compatibility value for the excluded legacy admin view. Migrated pages // display rarity_value directly because API.md defines no semantic mapping. rarity: 'common', rarity_value: row.rarity, description: row.description, - icon_url: null, created_at: row.created_at, } } @@ -177,12 +170,10 @@ export function toApiCloud(row: BackendCloudInfo): ApiCloud { id: row.id, user_id: row.owner.id, cloud_type_id: row.type.id, - custom_cloud_type: null, image_url: imageUrl(row.id, 'original'), thumbnail_url: imageUrl(row.id, 'preview'), latitude: row.latitude, longitude: row.longitude, - location_name: null, description: row.description, captured_at: row.captured_at, status: row.status, @@ -192,7 +183,6 @@ export function toApiCloud(row: BackendCloudInfo): ApiCloud { cloud_type: { id: row.type.id, name: row.type.name, - name_en: row.type.genus || '', rarity: 'common', rarity_value: row.type.rarity, }, @@ -201,7 +191,6 @@ export function toApiCloud(row: BackendCloudInfo): ApiCloud { cloud_type_rarity: 'common', cloud_type_rarity_value: row.type.rarity, username: row.owner.name, - favorite_count: row.received_like_count, - is_favorited: false, + received_like_count: row.received_like_count, } } diff --git a/src/lib/cloudTypes.ts b/src/lib/cloudTypes.ts index a39464d..94b8821 100644 --- a/src/lib/cloudTypes.ts +++ b/src/lib/cloudTypes.ts @@ -1,14 +1,14 @@ export const CLOUD_TYPES = [ - { id: 1, name: '积云', nameEn: 'Cumulus' }, - { id: 2, name: '层云', nameEn: 'Stratus' }, - { id: 3, name: '卷云', nameEn: 'Cirrus' }, - { id: 4, name: '积雨云', nameEn: 'Cumulonimbus' }, - { id: 5, name: '层积云', nameEn: 'Stratocumulus' }, - { id: 6, name: '高积云', nameEn: 'Altocumulus' }, - { id: 7, name: '高层云', nameEn: 'Altostratus' }, - { id: 8, name: '雨层云', nameEn: 'Nimbostratus' }, - { id: 9, name: '卷层云', nameEn: 'Cirrostratus' }, - { id: 10, name: '卷积云', nameEn: 'Cirrocumulus' }, + { id: 1, name: '积云' }, + { id: 2, name: '层云' }, + { id: 3, name: '卷云' }, + { id: 4, name: '积雨云' }, + { id: 5, name: '层积云' }, + { id: 6, name: '高积云' }, + { id: 7, name: '高层云' }, + { id: 8, name: '雨层云' }, + { id: 9, name: '卷层云' }, + { id: 10, name: '卷积云' }, ] as const export function getCloudTypeName(id: string | string[]) { diff --git a/src/stores/auth.ts b/src/stores/auth.ts index 450d684..df4def1 100644 --- a/src/stores/auth.ts +++ b/src/stores/auth.ts @@ -19,7 +19,7 @@ export const useAuthStore = defineStore('auth', () => { profile.value = { id: normalized.id, username: normalized.username, - avatar_url: normalized.avatar_url, + avatar_id: normalized.avatar_id, role: normalized.role, is_disabled: normalized.is_disabled, created_at: normalized.created_at, diff --git a/src/stores/profile.ts b/src/stores/profile.ts index d30bf00..c3822e2 100644 --- a/src/stores/profile.ts +++ b/src/stores/profile.ts @@ -8,12 +8,10 @@ import type { Profile } from '@/types/database' export interface ProfileCloudItem { id: string cloud_type_id: number - custom_cloud_type: null image_url: string thumbnail_url: string latitude: number longitude: number - location_name: null description: string | null captured_at: string | null created_at: string @@ -21,20 +19,17 @@ export interface ProfileCloudItem { is_hidden: boolean cloudTypeName: string cloudTypeRarity: number - favoriteCount: number - isFavorited: false + receivedLikeCount: number } function toProfileCloud(row: ApiCloud): ProfileCloudItem { return { id: row.id, cloud_type_id: row.cloud_type_id as number, - custom_cloud_type: null, image_url: row.image_url, thumbnail_url: row.thumbnail_url as string, latitude: row.latitude as number, longitude: row.longitude as number, - location_name: null, description: row.description, captured_at: row.captured_at, created_at: row.created_at, @@ -42,8 +37,7 @@ function toProfileCloud(row: ApiCloud): ProfileCloudItem { is_hidden: row.is_hidden, cloudTypeName: row.cloud_type_name || '未知', cloudTypeRarity: row.cloud_type_rarity_value ?? 0, - favoriteCount: row.favorite_count, - isFavorited: false, + receivedLikeCount: row.received_like_count, } } @@ -112,7 +106,7 @@ export const useProfileStore = defineStore('profile-page', () => { profilesByKey.value[identifier] = { id: owner?.id || identifier, username: owner?.name || identifier, - avatar_url: null, + avatar_id: null, role: 'user', is_disabled: false, created_at: '', diff --git a/src/types/api.ts b/src/types/api.ts index f3838f7..13b1b57 100644 --- a/src/types/api.ts +++ b/src/types/api.ts @@ -65,14 +65,11 @@ export interface CloudCreateResponse extends ActionResponse { export interface AuthUser { id: string email: string - email_verified: boolean username: string - avatar_url: string | null + avatar_id: string | null role: Profile['role'] is_disabled: boolean cloud_count: number - public_cloud_count: number - collection_count: number received_like_count: number created_at: string } @@ -88,7 +85,6 @@ export interface ApiPage { export interface ApiCloudTypeSummary { id: number name: string - name_en: string rarity: CloudType['rarity'] rarity_value: number } @@ -106,8 +102,7 @@ export interface ApiCloud extends Cloud { cloud_type_rarity: CloudType['rarity'] | null cloud_type_rarity_value: number | null username: string | null - favorite_count: number - is_favorited: boolean + received_like_count: number } export interface AdminStats { diff --git a/src/types/database.ts b/src/types/database.ts index 55703d7..610144a 100644 --- a/src/types/database.ts +++ b/src/types/database.ts @@ -1,12 +1,10 @@ export interface CloudType { id: number name: string - name_en: string genus: string rarity: 'common' | 'uncommon' | 'rare' rarity_value: number description: string | null - icon_url: string | null created_at: string } @@ -14,12 +12,10 @@ export interface Cloud { id: string user_id: string cloud_type_id: number | null - custom_cloud_type: string | null image_url: string thumbnail_url: string | null latitude: number | null longitude: number | null - location_name: string | null description: string | null captured_at: string | null status: 'pending' | 'approved' | 'rejected' @@ -30,7 +26,7 @@ export interface Cloud { export interface Profile { id: string username: string - avatar_url: string | null + avatar_id: string | null role: 'user' | 'admin' is_disabled: boolean created_at: string diff --git a/src/views/admin/AdminView.vue b/src/views/admin/AdminView.vue index 0479f19..d42293a 100644 --- a/src/views/admin/AdminView.vue +++ b/src/views/admin/AdminView.vue @@ -178,18 +178,18 @@ function toAdminCloud(row: ApiCloud): AdminCloud { id: row.id, user_id: row.user_id, cloud_type_id: row.cloud_type_id, - custom_cloud_type: row.custom_cloud_type, + custom_cloud_type: null, image_url: row.image_url, thumbnail_url: row.thumbnail_url, latitude: row.latitude, longitude: row.longitude, - location_name: row.location_name, + location_name: null, description: row.description, captured_at: row.captured_at, created_at: row.created_at, status: row.status, is_hidden: row.is_hidden, - cloudTypeName: row.cloud_type_name || row.custom_cloud_type || '未知云型', + cloudTypeName: row.cloud_type_name || '未知云型', cloudTypeRarity: row.cloud_type_rarity || 'common', username: row.username || '匿名用户', } diff --git a/src/views/encyclopedia/CloudTypeView.vue b/src/views/encyclopedia/CloudTypeView.vue index 77a4ae5..af9fa3a 100644 --- a/src/views/encyclopedia/CloudTypeView.vue +++ b/src/views/encyclopedia/CloudTypeView.vue @@ -90,7 +90,7 @@ watch(() => route.params.id, () => loadPage())
稀有度 {{ cloudType.rarity_value }}

{{ cloudType.name }}

-

{{ cloudType.name_en || '未提供云属名称' }}

+

{{ cloudType.genus || '未提供云属名称' }}

diff --git a/src/views/encyclopedia/EncyclopediaView.vue b/src/views/encyclopedia/EncyclopediaView.vue index 9b9e46b..44d536b 100644 --- a/src/views/encyclopedia/EncyclopediaView.vue +++ b/src/views/encyclopedia/EncyclopediaView.vue @@ -44,7 +44,7 @@ onMounted(() => encyclopediaStore.fetchCloudTypes())

{{ cloudType.name }}

- {{ cloudType.name_en || '未提供云属名称' }} + {{ cloudType.genus || '未提供云属名称' }}

diff --git a/src/views/gallery/GalleryView.vue b/src/views/gallery/GalleryView.vue index a9c5ae0..2a7023e 100644 --- a/src/views/gallery/GalleryView.vue +++ b/src/views/gallery/GalleryView.vue @@ -17,10 +17,8 @@ interface GalleryCloud { id: string user_id: string cloud_type_id: number | null - custom_cloud_type: string | null image_url: string thumbnail_url: string | null - location_name: string | null description: string | null latitude: number | null longitude: number | null @@ -88,10 +86,8 @@ function toGalleryCloud(row: ApiCloud) { id: row.id, user_id: row.user_id, cloud_type_id: row.cloud_type_id, - custom_cloud_type: row.custom_cloud_type, image_url: row.image_url, thumbnail_url: row.thumbnail_url, - location_name: row.location_name, description: row.description, latitude: row.latitude, longitude: row.longitude, @@ -99,7 +95,7 @@ function toGalleryCloud(row: ApiCloud) { created_at: row.created_at, status: row.status, is_hidden: row.is_hidden, - cloudTypeName: row.cloud_type_name || row.custom_cloud_type || '未知', + cloudTypeName: row.cloud_type_name || '未知', cloudTypeRarity: row.cloud_type_rarity_value ?? 0, username: row.username || '匿名', } satisfies GalleryCloud @@ -554,7 +550,6 @@ onUnmounted(() => {