mirror of
https://github.com/Jonnyan404/memos-bber.git
synced 2026-04-25 03:58:37 +09:00
匹配 v0.22.3
This commit is contained in:
@@ -65,9 +65,15 @@
|
|||||||
"picPending":{
|
"picPending":{
|
||||||
"message": "Image uploading is in progress"
|
"message": "Image uploading is in progress"
|
||||||
},
|
},
|
||||||
|
"saveSuccess":{
|
||||||
|
"message": "Save Info Success!"
|
||||||
|
},
|
||||||
"searchNow":{
|
"searchNow":{
|
||||||
"message": "What are you looking for?"
|
"message": "What are you looking for?"
|
||||||
},
|
},
|
||||||
|
"searchNone":{
|
||||||
|
"message": "Try another word!"
|
||||||
|
},
|
||||||
"archiveSuccess":{
|
"archiveSuccess":{
|
||||||
"message": "Archive Success 😊"
|
"message": "Archive Success 😊"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -71,6 +71,9 @@
|
|||||||
"searchNow":{
|
"searchNow":{
|
||||||
"message": "想搜点啥?"
|
"message": "想搜点啥?"
|
||||||
},
|
},
|
||||||
|
"searchNone":{
|
||||||
|
"message": "搜不到,换个词试试"
|
||||||
|
},
|
||||||
"archiveSuccess":{
|
"archiveSuccess":{
|
||||||
"message": "归档成功!😊"
|
"message": "归档成功!😊"
|
||||||
},
|
},
|
||||||
|
|||||||
Vendored
-9
File diff suppressed because one or more lines are too long
+104
-93
@@ -141,35 +141,63 @@ function initDrag() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let relistNow = []
|
let relistNow = []
|
||||||
function uploadImage(data) {
|
function uploadImage(file) {
|
||||||
$.message({
|
$.message({
|
||||||
message: chrome.i18n.getMessage("picUploading"),
|
message: chrome.i18n.getMessage("picUploading"),
|
||||||
autoClose: false
|
autoClose: false
|
||||||
})
|
});
|
||||||
//根据data判断是图片地址还是base64加密的数据
|
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) {
|
get_info(function(info) {
|
||||||
const formData = new FormData()
|
|
||||||
if (info.status) {
|
if (info.status) {
|
||||||
let old_name = data.name.split('.');
|
let old_name = file.name.split('.');
|
||||||
let file_ext = data.name.split('.').pop();
|
let file_ext = file.name.split('.').pop();
|
||||||
let now = dayjs().format('YYYYMMDDHHmmss')
|
let now = dayjs().format('YYYYMMDDHHmmss');
|
||||||
let new_name = old_name[0] + '_' + now + '.' + file_ext;
|
let new_name = old_name[0] + '_' + now + '.' + file_ext;
|
||||||
formData.append('file', data, new_name)
|
var hideTag = info.hidetag
|
||||||
var upAjaxUrl = info.apiUrl + 'api/v1/resource/blob'
|
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({
|
$.ajax({
|
||||||
url: upAjaxUrl,
|
url: upAjaxUrl,
|
||||||
data: formData,
|
data: JSON.stringify(data),
|
||||||
type: 'post',
|
type: 'post',
|
||||||
cache: false,
|
cache: false,
|
||||||
processData: false,
|
processData: false,
|
||||||
contentType: false,
|
contentType: 'application/json',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
headers: { 'Authorization': 'Bearer ' + info.apiTokens },
|
headers: { 'Authorization': 'Bearer ' + info.apiTokens },
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
console.log(data)
|
if (data.uid) {
|
||||||
if (data.id) {
|
relistNow.push({
|
||||||
//获取到图片
|
"name":data.name,
|
||||||
relistNow.push(data.id)
|
"uid":data.uid,
|
||||||
|
"type":data.type
|
||||||
|
})
|
||||||
chrome.storage.sync.set(
|
chrome.storage.sync.set(
|
||||||
{
|
{
|
||||||
open_action: '',
|
open_action: '',
|
||||||
@@ -198,13 +226,13 @@ function uploadImage(data) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}else {
|
}else {
|
||||||
$.message({
|
$.message({
|
||||||
message: chrome.i18n.getMessage("placeApiUrl")
|
message: chrome.i18n.getMessage("placeApiUrl")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#saveKey').click(function () {
|
$('#saveKey').click(function () {
|
||||||
@@ -325,41 +353,44 @@ $(document).on("click",".item-lock",function () {
|
|||||||
|
|
||||||
$('#search').click(function () {
|
$('#search').click(function () {
|
||||||
get_info(function (info) {
|
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) {
|
if (info.status) {
|
||||||
$("#randomlist").html('').hide()
|
$("#randomlist").html('').hide()
|
||||||
var searchDom = ""
|
var searchDom = ""
|
||||||
const pattern = $("textarea[name=text]").val()
|
|
||||||
if(pattern){
|
if(pattern){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
//memos+"api/"+apiV1+"memo?creatorId="+bbMemo.creatorId+"&content="+serchText+"&limit=20";
|
url:info.apiUrl+"api/v1/memos"+filter,
|
||||||
url:info.apiUrl+"api/v1/memo",
|
|
||||||
type:"GET",
|
type:"GET",
|
||||||
contentType:"application/json;",
|
contentType:"application/json;",
|
||||||
dataType:"json",
|
dataType:"json",
|
||||||
headers : {'Authorization':'Bearer ' + info.apiTokens},
|
headers : {'Authorization':'Bearer ' + info.apiTokens},
|
||||||
success: function(data){
|
success: function(data){
|
||||||
const options = {keys: ['content']};
|
let searchData = data.memos
|
||||||
const fuse = new Fuse(data, options);
|
if(searchData.length == 0){
|
||||||
var searchData = fuse.search(pattern)
|
$.message({
|
||||||
|
message: chrome.i18n.getMessage("searchNone")
|
||||||
|
})
|
||||||
|
}else{
|
||||||
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+'"><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>'
|
searchDom += '<div class="random-item"><div class="random-time"><span id="random-link" data-uid="'+searchData[i].uid+'"><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-name="'+searchData[i].name+'" data-uid="'+searchData[i].uid+'"><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(searchData.createTime).fromNow()+'</div><div class="random-content">'+searchData[i].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].resources && searchData[i].resources.length > 0){
|
||||||
var resourceList = searchData[i].item.resourceList;
|
var resources = searchData[i].resources;
|
||||||
for(var j=0;j < resourceList.length;j++){
|
for(var j=0;j < resources.length;j++){
|
||||||
var restype = resourceList[j].type.slice(0,5);
|
var restype = resources[j].type.slice(0,5);
|
||||||
var resexlink = resourceList[j].externalLink
|
var resexlink = resources[j].externalLink
|
||||||
var resLink = '',fileId=''
|
var resLink = '',fileId=''
|
||||||
if(resexlink){
|
if(resexlink){
|
||||||
resLink = resexlink
|
resLink = resexlink
|
||||||
}else{
|
}else{
|
||||||
fileId = resourceList[j].publicId || resourceList[j].filename
|
fileId = resources[j].publicId || resources[j].filename
|
||||||
resLink = info.apiUrl+'o/r/'+resourceList[j].id+'/'+fileId
|
resLink = info.apiUrl+'file/'+resources[j].name+'/'+fileId
|
||||||
}
|
}
|
||||||
if(restype == 'image'){
|
if(restype == 'image'){
|
||||||
searchDom += '<img class="random-image" src="'+resLink+'"/>'
|
searchDom += '<img class="random-image" src="'+resLink+'"/>'
|
||||||
}
|
}
|
||||||
if(restype !== 'image'){
|
if(restype !== 'image'){
|
||||||
searchDom += '<a target="_blank" rel="noreferrer" href="'+resLink+'">'+resourceList[j].filename+'</a>'
|
searchDom += '<a target="_blank" rel="noreferrer" href="'+resLink+'">'+resources[j].filename+'</a>'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -368,6 +399,7 @@ $('#search').click(function () {
|
|||||||
window.ViewImage && ViewImage.init('.random-image')
|
window.ViewImage && ViewImage.init('.random-image')
|
||||||
$("#randomlist").html(searchDom).slideDown(500);
|
$("#randomlist").html(searchDom).slideDown(500);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
$.message({
|
$.message({
|
||||||
@@ -384,59 +416,22 @@ $('#search').click(function () {
|
|||||||
|
|
||||||
$('#random').click(function () {
|
$('#random').click(function () {
|
||||||
get_info(function (info) {
|
get_info(function (info) {
|
||||||
|
var filter = "?filter=" + encodeURIComponent(`creator == 'users/${info.userid}'`);
|
||||||
if (info.status) {
|
if (info.status) {
|
||||||
$("#randomlist").html('').hide()
|
$("#randomlist").html('').hide()
|
||||||
var nowTag = $("textarea[name=text]").val().match(/#([^\s#]+)/)
|
var randomUrl = info.apiUrl + 'api/v1/memos' + filter;
|
||||||
if( $("#taglist").is(':visible') && nowTag[1]){
|
|
||||||
var tagUrl = info.apiUrl+'api/v1/memo?rowStatus=NORMAL&tag='+nowTag[1]
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url:tagUrl,
|
url:randomUrl,
|
||||||
type:"GET",
|
type:"GET",
|
||||||
contentType:"application/json;",
|
contentType:"application/json;",
|
||||||
dataType:"json",
|
dataType:"json",
|
||||||
headers : {'Authorization':'Bearer ' + info.apiTokens},
|
headers : {'Authorization':'Bearer ' + info.apiTokens},
|
||||||
success: function(data){
|
success: function(data){
|
||||||
let randomNum = Math.floor(Math.random() * (data.length));
|
let randomNum = Math.floor(Math.random() * (data.memos.length));
|
||||||
var randomData = data[randomNum]
|
var randomData = data.memos[randomNum]
|
||||||
randDom(randomData)
|
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)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$.message({
|
$.message({
|
||||||
message: chrome.i18n.getMessage("placeApiUrl")
|
message: chrome.i18n.getMessage("placeApiUrl")
|
||||||
@@ -447,24 +442,24 @@ $('#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+'"><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>'
|
var randomDom = '<div class="random-item"><div class="random-time"><span id="random-link" data-uid="'+randomData.uid+'"><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-uid="'+randomData.uid+'" data-name="'+randomData.name+'"><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(randomData.createTime).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.resources && randomData.resources.length > 0){
|
||||||
var resourceList = randomData.resourceList;
|
var resources = randomData.resources;
|
||||||
for(var j=0;j < resourceList.length;j++){
|
for(var j=0;j < resources.length;j++){
|
||||||
var restype = resourceList[j].type.slice(0,5);
|
var restype = resources[j].type.slice(0,5);
|
||||||
var resexlink = resourceList[j].externalLink
|
var resexlink = resources[j].externalLink
|
||||||
var resLink = '',fileId=''
|
var resLink = '',fileId=''
|
||||||
if(resexlink){
|
if(resexlink){
|
||||||
resLink = resexlink
|
resLink = resexlink
|
||||||
}else{
|
}else{
|
||||||
fileId = resourceList[j].publicId || resourceList[j].filename
|
fileId = resources[j].publicId || resources[j].filename
|
||||||
resLink = info.apiUrl+'o/r/'+resourceList[j].id+'/'+fileId
|
resLink = info.apiUrl+'file/'+resources[j].name+'/'+fileId
|
||||||
}
|
}
|
||||||
if(restype == 'image'){
|
if(restype == 'image'){
|
||||||
randomDom += '<img class="random-image" src="'+resLink+'"/>'
|
randomDom += '<img class="random-image" src="'+resLink+'"/>'
|
||||||
}
|
}
|
||||||
if(restype !== 'image'){
|
if(restype !== 'image'){
|
||||||
randomDom += '<a target="_blank" rel="noreferrer" href="'+resLink+'">'+resourceList[j].filename+'</a>'
|
randomDom += '<a target="_blank" rel="noreferrer" href="'+resLink+'">'+resources[j].filename+'</a>'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -475,21 +470,22 @@ function randDom(randomData){
|
|||||||
}
|
}
|
||||||
|
|
||||||
$(document).on("click","#random-link",function () {
|
$(document).on("click","#random-link",function () {
|
||||||
var memoId = $("#random-link").data('id');
|
var memoUid = $("#random-link").data('uid');
|
||||||
get_info(function (info) {
|
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 () {
|
$(document).on("click","#random-delete",function () {
|
||||||
get_info(function (info) {
|
get_info(function (info) {
|
||||||
var memosId = $("#random-delete").data('id');
|
var memoUid = $("#random-delete").data('uid');
|
||||||
var deleteUrl = info.apiUrl+'api/v1/memo/'+memosId
|
var memosName = $("#random-delete").data('name');
|
||||||
|
var deleteUrl = info.apiUrl+'api/v1/'+memosName
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url:deleteUrl,
|
url:deleteUrl,
|
||||||
type:"PATCH",
|
type:"PATCH",
|
||||||
data:JSON.stringify({
|
data:JSON.stringify({
|
||||||
'id': memosId,
|
'uid': memoUid,
|
||||||
'rowStatus': "ARCHIVED"
|
'rowStatus': "ARCHIVED"
|
||||||
}),
|
}),
|
||||||
contentType:"application/json;",
|
contentType:"application/json;",
|
||||||
@@ -579,7 +575,7 @@ function getOne(memosId){
|
|||||||
get_info(function (info) {
|
get_info(function (info) {
|
||||||
if (info.apiUrl) {
|
if (info.apiUrl) {
|
||||||
$("#randomlist").html('').hide()
|
$("#randomlist").html('').hide()
|
||||||
var getUrl = info.apiUrl+'api/v1/memo/'+memosId
|
var getUrl = info.apiUrl+'api/v1/'+memosId
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url:getUrl,
|
url:getUrl,
|
||||||
type:"GET",
|
type:"GET",
|
||||||
@@ -622,15 +618,30 @@ function sendText() {
|
|||||||
type:"POST",
|
type:"POST",
|
||||||
data:JSON.stringify({
|
data:JSON.stringify({
|
||||||
'content': content,
|
'content': content,
|
||||||
'visibility': sendvisi,
|
'visibility': sendvisi
|
||||||
'resourceIdList': info.resourceIdList || [],
|
|
||||||
}),
|
}),
|
||||||
contentType:"application/json;",
|
contentType:"application/json;",
|
||||||
dataType:"json",
|
dataType:"json",
|
||||||
headers : {'Authorization':'Bearer ' + info.apiTokens},
|
headers : {'Authorization':'Bearer ' + info.apiTokens},
|
||||||
success: function(data){
|
success: function(data){
|
||||||
//发送成功
|
if(info.resourceIdList.length > 0 ){
|
||||||
getOne(data.id)
|
//匹配图片
|
||||||
|
$.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(
|
chrome.storage.sync.set(
|
||||||
{ open_action: '', open_content: '',resourceIdList:''},
|
{ open_action: '', open_content: '',resourceIdList:''},
|
||||||
function () {
|
function () {
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "__MSG_extName__",
|
"name": "__MSG_extName__",
|
||||||
"default_locale": "zh_CN",
|
"default_locale": "zh_CN",
|
||||||
"version": "2024.06.15",
|
"version": "2024.07.21",
|
||||||
"action": {
|
"action": {
|
||||||
"default_popup": "popup.html",
|
"default_popup": "popup.html",
|
||||||
"default_icon": "assets/logo_24x24.png",
|
"default_icon": "assets/logo_24x24.png",
|
||||||
|
|||||||
@@ -132,7 +132,6 @@
|
|||||||
<script src="../js/dayjs.min.js"></script>
|
<script src="../js/dayjs.min.js"></script>
|
||||||
<script src="../js/zh-cn.js"></script>
|
<script src="../js/zh-cn.js"></script>
|
||||||
<script src="../js/relativeTime.js"></script>
|
<script src="../js/relativeTime.js"></script>
|
||||||
<script src="../js/fuse.basic.min.js"></script>
|
|
||||||
<script src="../js/view-image.js"></script>
|
<script src="../js/view-image.js"></script>
|
||||||
<script src="../js/oper.js"></script>
|
<script src="../js/oper.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user