File size: 9,946 Bytes
0daf81d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
import { useEffect, useRef, useState } from 'react'
import { Check, Copy, Download, Pause, Play, Volume2 } from 'lucide-react'
import { pack, type LiveItem, type LiveSet } from '@/data/livePack'

const asset = (p: string) => `${import.meta.env.BASE_URL}live/${p}?v=${pack.version}`


function LiveCard({ item, active, onPlay }: { item: LiveItem; active: boolean; onPlay: (id: string | null) => void }) {
  const ref = useRef<HTMLVideoElement>(null)
  const [playing, setPlaying] = useState(false)

  useEffect(() => {
    const v = ref.current
    if (!v) return
    if (active) {
      v.currentTime = 0
      v.muted = false
      v.play().catch(() => {
        v.muted = true
        v.play().catch(() => undefined)
      })
    } else {
      v.pause()
    }
  }, [active])

  return (
    <figure className="group flex flex-col gap-3">
      <button
        type="button"
        onClick={() => onPlay(active ? null : item.id)}
        className="relative aspect-[3/4] w-full overflow-hidden rounded-[22px] bg-neutral-900 ring-1 ring-white/10 transition hover:ring-white/30"
        aria-label={`播放第 ${item.index} 张实况:${item.zh}`}
      >
        <img
          src={asset(item.cover)}
          alt={`${item.zh} 实况图封面`}
          loading="lazy"
          className={`absolute inset-0 h-full w-full object-cover transition-opacity duration-300 ${playing ? 'opacity-0' : 'opacity-100'}`}
        />
        <video
          ref={ref}
          src={asset(item.preview)}
          playsInline
          preload="none"
          onPlaying={() => setPlaying(true)}
          onPause={() => setPlaying(false)}
          onEnded={() => {
            setPlaying(false)
            onPlay(null)
          }}
          className="absolute inset-0 h-full w-full object-cover"
        />
        <span className="absolute left-3 top-3 inline-flex items-center gap-1 rounded-full bg-black/45 px-2.5 py-1 text-[11px] font-semibold tracking-wide text-white backdrop-blur">
          <span className="inline-block h-2.5 w-2.5 rounded-full border-[1.5px] border-white" />
          LIVE
        </span>
        <span className="absolute bottom-3 right-3 inline-flex h-10 w-10 items-center justify-center rounded-full bg-white/90 text-neutral-900 shadow-lg transition group-hover:scale-105">
          {active && playing ? <Pause className="h-4 w-4" /> : <Play className="ml-0.5 h-4 w-4" />}
        </span>
      </button>
      <figcaption className="flex items-baseline justify-between gap-2 px-1">
        <div className="min-w-0">
          <div className="text-[13px] text-neutral-400">
            {String(item.index).padStart(2, '0')} · {item.zh} · {item.cat}
          </div>
          <div className="truncate text-lg font-semibold text-white">{item.en}</div>
          <div className="text-sm text-neutral-400">{item.ipa}</div>
        </div>
        <div className="shrink-0 text-right text-xs text-neutral-500">
          {item.duration.toFixed(1)} 秒
          <br />
          <span className="inline-flex items-center gap-1">
            <Volume2 className="h-3 w-3" />
            有声
          </span>
        </div>
      </figcaption>
    </figure>
  )
}

function CopyBlock({ label, text }: { label: string; text: string }) {
  const [done, setDone] = useState(false)
  return (
    <div className="rounded-2xl border border-white/10 bg-white/[0.03] p-4">
      <div className="mb-2 flex items-center justify-between">
        <span className="text-sm font-medium text-neutral-300">{label}</span>
        <button
          type="button"
          onClick={() => {
            navigator.clipboard?.writeText(text).then(() => {
              setDone(true)
              setTimeout(() => setDone(false), 1500)
            })
          }}
          className="inline-flex items-center gap-1 rounded-full border border-white/15 px-3 py-1 text-xs text-neutral-200 hover:bg-white/10"
        >
          {done ? <Check className="h-3.5 w-3.5" /> : <Copy className="h-3.5 w-3.5" />}
          {done ? '已复制' : '复制'}
        </button>
      </div>
      <p className="whitespace-pre-line text-[15px] leading-7 text-neutral-100">{text}</p>
    </div>
  )
}

function SetSection({ set, active, onPlay }: { set: LiveSet; active: string | null; onPlay: (id: string | null) => void }) {
  return (
    <section className="mt-14 border-t border-white/10 pt-10">
      <div className="mb-6 flex flex-col gap-4 md:flex-row md:items-end md:justify-between">
        <div>
          <h2 className="text-2xl font-bold">{set.name}</h2>
          <p className="mt-2 text-sm text-neutral-400">{set.items.map((i) => i.zh).join(' · ')}</p>
        </div>
        <div className="flex flex-col items-start gap-2 md:items-end">
          <a
            href={asset(set.zip)}
            download
            className="inline-flex items-center gap-2 rounded-full bg-white px-6 py-3 text-base font-semibold text-neutral-900 transition hover:bg-neutral-200"
          >
            <Download className="h-5 w-5" />
            下载这一组 JPG + MOV
          </a>
          <span className="text-xs text-neutral-500">
            ZIP · {set.zipMB.toFixed(1)} MB · {set.items.length} 组实况
          </span>
        </div>
      </div>
      <div className="grid grid-cols-2 gap-x-4 gap-y-8 sm:gap-x-6 lg:grid-cols-3">
        {set.items.map((it) => (
          <LiveCard key={it.id} item={it} active={active === it.id} onPlay={onPlay} />
        ))}
      </div>
      <div className="mt-10 grid gap-4 lg:grid-cols-2">
        <CopyBlock label="标题" text={set.copy.title} />
        <CopyBlock label="正文 + 话题" text={set.copy.body} />
      </div>
      {set.credits.length > 0 && (
        <div className="mt-8">
          <h3 className="mb-3 text-base font-semibold">图片来源与授权</h3>
          <div className="overflow-hidden rounded-2xl border border-white/10">
            <table className="w-full text-left text-sm">
              <tbody>
                {set.credits.map((c) => (
                  <tr key={c.id} className="border-t border-white/5 first:border-t-0">
                    <td className="px-4 py-2.5 text-neutral-300">
                      {c.zh} · {c.en}
                    </td>
                    <td className="px-4 py-2.5 text-neutral-400">
                      <span className="line-clamp-1">{c.author}</span>
                    </td>
                    <td className="px-4 py-2.5">
                      <a href={c.page} target="_blank" rel="noopener noreferrer" className="text-neutral-200 underline decoration-white/30 underline-offset-4 hover:decoration-white">
                        {c.license}
                      </a>
                    </td>
                  </tr>
                ))}
              </tbody>
            </table>
          </div>
          <p className="mt-3 text-xs leading-5 text-neutral-500">
            照片来自 Wikimedia Commons,均为允许商用的知识共享或公有领域授权。CC BY / BY-SA 授权要求注明作者,发布时建议在正文或评论区写上「图片来源:Wikimedia Commons」及作者。
          </p>
        </div>
      )}
    </section>
  )
}

export default function PackGallery() {
  const [active, setActive] = useState<string | null>(null)
  const total = pack.sets.reduce((n, s) => n + s.items.length, 0)
  return (
    <div>
      <div>
        <header className="max-w-2xl">
          <p className="mb-3 text-sm font-medium text-[#ff3b5c]">
            实况图素材包 · {pack.sets.length} 组 {total} 张 · 竖屏 3:4
          </p>
          <h1 className="text-4xl font-black leading-tight tracking-tight sm:text-5xl">这个用英语怎么说?</h1>
          <p className="mt-4 text-base leading-7 text-neutral-400">
            封面是一张生活照,卡片里向网友提问(第三组为看图填空);长按实况后,字母逐个打出,单词揭晓,配音标、中文释义、英语发音(美式女声,放得下时再加一遍男声慢读)和音效。每张不超过 3 秒,可直接发微信朋友圈。点击下方任意一张预览(带声音)。
          </p>
        </header>

        {pack.sets.map((s) => (
          <SetSection key={s.key} set={s} active={active} onPlay={setActive} />
        ))}

        <section className="mt-16 border-t border-white/10 pt-10">
          <h2 className="mb-4 text-xl font-semibold">在 Mac 上变成实况图</h2>
          <ol className="max-w-3xl space-y-4 text-[15px] leading-7 text-neutral-300">
            <li>
              <span className="mr-2 font-semibold text-white">1.</span>
              解压 ZIP。每张实况是一对同名文件,例如 <code className="rounded bg-white/10 px-1.5">LIVE_01_slippers.JPG</code> 和{' '}
              <code className="rounded bg-white/10 px-1.5">LIVE_01_slippers.MOV</code>。
            </li>
            <li>
              <span className="mr-2 font-semibold text-white">2.</span>
              全选一组的 18 个文件,一起拖进「照片」App(或 文件 → 导入)。照片识别配对后,每组显示为一张带 LIVE 标记的照片。
            </li>
            <li>
              <span className="mr-2 font-semibold text-white">3.</span>
              通过 iCloud 照片同步到 iPhone,或用隔空投送从「照片」发到手机,到手机里仍然是实况。
            </li>
            <li>
              <span className="mr-2 font-semibold text-white">4.</span>
              小红书 / 抖音发图文时,从相册选这 9 张,保持「实况」开关打开。
            </li>
          </ol>
          <p className="mt-5 text-sm leading-6 text-neutral-500">
            JPG 和 MOV 必须成对导入,单独拖一个文件不会变成实况。导入后不要再用其他软件转码 MOV,否则配对信息会丢失。
          </p>
        </section>
      </div>
    </div>
  )
}