-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
610 lines (522 loc) · 20.6 KB
/
Copy pathindex.html
File metadata and controls
610 lines (522 loc) · 20.6 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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MemeChat - 聊天截图生成工具</title>
<!-- Vue 3 -->
<!-- <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> -->
<script src="js/vue.global.js"></script>
<!-- Tailwind CSS -->
<!-- <script src="https://cdn.tailwindcss.com"></script> -->
<script src="js/tailwindcss.3.4.17.js"></script>
<!-- html-to-image -->
<script src="https://unpkg.com/html-to-image@1.11.13/dist/html-to-image.js"></script>
<!-- <script src="js/html-to-image.js"></script> -->
<link rel="shortcut icon" href="memechat.ico" type="image/x-icon" />
<meta name="description" content="MemeChat 是一个免费的聊天截图生成工具,支持微信、QQ、支付宝、飞书等聊天界面,一键生成高清聊天截图,适用于小红书、抖音和社交媒体内容创作。">
<meta name="keywords"
content="聊天截图生成器, 微信聊天生成, QQ聊天截图, 聊天记录制作, meme生成器, chat screenshot generator, fake chat maker">
<meta name="author" content="DoraFX">
<meta name="robots" content="index, follow">
<!-- 语言 & 地区 -->
<meta http-equiv="Content-Language" content="zh-CN">
<!-- Canonical(防止重复收录) -->
<link rel="canonical" href="https://your-domain.com/">
<!-- Open Graph(社交分享) -->
<meta property="og:title" content="MemeChat - 聊天截图生成工具">
<meta property="og:description" content="在线生成微信、QQ等聊天截图,一键导出高清图片。">
<meta property="og:type" content="website">
<meta property="og:url" content="https://your-domain.com/">
<meta property="og:image" content="https://your-domain.com/cover.png">
<!-- Twitter Card -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="MemeChat - Chat Screenshot Generator">
<meta name="twitter:description" content="Generate chat screenshots instantly — no backend needed.">
<meta name="twitter:image" content="https://your-domain.com/cover.png">
<!-- Favicon -->
<link rel="icon" href="/favicon.ico">
<!-- Apple -->
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<!-- 主题色(移动端) -->
<meta name="theme-color" content="#ffffff">
<!-- 预加载字体(可选优化) -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<!-- JSON-LD(结构化数据)🔥 很重要 -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "WebApplication",
"name": "MemeChat",
"url": "https://your-domain.com/",
"description": "在线聊天截图生成工具,支持微信、QQ等聊天界面",
"applicationCategory": "Utility",
"operatingSystem": "All",
"browserRequirements": "Requires JavaScript",
"creator": {
"@type": "Person",
"name": "DoraFX"
}
}
</script>
<script>
tailwind.config = {
theme: {
extend: {
fontFamily: {
sans: ['"PingFang SC"', '"Microsoft YaHei"', 'Inter', '-apple-system', 'BlinkMacSystemFont',
'"Segoe UI"', 'Roboto', '"Helvetica Neue"', 'Arial', 'sans-serif'
],
},
colors: {
canvas: '#f3f4f6',
surface: '#ffffff',
}
}
}
}
</script>
<style>
::-webkit-scrollbar {
width: 6px;
height: 6px;
}
::-webkit-scrollbar-track {
background: transparent;
}
::-webkit-scrollbar-thumb {
background: #d4d4d8;
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: #a1a1aa;
}
.dot-pattern {
background-image: radial-gradient(#d4d4d8 1px, transparent 1px);
background-size: 16px 16px;
}
input[type="color"]::-webkit-color-swatch-wrapper {
padding: 0;
}
input[type="color"]::-webkit-color-swatch {
border: none;
border-radius: 4px;
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}
.chat-render-box {
display: flex;
align-items: flex-start;
padding: 60px;
font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
background-color: transparent;
width: fit-content;
min-width: 300px;
}
.chat-avatar-wrap {
flex-shrink: 0;
}
.chat-avatar {
object-fit: cover;
}
.chat-content-wrap {
display: flex;
flex-direction: column;
align-items: flex-start;
}
.chat-name {
font-size: 12px;
color: #b2b2b2;
display: flex;
align-items: center;
}
.chat-bubble-container {
position: relative;
display: flex;
}
.chat-bubble {
height: 100%;
padding: 10px 14px;
font-size: 16px;
line-height: 1.4;
word-break: break-all;
position: relative;
z-index: 2;
display: flex;
align-items: center;
}
.chat-tail {
height: 100%;
z-index: 1;
overflow: hidden;
pointer-events: none;
}
.chat-tail img,
.chat-tail svg {
position: relative;
display: block;
width: 100%;
height: 100%;
}
</style>
<link rel="stylesheet" href="css/style.css" />
</head>
<body class="bg-surface text-neutral-900 font-sans h-screen overflow-hidden flex flex-col selection:bg-neutral-200">
<div id="app" class="flex h-full w-full">
<aside class="w-80 flex-shrink-0 border-r border-neutral-200/60 bg-surface flex flex-col h-full z-10">
<!-- Header -->
<header class="h-14 flex items-center px-5 border-b border-neutral-200/60 shrink-0 justify-between">
<span class="font-semibold text-sm tracking-wide">MemeChat</span>
<a href="https://github.com/doraFX/MemeChat"
class="text-neutral-400 hover:text-neutral-900 transition-colors" title="GitHub 仓库">
<span class="inline-flex w-5 h-5" v-html="icons.github"></span>
</a>
</header>
<div class="flex-grow overflow-y-auto p-5 space-y-8">
<section>
<div class="mb-4 pb-2 border-b border-neutral-200/60 flex items-center gap-2">
<h3 class="text-[14px] font-bold text-neutral-800 tracking-wide">平台</h3>
</div>
<div class="flex flex-wrap gap-2">
<button v-for="app in apps" :key="app.id" @click="selectApp(app.id)" :title="app.name"
:class="[
'w-9 h-9 rounded-md flex items-center justify-center transition-all duration-150 bg-neutral-50 active:scale-[0.94]',
selectedApp === app.id
? 'bg-white text-neutral-900 border border-neutral-900 shadow-none'
: 'text-neutral-500 hover:bg-neutral-200 hover:text-neutral-900'
]">
<span class="inline-flex w-5 h-5 items-center justify-center">
<img v-if="isAssetReady(app.iconSvg)" :src="app.iconSvg"
class="w-full h-full object-contain" :alt="app.name">
</span>
</button>
</div>
</section>
<section class="space-y-4">
<div class="mb-4 pb-2 border-b border-neutral-200/60 flex items-center gap-2">
<h3 class="text-[14px] font-bold text-neutral-800 tracking-wide">内容</h3>
</div>
<div class="flex flex-col gap-2">
<label class="text-xs font-medium text-neutral-600">头像</label>
<div class="relative flex items-center gap-3 rounded-md px-2 py-2 transition-colors"
:class="isAvatarDropActive ? 'border border-dashed border-neutral-300 bg-neutral-100/80' : 'border border-transparent'">
<img :src="chatData.avatar"
class="w-10 h-10 rounded shadow-sm object-cover border border-neutral-200/50"
alt="头像">
<label
class="cursor-pointer px-3 py-1.5 bg-neutral-100 hover:bg-neutral-200 text-neutral-700 rounded text-xs font-medium transition-colors active:scale-[0.97]">
上传
<input type="file" class="hidden" accept="image/*" @change="handleAvatarUpload">
</label>
<div v-if="isAvatarDropActive"
class="absolute inset-0 flex items-center justify-center rounded-md bg-white/80 backdrop-blur-[1px] transition-all duration-200 hover:bg-white/95 hover:backdrop-blur-[2px] cursor-pointer">
<span
class="text-xs font-medium tracking-wide text-neutral-700 transition-transform duration-200 hover:scale-[1.02] hover:text-neutral-900">拖拽图片到此处替换头像</span>
</div>
</div>
</div>
<div class="flex flex-col gap-1.5">
<label class="text-xs font-medium text-neutral-600">昵称</label>
<input type="text" v-model="chatData.name"
class="w-full bg-neutral-50 border border-transparent rounded-md px-3 py-2 text-sm text-neutral-800 placeholder-neutral-400 focus:outline-none focus:bg-white focus:border-neutral-300 focus:ring-2 focus:ring-neutral-900/10 transition-colors">
</div>
<div class="flex flex-col gap-1.5">
<label class="text-xs font-medium text-neutral-600">内容</label>
<textarea v-model="chatData.message" rows="3"
class="w-full bg-neutral-50 border border-transparent rounded-md px-3 py-2 text-sm text-neutral-800 focus:outline-none focus:bg-white focus:border-neutral-300 focus:ring-2 focus:ring-neutral-900/10 transition-colors resize-none"></textarea>
</div>
</section>
<section>
<div class="mb-4 pb-2 border-b border-neutral-200/60 flex items-center gap-2">
<h3 class="text-[14px] font-bold text-neutral-800 tracking-wide">外观</h3>
</div>
<div class="flex items-center justify-between bg-neutral-50 px-3 py-2 rounded-md">
<span class="text-xs font-medium text-neutral-600">画布颜色</span>
<input type="color" :value="canvasBgColor" @input="handleCanvasBgColorChange"
class="w-6 h-6 cursor-pointer bg-transparent">
</div>
</section>
</div>
<div class="p-5 border-t border-neutral-200/60 shrink-0 bg-surface">
<button @click="exportImage"
class="w-full bg-neutral-900 text-white font-medium text-sm py-2.5 rounded-md transition-all duration-150 hover:bg-neutral-800 active:scale-[0.97] flex items-center justify-center gap-2">
<span class="inline-flex w-4 h-4" v-html="icons.export"></span>
导出 PNG
</button>
</div>
</aside>
<main class="flex-grow bg-canvas flex flex-col relative overflow-hidden">
<div
class="h-14 flex items-center justify-center border-b border-neutral-200/60 bg-surface/50 backdrop-blur-sm absolute top-0 w-full z-10 px-4">
<div
class="bg-neutral-100 rounded-md px-3 py-1 text-xs text-neutral-500 font-medium flex items-center gap-2">
<span class="w-2 h-2 rounded-full" :style="{ backgroundColor: canvasBgColor }"></span>
<span>画布</span>
<span class="text-neutral-400">/</span>
<button @click="setZoom(zoom - 0.1)"
class="text-neutral-500 hover:text-neutral-900 transition-colors" title="缩小">
<span class="inline-flex w-4 h-4" v-html="icons.zoomOut"></span>
</button>
<span class="tabular-nums min-w-[3.5rem] text-center">{{ Math.round(zoom * 100) }}%</span>
<button @click="setZoom(zoom + 0.1)"
class="text-neutral-500 hover:text-neutral-900 transition-colors" title="放大">
<span class="inline-flex w-4 h-4" v-html="icons.zoomIn"></span>
</button>
<button @click="setZoom(1)"
class="ml-1 text-neutral-400 hover:text-neutral-900 transition-colors" title="重置为 100%">
100%
</button>
</div>
</div>
<div class="flex-grow dot-pattern flex items-center justify-center overflow-auto pt-14 p-8">
<div id="export-node" :style="{ backgroundColor: canvasBgColor, zoom: zoom }"
class="relative transition-colors duration-200">
<div :class="['chat-render-box', selectedApp]">
<div class="chat-avatar-wrap">
<img class="chat-avatar" :src="chatData.avatar" alt="avatar" />
</div>
<div class="chat-content-wrap">
<div class="chat-name">{{ chatData.name }}</div>
<div class="chat-bubble-container">
<div class="chat-tail">
<img v-if="isAssetReady(getAppById(selectedApp).chatTailSvg)"
:src="getAppById(selectedApp).chatTailSvg" alt="" aria-hidden="true">
</div>
<div class="chat-bubble">
{{ chatData.message }}
</div>
</div>
</div>
</div>
<!-- ========================================= -->
</div>
</div>
</main>
</div>
<script>
const {
createApp,
ref,
reactive,
nextTick,
onMounted,
onBeforeUnmount
} = Vue
createApp({
setup() {
// App 鍒楄〃鏁版嵁
// iconSvg / chatTailSvg: 浠ュ悗琛ラ綈鐨勬湰鍦?SVG 鏂囦欢
const apps = [{
id: 'wechat',
name: '微信',
iconSvg: 'icon/WeChat.svg',
chatTailSvg: 'assets/wechat-chat-tail.svg'
},
{
id: 'wecom',
name: '企业微信',
iconSvg: 'icon/WeCom.svg',
chatTailSvg: 'assets/wecom-chat-tail.svg'
},
{
id: 'qq',
name: 'QQ',
iconSvg: 'icon/QQ.svg',
chatTailSvg: 'assets/qq-chat-tail.svg'
},
{
id: 'alipay',
name: '支付宝',
iconSvg: 'icon/AliPay.svg',
chatTailSvg: 'assets/alipay-chat-tail.svg'
},
{
id: 'dingtalk',
name: '钉钉',
iconSvg: 'icon/DingTalk.svg',
chatTailSvg: 'assets/dingtalk-chat-tail.svg'
},
{
id: 'feishu',
name: '飞书',
iconSvg: 'icon/Feishu.svg',
chatTailSvg: 'assets/feishu-chat-tail.svg'
},
{
id: 'Douyin',
name: '抖音',
iconSvg: 'icon/Douyin.svg',
chatTailSvg: 'assets/Douyin-chat-tail.svg'
},
]
const appById = Object.fromEntries(apps.map((app) => [app.id, app]))
const appBgColors = {
wechat: '#EDEDED',
wecom: '#ECEDF1',
qq: '#F0F0F2',
alipay: '#F5F5F5',
dingtalk: '#ECEDF2',
feishu: '#FFFFFF',
Douyin: '#F5F5F5',
}
Object.values(appById).forEach((app) => {
app.bgColor = appBgColors[app.id] || '#ffffff'
})
const assetReady = reactive({})
const probeAsset = (src) => {
if (!src || assetReady[src] !== undefined) return
assetReady[src] = false
const image = new Image()
image.onload = () => {
assetReady[src] = true
}
image.onerror = () => {
assetReady[src] = false
}
image.src = src
}
apps.forEach((app) => {
probeAsset(app.iconSvg)
probeAsset(app.chatTailSvg)
})
const icons = {
github: '<svg class="w-full h-full" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 2C6.48 2 2 6.6 2 12.27c0 4.53 2.87 8.37 6.84 9.72.5.09.68-.22.68-.48 0-.24-.01-.88-.01-1.72-2.78.63-3.37-1.38-3.37-1.38-.45-1.2-1.12-1.52-1.12-1.52-.92-.65.07-.64.07-.64 1.02.08 1.56 1.08 1.56 1.08.9 1.58 2.36 1.12 2.93.86.09-.67.35-1.12.64-1.38-2.22-.26-4.56-1.14-4.56-5.06 0-1.12.38-2.04 1-2.76-.1-.26-.43-1.31.1-2.73 0 0 .84-.29 2.76 1.05A9.1 9.1 0 0 1 12 6.84c.85 0 1.7.12 2.5.35 1.92-1.34 2.76-1.05 2.76-1.05.53 1.42.2 2.47.1 2.73.62.72 1 1.64 1 2.76 0 3.93-2.34 4.8-4.57 5.05.36.32.68.94.68 1.89 0 1.37-.01 2.48-.01 2.82 0 .27.18.58.69.48A10.05 10.05 0 0 0 22 12.27C22 6.6 17.52 2 12 2Z"/></svg>',
export: '<svg class="w-full h-full" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 3v11"/><path d="M8 7l4-4 4 4"/><path d="M5 14v5h14v-5"/></svg>',
zoomIn: '<svg class="w-full h-full" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="6.5"/><path d="M11 8.5v5"/><path d="M8.5 11h5"/><path d="M16.2 16.2l4.3 4.3"/></svg>',
zoomOut: '<svg class="w-full h-full" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="6.5"/><path d="M8.5 11h5"/><path d="M16.2 16.2l4.3 4.3"/></svg>'
}
const getAppById = (id) => appById[id] || appById.wechat
const isAssetReady = (src) => !!assetReady[src]
const selectedApp = ref('wechat')
const canvasBgColor = ref(getAppById(selectedApp.value)
.bgColor) // Default canvas background for the current platform
const zoom = ref(1)
const isAvatarDropActive = ref(false)
const clampZoom = (value) => Math.min(2, Math.max(0.5, Math.round(value * 100) / 100))
const setZoom = (value) => {
zoom.value = clampZoom(value)
}
const selectApp = (appId) => {
selectedApp.value = appId
canvasBgColor.value = getAppById(appId).bgColor
}
const handleCanvasBgColorChange = (event) => {
const nextColor = event.target.value
canvasBgColor.value = nextColor
getAppById(selectedApp.value).bgColor = nextColor
}
const chatData = reactive({
name: '张小毛',
message: '你好,很高兴见到你',
// Default placeholder avatar
avatar: 'https://api.dicebear.com/7.x/avataaars/svg?seed=Felix&backgroundColor=e2e8f0'
})
const setAvatarFromFile = (file) => {
if (!file || !file.type.startsWith('image/')) return false
const reader = new FileReader()
reader.onload = (e) => {
chatData.avatar = e.target.result
}
reader.readAsDataURL(file)
return true
}
const isImageDragEvent = (event) => {
const items = event.dataTransfer?.items
if (items?.length) {
return Array.from(items).some((item) => item.kind === 'file' && item.type.startsWith(
'image/'))
}
const types = event.dataTransfer?.types
return !!types && Array.from(types).includes('Files')
}
const handleAvatarUpload = (event) => {
const file = event.target.files[0]
setAvatarFromFile(file)
event.target.value = ''
}
const handleWindowDragOver = (event) => {
const fileDrag = isImageDragEvent(event)
isAvatarDropActive.value = fileDrag
if (!fileDrag) return
event.preventDefault()
event.dataTransfer.dropEffect = 'copy'
}
const handleWindowDragEnter = (event) => {
if (!isImageDragEvent(event)) return
isAvatarDropActive.value = true
}
const handleWindowDragLeave = (event) => {
if (event.relatedTarget && document.contains(event.relatedTarget)) return
isAvatarDropActive.value = false
}
const handleWindowDragEnd = () => {
isAvatarDropActive.value = false
}
const handleWindowDrop = (event) => {
const files = event.dataTransfer?.files
isAvatarDropActive.value = false
if (!files || !files.length) return
event.preventDefault()
const imageFile = Array.from(files).find((file) => file.type.startsWith('image/'))
if (!imageFile) return
setAvatarFromFile(imageFile)
}
onMounted(() => {
window.addEventListener('dragenter', handleWindowDragEnter)
window.addEventListener('dragover', handleWindowDragOver)
window.addEventListener('dragleave', handleWindowDragLeave)
window.addEventListener('dragend', handleWindowDragEnd)
window.addEventListener('drop', handleWindowDrop)
})
onBeforeUnmount(() => {
window.removeEventListener('dragenter', handleWindowDragEnter)
window.removeEventListener('dragover', handleWindowDragOver)
window.removeEventListener('dragleave', handleWindowDragLeave)
window.removeEventListener('dragend', handleWindowDragEnd)
window.removeEventListener('drop', handleWindowDrop)
})
const exportImage = async () => {
const node = document.getElementById('export-node')
if (!node) return
const previousZoom = zoom.value
try {
zoom.value = 1
await nextTick()
const dataUrl = await htmlToImage.toPng(node, {
backgroundColor: canvasBgColor.value,
cacheBust: true,
pixelRatio: 3
})
const link = document.createElement('a')
link.download = `meme-${selectedApp.value}-${Date.now()}.png`
link.href = dataUrl
link.click()
} catch (error) {
zoom.value = previousZoom
alert('导出失败,请查看控制台。')
console.error('Export Error:', error)
} finally {
zoom.value = previousZoom
}
}
return {
apps,
icons,
selectedApp,
chatData,
canvasBgColor,
zoom,
setZoom,
isAvatarDropActive,
isAssetReady,
getAppById,
handleCanvasBgColorChange,
handleAvatarUpload,
exportImage,
selectApp
}
}
}).mount('#app')
</script>
</body>
</html>