mirror of
https://github.com/ialley-workshop-open/uni-halo.git
synced 2026-11-13 22:11:42 +08:00
refactor: 完成项目多模块优化与功能迭代
本次提交包含多项优化与功能更新: 1. 关闭本地开发模式,准备正式发布 2. 重构空状态按钮,统一使用刷新按钮替代加载按钮 3. 优化导航栏样式与返回按钮细节 4. 为图库页面添加图片标题展示与阴影优化 5. 关闭相册接口缓存,确保数据实时性 6. 重构相册查看组件,改为内部自动请求数据并优化布局 7. 优化投票页面样式与配色 8. 重构搜索页面代码结构与细节样式 9. 优化恋爱相册页面布局与交互体验
This commit is contained in:
@@ -1,16 +1,22 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { getLoveAlbumByName } from '@/api/uni-halo'
|
||||
import { checkImageUrl } from '@/utils/url'
|
||||
import { sleep } from '@/utils/common'
|
||||
import { DataLoadingStatusEnum, useDataLoadingStatus } from '@/hooks/useDataLoadingStatus'
|
||||
import type { ILoveAlbum } from '@/api/types/uni-halo'
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
show : boolean
|
||||
albumName ?: string
|
||||
photos ?: IAlbumPhoto[]
|
||||
loading ?: boolean
|
||||
/** 相册 key(详情请求参数) */
|
||||
albumKey ?: string
|
||||
/** 解锁 token(加密相册已解锁时传入) */
|
||||
token ?: string
|
||||
}>(), {
|
||||
albumName: '',
|
||||
photos: () => [],
|
||||
loading: false,
|
||||
albumKey: '',
|
||||
token: '',
|
||||
})
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -28,24 +34,39 @@
|
||||
}
|
||||
|
||||
const isShow = ref(false)
|
||||
|
||||
watch(() => props.show, (val) => {
|
||||
isShow.value = val
|
||||
})
|
||||
const { loadingStatus, updateLoadingStatus } = useDataLoadingStatus()
|
||||
const photos = ref<IAlbumPhoto[]>([])
|
||||
|
||||
/** 预处理图片路径(相对路径拼接 BASE_API) */
|
||||
const photoList = computed<IAlbumPhoto[]>(() =>
|
||||
(props.photos || []).map(photo => ({
|
||||
photos.value.map(photo => ({
|
||||
...photo,
|
||||
url: checkImageUrl(photo.url || ''),
|
||||
})),
|
||||
)
|
||||
|
||||
/** 左列(偶数位照片,瀑布流错落) */
|
||||
const leftPhotos = computed(() => photoList.value.filter((_, index) => index % 2 === 0))
|
||||
/** 内部自请求:获取相册详情并填充照片 */
|
||||
async function handleLoadPhotos() {
|
||||
updateLoadingStatus(DataLoadingStatusEnum.Loading)
|
||||
try {
|
||||
const detail = await getLoveAlbumByName(props.albumKey, { token: props.token })
|
||||
photos.value = (detail.data as unknown as ILoveAlbum)?.photos || []
|
||||
await sleep(600)
|
||||
updateLoadingStatus(photos.value.length === 0 ? DataLoadingStatusEnum.Empty : DataLoadingStatusEnum.Success)
|
||||
}
|
||||
catch (e) {
|
||||
console.error('获取相册照片失败', e)
|
||||
updateLoadingStatus(DataLoadingStatusEnum.Error)
|
||||
}
|
||||
}
|
||||
|
||||
/** 右列(奇数位照片) */
|
||||
const rightPhotos = computed(() => photoList.value.filter((_, index) => index % 2 === 1))
|
||||
watch(() => props.show, (val) => {
|
||||
isShow.value = val
|
||||
if (val) {
|
||||
photos.value = []
|
||||
handleLoadPhotos()
|
||||
}
|
||||
})
|
||||
|
||||
function handleClose() {
|
||||
isShow.value = false
|
||||
@@ -71,88 +92,61 @@
|
||||
safe-area-inset-bottom @close="handleClose">
|
||||
<view class="box-border h-full w-full flex flex-col gap-y-3 p-4">
|
||||
<!-- 头部 -->
|
||||
<view class="w-full shrink-0 flex items-center justify-between">
|
||||
<view class="font-bold flex items-center gap-x-1">
|
||||
<view class="w-full flex shrink-0 items-center justify-between">
|
||||
<view class="flex items-center gap-x-1 font-bold">
|
||||
{{ albumName }}
|
||||
</view>
|
||||
<view
|
||||
class="w-6 h-6 uh-global-card-glass border uh-shadow-xs flex items-center justify-center rounded-lg"
|
||||
class="uh-global-card-glass uh-shadow-xs h-6 w-6 flex items-center justify-center border rounded-lg"
|
||||
@click="handleClose">
|
||||
<wd-icon name="close" size="32rpx"></wd-icon>
|
||||
<wd-icon name="close" size="32rpx" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 照片列表 -->
|
||||
<scroll-view class="box-border max-h-[50vh] flex-1" scroll-y :show-scrollbar="false">
|
||||
<view v-if="loading" class="viewer-empty box-border h-full flex items-center justify-center p-10">
|
||||
<view class="viewer-loading flex flex-col items-center">
|
||||
<view class="loading-text mt-7 text-[28rpx] text-[#56bbf9]">
|
||||
照片正在努力加载中啦~
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-else-if="photoList.length === 0"
|
||||
class="viewer-empty box-border h-full flex items-center justify-center p-10">
|
||||
<wd-empty description="这个相册暂时还没有照片~" />
|
||||
</view>
|
||||
<view v-else class="photo-list box-border flex items-start p-5">
|
||||
<!-- 左列 -->
|
||||
<view class="photo-column box-border min-w-0 flex-1 mr-[20rpx]">
|
||||
<view v-for="photo in leftPhotos" :key="photo.name"
|
||||
class="photo-card mb-6 box-border overflow-hidden rounded-xl bg-white shadow-sm">
|
||||
<image class="photo-image w-full" :src="photo.url" mode="widthFix" lazy-load
|
||||
@click="handlePreview(photo.url)" />
|
||||
<view class="photo-info box-border px-6 py-5">
|
||||
<view v-if="photo.title" class="photo-title mb-3 text-[30rpx] text-[#333] font-bold">
|
||||
{{ photo.title }}
|
||||
</view>
|
||||
<view v-if="photo.takenDate || photo.location"
|
||||
class="photo-meta mb-3 flex flex-wrap items-center">
|
||||
<text v-if="photo.takenDate"
|
||||
class="meta-item mr-8 text-[24rpx] text-[#999]">{{ photo.takenDate }}</text>
|
||||
<text v-if="photo.location"
|
||||
class="meta-item mr-8 text-[24rpx] text-[#999]">{{ photo.location }}</text>
|
||||
</view>
|
||||
<view v-if="photo.description"
|
||||
class="photo-desc text-[26rpx] text-[#666] leading-[1.6]">
|
||||
{{ photo.description }}
|
||||
</view>
|
||||
<!-- 加载/错误/空占位(状态机) -->
|
||||
<uh-data-loading v-if="loadingStatus !== DataLoadingStatusEnum.Success" :use-refresh-button="false"
|
||||
:loading-status="loadingStatus" error-text="照片加载失败,请点击刷新重试" empty-text="这个相册暂时还没有照片~"
|
||||
min-height="40vh" @refresh="handleLoadPhotos" />
|
||||
<view v-else class="box-border grid grid-cols-2 gap-2">
|
||||
<view v-for="photo in photoList" :key="photo.name"
|
||||
class="relative box-border overflow-hidden uh-global-card-glass rounded-xl">
|
||||
<image class="w-full h-46 block" :src="photo.url" mode="aspectFill" lazy-load
|
||||
@click="handlePreview(photo.url)" />
|
||||
<view
|
||||
class="absolute bottom-0 w-full box-border p-3 pt-4 z-2 bg-gradient-to-b from-white/0 to-white/60">
|
||||
<view v-if="photo.title" class="mb-1 text-xs text-love font-bold">
|
||||
{{ photo.title }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 右列 -->
|
||||
<view class="photo-column box-border min-w-0 flex-1">
|
||||
<view v-for="photo in rightPhotos" :key="photo.name"
|
||||
class="photo-card mb-6 box-border overflow-hidden rounded-xl bg-white shadow-sm">
|
||||
<image class="photo-image w-full" :src="photo.url" mode="widthFix" lazy-load
|
||||
@click="handlePreview(photo.url)" />
|
||||
<view class="photo-info box-border px-6 py-5">
|
||||
<view v-if="photo.title" class="photo-title mb-3 text-[30rpx] text-[#333] font-bold">
|
||||
{{ photo.title }}
|
||||
</view>
|
||||
<view v-if="photo.takenDate || photo.location"
|
||||
class="photo-meta mb-3 flex flex-wrap items-center">
|
||||
<text v-if="photo.takenDate"
|
||||
class="meta-item mr-8 text-[24rpx] text-[#999]">{{ photo.takenDate }}</text>
|
||||
<text v-if="photo.location"
|
||||
class="meta-item mr-8 text-[24rpx] text-[#999]">{{ photo.location }}</text>
|
||||
</view>
|
||||
<view v-if="photo.description"
|
||||
class="photo-desc text-[26rpx] text-[#666] leading-[1.6]">
|
||||
{{ photo.description }}
|
||||
</view>
|
||||
<view v-if="photo.description" class="mb-1 text-xs text-white leading-5">
|
||||
{{ photo.description }}
|
||||
</view>
|
||||
<view v-if="photo.takenDate || photo.location"
|
||||
class="flex flex-col gap-y-1">
|
||||
<text v-if="photo.takenDate" class="text-xs text-white">
|
||||
<wd-icon name="time-line"></wd-icon> {{ photo.takenDate }}
|
||||
</text>
|
||||
<text v-if="photo.location" class="text-xs text-white">
|
||||
<wd-icon name="location"></wd-icon> {{ photo.location }}
|
||||
</text>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<!-- 底部关闭 -->
|
||||
<view class="w-full shrink-0">
|
||||
<uh-button custom-class="py-2 uh-global-card-glass rounded-xl !bg-love/90 text-white border"
|
||||
<view class="w-full shrink-0 flex items-center justify-center gap-x-2">
|
||||
<uh-button custom-class="py-2 flex-1 uh-global-card-glass border rounded-xl bg-white/90"
|
||||
@click="handleClose">
|
||||
关闭
|
||||
</uh-button>
|
||||
<uh-button custom-class="flex-1 py-2 uh-global-card-glass rounded-xl !bg-love/90 text-white border"
|
||||
@click="handleLoadPhotos">
|
||||
刷新
|
||||
</uh-button>
|
||||
</view>
|
||||
</view>
|
||||
</uh-glass-popup>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
loadingSubText ?: string
|
||||
errorSubText ?: string
|
||||
emptySubText ?: string
|
||||
useLoadingButton ?: boolean
|
||||
useRefreshButton ?: boolean
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<IProps>(), {
|
||||
@@ -28,7 +28,7 @@
|
||||
loadingSubText: '',
|
||||
errorSubText: '请检查网络连接,或稍后再试',
|
||||
emptySubText: '稍后再来看看吧~',
|
||||
useLoadingButton: true,
|
||||
useRefreshButton: true,
|
||||
})
|
||||
|
||||
const emit = defineEmits<{ (e : 'refresh') : void }>()
|
||||
@@ -106,8 +106,8 @@
|
||||
<text v-if="statusScene.subText" class="mt-3 text-xs text-gray-500">
|
||||
{{ statusScene.subText }}
|
||||
</text>
|
||||
<view v-if="props.useLoadingButton" class="mt-5 uh-global-card-glass uh-shadow-xs border rounded-lg">
|
||||
<uh-button custom-class="!rounded-lg" @click="emit('refresh')">
|
||||
<view v-if="props.useRefreshButton" class="mt-5">
|
||||
<uh-button custom-class="!rounded-lg uh-global-card-glass uh-shadow-xs border rounded-lg" @click="emit('refresh')">
|
||||
刷新试试
|
||||
</uh-button>
|
||||
</view>
|
||||
|
||||
@@ -95,11 +95,11 @@
|
||||
<!-- 左边 -->
|
||||
<view class="shrink-0 min-w-18" @click="handleBack()">
|
||||
<view v-if="props.useBack"
|
||||
class="uh-global-card-glass h-7 px-3 rounded-full border flex items-center gap-x-2 text-sm"
|
||||
class="uh-global-card-glass uh-shadow-xs h-8 px-3 rounded-full border flex items-center gap-x-2 text-sm"
|
||||
:class="props.backClass" :style="[props.backStyle]">
|
||||
<wd-icon name="arrow-left" size="32rpx"></wd-icon>
|
||||
<wd-icon name="arrow-left" size="34rpx"></wd-icon>
|
||||
<view class="w-[1px] h-4 bg-white/60" />
|
||||
<text class="text-xs font-bold">返回</text>
|
||||
<text class="text-sm font-bold">返回</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 中间 -->
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<uh-glass-popup v-model="isShow" position="center" :z-index="9999" radius="24rpx" @close="handleClose">
|
||||
<uh-glass-popup v-model="isShow" position="center" :z-index="9999" custom-class="rounded-xl" @close="handleClose">
|
||||
<view v-if="notice" class="box-border w-[80vw] p-4">
|
||||
<!-- 头部:标题 + 关闭 -->
|
||||
<view class="flex items-center justify-between">
|
||||
|
||||
Reference in New Issue
Block a user