Skip to content

Commit 6a9ff15

Browse files
committed
- 优化:更新axios版本
1 parent 7ca315c commit 6a9ff15

35 files changed

+335
-1569
lines changed

dist/Bark.js

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,22 @@
11
'use strict';
22

33
var _defineProperty = require("@babel/runtime/helpers/defineProperty");
4-
54
var _classPrivateFieldGet = require("@babel/runtime/helpers/classPrivateFieldGet");
6-
75
var _classPrivateFieldSet = require("@babel/runtime/helpers/classPrivateFieldSet");
8-
96
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
10-
117
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
12-
138
Object.defineProperty(exports, '__esModule', {
149
value: true
1510
});
16-
1711
var axios = require('axios');
18-
1912
var tool = require('./tool');
20-
2113
function _interopDefaultLegacy(e) {
2214
return e && typeof e === 'object' && 'default' in e ? e : {
2315
'default': e
2416
};
2517
}
26-
2718
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
28-
2919
var _baseURL = /*#__PURE__*/new WeakMap();
30-
3120
class Bark {
3221
constructor({
3322
token,
@@ -36,35 +25,27 @@ class Bark {
3625
proxy
3726
}) {
3827
_defineProperty(this, "_KEY", void 0);
39-
4028
_classPrivateFieldInitSpec(this, _baseURL, {
4129
writable: true,
4230
value: 'https://api.day.app/push'
4331
});
44-
4532
_defineProperty(this, "httpsAgent", void 0);
46-
4733
const $key = {
4834
token,
4935
baseURL,
5036
...key
5137
};
52-
5338
if (!$key.token) {
5439
throw new Error('Missing Parameter: token');
5540
}
56-
5741
this._KEY = $key.token;
58-
5942
if ($key.baseURL) {
6043
_classPrivateFieldSet(this, _baseURL, $key.baseURL);
6144
}
62-
6345
if (proxy && proxy.enable) {
6446
this.httpsAgent = tool.proxy2httpsAgent(proxy);
6547
}
6648
}
67-
6849
async send(sendOptions) {
6950
if (!sendOptions.message && !sendOptions.customOptions) {
7051
return {
@@ -73,9 +54,7 @@ class Bark {
7354
extraMessage: null
7455
};
7556
}
76-
7757
let barkOptions;
78-
7958
if (sendOptions.customOptions) {
8059
barkOptions = sendOptions.customOptions;
8160
} else {
@@ -84,17 +63,15 @@ class Bark {
8463
body: sendOptions.message
8564
};
8665
}
87-
8866
if (sendOptions.extraOptions) {
89-
barkOptions = { ...barkOptions,
67+
barkOptions = {
68+
...barkOptions,
9069
...sendOptions.extraOptions
9170
};
9271
}
93-
9472
if (!barkOptions.device_key) {
9573
barkOptions.device_key = this._KEY;
9674
}
97-
9875
const axiosOptions = {
9976
url: _classPrivateFieldGet(this, _baseURL),
10077
method: 'POST',
@@ -103,11 +80,9 @@ class Bark {
10380
},
10481
data: barkOptions
10582
};
106-
10783
if (this.httpsAgent) {
10884
axiosOptions.httpsAgent = this.httpsAgent;
10985
}
110-
11186
return axios__default["default"](axiosOptions).then(response => {
11287
if (response.data) {
11388
if (response.data.code === 200) {
@@ -117,14 +92,12 @@ class Bark {
11792
extraMessage: response
11893
};
11994
}
120-
12195
return {
12296
status: 100,
12397
statusText: 'Error',
12498
extraMessage: response
12599
};
126100
}
127-
128101
return {
129102
status: 101,
130103
statusText: 'No Response Data',
@@ -136,7 +109,5 @@ class Bark {
136109
extraMessage: error
137110
}));
138111
}
139-
140112
}
141-
142113
exports.Bark = Bark;

dist/Chanify.js

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,22 @@
11
'use strict';
22

33
var _defineProperty = require("@babel/runtime/helpers/defineProperty");
4-
54
var _classPrivateFieldGet = require("@babel/runtime/helpers/classPrivateFieldGet");
6-
75
var _classPrivateFieldSet = require("@babel/runtime/helpers/classPrivateFieldSet");
8-
96
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
10-
117
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
12-
138
Object.defineProperty(exports, '__esModule', {
149
value: true
1510
});
16-
1711
var axios = require('axios');
18-
1912
var tool = require('./tool');
20-
2113
function _interopDefaultLegacy(e) {
2214
return e && typeof e === 'object' && 'default' in e ? e : {
2315
'default': e
2416
};
2517
}
26-
2718
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
28-
2919
var _baseURL = /*#__PURE__*/new WeakMap();
30-
3120
class Chanify {
3221
constructor({
3322
token,
@@ -36,35 +25,27 @@ class Chanify {
3625
proxy
3726
}) {
3827
_defineProperty(this, "_KEY", void 0);
39-
4028
_classPrivateFieldInitSpec(this, _baseURL, {
4129
writable: true,
4230
value: 'https://api.chanify.net/v1/sender/'
4331
});
44-
4532
_defineProperty(this, "httpsAgent", void 0);
46-
4733
const $key = {
4834
token,
4935
baseURL,
5036
...key
5137
};
52-
5338
if (!$key.token) {
5439
throw new Error('Missing Parameter: token');
5540
}
56-
5741
this._KEY = $key.token;
58-
5942
if ($key.baseURL) {
6043
_classPrivateFieldSet(this, _baseURL, $key.baseURL);
6144
}
62-
6345
if (proxy && proxy.enable) {
6446
this.httpsAgent = tool.proxy2httpsAgent(proxy);
6547
}
6648
}
67-
6849
async send(sendOptions) {
6950
if (!sendOptions.message && !sendOptions.customOptions) {
7051
return {
@@ -73,9 +54,7 @@ class Chanify {
7354
extraMessage: null
7455
};
7556
}
76-
7757
let chanifyOptions;
78-
7958
if (sendOptions.customOptions) {
8059
chanifyOptions = sendOptions.customOptions;
8160
} else {
@@ -84,13 +63,12 @@ class Chanify {
8463
text: sendOptions.message
8564
};
8665
}
87-
8866
if (sendOptions.extraOptions) {
89-
chanifyOptions = { ...chanifyOptions,
67+
chanifyOptions = {
68+
...chanifyOptions,
9069
...sendOptions.extraOptions
9170
};
9271
}
93-
9472
const axiosOptions = {
9573
url: `${_classPrivateFieldGet(this, _baseURL)}${this._KEY}`,
9674
method: 'POST',
@@ -99,11 +77,9 @@ class Chanify {
9977
},
10078
data: tool.queryStringify(chanifyOptions)
10179
};
102-
10380
if (this.httpsAgent) {
10481
axiosOptions.httpsAgent = this.httpsAgent;
10582
}
106-
10783
return axios__default["default"](axiosOptions).then(response => {
10884
if (response.status === 200) {
10985
return {
@@ -112,7 +88,6 @@ class Chanify {
11288
extraMessage: response
11389
};
11490
}
115-
11691
return {
11792
status: 100,
11893
statusText: 'Error',
@@ -124,7 +99,5 @@ class Chanify {
12499
extraMessage: error
125100
}));
126101
}
127-
128102
}
129-
130103
exports.Chanify = Chanify;

0 commit comments

Comments
 (0)