Compare commits

..

2 Commits

2 changed files with 30 additions and 12 deletions

View File

@@ -231,7 +231,8 @@ function openConversation(id) {
const fileInput = document.getElementById('fileInput'); const fileInput = document.getElementById('fileInput');
if (attachBtn) { if (attachBtn) {
attachBtn.addEventListener('click', () => { attachBtn.addEventListener('click', (e) => {
e.stopPropagation(); // 阻止冒泡到 document
attachPanel.classList.toggle('show'); attachPanel.classList.toggle('show');
}); });
} }
@@ -239,7 +240,7 @@ function openConversation(id) {
// 点击其他地方关闭面板 // 点击其他地方关闭面板
document.addEventListener('click', (e) => { document.addEventListener('click', (e) => {
if (attachPanel && attachPanel.classList.contains('show') && if (attachPanel && attachPanel.classList.contains('show') &&
!attachPanel.contains(e.target) && e.target !== attachBtn) { !attachPanel.contains(e.target) && !attachBtn.contains(e.target)) {
attachPanel.classList.remove('show'); attachPanel.classList.remove('show');
} }
}); });
@@ -468,21 +469,38 @@ function deleteMessage(index) {
function copyMessage(index) { function copyMessage(index) {
if (!currentConversation) return; if (!currentConversation) return;
const content = currentConversation.messages[index].content; const msg = currentConversation.messages[index];
// 如果是图片消息,复制图片描述或提示
let content = msg.content;
if (msg.image && content === '[图片]') {
content = '[图片: ' + (msg.imageName || '未命名') + ']';
}
navigator.clipboard.writeText(content).then(() => { // HTTP 环境下 navigator.clipboard 不工作,优先使用 fallback
showToast('已复制到剪贴板'); try {
}).catch(err => {
const textarea = document.createElement('textarea'); const textarea = document.createElement('textarea');
textarea.value = content; textarea.value = content;
textarea.style.position = 'fixed'; textarea.style.position = 'fixed';
textarea.style.top = '0';
textarea.style.left = '0';
textarea.style.opacity = '0'; textarea.style.opacity = '0';
textarea.style.pointerEvents = 'none';
document.body.appendChild(textarea); document.body.appendChild(textarea);
textarea.focus();
textarea.select(); textarea.select();
document.execCommand('copy');
const success = document.execCommand('copy');
document.body.removeChild(textarea); document.body.removeChild(textarea);
if (success) {
showToast('已复制到剪贴板'); showToast('已复制到剪贴板');
}); } else {
showToast('复制失败,请手动复制');
}
} catch (err) {
console.error('复制失败:', err);
showToast('复制失败,请手动复制');
}
} }
// 清空当前对话 // 清空当前对话

View File

@@ -8,12 +8,12 @@
<meta http-equiv="Pragma" content="no-cache"> <meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0"> <meta http-equiv="Expires" content="0">
<title>AI助手</title> <title>AI助手</title>
<link rel="stylesheet" href="style.css?v=2.1.0"> <link rel="stylesheet" href="style.css?v=2.1.2">
<link rel="manifest" href="manifest.json"> <link rel="manifest" href="manifest.json">
</head> </head>
<body> <body>
<div id="app"></div> <div id="app"></div>
<script src="marked.min.js?v=2.1.0"></script> <script src="marked.min.js?v=2.1.2"></script>
<script src="app.js?v=2.1.0"></script> <script src="app.js?v=2.1.2"></script>
</body> </body>
</html> </html>