92 lines
2.2 KiB
JavaScript
92 lines
2.2 KiB
JavaScript
import axios from "axios";
|
|
import Jquery from "jquery";
|
|
import {getStoreKey} from "@/api/lock";
|
|
import storage from "@/libs/storage";
|
|
|
|
export function saveNote(noteForm) {
|
|
let storeKey = getStoreKey(noteForm.key);
|
|
let storeText = storage.local.getText(storeKey + '.text');
|
|
let note = {
|
|
"lock": storeText.substring(0, 1),
|
|
"cipher": storeText.substring(2, 34),
|
|
"text": storeText.substring(35+16),
|
|
"key": noteForm.key
|
|
}
|
|
|
|
return axios({
|
|
url: '/note/' + noteForm.key,
|
|
method: 'post',
|
|
data: note
|
|
}
|
|
)
|
|
}
|
|
|
|
export function deleteNote(key) {
|
|
let storeKey = getStoreKey(key);
|
|
let storeText = storage.local.getText(storeKey + '.text');
|
|
let note = {
|
|
"cipher": storeText.substring(2, 34),
|
|
"key": key
|
|
}
|
|
|
|
return axios({
|
|
url: '/note/' + key +'/delete',
|
|
method: 'post',
|
|
data: note
|
|
}
|
|
)
|
|
}
|
|
|
|
// export function getSecretKey(key, password) {
|
|
// console.log("getSecretKey");
|
|
// let secretKey = '';
|
|
// Jquery.ajax({
|
|
// method: 'POST',
|
|
// url: '/note/' + key + "/secretKey",
|
|
// async: false,
|
|
// contentType: 'application/json',
|
|
// dataTeyp: 'json',
|
|
// data: JSON.stringify({'password': password}),
|
|
// success: function (data) {
|
|
// secretKey = data;
|
|
// },
|
|
// error: function () {
|
|
// alert('服务器链接异常 ');
|
|
// },
|
|
// });
|
|
// return secretKey;
|
|
// }
|
|
|
|
|
|
export function getNoteMeta(key) {
|
|
let noteMeta = {};
|
|
Jquery.ajax({
|
|
method: 'GET',
|
|
url: '/note/' + key + "/noteMeta",
|
|
async: false,
|
|
success: function (data) {
|
|
noteMeta = eval(data); //eval("(" + data + ")");
|
|
},
|
|
error: function () {
|
|
noteMeta = null;
|
|
},
|
|
});
|
|
return noteMeta;
|
|
}
|
|
|
|
export function getKeyMeta() {
|
|
let keyMeta = {};
|
|
Jquery.ajax({
|
|
method: 'GET',
|
|
url: '/note/keyMeta',
|
|
async: false,
|
|
success: function (data) {
|
|
keyMeta = eval(data); //eval("(" + data + ")");
|
|
},
|
|
error: function () {
|
|
keyMeta = null;
|
|
},
|
|
});
|
|
return keyMeta;
|
|
}
|