File size: 9,612 Bytes
db22e56
 
7cf7eea
 
 
 
 
 
964f3df
db22e56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
964f3df
db22e56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
964f3df
 
db22e56
 
964f3df
db22e56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dfc7355
db22e56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import { useEffect, useMemo, useState } from 'react'
import { Clapperboard, Copy as CopyIcon, Download, Film as FilmIcon, Image as ImageIcon, ListVideo, Repeat, Trash2, X } from 'lucide-react'
import Player from '@/film/Player'
import Gallery from '@/film/Gallery'
import ExportPanel from '@/film/ExportPanel'
import CopyPanel from '@/film/CopyPanel'
import CoverPanel from '@/film/CoverPanel'
import { useThumbs } from '@/film/useThumbs'
import { QUOTES } from '@/film/data/quotes'
import { getCopy } from '@/film/core/copy'
import { pad2 } from '@/film/core/util'

type Tab = 'export' | 'copy' | 'cover'

export default function App() {
  const [current, setCurrent] = useState(1)
  const [portrait, setPortrait] = useState(() => typeof window !== 'undefined' && window.matchMedia?.('(max-width: 768px) and (orientation: portrait)').matches)
  const [selected, setSelected] = useState<number[]>([])
  const [mergeMode, setMergeMode] = useState(false)
  const [tab, setTab] = useState<Tab>('export')
  const [autoNext, setAutoNext] = useState(false)
  const [autoKey, setAutoKey] = useState(0)
  const thumbs = useThumbs(true)

  useEffect(() => { document.title = '奥德彪语录' }, [])

  const ids = useMemo(() => (mergeMode && selected.length ? selected : [current]), [mergeMode, selected, current])
  const q = QUOTES.find((x) => x.id === current)!
  const c = getCopy(current)

  const open = (id: number, auto = false) => {
    setMergeMode(false)
    setCurrent(id)
    setAutoKey(auto ? Date.now() : 0)
    if (!auto) window.scrollTo({ top: 0, behavior: 'smooth' })
  }
  const step = (d: number) => open(((current - 1 + d + QUOTES.length) % QUOTES.length) + 1, autoNext)
  const toggle = (id: number) => setSelected((s) => (s.includes(id) ? s.filter((x) => x !== id) : [...s, id]))

  return (
    <div className="min-h-screen bg-[#0a0908] text-white" style={{ fontFamily: '"OdbSans", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif' }}>
      {/* 顶栏 */}
      <header className="sticky top-0 z-30 border-b border-white/5 bg-[#0a0908]/85 backdrop-blur">
        <div className="mx-auto flex max-w-[1400px] items-center gap-3 px-4 py-3">
          <div className="flex h-8 w-8 items-center justify-center rounded-md bg-[#F5C518] text-black"><Clapperboard className="h-4.5 w-4.5" /></div>
          <div className="min-w-0">
            <h1 className="truncate font-[OdbSerif] text-[17px] font-bold tracking-[0.12em]">奥德彪语录 <span className="text-[#F5C518]">·</span> 语录短片</h1>
            <p className="hidden truncate font-[OdbLatin] text-[12px] tracking-[0.3em] text-white/40 sm:block">ODEBIAO · FORTY-THREE QUOTES</p>
          </div>
          <div className="ml-auto hidden items-center gap-4 text-[12px] text-white/50 md:flex">
            <span>43 条语录</span><span>原片 · 字幕 · 配音</span><span>本地导出 MP4</span>
          </div>
        </div>
      </header>

      <main className="mx-auto max-w-[1400px] px-4 pb-32 pt-5">
        <div className="grid gap-6 lg:grid-cols-[minmax(0,1fr)_380px]">
          {/* 播放器 + 片目信息 */}
          <section className="min-w-0">
            <Player
              ids={ids}
              portrait={portrait}
              setPortrait={setPortrait}
              onPrev={() => step(-1)}
              onNext={() => step(1)}
              onEnded={() => { if (autoNext && !mergeMode) step(1) }}
              autoPlayKey={autoKey}
            />
            <div className="mt-4 flex flex-wrap items-start gap-4">
              {mergeMode && selected.length ? (
                <div className="min-w-0 flex-1">
                  <div className="text-[11px] uppercase tracking-[0.25em] text-[#F5C518]">合集预览 · {selected.length} 则</div>
                  <p className="mt-1 font-[OdbSerif] text-[15px] text-white/80">{selected.map((i) => `№${pad2(i)} ${getCopy(i)?.chapter ?? ''}`).join(' → ')}</p>
                </div>
              ) : (
                <div className="min-w-0 flex-1">
                  <div className="flex flex-wrap items-center gap-2">
                    <span className="font-[OdbLatin] text-[28px] leading-none text-[#F5C518]">№{pad2(current)}</span>
                    <span className="font-[OdbSerif] text-[20px] font-bold tracking-[0.15em]">{c?.chapter}</span>
                  </div>
                  <p className="mt-2 font-[OdbSerif] text-[16px] leading-relaxed text-white/90">「{q.text}」</p>
                  {c?.en && <p className="mt-1 font-[OdbLatinItalic] text-[15px] italic text-white/45">{c.en}</p>}
                </div>
              )}
              <div className="flex gap-2">
                <button onClick={() => setAutoNext((v) => !v)} className={`flex items-center gap-1.5 rounded-md px-3 py-2 text-[12px] ring-1 ${autoNext ? 'bg-white/10 text-white ring-[#F5C518]/60' : 'text-white/60 ring-white/15'}`}>
                  <Repeat className="h-3.5 w-3.5" />连播 {autoNext ? '开' : '关'}
                </button>
                {!mergeMode && (
                  <button onClick={() => toggle(current)} className={`flex items-center gap-1.5 rounded-md px-3 py-2 text-[12px] ring-1 ${selected.includes(current) ? 'bg-[#F5C518] text-black ring-[#F5C518]' : 'text-white/70 ring-white/15'}`}>
                    <ListVideo className="h-3.5 w-3.5" />{selected.includes(current) ? '已加入合集' : '加入合集'}
                  </button>
                )}
              </div>
            </div>
          </section>

          {/* 侧栏 */}
          <aside className="min-w-0 rounded-xl bg-[#100e0c] p-4 ring-1 ring-white/8 lg:sticky lg:top-[76px] lg:max-h-[calc(100vh-96px)] lg:overflow-y-auto">
            <div className="mb-4 grid grid-cols-3 gap-1 rounded-lg bg-black/40 p-1">
              {([['export', '导出视频', Download], ['copy', '发布文案', CopyIcon], ['cover', '封面', ImageIcon]] as const).map(([k, l, I]) => (
                <button key={k} onClick={() => setTab(k)} className={`flex items-center justify-center gap-1.5 rounded-md py-2 text-[13px] transition ${tab === k ? 'bg-white/10 text-white' : 'text-white/50 hover:text-white/80'}`}>
                  <I className="h-3.5 w-3.5" />{l}
                </button>
              ))}
            </div>
            {tab === 'export' && (
              <ExportPanel
                ids={ids}
                portrait={portrait}
                label={ids.length > 1 ? `合集 · ${ids.length} 则(${ids.map(pad2).join('、')})` : `№${pad2(current)} ${c?.chapter ?? ''}`}
              />
            )}
            {tab === 'copy' && <CopyPanel id={mergeMode ? selected[0] ?? current : current} />}
            {tab === 'cover' && <CoverPanel id={mergeMode ? selected[0] ?? current : current} />}
          </aside>
        </div>

        {/* 作品墙 */}
        <section className="mt-12">
          <div className="mb-4 flex flex-wrap items-end justify-between gap-3">
            <div>
              <h2 className="font-[OdbSerif] text-[22px] font-bold tracking-[0.2em]">四十三则 <span className="font-[OdbLatin] text-[16px] font-normal tracking-[0.3em] text-white/40">THE COLLECTION</span></h2>
              <p className="mt-1 text-[12px] text-white/45">点击观看 · 右上角圆圈勾选多条,可预览并合并导出为一条视频</p>
            </div>
            <div className="flex gap-2">
              <button onClick={() => setSelected(QUOTES.map((x) => x.id))} className="rounded-md px-3 py-1.5 text-[12px] text-white/60 ring-1 ring-white/15 hover:bg-white/5">全选 43 条</button>
              {selected.length > 0 && <button onClick={() => { setSelected([]); setMergeMode(false) }} className="rounded-md px-3 py-1.5 text-[12px] text-white/60 ring-1 ring-white/15 hover:bg-white/5">清空选择</button>}
            </div>
          </div>
          <Gallery current={mergeMode ? -1 : current} selected={selected} thumbs={thumbs} onOpen={(id) => open(id)} onToggle={toggle} />
        </section>
      </main>

      {/* 合集条 */}
      {selected.length > 0 && (
        <div className="fixed inset-x-0 bottom-0 z-40 border-t border-white/10 bg-[#0f0d0b]/95 backdrop-blur">
          <div className="mx-auto flex max-w-[1400px] flex-wrap items-center gap-3 py-3 pl-4 pr-[132px]">
            <FilmIcon className="h-4 w-4 text-[#F5C518]" />
            <span className="text-[13px]">已选 <b className="text-[#F5C518]">{selected.length}</b> 条</span>
            <div className="flex min-w-0 flex-1 gap-1 overflow-x-auto">
              {selected.map((i) => (
                <span key={i} className="flex shrink-0 items-center gap-1 rounded bg-white/[0.06] px-2 py-1 text-[11px] text-white/75">
                  №{pad2(i)}
                  <button onClick={() => toggle(i)} aria-label="移除"><X className="h-3 w-3 text-white/40 hover:text-white" /></button>
                </span>
              ))}
            </div>
            <button onClick={() => { setMergeMode(true); setTab('export'); window.scrollTo({ top: 0, behavior: 'smooth' }) }} className="rounded-md bg-[#F5C518] px-4 py-2 text-[13px] font-bold text-black">预览 / 合并导出</button>
            {mergeMode && <button onClick={() => setMergeMode(false)} className="rounded-md px-3 py-2 text-[12px] text-white/60 ring-1 ring-white/15">退出合集</button>}
            <button onClick={() => { setSelected([]); setMergeMode(false) }} className="rounded-md p-2 text-white/50 hover:bg-white/5" aria-label="清空"><Trash2 className="h-4 w-4" /></button>
          </div>
        </div>
      )}
    </div>
  )
}