-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcherrystudio.html
More file actions
626 lines (590 loc) · 17.7 KB
/
Copy pathcherrystudio.html
File metadata and controls
626 lines (590 loc) · 17.7 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
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>CherryStudio Web — AI 聚合</title>
<style>
:root {
--bg-primary: #1a1a2e;
--bg-secondary: #16213e;
--bg-card: #0f3460;
--accent: #e94560;
--accent-hover: #c73652;
--accent-light: rgba(233,69,96,0.15);
--text-primary: #e0e6f0;
--text-secondary: #8899aa;
--text-muted: #556070;
--border: #2a3a5a;
--radius: 12px;
--radius-sm: 8px;
--font: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
--header-h: 56px;
--sidebar-w: 260px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body { font-family: var(--font); background: var(--bg-primary); color: var(--text-primary); display: flex; flex-direction: column; }
/* 顶部导航 */
#header {
height: var(--header-h);
background: var(--bg-secondary);
border-bottom: 1px solid var(--border);
display: flex; align-items: center; padding: 0 16px; gap: 12px;
flex-shrink: 0; z-index: 100;
}
#header .logo { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 700; color: var(--accent); }
#header .logo svg { width: 28px; height: 28px; }
#header .spacer { flex: 1; }
#header .btn-icon {
width: 36px; height: 36px; border-radius: 50%; border: none; cursor: pointer;
background: transparent; color: var(--text-secondary); display: flex;
align-items: center; justify-content: center; transition: background .2s, color .2s;
}
#header .btn-icon:hover { background: var(--accent-light); color: var(--accent); }
#header .sidebar-toggle { display: none; }
/* 主体布局 */
#app { display: flex; flex: 1; overflow: hidden; }
/* 侧边栏 */
#sidebar {
width: var(--sidebar-w);
background: var(--bg-secondary);
border-right: 1px solid var(--border);
display: flex; flex-direction: column;
flex-shrink: 0; transition: transform .3s ease; z-index: 90;
}
#sidebar .sidebar-header {
padding: 12px 16px; display: flex; align-items: center; justify-content: space-between;
border-bottom: 1px solid var(--border);
}
#sidebar .sidebar-header span { font-size: 13px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .5px; }
#service-list { flex: 1; overflow-y: auto; padding: 8px; }
.service-item {
display: flex; align-items: center; gap: 10px;
padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer;
margin-bottom: 4px; transition: background .15s; font-size: 14px;
}
.service-item:hover { background: var(--bg-card); }
.service-item.active { background: var(--accent-light); color: var(--accent); }
.service-item .svc-icon {
width: 28px; height: 28px; border-radius: 6px;
display: flex; align-items: center; justify-content: center;
font-size: 16px; flex-shrink: 0;
}
.service-item .svc-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.service-item .svc-tag {
font-size: 10px; padding: 2px 6px; border-radius: 10px;
background: rgba(76,175,80,.2); color: #4caf50;
}
.service-item .svc-tag.limited { background: rgba(255,152,0,.15); color: #ff9800; }
#sidebar .sidebar-footer {
padding: 12px 16px; border-top: 1px solid var(--border);
font-size: 11px; color: var(--text-muted); text-align: center;
}
/* 内容区 */
#content { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; }
/* iframe 容器 */
#iframe-container {
flex: 1; position: relative; background: #000;
}
#iframe-container iframe {
width: 100%; height: 100%; border: none; background: #fff;
}
/* 无法嵌入提示 */
#fallback-view {
position: absolute; inset: 0; background: var(--bg-secondary);
display: none; flex-direction: column; align-items: center; justify-content: center;
gap: 20px; padding: 40px; text-align: center;
}
#fallback-view.show { display: flex; }
#fallback-view .fallback-icon { font-size: 64px; }
#fallback-view h3 { font-size: 20px; color: var(--text-primary); }
#fallback-view p { font-size: 14px; color: var(--text-secondary); max-width: 400px; line-height: 1.7; }
#fallback-view .btn-open {
background: var(--accent); color: #fff; border: none;
border-radius: var(--radius-sm); padding: 12px 28px;
font-size: 15px; cursor: pointer; text-decoration: none;
transition: background .2s; display: inline-flex; align-items: center; gap: 8px;
}
#fallback-view .btn-open:hover { background: var(--accent-hover); }
/* 加载指示器 */
#loading {
position: absolute; inset: 0; background: var(--bg-secondary);
display: flex; flex-direction: column; align-items: center; justify-content: center;
gap: 16px; z-index: 10;
}
#loading.hide { display: none; }
.spinner {
width: 40px; height: 40px; border: 3px solid var(--border);
border-top-color: var(--accent); border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading p { color: var(--text-secondary); font-size: 14px; }
/* 响应式 */
@media (max-width: 768px) {
:root { --sidebar-w: 100%; }
#sidebar { position: fixed; top: var(--header-h); left: 0; bottom: 0; transform: translateX(-100%); }
#sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.5); }
#header .sidebar-toggle { display: flex; }
}
</style>
</head>
<body>
<header id="header">
<button class="btn-icon sidebar-toggle" id="btn-sidebar-toggle" title="切换侧边栏">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="20" height="20">
<line x1="3" y1="6" x2="21" y2="6"/><line x1="3" y1="12" x2="21" y2="12"/><line x1="3" y1="18" x2="21" y2="18"/>
</svg>
</button>
<div class="logo">
<svg viewBox="0 0 36 36" fill="none">
<circle cx="18" cy="18" r="18" fill="#e94560"/>
<path d="M11 14 Q18 8 25 14 Q28 18 25 22 Q18 28 11 22 Q8 18 11 14Z" fill="white" opacity=".9"/>
<circle cx="18" cy="18" r="4" fill="#e94560"/>
</svg>
CherryStudio Web
</div>
<div class="spacer"></div>
<button class="btn-icon" id="btn-reload" title="刷新当前页面">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="20" height="20">
<path d="M23 4v6h-6M1 20v-6h6M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"/>
</svg>
</button>
</header>
<div id="app">
<aside id="sidebar">
<div class="sidebar-header">
<span>AI 服务</span>
</div>
<div id="service-list"></div>
<div class="sidebar-footer">
点击服务切换 · 数据保存在浏览器本地
</div>
</aside>
<main id="content">
<div id="iframe-container">
<iframe id="ai-frame" sandbox="allow-scripts allow-same-origin allow-popups allow-forms allow-storage-access-by-user-activation"></iframe>
<div id="loading">
<div class="spinner"></div>
<p>正在加载 AI 服务...</p>
</div>
<div id="fallback-view">
<div class="fallback-icon">🚫</div>
<h3>该服务无法在当前页面嵌入</h3>
<p>由于安全限制(X-Frame-Options),该 AI 平台禁止在 iframe 中显示。请点击下方按钮在新标签页中打开。</p>
<a id="fallback-link" href="#" target="_blank" class="btn-open">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="18" height="18">
<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6M15 3h6v6M10 14L21 3"/>
</svg>
在新窗口打开
</a>
</div>
</div>
</main>
</div>
<script>
// =============================================
// AI 服务配置(官方网页版)
// =============================================
const AI_SERVICES = [
// 国内主流(大概率可嵌入)
{
id: 'doubao',
name: '豆包',
url: 'https://www.doubao.com/chat/',
icon: '🟡',
desc: '字节跳动出品,完全免费',
tag: '免费',
embed: true
},
{
id: 'kimi',
name: 'Kimi',
url: 'https://kimi.moonshot.cn/',
icon: '🌙',
desc: 'Moonshot,长文本能力强',
tag: '免费',
embed: true
},
{
id: 'wenxin',
name: '文心一言',
url: 'https://yiyan.baidu.com/',
icon: '🔷',
desc: '百度文心大模型',
tag: '免费',
embed: true
},
{
id: 'tongyi',
name: '通义千问',
url: 'https://tongyi.aliyun.com/qianwen/',
icon: '⚡',
desc: '阿里通义系列',
tag: '免费',
embed: true
},
{
id: 'baixiaoying',
name: '百小应',
url: 'https://chat.baichuan-ai.com/',
icon: '🅱️',
desc: '百川智能',
tag: '免费',
embed: true
},
{
id: 'zhipu',
name: '智谱清言',
url: 'https://chatglm.cn/',
icon: '💎',
desc: 'GLM-4 系列模型',
tag: '免费',
embed: true
},
{
id: 'hailuo',
name: '海螺 AI',
url: 'https://hailuoai.com/',
icon: '🐚',
desc: 'MiniMax 出品',
tag: '免费',
embed: true
},
{
id: 'yuanbao',
name: '腾讯元宝',
url: 'https://yuanbao.tencent.com/',
icon: '💠',
desc: '腾讯混元大模型',
tag: '免费',
embed: true
},
{
id: 'spark',
name: '讯飞星火',
url: 'https://xinghuo.xfyun.cn/',
icon: '🔥',
desc: '科大讯飞',
tag: '免费',
embed: true
},
{
id: 'tiangong',
name: '天工 AI',
url: 'https://www.tiangong.cn/',
icon: '⛩️',
desc: '昆仑万维',
tag: '免费',
embed: true
},
{
id: 'shangliang',
name: '商量',
url: 'https://chat.sensetime.com/',
icon: '🟢',
desc: '商汤日日新',
tag: '免费',
embed: true
},
{
id: 'metaso',
name: '秘塔 AI 搜索',
url: 'https://metaso.cn/',
icon: '🔍',
desc: 'AI 搜索引擎',
tag: '免费',
embed: true
},
// 国际/开源
{
id: 'qwenchat',
name: 'QwenChat',
url: 'https://chat.qwen.ai/',
icon: '🌐',
desc: '通义千问国际版',
tag: '免费',
embed: true
},
{
id: 'deepseek',
name: 'DeepSeek',
url: 'https://chat.deepseek.com/',
icon: '🐋',
desc: '深度求索,国产最强',
tag: '免费',
embed: true
},
{
id: 'poe',
name: 'Poe',
url: 'https://poe.com/',
icon: '🤖',
desc: 'Quora 出品,多模型聚合',
tag: '免费/限',
tagClass: 'limited',
embed: false // 大概率被阻止
},
{
id: 'groq',
name: 'Groq',
url: 'https://chat.groq.com/',
icon: '⚡',
desc: '超快推理,Llama3',
tag: '免费',
embed: false
},
{
id: 'perplexity',
name: 'Perplexity',
url: 'https://www.perplexity.ai/',
icon: '❓',
desc: 'AI 搜索引擎',
tag: '免费/限',
tagClass: 'limited',
embed: false
},
{
id: 'claude',
name: 'Claude',
url: 'https://claude.ai/',
icon: '🟣',
desc: 'Anthropic 出品',
tag: '免费/限',
tagClass: 'limited',
embed: false
},
{
id: 'gemini',
name: 'Gemini',
url: 'https://gemini.google.com/',
icon: '🔮',
desc: 'Google 出品',
tag: '免费/限',
tagClass: 'limited',
embed: false
},
{
id: 'chatgpt',
name: 'ChatGPT',
url: 'https://chat.openai.com/',
icon: '🟩',
desc: 'OpenAI 官方',
tag: '免费/限',
tagClass: 'limited',
embed: false
},
{
id: 'copilot',
name: 'GitHub Copilot',
url: 'https://github.com/copilot',
icon: '👨💻',
desc: '微软 Copilot',
tag: '限免',
tagClass: 'limited',
embed: false
},
{
id: 'grok',
name: 'Grok',
url: 'https://grok.x.ai/',
icon: '𝕏',
desc: 'X (Twitter) 出品',
tag: '付费',
tagClass: 'limited',
embed: false
},
{
id: 'genspark',
name: 'Genspark',
url: 'https://www.genspark.ai/',
icon: '✨',
desc: '多 Agent 协作',
tag: '免费/限',
tagClass: 'limited',
embed: false
},
{
id: 'duckduckgo',
name: 'DuckDuckGo AI',
url: 'https://duckduckgo.com/?q=DuckDuckGo+AI+Chat&ia=chat',
icon: '🦆',
desc: '隐私优先 AI',
tag: '免费',
embed: false
},
{
id: 'coze',
name: 'Coze',
url: 'https://www.coze.com/',
icon: '🎭',
desc: '字节 Bot 平台',
tag: '免费',
embed: false
},
{
id: 'dify',
name: 'Dify',
url: 'https://dify.ai/',
icon: '🧩',
desc: '开源 LLM 应用平台',
tag: '免费/自托管',
tagClass: 'limited',
embed: false
},
{
id: 'flowith',
name: 'Flowith',
url: 'https://flowith.io/',
icon: '🌊',
desc: 'AI 工作流',
tag: '免费/限',
tagClass: 'limited',
embed: false
},
{
id: 'lechat',
name: 'Le Chat',
url: 'https://chat.mistral.ai/',
icon: '🐱',
desc: 'Mistral AI',
tag: '免费/限',
tagClass: 'limited',
embed: false
}
];
// =============================================
// 状态管理
// =============================================
const STORE_KEY = 'cs_web_iframe_v1';
function loadState() {
try { return JSON.parse(localStorage.getItem(STORE_KEY)) || {}; } catch { return {}; }
}
function saveState(state) {
localStorage.setItem(STORE_KEY, JSON.stringify(state));
}
let state = loadState();
if (!state.lastService) state.lastService = 'doubao';
// =============================================
// DOM 引用
// =============================================
const $ = id => document.getElementById(id);
const serviceList = $('service-list');
const aiFrame = $('ai-frame');
const loading = $('loading');
const fallbackView = $('fallback-view');
const fallbackLink = $('fallback-link');
const sidebar = $('sidebar');
// =============================================
// 渲染服务列表
// =============================================
function renderServiceList() {
serviceList.innerHTML = AI_SERVICES.map(svc => `
<div class="service-item ${svc.id === state.lastService ? 'active' : ''}" data-id="${svc.id}">
<div class="svc-icon" style="background:${stringToColor(svc.id)}">${svc.icon}</div>
<span class="svc-name">${escapeHtml(svc.name)}</span>
<span class="svc-tag ${svc.tagClass || ''}">${svc.tag}</span>
</div>
`).join('');
serviceList.querySelectorAll('.service-item').forEach(item => {
item.addEventListener('click', () => {
const id = item.dataset.id;
switchService(id);
sidebar.classList.remove('open');
});
});
}
function stringToColor(str) {
let hash = 0;
for (let i = 0; i < str.length; i++) hash = str.charCodeAt(i) + ((hash << 5) - hash);
const c = (hash & 0x00FFFFFF).toString(16).padStart(6, '0');
return '#' + c;
}
function escapeHtml(str) {
return String(str).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
}
// =============================================
// 切换服务
// =============================================
function switchService(id) {
const svc = AI_SERVICES.find(s => s.id === id);
if (!svc) return;
// 更新状态
state.lastService = id;
saveState(state);
// 更新列表高亮
serviceList.querySelectorAll('.service-item').forEach(el => {
el.classList.toggle('active', el.dataset.id === id);
});
// 重置视图
fallbackView.classList.remove('show');
loading.classList.remove('hide');
// 检查是否可嵌入
if (svc.embed === false) {
// 直接显示 fallback
showFallback(svc);
return;
}
// 尝试嵌入
aiFrame.src = svc.url;
// 超时检测(如果 5 秒后还在加载,可能是被阻止了)
clearTimeout(window._loadTimeout);
window._loadTimeout = setTimeout(() => {
// 简单检测:如果 iframe 内容为空或无法访问,显示 fallback
try {
const doc = aiFrame.contentDocument || aiFrame.contentWindow?.document;
if (!doc || doc.body?.innerHTML === '') {
showFallback(svc);
}
} catch (e) {
// 跨域错误,说明加载了但无法访问,这是正常的
loading.classList.add('hide');
}
}, 5000);
}
// iframe 加载事件
aiFrame.addEventListener('load', () => {
loading.classList.add('hide');
clearTimeout(window._loadTimeout);
});
aiFrame.addEventListener('error', () => {
const svc = AI_SERVICES.find(s => s.id === state.lastService);
showFallback(svc);
});
function showFallback(svc) {
loading.classList.add('hide');
fallbackView.classList.add('show');
fallbackLink.href = svc.url;
fallbackLink.innerHTML = `
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="18" height="18">
<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6M15 3h6v6M10 14L21 3"/>
</svg>
打开 ${escapeHtml(svc.name)}
`;
}
// =============================================
// 侧边栏切换
// =============================================
$('btn-sidebar-toggle').addEventListener('click', () => {
sidebar.classList.toggle('open');
});
// =============================================
// 刷新按钮
// =============================================
$('btn-reload').addEventListener('click', () => {
const svc = AI_SERVICES.find(s => s.id === state.lastService);
if (svc) {
fallbackView.classList.remove('show');
loading.classList.remove('hide');
aiFrame.src = svc.url;
}
});
// =============================================
// 初始化
// =============================================
renderServiceList();
switchService(state.lastService);
</script>
</body>
</html>