From e96c16367ddbf3c1a1a821f0dfe2c8293e3e9966 Mon Sep 17 00:00:00 2001 From: lmm214 Date: Sun, 21 Jul 2024 22:23:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8C=B9=E9=85=8D=20v0.22.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _locales/en/messages.json | 6 + _locales/zh_CN/messages.json | 5 +- js/fuse.basic.min.js | 9 -- js/oper.js | 261 ++++++++++++++++++----------------- manifest.json | 2 +- popup.html | 1 - 6 files changed, 147 insertions(+), 137 deletions(-) delete mode 100644 js/fuse.basic.min.js diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 7ffa40a..456fb77 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -65,9 +65,15 @@ "picPending":{ "message": "Image uploading is in progress" }, + "saveSuccess":{ + "message": "Save Info Success!" + }, "searchNow":{ "message": "What are you looking for?" }, + "searchNone":{ + "message": "Try another word!" + }, "archiveSuccess":{ "message": "Archive Success 😊" }, diff --git a/_locales/zh_CN/messages.json b/_locales/zh_CN/messages.json index ba2402f..360ee42 100644 --- a/_locales/zh_CN/messages.json +++ b/_locales/zh_CN/messages.json @@ -71,6 +71,9 @@ "searchNow":{ "message": "想搜点啥?" }, + "searchNone":{ + "message": "搜不到,换个词试试" + }, "archiveSuccess":{ "message": "归档成功!😊" }, @@ -92,4 +95,4 @@ "invalidToken":{ "message": "无效的 token 或 url 😭" } -} +} \ No newline at end of file diff --git a/js/fuse.basic.min.js b/js/fuse.basic.min.js deleted file mode 100644 index 89477c6..0000000 --- a/js/fuse.basic.min.js +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Fuse.js v6.6.2 - Lightweight fuzzy-search (http://fusejs.io) - * - * Copyright (c) 2022 Kiro Risk (http://kiro.me) - * All Rights Reserved. Apache Software License 2.0 - * - * http://www.apache.org/licenses/LICENSE-2.0 - */ -var e,t;e=this,t=function(){"use strict";function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function t(t){for(var n=1;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,n=new Map,r=Math.pow(10,t);return{get:function(t){var i=t.match(_).length;if(n.has(i))return n.get(i);var o=1/Math.pow(i,.5*e),a=parseFloat(Math.round(o*r)/r);return n.set(i,a),a},clear:function(){n.clear()}}}var O=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.getFn,i=void 0===n?L.getFn:n,o=t.fieldNormWeight,a=void 0===o?L.fieldNormWeight:o;r(this,e),this.norm=S(a,3),this.getFn=i,this.isCreated=!1,this.setIndexRecords()}return o(e,[{key:"setSources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.docs=e}},{key:"setIndexRecords",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.records=e}},{key:"setKeys",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.keys=t,this._keysMap={},t.forEach((function(t,n){e._keysMap[t.id]=n}))}},{key:"create",value:function(){var e=this;!this.isCreated&&this.docs.length&&(this.isCreated=!0,u(this.docs[0])?this.docs.forEach((function(t,n){e._addString(t,n)})):this.docs.forEach((function(t,n){e._addObject(t,n)})),this.norm.clear())}},{key:"add",value:function(e){var t=this.size();u(e)?this._addString(e,t):this._addObject(e,t)}},{key:"removeAt",value:function(e){this.records.splice(e,1);for(var t=e,n=this.size();t2&&void 0!==arguments[2]?arguments[2]:{},r=n.getFn,i=void 0===r?L.getFn:r,o=n.fieldNormWeight,a=void 0===o?L.fieldNormWeight:o,c=new O({getFn:i,fieldNormWeight:a});return c.setKeys(e.map(k)),c.setSources(t),c.create(),c}function j(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.errors,r=void 0===n?0:n,i=t.currentLocation,o=void 0===i?0:i,a=t.expectedLocation,c=void 0===a?0:a,s=t.distance,h=void 0===s?L.distance:s,u=t.ignoreLocation,l=void 0===u?L.ignoreLocation:u,d=r/e.length;if(l)return d;var f=Math.abs(c-o);return h?d+f/h:f?1:d}function E(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:L.minMatchCharLength,n=[],r=-1,i=-1,o=0,a=e.length;o=t&&n.push([r,i]),r=-1)}return e[o-1]&&o-r>=t&&n.push([r,o-1]),n}var I=32;function F(e){for(var t={},n=0,r=e.length;n1&&void 0!==arguments[1]?arguments[1]:{},o=i.location,a=void 0===o?L.location:o,c=i.threshold,s=void 0===c?L.threshold:c,h=i.distance,u=void 0===h?L.distance:h,l=i.includeMatches,d=void 0===l?L.includeMatches:l,f=i.findAllMatches,v=void 0===f?L.findAllMatches:f,g=i.minMatchCharLength,y=void 0===g?L.minMatchCharLength:g,p=i.isCaseSensitive,m=void 0===p?L.isCaseSensitive:p,b=i.ignoreLocation,k=void 0===b?L.ignoreLocation:b;if(r(this,e),this.options={location:a,threshold:s,distance:u,includeMatches:d,findAllMatches:v,minMatchCharLength:y,isCaseSensitive:m,ignoreLocation:k},this.pattern=m?t:t.toLowerCase(),this.chunks=[],this.pattern.length){var M=function(e,t){n.chunks.push({pattern:e,alphabet:F(e),startIndex:t})},w=this.pattern.length;if(w>I){for(var x=0,_=w%I,S=w-_;x3&&void 0!==arguments[3]?arguments[3]:{},i=r.location,o=void 0===i?L.location:i,a=r.distance,c=void 0===a?L.distance:a,s=r.threshold,h=void 0===s?L.threshold:s,u=r.findAllMatches,l=void 0===u?L.findAllMatches:u,d=r.minMatchCharLength,f=void 0===d?L.minMatchCharLength:d,v=r.includeMatches,g=void 0===v?L.includeMatches:v,y=r.ignoreLocation,m=void 0===y?L.ignoreLocation:y;if(t.length>I)throw new Error(p(I));for(var b,k=t.length,M=e.length,w=Math.max(0,Math.min(o,M)),x=h,_=w,S=f>1||g,O=S?Array(M):[];(b=e.indexOf(t,_))>-1;){var A=j(t,{currentLocation:b,expectedLocation:w,distance:c,ignoreLocation:m});if(x=Math.min(A,x),_=b+k,S)for(var F=0;F=T;R-=1){var U=R-1,B=n[e.charAt(U)];if(S&&(O[U]=+!!B),J[R]=(J[R+1]<<1|1)&B,$&&(J[R]|=(C[R+1]|C[R])<<1|1|C[R+1]),J[R]&W&&(N=j(t,{errors:$,currentLocation:U,expectedLocation:w,distance:c,ignoreLocation:m}))<=x){if(x=N,(_=U)<=w)break;T=Math.max(1,2*w-_)}}if(j(t,{errors:$+1,currentLocation:w,expectedLocation:w,distance:c,ignoreLocation:m})>x)break;C=J}var V={isMatch:_>=0,score:Math.max(.001,N)};if(S){var q=E(O,f);q.length?g&&(V.indices=q):V.isMatch=!1}return V}(e,n,i,{location:a+o,distance:s,threshold:h,findAllMatches:u,minMatchCharLength:l,includeMatches:r,ignoreLocation:d}),m=y.isMatch,b=y.score,k=y.indices;m&&(g=!0),v+=b,m&&k&&(f=[].concat(c(f),c(k)))}));var y={isMatch:g,score:g?v/this.chunks.length:1};return g&&r&&(y.indices=f),y}}]),e}(),N=[];function P(e,t){for(var n=0,r=N.length;n-1&&(n.refIndex=e.idx),t.matches.push(n)}}))}function D(e,t){t.score=e.score}function K(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.includeMatches,i=void 0===r?L.includeMatches:r,o=n.includeScore,a=void 0===o?L.includeScore:o,c=[];return i&&c.push($),a&&c.push(D),e.map((function(e){var n=e.idx,r={item:t[n],refIndex:n};return c.length&&c.forEach((function(t){t(e,r)})),r}))}var T=function(){function e(n){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments.length>2?arguments[2]:void 0;if(r(this,e),this.options=t(t({},L),i),this.options.useExtendedSearch)throw new Error(y);this._keyStore=new b(this.options.keys),this.setCollection(n,o)}return o(e,[{key:"setCollection",value:function(e,t){if(this._docs=e,t&&!(t instanceof O))throw new Error("Incorrect 'index' type");this._myIndex=t||A(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}},{key:"add",value:function(e){f(e)&&(this._docs.push(e),this._myIndex.add(e))}},{key:"remove",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){return!1},t=[],n=0,r=this._docs.length;n1&&void 0!==arguments[1]?arguments[1]:{},n=t.limit,r=void 0===n?-1:n,i=this.options,o=i.includeMatches,a=i.includeScore,c=i.shouldSort,s=i.sortFn,h=i.ignoreFieldNorm,d=u(e)?u(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return W(d,{ignoreFieldNorm:h}),c&&d.sort(s),l(r)&&r>-1&&(d=d.slice(0,r)),K(d,this._docs,{includeMatches:o,includeScore:a})}},{key:"_searchStringList",value:function(e){var t=P(e,this.options),n=this._myIndex.records,r=[];return n.forEach((function(e){var n=e.v,i=e.i,o=e.n;if(f(n)){var a=t.searchIn(n),c=a.isMatch,s=a.score,h=a.indices;c&&r.push({item:n,idx:i,matches:[{score:s,value:n,norm:o,indices:h}]})}})),r}},{key:"_searchLogical",value:function(e){throw new Error("Logical search is not available")}},{key:"_searchObjectList",value:function(e){var t=this,n=P(e,this.options),r=this._myIndex,i=r.keys,o=r.records,a=[];return o.forEach((function(e){var r=e.$,o=e.i;if(f(r)){var s=[];i.forEach((function(e,i){s.push.apply(s,c(t._findMatches({key:e,value:r[i],searcher:n})))})),s.length&&a.push({idx:o,item:r,matches:s})}})),a}},{key:"_findMatches",value:function(e){var t=e.key,n=e.value,r=e.searcher;if(!f(n))return[];var i=[];if(h(n))n.forEach((function(e){var n=e.v,o=e.i,a=e.n;if(f(n)){var c=r.searchIn(n),s=c.isMatch,h=c.score,u=c.indices;s&&i.push({score:h,key:t,value:n,idx:o,norm:a,indices:u})}}));else{var o=n.v,a=n.n,c=r.searchIn(o),s=c.isMatch,u=c.score,l=c.indices;s&&i.push({score:u,key:t,value:o,norm:a,indices:l})}return i}}]),e}();return T.version="6.6.2",T.createIndex=A,T.parseIndex=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.getFn,r=void 0===n?L.getFn:n,i=t.fieldNormWeight,o=void 0===i?L.fieldNormWeight:i,a=e.keys,c=e.records,s=new O({getFn:r,fieldNormWeight:o});return s.setKeys(a),s.setIndexRecords(c),s},T.config=L,T},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Fuse=t(); \ No newline at end of file diff --git a/js/oper.js b/js/oper.js index 75bff8a..22d9dc2 100644 --- a/js/oper.js +++ b/js/oper.js @@ -141,35 +141,63 @@ function initDrag() { } let relistNow = [] -function uploadImage(data) { +function uploadImage(file) { $.message({ message: chrome.i18n.getMessage("picUploading"), autoClose: false - }) - //根据data判断是图片地址还是base64加密的数据 - get_info(function (info) { - const formData = new FormData() + }); + const reader = new FileReader(); + reader.onload = function(e) { + const base64String = e.target.result.split(',')[1]; + uploadImageNow(base64String, file); + }; + reader.onerror = function(error) { + console.error('Error reading file:', error); + }; + reader.readAsDataURL(file); +}; + +function uploadImageNow(base64String, file) { + get_info(function(info) { if (info.status) { - let old_name = data.name.split('.'); - let file_ext = data.name.split('.').pop(); - let now = dayjs().format('YYYYMMDDHHmmss') + let old_name = file.name.split('.'); + let file_ext = file.name.split('.').pop(); + let now = dayjs().format('YYYYMMDDHHmmss'); let new_name = old_name[0] + '_' + now + '.' + file_ext; - formData.append('file', data, new_name) - var upAjaxUrl = info.apiUrl + 'api/v1/resource/blob' + var hideTag = info.hidetag + var showTag = info.showtag + var nowTag = $("textarea[name=text]").val().match(/(#[^\s#]+)/) + var sendvisi = info.memo_lock || '' + if(nowTag){ + if(nowTag[1] == showTag){ + sendvisi = 'PUBLIC' + }else if(nowTag[1] == hideTag){ + sendvisi = 'PRIVATE' + } + } + const data = { + content: base64String, + visibility: sendvisi, + filename: new_name, + type: file.type + }; + var upAjaxUrl = info.apiUrl + 'api/v1/resources'; $.ajax({ url: upAjaxUrl, - data: formData, + data: JSON.stringify(data), type: 'post', cache: false, processData: false, - contentType: false, + contentType: 'application/json', dataType: 'json', headers: { 'Authorization': 'Bearer ' + info.apiTokens }, success: function (data) { - console.log(data) - if (data.id) { - //获取到图片 - relistNow.push(data.id) + if (data.uid) { + relistNow.push({ + "name":data.name, + "uid":data.uid, + "type":data.type + }) chrome.storage.sync.set( { open_action: '', @@ -198,13 +226,13 @@ function uploadImage(data) { ) } } - }) - } else { + }); + }else { $.message({ message: chrome.i18n.getMessage("placeApiUrl") }) } - }) + }); } $('#saveKey').click(function () { @@ -325,48 +353,52 @@ $(document).on("click",".item-lock",function () { $('#search').click(function () { get_info(function (info) { + const pattern = $("textarea[name=text]").val() + var filter = "?filter=" + encodeURIComponent(`creator == 'users/${info.userid}' && visibilities == ['PUBLIC', 'PROTECTED'] && content_search == ['${pattern}']`); if (info.status) { $("#randomlist").html('').hide() var searchDom = "" - const pattern = $("textarea[name=text]").val() if(pattern){ $.ajax({ - //memos+"api/"+apiV1+"memo?creatorId="+bbMemo.creatorId+"&content="+serchText+"&limit=20"; - url:info.apiUrl+"api/v1/memo", + url:info.apiUrl+"api/v1/memos"+filter, type:"GET", contentType:"application/json;", dataType:"json", headers : {'Authorization':'Bearer ' + info.apiTokens}, success: function(data){ - const options = {keys: ['content']}; - const fuse = new Fuse(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 ')+'
' - 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++){ - var restype = resourceList[j].type.slice(0,5); - var resexlink = resourceList[j].externalLink - var resLink = '',fileId='' - if(resexlink){ - resLink = resexlink - }else{ - fileId = resourceList[j].publicId || resourceList[j].filename - resLink = info.apiUrl+'o/r/'+resourceList[j].id+'/'+fileId + let searchData = data.memos + if(searchData.length == 0){ + $.message({ + message: chrome.i18n.getMessage("searchNone") + }) + }else{ + for(var i=0;i < searchData.length;i++){ + searchDom += '
'+dayjs(searchData.createTime).fromNow()+'
'+searchData[i].content.replace(/!\[.*?\]\((.*?)\)/g,' ').replace(/\[(.*?)\]\((.*?)\)/g,' $1 ')+'
' + if(searchData[i].resources && searchData[i].resources.length > 0){ + var resources = searchData[i].resources; + for(var j=0;j < resources.length;j++){ + var restype = resources[j].type.slice(0,5); + var resexlink = resources[j].externalLink + var resLink = '',fileId='' + if(resexlink){ + resLink = resexlink + }else{ + fileId = resources[j].publicId || resources[j].filename + resLink = info.apiUrl+'file/'+resources[j].name+'/'+fileId } - if(restype == 'image'){ - searchDom += '' - } - if(restype !== 'image'){ - searchDom += ''+resourceList[j].filename+'' + if(restype == 'image'){ + searchDom += '' + } + if(restype !== 'image'){ + searchDom += ''+resources[j].filename+'' + } } } + searchDom += '
' } - searchDom += '
' + window.ViewImage && ViewImage.init('.random-image') + $("#randomlist").html(searchDom).slideDown(500); } - window.ViewImage && ViewImage.init('.random-image') - $("#randomlist").html(searchDom).slideDown(500); } }); }else{ @@ -384,59 +416,22 @@ $('#search').click(function () { $('#random').click(function () { get_info(function (info) { + var filter = "?filter=" + encodeURIComponent(`creator == 'users/${info.userid}'`); if (info.status) { $("#randomlist").html('').hide() - var nowTag = $("textarea[name=text]").val().match(/#([^\s#]+)/) - if( $("#taglist").is(':visible') && nowTag[1]){ - var tagUrl = info.apiUrl+'api/v1/memo?rowStatus=NORMAL&tag='+nowTag[1] - $.ajax({ - url:tagUrl, - type:"GET", - contentType:"application/json;", - dataType:"json", - headers : {'Authorization':'Bearer ' + info.apiTokens}, - success: function(data){ - let randomNum = Math.floor(Math.random() * (data.length)); - var randomData = data[randomNum] - randDom(randomData) - } - }) - }else{ - var randomUrl0 = info.apiUrl+'api/v1/memo?rowStatus=NORMAL&limit=1' - $.ajax({ - url:randomUrl0, - type:"GET", - contentType:"application/json;", - dataType:"json", - headers : {'Authorization':'Bearer ' + info.apiTokens}, - success: function(data0){ - var creatorId = data0[0].creatorId - var randomUrl1 = info.apiUrl+'api/v1/memo/stats?creatorId='+creatorId - $.ajax({ - url:randomUrl1, - type:"GET", - contentType:"application/json;", - dataType:"json", - headers : {'Authorization':'Bearer ' + info.apiTokens}, - success: function(data1){ - let randomNum = Math.floor(Math.random() * (data1.length)) + 1; - var randomUrl2 = info.apiUrl+'api/v1/memo?rowStatus=NORMAL&limit=1&offset='+randomNum - $.ajax({ - url:randomUrl2, - type:"GET", - contentType:"application/json;", - dataType:"json", - headers : {'Authorization':'Bearer ' + info.apiTokens}, - success: function(data2){ - var randomData = data2[0] - randDom(randomData) - } - }); - } - }); - } - }) - } + var randomUrl = info.apiUrl + 'api/v1/memos' + filter; + $.ajax({ + url:randomUrl, + type:"GET", + contentType:"application/json;", + dataType:"json", + headers : {'Authorization':'Bearer ' + info.apiTokens}, + success: function(data){ + let randomNum = Math.floor(Math.random() * (data.memos.length)); + var randomData = data.memos[randomNum] + randDom(randomData) + } + }) } else { $.message({ message: chrome.i18n.getMessage("placeApiUrl") @@ -447,24 +442,24 @@ $('#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 ')+'
' - 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); - var resexlink = resourceList[j].externalLink + var randomDom = '
'+dayjs(randomData.createTime).fromNow()+'
'+randomData.content.replace(/!\[.*?\]\((.*?)\)/g,' ').replace(/\[(.*?)\]\((.*?)\)/g,' $1 ')+'
' + if(randomData.resources && randomData.resources.length > 0){ + var resources = randomData.resources; + for(var j=0;j < resources.length;j++){ + var restype = resources[j].type.slice(0,5); + var resexlink = resources[j].externalLink var resLink = '',fileId='' if(resexlink){ resLink = resexlink }else{ - fileId = resourceList[j].publicId || resourceList[j].filename - resLink = info.apiUrl+'o/r/'+resourceList[j].id+'/'+fileId + fileId = resources[j].publicId || resources[j].filename + resLink = info.apiUrl+'file/'+resources[j].name+'/'+fileId } if(restype == 'image'){ randomDom += '' } if(restype !== 'image'){ - randomDom += ''+resourceList[j].filename+'' + randomDom += ''+resources[j].filename+'' } } } @@ -475,21 +470,22 @@ function randDom(randomData){ } $(document).on("click","#random-link",function () { - var memoId = $("#random-link").data('id'); + var memoUid = $("#random-link").data('uid'); get_info(function (info) { - chrome.tabs.create({url:info.apiUrl+"m/"+memoId}) + chrome.tabs.create({url:info.apiUrl+"m/"+memoUid}) }) }) $(document).on("click","#random-delete",function () { get_info(function (info) { - var memosId = $("#random-delete").data('id'); - var deleteUrl = info.apiUrl+'api/v1/memo/'+memosId + var memoUid = $("#random-delete").data('uid'); + var memosName = $("#random-delete").data('name'); + var deleteUrl = info.apiUrl+'api/v1/'+memosName $.ajax({ url:deleteUrl, type:"PATCH", data:JSON.stringify({ - 'id': memosId, + 'uid': memoUid, 'rowStatus': "ARCHIVED" }), contentType:"application/json;", @@ -579,7 +575,7 @@ function getOne(memosId){ get_info(function (info) { if (info.apiUrl) { $("#randomlist").html('').hide() - var getUrl = info.apiUrl+'api/v1/memo/'+memosId + var getUrl = info.apiUrl+'api/v1/'+memosId $.ajax({ url:getUrl, type:"GET", @@ -622,24 +618,39 @@ function sendText() { type:"POST", data:JSON.stringify({ 'content': content, - 'visibility': sendvisi, - 'resourceIdList': info.resourceIdList || [], + 'visibility': sendvisi }), contentType:"application/json;", dataType:"json", headers : {'Authorization':'Bearer ' + info.apiTokens}, success: function(data){ - //发送成功 - getOne(data.id) - chrome.storage.sync.set( - { open_action: '', open_content: '',resourceIdList:''}, - function () { - $.message({ - message: chrome.i18n.getMessage("memoSuccess") - }) - //$("#content_submit_text").removeAttr('disabled'); - $("textarea[name=text]").val('') - } + if(info.resourceIdList.length > 0 ){ + //匹配图片 + $.ajax({ + url:info.apiUrl+'api/v1/'+data.name+'/resources', + type:"PATCH", + data:JSON.stringify({ + 'resources': info.resourceIdList || [], + }), + contentType:"application/json;", + dataType:"json", + headers : {'Authorization':'Bearer ' + info.apiTokens}, + success: function(res){ + getOne(data.name) + } + }) + }else{ + getOne(data.name) + } + chrome.storage.sync.set( + { open_action: '', open_content: '',resourceIdList:''}, + function () { + $.message({ + message: chrome.i18n.getMessage("memoSuccess") + }) + //$("#content_submit_text").removeAttr('disabled'); + $("textarea[name=text]").val('') + } ) },error:function(err){//清空open_action(打开时候进行的操作),同时清空open_content chrome.storage.sync.set( diff --git a/manifest.json b/manifest.json index 99d8faa..be77e73 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 3, "name": "__MSG_extName__", "default_locale": "zh_CN", - "version": "2024.06.15", + "version": "2024.07.21", "action": { "default_popup": "popup.html", "default_icon": "assets/logo_24x24.png", diff --git a/popup.html b/popup.html index 388c9ea..e7fa63a 100644 --- a/popup.html +++ b/popup.html @@ -132,7 +132,6 @@ -