From 2177541de3a8f0e25cd3472ceb4d9573de512fa5 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, 13 Sep 2026 03:03:26 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=9B=B8=E5=86=8C=E8=A7=A3?= =?UTF-8?q?=E9=94=81=E5=BC=B9=E7=AA=97=E5=A4=8D=E7=94=A8=20uh-unlock-popup?= =?UTF-8?q?=20=E9=80=9A=E7=94=A8=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit album.vue 弃用独立 uh-album-unlock-popup,改用通用解锁弹窗: 解锁请求/成功回调注入,解锁成功自动打开相册查看,行为与原一致; 删除不再使用的 unlockAlbumKey --- src/pages-blog/love/album.vue | 73 +++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 28 deletions(-) diff --git a/src/pages-blog/love/album.vue b/src/pages-blog/love/album.vue index 414f6ff..3e6f020 100644 --- a/src/pages-blog/love/album.vue +++ b/src/pages-blog/love/album.vue @@ -2,7 +2,8 @@ import { computed, ref } from 'vue' import { onLoad, onPageScroll, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app' import dayjs from 'dayjs' -import { getLoveAlbumByName, getLoveAlbums } from '@/api/uni-halo' +import { getLoveAlbumByName, getLoveAlbums, unlockAlbum } from '@/api/uni-halo' +import type { ICaptchaQuery } from '@/api/uni-halo' import { useAppConfigStore } from '@/store/appConfig' import { checkImageUrl } from '@/utils/url' import { getCache, setCache } from '@/utils/storage' @@ -106,7 +107,6 @@ const showPhotoViewer = ref(false) const currentViewerAlbum = ref(null) const unlockAlbumName = computed(() => currentUnlockAlbum.value?.displayName || '') -const unlockAlbumKey = computed(() => currentUnlockAlbum.value?.name || '') const viewerAlbumName = computed(() => currentViewerAlbum.value?.displayName || '') const viewerAlbumKey = computed(() => currentViewerAlbum.value?.name || '') const viewerAlbumToken = computed(() => currentViewerAlbum.value @@ -219,13 +219,28 @@ function handleOpenPhotoViewer(item: ILoveAlbumCard) { // 照片数据由 uh-album-photo-viewer 内部自请求(见组件 handleLoadPhotos) } -function handleOnUnlockSuccess(data: { albumKey: string, token: string, photos: unknown[] }) { - unlockedAlbums.value[data.albumKey] = data.token +/** 相册解锁请求(uh-unlock-popup 注入;返回含 token + photos 表示成功) */ +async function handleAlbumUnlockRequest(password: string, captcha?: ICaptchaQuery | null) { + const album = currentUnlockAlbum.value + if (!album) { + return null + } + const res = await unlockAlbum(album.name, password, captcha) + return res.data as { token?: string, photos?: unknown[] } | null | undefined +} + +/** 相册解锁成功:存 token + photos,自动打开相册查看 */ +function handleAlbumUnlockSuccess(data: { token?: string, photos?: unknown[] }) { + const album = currentUnlockAlbum.value + if (!album || !data.token) { + return + } + unlockedAlbums.value[album.name] = data.token handleSaveUnlockedAlbums() - const albumIndex = dataList.value.findIndex(a => a.name === data.albumKey) + const albumIndex = dataList.value.findIndex(a => a.name === album.name) if (albumIndex !== -1) { - dataList.value[albumIndex].photos = data.photos as ILovePhoto[] + dataList.value[albumIndex].photos = (data.photos || []) as ILovePhoto[] dataList.value[albumIndex].locked = false } currentUnlockAlbum.value = null @@ -257,7 +272,9 @@ onLoad(() => { async function handlePageInit() { handleRestoreUnlockedAlbums() await appConfigStore.bootstrap() - if (!ensureUnlocked()) { return } + if (!ensureUnlocked()) { + return + } canLoad.value = true handleGetData() } @@ -287,16 +304,13 @@ onReachBottom(() => {