完成书签的备份下载
This commit is contained in:
parent
6636b698ff
commit
e6af3742ac
|
|
@ -11,7 +11,7 @@ function md5(str) {
|
||||||
|
|
||||||
module.exports = class extends Base {
|
module.exports = class extends Base {
|
||||||
async __before() {
|
async __before() {
|
||||||
if (['userRegister', 'userLogin', 'noteShare'].indexOf(this.ctx.action) >= 0) {
|
if (['userRegister', 'userLogin', 'noteShare', 'bookmarkDownload'].indexOf(this.ctx.action) >= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
@ -508,9 +508,26 @@ module.exports = class extends Base {
|
||||||
|
|
||||||
await fs.ensureFile(filePath);
|
await fs.ensureFile(filePath);
|
||||||
await fs.writeFile(filePath, $.xml());
|
await fs.writeFile(filePath, $.xml());
|
||||||
this.json({ code: 0, data: `runtime/backup/${fileName}` });
|
this.json({ code: 0, data: fileName });
|
||||||
setTimeout(() => fs.remove(filePath), 10000);
|
|
||||||
// await this.download(filePath, fileName)
|
setTimeout(async () => {
|
||||||
|
let exists = await fs.pathExists(filePath);
|
||||||
|
if (exists) {
|
||||||
|
await fs.remove(filePath);
|
||||||
|
}
|
||||||
|
}, 1000 * 60 * 10); // 十分钟内没下载就给删掉
|
||||||
|
}
|
||||||
|
|
||||||
|
async bookmarkDownloadAction() {
|
||||||
|
let fileName = this.get('fileName');
|
||||||
|
let filePath = path.join(think.ROOT_PATH, 'runtime', 'backup', fileName);
|
||||||
|
let exists = await fs.pathExists(filePath);
|
||||||
|
if (exists) {
|
||||||
|
await this.download(filePath);
|
||||||
|
await fs.remove(filePath);
|
||||||
|
} else {
|
||||||
|
this.body = "文件不存在!";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取文章
|
// 获取文章
|
||||||
|
|
|
||||||
|
|
@ -113,8 +113,8 @@ app.controller('settingsCtr', ['$scope', '$stateParams', '$filter', '$state', '$
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.exportBookmark = async function () {
|
$scope.exportBookmark = async function () {
|
||||||
let data = await get('bookmarkBackup');
|
let fileName = await get('bookmarkBackup');
|
||||||
console.log(data);
|
$window.open(`${document.location.origin}/api/bookmarkDownload?fileName=${fileName}`, '_blank');
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue