yaoqifa commited on
Commit
ea0d3fc
·
verified ·
1 Parent(s): 992f229

Update static/index.html

Browse files
Files changed (1) hide show
  1. static/index.html +320 -320
static/index.html CHANGED
@@ -1,321 +1,321 @@
1
- <!DOCTYPE html>
2
- <html lang="zh-CN">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Nano Banana Generator</title>
7
- <style>
8
- :root {
9
- --bg-color: #0b0f19;
10
- --card-color: #1a1f2e;
11
- --text-color: #e2e8f0;
12
- --accent-color: #3b82f6;
13
- --input-bg: #2d3748;
14
- --danger-color: #ef4444;
15
- --success-color: #10b981;
16
- }
17
- body {
18
- font-family: 'Segoe UI', system-ui, sans-serif;
19
- background-color: var(--bg-color);
20
- color: var(--text-color);
21
- margin: 0;
22
- padding: 20px;
23
- display: flex;
24
- justify-content: center;
25
- }
26
- .container {
27
- width: 100%;
28
- max-width: 1000px;
29
- display: grid;
30
- grid-template-columns: 350px 1fr;
31
- gap: 20px;
32
- }
33
- .card {
34
- background-color: var(--card-color);
35
- padding: 20px;
36
- border-radius: 12px;
37
- box-shadow: 0 4px 6px rgba(0,0,0,0.3);
38
- }
39
- h1 { margin-top: 0; font-size: 1.5rem; color: var(--accent-color); }
40
- .form-group { margin-bottom: 15px; }
41
- label { display: block; margin-bottom: 5px; font-size: 0.9rem; color: #a0aec0; }
42
- input, select, textarea {
43
- width: 100%;
44
- padding: 10px;
45
- background-color: var(--input-bg);
46
- border: 1px solid #4a5568;
47
- border-radius: 6px;
48
- color: white;
49
- box-sizing: border-box;
50
- font-size: 0.95rem;
51
- }
52
- input:focus, select:focus, textarea:focus {
53
- outline: none;
54
- border-color: var(--accent-color);
55
- }
56
-
57
- button {
58
- width: 100%;
59
- padding: 12px;
60
- background-color: var(--accent-color);
61
- color: white;
62
- border: none;
63
- border-radius: 6px;
64
- font-size: 1rem;
65
- cursor: pointer;
66
- transition: all 0.3s;
67
- font-weight: bold;
68
- opacity: 1;
69
- }
70
- button:hover:not(:disabled) {
71
- background-color: #2563eb;
72
- transform: translateY(-1px);
73
- }
74
- button:disabled {
75
- background-color: #4a5568;
76
- cursor: not-allowed;
77
- opacity: 0.6;
78
- }
79
-
80
- .result-area {
81
- display: flex;
82
- flex-direction: column;
83
- align-items: center;
84
- justify-content: center;
85
- min-height: 400px;
86
- border: 2px dashed #4a5568;
87
- border-radius: 12px;
88
- position: relative;
89
- margin-top: 20px;
90
- }
91
- #result-img {
92
- max-width: 100%;
93
- max-height: 600px;
94
- border-radius: 8px;
95
- display: none;
96
- box-shadow: 0 4px 15px rgba(0,0,0,0.5);
97
- }
98
- .loader {
99
- border: 4px solid #f3f3f3;
100
- border-top: 4px solid var(--accent-color);
101
- border-radius: 50%;
102
- width: 40px;
103
- height: 40px;
104
- animation: spin 1s linear infinite;
105
- display: none;
106
- }
107
- .download-btn {
108
- margin-top: 15px;
109
- background-color: var(--success-color);
110
- width: auto;
111
- padding: 8px 20px;
112
- display: none;
113
- text-decoration: none;
114
- color: white;
115
- border-radius: 6px;
116
- }
117
- @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
118
-
119
- .disclaimer-box {
120
- margin-bottom: 15px;
121
- padding: 12px;
122
- background-color: rgba(239, 68, 68, 0.1);
123
- border: 1px solid rgba(239, 68, 68, 0.3);
124
- border-radius: 6px;
125
- font-size: 0.85rem;
126
- color: #cbd5e1;
127
- line-height: 1.5;
128
- }
129
- .disclaimer-box strong { color: var(--danger-color); display: block; margin-bottom: 5px; }
130
-
131
- .checkbox-wrapper {
132
- display: flex;
133
- align-items: center;
134
- margin-bottom: 15px;
135
- padding: 5px 0;
136
- cursor: pointer;
137
- }
138
- .checkbox-wrapper input[type="checkbox"] {
139
- width: 18px;
140
- height: 18px;
141
- margin-right: 10px;
142
- cursor: pointer;
143
- accent-color: var(--accent-color);
144
- }
145
- .checkbox-wrapper label {
146
- display: inline;
147
- margin: 0;
148
- font-size: 0.95rem;
149
- color: #e2e8f0;
150
- cursor: pointer;
151
- }
152
-
153
- @media (max-width: 768px) {
154
- .container { grid-template-columns: 1fr; }
155
- }
156
- </style>
157
- </head>
158
- <body>
159
-
160
- <div class="container">
161
- <div class="card">
162
- <h1>🍌 Nano Generator</h1>
163
-
164
- <div class="form-group">
165
- <label>API Key</label>
166
- <input type="password" id="api_key" placeholder="sk-...">
167
- </div>
168
-
169
- <div class="form-group">
170
- <label>模型名称</label>
171
- <select id="model">
172
- <option value="nano-banana">nano-banana</option>
173
- <option value="nano-banana-pro">nano-banana-pro</option>
174
- <option value="nano-banana-pro-4k">nano-banana-pro-4k</option>
175
- <option value="gemini-2.5-flash-image">gemini-2.5-flash-image</option>
176
- <option value="gemini-3-pro-image">gemini-3-pro-image</option>
177
- <option value="gemini-3-pro-image-preview">gemini-3-pro-image-preview</option>
178
- </select>
179
- </div>
180
-
181
- <div class="form-group">
182
- <label>画面比例</label>
183
- <select id="ratio">
184
- <option value="16:9 (1080p/4K)">16:9 (1080p/4K 宽屏)</option>
185
- <option value="1:1 (正方形)">1:1 (正方形)</option>
186
- <option value="9:16 (手机壁纸)">9:16 (手机壁纸)</option>
187
- <option value="4:3 (标准照片)">4:3 (标准照片)</option>
188
- <option value="3:4 (竖向照片)">3:4 (竖向照片)</option>
189
- <option value="21:9 (电影感)">21:9 (电影感)</option>
190
- <option value="2:3 (艺术照)">2:3 (艺术照)</option>
191
- </select>
192
- </div>
193
-
194
- <div class="form-group">
195
- <label>清晰度等级</label>
196
- <select id="scale">
197
- <option value="1k">1k (标准)</option>
198
- <option value="2k">2k (高清)</option>
199
- <option value="4k">4k (超清 Pro)</option>
200
- </select>
201
- </div>
202
-
203
- <div class="form-group">
204
- <label>输出格式</label>
205
- <select id="format">
206
- <option value="png">PNG</option>
207
- <option value="jpg">JPG</option>
208
- </select>
209
- </div>
210
- </div>
211
-
212
- <div class="card">
213
- <div class="form-group">
214
- <label>提示词 (Prompt)</label>
215
- <textarea id="prompt" rows="4" placeholder="描述你想要的画面..."></textarea>
216
- </div>
217
-
218
- <div class="disclaimer-box">
219
- <strong>⚠️ 免责声明 (Disclaimer)</strong>
220
- 本工具仅供个人学习与技术研究使用。严禁生成色情、暴力、政治敏感等违法内容。用户生成的任何内容纯属个人行为,法律后果由用户自行承担。
221
- </div>
222
-
223
- <div class="checkbox-wrapper">
224
- <input type="checkbox" id="agree_chk" onchange="toggleSubmitButton()">
225
- <label for="agree_chk">我已知晓并承诺合规使用</label>
226
- </div>
227
-
228
- <button onclick="generateImage()" id="gen-btn" disabled>🚫 请先勾选免责声明</button>
229
-
230
- <div class="result-area" id="result-area">
231
- <div class="loader" id="loader"></div>
232
- <img id="result-img" alt="Generated Image" />
233
- <a id="download-link" class="download-btn" href="#" download="image.png">下载图片</a>
234
- <p id="status-text" style="color: #a0aec0; margin-top: 10px;">等待生成...</p>
235
- </div>
236
- </div>
237
- </div>
238
-
239
- <script>
240
- function toggleSubmitButton() {
241
- const checkbox = document.getElementById('agree_chk');
242
- const btn = document.getElementById('gen-btn');
243
- if (checkbox.checked) {
244
- btn.disabled = false;
245
- btn.innerText = "🚀 开始生成";
246
- } else {
247
- btn.disabled = true;
248
- btn.innerText = "🚫 请先勾选免责声明";
249
- }
250
- }
251
-
252
- async function generateImage() {
253
- const apiKey = document.getElementById('api_key').value;
254
- const prompt = document.getElementById('prompt').value;
255
- const checkbox = document.getElementById('agree_chk');
256
-
257
- if (!checkbox.checked) { alert("请先勾选免责声明!"); return; }
258
- if (!apiKey) { alert("请输入 API Key"); return; }
259
- if (!prompt) { alert("请输入提示词"); return; }
260
-
261
- const btn = document.getElementById('gen-btn');
262
- const loader = document.getElementById('loader');
263
- const img = document.getElementById('result-img');
264
- const downloadBtn = document.getElementById('download-link');
265
- const statusText = document.getElementById('status-text');
266
-
267
- btn.disabled = true;
268
- btn.innerText = "生成中...";
269
- loader.style.display = 'block';
270
- img.style.display = 'none';
271
- downloadBtn.style.display = 'none';
272
- statusText.innerText = "正在请求 API...";
273
-
274
- const payload = {
275
- api_key: apiKey,
276
- model: document.getElementById('model').value,
277
- prompt: prompt,
278
- ratio: document.getElementById('ratio').value,
279
- scale: document.getElementById('scale').value,
280
- format: document.getElementById('format').value
281
- };
282
-
283
- try {
284
- const response = await fetch('/api/generate', {
285
- method: 'POST',
286
- headers: { 'Content-Type': 'application/json' },
287
- body: JSON.stringify(payload)
288
- });
289
-
290
- const data = await response.json();
291
-
292
- if (data.status === 'success') {
293
- img.src = `data:image/${payload.format === 'jpg' ? 'jpeg' : 'png'};base64,${data.image_base64}`;
294
- img.style.display = 'block';
295
- downloadBtn.href = img.src;
296
- downloadBtn.download = `generated_image.${payload.format}`;
297
- downloadBtn.style.display = 'inline-block';
298
- downloadBtn.innerText = "下载图片";
299
- statusText.innerText = "";
300
- } else {
301
- statusText.innerText = "生成失败: " + data.message;
302
- alert("错误: " + data.message);
303
- }
304
- } catch (error) {
305
- console.error(error);
306
- statusText.innerText = "网络请求失败";
307
- alert("网络请求失败,请检查控制台");
308
- } finally {
309
- if (document.getElementById('agree_chk').checked) {
310
- btn.disabled = false;
311
- btn.innerText = "🚀 开始生成";
312
- } else {
313
- btn.innerText = "🚫 请先勾选免责声明";
314
- }
315
- loader.style.display = 'none';
316
- }
317
- }
318
- </script>
319
-
320
- </body>
321
  </html>
 
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Nano Banana Generator</title>
7
+ <style>
8
+ :root {
9
+ --bg-color: #0b0f19;
10
+ --card-color: #1a1f2e;
11
+ --text-color: #e2e8f0;
12
+ --accent-color: #3b82f6;
13
+ --input-bg: #2d3748;
14
+ --danger-color: #ef4444;
15
+ --success-color: #10b981;
16
+ }
17
+ body {
18
+ font-family: 'Segoe UI', system-ui, sans-serif;
19
+ background-color: var(--bg-color);
20
+ color: var(--text-color);
21
+ margin: 0;
22
+ padding: 20px;
23
+ display: flex;
24
+ justify-content: center;
25
+ }
26
+ .container {
27
+ width: 100%;
28
+ max-width: 1000px;
29
+ display: grid;
30
+ grid-template-columns: 350px 1fr;
31
+ gap: 20px;
32
+ }
33
+ .card {
34
+ background-color: var(--card-color);
35
+ padding: 20px;
36
+ border-radius: 12px;
37
+ box-shadow: 0 4px 6px rgba(0,0,0,0.3);
38
+ }
39
+ h1 { margin-top: 0; font-size: 1.5rem; color: var(--accent-color); }
40
+ .form-group { margin-bottom: 15px; }
41
+ label { display: block; margin-bottom: 5px; font-size: 0.9rem; color: #a0aec0; }
42
+ input, select, textarea {
43
+ width: 100%;
44
+ padding: 10px;
45
+ background-color: var(--input-bg);
46
+ border: 1px solid #4a5568;
47
+ border-radius: 6px;
48
+ color: white;
49
+ box-sizing: border-box;
50
+ font-size: 0.95rem;
51
+ }
52
+ input:focus, select:focus, textarea:focus {
53
+ outline: none;
54
+ border-color: var(--accent-color);
55
+ }
56
+
57
+ button {
58
+ width: 100%;
59
+ padding: 12px;
60
+ background-color: var(--accent-color);
61
+ color: white;
62
+ border: none;
63
+ border-radius: 6px;
64
+ font-size: 1rem;
65
+ cursor: pointer;
66
+ transition: all 0.3s;
67
+ font-weight: bold;
68
+ opacity: 1;
69
+ }
70
+ button:hover:not(:disabled) {
71
+ background-color: #2563eb;
72
+ transform: translateY(-1px);
73
+ }
74
+ button:disabled {
75
+ background-color: #4a5568;
76
+ cursor: not-allowed;
77
+ opacity: 0.6;
78
+ }
79
+
80
+ .result-area {
81
+ display: flex;
82
+ flex-direction: column;
83
+ align-items: center;
84
+ justify-content: center;
85
+ min-height: 400px;
86
+ border: 2px dashed #4a5568;
87
+ border-radius: 12px;
88
+ position: relative;
89
+ margin-top: 20px;
90
+ }
91
+ #result-img {
92
+ max-width: 100%;
93
+ max-height: 600px;
94
+ border-radius: 8px;
95
+ display: none;
96
+ box-shadow: 0 4px 15px rgba(0,0,0,0.5);
97
+ }
98
+ .loader {
99
+ border: 4px solid #f3f3f3;
100
+ border-top: 4px solid var(--accent-color);
101
+ border-radius: 50%;
102
+ width: 40px;
103
+ height: 40px;
104
+ animation: spin 1s linear infinite;
105
+ display: none;
106
+ }
107
+ .download-btn {
108
+ margin-top: 15px;
109
+ background-color: var(--success-color);
110
+ width: auto;
111
+ padding: 8px 20px;
112
+ display: none;
113
+ text-decoration: none;
114
+ color: white;
115
+ border-radius: 6px;
116
+ }
117
+ @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
118
+
119
+ .disclaimer-box {
120
+ margin-bottom: 15px;
121
+ padding: 12px;
122
+ background-color: rgba(239, 68, 68, 0.1);
123
+ border: 1px solid rgba(239, 68, 68, 0.3);
124
+ border-radius: 6px;
125
+ font-size: 0.85rem;
126
+ color: #cbd5e1;
127
+ line-height: 1.5;
128
+ }
129
+ .disclaimer-box strong { color: var(--danger-color); display: block; margin-bottom: 5px; }
130
+
131
+ .checkbox-wrapper {
132
+ display: flex;
133
+ align-items: center;
134
+ margin-bottom: 15px;
135
+ padding: 5px 0;
136
+ cursor: pointer;
137
+ }
138
+ .checkbox-wrapper input[type="checkbox"] {
139
+ width: 18px;
140
+ height: 18px;
141
+ margin-right: 10px;
142
+ cursor: pointer;
143
+ accent-color: var(--accent-color);
144
+ }
145
+ .checkbox-wrapper label {
146
+ display: inline;
147
+ margin: 0;
148
+ font-size: 0.95rem;
149
+ color: #e2e8f0;
150
+ cursor: pointer;
151
+ }
152
+
153
+ @media (max-width: 768px) {
154
+ .container { grid-template-columns: 1fr; }
155
+ }
156
+ </style>
157
+ </head>
158
+ <body>
159
+
160
+ <div class="container">
161
+ <div class="card">
162
+ <h1>Imagen Generator</h1>
163
+
164
+ <div class="form-group">
165
+ <label>API Key</label>
166
+ <input type="password" id="api_key" placeholder="sk-...">
167
+ </div>
168
+
169
+ <div class="form-group">
170
+ <label>模型名称</label>
171
+ <select id="model">
172
+ <option value="nano-banana">nano-banana</option>
173
+ <option value="nano-banana-pro">nano-banana-pro</option>
174
+ <option value="nano-banana-pro-4k">nano-banana-pro-4k</option>
175
+ <option value="gemini-2.5-flash-image">gemini-2.5-flash-image</option>
176
+ <option value="gemini-3-pro-image">gemini-3-pro-image</option>
177
+ <option value="gemini-3-pro-image-preview">gemini-3-pro-image-preview</option>
178
+ </select>
179
+ </div>
180
+
181
+ <div class="form-group">
182
+ <label>画面比例</label>
183
+ <select id="ratio">
184
+ <option value="16:9 (1080p/4K)">16:9 (1080p/4K 宽屏)</option>
185
+ <option value="1:1 (正方形)">1:1 (正方形)</option>
186
+ <option value="9:16 (手机壁纸)">9:16 (手机壁纸)</option>
187
+ <option value="4:3 (标准照片)">4:3 (标准照片)</option>
188
+ <option value="3:4 (竖向照片)">3:4 (竖向照片)</option>
189
+ <option value="21:9 (电影感)">21:9 (电影感)</option>
190
+ <option value="2:3 (艺术照)">2:3 (艺术照)</option>
191
+ </select>
192
+ </div>
193
+
194
+ <div class="form-group">
195
+ <label>清晰度等级</label>
196
+ <select id="scale">
197
+ <option value="1k">1k (标准)</option>
198
+ <option value="2k">2k (高清)</option>
199
+ <option value="4k">4k (超清 Pro)</option>
200
+ </select>
201
+ </div>
202
+
203
+ <div class="form-group">
204
+ <label>输出格式</label>
205
+ <select id="format">
206
+ <option value="png">PNG</option>
207
+ <option value="jpg">JPG</option>
208
+ </select>
209
+ </div>
210
+ </div>
211
+
212
+ <div class="card">
213
+ <div class="form-group">
214
+ <label>提示词 (Prompt)</label>
215
+ <textarea id="prompt" rows="4" placeholder="描述你想要的画面..."></textarea>
216
+ </div>
217
+
218
+ <div class="disclaimer-box">
219
+ <strong>⚠️ 免责声明 (Disclaimer)</strong>
220
+ 本工具仅供个人学习与技术研究使用。严禁生成色情、暴力、政治敏感等违法内容。用户生成的任何内容纯属个人行为,法律后果由用户自行承担。
221
+ </div>
222
+
223
+ <div class="checkbox-wrapper">
224
+ <input type="checkbox" id="agree_chk" onchange="toggleSubmitButton()">
225
+ <label for="agree_chk">我已知晓并承诺合规使用</label>
226
+ </div>
227
+
228
+ <button onclick="generateImage()" id="gen-btn" disabled>🚫 请先勾选免责声明</button>
229
+
230
+ <div class="result-area" id="result-area">
231
+ <div class="loader" id="loader"></div>
232
+ <img id="result-img" alt="Generated Image" />
233
+ <a id="download-link" class="download-btn" href="#" download="image.png">下载图片</a>
234
+ <p id="status-text" style="color: #a0aec0; margin-top: 10px;">等待生成...</p>
235
+ </div>
236
+ </div>
237
+ </div>
238
+
239
+ <script>
240
+ function toggleSubmitButton() {
241
+ const checkbox = document.getElementById('agree_chk');
242
+ const btn = document.getElementById('gen-btn');
243
+ if (checkbox.checked) {
244
+ btn.disabled = false;
245
+ btn.innerText = "🚀 开始生成";
246
+ } else {
247
+ btn.disabled = true;
248
+ btn.innerText = "🚫 请先勾选免责声明";
249
+ }
250
+ }
251
+
252
+ async function generateImage() {
253
+ const apiKey = document.getElementById('api_key').value;
254
+ const prompt = document.getElementById('prompt').value;
255
+ const checkbox = document.getElementById('agree_chk');
256
+
257
+ if (!checkbox.checked) { alert("请先勾选免责声明!"); return; }
258
+ if (!apiKey) { alert("请输入 API Key"); return; }
259
+ if (!prompt) { alert("请输入提示词"); return; }
260
+
261
+ const btn = document.getElementById('gen-btn');
262
+ const loader = document.getElementById('loader');
263
+ const img = document.getElementById('result-img');
264
+ const downloadBtn = document.getElementById('download-link');
265
+ const statusText = document.getElementById('status-text');
266
+
267
+ btn.disabled = true;
268
+ btn.innerText = "生成中...";
269
+ loader.style.display = 'block';
270
+ img.style.display = 'none';
271
+ downloadBtn.style.display = 'none';
272
+ statusText.innerText = "正在请求 API...";
273
+
274
+ const payload = {
275
+ api_key: apiKey,
276
+ model: document.getElementById('model').value,
277
+ prompt: prompt,
278
+ ratio: document.getElementById('ratio').value,
279
+ scale: document.getElementById('scale').value,
280
+ format: document.getElementById('format').value
281
+ };
282
+
283
+ try {
284
+ const response = await fetch('/api/generate', {
285
+ method: 'POST',
286
+ headers: { 'Content-Type': 'application/json' },
287
+ body: JSON.stringify(payload)
288
+ });
289
+
290
+ const data = await response.json();
291
+
292
+ if (data.status === 'success') {
293
+ img.src = `data:image/${payload.format === 'jpg' ? 'jpeg' : 'png'};base64,${data.image_base64}`;
294
+ img.style.display = 'block';
295
+ downloadBtn.href = img.src;
296
+ downloadBtn.download = `generated_image.${payload.format}`;
297
+ downloadBtn.style.display = 'inline-block';
298
+ downloadBtn.innerText = "下载图片";
299
+ statusText.innerText = "";
300
+ } else {
301
+ statusText.innerText = "生成失败: " + data.message;
302
+ alert("错误: " + data.message);
303
+ }
304
+ } catch (error) {
305
+ console.error(error);
306
+ statusText.innerText = "网络请求失败";
307
+ alert("网络请求失败,请检查控制台");
308
+ } finally {
309
+ if (document.getElementById('agree_chk').checked) {
310
+ btn.disabled = false;
311
+ btn.innerText = "🚀 开始生成";
312
+ } else {
313
+ btn.innerText = "🚫 请先勾选免责声明";
314
+ }
315
+ loader.style.display = 'none';
316
+ }
317
+ }
318
+ </script>
319
+
320
+ </body>
321
  </html>