Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b97abb0fc6 | |||
| b8e670978c |
36
www/app.js
36
www/app.js
@@ -231,7 +231,8 @@ function openConversation(id) {
|
||||
const fileInput = document.getElementById('fileInput');
|
||||
|
||||
if (attachBtn) {
|
||||
attachBtn.addEventListener('click', () => {
|
||||
attachBtn.addEventListener('click', (e) => {
|
||||
e.stopPropagation(); // 阻止冒泡到 document
|
||||
attachPanel.classList.toggle('show');
|
||||
});
|
||||
}
|
||||
@@ -239,7 +240,7 @@ function openConversation(id) {
|
||||
// 点击其他地方关闭面板
|
||||
document.addEventListener('click', (e) => {
|
||||
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');
|
||||
}
|
||||
});
|
||||
@@ -468,21 +469,38 @@ function deleteMessage(index) {
|
||||
function copyMessage(index) {
|
||||
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(() => {
|
||||
showToast('已复制到剪贴板');
|
||||
}).catch(err => {
|
||||
// HTTP 环境下 navigator.clipboard 不工作,优先使用 fallback
|
||||
try {
|
||||
const textarea = document.createElement('textarea');
|
||||
textarea.value = content;
|
||||
textarea.style.position = 'fixed';
|
||||
textarea.style.top = '0';
|
||||
textarea.style.left = '0';
|
||||
textarea.style.opacity = '0';
|
||||
textarea.style.pointerEvents = 'none';
|
||||
document.body.appendChild(textarea);
|
||||
textarea.focus();
|
||||
textarea.select();
|
||||
document.execCommand('copy');
|
||||
|
||||
const success = document.execCommand('copy');
|
||||
document.body.removeChild(textarea);
|
||||
showToast('已复制到剪贴板');
|
||||
});
|
||||
|
||||
if (success) {
|
||||
showToast('已复制到剪贴板');
|
||||
} else {
|
||||
showToast('复制失败,请手动复制');
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('复制失败:', err);
|
||||
showToast('复制失败,请手动复制');
|
||||
}
|
||||
}
|
||||
|
||||
// 清空当前对话
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
<meta http-equiv="Pragma" content="no-cache">
|
||||
<meta http-equiv="Expires" content="0">
|
||||
<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">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script src="marked.min.js?v=2.1.0"></script>
|
||||
<script src="app.js?v=2.1.0"></script>
|
||||
<script src="marked.min.js?v=2.1.2"></script>
|
||||
<script src="app.js?v=2.1.2"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user