From 1ea027e4f1c0ab8b33777307bf9a7e146b710525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=87=E8=B6=A3=E4=BF=9D=E7=BD=97?= Date: Fri, 23 Jan 2026 22:19:37 +0800 Subject: [PATCH] Feat: Add Settings Modal --- src/App.vue | 108 ++++++++++---- src/components/biz/settings-modal.vue | 200 ++++++++++++++++++++++++++ src/components/ui/drawer.vue | 85 +++++++++++ src/composables/use-photo-columns.ts | 38 +++++ 4 files changed, 405 insertions(+), 26 deletions(-) create mode 100644 src/components/biz/settings-modal.vue create mode 100644 src/components/ui/drawer.vue create mode 100644 src/composables/use-photo-columns.ts diff --git a/src/App.vue b/src/App.vue index d585cde..f31df30 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,8 +1,10 @@ + + diff --git a/src/components/ui/drawer.vue b/src/components/ui/drawer.vue new file mode 100644 index 0000000..5bd8d56 --- /dev/null +++ b/src/components/ui/drawer.vue @@ -0,0 +1,85 @@ + + + + + + diff --git a/src/composables/use-photo-columns.ts b/src/composables/use-photo-columns.ts new file mode 100644 index 0000000..22a98f6 --- /dev/null +++ b/src/composables/use-photo-columns.ts @@ -0,0 +1,38 @@ +import { computed, type Ref } from "vue"; + +interface MediaItem { + id: number; + title: string; + content: string; + url: string; + thumb_url: string; + meta: string; + take_time: string; + width?: number; + height?: number; +} + +/** + * 计算宫格图片对象的 hooks + * @param photos 照片数组 + * @param gridCount 宫格数量,可以是数字或 Ref,默认为 4 + * @returns 返回一个 computed,包含按宫格数分配的图片数组 + */ +export function usePhotoColumns( + photos: Ref, + gridCount: number | Ref = 4 +) { + const columns = computed(() => { + const count = typeof gridCount === 'number' ? gridCount : gridCount.value; + const result: MediaItem[][] = Array.from({ length: count }, () => []); + + photos.value.forEach((photo, index) => { + const columnIndex = index % count; + result[columnIndex].push(photo); + }); + + return result; + }); + + return columns; +}