瀏覽代碼

增加上传/下载时的错误提示

master
unknown 4 年之前
父節點
當前提交
8834202215
共有 2 個檔案被更改,包括 33 行新增3 行删除
  1. +33
    -1
      src/services/system.js
  2. +0
    -2
      src/views/main_web/workspace/workspace.new.vue

+ 33
- 1
src/services/system.js 查看文件

@@ -83,7 +83,19 @@ const system = {
socket.on('open', () => {
socket.send([fileIpfsId, projectName, fileName, dirName].join('|'));
});
socket.on('message', (e) => { onProcessHandler(e, socket); });
socket.on('message', (e) => {
if(e.data === '-1') {
notify.error('文件下载失败');
onErrorHandler(e);
return;
}
if(e.data === '-2') {
notify.error('请先关闭本地文件后再下载');
onErrorHandler(e);
return;
}
onProcessHandler(e, socket);
});
socket.on('error', e => {
onErrorHandler(e);
});
@@ -161,6 +173,16 @@ const system = {

socket.on('message', async (e) => {
console.log('receive download file message:', e);
if(e.data === '-1') {
notify.error('文件上传失败');
onErrorHandler(e);
return;
}
if(e.data === '-2') {
notify.error('请先关闭本地文件后再上传');
onErrorHandler(e);
return;
}
try {
const progressData = JSON.parse(e.data);
const { size, process, hash } = progressData;
@@ -203,6 +225,16 @@ const system = {
socket.send(data);
});
socket.on('message', async (e) => {
if(e.data === '-1') {
notify.error('文件上传失败');
onErrorHandler(e);
return;
}
if(e.data === '-2') {
notify.error('请先关闭本地文件后再上传');
onErrorHandler(e);
return;
}
try {
const progressData = JSON.parse(e.data);
const { size, process, hash } = progressData;


+ 0
- 2
src/views/main_web/workspace/workspace.new.vue 查看文件

@@ -704,7 +704,6 @@ export default {
const extensionedFileName = `${fileName}${extension ? `.${extension}`:''}`;
const fileStoreKey = `${nodeFolderName}\\${extensionedFileName}`;
const errorHandler = () => {
notify.error('文件下载失败');
this.removeFileLoadingState(file.id);
}
this.updateFileLoadState(file.id, DOWNLOADING, 0);
@@ -713,7 +712,6 @@ export default {
// {"size":"11","currentSize":"11","unit":"B","process":100,"hash":""}
try {
const { process, hash } = JSON.parse(resMessage.data);
if(resMessage.data === '-1') { throw 'download failed'; }
this.updateFileLoadState(file.id, DOWNLOADING, process);
if(process !== 100) return;
this.addLocalFileRecord(fileStoreKey, ipfsCid);


Loading…
取消
儲存