feat: unify cloud workspace and release desktop v0.1.38

This commit is contained in:
237899745
2026-07-21 16:16:17 +08:00
parent e6f3556ab7
commit 465be72579
19 changed files with 6145 additions and 666 deletions

View File

@@ -2045,28 +2045,28 @@ handleDragLeave(e) {
}
},
// 本地存储下载(先预检,避免浏览器下载 JSON 错误文件)
// 本地存储下载使用短时令牌,兼容不携带站点 Cookie 的系统下载器。
async downloadFromLocal(filePath) {
try {
const checkResp = await axios.get(`${this.apiBase}/api/files/download-check`, {
const response = await axios.get(`${this.apiBase}/api/files/download-url`, {
params: { path: filePath }
});
if (!checkResp.data?.success) {
this.showToast('error', '下载失败', checkResp.data?.message || '下载失败,请稍后重试');
if (!response.data?.success || !response.data?.downloadUrl) {
this.showToast('error', '下载失败', response.data?.message || '下载失败,请稍后重试');
return false;
}
const url = `${this.apiBase}/api/files/download?path=${encodeURIComponent(filePath)}`;
const link = document.createElement('a');
link.href = url;
link.href = response.data.downloadUrl;
link.setAttribute('download', '');
link.rel = 'noopener noreferrer';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
return true;
} catch (error) {
console.error('本地下载预检失败:', error);
console.error('获取本地下载地址失败:', error);
const message = error.response?.data?.message || '下载失败,请稍后重试';
this.showToast('error', '下载失败', message);
if (error.response?.status === 401) {
@@ -3101,9 +3101,26 @@ handleDragLeave(e) {
formData.append('chunk_index', String(chunkIndex));
formData.append('chunk', chunkBlob, `${file.name}.part${chunkIndex}`);
const confirmedUploadedBytes = uploadedBytes;
const chunkResp = await axios.post(`${this.apiBase}/api/upload/resumable/chunk`, formData, {
headers: { 'Content-Type': 'multipart/form-data' },
timeout: 30 * 60 * 1000
timeout: 30 * 60 * 1000,
onUploadProgress: (progressEvent) => {
const currentChunkLoaded = Math.min(
chunkBlob.size,
Math.max(0, Number(progressEvent.loaded) || 0)
);
const liveUploadedBytes = Math.min(
file.size,
confirmedUploadedBytes + currentChunkLoaded
);
this.uploadedBytes = liveUploadedBytes;
this.totalBytes = file.size;
this.uploadProgress = file.size > 0
? Math.min(100, Math.round((liveUploadedBytes / file.size) * 100))
: 0;
this.uploadPhase = liveUploadedBytes >= file.size ? '分片确认中' : '上传中';
}
});
if (!chunkResp.data?.success) {