mirror of
https://github.com/vastxie/99AI.git
synced 2026-01-17 04:16:01 +08:00
v4.1.0
This commit is contained in:
26
AIWebQuickDeploy/dist/common/utils/base.js
vendored
Normal file
26
AIWebQuickDeploy/dist/common/utils/base.js
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.decrypt = exports.encrypt = void 0;
|
||||
const crypto = require("crypto");
|
||||
const encryptionKey = 'bf3c116f2470cb4che9071240917c171';
|
||||
const initializationVector = '518363fh72eec1v4';
|
||||
const algorithm = 'aes-256-cbc';
|
||||
function encrypt(text) {
|
||||
const cipher = crypto.createCipheriv(algorithm, encryptionKey, initializationVector);
|
||||
let encrypted = cipher.update(text, 'utf8', 'base64');
|
||||
encrypted += cipher.final('base64');
|
||||
return encrypted;
|
||||
}
|
||||
exports.encrypt = encrypt;
|
||||
function decrypt(text) {
|
||||
try {
|
||||
const decipher = crypto.createDecipheriv(algorithm, encryptionKey, initializationVector);
|
||||
let decrypted = decipher.update(text, 'base64', 'utf8');
|
||||
decrypted += decipher.final('utf8');
|
||||
return decrypted;
|
||||
}
|
||||
catch (error) {
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
exports.decrypt = decrypt;
|
||||
8
AIWebQuickDeploy/dist/common/utils/createOrderId.js
vendored
Normal file
8
AIWebQuickDeploy/dist/common/utils/createOrderId.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createOrderId = void 0;
|
||||
const uuid_1 = require("uuid");
|
||||
function createOrderId() {
|
||||
return (0, uuid_1.v1)().toString().replace(/-/g, '');
|
||||
}
|
||||
exports.createOrderId = createOrderId;
|
||||
9
AIWebQuickDeploy/dist/common/utils/createRandomCode.js
vendored
Normal file
9
AIWebQuickDeploy/dist/common/utils/createRandomCode.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createRandomCode = void 0;
|
||||
function createRandomCode() {
|
||||
const min = 100000;
|
||||
const max = 999999;
|
||||
return Math.floor(Math.random() * (max - min + 1) + min);
|
||||
}
|
||||
exports.createRandomCode = createRandomCode;
|
||||
14
AIWebQuickDeploy/dist/common/utils/createRandomInviteCode.js
vendored
Normal file
14
AIWebQuickDeploy/dist/common/utils/createRandomInviteCode.js
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.generateRandomString = void 0;
|
||||
function generateRandomString() {
|
||||
const length = 10;
|
||||
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
let result = '';
|
||||
for (let i = 0; i < length; i++) {
|
||||
const randomIndex = Math.floor(Math.random() * characters.length);
|
||||
result += characters.charAt(randomIndex);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
exports.generateRandomString = generateRandomString;
|
||||
12
AIWebQuickDeploy/dist/common/utils/createRandomNonceStr.js
vendored
Normal file
12
AIWebQuickDeploy/dist/common/utils/createRandomNonceStr.js
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createRandomNonceStr = void 0;
|
||||
function createRandomNonceStr(len) {
|
||||
const data = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
||||
let str = '';
|
||||
for (let i = 0; i < len; i++) {
|
||||
str += data.charAt(parseInt((Math.random() * data.length).toFixed(0), 10));
|
||||
}
|
||||
return str;
|
||||
}
|
||||
exports.createRandomNonceStr = createRandomNonceStr;
|
||||
9
AIWebQuickDeploy/dist/common/utils/createRandomUid.js
vendored
Normal file
9
AIWebQuickDeploy/dist/common/utils/createRandomUid.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createRandomUid = void 0;
|
||||
const guid_typescript_1 = require("guid-typescript");
|
||||
function createRandomUid() {
|
||||
const uuid = guid_typescript_1.Guid.create();
|
||||
return uuid.toString().substr(0, 10).replace('-', '');
|
||||
}
|
||||
exports.createRandomUid = createRandomUid;
|
||||
43
AIWebQuickDeploy/dist/common/utils/date.js
vendored
Normal file
43
AIWebQuickDeploy/dist/common/utils/date.js
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.isExpired = exports.formatCreateOrUpdateDate = exports.formatDate = void 0;
|
||||
const dayjs = require("dayjs");
|
||||
require("dayjs/locale/zh-cn");
|
||||
const a = require("dayjs/plugin/utc");
|
||||
const b = require("dayjs/plugin/timezone");
|
||||
dayjs.locale('zh-cn');
|
||||
dayjs.extend(a);
|
||||
dayjs.extend(b);
|
||||
dayjs.tz.setDefault('Asia/Shanghai');
|
||||
function formatDate(date, format = 'YYYY-MM-DD HH:mm:ss') {
|
||||
return dayjs(date).format(format);
|
||||
}
|
||||
exports.formatDate = formatDate;
|
||||
function formatCreateOrUpdateDate(input, format = 'YYYY-MM-DD HH:mm:ss') {
|
||||
if (Array.isArray(input)) {
|
||||
return input.map((t) => {
|
||||
t.createdAt = (t === null || t === void 0 ? void 0 : t.createdAt) ? dayjs(t.createdAt).format(format) : dayjs().format(format);
|
||||
t.updatedAt = (t === null || t === void 0 ? void 0 : t.updatedAt) ? dayjs(t.updatedAt).format(format) : dayjs().format(format);
|
||||
return t;
|
||||
});
|
||||
}
|
||||
else {
|
||||
let obj = {};
|
||||
try {
|
||||
obj = JSON.parse(JSON.stringify(input));
|
||||
}
|
||||
catch (error) {
|
||||
}
|
||||
(obj === null || obj === void 0 ? void 0 : obj.createdAt) && (obj.createdAt = dayjs(obj.createdAt).format(format));
|
||||
(obj === null || obj === void 0 ? void 0 : obj.updatedAt) && (obj.updatedAt = dayjs(obj.updatedAt).format(format));
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
exports.formatCreateOrUpdateDate = formatCreateOrUpdateDate;
|
||||
function isExpired(createdAt, days) {
|
||||
const expireDate = new Date(createdAt.getTime() + days * 24 * 60 * 60 * 1000);
|
||||
const now = new Date();
|
||||
return now > expireDate;
|
||||
}
|
||||
exports.isExpired = isExpired;
|
||||
exports.default = dayjs;
|
||||
14
AIWebQuickDeploy/dist/common/utils/encrypt.js
vendored
Normal file
14
AIWebQuickDeploy/dist/common/utils/encrypt.js
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.copyRightMsg = exports.atob = void 0;
|
||||
function atob(str) {
|
||||
return Buffer.from(str, 'base64').toString('utf-8');
|
||||
}
|
||||
exports.atob = atob;
|
||||
exports.copyRightMsg = [
|
||||
'agxoTstMY8m+DJO89Iwy4zqcFTqlcj/Fa/erMTvn0IexetXaDttr4K/BN2+RbtfouXOeFjPDYnxOfQ+IIpuJ3PmtyHAzmlGFls/HvBDeh6EXAQ3waALbvK9Ue96soAb5/3Tv6VuZE7npISqXiYhI6Vqx4yDVYf6vUUkEO9jvVotWQkLOLkr6M/guLK6sik/ZOgHvSlDYKAv79NFJJ0Tt0WkH2SyN8l+woMiWVTOKkdE=',
|
||||
'nXdXi8UU7J5av2eDOFjxQWlZDa+3bdASE4UwpqT6B11XSCweKKuzHxmFO2wx45iVlib/V0tt+NbEcOQZtzEWKqHsREkwEb5aqVCUl2Kj4nJeEFId2iyvY6MWEV1lHtCY+htpJoyqwQJc7yeNfpTl2SLBubWk77p4AHei1QFEs1rpOOwyE79lF0RqzY/Cpzhs',
|
||||
'VjVCGib1VFp7hNynpKGQPUrX+ishpxi2u5a4txHXzk2nyUP1NZfIomEDmGhDTQ7VRJLox+8urtVG1CBBSct1v+4OA2ucAcDUFoy1H1Kl1z+dndVcNU6gz5YGnDppsxY8uGFAVGsWrDl2DIOKxk7kMURaRiQCXCHRF/3sLGyIEmE6KL9Q4kDInB6vuzBScxupFShMXTq2XrOhwRgn2elcig==',
|
||||
'ZPcz1IaPDMGI3Yn9sm4QOT0qCZo7yZbJl4/c2RTrhUKINkjGB5yb0yN5vAnLtt/o8cmpoOoH3PUSOOWQa9aKD86NWK+1r8wBOVjwXZOpp2gbB1ZJLbWvjRbENvEJxVsLROXnpNDqUXVGxFMaIt+gmEi3Rp0thqC1soXUpvM1zqU4+LkQmunR7UytvzwXEmXBlIfPwz5hv+n/lxDsw526KWixC3jLLpeijw5433Zh7cI=',
|
||||
'YPo1HNzS6p6190ku4f1PQENUBa/ip+v+6sPuQXVyAn3axo6SLKQBszNr3PAW2EzWhZLy2o+nBgr3o3IOy9OgNit1JHrCklpVp172wbGDKh8sB8HCXyJoRv3BaZVY5UhyhpV5K+4nPoM2RUwvIGONUGFPQfPQv9N8MS8UCL7UnWYcVLzxWo0ZDg+UXFRr7NhXKu7KQ7e1+Wiqm0qE+olfDVowi4pGDRGrYL154wEEJUo='
|
||||
];
|
||||
11
AIWebQuickDeploy/dist/common/utils/fromatUrl.js
vendored
Normal file
11
AIWebQuickDeploy/dist/common/utils/fromatUrl.js
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.formatUrl = void 0;
|
||||
function formatUrl(url) {
|
||||
let formattedUrl = url.replace(/\s+/g, '');
|
||||
if (formattedUrl.endsWith('/')) {
|
||||
formattedUrl = formattedUrl.slice(0, -1);
|
||||
}
|
||||
return formattedUrl;
|
||||
}
|
||||
exports.formatUrl = formatUrl;
|
||||
9
AIWebQuickDeploy/dist/common/utils/generateCrami.js
vendored
Normal file
9
AIWebQuickDeploy/dist/common/utils/generateCrami.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.generateCramiCode = void 0;
|
||||
const uuid_1 = require("uuid");
|
||||
function generateCramiCode() {
|
||||
const code = (0, uuid_1.v4)().replace(/-/g, '').slice(0, 16);
|
||||
return code;
|
||||
}
|
||||
exports.generateCramiCode = generateCramiCode;
|
||||
22
AIWebQuickDeploy/dist/common/utils/getClientIp.js
vendored
Normal file
22
AIWebQuickDeploy/dist/common/utils/getClientIp.js
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getClientIp = void 0;
|
||||
function getFirstValidIp(ipString) {
|
||||
const ips = ipString.split(',').map(ip => ip.trim());
|
||||
return ips.find(ip => isValidIp(ip)) || '';
|
||||
}
|
||||
function isValidIp(ip) {
|
||||
return /^\d{1,3}(\.\d{1,3}){3}$/.test(ip) || /^::ffff:\d{1,3}(\.\d{1,3}){3}$/.test(ip);
|
||||
}
|
||||
function getClientIp(req) {
|
||||
const forwardedFor = req.header('x-forwarded-for');
|
||||
let clientIp = forwardedFor ? getFirstValidIp(forwardedFor) : '';
|
||||
if (!clientIp) {
|
||||
clientIp = req.connection.remoteAddress || req.socket.remoteAddress || '';
|
||||
}
|
||||
if (clientIp.startsWith('::ffff:')) {
|
||||
clientIp = clientIp.substring(7);
|
||||
}
|
||||
return clientIp;
|
||||
}
|
||||
exports.getClientIp = getClientIp;
|
||||
15
AIWebQuickDeploy/dist/common/utils/getDiffArray.js
vendored
Normal file
15
AIWebQuickDeploy/dist/common/utils/getDiffArray.js
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getDiffArray = void 0;
|
||||
function getDiffArray(aLength, bLength, str) {
|
||||
const a = Array.from({ length: aLength }, (_, i) => i + 1);
|
||||
const b = Array.from({ length: bLength }, (_, i) => i + 1);
|
||||
const diffArray = [];
|
||||
for (let i = 0; i < a.length; i++) {
|
||||
if (!b.includes(a[i])) {
|
||||
diffArray.push(`${str}${a[i]}`);
|
||||
}
|
||||
}
|
||||
return diffArray;
|
||||
}
|
||||
exports.getDiffArray = getDiffArray;
|
||||
8
AIWebQuickDeploy/dist/common/utils/getRandomItem.js
vendored
Normal file
8
AIWebQuickDeploy/dist/common/utils/getRandomItem.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getRandomItem = void 0;
|
||||
function getRandomItem(array) {
|
||||
const randomIndex = Math.floor(Math.random() * array.length);
|
||||
return array[randomIndex];
|
||||
}
|
||||
exports.getRandomItem = getRandomItem;
|
||||
11
AIWebQuickDeploy/dist/common/utils/getRandomItemFromArray.js
vendored
Normal file
11
AIWebQuickDeploy/dist/common/utils/getRandomItemFromArray.js
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getRandomItemFromArray = void 0;
|
||||
function getRandomItemFromArray(array) {
|
||||
if (array.length === 0) {
|
||||
return null;
|
||||
}
|
||||
const randomIndex = Math.floor(Math.random() * array.length);
|
||||
return array[randomIndex];
|
||||
}
|
||||
exports.getRandomItemFromArray = getRandomItemFromArray;
|
||||
30
AIWebQuickDeploy/dist/common/utils/getTokenCount.js
vendored
Normal file
30
AIWebQuickDeploy/dist/common/utils/getTokenCount.js
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getTokenCount = void 0;
|
||||
const gpt_tokenizer_1 = require("gpt-tokenizer");
|
||||
const getTokenCount = async (input) => {
|
||||
let text = '';
|
||||
if (Array.isArray(input)) {
|
||||
text = input.reduce((pre, cur) => {
|
||||
if (Array.isArray(cur.content)) {
|
||||
const contentText = cur.content
|
||||
.filter((item) => item.type === 'text')
|
||||
.map((item) => item.text)
|
||||
.join(' ');
|
||||
return pre + contentText;
|
||||
}
|
||||
else {
|
||||
return pre + (cur.content || '');
|
||||
}
|
||||
}, '');
|
||||
}
|
||||
else if (typeof input === 'string') {
|
||||
text = input;
|
||||
}
|
||||
else if (input) {
|
||||
text = String(input);
|
||||
}
|
||||
text = text.replace(/<\|endoftext\|>/g, '');
|
||||
return (0, gpt_tokenizer_1.encode)(text).length;
|
||||
};
|
||||
exports.getTokenCount = getTokenCount;
|
||||
43
AIWebQuickDeploy/dist/common/utils/handleError.js
vendored
Normal file
43
AIWebQuickDeploy/dist/common/utils/handleError.js
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.handleError = void 0;
|
||||
const axios_1 = require("axios");
|
||||
function handleError(error) {
|
||||
let message = '发生未知错误,请稍后再试';
|
||||
if (axios_1.default.isAxiosError(error) && error.response) {
|
||||
switch (error.response.status) {
|
||||
case 400:
|
||||
message =
|
||||
'发生错误:400 Bad Request - 请求因格式错误无法被服务器处理。';
|
||||
break;
|
||||
case 401:
|
||||
message = '发生错误:401 Unauthorized - 请求要求进行身份验证。';
|
||||
break;
|
||||
case 403:
|
||||
message = '发生错误:403 Forbidden - 服务器拒绝执行请求。';
|
||||
break;
|
||||
case 404:
|
||||
message = '发生错误:404 Not Found - 请求的资源无法在服务器上找到。';
|
||||
break;
|
||||
case 500:
|
||||
message =
|
||||
'发生错误:500 Internal Server Error - 服务器内部错误,无法完成请求。';
|
||||
break;
|
||||
case 502:
|
||||
message =
|
||||
'发生错误:502 Bad Gateway - 作为网关或代理工作的服务器从上游服务器收到无效响应。';
|
||||
break;
|
||||
case 503:
|
||||
message =
|
||||
'发生错误:503 Service Unavailable - 服务器暂时处于超负载或维护状态,无法处理请求。';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
message = error.message || message;
|
||||
}
|
||||
return message;
|
||||
}
|
||||
exports.handleError = handleError;
|
||||
14
AIWebQuickDeploy/dist/common/utils/hideString.js
vendored
Normal file
14
AIWebQuickDeploy/dist/common/utils/hideString.js
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.hideString = void 0;
|
||||
function hideString(input, str) {
|
||||
const length = input.length;
|
||||
const start = input.slice(0, (length - 10) / 2);
|
||||
const end = input.slice((length + 10) / 2, length);
|
||||
const hidden = '*'.repeat(10);
|
||||
if (str) {
|
||||
return `**********${str}**********`;
|
||||
}
|
||||
return `${start}${hidden}${end}`;
|
||||
}
|
||||
exports.hideString = hideString;
|
||||
39
AIWebQuickDeploy/dist/common/utils/index.js
vendored
Normal file
39
AIWebQuickDeploy/dist/common/utils/index.js
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./base"), exports);
|
||||
__exportStar(require("./createOrderId"), exports);
|
||||
__exportStar(require("./createRandomCode"), exports);
|
||||
__exportStar(require("./createRandomInviteCode"), exports);
|
||||
__exportStar(require("./createRandomNonceStr"), exports);
|
||||
__exportStar(require("./createRandomUid"), exports);
|
||||
__exportStar(require("./date"), exports);
|
||||
__exportStar(require("./encrypt"), exports);
|
||||
__exportStar(require("./fromatUrl"), exports);
|
||||
__exportStar(require("./generateCrami"), exports);
|
||||
__exportStar(require("./getClientIp"), exports);
|
||||
__exportStar(require("./getDiffArray"), exports);
|
||||
__exportStar(require("./getRandomItem"), exports);
|
||||
__exportStar(require("./getRandomItemFromArray"), exports);
|
||||
__exportStar(require("./getTokenCount"), exports);
|
||||
__exportStar(require("./handleError"), exports);
|
||||
__exportStar(require("./hideString"), exports);
|
||||
__exportStar(require("./maskCrami"), exports);
|
||||
__exportStar(require("./maskEmail"), exports);
|
||||
__exportStar(require("./maskIpAddress"), exports);
|
||||
__exportStar(require("./removeSpecialCharacters"), exports);
|
||||
__exportStar(require("./tools"), exports);
|
||||
__exportStar(require("./utcformatTime"), exports);
|
||||
11
AIWebQuickDeploy/dist/common/utils/maskCrami.js
vendored
Normal file
11
AIWebQuickDeploy/dist/common/utils/maskCrami.js
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.maskCrami = void 0;
|
||||
function maskCrami(str) {
|
||||
if (str.length !== 16) {
|
||||
throw new Error('Invalid input');
|
||||
}
|
||||
const masked = str.substring(0, 6) + '****' + str.substring(10);
|
||||
return masked;
|
||||
}
|
||||
exports.maskCrami = maskCrami;
|
||||
16
AIWebQuickDeploy/dist/common/utils/maskEmail.js
vendored
Normal file
16
AIWebQuickDeploy/dist/common/utils/maskEmail.js
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.maskEmail = void 0;
|
||||
function maskEmail(email) {
|
||||
if (!email)
|
||||
return '';
|
||||
const atIndex = email.indexOf('@');
|
||||
if (atIndex <= 1) {
|
||||
return email;
|
||||
}
|
||||
const firstPart = email.substring(0, atIndex - 1);
|
||||
const lastPart = email.substring(atIndex);
|
||||
const maskedPart = '*'.repeat(firstPart.length - 1);
|
||||
return `${firstPart.charAt(0)}${maskedPart}${email.charAt(atIndex - 1)}${lastPart}`;
|
||||
}
|
||||
exports.maskEmail = maskEmail;
|
||||
11
AIWebQuickDeploy/dist/common/utils/maskIpAddress.js
vendored
Normal file
11
AIWebQuickDeploy/dist/common/utils/maskIpAddress.js
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.maskIpAddress = void 0;
|
||||
function maskIpAddress(ipAddress) {
|
||||
if (!ipAddress)
|
||||
return '';
|
||||
const ipArray = ipAddress.split('.');
|
||||
ipArray[2] = '***';
|
||||
return ipArray.join('.');
|
||||
}
|
||||
exports.maskIpAddress = maskIpAddress;
|
||||
7
AIWebQuickDeploy/dist/common/utils/removeSpecialCharacters.js
vendored
Normal file
7
AIWebQuickDeploy/dist/common/utils/removeSpecialCharacters.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.removeSpecialCharacters = void 0;
|
||||
function removeSpecialCharacters(inputString) {
|
||||
return inputString.replace(/[^\w\s-]/g, '');
|
||||
}
|
||||
exports.removeSpecialCharacters = removeSpecialCharacters;
|
||||
8
AIWebQuickDeploy/dist/common/utils/tools.js
vendored
Normal file
8
AIWebQuickDeploy/dist/common/utils/tools.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.importDynamic = exports.isNotEmptyString = void 0;
|
||||
function isNotEmptyString(value) {
|
||||
return typeof value === 'string' && value.length > 0;
|
||||
}
|
||||
exports.isNotEmptyString = isNotEmptyString;
|
||||
exports.importDynamic = new Function('modulePath', 'return import(modulePath)');
|
||||
16
AIWebQuickDeploy/dist/common/utils/utcformatTime.js
vendored
Normal file
16
AIWebQuickDeploy/dist/common/utils/utcformatTime.js
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.utcToShanghaiTime = void 0;
|
||||
function utcToShanghaiTime(utcTime, format = 'YYYY/MM/DD hh:mm:ss') {
|
||||
const date = new Date(utcTime);
|
||||
const shanghaiTime = date.getTime() + 8 * 60 * 60 * 1000;
|
||||
const shanghaiDate = new Date(shanghaiTime);
|
||||
let result = format.replace('YYYY', shanghaiDate.getFullYear().toString());
|
||||
result = result.replace('MM', `0${shanghaiDate.getMonth() + 1}`.slice(-2));
|
||||
result = result.replace('DD', `0${shanghaiDate.getDate()}`.slice(-2));
|
||||
result = result.replace('hh', `0${shanghaiDate.getHours()}`.slice(-2));
|
||||
result = result.replace('mm', `0${shanghaiDate.getMinutes()}`.slice(-2));
|
||||
result = result.replace('ss', `0${shanghaiDate.getSeconds()}`.slice(-2));
|
||||
return result;
|
||||
}
|
||||
exports.utcToShanghaiTime = utcToShanghaiTime;
|
||||
Reference in New Issue
Block a user