js_ryl_v3 1.0.0
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.
- package/README.md +775 -0
- package/dist/base64Img/index.d.ts +5 -0
- package/dist/base64Img/index.js +50 -0
- package/dist/cookie/index.d.ts +14 -0
- package/dist/cookie/index.js +39 -0
- package/dist/copy/index.d.ts +9 -0
- package/dist/copy/index.js +18 -0
- package/dist/deepCopy/index.d.ts +1 -0
- package/dist/deepCopy/index.js +28 -0
- package/dist/downExcel/index.d.ts +5 -0
- package/dist/downExcel/index.js +43 -0
- package/dist/emoji/index.d.ts +1 -0
- package/dist/emoji/index.js +64 -0
- package/dist/emojiToUnicode/index.d.ts +1 -0
- package/dist/emojiToUnicode/index.js +8 -0
- package/dist/esm/base64Img/index.d.ts +5 -0
- package/dist/esm/base64Img/index.js +47 -0
- package/dist/esm/cookie/index.d.ts +14 -0
- package/dist/esm/cookie/index.js +37 -0
- package/dist/esm/copy/index.d.ts +9 -0
- package/dist/esm/copy/index.js +15 -0
- package/dist/esm/deepCopy/index.d.ts +1 -0
- package/dist/esm/deepCopy/index.js +25 -0
- package/dist/esm/downExcel/index.d.ts +5 -0
- package/dist/esm/downExcel/index.js +7 -0
- package/dist/esm/emoji/index.d.ts +1 -0
- package/dist/esm/emoji/index.js +61 -0
- package/dist/esm/emojiToUnicode/index.d.ts +1 -0
- package/dist/esm/emojiToUnicode/index.js +5 -0
- package/dist/esm/filterTable/index.d.ts +5 -0
- package/dist/esm/filterTable/index.js +21 -0
- package/dist/esm/flyToCart/index.d.ts +5 -0
- package/dist/esm/flyToCart/index.js +47 -0
- package/dist/esm/function/index.d.ts +11 -0
- package/dist/esm/function/index.js +23 -0
- package/dist/esm/getMonthDays/index.d.ts +1 -0
- package/dist/esm/getMonthDays/index.js +4 -0
- package/dist/esm/getParamsUtil/index.d.ts +12 -0
- package/dist/esm/getParamsUtil/index.js +85 -0
- package/dist/esm/highLight/index.d.ts +1 -0
- package/dist/esm/highLight/index.js +7 -0
- package/dist/esm/index.d.ts +17 -0
- package/dist/esm/index.js +17 -0
- package/dist/esm/number/index.d.ts +8 -0
- package/dist/esm/number/index.js +160 -0
- package/dist/esm/reg/index.d.ts +11 -0
- package/dist/esm/reg/index.js +35 -0
- package/dist/esm/time/index.d.ts +8 -0
- package/dist/esm/time/index.js +78 -0
- package/dist/esm/verCode/index.d.ts +6 -0
- package/dist/esm/verCode/index.js +37 -0
- package/dist/filterTable/index.d.ts +5 -0
- package/dist/filterTable/index.js +24 -0
- package/dist/flyToCart/index.d.ts +5 -0
- package/dist/flyToCart/index.js +50 -0
- package/dist/function/index.d.ts +11 -0
- package/dist/function/index.js +25 -0
- package/dist/getMonthDays/index.d.ts +1 -0
- package/dist/getMonthDays/index.js +7 -0
- package/dist/getParamsUtil/index.d.ts +12 -0
- package/dist/getParamsUtil/index.js +87 -0
- package/dist/highLight/index.d.ts +1 -0
- package/dist/highLight/index.js +10 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +40 -0
- package/dist/number/index.d.ts +8 -0
- package/dist/number/index.js +162 -0
- package/dist/reg/index.d.ts +11 -0
- package/dist/reg/index.js +37 -0
- package/dist/time/index.d.ts +8 -0
- package/dist/time/index.js +80 -0
- package/dist/verCode/index.d.ts +6 -0
- package/dist/verCode/index.js +39 -0
- package/package.json +36 -0
- package/src/base64Img/index.ts +66 -0
- package/src/cookie/index.ts +47 -0
- package/src/copy/index.ts +23 -0
- package/src/deepCopy/index.ts +26 -0
- package/src/downExcel/index.ts +16 -0
- package/src/emoji/index.ts +63 -0
- package/src/emojiToUnicode/index.ts +9 -0
- package/src/filterTable/index.ts +33 -0
- package/src/flyToCart/index.ts +67 -0
- package/src/function/index.ts +37 -0
- package/src/getMonthDays/index.ts +4 -0
- package/src/getParamsUtil/index.ts +107 -0
- package/src/highLight/index.ts +10 -0
- package/src/index.ts +17 -0
- package/src/number/index.ts +133 -0
- package/src/reg/index.ts +36 -0
- package/src/time/index.ts +90 -0
- package/src/verCode/index.ts +42 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type ParamType = 'string' | 'number' | 'boolean' | 'object';
|
|
2
|
+
interface ParamsObject {
|
|
3
|
+
[key: string]: string | string[];
|
|
4
|
+
}
|
|
5
|
+
declare const getParamsUtil: {
|
|
6
|
+
getParam<T = any>(name: string, url?: string, defaultValue?: T, type?: ParamType): T;
|
|
7
|
+
getParams(url?: string): ParamsObject;
|
|
8
|
+
buildQueryString(params: Record<string, any>): string;
|
|
9
|
+
joinParams(url: string, params: Record<string, any>): string;
|
|
10
|
+
removeParams(url: string, keys: string | string[]): string;
|
|
11
|
+
};
|
|
12
|
+
export default getParamsUtil;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getParamsUtil = {
|
|
4
|
+
getParam(name, url, defaultValue, type) {
|
|
5
|
+
const params = this.getParams(url);
|
|
6
|
+
let value = params[name];
|
|
7
|
+
if (value === undefined) {
|
|
8
|
+
return defaultValue;
|
|
9
|
+
}
|
|
10
|
+
if (type === 'number') {
|
|
11
|
+
return Number(value);
|
|
12
|
+
}
|
|
13
|
+
else if (type === 'boolean') {
|
|
14
|
+
return (value === 'true' || value === '1');
|
|
15
|
+
}
|
|
16
|
+
else if (type === 'object') {
|
|
17
|
+
try {
|
|
18
|
+
return JSON.parse(String(value));
|
|
19
|
+
}
|
|
20
|
+
catch (e) {
|
|
21
|
+
return defaultValue;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return value;
|
|
25
|
+
},
|
|
26
|
+
getParams(url = window.location.href) {
|
|
27
|
+
const params = {};
|
|
28
|
+
const search = url.split('?')[1];
|
|
29
|
+
if (!search) {
|
|
30
|
+
return params;
|
|
31
|
+
}
|
|
32
|
+
const pairs = search.split('&');
|
|
33
|
+
pairs.forEach(pair => {
|
|
34
|
+
const [key, value] = pair.split('=');
|
|
35
|
+
if (key) {
|
|
36
|
+
const decodedKey = decodeURIComponent(key);
|
|
37
|
+
const decodedValue = value ? decodeURIComponent(value) : '';
|
|
38
|
+
if (params[decodedKey]) {
|
|
39
|
+
if (Array.isArray(params[decodedKey])) {
|
|
40
|
+
params[decodedKey].push(decodedValue);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
params[decodedKey] = [params[decodedKey], decodedValue];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
params[decodedKey] = decodedValue;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
return params;
|
|
52
|
+
},
|
|
53
|
+
buildQueryString(params) {
|
|
54
|
+
const query = [];
|
|
55
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
56
|
+
if (value !== undefined && value !== null) {
|
|
57
|
+
if (Array.isArray(value)) {
|
|
58
|
+
value.forEach(item => {
|
|
59
|
+
query.push(`${encodeURIComponent(key)}=${encodeURIComponent(item)}`);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
query.push(`${encodeURIComponent(key)}=${encodeURIComponent(value)}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
return query.join('&');
|
|
68
|
+
},
|
|
69
|
+
joinParams(url, params) {
|
|
70
|
+
const [baseUrl] = url.split('?');
|
|
71
|
+
const existingParams = this.getParams(url);
|
|
72
|
+
const mergedParams = Object.assign(Object.assign({}, existingParams), params);
|
|
73
|
+
const queryString = this.buildQueryString(mergedParams);
|
|
74
|
+
return queryString ? `${baseUrl}?${queryString}` : baseUrl;
|
|
75
|
+
},
|
|
76
|
+
removeParams(url, keys) {
|
|
77
|
+
const [baseUrl] = url.split('?');
|
|
78
|
+
const params = this.getParams(url);
|
|
79
|
+
const keysArray = Array.isArray(keys) ? keys : [keys];
|
|
80
|
+
keysArray.forEach(key => {
|
|
81
|
+
delete params[key];
|
|
82
|
+
});
|
|
83
|
+
const queryString = this.buildQueryString(params);
|
|
84
|
+
return queryString ? `${baseUrl}?${queryString}` : baseUrl;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
exports.default = getParamsUtil;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function highlight(searchName: string, backText: string, className: string): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = highlight;
|
|
4
|
+
function highlight(searchName, backText, className) {
|
|
5
|
+
if (!searchName)
|
|
6
|
+
return backText;
|
|
7
|
+
const escapedKeyword = searchName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
8
|
+
const regex = new RegExp(`(${escapedKeyword})`, 'gi');
|
|
9
|
+
return backText.replace(regex, `<span class="${className}">$1</span>`);
|
|
10
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export { default as base64Img } from './base64Img';
|
|
2
|
+
export { default as cookie } from './cookie';
|
|
3
|
+
export { default as copy } from './copy';
|
|
4
|
+
export { default as deepCopy } from './deepCopy';
|
|
5
|
+
export { default as downExcel } from './downExcel';
|
|
6
|
+
export { default as emoji } from './emoji';
|
|
7
|
+
export { default as emojiToUnicode } from './emojiToUnicode';
|
|
8
|
+
export { default as filterTable } from './filterTable';
|
|
9
|
+
export { default as flyToCart } from './flyToCart';
|
|
10
|
+
export { default as fun } from './function';
|
|
11
|
+
export { default as getMonthDays } from './getMonthDays';
|
|
12
|
+
export { default as getParamsUtil } from './getParamsUtil';
|
|
13
|
+
export { default as highlight } from './highLight';
|
|
14
|
+
export { default as num } from './number';
|
|
15
|
+
export { default as reg } from './reg';
|
|
16
|
+
export { default as time } from './time';
|
|
17
|
+
export { default as verCode } from './verCode';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.verCode = exports.time = exports.reg = exports.num = exports.highlight = exports.getParamsUtil = exports.getMonthDays = exports.fun = exports.flyToCart = exports.filterTable = exports.emojiToUnicode = exports.emoji = exports.downExcel = exports.deepCopy = exports.copy = exports.cookie = exports.base64Img = void 0;
|
|
7
|
+
var base64Img_1 = require("./base64Img");
|
|
8
|
+
Object.defineProperty(exports, "base64Img", { enumerable: true, get: function () { return __importDefault(base64Img_1).default; } });
|
|
9
|
+
var cookie_1 = require("./cookie");
|
|
10
|
+
Object.defineProperty(exports, "cookie", { enumerable: true, get: function () { return __importDefault(cookie_1).default; } });
|
|
11
|
+
var copy_1 = require("./copy");
|
|
12
|
+
Object.defineProperty(exports, "copy", { enumerable: true, get: function () { return __importDefault(copy_1).default; } });
|
|
13
|
+
var deepCopy_1 = require("./deepCopy");
|
|
14
|
+
Object.defineProperty(exports, "deepCopy", { enumerable: true, get: function () { return __importDefault(deepCopy_1).default; } });
|
|
15
|
+
var downExcel_1 = require("./downExcel");
|
|
16
|
+
Object.defineProperty(exports, "downExcel", { enumerable: true, get: function () { return __importDefault(downExcel_1).default; } });
|
|
17
|
+
var emoji_1 = require("./emoji");
|
|
18
|
+
Object.defineProperty(exports, "emoji", { enumerable: true, get: function () { return __importDefault(emoji_1).default; } });
|
|
19
|
+
var emojiToUnicode_1 = require("./emojiToUnicode");
|
|
20
|
+
Object.defineProperty(exports, "emojiToUnicode", { enumerable: true, get: function () { return __importDefault(emojiToUnicode_1).default; } });
|
|
21
|
+
var filterTable_1 = require("./filterTable");
|
|
22
|
+
Object.defineProperty(exports, "filterTable", { enumerable: true, get: function () { return __importDefault(filterTable_1).default; } });
|
|
23
|
+
var flyToCart_1 = require("./flyToCart");
|
|
24
|
+
Object.defineProperty(exports, "flyToCart", { enumerable: true, get: function () { return __importDefault(flyToCart_1).default; } });
|
|
25
|
+
var function_1 = require("./function");
|
|
26
|
+
Object.defineProperty(exports, "fun", { enumerable: true, get: function () { return __importDefault(function_1).default; } });
|
|
27
|
+
var getMonthDays_1 = require("./getMonthDays");
|
|
28
|
+
Object.defineProperty(exports, "getMonthDays", { enumerable: true, get: function () { return __importDefault(getMonthDays_1).default; } });
|
|
29
|
+
var getParamsUtil_1 = require("./getParamsUtil");
|
|
30
|
+
Object.defineProperty(exports, "getParamsUtil", { enumerable: true, get: function () { return __importDefault(getParamsUtil_1).default; } });
|
|
31
|
+
var highLight_1 = require("./highLight");
|
|
32
|
+
Object.defineProperty(exports, "highlight", { enumerable: true, get: function () { return __importDefault(highLight_1).default; } });
|
|
33
|
+
var number_1 = require("./number");
|
|
34
|
+
Object.defineProperty(exports, "num", { enumerable: true, get: function () { return __importDefault(number_1).default; } });
|
|
35
|
+
var reg_1 = require("./reg");
|
|
36
|
+
Object.defineProperty(exports, "reg", { enumerable: true, get: function () { return __importDefault(reg_1).default; } });
|
|
37
|
+
var time_1 = require("./time");
|
|
38
|
+
Object.defineProperty(exports, "time", { enumerable: true, get: function () { return __importDefault(time_1).default; } });
|
|
39
|
+
var verCode_1 = require("./verCode");
|
|
40
|
+
Object.defineProperty(exports, "verCode", { enumerable: true, get: function () { return __importDefault(verCode_1).default; } });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare const num: {
|
|
2
|
+
NumFilter(v: number): number;
|
|
3
|
+
add(num1: number | string, num2: number | string): number;
|
|
4
|
+
sub(num1: number | string, num2: number | string): number;
|
|
5
|
+
div(num1: number | string, num2: number | string): number;
|
|
6
|
+
mul(num1: number | string, num2: number | string): number;
|
|
7
|
+
};
|
|
8
|
+
export default num;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function countDecimals(num) {
|
|
4
|
+
let len = 0;
|
|
5
|
+
try {
|
|
6
|
+
num = Number(num);
|
|
7
|
+
const str = num.toString().toUpperCase();
|
|
8
|
+
if (str.split('E').length === 2) {
|
|
9
|
+
let isDecimal = false;
|
|
10
|
+
if (str.split('.').length === 2) {
|
|
11
|
+
str.split('.')[1];
|
|
12
|
+
if (parseInt(str.split('E')[0]) !== 0) {
|
|
13
|
+
isDecimal = true;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const x = str.split('E');
|
|
17
|
+
if (isDecimal) {
|
|
18
|
+
len = x[0].length;
|
|
19
|
+
}
|
|
20
|
+
len -= parseInt(x[1]);
|
|
21
|
+
}
|
|
22
|
+
else if (str.split('.').length === 2) {
|
|
23
|
+
if (parseInt(str.split('.')[1]) !== 0) {
|
|
24
|
+
len = str.split('.')[1].length;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
throw e;
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
32
|
+
if (isNaN(len) || len < 0) {
|
|
33
|
+
len = 0;
|
|
34
|
+
}
|
|
35
|
+
return len;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function convertToInt(num) {
|
|
39
|
+
num = Number(num);
|
|
40
|
+
let newNum = num;
|
|
41
|
+
const times = countDecimals(num);
|
|
42
|
+
const temp_num = num.toString().toUpperCase();
|
|
43
|
+
if (temp_num.split('E').length === 2) {
|
|
44
|
+
newNum = Math.round(num * Math.pow(10, times));
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
newNum = Number(temp_num.replace(".", ""));
|
|
48
|
+
}
|
|
49
|
+
return newNum;
|
|
50
|
+
}
|
|
51
|
+
function getCorrectResult(type, num1, num2, result) {
|
|
52
|
+
let temp_result = 0;
|
|
53
|
+
switch (type) {
|
|
54
|
+
case "add":
|
|
55
|
+
temp_result = num1 + num2;
|
|
56
|
+
break;
|
|
57
|
+
case "sub":
|
|
58
|
+
temp_result = num1 - num2;
|
|
59
|
+
break;
|
|
60
|
+
case "div":
|
|
61
|
+
temp_result = num1 / num2;
|
|
62
|
+
break;
|
|
63
|
+
case "mul":
|
|
64
|
+
temp_result = num1 * num2;
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
if (Math.abs(result - temp_result) > 1) {
|
|
68
|
+
return temp_result;
|
|
69
|
+
}
|
|
70
|
+
if (!isLessThanTwoDecimalPlaces(result)) {
|
|
71
|
+
result = Number(result.toFixed(2));
|
|
72
|
+
}
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
function isLessThanTwoDecimalPlaces(num) {
|
|
76
|
+
return Math.floor(num * 100) === num * 100;
|
|
77
|
+
}
|
|
78
|
+
const num = {
|
|
79
|
+
NumFilter(v) {
|
|
80
|
+
const x = String(v).indexOf(".") + 1;
|
|
81
|
+
const y = String(v).length - x;
|
|
82
|
+
if (y > 0 && y >= 3) {
|
|
83
|
+
v = Math.floor(v * 100) / 100;
|
|
84
|
+
}
|
|
85
|
+
return v;
|
|
86
|
+
},
|
|
87
|
+
add(num1, num2) {
|
|
88
|
+
const n1 = this.NumFilter(Number(num1));
|
|
89
|
+
const n2 = this.NumFilter(Number(num2));
|
|
90
|
+
let dec1 = 0, dec2 = 0, times;
|
|
91
|
+
try {
|
|
92
|
+
dec1 = countDecimals(n1) + 1;
|
|
93
|
+
}
|
|
94
|
+
catch (e) {
|
|
95
|
+
dec1 = 0;
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
dec2 = countDecimals(n2) + 1;
|
|
99
|
+
}
|
|
100
|
+
catch (e) {
|
|
101
|
+
dec2 = 0;
|
|
102
|
+
}
|
|
103
|
+
times = Math.pow(10, Math.max(dec1, dec2));
|
|
104
|
+
const result = (this.mul(n1, times) + this.mul(n2, times)) / times;
|
|
105
|
+
return getCorrectResult("add", n1, n2, result);
|
|
106
|
+
},
|
|
107
|
+
sub(num1, num2) {
|
|
108
|
+
const n1 = this.NumFilter(Number(num1));
|
|
109
|
+
const n2 = this.NumFilter(Number(num2));
|
|
110
|
+
let dec1 = 0, dec2 = 0, times;
|
|
111
|
+
try {
|
|
112
|
+
dec1 = countDecimals(n1) + 1;
|
|
113
|
+
}
|
|
114
|
+
catch (e) {
|
|
115
|
+
dec1 = 0;
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
dec2 = countDecimals(n2) + 1;
|
|
119
|
+
}
|
|
120
|
+
catch (e) {
|
|
121
|
+
dec2 = 0;
|
|
122
|
+
}
|
|
123
|
+
times = Math.pow(10, Math.max(dec1, dec2));
|
|
124
|
+
const result = Number((this.mul(n1, times) - this.mul(n2, times)) / times);
|
|
125
|
+
return getCorrectResult("sub", n1, n2, result);
|
|
126
|
+
},
|
|
127
|
+
div(num1, num2) {
|
|
128
|
+
const n1 = Number(num1);
|
|
129
|
+
const n2 = Number(num2);
|
|
130
|
+
let t1 = 0, t2 = 0, dec1, dec2;
|
|
131
|
+
try {
|
|
132
|
+
t1 = countDecimals(n1);
|
|
133
|
+
}
|
|
134
|
+
catch (e) { }
|
|
135
|
+
try {
|
|
136
|
+
t2 = countDecimals(n2);
|
|
137
|
+
}
|
|
138
|
+
catch (e) { }
|
|
139
|
+
dec1 = convertToInt(n1);
|
|
140
|
+
dec2 = convertToInt(n2);
|
|
141
|
+
const result = this.mul((dec1 / dec2), Math.pow(10, t2 - t1));
|
|
142
|
+
return getCorrectResult("div", n1, n2, result);
|
|
143
|
+
},
|
|
144
|
+
mul(num1, num2) {
|
|
145
|
+
const n1 = Number(num1);
|
|
146
|
+
const n2 = Number(num2);
|
|
147
|
+
let times = 0;
|
|
148
|
+
const s1 = n1.toString();
|
|
149
|
+
const s2 = n2.toString();
|
|
150
|
+
try {
|
|
151
|
+
times += countDecimals(n1);
|
|
152
|
+
}
|
|
153
|
+
catch (e) { }
|
|
154
|
+
try {
|
|
155
|
+
times += countDecimals(n2);
|
|
156
|
+
}
|
|
157
|
+
catch (e) { }
|
|
158
|
+
const result = convertToInt(n1) * convertToInt(n2) / Math.pow(10, times);
|
|
159
|
+
return getCorrectResult("mul", n1, n2, result);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
exports.default = num;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare const reg: {
|
|
2
|
+
Phone(value: string): boolean;
|
|
3
|
+
Email(value: string): boolean;
|
|
4
|
+
IdCard(value: string): boolean;
|
|
5
|
+
Common(value: string): boolean;
|
|
6
|
+
QQ(value: string): boolean;
|
|
7
|
+
Money(value: string): boolean;
|
|
8
|
+
imgUrl(value: string): boolean;
|
|
9
|
+
verChinese(value: string): boolean;
|
|
10
|
+
};
|
|
11
|
+
export default reg;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const reg = {
|
|
4
|
+
Phone(value) {
|
|
5
|
+
const regex = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
|
|
6
|
+
return regex.test(value);
|
|
7
|
+
},
|
|
8
|
+
Email(value) {
|
|
9
|
+
const regex = /^([0-9A-Za-z\-_\.]+)@([0-9a-z]+\.[a-z]{2,3}(\.[a-z]{2})?)$/g;
|
|
10
|
+
return regex.test(value);
|
|
11
|
+
},
|
|
12
|
+
IdCard(value) {
|
|
13
|
+
const regex = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
|
|
14
|
+
return regex.test(value);
|
|
15
|
+
},
|
|
16
|
+
Common(value) {
|
|
17
|
+
const regex = /^[a-zA-Z0-9_]+$/;
|
|
18
|
+
return regex.test(value);
|
|
19
|
+
},
|
|
20
|
+
QQ(value) {
|
|
21
|
+
const regex = /^[1-9][0-9]{4,10}$/gim;
|
|
22
|
+
return regex.test(value);
|
|
23
|
+
},
|
|
24
|
+
Money(value) {
|
|
25
|
+
const regex = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
|
|
26
|
+
return regex.test(value);
|
|
27
|
+
},
|
|
28
|
+
imgUrl(value) {
|
|
29
|
+
const regex = /^\s*data:([a-z]+\/[a-z0-9-+.]+(;[a-z-]+=[a-z0-9-]+)?)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s]*?)\s*$/i;
|
|
30
|
+
return regex.test(value);
|
|
31
|
+
},
|
|
32
|
+
verChinese(value) {
|
|
33
|
+
const regex = /[\u4e00-\u9fa5]/;
|
|
34
|
+
return regex.test(value);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
exports.default = reg;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type DateFormatType = 'yyyy-MM-dd' | 'yyyy-MM-dd HH:mm' | 'yyyy-MM-dd HH:mm:ss';
|
|
2
|
+
declare const time: {
|
|
3
|
+
toDate(v: number | string, type?: DateFormatType): string;
|
|
4
|
+
toStamp(v?: Date | string, len?: number): number;
|
|
5
|
+
getNow(): string;
|
|
6
|
+
timestampFormat(timestamp: number | string): string;
|
|
7
|
+
};
|
|
8
|
+
export default time;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function add0(m) {
|
|
4
|
+
return m < 10 ? '0' + m : String(m);
|
|
5
|
+
}
|
|
6
|
+
const time = {
|
|
7
|
+
toDate(v, type) {
|
|
8
|
+
let date;
|
|
9
|
+
if (String(v).length === 10) {
|
|
10
|
+
date = new Date(Number(v) * 1000);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
date = new Date(v);
|
|
14
|
+
}
|
|
15
|
+
const Y = date.getFullYear();
|
|
16
|
+
const M = date.getMonth() + 1;
|
|
17
|
+
const D = date.getDate();
|
|
18
|
+
const h = date.getHours();
|
|
19
|
+
const m = date.getMinutes();
|
|
20
|
+
const s = date.getSeconds();
|
|
21
|
+
let tim = '';
|
|
22
|
+
if (type === 'yyyy-MM-dd') {
|
|
23
|
+
tim = `${Y}-${add0(M)}-${add0(D)}`;
|
|
24
|
+
}
|
|
25
|
+
else if (type === 'yyyy-MM-dd HH:mm') {
|
|
26
|
+
tim = `${Y}-${add0(M)}-${add0(D)} ${add0(h)}:${add0(m)}`;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
tim = `${Y}-${add0(M)}-${add0(D)} ${add0(h)}:${add0(m)}:${add0(s)}`;
|
|
30
|
+
}
|
|
31
|
+
return tim;
|
|
32
|
+
},
|
|
33
|
+
toStamp(v = new Date(), len = 10) {
|
|
34
|
+
const tmp = new Date(String(v).replace(/-/g, '/')).getTime().toString();
|
|
35
|
+
if (len === 10) {
|
|
36
|
+
return parseInt(tmp.substr(0, 10));
|
|
37
|
+
}
|
|
38
|
+
return parseInt(tmp);
|
|
39
|
+
},
|
|
40
|
+
getNow() {
|
|
41
|
+
const ts = new Date().getTime();
|
|
42
|
+
return this.toDate(ts);
|
|
43
|
+
},
|
|
44
|
+
timestampFormat(timestamp) {
|
|
45
|
+
if (String(timestamp).length === 10) {
|
|
46
|
+
timestamp = Number(timestamp) * 1000;
|
|
47
|
+
}
|
|
48
|
+
function zeroize(num) {
|
|
49
|
+
return (String(num).length === 1 ? "0" : "") + num;
|
|
50
|
+
}
|
|
51
|
+
const curTimestamp = parseInt(String(new Date().getTime() / 1000));
|
|
52
|
+
const curDate = new Date(curTimestamp * 1000);
|
|
53
|
+
const tmDate = new Date(Number(timestamp));
|
|
54
|
+
const Y = tmDate.getFullYear();
|
|
55
|
+
const m = tmDate.getMonth() + 1;
|
|
56
|
+
const d = tmDate.getDate();
|
|
57
|
+
const H = tmDate.getHours();
|
|
58
|
+
const i = tmDate.getMinutes();
|
|
59
|
+
if (curDate.getFullYear() === Y &&
|
|
60
|
+
curDate.getMonth() + 1 === m &&
|
|
61
|
+
curDate.getDate() === d) {
|
|
62
|
+
return zeroize(H) + ":" + zeroize(i);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
const newDate = new Date((curTimestamp - 86400) * 1000);
|
|
66
|
+
if (newDate.getFullYear() === Y &&
|
|
67
|
+
newDate.getMonth() + 1 === m &&
|
|
68
|
+
newDate.getDate() === d) {
|
|
69
|
+
return "昨天 " + zeroize(H) + ":" + zeroize(i);
|
|
70
|
+
}
|
|
71
|
+
else if (curDate.getFullYear() === Y) {
|
|
72
|
+
return zeroize(m) + "/" + zeroize(d) + " " + zeroize(H) + ":" + zeroize(i);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
return Y + "/" + zeroize(m) + "/" + zeroize(d) + " " + zeroize(H) + ":" + zeroize(i);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
exports.default = time;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
let phoneCodeStatus = false;
|
|
4
|
+
let phoneCodeTimer = null;
|
|
5
|
+
let phoneCodeName = '';
|
|
6
|
+
let phoneCodeSelf = null;
|
|
7
|
+
const verCode = {
|
|
8
|
+
PhoneCode(e, ss = 60, cc = '后重新获取') {
|
|
9
|
+
phoneCodeName = e.target.innerText;
|
|
10
|
+
phoneCodeSelf = e;
|
|
11
|
+
if (!phoneCodeStatus) {
|
|
12
|
+
phoneCodeStatus = true;
|
|
13
|
+
e.target.innerText = `${ss - 1}s${cc}`;
|
|
14
|
+
let timer = ss - 1;
|
|
15
|
+
phoneCodeTimer = setInterval(() => {
|
|
16
|
+
timer--;
|
|
17
|
+
if (timer <= 0) {
|
|
18
|
+
e.target.innerText = phoneCodeName;
|
|
19
|
+
this.PhoneCodeClear();
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
e.target.innerText = `${timer}s${cc}`;
|
|
23
|
+
}
|
|
24
|
+
}, 1000);
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
PhoneCodeClear() {
|
|
28
|
+
phoneCodeStatus = false;
|
|
29
|
+
if (phoneCodeSelf) {
|
|
30
|
+
phoneCodeSelf.target.innerText = phoneCodeName;
|
|
31
|
+
}
|
|
32
|
+
if (phoneCodeTimer) {
|
|
33
|
+
clearInterval(phoneCodeTimer);
|
|
34
|
+
phoneCodeTimer = null;
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
phoneCodeStatus: () => phoneCodeStatus
|
|
38
|
+
};
|
|
39
|
+
exports.default = verCode;
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "js_ryl_v3",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "常用JavaScript工具函数集合,包含日期处理、数字运算、正则验证、Cookie操作等",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"module": "dist/esm/index.js",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"src"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"dev": "vite",
|
|
14
|
+
"build": "tsc && npm run build:esm",
|
|
15
|
+
"build:esm": "tsc --module ES6 --outDir dist/esm",
|
|
16
|
+
"clean": "rd /s /q dist 2>nul || rm -rf dist",
|
|
17
|
+
"prepublishOnly": "npm run build"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"utils",
|
|
21
|
+
"javascript",
|
|
22
|
+
"typescript",
|
|
23
|
+
"tools",
|
|
24
|
+
"common"
|
|
25
|
+
],
|
|
26
|
+
"author": "",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "^20.0.0",
|
|
30
|
+
"typescript": "^5.0.0",
|
|
31
|
+
"vite": "^8.1.0"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"xlsx": "^0.18.5"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
interface Base64Replacement {
|
|
2
|
+
original: string;
|
|
3
|
+
base64: string;
|
|
4
|
+
url?: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
interface Base64ImgCallback {
|
|
8
|
+
(original: string, error: string | Error): void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default function base64Img(
|
|
12
|
+
content: string,
|
|
13
|
+
apiUrl: string,
|
|
14
|
+
token: string,
|
|
15
|
+
data?: Record<string, any>,
|
|
16
|
+
callback: Base64ImgCallback = () => {}
|
|
17
|
+
): Promise<string> {
|
|
18
|
+
const base64Regex = /<img [^>]*src=['"](data:image[^'"]+base64,[^'"]+)['"][^>]*>/gi;
|
|
19
|
+
let match: RegExpExecArray | null;
|
|
20
|
+
const replacements: Base64ImgCallback[] = [];
|
|
21
|
+
|
|
22
|
+
while ((match = base64Regex.exec(content)) !== null) {
|
|
23
|
+
replacements.push({
|
|
24
|
+
original: match[1],
|
|
25
|
+
base64: match[1]
|
|
26
|
+
} as any);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (replacements.length > 0) {
|
|
30
|
+
const uploadPromises = replacements.map((replacement: any) => {
|
|
31
|
+
return fetch(apiUrl, {
|
|
32
|
+
method: "POST",
|
|
33
|
+
headers: {
|
|
34
|
+
"Authorization": "Bearer " + token,
|
|
35
|
+
"Content-Type": "application/json"
|
|
36
|
+
},
|
|
37
|
+
body: JSON.stringify({ image: replacement.base64, ...data })
|
|
38
|
+
})
|
|
39
|
+
.then(res => res.json())
|
|
40
|
+
.then(result => {
|
|
41
|
+
if (result.code === 200) {
|
|
42
|
+
replacement.url = result.data.url;
|
|
43
|
+
} else {
|
|
44
|
+
callback(replacement.original, result.msg);
|
|
45
|
+
}
|
|
46
|
+
return replacement;
|
|
47
|
+
})
|
|
48
|
+
.catch(error => {
|
|
49
|
+
callback(replacement.original, error);
|
|
50
|
+
return replacement;
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
return Promise.all(uploadPromises)
|
|
55
|
+
.then(results => {
|
|
56
|
+
results.forEach((result: any) => {
|
|
57
|
+
if (result.url) {
|
|
58
|
+
content = content.replace(result.original, result.url);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
return content;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return Promise.resolve(content);
|
|
66
|
+
}
|