Procházet zdrojové kódy

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

master
unknown před 4 roky
rodič
revize
8834202215
2 změnil soubory, kde provedl 33 přidání a 3 odebrání
  1. +33
    -1
      src/services/system.js
  2. +0
    -2
      src/views/main_web/workspace/workspace.new.vue

+ 33
- 1
src/services/system.js Zobrazit soubor

@@ -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 Zobrazit soubor

@@ -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);


Načítá se…
Zrušit
Uložit