-
Notifications
You must be signed in to change notification settings - Fork 2
/
preload.js
75 lines (73 loc) · 1.93 KB
/
preload.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
'use strict';
const { utools } = window;
const axios = require('axios');
window.exports = {
'setapi': {
mode: 'list',
args: {
enter: () => {
utools.subInputFocus();
},
search: (action, searchWord, callbackSetList) => {
callbackSetList([
{
title: '确定',
description: '设置 Flomo API',
icon: 'icons/setapi.png',
urlWithToken: searchWord,
}
]);
},
select: (action, itemData, callbackSetList) => {
const api = utools.db.get('api');
const data = {
_id: 'api',
urlWithToken: itemData.urlWithToken,
};
if (api) {
data._rev = api._rev;
}
utools.db.put(data);
utools.hideMainWindow();
utools.showNotification('设置专属记录 API 成功!');
utools.outPlugin();
},
placeholder: "输入"
}
},
'sendto_by_text': {
mode: 'none',
args: {
enter: (action, callbackSetList) => {
utools.hideMainWindow();
const api = utools.db.get('api');
if (api) {
const { payload } = action;
axios.post(api.urlWithToken, {
content: payload,
})
.then(function (response) {
if (response.data && response.data.code === -1) {
utools.showNotification('发送失败!请检查API是否正确?');
} else {
utools.showNotification('发送成功!');
}
})
.catch(function (error) {
utools.showNotification('未知错误!');
});
} else {
utools.showNotification('请先设置专属记录 API!');
}
utools.outPlugin();
},
}
},
// 'sendto_by_img': {
// mode: 'none',
// args: {
// enter: (action, callbackSetList) => {},
// select: (action, itemData) => {}
// }
// }
}