diff --git a/README.md b/README.md index de992ab..80daa69 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ ## 更新日志 +2023.02.07 新增发布后显示最新一条 Memo ,具体一条新增归档按钮。 + 2023.02.06 新增搜索按钮;新增图片灯箱。 ![iShot_2023-02-04_20 42 40](https://user-images.githubusercontent.com/1472390/216768533-4a93124a-666e-4617-a60b-29c826dc1584.png) diff --git a/css/main.css b/css/main.css index 45ed61f..7361161 100644 --- a/css/main.css +++ b/css/main.css @@ -18,6 +18,7 @@ input::placeholder ,.common-editor-inputer::placeholder { input:focus::placeholder ,.common-editor-inputer:focus::placeholder { color: #d3d3d3 } +.title{cursor: pointer;} .body{ min-width:460px; background-color: #f6f5f4; @@ -51,7 +52,10 @@ a{color: #555;} 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-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-content{width:100%; max-width:100%; diff --git a/js/oper.js b/js/oper.js index e381cfc..7960e99 100644 --- a/js/oper.js +++ b/js/oper.js @@ -109,7 +109,7 @@ function uploadImage(data) { if (info.status) { formData.append('file', data) $.ajax({ - url: info.apiUrl.replace(/api\/memo/,'api/resource'), + url: info.apiUrl.replace(/api\/memo/,'api/resource/blob'), data: formData, type: 'post', 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 () { get_info(function (info) { - if (info.status) { + if (info.apiUrl) { var tagUrl = info.apiUrl.replace(/api\/memo/,'api/tag') var tagDom = "" $.get(tagUrl,function(data){ @@ -218,7 +239,7 @@ $('#search').click(function () { const fuse = new Fuse(data.data, options); var searchData = fuse.search(pattern) for(var i=0;i < searchData.length;i++){ - searchDom += '
'+dayjs(new Date(searchData[i].item.createdTs)*1000).fromNow()+'
'+searchData[i].item.content.replace(/!\[.*?\]\((.*?)\)/g,' ').replace(/\[(.*?)\]\((.*?)\)/g,' $1 ')+'
' + searchDom += '
'+dayjs(new Date(searchData[i].item.createdTs)*1000).fromNow()+'
'+searchData[i].item.content.replace(/!\[.*?\]\((.*?)\)/g,' ').replace(/\[(.*?)\]\((.*?)\)/g,' $1 ')+'
' if(searchData[i].item.resourceList && searchData[i].item.resourceList.length > 0){ var resourceList = searchData[i].item.resourceList; for(var j=0;j < resourceList.length;j++){ @@ -279,7 +300,7 @@ $('#random').click(function () { function randDom(randomData){ get_info(function (info) { - var randomDom = '
'+dayjs(new Date(randomData.createdTs * 1000)).fromNow()+'
'+randomData.content.replace(/!\[.*?\]\((.*?)\)/g,' ').replace(/\[(.*?)\]\((.*?)\)/g,' $1 ')+'
' + var randomDom = '
'+dayjs(new Date(randomData.createdTs * 1000)).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++){ @@ -296,12 +317,39 @@ function randDom(randomData){ } $(document).on("click","#random-link",function () { - var memoId = this.getAttribute('data-id') + var memoId = $("#random-link").data('id'); get_info(function (info) { 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 () { _this = $(this)[0].dataset.type if(_this !== "PUBLIC"){ @@ -433,7 +481,7 @@ function sendText() { dataType:"json", success: function(result){ //发送成功 - console.log(result) + getOne() chrome.storage.sync.set( { open_action: '', open_content: '',resourceIdList:''}, function () { diff --git a/manifest.json b/manifest.json index 80b5bb5..32c77cf 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 3, "name": "__MSG_extName__", - "version": "2023.02.06", + "version": "2023.02.07", "action": { "default_popup": "popup.html", "default_icon": "assets/logo_24x24.png", diff --git a/popup.html b/popup.html index 446e678..50f184a 100644 --- a/popup.html +++ b/popup.html @@ -11,7 +11,7 @@ -
MEMOS
+
MEMOS