增加json
This commit is contained in:
parent
0a74c4fc0a
commit
3d06055292
|
|
@ -12,6 +12,10 @@ function md5(str) {
|
||||||
module.exports = class extends Base {
|
module.exports = class extends Base {
|
||||||
async __before() {
|
async __before() {
|
||||||
if (['userRegister', 'userLogin', 'noteShare', 'bookmarkDownload', 'hotBookmarks', 'hotBookmarksRandom'].indexOf(this.ctx.action) >= 0) {
|
if (['userRegister', 'userLogin', 'noteShare', 'bookmarkDownload', 'hotBookmarks', 'hotBookmarksRandom'].indexOf(this.ctx.action) >= 0) {
|
||||||
|
this.header("Access-Control-Allow-Origin", this.header("origin") || "*");
|
||||||
|
this.header("Access-Control-Allow-Headers", "x-requested-with");
|
||||||
|
this.header("Access-Control-Allow-Methods", "GET,POST,OPTIONS,PUT,DELETE");
|
||||||
|
this.header('Access-Control-Allow-Credentials', true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
@ -804,7 +808,11 @@ module.exports = class extends Base {
|
||||||
|
|
||||||
async noteShareAction() {
|
async noteShareAction() {
|
||||||
let id = this.get("id");
|
let id = this.get("id");
|
||||||
|
let json = this.get("json");
|
||||||
let note = await this.model('notes').where({ id, public: 1 }).find();
|
let note = await this.model('notes').where({ id, public: 1 }).find();
|
||||||
|
if (json) {
|
||||||
|
this.json(JSON.parse(note.content))
|
||||||
|
} else {
|
||||||
let body = think.isEmpty(note) ? "备忘为非公开或者已删除!" : note.content;
|
let body = think.isEmpty(note) ? "备忘为非公开或者已删除!" : note.content;
|
||||||
this.body = `<body style="margin:0px;height:100%;">
|
this.body = `<body style="margin:0px;height:100%;">
|
||||||
<head>
|
<head>
|
||||||
|
|
@ -824,4 +832,5 @@ module.exports = class extends Base {
|
||||||
</div>
|
</div>
|
||||||
</body>`;
|
</body>`;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue