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