路径降级处理

main
SWX\10484 6 days ago
parent 6d3ebd0bb7
commit c253e9e58f
  1. 38
      src/layout/components/SystemSettingDialog.vue

@ -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:';

Loading…
Cancel
Save