完成备忘的分享接口

This commit is contained in:
HelloWorld 2020-04-09 08:49:28 +08:00
parent 33cd8229f9
commit e3647ac4d4
5 changed files with 31 additions and 8 deletions

View File

@ -11,7 +11,7 @@ function md5(str) {
module.exports = class extends Base {
async __before() {
if (['userRegister', 'userLogin'].indexOf(this.ctx.action) >= 0) {
if (['userRegister', 'userLogin', 'noteShare'].indexOf(this.ctx.action) >= 0) {
return;
}
try {
@ -584,4 +584,27 @@ module.exports = class extends Base {
this.json({ code: 1, msg: error.toString() });
}
}
async noteShareAction() {
let id = this.get("id");
let note = await this.model('notes').where({ id, public: 1 }).find();
let body = think.isEmpty(note) ? "备忘为非公开或者已删除!" : note.content;
this.body = `<body style="margin:0px;height:100%;">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
<script>
if(screen && screen.availWidth <= 1024) {
setTimeout(() => {
document.getElementById("note-div").style.width = "100%";
document.getElementById("note-div").style["background-color"] = "#F3F4F5";
document.getElementById("note").style.width = "95%";
}, 100);
}
</script>
</head>
<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>`;
}
};

View File

@ -56,7 +56,7 @@
<p>
对不起,您的风筝已掉线,请时光倒流回前一秒。<br />
<span id="totalSecond">5</span>秒后自动
<a href="http://mybookmark.cn" class="backhome"><span>返回首页</span></a>
<a href="https://mybookmark.cn" class="backhome"><span>返回首页</span></a>
</p>
</div>
</div>
@ -71,7 +71,7 @@
}
setInterval(function() {
if (second < 0) {
location.href = "http://mybookmark.cn";
location.href = document.location.origin;
} else {
if (navigator.appName.indexOf("Explorer") > -1) {
document.getElementById("totalSecond").innerText = second--;

View File

@ -262,8 +262,8 @@ app.controller('noteCtr', ['$scope', '$state', '$stateParams', '$filter', '$wind
time = 1000;
}
setTimeout(() => {
dataService.clipboard(`https://mybookmark.cn/api/notes/?shareNote=${note.id}`);
toastr.info(`将地址 https://mybookmark.cn/api/notes/?shareNote=${note.id} 发给别人粘贴到浏览器地址栏就可以访问到你分享的备忘啦!`, "提示");
dataService.clipboard(`${document.location.origin}/api/noteShare/?id=${note.id}`);
toastr.info(`将地址 ${document.location.origin}/api/noteShare/?id=${note.id} 发给别人粘贴到浏览器地址栏就可以访问到你分享的备忘啦!`, "提示");
}, time)
}
@ -273,7 +273,7 @@ app.controller('noteCtr', ['$scope', '$state', '$stateParams', '$filter', '$wind
public: public,
}
await post("updateNode", params);
await post("noteUpdate", params);
note.public = public;
}

View File

@ -285,7 +285,7 @@ app.controller('weixinArticleCtr', ['$scope', '$state', '$sce', '$filter', '$win
b.account = articl.weixinaccount;
b.snapUrl = articl.pic || defaultSnap;
b.favCount = articl.likenum;
b.created_at = timeagoInstance.format(cdate, 'zh_CN');
b.createdAt = timeagoInstance.format(cdate, 'zh_CN');
b.content = articl.content
b.content = b.content.replace(/https:\/\/mmbiz.qpic.cn/gi, "http://img01.store.sogou.com/net/a/04/link?appid=100520029&url=https://mmbiz.qpic.cn")
b.content = b.content.replace(/http:\/\/mmbiz.qpic.cn/gi, "http://img01.store.sogou.com/net/a/04/link?appid=100520029&url=https://mmbiz.qpic.cn")

View File

@ -9,7 +9,7 @@
<div class="fields">
<div class="required eight wide field" ng-class="{error:urlError}">
<label>书签链接</label>
<input type="text" placeholder="输粘贴网页地址http://mybookmark.cn/" ng-model="url" />
<input type="text" placeholder="输粘贴网页地址https://mybookmark.cn/" ng-model="url" />
</div>
<div class="required eight wide field" ng-class="{error:titleError}">
<label ng-click="restoreTitle()">书签标题</label>