memos random

This commit is contained in:
lmm214
2023-02-04 17:23:49 +08:00
parent 20fcbbc1f6
commit 1f47e5146b
8 changed files with 69 additions and 5 deletions
+2
View File
@@ -1,5 +1,7 @@
## 更新日志
2023.02.04 新增随机 Memos 按钮,随时唤醒记忆。
2022.11.15 新增插入文件图片按钮,尝试修复首次安装需要点一下小锁。
2022.11.13 新增插入 todo 按钮。
+13 -3
View File
@@ -34,7 +34,7 @@ input:focus::placeholder ,.common-editor-inputer:focus::placeholder {
line-height: 2.5rem;
color: rgb(55,65,81);
}
.memo-editor{
.memo-editor,#randomlist{
border: 2px solid rgb(229,231,235);
border-radius: .5rem;
background-color: rgb(255,255,255);
@@ -44,6 +44,15 @@ input:focus::placeholder ,.common-editor-inputer:focus::placeholder {
transition-timing-function: cubic-bezier(.4,0,.2,1);
transition-duration: .15s;
}
#randomlist{
border: 1px solid rgb(229,231,235);
color: #666;
padding: 1rem;
}
.random-time{font-size:13px;margin-bottom:6px;color: #999;font-style:italic;}
#random-link{float: right;margin-top: -5px;cursor: pointer;}
.random-image{width:180px;height:180px;max-width:100%;object-fit: cover;border-radius: .25rem;margin:5px 5px 5px 0;}
.btns-container{text-align:right;}
.common-editor-inputer,input.inputer{
font-family: ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;
@@ -109,9 +118,10 @@ input.inputer{border-bottom: 1px solid #ccc;width:75%;}
.common-tools-container svg.icon,#blog_info_edit svg.icon{width:24px;height:24px;opacity: 0.6;cursor: pointer;}
#newtodo svg.icon{padding-top: 2px;}
#tags svg.icon{padding: 2px;width:23px;height:23px;}
#tags:hover svg,#getlink:hover svg,#locked:hover svg,#unlock:hover svg,#newtodo:hover svg,#upres:hover svg{opacity: 1;}
#random svg.icon{padding:2px;width:19px;height:19px;}
#tags:hover svg,#getlink:hover svg,#locked:hover svg,#unlock:hover svg,#newtodo:hover svg,#upres:hover svg,#random:hover svg{opacity: 1;}
#locked,#taglist,#visibilitylist{display: none;}
#locked,#taglist,#visibilitylis,#randomlist{display: none;}
.tag-list,.visibility-list {
margin-top: .5rem;
max-height: 13rem;
+1
View File
File diff suppressed because one or more lines are too long
+43 -1
View File
@@ -103,7 +103,6 @@ function uploadImage(data) {
message: '上传图片中……',
autoClose: false
})
console.log(data)
//根据data判断是图片地址还是base64加密的数据
get_info(function (info) {
const formData = new FormData()
@@ -204,6 +203,49 @@ $('#unlock,#locked').click(function () {
$("#visibilitylist").html(lockDom).slideToggle(500)
})
})
$('#random').click(function () {
dayjs.extend(window.dayjs_plugin_relativeTime)
dayjs.locale('zh-cn')
get_info(function (info) {
if (info.status) {
$("#randomlist").html('').hide()
var randomUrl1 = info.apiUrl.replace(/api\/memo/,'api/memo/amount')
var randomDom = ""
$.get(randomUrl1,function(data,status){
let randomNum = Math.floor(Math.random() * (data.data)) + 1;
var randomUrl2 = info.apiUrl+'&rowStatus=NORMAL&limit=1&offset='+randomNum
$.get(randomUrl2,function(data){
var randomData = data.data[0]
randomDom += '<div class="random-item"><div class="random-time"><span id="random-link" data-id="'+randomData.id+'">…</span>'+dayjs(new Date(randomData.createdTs * 1000).toLocaleString()).fromNow()+'</div><div class="random-content">'+randomData.content.replace(/!\[.*?\]\((.*?)\)/g,' <img class="random-image" src="$1"/> ').replace(/\[(.*?)\]\((.*?)\)/g,' <a href="$2" target="_blank">$1</a> ')+'</div></div>'
if(randomData.resourceList && randomData.resourceList.length > 0){
var resourceList = randomData.resourceList;
for(var j=0;j < resourceList.length;j++){
var restype = resourceList[j].type.slice(0,5);
if(restype == 'image'){
randomDom += '<img class="random-image" src="'+info.apiUrl.replace(/api\/memo.*/,'')+'o/r/'+resourceList[j].id+'/'+resourceList[j].filename+'"/>'
}
}
}
$("#randomlist").html(randomDom).slideDown(500);
});
});
} else {
$.message({
message: '请先填写好 API 链接'
})
}
})
})
$(document).on("click","#random-link",function () {
var memoId = this.getAttribute('data-id')
get_info(function (info) {
chrome.tabs.create({url:info.apiUrl.replace(/api\/memo.*/,'')+"m/"+memoId})
})
})
$(document).on("click",".item-lock",function () {
_this = $(this)[0].dataset.type
if(_this !== "PUBLIC"){
+1
View File
@@ -0,0 +1 @@
!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(r="undefined"!=typeof globalThis?globalThis:r||self).dayjs_plugin_relativeTime=e()}(this,(function(){"use strict";return function(r,e,t){r=r||{};var n=e.prototype,o={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function i(r,e,t,o){return n.fromToBase(r,e,t,o)}t.en.relativeTime=o,n.fromToBase=function(e,n,i,d,u){for(var f,a,s,l=i.$locale().relativeTime||o,h=r.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],m=h.length,c=0;c<m;c+=1){var y=h[c];y.d&&(f=d?t(e).diff(i,y.d,!0):i.diff(e,y.d,!0));var p=(r.rounding||Math.round)(Math.abs(f));if(s=f>0,p<=y.r||!y.r){p<=1&&c>0&&(y=h[c-1]);var v=l[y.l];u&&(p=u(""+p)),a="string"==typeof v?v.replace("%d",p):v(p,n,y.l,s);break}}if(n)return a;var M=s?l.future:l.past;return"function"==typeof M?M(a):M.replace("%s",a)},n.to=function(r,e){return i(r,e,this,!0)},n.from=function(r,e){return i(r,e,this)};var d=function(r){return r.$u?t.utc():t()};n.toNow=function(r){return this.to(d(this),r)},n.fromNow=function(r){return this.from(d(this),r)}}}));
+1
View File
@@ -0,0 +1 @@
!function(e,_){"object"==typeof exports&&"undefined"!=typeof module?module.exports=_(require("dayjs")):"function"==typeof define&&define.amd?define(["dayjs"],_):(e="undefined"!=typeof globalThis?globalThis:e||self).dayjs_locale_zh_cn=_(e.dayjs)}(this,(function(e){"use strict";function _(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=_(e),d={name:"zh-cn",weekdays:"星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),weekdaysShort:"周日_周一_周二_周三_周四_周五_周六".split("_"),weekdaysMin:"日_一_二_三_四_五_六".split("_"),months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),ordinal:function(e,_){return"W"===_?e+"周":e+"日"},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日Ah点mm分",LLLL:"YYYY年M月D日ddddAh点mm分",l:"YYYY/M/D",ll:"YYYY年M月D日",lll:"YYYY年M月D日 HH:mm",llll:"YYYY年M月D日dddd HH:mm"},relativeTime:{future:"%s内",past:"%s前",s:"几秒",m:"1 分钟",mm:"%d 分钟",h:"1 小时",hh:"%d 小时",d:"1 天",dd:"%d 天",M:"1 个月",MM:"%d 个月",y:"1 年",yy:"%d 年"},meridiem:function(e,_){var t=100*e+_;return t<600?"凌晨":t<900?"早上":t<1100?"上午":t<1300?"中午":t<1800?"下午":"晚上"}};return t.default.locale(d,null,!0),d}));
+1 -1
View File
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "__MSG_extName__",
"version": "2022.11.15",
"version": "2023.02.04",
"action": {
"default_popup": "popup.html",
"default_icon": "assets/logo_24x24.png",
+7
View File
@@ -80,16 +80,23 @@
<path fill="#666" d="M512 597a85 85 0 1 0 0 171 85 85 0 0 0 0-171zm0-512a213 213 0 0 1 213 204v180a43 43 0 0 1-85 5V299a128 128 0 0 0-256-8v178a43 43 0 0 1-85 5V299A213 213 0 0 1 512 85z"/>
</svg>
</div>
<div id="random" class="mr-5">
<svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="32" height="32"><path fill="#666" d="M988.492 718.906L864.168 595.6c-15.686-15.556-41.012-15.454-56.568.232-15.556 15.686-15.452 41.012.232 56.568L922.368 766h-48.812c-115.514 0-222.1-49.978-292.428-137.122-13.874-17.194-39.058-19.88-56.248-6.006-17.192 13.874-19.88 39.056-6.006 56.248C604.464 785.176 733.74 846 873.556 846h44.78L807.832 955.6c-15.684 15.556-15.79 40.882-.232 56.568A39.88 39.88 0 0 0 836.002 1024c10.18 0 20.368-3.864 28.166-11.6l124.324-123.306C1011.39 866.384 1024 836.162 1024 804s-12.61-62.382-35.508-85.094z"/><path fill="#666" d="M988.492 134.906L864.168 11.6c-15.686-15.556-41.012-15.454-56.568.232-15.556 15.686-15.452 41.012.232 56.568L918.336 178h-44.78c-163.332 0-314.542 86.102-394.626 224.702l-16.952 29.342-27.352-47.342C354.544 246.102 203.332 160 40 160c-22.092 0-40 17.908-40 40s17.908 40 40 40c134.852 0 259.522 70.782 325.356 184.724L415.78 512l-50.426 87.276C299.522 713.22 174.852 784 40 784c-22.092 0-40 17.908-40 40s17.908 40 40 40c163.332 0 314.542-86.102 394.626-224.702l61.64-106.684c.224-.374.442-.752.654-1.134l51.28-88.756C614.034 328.782 738.704 258 873.556 258h48.812L807.832 371.6c-15.684 15.556-15.79 40.882-.232 56.568A39.88 39.88 0 0 0 836.002 440c10.18 0 20.368-3.864 28.166-11.6l124.324-123.306C1011.39 282.384 1024 252.162 1024 220s-12.61-62.382-35.508-85.094z"/></svg>
</div>
</div>
<div class="btns-container" type="submit" name="submit" id="submit">
<button id="content_submit_text" class="action-btn confirm-btn">记下<img class="icon-img" src="../assets/logo_24x24.png"></button>
</div>
</div>
<div class="tag-list" id="taglist"></div>
<div class="" id="randomlist"></div>
<div class="visibility-list" id="visibilitylist"></div>
<input type="file" id="inFile" style="display:none;">
<script src="../js/jquery.min.js"></script>
<script src="../js/message.js"></script>
<script src="../js/dayjs.min.js"></script>
<script src="../js/zh-cn.js"></script>
<script src="../js/relativeTime.js"></script>
<script src="../js/oper.js"></script>
</body>
</html>