|
|
|
@ -886,8 +886,57 @@ export default { |
|
|
|
element.scrollIntoView({ behavior: "smooth", block: "start" }); |
|
|
|
element.scrollIntoView({ behavior: "smooth", block: "start" }); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 图片操作 |
|
|
|
// ==================== IndexedDB 目录句柄读取(与 SystemSettingDialog 共享 HiUTalkStoreDB) ==================== |
|
|
|
handleOpenFile() { |
|
|
|
_openIDB() { |
|
|
|
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
|
|
|
|
const req = indexedDB.open('HiUTalkStoreDB', 1); |
|
|
|
|
|
|
|
req.onupgradeneeded = () => { req.result.createObjectStore('handles'); }; |
|
|
|
|
|
|
|
req.onsuccess = () => resolve(req.result); |
|
|
|
|
|
|
|
req.onerror = () => reject(req.error); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
async _getStoredDirHandle(key) { |
|
|
|
|
|
|
|
const db = await this._openIDB(); |
|
|
|
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
|
|
|
|
const tx = db.transaction('handles', 'readonly'); |
|
|
|
|
|
|
|
const req = tx.objectStore('handles').get(key); |
|
|
|
|
|
|
|
req.onsuccess = () => { db.close(); resolve(req.result); }; |
|
|
|
|
|
|
|
req.onerror = () => { db.close(); reject(req.error); }; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
// 图片操作:优先使用系统设置中的 videoPath 目录选择文件 |
|
|
|
|
|
|
|
async handleOpenFile() { |
|
|
|
|
|
|
|
// 尝试使用系统设置中配置的 videoPath 目录打开文件选择器 |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
const dirHandle = await this._getStoredDirHandle('screenshot_dir'); |
|
|
|
|
|
|
|
if (dirHandle && window.showOpenFilePicker) { |
|
|
|
|
|
|
|
// 检查目录权限 |
|
|
|
|
|
|
|
let perm = await dirHandle.queryPermission({ mode: 'read' }); |
|
|
|
|
|
|
|
if (perm !== 'granted') { |
|
|
|
|
|
|
|
perm = await dirHandle.requestPermission({ mode: 'read' }); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (perm === 'granted') { |
|
|
|
|
|
|
|
const fileHandles = await window.showOpenFilePicker({ |
|
|
|
|
|
|
|
startIn: dirHandle, |
|
|
|
|
|
|
|
multiple: true, |
|
|
|
|
|
|
|
types: [{ |
|
|
|
|
|
|
|
description: 'Images', |
|
|
|
|
|
|
|
accept: { 'image/*': ['.png', '.jpg', '.jpeg', '.gif', '.bmp', '.webp'] }, |
|
|
|
|
|
|
|
}], |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
// 逐个上传选中的文件 |
|
|
|
|
|
|
|
for (const fileHandle of fileHandles) { |
|
|
|
|
|
|
|
const file = await fileHandle.getFile(); |
|
|
|
|
|
|
|
await this.uploadImageToMinIO(file); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
if (e.name === 'AbortError') return; // 用户取消选择 |
|
|
|
|
|
|
|
console.warn('基于系统设置目录的文件选择器不可用,降级使用默认文件选择:', e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 降级:使用原始的文件 input 方式 |
|
|
|
this.$refs.fileInput.click(); |
|
|
|
this.$refs.fileInput.click(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
async handleFileChange(event) { |
|
|
|
async handleFileChange(event) { |
|
|
|
|