@wzyjs/utils 0.0.18 → 0.0.21

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.
@@ -1,8 +1,11 @@
1
1
  import { KeyValue, OrderParams, Pagination, SortParams } from '../types';
2
2
  export declare const handleParams: (params?: Pagination & KeyValue, sort?: SortParams) => {
3
- page: Pagination;
3
+ page: {
4
+ size?: number | undefined;
5
+ current?: number | undefined;
6
+ };
4
7
  where: KeyValue<string, string | number | boolean | RegExp>;
5
- order?: OrderParams;
8
+ order?: OrderParams<string> | undefined;
6
9
  };
7
10
  export declare const handleRes2List: <D>(reqPromise: any) => Promise<{
8
11
  label: string;
@@ -14,7 +14,7 @@ const handleParams = (params, sort) => {
14
14
  return {
15
15
  page: {
16
16
  current: current || 1,
17
- pageSize: pageSize || 10,
17
+ size: pageSize || 10,
18
18
  },
19
19
  where: Object.entries(other).reduce((acc, [key, value]) => {
20
20
  if (key && value) {
@@ -1,3 +1,3 @@
1
- export * from './common';
2
- export * from './fe';
3
- export * from './rd';
1
+ export * from './common';
2
+ export * from './fe';
3
+ export * from './rd';
@@ -0,0 +1,2 @@
1
+ export * from './common';
2
+ export * from './fe';
@@ -7,7 +7,8 @@ var object = require('./common/tools/object.js');
7
7
  var other = require('./common/tools/other.js');
8
8
  var number = require('./common/tools/number.js');
9
9
  var Database = require('./rd/database/Database.js');
10
- var jsonFile = require('./rd/jsonFile.js');
10
+ var index = require('./rd/jsonFile/index.js');
11
+ var index$1 = require('./rd/mail/index.js');
11
12
 
12
13
  function _interopNamespaceDefault(e) {
13
14
  var n = Object.create(null);
@@ -132,4 +133,5 @@ exports.getFileSize = number.getFileSize;
132
133
  exports.getRandomNum = number.getRandomNum;
133
134
  exports.limitDecimals = number.limitDecimals;
134
135
  exports.Database = Database.Database;
135
- exports.JsonFile = jsonFile.JsonFile;
136
+ exports.JsonFile = index.JsonFile;
137
+ exports.sendMail = index$1.sendMail;
@@ -1,2 +1,3 @@
1
1
  export * from './database';
2
2
  export * from './jsonFile';
3
+ export * from './mail';
@@ -0,0 +1,6 @@
1
+ export declare class JsonFile {
2
+ filePath: string;
3
+ constructor(filePath: string);
4
+ get(key: string): Promise<unknown>;
5
+ set(key: string, value: string): void;
6
+ }
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ // 实现一个文件系统读写数据库
6
+ class JsonFile {
7
+ filePath;
8
+ constructor(filePath) {
9
+ this.filePath = path.resolve(__dirname, filePath);
10
+ }
11
+ get(key) {
12
+ return new Promise((resolve) => {
13
+ fs.readFile(this.filePath, (err, data) => {
14
+ const json = data ? JSON.parse(data) : {};
15
+ resolve(json[key]);
16
+ });
17
+ });
18
+ }
19
+ set(key, value) {
20
+ fs.readFile(this.filePath, { encoding: 'utf-8' }, (err, data) => {
21
+ const json = data ? JSON.parse(data || '{}') : {};
22
+ json[key] = value;
23
+ fs.writeFile(this.filePath, JSON.stringify(json), () => {
24
+ });
25
+ });
26
+ }
27
+ }
28
+
29
+ exports.JsonFile = JsonFile;
@@ -0,0 +1 @@
1
+ export declare const sendMail: (title: string, content: string) => Promise<string>;
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+
3
+ var nodemailer = require('nodemailer');
4
+
5
+ const fromEmail = '15835196981@163.com';
6
+ const fromPass = 'REGDSGDETFECIGKE';
7
+ const toEmail = '657189555@qq.com';
8
+ const transporter = nodemailer.createTransport({
9
+ host: 'smtp.163.com',
10
+ port: 465,
11
+ secure: true,
12
+ auth: {
13
+ user: fromEmail,
14
+ pass: fromPass
15
+ }
16
+ });
17
+ const sendMail = async (title, content) => {
18
+ try {
19
+ await transporter.sendMail({
20
+ from: fromEmail,
21
+ to: toEmail,
22
+ subject: title,
23
+ text: content // 邮件正文
24
+ });
25
+ return title + ' 邮件通知成功';
26
+ }
27
+ catch (error) {
28
+ return title + '邮件通知失败' + JSON.stringify(error);
29
+ }
30
+ };
31
+
32
+ exports.sendMail = sendMail;
@@ -1,8 +1,11 @@
1
1
  import { KeyValue, OrderParams, Pagination, SortParams } from '../types';
2
2
  export declare const handleParams: (params?: Pagination & KeyValue, sort?: SortParams) => {
3
- page: Pagination;
3
+ page: {
4
+ size?: number | undefined;
5
+ current?: number | undefined;
6
+ };
4
7
  where: KeyValue<string, string | number | boolean | RegExp>;
5
- order?: OrderParams;
8
+ order?: OrderParams<string> | undefined;
6
9
  };
7
10
  export declare const handleRes2List: <D>(reqPromise: any) => Promise<{
8
11
  label: string;
@@ -12,7 +12,7 @@ const handleParams = (params, sort) => {
12
12
  return {
13
13
  page: {
14
14
  current: current || 1,
15
- pageSize: pageSize || 10,
15
+ size: pageSize || 10,
16
16
  },
17
17
  where: Object.entries(other).reduce((acc, [key, value]) => {
18
18
  if (key && value) {
@@ -1,3 +1,3 @@
1
- export * from './common';
2
- export * from './fe';
3
- export * from './rd';
1
+ export * from './common';
2
+ export * from './fe';
3
+ export * from './rd';
@@ -0,0 +1,2 @@
1
+ export * from './common';
2
+ export * from './fe';
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@wzyjs/utils",
3
- "version": "0.0.18",
3
+ "version": "0.0.21",
4
4
  "description": "description",
5
5
  "author": "wzy",
6
6
  "license": "ISC",
7
- "main": "dist/cjs/index_c.js",
8
- "module": "dist/esm/index.js",
9
- "typings": "dist/esm/index.d.ts",
7
+ "main": "dist/cjs/index_rd.js",
8
+ "module": "dist/esm/index_fe.js",
9
+ "typings": "dist/esm/index_all.d.ts",
10
10
  "scripts": {
11
11
  "dev": "rollup -c -w --bundleConfigAsCjs",
12
12
  "build": "rollup -c --bundleConfigAsCjs"
@@ -17,6 +17,7 @@
17
17
  "dependencies": {
18
18
  "@cloudbase/node-sdk": "^2.9.1",
19
19
  "@types/animejs": "^3.1.6",
20
+ "@types/nodemailer": "^6.4.7",
20
21
  "animejs": "^3.2.1",
21
22
  "classnames": "^2.3.2",
22
23
  "consola": "^2.15.3",
@@ -25,6 +26,7 @@
25
26
  "localforage": "^1.10.0",
26
27
  "lodash": "^4.17.21",
27
28
  "md5": "^2.3.0",
29
+ "nodemailer": "^6.9.1",
28
30
  "tslib": "^2.4.1"
29
31
  },
30
32
  "devDependencies": {
@@ -44,5 +46,5 @@
44
46
  "type": "git",
45
47
  "url": "https://gitee.com/wang-zhenyu/app.git"
46
48
  },
47
- "gitHead": "7ebb80ef50a4df3d262a1da82d7967e628698b10"
49
+ "gitHead": "e9f0222770f1a8a3b3365e9fadd8f65a069a3ef5"
48
50
  }
File without changes
File without changes
File without changes