diff --git a/GALLERY-README.md b/GALLERY-README.md new file mode 100644 index 0000000..a0fdf99 --- /dev/null +++ b/GALLERY-README.md @@ -0,0 +1,141 @@ +# Gallery 配置驱动系统 + +## ✨ 已完成的改造 + +### 新增文件结构 + +``` +gallery/ +├── src/ +│ ├── data/ +│ │ └── gallery-config.js ← 核心配置文件(所有图片路径在这里) +│ ├── components/ +│ │ └── sections/ +│ │ ├── HeroSection.astro ← 首屏大图组件 +│ │ ├── FullBleedSection.astro ← 全屏单图组件 +│ │ ├── QuadGridSection.astro ← 四宫格组件 +│ │ ├── DualSection.astro ← 双栏组件 +│ │ └── GridSection.astro ← 网格布局组件 +│ └── pages/ +│ └── index.astro ← 主页(动态渲染) +└── public/ + └── media/ ← 所有图片资源存放处 +``` + +## 🚀 快速开始 + +### 1. 复制图片到项目 + +```bash +cd /Users/sinlee/Documents/git-repos/gallery +chmod +x copy-photos.sh +./copy-photos.sh +``` + +### 2. 启动开发服务器 + +```bash +pnpm dev +``` + +然后访问 `http://localhost:4321` + +## 📸 当前图片布局 + +根据你的图片命名,我已经这样组织了内容: + +1. **首屏** - 四人合照 (`0123_1.JPG`) +2. **全屏单图** - 另一张合照 (`0123_2.JPG`) +3. **四宫格** - 0号人物的四张照片 (`0_1` 到 `0_4`) +4. **双栏** - 23号合照 + 1号单人 +5. **网格** - 2号和3号的照片 +6. **全屏结尾** - 0号照片 + +## 🎨 如何修改布局 + +### 只需编辑一个文件:`src/data/gallery-config.js` + +#### 示例 1:修改首屏图片 + +```javascript +hero: { + image: '/media/0123_2.JPG', // 改成其他图片 + title: '新的标题', + subtitle: '新的副标题' +} +``` + +#### 示例 2:添加新的四宫格 + +在 `sections` 数组中添加: + +```javascript +{ + type: 'quad-grid', + title: '新的四宫格', + images: [ + '/media/1_1.JPG', + '/media/2_1.JPG', + '/media/2_2.JPG', + '/media/3_1.JPG' + ] +} +``` + +#### 示例 3:添加双栏布局 + +```javascript +{ + type: 'dual', + cards: [ + { + image: '/media/0_1.JPG', + title: '左边标题', + description: '左边描述' + }, + { + image: '/media/1_1.JPG', + title: '右边标题', + description: '右边描述' + } + ] +} +``` + +## 📦 支持的布局类型 + +- `hero` - 首屏大图 +- `full-bleed` - 全屏单图(支持 left/right/center 对齐) +- `quad-grid` - 四宫格(2x2) +- `dual` - 双栏布局 +- `grid` - 灵活网格(支持 large 和 normal 尺寸) + +## 🔄 部署到 VPS + +修改完成后: + +```bash +git add . +git commit -m "更新 gallery 配置" +git push +``` + +自动部署会触发,几秒后就能在 `https://show.leexxx.com` 看到更新! + +## 💡 提示 + +- **图片路径**:相对于 `public/` 目录,所以 `/media/xxx.jpg` 对应 `public/media/xxx.jpg` +- **图片格式**:支持 JPG, PNG, WebP +- **添加图片**:只需把新图片放到 `public/media/` 然后在配置文件中引用即可 +- **调整顺序**:在 `sections` 数组中调整顺序即可改变页面布局顺序 + +## 🎯 图片命名规则(你的照片) + +- `0_X.JPG` - 0号人物的照片 +- `1_X.JPG` - 1号人物的照片 +- `2_X.JPG` - 2号人物的照片 +- `3_X.JPG` - 3号人物的照片 +- `0123_X.JPG` - 四人合照 +- `23_X.JPG` - 2号和3号的合照 + +你可以根据这些照片自由组织任何布局! diff --git a/copy-photos.sh b/copy-photos.sh new file mode 100755 index 0000000..85cb849 --- /dev/null +++ b/copy-photos.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# 复制图片到 gallery 项目 +echo "开始复制图片..." + +# 源目录 +SOURCE_DIR="/Users/sinlee/photo_test" +# 目标目录 +TARGET_DIR="/Users/sinlee/Documents/git-repos/gallery/public/media" + +# 检查源目录是否存在 +if [ ! -d "$SOURCE_DIR" ]; then + echo "错误: 源目录不存在: $SOURCE_DIR" + exit 1 +fi + +# 检查目标目录是否存在,不存在则创建 +if [ ! -d "$TARGET_DIR" ]; then + mkdir -p "$TARGET_DIR" + echo "创建目标目录: $TARGET_DIR" +fi + +# 复制所有 JPG 文件 +cp "$SOURCE_DIR"/*.JPG "$TARGET_DIR"/ + +if [ $? -eq 0 ]; then + echo "✅ 图片复制成功!" + echo "已复制的文件:" + ls -lh "$TARGET_DIR"/*.JPG +else + echo "❌ 复制失败" + exit 1 +fi + +echo "" +echo "下一步: 在项目目录执行 pnpm dev 启动开发服务器" diff --git a/public/media/0123_1.JPG b/public/media/0123_1.JPG new file mode 100755 index 0000000..53f597b Binary files /dev/null and b/public/media/0123_1.JPG differ diff --git a/public/media/0123_2.JPG b/public/media/0123_2.JPG new file mode 100755 index 0000000..c88eb19 Binary files /dev/null and b/public/media/0123_2.JPG differ diff --git a/public/media/0_1.JPG b/public/media/0_1.JPG new file mode 100755 index 0000000..f665423 Binary files /dev/null and b/public/media/0_1.JPG differ diff --git a/public/media/0_2.JPG b/public/media/0_2.JPG new file mode 100755 index 0000000..8e9db5d Binary files /dev/null and b/public/media/0_2.JPG differ diff --git a/public/media/0_3.JPG b/public/media/0_3.JPG new file mode 100644 index 0000000..c98df53 Binary files /dev/null and b/public/media/0_3.JPG differ diff --git a/public/media/0_4.JPG b/public/media/0_4.JPG new file mode 100644 index 0000000..f8c18ec Binary files /dev/null and b/public/media/0_4.JPG differ diff --git a/public/media/1_1.JPG b/public/media/1_1.JPG new file mode 100755 index 0000000..0cd0614 Binary files /dev/null and b/public/media/1_1.JPG differ diff --git a/public/media/23_1.JPG b/public/media/23_1.JPG new file mode 100755 index 0000000..ce3ce65 Binary files /dev/null and b/public/media/23_1.JPG differ diff --git a/public/media/2_1.JPG b/public/media/2_1.JPG new file mode 100755 index 0000000..8dbe1ef Binary files /dev/null and b/public/media/2_1.JPG differ diff --git a/public/media/2_2.JPG b/public/media/2_2.JPG new file mode 100644 index 0000000..4e32836 Binary files /dev/null and b/public/media/2_2.JPG differ diff --git a/public/media/3_1.JPG b/public/media/3_1.JPG new file mode 100755 index 0000000..1d59d51 Binary files /dev/null and b/public/media/3_1.JPG differ diff --git a/src/components/sections/DualSection.astro b/src/components/sections/DualSection.astro new file mode 100644 index 0000000..7fc836e --- /dev/null +++ b/src/components/sections/DualSection.astro @@ -0,0 +1,113 @@ +--- +interface Card { + image: string; + title: string; + description: string; +} + +interface Props { + cards: Card[]; +} + +const { cards } = Astro.props; +--- + +
+
+ {cards.map((card, index) => ( +
+
+ {card.title} +
+
+

{card.title}

+

{card.description}

+
+
+ ))} +
+
+ + diff --git a/src/components/sections/FullBleedSection.astro b/src/components/sections/FullBleedSection.astro new file mode 100644 index 0000000..2cb0c26 --- /dev/null +++ b/src/components/sections/FullBleedSection.astro @@ -0,0 +1,109 @@ +--- +interface Props { + image: string; + title: string; + description: string; + align: 'left' | 'right' | 'center'; +} + +const { image, title, description, align } = Astro.props; +--- + +
+
+ {title} +
+
+

{title}

+

{description}

+
+
+ + diff --git a/src/components/sections/GridSection.astro b/src/components/sections/GridSection.astro new file mode 100644 index 0000000..7ed8007 --- /dev/null +++ b/src/components/sections/GridSection.astro @@ -0,0 +1,112 @@ +--- +interface GridItem { + image: string; + size: 'large' | 'normal'; +} + +interface Props { + items: GridItem[]; +} + +const { items } = Astro.props; +--- + +
+
+ {items.map((item, index) => ( +
+ {`Gallery +
+ ))} +
+
+ + diff --git a/src/components/sections/HeroSection.astro b/src/components/sections/HeroSection.astro new file mode 100644 index 0000000..31bebe9 --- /dev/null +++ b/src/components/sections/HeroSection.astro @@ -0,0 +1,141 @@ +--- +interface Props { + image: string; + title: string; + subtitle: string; +} + +const { image, title, subtitle } = Astro.props; +--- + +
+
+ {title} +
+
+
+

{title}

+

{subtitle}

+
+ 向下探索 + + + +
+
+
+ + + + diff --git a/src/components/sections/QuadGridSection.astro b/src/components/sections/QuadGridSection.astro new file mode 100644 index 0000000..a31db01 --- /dev/null +++ b/src/components/sections/QuadGridSection.astro @@ -0,0 +1,89 @@ +--- +interface Props { + title?: string; + images: string[]; +} + +const { title, images } = Astro.props; +--- + +
+ {title &&

{title}

} +
+ {images.map((img, index) => ( +
+ {`Image +
+ ))} +
+
+ + diff --git a/src/data/gallery-config.js b/src/data/gallery-config.js new file mode 100644 index 0000000..1b1a03f --- /dev/null +++ b/src/data/gallery-config.js @@ -0,0 +1,79 @@ +// 画廊配置 - 所有布局和资源的单一数据源 +export const galleryConfig = { + // 首屏大图 - 使用四人合照 + hero: { + type: 'hero', + image: '/media/0123_1.JPG', + title: '时光印记', + subtitle: '定格美好瞬间,记录青春故事' + }, + + // 内容区块 - 按顺序渲染 + sections: [ + // 1. 全屏单图 - 另一张合照 + { + type: 'full-bleed', + align: 'left', + image: '/media/0123_2.JPG', + title: '相聚时刻', + description: '珍贵的回忆,永恒的友谊' + }, + + // 2. 四宫格 - 0号人物的四张照片 + { + type: 'quad-grid', + title: '个人时光', + images: [ + '/media/0_1.JPG', + '/media/0_2.JPG', + '/media/0_3.JPG', + '/media/0_4.JPG' + ] + }, + + // 3. 左右双栏 - 2&3号合照 和 1号单人 + { + type: 'dual', + cards: [ + { + image: '/media/23_1.JPG', + title: '双人组合', + description: '默契的搭档' + }, + { + image: '/media/1_1.JPG', + title: '独特视角', + description: '一个人的精彩' + } + ] + }, + + // 4. 网格布局 - 混合展示 + { + type: 'grid', + items: [ + { + image: '/media/2_1.JPG', + size: 'large' + }, + { + image: '/media/2_2.JPG', + size: 'normal' + }, + { + image: '/media/3_1.JPG', + size: 'normal' + } + ] + }, + + // 5. 全屏单图 - 收尾 + { + type: 'full-bleed', + align: 'right', + image: '/media/0_1.JPG', + title: '青春不散场', + description: '愿时光不老,我们不散' + } + ] +}; diff --git a/src/pages/index.astro b/src/pages/index.astro index 20a96b4..494b548 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,281 +1,84 @@ --- -import Layout from '../layouts/Layout.astro'; +import { galleryConfig } from '../data/gallery-config.js'; -// Hero 大画幅展示图片 -const heroImage = { - src: 'https://images.unsplash.com/photo-1682687220742-aba13b6e50ba?w=2400&h=1600&fit=crop', - title: '视界之外', - subtitle: '每一次快门,都是时间的诗', +// 导入所有组件 +import HeroSection from '../components/sections/HeroSection.astro'; +import FullBleedSection from '../components/sections/FullBleedSection.astro'; +import DualSection from '../components/sections/DualSection.astro'; +import GridSection from '../components/sections/GridSection.astro'; +import QuadGridSection from '../components/sections/QuadGridSection.astro'; + +// 组件映射表 +const componentMap = { + 'hero': HeroSection, + 'full-bleed': FullBleedSection, + 'dual': DualSection, + 'grid': GridSection, + 'quad-grid': QuadGridSection }; - -// 展示作品集合 - 支持不同布局类型 -const sections = [ - { - type: 'full-bleed', // 全出血大图 - image: 'https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=2000&h=1200&fit=crop', - title: '山川湖海', - description: '在自然中寻找内心的宁静', - align: 'left' - }, - { - type: 'dual', // 双图并排 - images: [ - { - src: 'https://images.unsplash.com/photo-1514565131-fce0801e5785?w=1000&h=1200&fit=crop', - title: '都市脉搏', - description: '霓虹闪烁的夜晚' - }, - { - src: 'https://images.unsplash.com/photo-1511988617509-a57c8a288659?w=1000&h=1200&fit=crop', - title: '人间烟火', - description: '最真实的生活瞬间' - } - ] - }, - { - type: 'stacked', // 层叠卡片 - images: [ - { - src: 'https://images.unsplash.com/photo-1486718448742-163732cd1544?w=1200&h=800&fit=crop', - title: '几何诗篇', - offset: { x: 0, y: 0, rotate: -2 } - }, - { - src: 'https://images.unsplash.com/photo-1541701494587-cb58502866ab?w=1200&h=800&fit=crop', - title: '色彩交响', - offset: { x: 40, y: 40, rotate: 3 } - }, - { - src: 'https://images.unsplash.com/photo-1505142468610-359e7d316be0?w=1200&h=800&fit=crop', - title: '海天一色', - offset: { x: 80, y: 80, rotate: -1 } - } - ] - }, - { - type: 'grid', // 网格展示 - images: [ - { src: 'https://images.unsplash.com/photo-1682687220742-aba13b6e50ba?w=800&h=800&fit=crop', span: 'large' }, - { src: 'https://images.unsplash.com/photo-1682687221038-404670f09439?w=600&h=600&fit=crop' }, - { src: 'https://images.unsplash.com/photo-1682687220063-4742bd7fd538?w=600&h=600&fit=crop' }, - { src: 'https://images.unsplash.com/photo-1682687220923-c58b9a4592ae?w=600&h=600&fit=crop' }, - { src: 'https://images.unsplash.com/photo-1682687221080-5cb261c645cb?w=600&h=600&fit=crop' }, - ] - }, - { - type: 'full-bleed', - image: 'https://images.unsplash.com/photo-1682687220015-186f63b8850a?w=2000&h=1200&fit=crop', - title: '时光印记', - description: '定格永恒的瞬间', - align: 'right' - } -]; --- - + + + + + + + Gallery | 时光印记 + + +
- -
-
- {heroImage.title} -
-
-
-

{heroImage.title}

-

{heroImage.subtitle}

-
- 向下探索 - - - -
-
-
+ + - - {sections.map((section, index) => { - if (section.type === 'full-bleed') { - return ( -
-
- {section.title} -
-
-

{section.title}

-

{section.description}

-
-
- ); - } - - if (section.type === 'dual') { - return ( -
-
- {section.images.map((img, i) => ( -
-
- {img.title} -
-
-

{img.title}

-

{img.description}

-
-
- ))} -
-
- ); - } - - if (section.type === 'stacked') { - return ( -
-
- {section.images.map((img, i) => ( -
- {img.title} -
{img.title}
-
- ))} -
-
- ); - } - - if (section.type === 'grid') { - return ( -
-
- {section.images.map((img, i) => ( -
- {`Gallery -
- ))} -
-
- ); - } + + {galleryConfig.sections.map((section, index) => { + const Component = componentMap[section.type]; + return Component ? ( + + ) : null; })} - +
-

探索更多

-

每一张作品背后,都有一个独特的故事

- +

时光不老,我们不散

+

感谢每一个美好的瞬间

-
+ + -