@wendongfly/myhi 1.3.218 → 1.3.220

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,167 @@
1
+ // ---------------------------------------------------------------------------
2
+ // 全站图标统一:按钮 / 菜单 / 快捷栏 / 列表图标位上开头的 emoji → 单色线条 SVG(跟随文字颜色)
3
+ // 以前各处混着彩色 emoji(📥 🩺 📊)、单色字符(⚙ ▦ ✕)和彩色箭头,风格不一。
4
+ // 做法:页面加载后、以及之后按钮 / 菜单重新渲染时,自动把「标签开头的 emoji」换成同一套线条图标;
5
+ // 没有对应图标的 emoji 原样保留(不会坏)。
6
+ // 不动的地方:聊天消息 / AI 回复 / 状态提示(#chat-area 里)、输入框、终端 —— 那些是内容,不是图标。
7
+ // 新加按钮照常写「📥 草稿」即可,会自动换;不想被换的元素加 data-no-ico。
8
+ // ---------------------------------------------------------------------------
9
+ (function () {
10
+ const P = {
11
+ inbox: '<polyline points="22 12 16 12 14 15 10 15 8 12 2 12"/><path d="M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"/>',
12
+ upload: '<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/>',
13
+ download: '<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/>',
14
+ refresh: '<polyline points="23 4 23 10 17 10"/><polyline points="1 20 1 14 7 14"/><path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"/>',
15
+ pack: '<path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"/><polyline points="3.27 6.96 12 12.01 20.73 6.96"/><line x1="12" y1="22.08" x2="12" y2="12"/>',
16
+ key: '<circle cx="7.5" cy="15.5" r="5.5"/><path d="M11.4 11.6 21 2"/><path d="m16 7 3 3"/><path d="m18.5 4.5 2 2"/>',
17
+ sparkles: '<path d="M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9z"/><path d="M19 3v4M21 5h-4"/>',
18
+ alert: '<path d="M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/>',
19
+ zap: '<polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/>',
20
+ shield: '<path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/>',
21
+ clipboard: '<path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"/><rect x="8" y="2" width="8" height="4" rx="1"/>',
22
+ book: '<path d="M4 19.5A2.5 2.5 0 0 1 6.5 17H20"/><path d="M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"/>',
23
+ pencil: '<path d="M12 20h9"/><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4z"/>',
24
+ folderOpen: '<path d="M6 14l1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"/>',
25
+ folder: '<path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"/>',
26
+ users: '<path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M23 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/>',
27
+ user: '<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/>',
28
+ checkCircle: '<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><polyline points="22 4 12 14.01 9 11.01"/>',
29
+ check: '<polyline points="20 6 9 17 4 12"/>',
30
+ checkSquare: '<polyline points="9 11 12 14 22 4"/><path d="M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"/>',
31
+ bulb: '<path d="M9 18h6"/><path d="M10 22h4"/><path d="M12 2a7 7 0 0 0-4 12.74V17h8v-2.26A7 7 0 0 0 12 2z"/>',
32
+ external: '<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/>',
33
+ search: '<circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/>',
34
+ settings: '<circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"/>',
35
+ eye: '<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/>',
36
+ message: '<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>',
37
+ bot: '<rect x="3" y="8" width="18" height="12" rx="2"/><path d="M12 8V4"/><circle cx="12" cy="3" r="1"/><line x1="9" y1="13" x2="9" y2="15"/><line x1="15" y1="13" x2="15" y2="15"/>',
38
+ pointer: '<line x1="5" y1="12" x2="19" y2="12"/><polyline points="12 5 19 12 12 19"/>',
39
+ activity: '<polyline points="22 12 18 12 15 21 9 3 6 12 2 12"/>',
40
+ hourglass: '<path d="M5 22h14"/><path d="M5 2h14"/><path d="M17 22v-4.17a2 2 0 0 0-.59-1.42L12 12l-4.41 4.41A2 2 0 0 0 7 17.83V22"/><path d="M7 2v4.17a2 2 0 0 0 .59 1.42L12 12l4.41-4.41A2 2 0 0 0 17 6.17V2"/>',
41
+ lock: '<rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/>',
42
+ help: '<circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/><line x1="12" y1="17" x2="12.01" y2="17"/>',
43
+ cart: '<circle cx="9" cy="21" r="1"/><circle cx="20" cy="21" r="1"/><path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"/>',
44
+ file: '<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/>',
45
+ fileEdit: '<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="8" y1="13" x2="16" y2="13"/><line x1="8" y1="17" x2="13" y2="17"/>',
46
+ bell: '<path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"/><path d="M13.73 21a2 2 0 0 1-3.46 0"/>',
47
+ phone: '<rect x="5" y="2" width="14" height="20" rx="2"/><line x1="12" y1="18" x2="12.01" y2="18"/>',
48
+ undo: '<polyline points="9 14 4 9 9 4"/><path d="M20 20v-7a4 4 0 0 0-4-4H4"/>',
49
+ chart: '<line x1="18" y1="20" x2="18" y2="10"/><line x1="12" y1="20" x2="12" y2="4"/><line x1="6" y1="20" x2="6" y2="14"/>',
50
+ wrench: '<path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94z"/>',
51
+ tag: '<path d="M20.59 13.41 13.42 20.58a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z"/><line x1="7" y1="7" x2="7.01" y2="7"/>',
52
+ trash: '<polyline points="3 6 5 6 21 6"/><path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"/><path d="M10 11v6M14 11v6"/><path d="M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/>',
53
+ memory: '<path d="M19 21l-7-5-7 5V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z"/>',
54
+ blocks: '<rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="3" y="14" width="7" height="7" rx="1"/><path d="M14 17.5h7M17.5 14v7"/>',
55
+ pause: '<rect x="6" y="4" width="4" height="16" rx="1"/><rect x="14" y="4" width="4" height="16" rx="1"/>',
56
+ link: '<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/>',
57
+ save: '<path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"/><polyline points="17 21 17 13 7 13 7 21"/><polyline points="7 3 7 8 15 8"/>',
58
+ send: '<line x1="22" y1="2" x2="11" y2="13"/><polygon points="22 2 15 22 11 13 2 9 22 2"/>',
59
+ skip: '<polygon points="5 4 15 12 5 20 5 4"/><line x1="19" y1="5" x2="19" y2="19"/>',
60
+ menu: '<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"/>',
61
+ alarm: '<circle cx="12" cy="13" r="8"/><path d="M12 9v4l2 2"/><path d="M5 3 2 6M22 6l-3-3"/>',
62
+ image: '<rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/>',
63
+ grid: '<rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="3" y="14" width="7" height="7" rx="1"/><rect x="14" y="14" width="7" height="7" rx="1"/>',
64
+ diamond: '<path d="M12 2 22 12 12 22 2 12z"/><path d="M12 7l5 5-5 5-5-5z"/>',
65
+ type: '<polyline points="4 7 4 4 20 4 20 7"/><line x1="9" y1="20" x2="15" y2="20"/><line x1="12" y1="4" x2="12" y2="20"/>',
66
+ clock: '<circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/>',
67
+ share: '<path d="M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8"/><polyline points="16 6 12 2 8 6"/><line x1="12" y1="2" x2="12" y2="15"/>',
68
+ globe: '<circle cx="12" cy="12" r="10"/><line x1="2" y1="12" x2="22" y2="12"/><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"/>',
69
+ plusSquare: '<rect x="3" y="3" width="18" height="18" rx="2"/><line x1="12" y1="8" x2="12" y2="16"/><line x1="8" y1="12" x2="16" y2="12"/>',
70
+ camera: '<path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/><circle cx="12" cy="13" r="4"/>',
71
+ clip: '<path d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"/>',
72
+ close: '<line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/>',
73
+ pin: '<line x1="12" y1="17" x2="12" y2="22"/><path d="M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24z"/>',
74
+ back: '<polyline points="15 18 9 12 15 6"/>',
75
+ mic: '<path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" y1="19" x2="12" y2="23"/>',
76
+ home: '<path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/><polyline points="9 22 9 12 15 12 15 22"/>',
77
+ play: '<polygon points="5 3 19 12 5 21 5 3"/>',
78
+ stop: '<rect x="5" y="5" width="14" height="14" rx="2"/>',
79
+ rocket: '<path d="M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z"/><path d="M12 15l-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z"/><path d="M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5"/>',
80
+ terminal: '<polyline points="4 17 10 11 4 5"/><line x1="12" y1="19" x2="20" y2="19"/>',
81
+ copy: '<rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>',
82
+ star: '<polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/>',
83
+ broom: '<path d="M19.36 2.72 20.78 4.14"/><path d="m15 7 5.36-4.28"/><path d="M14 8 4 18l2 2 10-10"/><path d="M14 8l2 2"/>',
84
+ };
85
+ // emoji → 图标名(没列的 emoji 原样保留)
86
+ const MAP = {
87
+ '📥': 'inbox', '⬆': 'upload', '⬇': 'download', '🔄': 'refresh', '↻': 'refresh', '🔁': 'refresh', '📦': 'pack', '🔑': 'key', '🗝': 'key',
88
+ '✨': 'sparkles', '⚠': 'alert', '⚡': 'zap', '🛡': 'shield', '📋': 'clipboard', '📘': 'book', '📖': 'book', '📚': 'book',
89
+ '✏': 'pencil', '✍': 'pencil', '📝': 'fileEdit', '📂': 'folderOpen', '📁': 'folder', '🗂': 'folder', '👥': 'users', '👤': 'user',
90
+ '✅': 'checkCircle', '✓': 'check', '✔': 'check', '☑': 'checkSquare', '💡': 'bulb', '↗': 'external', '🔍': 'search', '🔎': 'search',
91
+ '⚙': 'settings', '👁': 'eye', '💬': 'message', '🤖': 'bot', '👉': 'pointer', '🩺': 'activity', '⏳': 'hourglass', '⌛': 'hourglass',
92
+ '🔒': 'lock', '🔐': 'lock', '❓': 'help', '❔': 'help', '🛒': 'cart', '📄': 'file', '📃': 'file', '🔔': 'bell', '📱': 'phone',
93
+ '↩': 'undo', '📊': 'chart', '📈': 'chart', '🛠': 'wrench', '🔧': 'wrench', '🏷': 'tag', '🗑': 'trash', '🧠': 'memory',
94
+ '🧩': 'blocks', '⏸': 'pause', '🔗': 'link', '💾': 'save', '📨': 'send', '📤': 'share', '⏭': 'skip', '☰': 'menu', '⏰': 'alarm',
95
+ '🖼': 'image', '▦': 'grid', '◈': 'diamond', '🔤': 'type', '🕘': 'clock', '🕐': 'clock', '🌐': 'globe', '🆕': 'plusSquare',
96
+ '📷': 'camera', '📸': 'camera', '📎': 'clip', '✕': 'close', '✖': 'close', '📌': 'pin', '←': 'back', '🎤': 'mic', '🎙': 'mic',
97
+ '🏠': 'home', '▶': 'play', '⏹': 'stop', '🚀': 'rocket', '💻': 'terminal', '⌨': 'terminal', '📑': 'copy', '⭐': 'star', '🧹': 'broom', '🐚': 'terminal', '🧰': 'wrench', '🧪': 'activity', '🔥': 'zap', '📭': 'inbox', '🗄': 'save',
98
+ };
99
+ const NS = 'http://www.w3.org/2000/svg';
100
+ // 图标位:按钮、设置条目、快捷栏、菜单项、列表图标格
101
+ const CAND = 'button, .set-link, .sk, .hd-btn, .mi, .m-ico, .fp-icon, .fp-btn, .ii-icon, .chip-icon, .rb, [data-ico], #ai-banner b, .set-mode, #guide-tip > span:first-child, .ask-head b, .mig-row > span:first-child, #mig-box h3, .action-sheet-title';
102
+ // 内容区不动:聊天消息 / AI 回复 / 状态行、可编辑区、终端、明确不要的
103
+ const SKIP = '#chat-area, .msg, .content, .bubble, textarea, input, [contenteditable], .xterm, [data-no-ico], #plan-sheet-body, #plan-digest, .ask-a';
104
+ const LEAD = /^\s*((?:[←-⇿⌀-⏿■-➿⬀-⯿]|[\uD83C-\uDBFF][\uDC00-\uDFFF])️?)\s?/;
105
+
106
+ function svgFor(name) {
107
+ const s = document.createElementNS(NS, 'svg');
108
+ s.setAttribute('viewBox', '0 0 24 24');
109
+ s.setAttribute('aria-hidden', 'true');
110
+ s.setAttribute('class', 'ui-ico');
111
+ s.innerHTML = P[name];
112
+ return s;
113
+ }
114
+ // 找元素里第一个有字的文本节点(遇到已换好的图标就停)
115
+ function firstText(el) {
116
+ for (const n of el.childNodes) {
117
+ if (n.nodeType === 3) { if (n.data.trim()) return n; continue; }
118
+ if (n.nodeType !== 1) continue;
119
+ if (n.classList?.contains('ui-ico') || n.tagName === 'svg' || n.tagName === 'IMG') return null;
120
+ const t = firstText(n); if (t !== undefined) return t;
121
+ }
122
+ return undefined;
123
+ }
124
+ function convert(el) {
125
+ if (!el || el.nodeType !== 1 || el.closest(SKIP)) return;
126
+ const t = firstText(el);
127
+ if (!t) return;
128
+ const m = LEAD.exec(t.data);
129
+ if (!m) return;
130
+ const name = MAP[m[1].replace('️', '')];
131
+ if (!name || !P[name]) return;
132
+ const svg = svgFor(name);
133
+ const rest = t.data.slice(m[0].length);
134
+ t.parentNode.insertBefore(svg, t);
135
+ t.data = rest;
136
+ if (!rest.trim() && !t.nextSibling) svg.classList.add('solo'); // 只有图标的按钮(✕ ☰ 等):不留右边距
137
+ }
138
+ function scan(root) {
139
+ if (!root || root.nodeType !== 1) return;
140
+ if (root.matches?.(CAND)) convert(root);
141
+ root.querySelectorAll?.(CAND).forEach(convert);
142
+ }
143
+ // 之后重新渲染的按钮 / 菜单(改文字、弹出菜单、抽屉列表)也换;聊天区的变动直接忽略(量大,且不是图标)
144
+ let queue = new Set(), raf = 0;
145
+ const flush = () => { raf = 0; const q = queue; queue = new Set(); q.forEach(scan); };
146
+ function enqueue(n) {
147
+ const el = n.nodeType === 1 ? n : n.parentElement;
148
+ if (!el || el.closest('#chat-area')) return;
149
+ const c = el.closest(CAND);
150
+ queue.add(c || el);
151
+ if (!raf) raf = requestAnimationFrame(flush);
152
+ }
153
+ function start() {
154
+ const css = document.createElement('style');
155
+ css.textContent = '.ui-ico{width:1.05em;height:1.05em;vertical-align:-0.17em;flex-shrink:0;fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round;margin-right:0.32em}.ui-ico.solo{margin-right:0}';
156
+ document.head.appendChild(css);
157
+ scan(document.body);
158
+ new MutationObserver((ms) => {
159
+ for (const m of ms) {
160
+ if (m.type === 'characterData') enqueue(m.target);
161
+ else m.addedNodes.forEach(enqueue);
162
+ }
163
+ }).observe(document.body, { childList: true, subtree: true, characterData: true });
164
+ }
165
+ window.myhiIcon = (name) => (P[name] ? svgFor(name).outerHTML : '');
166
+ if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', start); else start();
167
+ })();
@@ -0,0 +1,310 @@
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, maximum-scale=1.0, viewport-fit=cover">
6
+ <meta name="theme-color" content="#0d1117">
7
+ <link rel="manifest" href="/manifest.json">
8
+ <link rel="apple-touch-icon" href="/icon.png">
9
+ <title>语音处理 · myhi</title>
10
+ <script src="/theme.js"></script>
11
+ <script src="/lib/machine.js"></script>
12
+ <script src="/lib/icons.js"></script>
13
+ <script>
14
+ (function(){try{var t=localStorage.getItem('myhi_theme')||window.MYHI_DEFAULT_THEME||'dark',f=localStorage.getItem('myhi_font')||'medium',r=document.documentElement;if(t&&t!=='dark')r.setAttribute('data-theme',t);r.setAttribute('data-font',f);}catch(e){}})();
15
+ </script>
16
+ <style>
17
+ :root {
18
+ --bg:#0d1117; --surface:#161b22; --surface2:#1c2128; --border:#21262d; --border2:#30363d;
19
+ --text:#e6edf3; --text2:#b1bac4; --muted:#8b949e; --dim:#6e7681;
20
+ --accent:#7c3aed; --red:#f85149; --green:#3fb950; --yellow:#d29922; --orange:#f0883e; --blue:#58a6ff;
21
+ }
22
+ :root[data-theme="light"] { --bg:#ffffff; --surface:#f6f8fa; --surface2:#eef1f4; --border:#d0d7de; --border2:#d0d7de;
23
+ --text:#1f2328; --text2:#57606a; --muted:#656d76; --dim:#818b98;
24
+ --accent:#8250df; --red:#cf222e; --green:#1a7f37; --yellow:#9a6700; --orange:#bc4c00; --blue:#0969da; }
25
+ :root[data-theme="black"] { --bg:#000000; --surface:#0a0a0a; --surface2:#111; --border:#161616; --border2:#262626; }
26
+ @media (prefers-color-scheme: light) { :root[data-theme="system"] { --bg:#ffffff; --surface:#f6f8fa; --surface2:#eef1f4; --border:#d0d7de; --border2:#d0d7de;
27
+ --text:#1f2328; --text2:#57606a; --muted:#656d76; --dim:#818b98;
28
+ --accent:#8250df; --red:#cf222e; --green:#1a7f37; --yellow:#9a6700; --orange:#bc4c00; --blue:#0969da; } }
29
+ html { font-size: 16px; } html[data-font="small"]{font-size:15px;} html[data-font="medium"]{font-size:17px;} html[data-font="large"]{font-size:19.5px;}
30
+ * { box-sizing: border-box; margin: 0; padding: 0; }
31
+ body { background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 0.85rem; line-height: 1.6; }
32
+ a { color: var(--blue); text-decoration: none; cursor: pointer; }
33
+ #hd { display: flex; align-items: center; gap: 0.6rem; padding: max(0.6rem, env(safe-area-inset-top)) 1rem 0.6rem; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 5; }
34
+ #hd .back { color: var(--muted); }
35
+ body.embed #hd .back { display: none; }
36
+ body.embed #hd { padding-top: 0.6rem; }
37
+ #hd h1 { font-size: 1rem; font-weight: 600; }
38
+ #wrap { display: grid; grid-template-columns: 360px 1fr; gap: 1rem; padding: 1rem; max-width: 1400px; margin: 0 auto; align-items: start; }
39
+ @media (max-width: 860px) { #wrap { grid-template-columns: 1fr; padding: 0.75rem; } }
40
+ .card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 0.9rem; }
41
+ .card + .card { margin-top: 0.8rem; }
42
+ .lbl { display: block; font-weight: 600; margin: 0.7rem 0 0.3rem; font-size: 0.82rem; }
43
+ .lbl:first-child { margin-top: 0; }
44
+ .lbl small { font-weight: 400; color: var(--muted); margin-left: 0.3rem; }
45
+ textarea, input[type=text], input[type=date], select { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border2); border-radius: 8px; padding: 0.5rem 0.6rem; font: inherit; outline: none; }
46
+ textarea:focus, input:focus, select:focus { border-color: var(--accent); }
47
+ .file { border: 1.5px dashed var(--border2); border-radius: 10px; padding: 0.9rem; text-align: center; cursor: pointer; color: var(--muted); }
48
+ .file:hover, .file.drag { border-color: var(--accent); color: var(--text); }
49
+ .file b { color: var(--text); }
50
+ .go { width: 100%; margin-top: 0.9rem; background: var(--accent); color: #fff; border: none; border-radius: 10px; padding: 0.7rem; font: inherit; font-weight: 600; font-size: 0.92rem; cursor: pointer; }
51
+ .go:disabled { opacity: 0.55; cursor: default; }
52
+ .bar { height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden; margin-top: 0.5rem; }
53
+ .bar > div { height: 100%; background: var(--accent); width: 0; transition: width 0.3s; }
54
+ .hint { font-size: 0.72rem; color: var(--muted); margin-top: 0.5rem; line-height: 1.6; }
55
+ .warn { color: var(--yellow); } .err { color: var(--red); } .ok { color: var(--green); }
56
+ .empty { color: var(--muted); text-align: center; padding: 2.5rem 1rem; }
57
+ .btn { background: var(--surface2); border: 1px solid var(--border2); color: var(--text); border-radius: 8px; padding: 0.3rem 0.7rem; font: inherit; font-size: 0.78rem; cursor: pointer; white-space: nowrap; }
58
+ .btn:hover { border-color: var(--accent); }
59
+ .btn.pri { background: var(--accent); color: #fff; border-color: var(--accent); }
60
+ .btn:disabled { opacity: 0.5; cursor: default; }
61
+ #job-hd { display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; }
62
+ #job-hd b { font-size: 1rem; }
63
+ #job-hd .meta { color: var(--muted); font-size: 0.75rem; }
64
+ .steps { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; margin: 0.6rem 0; font-size: 0.78rem; }
65
+ .step { padding: 0.15rem 0.6rem; border-radius: 12px; border: 1px solid var(--border2); color: var(--muted); }
66
+ .step.done { color: var(--green); border-color: var(--green); }
67
+ .step.on { color: #fff; background: var(--accent); border-color: var(--accent); }
68
+ .step.bad { color: var(--red); border-color: var(--red); }
69
+ .spk { display: grid; grid-template-columns: 140px 1fr; gap: 0.3rem 0.6rem; align-items: center; margin-top: 0.5rem; }
70
+ .spk .dot { display: inline-block; width: 0.6rem; height: 0.6rem; border-radius: 50%; margin-right: 0.3rem; vertical-align: middle; }
71
+ .spk small { color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
72
+ .tabs { display: flex; gap: 0.2rem; border-bottom: 1px solid var(--border); margin: 0.8rem 0 0.6rem; }
73
+ .tabs button { background: none; border: none; color: var(--muted); padding: 0.4rem 0.8rem; font: inherit; cursor: pointer; border-bottom: 2px solid transparent; }
74
+ .tabs button.on { color: var(--text); border-color: var(--accent); font-weight: 600; }
75
+ .acts { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
76
+ .md { line-height: 1.75; }
77
+ .md h1 { font-size: 1.25rem; margin: 0.4rem 0 0.6rem; } .md h2 { font-size: 1.05rem; margin: 1rem 0 0.4rem; padding-bottom: 0.2rem; border-bottom: 1px solid var(--border); } .md h3 { font-size: 0.95rem; margin: 0.8rem 0 0.3rem; }
78
+ .md p { margin: 0.4rem 0; } .md ul, .md ol { padding-left: 1.4rem; margin: 0.3rem 0; }
79
+ .md table { border-collapse: collapse; margin: 0.5rem 0; width: 100%; font-size: 0.8rem; } .md th, .md td { border: 1px solid var(--border2); padding: 0.3rem 0.5rem; text-align: left; vertical-align: top; } .md th { background: var(--surface2); }
80
+ .md code { background: var(--surface2); padding: 0 0.25rem; border-radius: 4px; }
81
+ #mtext { min-height: 60vh; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.8rem; line-height: 1.6; }
82
+ .tr { margin: 0.45rem 0; }
83
+ .tr .w { font-weight: 600; margin-right: 0.3rem; }
84
+ .tr .t { color: var(--muted); font-size: 0.72rem; margin-right: 0.3rem; font-variant-numeric: tabular-nums; }
85
+ #hist .h { padding: 0.45rem 0.4rem; border-top: 1px solid var(--border); cursor: pointer; border-radius: 6px; }
86
+ #hist .h:first-child { border-top: none; }
87
+ #hist .h:hover, #hist .h.on { background: var(--surface2); }
88
+ #hist .h div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
89
+ #hist .h small { color: var(--muted); }
90
+ </style>
91
+ </head>
92
+ <body>
93
+ <script>if (new URLSearchParams(location.search).get('embed')) document.body.classList.add('embed');</script>
94
+ <div id="hd"><a class="back" href="/">‹ myhi</a><h1 data-ico>🎤 语音处理 <span style="font-weight:400;color:var(--muted);font-size:0.85rem">· 会议纪要</span></h1></div>
95
+ <div id="wrap">
96
+ <div>
97
+ <div class="card">
98
+ <label class="lbl">会议录音</label>
99
+ <div class="file" id="drop" onclick="$('file').click()"><b>点这里选录音文件</b>,或拖进来<br><small>mp3、m4a、wav、aac、amr、webm、mp4 等,最大 1GB</small></div>
100
+ <input type="file" id="file" accept="audio/*,video/mp4,video/webm,.m4a,.amr,.mp3,.wav,.aac" style="display:none">
101
+ <div id="fname" class="hint"></div>
102
+ <label class="lbl" for="title">会议名称</label>
103
+ <input type="text" id="title" placeholder="例如:双十一活动筹备会">
104
+ <label class="lbl" for="mdate">会议时间</label>
105
+ <input type="date" id="mdate">
106
+ <label class="lbl" for="att">参会人<small>可选,帮 AI 把发言人对上人名</small></label>
107
+ <input type="text" id="att" placeholder="例如:张总、李经理、王工">
108
+ <label class="lbl" for="focus">整理重点<small>可选</small></label>
109
+ <textarea id="focus" rows="2" placeholder="例如:重点整理预算和时间节点"></textarea>
110
+ <label class="lbl" for="save-to">保存到项目<small>可选:纪要和逐字稿自动放进项目的「会议纪要」文件夹</small></label>
111
+ <select id="save-to"><option value="">不保存(之后也可以手动保存)</option></select>
112
+ <button class="go" id="go" onclick="upload()">上传并整理纪要</button>
113
+ <div id="up" style="display:none"><div class="bar"><div></div></div><div class="hint" id="up-t"></div></div>
114
+ <div class="hint" id="cfg-hint"></div>
115
+ </div>
116
+ <div class="card">
117
+ <div style="display:flex;align-items:center;margin-bottom:0.3rem"><b>历史</b><a style="margin-left:auto;font-size:0.75rem" onclick="loadHistory()">刷新</a></div>
118
+ <div id="hist"><div class="empty" style="padding:1rem">还没有整理过会议</div></div>
119
+ </div>
120
+ </div>
121
+ <div class="card" id="result"><div class="empty">左边选好录音、填上会议名称,点「上传并整理纪要」。<br>会先转写成文字并区分发言人,再由 AI 整理成纪要:议题、决议、待办。</div></div>
122
+ </div>
123
+ <script>
124
+ const $ = (id) => document.getElementById(id);
125
+ const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
126
+ const COLORS = ['#7c3aed', '#0969da', '#1a7f37', '#bc4c00', '#cf222e', '#8a6d00', '#6639ba', '#0e7490'];
127
+ let CFG = null, CUR = null, POLL = null, TAB = 'minutes', EDIT = false, FILE = null;
128
+ const fmt = (s) => { s = Math.max(0, Math.round(s || 0)); const h = Math.floor(s / 3600), m = Math.floor((s % 3600) / 60), x = s % 60; return (h ? h + ':' : '') + String(m).padStart(2, '0') + ':' + String(x).padStart(2, '0'); };
129
+ const fmtSize = (n) => n >= 1048576 ? (n / 1048576).toFixed(1) + ' MB' : Math.max(1, Math.round(n / 1024)) + ' KB';
130
+ $('mdate').value = new Date(Date.now() - new Date().getTimezoneOffset() * 60000).toISOString().slice(0, 10);
131
+
132
+ async function api(path, opt) {
133
+ const r = await fetch(path, opt);
134
+ if (r.status === 401 || r.redirected) { location.href = '/'; throw new Error('需要登录'); }
135
+ return r.json();
136
+ }
137
+ async function loadConfig() {
138
+ CFG = await api('/api/minutes/config').catch((e) => ({ ok: false, error: e.message }));
139
+ $('save-to').innerHTML = '<option value="">不保存(之后也可以手动保存)</option>' + (CFG.projects || []).map((p) => `<option value="${esc(p.cwd)}">${esc(p.name)}${p.title ? '(' + esc(p.title) + ')' : ''}</option>`).join('');
140
+ const h = [];
141
+ if (!CFG.asr) { h.push('<span class="err">还没有配置语音服务:到 /admin › 语音输入 填语音服务地址</span>'); $('go').disabled = true; }
142
+ h.push('生成纪要用的模型:' + esc(CFG.model || 'Claude Code 默认') + '(首页 ⚙ 设置 › 系统设置 · 模型 › 会议纪要)');
143
+ $('cfg-hint').innerHTML = h.join('<br>');
144
+ }
145
+ function pickFile(f) {
146
+ if (!f) return;
147
+ FILE = f;
148
+ $('fname').innerHTML = `已选:<b>${esc(f.name)}</b>(${fmtSize(f.size)})`;
149
+ if (!$('title').value.trim()) $('title').value = f.name.replace(/\.[^.]+$/, '').slice(0, 60);
150
+ }
151
+ $('file').onchange = (e) => pickFile(e.target.files[0]);
152
+ const drop = $('drop');
153
+ ['dragover', 'dragenter'].forEach((t) => drop.addEventListener(t, (e) => { e.preventDefault(); drop.classList.add('drag'); }));
154
+ ['dragleave', 'drop'].forEach((t) => drop.addEventListener(t, (e) => { e.preventDefault(); drop.classList.remove('drag'); }));
155
+ drop.addEventListener('drop', (e) => pickFile(e.dataTransfer.files[0]));
156
+
157
+ window.upload = function () {
158
+ if (!FILE) { $('drop').click(); return; }
159
+ const fd = new FormData();
160
+ fd.append('title', $('title').value); fd.append('meetingDate', $('mdate').value); fd.append('attendees', $('att').value);
161
+ fd.append('focus', $('focus').value); fd.append('saveTo', $('save-to').value);
162
+ fd.append('audio', FILE); // 文件放最后:服务端先拿到其它字段
163
+ const up = $('up'), bar = up.querySelector('.bar > div'), t = $('up-t');
164
+ up.style.display = ''; $('go').disabled = true;
165
+ const xhr = new XMLHttpRequest(); xhr.open('POST', '/api/minutes/jobs');
166
+ xhr.upload.onprogress = (e) => { if (e.lengthComputable) { bar.style.width = (e.loaded / e.total * 100) + '%'; t.textContent = `上传中… ${fmtSize(e.loaded)} / ${fmtSize(e.total)}`; } };
167
+ xhr.onload = () => {
168
+ $('go').disabled = !CFG?.asr;
169
+ let r; try { r = JSON.parse(xhr.responseText); } catch { r = { ok: false, error: '上传失败(' + xhr.status + ')' }; }
170
+ if (!r.ok) { t.innerHTML = '<span class="err">' + esc(r.error) + '</span>'; return; }
171
+ t.textContent = '已上传,正在转写…'; bar.style.width = '100%';
172
+ FILE = null; $('file').value = ''; $('fname').textContent = '';
173
+ TAB = 'minutes'; EDIT = false; showJob(r.job); loadHistory();
174
+ };
175
+ xhr.onerror = () => { $('go').disabled = false; t.innerHTML = '<span class="err">上传失败,网络中断了,请重试</span>'; };
176
+ xhr.send(fd);
177
+ };
178
+
179
+ // 极简 Markdown → HTML(标题、列表、表格、粗体、行内代码),纪要预览够用
180
+ function md(src) {
181
+ const inline = (s) => esc(s).replace(/\*\*(.+?)\*\*/g, '<b>$1</b>').replace(/`([^`]+)`/g, '<code>$1</code>');
182
+ const lines = String(src || '').split('\n'); let html = '', i = 0;
183
+ while (i < lines.length) {
184
+ const l = lines[i];
185
+ if (/^\s*$/.test(l)) { i++; continue; }
186
+ let m;
187
+ if ((m = /^(#{1,3})\s+(.*)$/.exec(l))) { html += `<h${m[1].length}>${inline(m[2])}</h${m[1].length}>`; i++; continue; }
188
+ if (/^\s*\|/.test(l)) {
189
+ const rows = []; while (i < lines.length && /^\s*\|/.test(lines[i])) rows.push(lines[i++]);
190
+ const cells = (r) => r.trim().replace(/^\||\|$/g, '').split('|').map((c) => c.trim());
191
+ const body = rows.filter((r) => !/^\s*\|[\s:|-]+\|\s*$/.test(r));
192
+ html += '<table>' + body.map((r, k) => '<tr>' + cells(r).map((c) => k === 0 ? `<th>${inline(c)}</th>` : `<td>${inline(c)}</td>`).join('') + '</tr>').join('') + '</table>';
193
+ continue;
194
+ }
195
+ if (/^\s*([-*]|\d+\.)\s+/.test(l)) {
196
+ const ol = /^\s*\d+\./.test(l), items = [];
197
+ while (i < lines.length && /^\s*([-*]|\d+\.)\s+/.test(lines[i])) items.push(lines[i++].replace(/^\s*([-*]|\d+\.)\s+/, ''));
198
+ html += `<${ol ? 'ol' : 'ul'}>` + items.map((x) => `<li>${inline(x)}</li>`).join('') + `</${ol ? 'ol' : 'ul'}>`;
199
+ continue;
200
+ }
201
+ const para = []; while (i < lines.length && lines[i].trim() && !/^(#{1,3}\s|\s*\||\s*([-*]|\d+\.)\s)/.test(lines[i])) para.push(lines[i++]);
202
+ html += `<p>${para.map(inline).join('<br>')}</p>`;
203
+ }
204
+ return html;
205
+ }
206
+
207
+ const spkName = (job, k) => (k == null ? '' : job.speakers?.[k] || ('发言人' + (Number(k) + 1)));
208
+ const spkColor = (job, k) => COLORS[Object.keys(job.speakers || {}).indexOf(String(k)) % COLORS.length] || 'var(--text2)';
209
+ function showJob(job) {
210
+ CUR = job;
211
+ const busy = job.status === 'transcribing' || job.status === 'summarizing';
212
+ const st = (k) => {
213
+ if (k === 'up') return 'done';
214
+ if (k === 'asr') return job.status === 'transcribing' ? 'on' : job.segments?.length ? 'done' : job.status === 'error' || job.status === 'cancelled' ? 'bad' : '';
215
+ return job.status === 'summarizing' ? 'on' : job.minutes && job.status === 'done' ? 'done' : job.status === 'error' && job.segments?.length ? 'bad' : '';
216
+ };
217
+ const spks = Object.keys(job.speakers || {});
218
+ const counts = {}; (job.segments || []).forEach((s) => { if (s.spk != null) counts[s.spk] = (counts[s.spk] || 0) + 1; });
219
+ const sample = (k) => (job.segments || []).find((s) => s.spk === k && s.text.length > 6)?.text || '';
220
+ let body = '';
221
+ if (spks.length && !busy || (spks.length && job.status === 'summarizing')) {
222
+ body += `<div class="card" style="margin-top:0.6rem;background:var(--bg)"><b>发言人</b><span class="hint" style="margin-left:0.4rem">自动区分的,把名字改成真名后点「按新名字重新生成纪要」</span>
223
+ <div class="spk">${spks.map((k) => `<input type="text" data-spk="${esc(k)}" value="${esc(job.speakers[k])}" style="border-left:4px solid ${spkColor(job, k)}"><div><small>${counts[k] || 0} 段 · 「${esc(sample(k).slice(0, 40))}」</small></div>`).join('')}</div>
224
+ <div class="acts" style="margin:0.6rem 0 0"><button class="btn" onclick="saveSpeakers(false)">保存名字</button><button class="btn pri" onclick="saveSpeakers(true)" ${busy ? 'disabled' : ''}>按新名字重新生成纪要</button></div></div>`;
225
+ }
226
+ const tabs = `<div class="tabs"><button class="${TAB === 'minutes' ? 'on' : ''}" onclick="setTab('minutes')">纪要</button><button class="${TAB === 'tr' ? 'on' : ''}" onclick="setTab('tr')">逐字稿${job.segments?.length ? '(' + job.segments.length + ' 段)' : ''}</button></div>`;
227
+ let pane = '';
228
+ if (TAB === 'minutes') {
229
+ if (job.minutes) {
230
+ pane = `<div class="acts">${EDIT ? '<button class="btn pri" onclick="saveEdit()">保存修改</button><button class="btn" onclick="setEdit(false)">取消</button>' : '<button class="btn" onclick="setEdit(true)">编辑</button>'}
231
+ <button class="btn" onclick="copyMinutes()">复制</button><a class="btn" href="/api/minutes/jobs/${encodeURIComponent(job.id)}/download">下载 .md</a>
232
+ ${CFG?.projects?.length ? '<button class="btn" onclick="saveProject()">保存到项目</button>' : ''}<button class="btn" onclick="regen()" ${busy ? 'disabled' : ''}>重新生成</button></div>`
233
+ + (EDIT ? `<textarea id="mtext">${esc(job.minutes)}</textarea>` : `<div class="md">${md(job.minutes)}</div>`);
234
+ } else pane = `<div class="empty">${busy ? esc(job.stage || '处理中…') + (job.status === 'transcribing' && job.progress ? `(${Math.round(job.progress * 100)}%)` : '') + '<br><small>1 小时的会议,转写通常要几分钟到十几分钟;可以离开这个页面,回来在「历史」里查看</small>' : job.status === 'error' ? '<span class="err">' + esc(job.error || '出错了') + '</span>' : job.status === 'cancelled' ? '已取消' : ''}</div>`;
235
+ } else {
236
+ pane = job.segments?.length ? `<div class="acts"><a class="btn" href="/api/minutes/jobs/${encodeURIComponent(job.id)}/download?what=transcript">下载逐字稿 .md</a></div>`
237
+ + job.segments.map((s) => `<div class="tr">${s.start != null ? `<span class="t">${fmt(s.start)}</span>` : ''}${s.spk != null ? `<span class="w" style="color:${spkColor(job, s.spk)}">${esc(spkName(job, s.spk))}</span>` : ''}${esc(s.text)}</div>`).join('')
238
+ : `<div class="empty">${busy ? '转写中…' : '没有逐字稿'}</div>`;
239
+ }
240
+ $('result').innerHTML = `<div id="job-hd"><b>${esc(job.title)}</b><span class="meta">${esc(job.meetingDate)}${job.duration ? ' · ' + fmt(job.duration) : ''}${spks.length ? ' · ' + spks.length + ' 位发言人' : ''} · ${esc(job.audio?.name || '')}</span>
241
+ ${job.status === 'transcribing' ? '<button class="btn" style="margin-left:auto" onclick="cancelJob()">取消</button>' : ''}</div>
242
+ <div class="steps"><span class="step ${st('up')}">① 上传</span>›<span class="step ${st('asr')}">② 转写${job.status === 'transcribing' && job.progress ? ' ' + Math.round(job.progress * 100) + '%' : ''}</span>›<span class="step ${st('ai')}">③ 生成纪要</span>
243
+ ${busy ? `<span class="hint" style="margin:0">${esc(job.stage || '')}</span>` : ''}</div>
244
+ ${job.status === 'error' ? `<div class="hint err">${esc(job.error || '')}</div>` : ''}
245
+ ${(job.notes || []).map((n) => `<div class="hint warn">${esc(n)}</div>`).join('')}
246
+ ${(job.savedTo || []).length ? `<div class="hint ok">已保存到项目:${job.savedTo.map(esc).join('、')}</div>` : ''}
247
+ ${body}${tabs}${pane}`;
248
+ document.querySelectorAll('#hist .h').forEach((h) => h.classList.toggle('on', h.dataset.id === job.id));
249
+ clearTimeout(POLL);
250
+ if (busy) POLL = setTimeout(() => refresh(job.id), 3000);
251
+ else $('up').style.display = 'none'; // 上传进度条:处理完就收起
252
+ }
253
+ async function refresh(id) {
254
+ const d = await api('/api/minutes/jobs/' + encodeURIComponent(id)).catch(() => null);
255
+ if (!d?.ok || CUR?.id !== id) return;
256
+ if (EDIT) { CUR = d.job; clearTimeout(POLL); return; } // 编辑中不刷掉正在改的内容
257
+ const was = CUR.status; showJob(d.job);
258
+ if (was !== d.job.status && !['transcribing', 'summarizing'].includes(d.job.status)) loadHistory();
259
+ }
260
+ window.setTab = (t) => { TAB = t; showJob(CUR); };
261
+ window.setEdit = (on) => { EDIT = on; showJob(CUR); };
262
+ window.saveEdit = async () => {
263
+ const markdown = $('mtext').value;
264
+ const d = await api(`/api/minutes/jobs/${CUR.id}/minutes`, { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ markdown }) }).catch((e) => ({ ok: false, error: e.message }));
265
+ if (!d.ok) return alert('保存失败:' + d.error);
266
+ CUR.minutes = markdown; EDIT = false; showJob(CUR);
267
+ };
268
+ window.copyMinutes = async () => { try { await navigator.clipboard.writeText(CUR.minutes); alert('已复制纪要'); } catch { alert('复制失败,请用「下载 .md」'); } };
269
+ window.saveSpeakers = async (regen) => {
270
+ const speakers = {}; document.querySelectorAll('[data-spk]').forEach((i) => { speakers[i.dataset.spk] = i.value.trim(); });
271
+ const d = await api(`/api/minutes/jobs/${CUR.id}/speakers`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ speakers }) }).catch((e) => ({ ok: false, error: e.message }));
272
+ if (!d.ok) return alert('保存失败:' + d.error);
273
+ if (regen) return window.regen();
274
+ showJob(d.job);
275
+ };
276
+ window.regen = async () => {
277
+ const d = await api(`/api/minutes/jobs/${CUR.id}/regenerate`, { method: 'POST' }).catch((e) => ({ ok: false, error: e.message }));
278
+ if (!d.ok) return alert(d.error);
279
+ EDIT = false; TAB = 'minutes'; refresh(CUR.id);
280
+ };
281
+ window.cancelJob = async () => { await api(`/api/minutes/jobs/${CUR.id}/cancel`, { method: 'POST' }).catch(() => {}); refresh(CUR.id); };
282
+ window.saveProject = async () => {
283
+ const ps = CFG?.projects || [];
284
+ let cwd = $('save-to').value;
285
+ if (!cwd) {
286
+ const pick = prompt('保存到哪个项目?输入序号:\n' + ps.map((p, i) => `${i + 1}. ${p.name}${p.title ? '(' + p.title + ')' : ''}`).join('\n'));
287
+ const k = parseInt(pick, 10); if (!k || !ps[k - 1]) return; cwd = ps[k - 1].cwd;
288
+ }
289
+ const d = await api(`/api/minutes/jobs/${CUR.id}/save`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ cwd }) }).catch((e) => ({ ok: false, error: e.message }));
290
+ alert(d.ok ? '已保存到:\n' + d.saved.join('\n') : '保存失败:' + d.error);
291
+ refresh(CUR.id);
292
+ };
293
+ async function loadHistory() {
294
+ const d = await api('/api/minutes/jobs').catch(() => null);
295
+ const jobs = d?.jobs || [];
296
+ const ST = { transcribing: '转写中', summarizing: '生成纪要中', done: '已完成', error: '出错', cancelled: '已取消' };
297
+ $('hist').innerHTML = jobs.length ? jobs.map((j) => `<div class="h" data-id="${esc(j.id)}"><div>${esc(j.title)}</div><small>${esc(j.meetingDate)}${j.duration ? ' · ' + fmt(j.duration) : ''}${j.speakers ? ' · ' + j.speakers + ' 人' : ''} · ${ST[j.status] || j.status}</small></div>`).join('')
298
+ : '<div class="empty" style="padding:1rem">还没有整理过会议</div>';
299
+ $('hist').querySelectorAll('.h').forEach((h) => h.onclick = async () => {
300
+ const r = await api('/api/minutes/jobs/' + encodeURIComponent(h.dataset.id)).catch(() => null);
301
+ if (r?.ok) { TAB = 'minutes'; EDIT = false; showJob(r.job); if (innerWidth <= 860) $('result').scrollIntoView({ behavior: 'smooth' }); }
302
+ });
303
+ if (CUR) document.querySelectorAll('#hist .h').forEach((h) => h.classList.toggle('on', h.dataset.id === CUR.id));
304
+ }
305
+ loadConfig(); loadHistory();
306
+ const q = new URLSearchParams(location.search).get('job');
307
+ if (q) api('/api/minutes/jobs/' + encodeURIComponent(q)).then((r) => r?.ok && showJob(r.job)).catch(() => {});
308
+ </script>
309
+ </body>
310
+ </html>
Binary file