From a60def91a09bd406f86d12a03a7f866452946ef4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=8E=AB=E5=94=90=E5=B0=BC?= Date: Sun, 14 Jun 2026 17:36:13 +0800 Subject: [PATCH] =?UTF-8?q?feat(gallery):=20=E5=AE=9E=E7=8E=B0=E7=9B=B8?= =?UTF-8?q?=E5=86=8C=E5=8A=9F=E8=83=BD=E5=AF=B9=E6=8E=A5=E5=90=8E=E7=AB=AF?= =?UTF-8?q?API=EF=BC=8C=E6=9B=BF=E6=8D=A2=E9=9D=99=E6=80=81=E6=A8=A1?= =?UTF-8?q?=E6=8B=9F=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 重构相册页面,使用真实的Halo图片插件API获取分组与图片数据 2. 新增图片预览工具函数,支持大图预览 3. 更新滚动加载hook,补充响应式原始数据与加载状态控制 4. 调整相册面板组件参数与样式,适配真实数据展示 5. 修复开发环境接口地址配置 --- env/.env.development | 3 +- src/api/halo-plugin/photo.ts | 33 +- .../uh-gallery-panel/uh-gallery-panel.vue | 61 +-- src/hooks/useHaloScroll.ts | 12 +- src/pages/gallery/gallery-bak.vue | 348 ++++++++++++++++ src/pages/gallery/gallery.vue | 394 ++++++++---------- src/utils/imageHelper.ts | 18 + 7 files changed, 615 insertions(+), 254 deletions(-) create mode 100644 src/pages/gallery/gallery-bak.vue diff --git a/env/.env.development b/env/.env.development index 32b178a..c09bd8b 100644 --- a/env/.env.development +++ b/env/.env.development @@ -7,4 +7,5 @@ VITE_SHOW_SOURCEMAP=false # development mode 后台请求地址 # VITE_UNI_HALO_BASEURL='https://www.yijunzhao.cn' -VITE_UNI_HALO_BASEURL='https://www.xhhao.com' +# VITE_UNI_HALO_BASEURL='https://www.xhhao.com' +VITE_UNI_HALO_BASEURL='https://ryanc.cc' diff --git a/src/api/halo-plugin/photo.ts b/src/api/halo-plugin/photo.ts index 116d5a1..b07d605 100644 --- a/src/api/halo-plugin/photo.ts +++ b/src/api/halo-plugin/photo.ts @@ -18,6 +18,27 @@ export interface IQueryPhotosRequest { size?: number } +export interface IPhotoGroup { + metadata: { + creationTimestamp: string + generateName: string + name: string + version: string + } + spec: { + displayName: string + priority: number + } + status: { + photoCount: number + } +} + +export interface IPhotoTag { + name: string + photoCount: number +} + export interface IPhoto { metadata: { creationTimestamp: string @@ -36,12 +57,10 @@ export interface IPhoto { /** * 获取图库分组列表 - * @param params 获取图库分组列表请求参数 * @returns 获取图库分组列表响应参数 */ -export function queryPhotoGroups(params: IQueryPhotoGroupsRequest) { - return http.Get(`/apis/api.photo.halo.run/v1alpha1/photogroups`, { - params, +export function queryPhotoGroups() { + return http.Get>(`/apis/api.photo.halo.run/v1alpha1/photogroups`, { meta: { isHalo: true, }, @@ -51,10 +70,11 @@ export function queryPhotoGroups(params: IQueryPhotoGroupsRequest) { /** * 获取图库标签列表 列出所有不重复的标签名称及对应图片数量,支持可选的 name 参数进行大小写不敏感模糊过滤 * @param params 获取图库标签列表请求参数 + * @param params.name 标签名称 * @returns 获取图库标签列表响应参数 */ -export function queryPhotoTags(params: any) { - return http.Get(`/apis/api.photo.halo.run/v1alpha1/tags`, { +export function queryPhotoTags(params: { name?: string }) { + return http.Get>(`/apis/api.photo.halo.run/v1alpha1/tags`, { params, meta: { isHalo: true, @@ -70,6 +90,7 @@ export function queryPhotoTags(params: any) { export function queryPhotos(params: IQueryPhotosRequest) { return http.Get>(`/apis/api.photo.halo.run/v1alpha1/photos`, { params, + cacheFor: null, meta: { isHalo: true, }, diff --git a/src/components/uh-gallery-panel/uh-gallery-panel.vue b/src/components/uh-gallery-panel/uh-gallery-panel.vue index d3c2f37..9fcbf22 100644 --- a/src/components/uh-gallery-panel/uh-gallery-panel.vue +++ b/src/components/uh-gallery-panel/uh-gallery-panel.vue @@ -3,10 +3,12 @@ import { queryPhotos } from '@/api/halo-plugin/photo' import { completeUrl } from '@/utils/url' import { useHaloScroll } from '@/hooks/useHaloScroll' import { random } from '@/utils/base/random' +import { preview } from '@/utils/imageHelper' import type { IPhoto, IQueryPhotosRequest } from '@/api/halo-plugin/photo' interface IProps { - groupName: string + groupMetadataName: string + groupDisplayName: string } const props = defineProps() @@ -16,6 +18,7 @@ const emits = defineEmits<{ }>() const { + response, // 响应式的原始数据响应 list, // 响应式的数据列表 loading, // 是否加载中 finished, // 是否已全部加载 @@ -27,6 +30,7 @@ const { params: { page: 1, size: 12, + group: props.groupMetadataName.trim() ?? undefined, }, }) @@ -36,61 +40,62 @@ function getImageItemClass() { const randomIndex = random(0, imageItemClass.length - 1) return imageItemClass[randomIndex] } + +function handlePreview(item: IPhoto) { + preview(completeUrl(item.spec.url), list.value.map(item => completeUrl(item.spec.url))) +}