增加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,24 +808,29 @@ 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();
|
||||||
let body = think.isEmpty(note) ? "备忘为非公开或者已删除!" : note.content;
|
if (json) {
|
||||||
this.body = `<body style="margin:0px;height:100%;">
|
this.json(JSON.parse(note.content))
|
||||||
<head>
|
} else {
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
|
let body = think.isEmpty(note) ? "备忘为非公开或者已删除!" : note.content;
|
||||||
<script>
|
this.body = `<body style="margin:0px;height:100%;">
|
||||||
if(screen && screen.availWidth <= 1024) {
|
<head>
|
||||||
setTimeout(() => {
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
|
||||||
document.getElementById("note-div").style.width = "100%";
|
<script>
|
||||||
document.getElementById("note-div").style["background-color"] = "#F3F4F5";
|
if(screen && screen.availWidth <= 1024) {
|
||||||
document.getElementById("note").style.width = "95%";
|
setTimeout(() => {
|
||||||
}, 100);
|
document.getElementById("note-div").style.width = "100%";
|
||||||
}
|
document.getElementById("note-div").style["background-color"] = "#F3F4F5";
|
||||||
</script>
|
document.getElementById("note").style.width = "95%";
|
||||||
</head>
|
}, 100);
|
||||||
<div id="note-div" style="text-align:center;">
|
}
|
||||||
<pre id="note" style="background-color:RGB(243,244,245); padding:0px 10px 0px 10px; margin:0px; width:60%; min-height:100%;display: inline-block;text-align: left; font-size: 15px; font-family:italic arial,sans-serif;word-wrap: break-word;white-space: pre-wrap;">\n\n${body}\n\n</pre>
|
</script>
|
||||||
</div>
|
</head>
|
||||||
</body>`;
|
<div id="note-div" style="text-align:center;">
|
||||||
|
<pre id="note" style="background-color:RGB(243,244,245); padding:0px 10px 0px 10px; margin:0px; width:60%; min-height:100%;display: inline-block;text-align: left; font-size: 15px; font-family:italic arial,sans-serif;word-wrap: break-word;white-space: pre-wrap;">\n\n${body}\n\n</pre>
|
||||||
|
</div>
|
||||||
|
</body>`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue