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,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = base64Img;
|
|
4
|
+
function base64Img(content, apiUrl, token, data, callback = () => { }) {
|
|
5
|
+
const base64Regex = /<img [^>]*src=['"](data:image[^'"]+base64,[^'"]+)['"][^>]*>/gi;
|
|
6
|
+
let match;
|
|
7
|
+
const replacements = [];
|
|
8
|
+
while ((match = base64Regex.exec(content)) !== null) {
|
|
9
|
+
replacements.push({
|
|
10
|
+
original: match[1],
|
|
11
|
+
base64: match[1]
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
if (replacements.length > 0) {
|
|
15
|
+
const uploadPromises = replacements.map((replacement) => {
|
|
16
|
+
return fetch(apiUrl, {
|
|
17
|
+
method: "POST",
|
|
18
|
+
headers: {
|
|
19
|
+
"Authorization": "Bearer " + token,
|
|
20
|
+
"Content-Type": "application/json"
|
|
21
|
+
},
|
|
22
|
+
body: JSON.stringify(Object.assign({ image: replacement.base64 }, data))
|
|
23
|
+
})
|
|
24
|
+
.then(res => res.json())
|
|
25
|
+
.then(result => {
|
|
26
|
+
if (result.code === 200) {
|
|
27
|
+
replacement.url = result.data.url;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
callback(replacement.original, result.msg);
|
|
31
|
+
}
|
|
32
|
+
return replacement;
|
|
33
|
+
})
|
|
34
|
+
.catch(error => {
|
|
35
|
+
callback(replacement.original, error);
|
|
36
|
+
return replacement;
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
return Promise.all(uploadPromises)
|
|
40
|
+
.then(results => {
|
|
41
|
+
results.forEach((result) => {
|
|
42
|
+
if (result.url) {
|
|
43
|
+
content = content.replace(result.original, result.url);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return content;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return Promise.resolve(content);
|
|
50
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface CookieOptions {
|
|
2
|
+
path?: string;
|
|
3
|
+
domain?: string;
|
|
4
|
+
expires?: number | Date;
|
|
5
|
+
}
|
|
6
|
+
interface CookieSetOptions extends CookieOptions {
|
|
7
|
+
domain?: 'domain' | string;
|
|
8
|
+
}
|
|
9
|
+
declare const cookie: {
|
|
10
|
+
set: (key: string, val: string, ops?: CookieSetOptions) => void;
|
|
11
|
+
get: (name: string) => string | null;
|
|
12
|
+
remove: (key: string, ops?: CookieOptions) => void;
|
|
13
|
+
};
|
|
14
|
+
export default cookie;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const cookie = {
|
|
4
|
+
set: (key, val, ops) => {
|
|
5
|
+
ops = ops || {};
|
|
6
|
+
let path = ops.path ? ";Path=" + ops.path : "";
|
|
7
|
+
let domain = '';
|
|
8
|
+
if (ops.domain && ops.domain === 'domain') {
|
|
9
|
+
const hostname = window.location.hostname;
|
|
10
|
+
const parts = hostname.split('.');
|
|
11
|
+
const set_domain = parts.slice(-2).join('.');
|
|
12
|
+
domain = ";domain=" + set_domain;
|
|
13
|
+
}
|
|
14
|
+
let expires = "";
|
|
15
|
+
if (ops.expires) {
|
|
16
|
+
const exp = String(ops.expires).length === 10
|
|
17
|
+
? new Date(Number(ops.expires) * 1000)
|
|
18
|
+
: new Date(ops.expires);
|
|
19
|
+
expires = ";expires=" + exp.toUTCString();
|
|
20
|
+
}
|
|
21
|
+
document.cookie = `${key}=${encodeURIComponent(val)}${domain}${path}${expires}`;
|
|
22
|
+
},
|
|
23
|
+
get: (name) => {
|
|
24
|
+
const value = `; ${document.cookie}`;
|
|
25
|
+
const parts = value.split(`; ${name}=`);
|
|
26
|
+
if (parts.length === 2) {
|
|
27
|
+
return decodeURIComponent(parts.pop().split(';').shift());
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
remove: (key, ops) => {
|
|
34
|
+
ops = ops || {};
|
|
35
|
+
ops.expires = -1;
|
|
36
|
+
cookie.set(key, '', ops);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
exports.default = cookie;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = copy;
|
|
4
|
+
function copy(content, callback) {
|
|
5
|
+
const newInput = document.createElement("input");
|
|
6
|
+
newInput.setAttribute("readonly", "readonly");
|
|
7
|
+
newInput.setAttribute("value", content);
|
|
8
|
+
document.body.appendChild(newInput);
|
|
9
|
+
if (document.execCommand("copy")) {
|
|
10
|
+
newInput.select();
|
|
11
|
+
document.execCommand("copy");
|
|
12
|
+
callback({ code: 200, msg: "复制成功" });
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
callback({ code: 100, msg: "当前浏览器不支持,请更换浏览器后重试" });
|
|
16
|
+
}
|
|
17
|
+
document.body.removeChild(newInput);
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function deepCopy<T extends Record<string, any>>(obj?: T, tar?: Record<string, any>): T;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = deepCopy;
|
|
4
|
+
function deepCopy(obj = {}, tar) {
|
|
5
|
+
const dest = obj || {};
|
|
6
|
+
if (!tar)
|
|
7
|
+
return dest;
|
|
8
|
+
for (const key in tar) {
|
|
9
|
+
if (!tar.hasOwnProperty(key))
|
|
10
|
+
continue;
|
|
11
|
+
const val = tar[key];
|
|
12
|
+
if (val === null || val === undefined) {
|
|
13
|
+
dest[key] = val;
|
|
14
|
+
}
|
|
15
|
+
else if (Array.isArray(val)) {
|
|
16
|
+
dest[key] = [];
|
|
17
|
+
deepCopy(dest[key], val);
|
|
18
|
+
}
|
|
19
|
+
else if (typeof val === 'object') {
|
|
20
|
+
dest[key] = {};
|
|
21
|
+
deepCopy(dest[key], val);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
dest[key] = val;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return dest;
|
|
28
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.default = downExcel;
|
|
37
|
+
const XLSX = __importStar(require("xlsx"));
|
|
38
|
+
function downExcel(data, fileName = '列表', sheetName = 'Sheet1') {
|
|
39
|
+
const worksheet = XLSX.utils.json_to_sheet(data);
|
|
40
|
+
const workbook = XLSX.utils.book_new();
|
|
41
|
+
XLSX.utils.book_append_sheet(workbook, worksheet, sheetName);
|
|
42
|
+
XLSX.writeFile(workbook, fileName + '.xlsx');
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function emoji(str: string): string;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = emoji;
|
|
4
|
+
const emojiRanges = [
|
|
5
|
+
[0x231A, 0x231B], [0x23E9, 0x23EC], [0x23F0, 0x23F0], [0x23F3, 0x23F3],
|
|
6
|
+
[0x25AA, 0x25AB], [0x25B6, 0x25B6], [0x25C0, 0x25C0], [0x25FB, 0x25FE],
|
|
7
|
+
[0x2600, 0x2604], [0x260E, 0x260E], [0x2611, 0x2611], [0x2614, 0x2615],
|
|
8
|
+
[0x2618, 0x2618], [0x261D, 0x261D], [0x2620, 0x2620], [0x2622, 0x2623],
|
|
9
|
+
[0x2626, 0x2626], [0x262A, 0x262A], [0x262E, 0x262F], [0x2638, 0x263A],
|
|
10
|
+
[0x2640, 0x2640], [0x2642, 0x2642], [0x2648, 0x2653], [0x265F, 0x2660],
|
|
11
|
+
[0x2663, 0x2663], [0x2665, 0x2666], [0x2668, 0x2668], [0x267B, 0x267B],
|
|
12
|
+
[0x267F, 0x267F], [0x2692, 0x2697], [0x2699, 0x2699], [0x269B, 0x269C],
|
|
13
|
+
[0x26A0, 0x26A1], [0x26AA, 0x26AB], [0x26B0, 0x26B1], [0x26BD, 0x26BE],
|
|
14
|
+
[0x26C4, 0x26C5], [0x26C8, 0x26C8], [0x26CE, 0x26CF], [0x26D1, 0x26D1],
|
|
15
|
+
[0x26D3, 0x26D4], [0x26E9, 0x26EA], [0x26F0, 0x26F5], [0x26F7, 0x26FA],
|
|
16
|
+
[0x26FD, 0x26FD], [0x2702, 0x2702], [0x2705, 0x2705], [0x2708, 0x270D],
|
|
17
|
+
[0x270F, 0x270F], [0x2712, 0x2712], [0x2714, 0x2714], [0x2716, 0x2716],
|
|
18
|
+
[0x271D, 0x271D], [0x2721, 0x2721], [0x2728, 0x2728], [0x2733, 0x2734],
|
|
19
|
+
[0x2744, 0x2744], [0x2747, 0x2747], [0x274C, 0x274C], [0x274E, 0x274E],
|
|
20
|
+
[0x2753, 0x2755], [0x2757, 0x2757], [0x2763, 0x2764], [0x2795, 0x2797],
|
|
21
|
+
[0x27A1, 0x27A1], [0x27B0, 0x27B0], [0x27BF, 0x27BF], [0x2934, 0x2935],
|
|
22
|
+
[0x2B05, 0x2B07], [0x2B1B, 0x2B1C], [0x2B50, 0x2B50], [0x2B55, 0x2B55],
|
|
23
|
+
[0x1F004, 0x1F004], [0x1F0CF, 0x1F0CF], [0x1F170, 0x1F171], [0x1F17E, 0x1F17F],
|
|
24
|
+
[0x1F18E, 0x1F18E], [0x1F191, 0x1F19A], [0x1F1E6, 0x1F1FF], [0x1F201, 0x1F202],
|
|
25
|
+
[0x1F21A, 0x1F21A], [0x1F22F, 0x1F22F], [0x1F232, 0x1F23A], [0x1F250, 0x1F251],
|
|
26
|
+
[0x1F300, 0x1F5FF], [0x1F600, 0x1F64F], [0x1F680, 0x1F6FF], [0x1F700, 0x1F77F],
|
|
27
|
+
[0x1F780, 0x1F7FF], [0x1F800, 0x1F8FF], [0x1F900, 0x1F9FF], [0x1FA00, 0x1FA6F],
|
|
28
|
+
[0x1FA70, 0x1FAFF], [0x1FB00, 0x1FBFF],
|
|
29
|
+
];
|
|
30
|
+
function isEmoji(codePoint) {
|
|
31
|
+
return emojiRanges.some(([start, end]) => codePoint >= start && codePoint <= end);
|
|
32
|
+
}
|
|
33
|
+
function canDisplayChar(char) {
|
|
34
|
+
return char !== '\uFFFD';
|
|
35
|
+
}
|
|
36
|
+
function emoji(str) {
|
|
37
|
+
if (!str)
|
|
38
|
+
return str;
|
|
39
|
+
const regex = /U\+([0-9A-Fa-f]{4,6})|\[u\+([0-9A-Fa-f]{4,6})\]|\\u\{([0-9A-Fa-f]{4,6})\}/g;
|
|
40
|
+
return str.replace(regex, (match, p1, p2, p3) => {
|
|
41
|
+
const hexStr = p1 || p2 || p3;
|
|
42
|
+
const codePoint = parseInt(hexStr, 16);
|
|
43
|
+
if (isNaN(codePoint) || codePoint < 0 || codePoint > 0x10FFFF) {
|
|
44
|
+
return match;
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const char = String.fromCodePoint(codePoint);
|
|
48
|
+
if (isEmoji(codePoint)) {
|
|
49
|
+
return char;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
if (canDisplayChar(char)) {
|
|
53
|
+
return char;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
return match;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
return match;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function emojiToUnicode(msg: string): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = emojiToUnicode;
|
|
4
|
+
function emojiToUnicode(msg) {
|
|
5
|
+
const rex = /[\u{1f300}-\u{1f5ff}\u{1f900}-\u{1f9ff}\u{1f600}-\u{1f64f}\u{1f680}-\u{1f6ff}\u{2600}-\u{26ff}\u{2700}-\u{27bf}\u{1f1e6}-\u{1f1ff}\u{1f191}-\u{1f251}\u{1f004}\u{1f0cf}\u{1f170}-\u{1f171}\u{1f17e}-\u{1f17f}\u{1f18e}\u{3030}\u{2b50}\u{2b55}\u{2934}-\u{2935}\u{2b05}-\u{2b07}\u{2b1b}-\u{2b1c}\u{3297}\u{3299}\u{303d}\u{00a9}\u{00ae}\u{2122}\u{23f3}\u{24c2}\u{23e9}-\u{23ef}\u{25b6}\u{23f8}-\u{23fa}]/gu;
|
|
6
|
+
const updated = msg.replace(rex, (match) => `[u+${match.codePointAt(0).toString(16)}]`);
|
|
7
|
+
return updated;
|
|
8
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export default function base64Img(content, apiUrl, token, data, callback = () => { }) {
|
|
2
|
+
const base64Regex = /<img [^>]*src=['"](data:image[^'"]+base64,[^'"]+)['"][^>]*>/gi;
|
|
3
|
+
let match;
|
|
4
|
+
const replacements = [];
|
|
5
|
+
while ((match = base64Regex.exec(content)) !== null) {
|
|
6
|
+
replacements.push({
|
|
7
|
+
original: match[1],
|
|
8
|
+
base64: match[1]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
if (replacements.length > 0) {
|
|
12
|
+
const uploadPromises = replacements.map((replacement) => {
|
|
13
|
+
return fetch(apiUrl, {
|
|
14
|
+
method: "POST",
|
|
15
|
+
headers: {
|
|
16
|
+
"Authorization": "Bearer " + token,
|
|
17
|
+
"Content-Type": "application/json"
|
|
18
|
+
},
|
|
19
|
+
body: JSON.stringify(Object.assign({ image: replacement.base64 }, data))
|
|
20
|
+
})
|
|
21
|
+
.then(res => res.json())
|
|
22
|
+
.then(result => {
|
|
23
|
+
if (result.code === 200) {
|
|
24
|
+
replacement.url = result.data.url;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
callback(replacement.original, result.msg);
|
|
28
|
+
}
|
|
29
|
+
return replacement;
|
|
30
|
+
})
|
|
31
|
+
.catch(error => {
|
|
32
|
+
callback(replacement.original, error);
|
|
33
|
+
return replacement;
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
return Promise.all(uploadPromises)
|
|
37
|
+
.then(results => {
|
|
38
|
+
results.forEach((result) => {
|
|
39
|
+
if (result.url) {
|
|
40
|
+
content = content.replace(result.original, result.url);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return content;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return Promise.resolve(content);
|
|
47
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface CookieOptions {
|
|
2
|
+
path?: string;
|
|
3
|
+
domain?: string;
|
|
4
|
+
expires?: number | Date;
|
|
5
|
+
}
|
|
6
|
+
interface CookieSetOptions extends CookieOptions {
|
|
7
|
+
domain?: 'domain' | string;
|
|
8
|
+
}
|
|
9
|
+
declare const cookie: {
|
|
10
|
+
set: (key: string, val: string, ops?: CookieSetOptions) => void;
|
|
11
|
+
get: (name: string) => string | null;
|
|
12
|
+
remove: (key: string, ops?: CookieOptions) => void;
|
|
13
|
+
};
|
|
14
|
+
export default cookie;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const cookie = {
|
|
2
|
+
set: (key, val, ops) => {
|
|
3
|
+
ops = ops || {};
|
|
4
|
+
let path = ops.path ? ";Path=" + ops.path : "";
|
|
5
|
+
let domain = '';
|
|
6
|
+
if (ops.domain && ops.domain === 'domain') {
|
|
7
|
+
const hostname = window.location.hostname;
|
|
8
|
+
const parts = hostname.split('.');
|
|
9
|
+
const set_domain = parts.slice(-2).join('.');
|
|
10
|
+
domain = ";domain=" + set_domain;
|
|
11
|
+
}
|
|
12
|
+
let expires = "";
|
|
13
|
+
if (ops.expires) {
|
|
14
|
+
const exp = String(ops.expires).length === 10
|
|
15
|
+
? new Date(Number(ops.expires) * 1000)
|
|
16
|
+
: new Date(ops.expires);
|
|
17
|
+
expires = ";expires=" + exp.toUTCString();
|
|
18
|
+
}
|
|
19
|
+
document.cookie = `${key}=${encodeURIComponent(val)}${domain}${path}${expires}`;
|
|
20
|
+
},
|
|
21
|
+
get: (name) => {
|
|
22
|
+
const value = `; ${document.cookie}`;
|
|
23
|
+
const parts = value.split(`; ${name}=`);
|
|
24
|
+
if (parts.length === 2) {
|
|
25
|
+
return decodeURIComponent(parts.pop().split(';').shift());
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
remove: (key, ops) => {
|
|
32
|
+
ops = ops || {};
|
|
33
|
+
ops.expires = -1;
|
|
34
|
+
cookie.set(key, '', ops);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
export default cookie;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export default function copy(content, callback) {
|
|
2
|
+
const newInput = document.createElement("input");
|
|
3
|
+
newInput.setAttribute("readonly", "readonly");
|
|
4
|
+
newInput.setAttribute("value", content);
|
|
5
|
+
document.body.appendChild(newInput);
|
|
6
|
+
if (document.execCommand("copy")) {
|
|
7
|
+
newInput.select();
|
|
8
|
+
document.execCommand("copy");
|
|
9
|
+
callback({ code: 200, msg: "复制成功" });
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
callback({ code: 100, msg: "当前浏览器不支持,请更换浏览器后重试" });
|
|
13
|
+
}
|
|
14
|
+
document.body.removeChild(newInput);
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function deepCopy<T extends Record<string, any>>(obj?: T, tar?: Record<string, any>): T;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export default function deepCopy(obj = {}, tar) {
|
|
2
|
+
const dest = obj || {};
|
|
3
|
+
if (!tar)
|
|
4
|
+
return dest;
|
|
5
|
+
for (const key in tar) {
|
|
6
|
+
if (!tar.hasOwnProperty(key))
|
|
7
|
+
continue;
|
|
8
|
+
const val = tar[key];
|
|
9
|
+
if (val === null || val === undefined) {
|
|
10
|
+
dest[key] = val;
|
|
11
|
+
}
|
|
12
|
+
else if (Array.isArray(val)) {
|
|
13
|
+
dest[key] = [];
|
|
14
|
+
deepCopy(dest[key], val);
|
|
15
|
+
}
|
|
16
|
+
else if (typeof val === 'object') {
|
|
17
|
+
dest[key] = {};
|
|
18
|
+
deepCopy(dest[key], val);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
dest[key] = val;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return dest;
|
|
25
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as XLSX from 'xlsx';
|
|
2
|
+
export default function downExcel(data, fileName = '列表', sheetName = 'Sheet1') {
|
|
3
|
+
const worksheet = XLSX.utils.json_to_sheet(data);
|
|
4
|
+
const workbook = XLSX.utils.book_new();
|
|
5
|
+
XLSX.utils.book_append_sheet(workbook, worksheet, sheetName);
|
|
6
|
+
XLSX.writeFile(workbook, fileName + '.xlsx');
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function emoji(str: string): string;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const emojiRanges = [
|
|
2
|
+
[0x231A, 0x231B], [0x23E9, 0x23EC], [0x23F0, 0x23F0], [0x23F3, 0x23F3],
|
|
3
|
+
[0x25AA, 0x25AB], [0x25B6, 0x25B6], [0x25C0, 0x25C0], [0x25FB, 0x25FE],
|
|
4
|
+
[0x2600, 0x2604], [0x260E, 0x260E], [0x2611, 0x2611], [0x2614, 0x2615],
|
|
5
|
+
[0x2618, 0x2618], [0x261D, 0x261D], [0x2620, 0x2620], [0x2622, 0x2623],
|
|
6
|
+
[0x2626, 0x2626], [0x262A, 0x262A], [0x262E, 0x262F], [0x2638, 0x263A],
|
|
7
|
+
[0x2640, 0x2640], [0x2642, 0x2642], [0x2648, 0x2653], [0x265F, 0x2660],
|
|
8
|
+
[0x2663, 0x2663], [0x2665, 0x2666], [0x2668, 0x2668], [0x267B, 0x267B],
|
|
9
|
+
[0x267F, 0x267F], [0x2692, 0x2697], [0x2699, 0x2699], [0x269B, 0x269C],
|
|
10
|
+
[0x26A0, 0x26A1], [0x26AA, 0x26AB], [0x26B0, 0x26B1], [0x26BD, 0x26BE],
|
|
11
|
+
[0x26C4, 0x26C5], [0x26C8, 0x26C8], [0x26CE, 0x26CF], [0x26D1, 0x26D1],
|
|
12
|
+
[0x26D3, 0x26D4], [0x26E9, 0x26EA], [0x26F0, 0x26F5], [0x26F7, 0x26FA],
|
|
13
|
+
[0x26FD, 0x26FD], [0x2702, 0x2702], [0x2705, 0x2705], [0x2708, 0x270D],
|
|
14
|
+
[0x270F, 0x270F], [0x2712, 0x2712], [0x2714, 0x2714], [0x2716, 0x2716],
|
|
15
|
+
[0x271D, 0x271D], [0x2721, 0x2721], [0x2728, 0x2728], [0x2733, 0x2734],
|
|
16
|
+
[0x2744, 0x2744], [0x2747, 0x2747], [0x274C, 0x274C], [0x274E, 0x274E],
|
|
17
|
+
[0x2753, 0x2755], [0x2757, 0x2757], [0x2763, 0x2764], [0x2795, 0x2797],
|
|
18
|
+
[0x27A1, 0x27A1], [0x27B0, 0x27B0], [0x27BF, 0x27BF], [0x2934, 0x2935],
|
|
19
|
+
[0x2B05, 0x2B07], [0x2B1B, 0x2B1C], [0x2B50, 0x2B50], [0x2B55, 0x2B55],
|
|
20
|
+
[0x1F004, 0x1F004], [0x1F0CF, 0x1F0CF], [0x1F170, 0x1F171], [0x1F17E, 0x1F17F],
|
|
21
|
+
[0x1F18E, 0x1F18E], [0x1F191, 0x1F19A], [0x1F1E6, 0x1F1FF], [0x1F201, 0x1F202],
|
|
22
|
+
[0x1F21A, 0x1F21A], [0x1F22F, 0x1F22F], [0x1F232, 0x1F23A], [0x1F250, 0x1F251],
|
|
23
|
+
[0x1F300, 0x1F5FF], [0x1F600, 0x1F64F], [0x1F680, 0x1F6FF], [0x1F700, 0x1F77F],
|
|
24
|
+
[0x1F780, 0x1F7FF], [0x1F800, 0x1F8FF], [0x1F900, 0x1F9FF], [0x1FA00, 0x1FA6F],
|
|
25
|
+
[0x1FA70, 0x1FAFF], [0x1FB00, 0x1FBFF],
|
|
26
|
+
];
|
|
27
|
+
function isEmoji(codePoint) {
|
|
28
|
+
return emojiRanges.some(([start, end]) => codePoint >= start && codePoint <= end);
|
|
29
|
+
}
|
|
30
|
+
function canDisplayChar(char) {
|
|
31
|
+
return char !== '\uFFFD';
|
|
32
|
+
}
|
|
33
|
+
export default function emoji(str) {
|
|
34
|
+
if (!str)
|
|
35
|
+
return str;
|
|
36
|
+
const regex = /U\+([0-9A-Fa-f]{4,6})|\[u\+([0-9A-Fa-f]{4,6})\]|\\u\{([0-9A-Fa-f]{4,6})\}/g;
|
|
37
|
+
return str.replace(regex, (match, p1, p2, p3) => {
|
|
38
|
+
const hexStr = p1 || p2 || p3;
|
|
39
|
+
const codePoint = parseInt(hexStr, 16);
|
|
40
|
+
if (isNaN(codePoint) || codePoint < 0 || codePoint > 0x10FFFF) {
|
|
41
|
+
return match;
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
const char = String.fromCodePoint(codePoint);
|
|
45
|
+
if (isEmoji(codePoint)) {
|
|
46
|
+
return char;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
if (canDisplayChar(char)) {
|
|
50
|
+
return char;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
return match;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
return match;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function emojiToUnicode(msg: string): string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export default function emojiToUnicode(msg) {
|
|
2
|
+
const rex = /[\u{1f300}-\u{1f5ff}\u{1f900}-\u{1f9ff}\u{1f600}-\u{1f64f}\u{1f680}-\u{1f6ff}\u{2600}-\u{26ff}\u{2700}-\u{27bf}\u{1f1e6}-\u{1f1ff}\u{1f191}-\u{1f251}\u{1f004}\u{1f0cf}\u{1f170}-\u{1f171}\u{1f17e}-\u{1f17f}\u{1f18e}\u{3030}\u{2b50}\u{2b55}\u{2934}-\u{2935}\u{2b05}-\u{2b07}\u{2b1b}-\u{2b1c}\u{3297}\u{3299}\u{303d}\u{00a9}\u{00ae}\u{2122}\u{23f3}\u{24c2}\u{23e9}-\u{23ef}\u{25b6}\u{23f8}-\u{23fa}]/gu;
|
|
3
|
+
const updated = msg.replace(rex, (match) => `[u+${match.codePointAt(0).toString(16)}]`);
|
|
4
|
+
return updated;
|
|
5
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const defaultTypes = ['', undefined, null];
|
|
2
|
+
function filterType(val, types) {
|
|
3
|
+
return types.some(v => v === val);
|
|
4
|
+
}
|
|
5
|
+
export default function filterTable(data, params = '--', more) {
|
|
6
|
+
const types = more && more.length ? [...defaultTypes, ...more] : defaultTypes;
|
|
7
|
+
const newArr = [];
|
|
8
|
+
for (const key in data) {
|
|
9
|
+
const obj = {};
|
|
10
|
+
const re = Object.entries(data[key]);
|
|
11
|
+
for (let i = 0; i < re.length; i++) {
|
|
12
|
+
const d = re[i];
|
|
13
|
+
if (filterType(d[1], types)) {
|
|
14
|
+
d[1] = params;
|
|
15
|
+
}
|
|
16
|
+
obj[d[0]] = d[1];
|
|
17
|
+
}
|
|
18
|
+
newArr.push(obj);
|
|
19
|
+
}
|
|
20
|
+
return newArr;
|
|
21
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export default function flyToCart(event, image, targets, callback = () => { }) {
|
|
2
|
+
const button = event.target;
|
|
3
|
+
const flyEl = document.createElement('img');
|
|
4
|
+
flyEl.style.cssText = `position: fixed;
|
|
5
|
+
width: 20px;
|
|
6
|
+
height: 20px;
|
|
7
|
+
border-radius: 50%;
|
|
8
|
+
pointer-events: none;
|
|
9
|
+
transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.8s;
|
|
10
|
+
z-index: 10000;
|
|
11
|
+
opacity: 1;
|
|
12
|
+
transform-origin: center center;`;
|
|
13
|
+
flyEl.setAttribute('src', image);
|
|
14
|
+
document.body.appendChild(flyEl);
|
|
15
|
+
const startRect = button.getBoundingClientRect();
|
|
16
|
+
const startX = startRect.left + startRect.width / 2;
|
|
17
|
+
const startY = startRect.top + startRect.height / 2;
|
|
18
|
+
const cartRect = targets.getBoundingClientRect();
|
|
19
|
+
const endX = cartRect.left + cartRect.width / 2;
|
|
20
|
+
const endY = cartRect.top + cartRect.height / 2;
|
|
21
|
+
const controlX = (startX + endX) / 2;
|
|
22
|
+
const controlY = Math.min(startY, endY) - 150;
|
|
23
|
+
flyEl.style.left = startX + 'px';
|
|
24
|
+
flyEl.style.top = startY + 'px';
|
|
25
|
+
let t = 0;
|
|
26
|
+
const duration = 800;
|
|
27
|
+
const startTime = performance.now();
|
|
28
|
+
const animate = (time) => {
|
|
29
|
+
t = (time - startTime) / duration;
|
|
30
|
+
if (t > 1)
|
|
31
|
+
t = 1;
|
|
32
|
+
const x = (1 - t) * (1 - t) * startX + 2 * (1 - t) * t * controlX + t * t * endX;
|
|
33
|
+
const y = (1 - t) * (1 - t) * startY + 2 * (1 - t) * t * controlY + t * t * endY;
|
|
34
|
+
flyEl.style.left = x + 'px';
|
|
35
|
+
flyEl.style.top = y + 'px';
|
|
36
|
+
flyEl.style.transform = `scale(${1 - t * 0.7})`;
|
|
37
|
+
flyEl.style.opacity = `${1 - t}`;
|
|
38
|
+
if (t < 1) {
|
|
39
|
+
requestAnimationFrame(animate);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
flyEl.remove();
|
|
43
|
+
callback();
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
requestAnimationFrame(animate);
|
|
47
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface ThrottleFunction<T extends (...args: any[]) => any> {
|
|
2
|
+
(...args: Parameters<T>): void;
|
|
3
|
+
}
|
|
4
|
+
interface DebounceFunction<T extends (...args: any[]) => any> {
|
|
5
|
+
(...args: Parameters<T>): void;
|
|
6
|
+
}
|
|
7
|
+
declare const fun: {
|
|
8
|
+
throole<T extends (...args: any[]) => any>(fn: T, delay?: number): ThrottleFunction<T>;
|
|
9
|
+
debounce<T extends (...args: any[]) => any>(fn: T, delay?: number): DebounceFunction<T>;
|
|
10
|
+
};
|
|
11
|
+
export default fun;
|