This commit is contained in:
lmm214
2023-02-06 19:03:56 +08:00
parent d6258a6284
commit b9c4c17062
5 changed files with 63 additions and 9 deletions
+2
View File
@@ -1,5 +1,7 @@
## 更新日志 ## 更新日志
2023.02.07 新增发布后显示最新一条 Memo ,具体一条新增归档按钮。
2023.02.06 新增搜索按钮;新增图片灯箱。 2023.02.06 新增搜索按钮;新增图片灯箱。
![iShot_2023-02-04_20 42 40](https://user-images.githubusercontent.com/1472390/216768533-4a93124a-666e-4617-a60b-29c826dc1584.png) ![iShot_2023-02-04_20 42 40](https://user-images.githubusercontent.com/1472390/216768533-4a93124a-666e-4617-a60b-29c826dc1584.png)
+5 -1
View File
@@ -18,6 +18,7 @@ input::placeholder ,.common-editor-inputer::placeholder {
input:focus::placeholder ,.common-editor-inputer:focus::placeholder { input:focus::placeholder ,.common-editor-inputer:focus::placeholder {
color: #d3d3d3 color: #d3d3d3
} }
.title{cursor: pointer;}
.body{ .body{
min-width:460px; min-width:460px;
background-color: #f6f5f4; background-color: #f6f5f4;
@@ -51,7 +52,10 @@ a{color: #555;}
padding: 1rem; padding: 1rem;
} }
.random-time{font-size:13px;margin-bottom:6px;color: #999;font-style:italic;} .random-time{font-size:13px;margin-bottom:6px;color: #999;font-style:italic;}
#random-link{float: right;margin-top: -5px;cursor: pointer;} .random-time span{float: right;margin-top: -3px;cursor: pointer;}
.random-time span svg.icon{width:15px;height:15px;padding:4px 6px 0;opacity: 0.6;margin-left:4px;}
.random-time span svg.icon:hover{opacity: 1;}
.random-image{width:180px;height:180px;max-width:100%;object-fit: cover;border-radius: .25rem;margin:5px 5px 5px 0;} .random-image{width:180px;height:180px;max-width:100%;object-fit: cover;border-radius: .25rem;margin:5px 5px 5px 0;}
.random-content{width:100%; .random-content{width:100%;
max-width:100%; max-width:100%;
+54 -6
View File
@@ -109,7 +109,7 @@ function uploadImage(data) {
if (info.status) { if (info.status) {
formData.append('file', data) formData.append('file', data)
$.ajax({ $.ajax({
url: info.apiUrl.replace(/api\/memo/,'api/resource'), url: info.apiUrl.replace(/api\/memo/,'api/resource/blob'),
data: formData, data: formData,
type: 'post', type: 'post',
cache: false, cache: false,
@@ -175,9 +175,30 @@ $('#saveKey').click(function () {
) )
}) })
$('#getone').click(function () {
getOne()
})
function getOne(){
get_info(function (info) {
if (info.apiUrl) {
$("#randomlist").html('').hide()
var getUrl = info.apiUrl+'&rowStatus=NORMAL&limit=1'
$.get(getUrl,function(data){
var getData = data.data[0]
randDom(getData)
});
} else {
$.message({
message: '请先填写好 API 链接'
})
}
})
}
$('#tags').click(function () { $('#tags').click(function () {
get_info(function (info) { get_info(function (info) {
if (info.status) { if (info.apiUrl) {
var tagUrl = info.apiUrl.replace(/api\/memo/,'api/tag') var tagUrl = info.apiUrl.replace(/api\/memo/,'api/tag')
var tagDom = "" var tagDom = ""
$.get(tagUrl,function(data){ $.get(tagUrl,function(data){
@@ -218,7 +239,7 @@ $('#search').click(function () {
const fuse = new Fuse(data.data, options); const fuse = new Fuse(data.data, options);
var searchData = fuse.search(pattern) var searchData = fuse.search(pattern)
for(var i=0;i < searchData.length;i++){ for(var i=0;i < searchData.length;i++){
searchDom += '<div class="random-item"><div class="random-time"><span id="random-link" data-id="'+searchData[i].item.id+'"></span>'+dayjs(new Date(searchData[i].item.createdTs)*1000).fromNow()+'</div><div class="random-content">'+searchData[i].item.content.replace(/!\[.*?\]\((.*?)\)/g,' <img class="random-image" src="$1"/> ').replace(/\[(.*?)\]\((.*?)\)/g,' <a href="$2" target="_blank">$1</a> ')+'</div>' searchDom += '<div class="random-item"><div class="random-time"><span id="random-link" data-id="'+searchData[i].item.id+'"><svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="32" height="32"><path d="M864 640a32 32 0 0 1 64 0v224.096A63.936 63.936 0 0 1 864.096 928H159.904A63.936 63.936 0 0 1 96 864.096V159.904C96 124.608 124.64 96 159.904 96H384a32 32 0 0 1 0 64H192.064A31.904 31.904 0 0 0 160 192.064v639.872A31.904 31.904 0 0 0 192.064 864h639.872A31.904 31.904 0 0 0 864 831.936V640zm-485.184 52.48a31.84 31.84 0 0 1-45.12-.128 31.808 31.808 0 0 1-.128-45.12L815.04 166.048l-176.128.736a31.392 31.392 0 0 1-31.584-31.744 32.32 32.32 0 0 1 31.84-32l255.232-1.056a31.36 31.36 0 0 1 31.584 31.584L924.928 388.8a32.32 32.32 0 0 1-32 31.84 31.392 31.392 0 0 1-31.712-31.584l.736-179.392L378.816 692.48z" fill="#666" data-spm-anchor-id="a313x.7781069.0.i12" class="selected"/></svg></span><span id="random-delete" data-id="'+searchData[i].item.id+'"><svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="32" height="32"><path d="M224 322.6h576c16.6 0 30-13.4 30-30s-13.4-30-30-30H224c-16.6 0-30 13.4-30 30 0 16.5 13.5 30 30 30zm66.1-144.2h443.8c16.6 0 30-13.4 30-30s-13.4-30-30-30H290.1c-16.6 0-30 13.4-30 30s13.4 30 30 30zm339.5 435.5H394.4c-16.6 0-30 13.4-30 30s13.4 30 30 30h235.2c16.6 0 30-13.4 30-30s-13.4-30-30-30z" fill="#666"/><path d="M850.3 403.9H173.7c-33 0-60 27-60 60v360c0 33 27 60 60 60h676.6c33 0 60-27 60-60v-360c0-33-27-60-60-60zm-.1 419.8l-.1.1H173.9l-.1-.1V464l.1-.1h676.2l.1.1v359.7z" fill="#666"/></svg></span>'+dayjs(new Date(searchData[i].item.createdTs)*1000).fromNow()+'</div><div class="random-content">'+searchData[i].item.content.replace(/!\[.*?\]\((.*?)\)/g,' <img class="random-image" src="$1"/> ').replace(/\[(.*?)\]\((.*?)\)/g,' <a href="$2" target="_blank">$1</a> ')+'</div>'
if(searchData[i].item.resourceList && searchData[i].item.resourceList.length > 0){ if(searchData[i].item.resourceList && searchData[i].item.resourceList.length > 0){
var resourceList = searchData[i].item.resourceList; var resourceList = searchData[i].item.resourceList;
for(var j=0;j < resourceList.length;j++){ for(var j=0;j < resourceList.length;j++){
@@ -279,7 +300,7 @@ $('#random').click(function () {
function randDom(randomData){ function randDom(randomData){
get_info(function (info) { 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)).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>' var randomDom = '<div class="random-item"><div class="random-time"><span id="random-link" data-id="'+randomData.id+'"><svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="32" height="32"><path d="M864 640a32 32 0 0 1 64 0v224.096A63.936 63.936 0 0 1 864.096 928H159.904A63.936 63.936 0 0 1 96 864.096V159.904C96 124.608 124.64 96 159.904 96H384a32 32 0 0 1 0 64H192.064A31.904 31.904 0 0 0 160 192.064v639.872A31.904 31.904 0 0 0 192.064 864h639.872A31.904 31.904 0 0 0 864 831.936V640zm-485.184 52.48a31.84 31.84 0 0 1-45.12-.128 31.808 31.808 0 0 1-.128-45.12L815.04 166.048l-176.128.736a31.392 31.392 0 0 1-31.584-31.744 32.32 32.32 0 0 1 31.84-32l255.232-1.056a31.36 31.36 0 0 1 31.584 31.584L924.928 388.8a32.32 32.32 0 0 1-32 31.84 31.392 31.392 0 0 1-31.712-31.584l.736-179.392L378.816 692.48z" fill="#666" data-spm-anchor-id="a313x.7781069.0.i12" class="selected"/></svg></span><span id="random-delete" data-id="'+randomData.id+'"><svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="32" height="32"><path d="M224 322.6h576c16.6 0 30-13.4 30-30s-13.4-30-30-30H224c-16.6 0-30 13.4-30 30 0 16.5 13.5 30 30 30zm66.1-144.2h443.8c16.6 0 30-13.4 30-30s-13.4-30-30-30H290.1c-16.6 0-30 13.4-30 30s13.4 30 30 30zm339.5 435.5H394.4c-16.6 0-30 13.4-30 30s13.4 30 30 30h235.2c16.6 0 30-13.4 30-30s-13.4-30-30-30z" fill="#666"/><path d="M850.3 403.9H173.7c-33 0-60 27-60 60v360c0 33 27 60 60 60h676.6c33 0 60-27 60-60v-360c0-33-27-60-60-60zm-.1 419.8l-.1.1H173.9l-.1-.1V464l.1-.1h676.2l.1.1v359.7z" fill="#666"/></svg></span>'+dayjs(new Date(randomData.createdTs * 1000)).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>'
if(randomData.resourceList && randomData.resourceList.length > 0){ if(randomData.resourceList && randomData.resourceList.length > 0){
var resourceList = randomData.resourceList; var resourceList = randomData.resourceList;
for(var j=0;j < resourceList.length;j++){ for(var j=0;j < resourceList.length;j++){
@@ -296,12 +317,39 @@ function randDom(randomData){
} }
$(document).on("click","#random-link",function () { $(document).on("click","#random-link",function () {
var memoId = this.getAttribute('data-id') var memoId = $("#random-link").data('id');
get_info(function (info) { get_info(function (info) {
chrome.tabs.create({url:info.apiUrl.replace(/api\/memo.*/,'')+"m/"+memoId}) chrome.tabs.create({url:info.apiUrl.replace(/api\/memo.*/,'')+"m/"+memoId})
}) })
}) })
$(document).on("click","#random-delete",function () {
get_info(function (info) {
var memosId = $("#random-delete").data('id');
var deleteUrl = info.apiUrl.replace(/api\/memo(.*)/,'api/memo/'+memosId+'$1')
$.ajax({
url:deleteUrl,
type:"PATCH",
data:JSON.stringify({
'id': memosId,
'rowStatus': "ARCHIVED"
}),
contentType:"application/json;",
dataType:"json",
success: function(result){
$("#randomlist").html('').hide()
$.message({
message: '归档成功!😊'
})
},error:function(err){//清空open_action(打开时候进行的操作),同时清空open_content
$.message({
message: '网络问题,归档失败!😭'
})
}
})
})
})
$(document).on("click",".item-lock",function () { $(document).on("click",".item-lock",function () {
_this = $(this)[0].dataset.type _this = $(this)[0].dataset.type
if(_this !== "PUBLIC"){ if(_this !== "PUBLIC"){
@@ -433,7 +481,7 @@ function sendText() {
dataType:"json", dataType:"json",
success: function(result){ success: function(result){
//发送成功 //发送成功
console.log(result) getOne()
chrome.storage.sync.set( chrome.storage.sync.set(
{ open_action: '', open_content: '',resourceIdList:''}, { open_action: '', open_content: '',resourceIdList:''},
function () { function () {
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"manifest_version": 3, "manifest_version": 3,
"name": "__MSG_extName__", "name": "__MSG_extName__",
"version": "2023.02.06", "version": "2023.02.07",
"action": { "action": {
"default_popup": "popup.html", "default_popup": "popup.html",
"default_icon": "assets/logo_24x24.png", "default_icon": "assets/logo_24x24.png",
+1 -1
View File
@@ -11,7 +11,7 @@
<link rel="stylesheet" href="../css/main.css" /> <link rel="stylesheet" href="../css/main.css" />
</head> </head>
<body class="body"> <body class="body">
<div class="title">MEMOS</div> <div class="title" id="getone">MEMOS</div>
<div id="blog_info_edit"><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" class="icon" viewBox="0 0 1024 1024"> <div id="blog_info_edit"><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" class="icon" viewBox="0 0 1024 1024">
<path d="M914 432c-5-26-21-43-41-43h-4c-54 0-99-44-99-99 0-17 9-37 9-38 10-22 2-50-18-65l-103-57h-1c-21-9-49-4-64 12-12 12-50 44-79 44s-68-33-79-45a60 60 0 0 0-64-13l-106 58-2 1a54 54 0 0 0-18 65c0 1 9 21 9 38 0 55-45 99-99 99h-5c-19 0-35 17-40 43 0 2-9 45-9 80s9 79 9 81c5 25 21 42 41 42h4c54 0 99 45 99 99 0 18-9 37-9 38-10 23-2 51 18 65l101 56 1 1c21 9 49 3 65-13 14-15 52-47 80-47 30 0 69 35 81 48a58 58 0 0 0 64 14l104-58 2-1c20-14 28-42 18-65 0-1-9-20-9-38 0-54 45-99 99-99h5c19 0 35-17 40-42 0-2 9-46 9-81s-9-78-9-80m-51 80c0 23-5 52-7 64a158 158 0 0 0-134 215l-89 49c-4-5-17-18-35-31-31-23-61-35-88-35s-57 12-88 34c-17 13-30 26-34 31l-86-48a159 159 0 0 0-134-215c-2-12-7-41-7-64 0-22 5-51 7-64a157 157 0 0 0 134-214l91-50c4 4 17 17 35 29 30 22 59 33 86 33s55-11 85-32c18-13 31-25 35-29l88 49a159 159 0 0 0 134 214c2 13 7 42 7 64"/> <path d="M914 432c-5-26-21-43-41-43h-4c-54 0-99-44-99-99 0-17 9-37 9-38 10-22 2-50-18-65l-103-57h-1c-21-9-49-4-64 12-12 12-50 44-79 44s-68-33-79-45a60 60 0 0 0-64-13l-106 58-2 1a54 54 0 0 0-18 65c0 1 9 21 9 38 0 55-45 99-99 99h-5c-19 0-35 17-40 43 0 2-9 45-9 80s9 79 9 81c5 25 21 42 41 42h4c54 0 99 45 99 99 0 18-9 37-9 38-10 23-2 51 18 65l101 56 1 1c21 9 49 3 65-13 14-15 52-47 80-47 30 0 69 35 81 48a58 58 0 0 0 64 14l104-58 2-1c20-14 28-42 18-65 0-1-9-20-9-38 0-54 45-99 99-99h5c19 0 35-17 40-42 0-2 9-46 9-81s-9-78-9-80m-51 80c0 23-5 52-7 64a158 158 0 0 0-134 215l-89 49c-4-5-17-18-35-31-31-23-61-35-88-35s-57 12-88 34c-17 13-30 26-34 31l-86-48a159 159 0 0 0-134-215c-2-12-7-41-7-64 0-22 5-51 7-64a157 157 0 0 0 134-214l91-50c4 4 17 17 35 29 30 22 59 33 86 33s55-11 85-32c18-13 31-25 35-29l88 49a159 159 0 0 0 134 214c2 13 7 42 7 64"/>
<path d="M510 366a146 146 0 1 0 1 292 146 146 0 0 0-1-292m87 146a87 87 0 1 1-173-1 87 87 0 0 1 173 1"/> <path d="M510 366a146 146 0 1 0 1 292 146 146 0 0 0-1-292m87 146a87 87 0 1 1-173-1 87 87 0 0 1 173 1"/>