修改返回参数等问题
This commit is contained in:
parent
6e09034db9
commit
21f1838537
|
@ -200,10 +200,14 @@ export async function cordovaReady() {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
game.removeDir = (directory, successCallback, errorCallback) => {
|
game.removeDir = (directory, successCallback, errorCallback) => {
|
||||||
new Promise((resolve, reject) => {
|
window.resolveLocalFileSystemURL(`${nonameInitialized}${directory}`, directoryEntry => {
|
||||||
window.cordova.file
|
directoryEntry.removeRecursively(() => {
|
||||||
window.resolveLocalFileSystemURL(`${nonameInitialized}${directory}`, resolve, reject);
|
if (typeof successCallback == 'function') successCallback();
|
||||||
}).then((directoryEntry) => directoryEntry.removeRecursively(successCallback, errorCallback));
|
});
|
||||||
|
}, e => {
|
||||||
|
if (typeof errorCallback == 'function') errorCallback(e);
|
||||||
|
else throw e;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
if (ui.updateUpdate) {
|
if (ui.updateUpdate) {
|
||||||
ui.updateUpdate();
|
ui.updateUpdate();
|
||||||
|
|
|
@ -176,6 +176,7 @@ export function nodeReady() {
|
||||||
lib.node.fs.mkdir(lib.node.path.join(__dirname, directory), { recursive: true }, e => {
|
lib.node.fs.mkdir(lib.node.path.join(__dirname, directory), { recursive: true }, e => {
|
||||||
if (e) {
|
if (e) {
|
||||||
if (typeof errorCallback == 'function') errorCallback(e);
|
if (typeof errorCallback == 'function') errorCallback(e);
|
||||||
|
else throw e;
|
||||||
} else {
|
} else {
|
||||||
if (typeof successCallback == 'function') successCallback(e)
|
if (typeof successCallback == 'function') successCallback(e)
|
||||||
}
|
}
|
||||||
|
@ -184,17 +185,19 @@ export function nodeReady() {
|
||||||
const paths = directory.split('/').reverse();
|
const paths = directory.split('/').reverse();
|
||||||
let path = __dirname;
|
let path = __dirname;
|
||||||
const redo = () => {
|
const redo = () => {
|
||||||
path += `/${paths.pop()}`;
|
path = lib.node.path.join(path, paths.pop());
|
||||||
return new Promise(resolve => lib.node.fs.exists(path, resolve)).then(exists => {
|
const exists = lib.node.fs.existsSync(path);
|
||||||
//不存在此目录
|
const callback = e => {
|
||||||
if (!exists) return new Promise(resolve => lib.node.fs.mkdir(path, resolve));
|
if (e) {
|
||||||
}).then(() => {
|
if (typeof errorCallback != 'function') throw e;
|
||||||
|
errorCallback(e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (paths.length) return redo();
|
if (paths.length) return redo();
|
||||||
if (typeof successCallback == 'function') successCallback();
|
if (typeof successCallback == 'function') successCallback();
|
||||||
}).catch(reason => {
|
};
|
||||||
if (typeof errorCallback != 'function') return Promise.reject(reason);
|
if (!exists) lib.node.fs.mkdir(path, callback);
|
||||||
errorCallback(reason);
|
else callback();
|
||||||
});
|
|
||||||
};
|
};
|
||||||
redo();
|
redo();
|
||||||
}
|
}
|
||||||
|
@ -213,8 +216,9 @@ export function nodeReady() {
|
||||||
lib.node.fs.rmdir(target, { recursive: true }, e => {
|
lib.node.fs.rmdir(target, { recursive: true }, e => {
|
||||||
if (e) {
|
if (e) {
|
||||||
if (typeof errorCallback == 'function') errorCallback(e);
|
if (typeof errorCallback == 'function') errorCallback(e);
|
||||||
|
else throw e;
|
||||||
} else {
|
} else {
|
||||||
if (typeof successCallback == 'function') successCallback(e)
|
if (typeof successCallback == 'function') successCallback()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -230,7 +234,12 @@ export function nodeReady() {
|
||||||
successCallback();
|
successCallback();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
deleteFolderRecursive(target);
|
try {
|
||||||
|
deleteFolderRecursive(target);
|
||||||
|
} catch (e) {
|
||||||
|
if (typeof errorCallback == 'function') errorCallback(e);
|
||||||
|
else throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (ui.updateUpdate) {
|
if (ui.updateUpdate) {
|
||||||
|
|
Loading…
Reference in New Issue