-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.html
More file actions
398 lines (375 loc) · 23.5 KB
/
index.html
File metadata and controls
398 lines (375 loc) · 23.5 KB
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>comic-perfect</title>
<link rel="icon" type="image/jpeg" href="assets/favicon.jpeg">
<link rel="stylesheet" href="frontend/css/style.css?v=10">
</head>
<body>
<!-- Left Editor Container -->
<div class="editor-container">
<div class="header-row">
<h3 data-i18n="appName">ComicPerfect</h3>
<div class="header-buttons">
<button onclick="toggleConfig()" class="icon-btn" id="config-btn" title="Config">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
stroke-linecap="round" stroke-linejoin="round">
<path
d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z">
</path>
<circle cx="12" cy="12" r="3"></circle>
</svg>
</button>
<!-- Export Dropdown -->
<div class="export-dropdown" id="export-dropdown">
<button onclick="toggleExportMenu()" class="icon-btn" title="Export">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M21 15V19C21 19.5304 20.7893 20.0391 20.4142 20.4142C20.0391 20.7893 19.5304 21 19 21H5C4.46957 21 3.96086 20.7893 3.58579 20.4142C3.21071 20.0391 3 19.5304 3 19V15"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
<polyline points="17,8 12,3 7,8" stroke="currentColor" stroke-width="2"
stroke-linecap="round" stroke-linejoin="round" />
<line x1="12" y1="3" x2="12" y2="15" stroke="currentColor" stroke-width="2"
stroke-linecap="round" stroke-linejoin="round" />
</svg>
</button>
<div class="export-menu" id="export-menu">
<button onclick="generateXiaohongshuContent(); toggleExportMenu();" class="export-menu-item"
id="xiaohongshu-btn">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none">
<path
d="M4 4H20C20.5523 4 21 4.44772 21 5V19C21 19.5523 20.5523 20 20 20H4C3.44772 20 3 19.5523 3 19V5C3 4.44772 3.44772 4 4 4Z"
stroke="currentColor" stroke-width="2" />
<path d="M7 8H17M7 12H17M7 16H13" stroke="currentColor" stroke-width="2"
stroke-linecap="round" />
</svg>
<span data-i18n="socialMediaContent">生成社媒文案</span>
</button>
</div>
</div>
</div>
</div>
<!-- Configuration Panel -->
<div id="config-panel" class="config-panel">
<h4 data-i18n="configTitle">环境变量配置</h4>
<div class="flex-col">
<!-- Theme and Language Row -->
<div class="config-row-inline">
<div class="config-item-half">
<label data-i18n="themeLabel">主题</label>
<button onclick="toggleTheme()" class="theme-toggle-btn" id="theme-btn">
<span class="theme-icon">☀️</span>
<span data-i18n="themeBtnLight">浅色</span>
</button>
</div>
<div class="config-item-half">
<label data-i18n="languageLabelShort">语言</label>
<select id="language-select" class="language-select" onchange="changeLanguage(this.value)">
<option value="en">English</option>
<option value="zh">中文</option>
</select>
</div>
</div>
<div>
<label data-i18n="googleApiKeyLabel">Google API Key</label>
<input type="password" id="google-api-key" data-i18n="googleApiKeyPlaceholder"
placeholder="输入你的 Google API Key (用于智能生成)">
</div>
<!-- Advanced Config Toggle -->
<div class="advanced-toggle" onclick="toggleAdvancedSettings()"
style="cursor: pointer; display: flex; align-items: center; gap: 5px; margin: 10px 0; font-size: 0.9em; color: var(--text-secondary);">
<svg id="advanced-chevron" width="14" height="14" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" style="transition: transform 0.3s;">
<polyline points="9 18 15 12 9 6"></polyline>
</svg>
<span data-i18n="advancedSettings">高级配置</span>
</div>
<!-- Advanced Config Panel -->
<div id="advanced-config"
style="display: none; border-left: 2px solid var(--border-color); padding-left: 15px; margin-bottom: 10px;">
<div style="margin-bottom: 15px;">
<label data-i18n="apiKeyLabel">OpenAI API Key</label>
<input type="password" id="api-key" data-i18n="apiKeyPlaceholder"
placeholder="输入你的 OpenAI API Key">
</div>
<div style="margin-bottom: 15px;">
<label data-i18n="baseUrlLabel">Base URL</label>
<input type="text" id="base-url" data-i18n="baseUrlPlaceholder"
placeholder="https://api.openai.com/v1">
</div>
<div style="margin-bottom: 15px;">
<label data-i18n="modelLabel">Model</label>
<select id="model-select">
<option value="gpt-4o-mini">gpt-4o-mini</option>
<option value="gpt-4o">gpt-4o</option>
<option value="gpt-4-turbo">gpt-4-turbo</option>
<option value="gpt-3.5-turbo">gpt-3.5-turbo</option>
<option value="custom" data-i18n="customModelLabel">自定义模型</option>
</select>
</div>
<div id="custom-model-input" style="display: none;">
<label data-i18n="customModelLabel">自定义模型名称</label>
<input type="text" id="custom-model" data-i18n="customModelPlaceholder" placeholder="输入模型名称">
</div>
</div>
<button onclick="saveConfig()" class="save-config-btn" data-i18n="saveConfigBtn">💾 保存配置</button>
</div>
</div>
<!-- AI Generation Section -->
<div class="ai-section">
<div class="flex-row">
<label style="white-space: nowrap;" data-i18n="pageCountLabel">生成页数:</label>
<input type="number" id="page-count" value="3" min="1" max="10" style="flex: 1;">
</div>
<div class="flex-row">
<label style="white-space: nowrap;" data-i18n="rowsPerPageLabel">每页行数:</label>
<select id="rows-per-page" style="flex: 1;">
<option value="2">2</option>
<option value="3">3</option>
<option value="4" selected>4</option>
<option value="5">5</option>
</select>
</div>
<div class="flex-row">
<label style="white-space: nowrap;" data-i18n="comicStyleLabel">漫画风格:</label>
<select id="comic-style" style="flex: 1;">
<option value="doraemon" data-i18n="styleDoraemon">哆啦A梦风格</option>
<option value="american" data-i18n="styleAmerican">美式漫画风格</option>
<option value="watercolor" data-i18n="styleWatercolor">水彩风格</option>
<option value="disney" data-i18n="styleDisney">迪士尼动画风格</option>
<option value="ghibli" data-i18n="styleGhibli">宫崎骏/吉卜力风格</option>
<option value="pixar" data-i18n="stylePixar">皮克斯动画风格</option>
<option value="shonen" data-i18n="styleShonen">日本少年漫画风格</option>
<option value="tom_and_jerry" data-i18n="styleTomAndJerry">猫和老鼠风格</option>
<option value="nezha" data-i18n="styleNezha">哪吒风格</option>
<option value="langlangshan" data-i18n="styleLanglangshan">浪浪山小妖怪风格</option>
</select>
</div>
<div class="flex-row">
<label style="white-space: nowrap;" data-i18n="comicLanguageLabel">漫画语言:</label>
<select id="comic-language" style="flex: 1;">
<option value="en" data-i18n="langEn">English</option>
<option value="zh" data-i18n="langZh">中文</option>
<option value="ja" data-i18n="langJa">日本語</option>
</select>
</div>
<div id="ai-status"></div>
</div>
<!-- Session Management Section -->
<div class="session-section">
<div class="session-header">
<select id="session-selector" class="session-selector-large" onchange="switchToSession(this.value)">
<!-- Sessions will be populated by JavaScript -->
</select>
<div class="session-actions-row">
<button onclick="createNewSession()" class="session-action-icon-btn" title="New Session">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12 5V19M5 12H19" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
</svg>
</button>
<button onclick="toggleSessionManager()" class="session-action-icon-btn" title="Manage Sessions">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="3" y="3" width="7" height="7" rx="1" stroke="currentColor" stroke-width="2" />
<rect x="14" y="3" width="7" height="7" rx="1" stroke="currentColor" stroke-width="2" />
<rect x="3" y="14" width="7" height="7" rx="1" stroke="currentColor" stroke-width="2" />
<rect x="14" y="14" width="7" height="7" rx="1" stroke="currentColor" stroke-width="2" />
</svg>
</button>
</div>
</div>
</div>
<h3 style="display: none;">分镜脚本 (JSON)
<span id="page-indicator"></span>
</h3>
<div id="error-msg" class="error" style="display: none;" data-i18n="errorJsonFormat">JSON 格式错误</div>
<textarea id="json-input" style="display: none;"></textarea>
</div>
<!-- Right Preview Container -->
<div class="preview-container">
<!-- Empty State -->
<div id="empty-state" class="empty-state">
<div class="empty-state-icon">
<svg width="64" height="64" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="3" y="3" width="18" height="18" rx="3" stroke="currentColor" stroke-width="1.5" opacity="0.4"/>
<rect x="6" y="6" width="5" height="5" rx="1" stroke="currentColor" stroke-width="1.5"/>
<rect x="13" y="6" width="5" height="5" rx="1" stroke="currentColor" stroke-width="1.5"/>
<rect x="6" y="13" width="12" height="5" rx="1" stroke="currentColor" stroke-width="1.5"/>
</svg>
</div>
<h3 class="empty-state-title" data-i18n="emptyStateTitle">开始创作你的漫画</h3>
<p class="empty-state-desc" data-i18n="emptyStateDesc">在下方输入你的故事描述,AI 将为你生成精美的漫画分镜</p>
<div class="empty-state-steps">
<div class="step-item">
<span class="step-num">1</span>
<span class="step-text" data-i18n="emptyStep1">输入故事描述</span>
</div>
<div class="step-arrow">→</div>
<div class="step-item">
<span class="step-num">2</span>
<span class="step-text" data-i18n="emptyStep2">AI 生成分镜</span>
</div>
<div class="step-arrow">→</div>
<div class="step-item">
<span class="step-num">3</span>
<span class="step-text" data-i18n="emptyStep3">渲染精美图像</span>
</div>
</div>
</div>
<div class="edit-hint" data-i18n="editHint" style="display: none;">点击任意面板可直接编辑内容</div>
<div id="comic-page" style="display: none;">
<!-- Content will be inserted here by JavaScript -->
</div>
<!-- Page Navigation -->
<div id="page-nav" class="page-nav">
<button onclick="prevPage()" id="prev-btn" class="nav-btn" title="Previous Page">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M15 18L9 12L15 6" stroke="currentColor" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round" />
</svg>
</button>
<button onclick="nextPage()" id="next-btn" class="nav-btn" title="Next Page">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M9 18L15 12L9 6" stroke="currentColor" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round" />
</svg>
</button>
</div>
</div>
<!-- Session Management Modal -->
<div id="session-modal" class="modal" style="display: none;">
<div class="modal-content session-modal-content">
<div class="modal-header">
<h3 data-i18n="sessionTitle">Session Management</h3>
<button onclick="toggleSessionManager()" class="modal-close-btn">×</button>
</div>
<div class="modal-body">
<div id="session-list" class="session-list">
<!-- Sessions will be populated by JavaScript -->
</div>
</div>
</div>
</div>
<!-- Prompt Input Section - Fixed at Bottom -->
<div class="prompt-section-fixed">
<div id="image-preview-container" class="image-preview-container" style="display: none;">
<div class="image-preview-wrapper">
<img id="reference-image-preview" src="" alt="Reference Preview">
<button onclick="removeReferenceImage()" class="remove-image-btn">×</button>
</div>
</div>
<div class="prompt-wrapper">
<!-- Primary input row -->
<div class="prompt-input-row">
<textarea id="prompt-input" data-i18n="promptPlaceholder"
placeholder="描述你想要的漫画内容,例如:生成一个关于小明学习编程的故事"></textarea>
<button onclick="optimizePrompt()" class="optimize-btn" id="optimize-btn" data-i18n-title="optimizePromptTitle" title="优化提示词">
<!-- Magic Wand with Sparkles -->
<svg class="wand-icon" width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<!-- Wand body -->
<path class="wand-body" d="M3 21L15 9" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
<!-- Sparkle 1 (large) -->
<path class="sparkle sparkle-1" d="M19 5L19 2M19 5L19 8M19 5L16 5M19 5L22 5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
<!-- Sparkle 2 (medium) -->
<path class="sparkle sparkle-2" d="M14 3L14 1M14 3L14 5M14 3L12 3M14 3L16 3" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
<!-- Sparkle 3 (small) -->
<circle class="sparkle sparkle-3" cx="10" cy="6" r="1" fill="currentColor"/>
</svg>
<!-- Orbiting stars for loading state -->
<div class="magic-loader">
<span class="orbit-star star-1"></span>
<span class="orbit-star star-2"></span>
<span class="orbit-star star-3"></span>
</div>
</button>
<button onclick="generateWithAI()" class="run-btn" id="run-btn" title="Run">
<span class="btn-text">Run</span>
<span class="shortcut-hint">⌘↵</span>
</button>
</div>
<!-- Secondary actions row -->
<div class="prompt-actions-row" id="prompt-actions-row">
<!-- Render Current Page Button -->
<button onclick="generateFinalImage()" class="render-btn" id="render-current-btn" style="display: none;">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="3" y="3" width="18" height="18" rx="2" stroke="currentColor" stroke-width="2" />
<circle cx="8.5" cy="8.5" r="1.5" fill="currentColor" />
<path d="M21 15L16 10L5 21" stroke="currentColor" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round" />
</svg>
<span data-i18n="renderThisPage">渲染本页</span>
</button>
<!-- Toggle View Button -->
<button onclick="toggleView()" class="toggle-view-btn" id="toggle-view-btn" style="display: none;">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M15 2L12 5L15 8" stroke="currentColor" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round" />
<path d="M9 22L12 19L9 16" stroke="currentColor" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round" />
<path d="M12 5C7.03 5 3 9.03 3 14C3 15.58 3.41 17.06 4.12 18.34" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
<path d="M12 19C16.97 19 21 14.97 21 10C21 8.42 20.59 6.94 19.88 5.66" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
</svg>
<span data-i18n="toggleView">翻转预览</span>
</button>
<!-- Generate All Pages Button -->
<button onclick="generateAllPagesImages()" class="generate-all-btn" id="generate-all-btn"
style="display: none;">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M12 2L15.09 8.26L22 9.27L17 14.14L18.18 21.02L12 17.77L5.82 21.02L7 14.14L2 9.27L8.91 8.26L12 2Z"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
fill="none" />
</svg>
<span data-i18n="generateAllText">生成全部</span>
</button>
<!-- Generate Cover Button -->
<button onclick="generateCover()" class="generate-cover-btn" id="generate-cover-btn" style="display: none;">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="3" y="3" width="18" height="18" rx="2" stroke="currentColor" stroke-width="2" />
<path d="M12 8L12 16" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
<path d="M8 12L16 12" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
</svg>
<span data-i18n="btnGenerateCover">生成封面</span>
</button>
</div>
<!-- Cover Customization Floating Panel -->
<div id="cover-custom-panel" class="cover-custom-panel" style="display: none;">
<div class="cover-custom-header">
<span data-i18n="coverCustomTitle">自定义封面要求</span>
<span class="cover-custom-optional" data-i18n="coverCustomOptional">(可选)</span>
</div>
<textarea
id="cover-custom-input"
class="cover-custom-input"
data-i18n-placeholder="coverCustomPlaceholder"
placeholder="例如:使用对比色和大字报风格。左边是哭泣的打工人,右边是喝咖啡的闪电,中间大字'贫富差距?'"
rows="4"
></textarea>
<div class="cover-custom-actions">
<button class="cover-custom-btn cancel" onclick="hideCoverCustomPanel()">
<span data-i18n="btnCancel">取消</span>
</button>
<button class="cover-custom-btn generate" onclick="generateCoverWithCustom()">
<span data-i18n="coverCustomGenerate">直接生成</span>
</button>
</div>
</div>
</div>
</div>
<!-- External Libraries -->
<script src="https://cdn.jsdelivr.net/npm/html2canvas@1.4.1/dist/html2canvas.min.js"></script>
<!-- Application Modules -->
<script src="frontend/js/i18n.js?v=8"></script>
<script src="frontend/js/theme.js?v=4"></script>
<script src="frontend/js/config.js?v=4"></script>
<script src="frontend/js/api.js?v=5"></script>
<script src="frontend/js/renderer.js?v=4"></script>
<script src="frontend/js/pageManager.js?v=4"></script>
<script src="frontend/js/exporter.js?v=4"></script>
<script src="frontend/js/sessionManager.js?v=2"></script>
<script src="frontend/js/app.js?v=14"></script>
</body>
</html>