mirror of
https://github.com/Jonnyan404/memos-bber.git
synced 2026-04-25 03:58:37 +09:00
Memos
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
## 更新日志
|
||||
|
||||
2023.02.05 支持指定标签下的随机 Memos (算是彩蛋:标签列表点开,输入框内有且只有1个标签时,点击随机按钮)
|
||||
|
||||
2023.02.04 新增随机 Memos 按钮,随时唤醒记忆。
|
||||
|
||||
2022.11.15 新增插入文件图片按钮,尝试修复首次安装需要点一下小锁。
|
||||
|
||||
+25
-10
@@ -211,14 +211,36 @@ $('#random').click(function () {
|
||||
get_info(function (info) {
|
||||
if (info.status) {
|
||||
$("#randomlist").html('').hide()
|
||||
var nowTag = $("textarea[name=text]").val().replace(/#([^\s#]+)/,'$1') ;
|
||||
if( $("#taglist").is(':visible') && nowTag){
|
||||
var tagUrl = info.apiUrl.replace(/api\/memo.*/,'api/memo/all?tag='+nowTag)
|
||||
$.get(tagUrl,function(data){
|
||||
let randomNum = Math.floor(Math.random() * (data.data.length));
|
||||
var randomData = data.data[randomNum]
|
||||
randDom(randomData)
|
||||
})
|
||||
}else{
|
||||
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>'
|
||||
randDom(randomData)
|
||||
});
|
||||
});
|
||||
}
|
||||
} else {
|
||||
$.message({
|
||||
message: '请先填写好 API 链接'
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
function randDom(randomData){
|
||||
get_info(function (info) {
|
||||
var 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++){
|
||||
@@ -229,15 +251,8 @@ $('#random').click(function () {
|
||||
}
|
||||
}
|
||||
$("#randomlist").html(randomDom).slideDown(500);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
$.message({
|
||||
message: '请先填写好 API 链接'
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
$(document).on("click","#random-link",function () {
|
||||
var memoId = this.getAttribute('data-id')
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"manifest_version": 3,
|
||||
"name": "__MSG_extName__",
|
||||
"version": "2023.02.04",
|
||||
"version": "2023.02.05",
|
||||
"action": {
|
||||
"default_popup": "popup.html",
|
||||
"default_icon": "assets/logo_24x24.png",
|
||||
|
||||
Reference in New Issue
Block a user