mirror of
https://github.com/Jonnyan404/memos-bber.git
synced 2026-04-25 03:58:37 +09:00
memo
This commit is contained in:
+54
-6
@@ -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 += '<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){
|
||||
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 = '<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){
|
||||
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 () {
|
||||
|
||||
Reference in New Issue
Block a user