From 1f47e5146b2d2b5c30fefab4f216fe6a21ad1978 Mon Sep 17 00:00:00 2001 From: lmm214 Date: Sat, 4 Feb 2023 17:23:49 +0800 Subject: [PATCH] memos random --- README.md | 2 ++ css/main.css | 16 +++++++++++++--- js/dayjs.min.js | 1 + js/oper.js | 44 +++++++++++++++++++++++++++++++++++++++++++- js/relativeTime.js | 1 + js/zh-cn.js | 1 + manifest.json | 2 +- popup.html | 7 +++++++ 8 files changed, 69 insertions(+), 5 deletions(-) create mode 100644 js/dayjs.min.js create mode 100644 js/relativeTime.js create mode 100644 js/zh-cn.js diff --git a/README.md b/README.md index 66ecf0f..da0a471 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ ## 更新日志 +2023.02.04 新增随机 Memos 按钮,随时唤醒记忆。 + 2022.11.15 新增插入文件图片按钮,尝试修复首次安装需要点一下小锁。 2022.11.13 新增插入 todo 按钮。 diff --git a/css/main.css b/css/main.css index 5d11592..a7f0304 100644 --- a/css/main.css +++ b/css/main.css @@ -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; diff --git a/js/dayjs.min.js b/js/dayjs.min.js new file mode 100644 index 0000000..ba16e65 --- /dev/null +++ b/js/dayjs.min.js @@ -0,0 +1 @@ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).dayjs=e()}(this,(function(){"use strict";var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",f="month",h="quarter",c="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return"["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return!r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return(e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()1)return t(u[0])}else{var a=e.name;D[a]=e,i=a}return!r&&i&&(g=i),i||!r&&g},w=function(t,e){if(p(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},O=v;O.l=S,O.i=p,O.w=function(t,e){return w(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=S(t.locale,null,!0),this.parse(t)}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(O.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.$x=t.x||{},this.init()},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},m.$utils=function(){return O},m.isValid=function(){return!(this.$d.toString()===l)},m.isSame=function(t,e){var n=w(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return w(t)…'+dayjs(new Date(randomData.createdTs * 1000).toLocaleString()).fromNow()+'
'+randomData.content.replace(/!\[.*?\]\((.*?)\)/g,' ').replace(/\[(.*?)\]\((.*?)\)/g,' $1 ')+'
' + 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 += '' + } + } + } + $("#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"){ diff --git a/js/relativeTime.js b/js/relativeTime.js new file mode 100644 index 0000000..898eee6 --- /dev/null +++ b/js/relativeTime.js @@ -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;c0,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)}}})); \ No newline at end of file diff --git a/js/zh-cn.js b/js/zh-cn.js new file mode 100644 index 0000000..21cf228 --- /dev/null +++ b/js/zh-cn.js @@ -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})); \ No newline at end of file diff --git a/manifest.json b/manifest.json index f287048..f4379a6 100644 --- a/manifest.json +++ b/manifest.json @@ -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", diff --git a/popup.html b/popup.html index 3da6949..5a97fa7 100644 --- a/popup.html +++ b/popup.html @@ -80,16 +80,23 @@ +
+ +
+
+ + +