完成文件的上传
This commit is contained in:
parent
43967e03fe
commit
82f9996a10
|
|
@ -1,6 +1,7 @@
|
|||
const Base = require('./base.js');
|
||||
const crypto = require('crypto');
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const read = require('node-readability');
|
||||
|
||||
function md5(str) {
|
||||
|
|
@ -366,6 +367,23 @@ module.exports = class extends Base {
|
|||
this.json({ code: 1, msg: error.toString() });
|
||||
}
|
||||
}
|
||||
|
||||
// 书签上传
|
||||
async bookmarkUploadAction() {
|
||||
// size: 367450,
|
||||
// path: 'C:\\Users\\lucq\\AppData\\Local\\Temp\\upload_4ae3b14dacaa107076d3bddd471ebe39.html',
|
||||
// name: 'exportbookmark-lcq-20200402084709.html',
|
||||
// type: 'text/html',
|
||||
const file = this.file();
|
||||
this.json({ code: 0 });
|
||||
// const fileName = this.ctx.state.user.username;
|
||||
// if (file) {
|
||||
// const filepath = path.join(think.ROOT_PATH, `runtime/upload/${fileName}.html`);
|
||||
// think.mkdir(path.dirname(filepath));
|
||||
// await rename(file.path, filepath);
|
||||
// }
|
||||
}
|
||||
|
||||
// 获取文章
|
||||
async articleAction() {
|
||||
let url = this.get("url");
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ app.controller('bookmarkInfoCtr', ['$scope', '$state', '$timeout', '$sce', '$win
|
|||
}, 500);
|
||||
$scope.loading = true;
|
||||
try {
|
||||
let data = get("getArticle", { url: bookmark.url });
|
||||
let data = get("article", { url: bookmark.url });
|
||||
$scope.content = data.content ? $sce.trustAsHtml(data.content) : $sce.trustAsHtml('<p>数据获取失败,可能是服务器不允许获取,或者是https网站!</p>');
|
||||
setTimeout(function () {
|
||||
$('.ui.modal.js-bookmark-info').modal && $('.ui.modal.js-bookmark-info').modal("refresh");
|
||||
|
|
|
|||
|
|
@ -127,22 +127,29 @@ app.controller('settingsCtr', ['$scope', '$stateParams', '$filter', '$state', '$
|
|||
|
||||
setTimeout(function () {
|
||||
$("#fileuploader").uploadFile({
|
||||
url: "/api/uploadBookmarkFile",
|
||||
url: "/api/bookmarkUpload",
|
||||
multiple: false,
|
||||
dragDrop: true,
|
||||
fileName: "bookmark",
|
||||
acceptFiles: "text/html",
|
||||
maxFileSize: 10 * 1024 * 1024, // 最大10M
|
||||
dragdropWidth: "100%",
|
||||
onSuccess: function (files, response, xhr, pd) {
|
||||
toastr.success('文件上传成功,3秒钟自动跳转到书签页面', "提示");
|
||||
setTimeout(function () {
|
||||
pubSubService.publish('Common.menuActive', {
|
||||
login: true,
|
||||
index: dataService.LoginIndexBookmarks
|
||||
});
|
||||
$state.go('bookmarks', {})
|
||||
}, 3000);
|
||||
headers: {
|
||||
Authorization: localStorage.getItem("authorization"),
|
||||
},
|
||||
onSuccess: function (files, response) {
|
||||
console.log(files, response);
|
||||
if (response.code == 0) {
|
||||
setTimeout(function () {
|
||||
pubSubService.publish('Common.menuActive', {
|
||||
login: true,
|
||||
index: dataService.LoginIndexBookmarks
|
||||
});
|
||||
$state.go('bookmarks', {})
|
||||
}, 3000);
|
||||
} else {
|
||||
toastr.success('文件上传失败:' + response.msg, "提示");
|
||||
}
|
||||
},
|
||||
});
|
||||
$(".ui.pointing.menu .item").removeClass("selected");
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue