|
|
|
@ -321,8 +321,14 @@ export default { |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 通用:弹出目录选择器 → 创建 HiUTalkStore 子文件夹 → 存储句柄 → 填充路径到输入框 |
|
|
|
// 通用:弹出目录选择器 → 创建 HiUTalkStore 子文件夹 → 存储句柄 → 填充路径到输入框 |
|
|
|
async _selectAndStorePath(handleKey, pathKey, label) { |
|
|
|
async _selectAndStorePath(handleKey, pathKey, label) { |
|
|
|
|
|
|
|
// File System Access API 必须在安全上下文(HTTPS/localhost)下才可用 |
|
|
|
if (!window.showDirectoryPicker) { |
|
|
|
if (!window.showDirectoryPicker) { |
|
|
|
this.$message.error('当前浏览器不支持,请使用 Chrome 或 Edge'); |
|
|
|
const reason = window.isSecureContext |
|
|
|
|
|
|
|
? '当前浏览器不支持目录选择(需要 Chrome/Edge 86+)' |
|
|
|
|
|
|
|
: '非安全连接(HTTP),目录选择仅支持 HTTPS 或 localhost'; |
|
|
|
|
|
|
|
this.$message({ message: `${reason},可手动输入路径`, type: 'warning', duration: 5000 }); |
|
|
|
|
|
|
|
// 降级:弹出输入框让用户手动填写路径 |
|
|
|
|
|
|
|
await this._manualInputPath(pathKey, label); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
try { |
|
|
|
try { |
|
|
|
@ -345,6 +351,36 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 降级方案:用户手动输入路径(showDirectoryPicker 不可用时) |
|
|
|
|
|
|
|
_manualInputPath(pathKey, label) { |
|
|
|
|
|
|
|
return new Promise((resolve) => { |
|
|
|
|
|
|
|
this.$prompt(`请输入${label}文件夹的完整路径(如 D:\\MyFolder\\HiUTalkStore)`, '手动输入路径', { |
|
|
|
|
|
|
|
confirmButtonText: '确定', |
|
|
|
|
|
|
|
cancelButtonText: '取消', |
|
|
|
|
|
|
|
inputValue: this.basicForm[pathKey], |
|
|
|
|
|
|
|
inputPattern: /^[A-Za-z]:\\.+$/, |
|
|
|
|
|
|
|
inputErrorMessage: '请输入有效的完整路径(如 D:\\RUS\\HiUTalkStore)', |
|
|
|
|
|
|
|
}).then(({ value }) => { |
|
|
|
|
|
|
|
this.basicForm[pathKey] = value.trim(); |
|
|
|
|
|
|
|
// 手动输入的路径无法获得目录句柄,清空 IndexedDB 中的旧句柄 |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
this._openIDB().then(db => { |
|
|
|
|
|
|
|
const tx = db.transaction('handles', 'readwrite'); |
|
|
|
|
|
|
|
tx.objectStore('handles').delete(pathKey === 'videoPath' ? 'screenshot_dir' : 'cache_dir'); |
|
|
|
|
|
|
|
db.close(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} catch (e) { /* 忽略 */ } |
|
|
|
|
|
|
|
// 标记未授权(HTTP 下无法使用 File System Access API 写入) |
|
|
|
|
|
|
|
if (pathKey === 'videoPath') this.videoAuthorized = false; |
|
|
|
|
|
|
|
if (pathKey === 'cachePath') this.cacheAuthorized = false; |
|
|
|
|
|
|
|
this.$message.success(`${label}路径已更新(由于非 HTTPS,截图/录制将使用浏览器下载)`); |
|
|
|
|
|
|
|
resolve(); |
|
|
|
|
|
|
|
}).catch(() => { |
|
|
|
|
|
|
|
resolve(); // 用户取消 |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
// 从路径中提取盘符,例如 "D:\RUS\HiUTalkStore" → "D:" |
|
|
|
// 从路径中提取盘符,例如 "D:\RUS\HiUTalkStore" → "D:" |
|
|
|
_extractDrive(path) { |
|
|
|
_extractDrive(path) { |
|
|
|
if (!path) return 'D:'; |
|
|
|
if (!path) return 'D:'; |
|
|
|
|