abler-api 0.1.54 → 0.1.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -217,7 +217,7 @@ class apiUtil$2 {
217
217
  */
218
218
 
219
219
 
220
- static apiSuccess(data, req) {
220
+ static apiSuccess(data, req, spOrderNum) {
221
221
  let response = {
222
222
  success: true,
223
223
  stateCode: 0,
@@ -225,6 +225,10 @@ class apiUtil$2 {
225
225
  datetime: new Date()
226
226
  };
227
227
 
228
+ if (spOrderNum) {
229
+ response.spOrderNum = spOrderNum;
230
+ }
231
+
228
232
  if (req && req.headers) {
229
233
  let userAgent = req.headers["user-agent"];
230
234
 
@@ -250,11 +254,15 @@ class apiUtil$2 {
250
254
  */
251
255
 
252
256
 
253
- static apiFail(error, req) {
257
+ static apiFail(error, req, spOrderNum) {
254
258
  configNeeded();
255
259
  let response = err$2.ERROR(error, err$2.errorLangParamFlag + ppUtil$4.getMsgLang(req));
256
260
  response.datetime = new Date();
257
261
 
262
+ if (spOrderNum) {
263
+ response.spOrderNum = spOrderNum;
264
+ }
265
+
258
266
  if (req && req.headers) {
259
267
  let userAgent = req.headers["user-agent"];
260
268
 
@@ -1524,6 +1532,28 @@ class apiUtil$2 {
1524
1532
  text = lines.join('\r\n');
1525
1533
  await fs$1.async_writeFile(fileName, text);
1526
1534
  return n;
1535
+ }
1536
+ /**
1537
+ * 创建验证码对象
1538
+ * npm i svg-captcha
1539
+ * npm i svg2png
1540
+ */
1541
+
1542
+
1543
+ static createSvgCaptcha(options) {
1544
+ const captcha = svgCaptcha.create({
1545
+ inverse: options.hasOwnProperty('inverse') ? options.inverse : false,
1546
+ fontSize: options.fontSize || 48,
1547
+ noise: options.noise || 2,
1548
+ width: options.width || 150,
1549
+ height: options.height || 75,
1550
+ size: options.size || 4,
1551
+ charPreset: options.charPreset || '0123456789',
1552
+ ignoreChars: options.ignoreChars || '0oli',
1553
+ color: options.hasOwnProperty('color') ? options.color : true,
1554
+ background: options.background || '#cc9966'
1555
+ });
1556
+ return captcha;
1527
1557
  } //#endregion
1528
1558
 
1529
1559
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "abler-api",
3
- "version": "0.1.54",
3
+ "version": "0.1.56",
4
4
  "description": "API服务相关工具",
5
5
  "main": "./dist/cjs/pp-util.js",
6
6
  "-module": "./dist/es/pp-util.js",