题目搜索,收藏功能

This commit is contained in:
undefined committed 2020-06-24 13:39:32 +08:00
1 parent a248425db6
commit 441eeadaf3
23 files changed
+158 -97

No files matched your search

+13 -11
View File
@@ -1,17 +1,19 @@
const superagent = require('superagent');
const fs = require('fs');
async function download(url, path, retry = 3) {
if (path) {
const w = await fs.createWriteStream(path);
await superagent.get(url).retry(retry).pipe(w);
await new Promise((resolve, reject) => {
w.on('finish', resolve);
w.on('error', reject);
});
return path;
}
return superagent.get(url);
async function _download(url, path, retry) {
const w = fs.createWriteStream(path);
await superagent.get(url).retry(retry).pipe(w);
await new Promise((resolve, reject) => {
w.on('finish', resolve);
w.on('error', reject);
});
return path;
}
function download(url, path, retry = 3) {
if (path) return _download(url, path, retry);
return superagent.get(url).retry(retry);
}
global.Hydro.lib.download = module.exports = download;
+2 -2
View File
@@ -60,8 +60,8 @@ async function del(id) {
fs.unlinkSync(root(`${moduleRoot}/${id}.hydro`));
}
async function install(url) {
await download(url, root(`${moduleRoot}/${String.random(16)}.hydro`));
function install(url) {
return download(url, root(`${moduleRoot}/${String.random(16)}.hydro`));
}
global.Hydro.lib.hpm = module.exports = {