feat: 🚀 订阅功能

This commit is contained in:
2025-09-16 16:38:30 +08:00
parent eb1b66a066
commit d3a3ef2911
456 changed files with 40544 additions and 124 deletions

59
src/utils/color.ts Normal file
View File

@@ -0,0 +1,59 @@
import { ElMessage } from "element-plus";
/**
* @description hex颜色转rgb颜色
* @param {String} str 颜色值字符串
* @returns {String} 返回处理后的颜色值
*/
export function hexToRgb(str: any) {
let hexs: any = "";
let reg = /^\#?[0-9A-Fa-f]{6}$/;
if (!reg.test(str)) return ElMessage.warning("输入错误的hex");
str = str.replace("#", "");
hexs = str.match(/../g);
for (let i = 0; i < 3; i++) hexs[i] = parseInt(hexs[i], 16);
return hexs;
}
/**
* @description rgb颜色转Hex颜色
* @param {*} r 代表红色
* @param {*} g 代表绿色
* @param {*} b 代表蓝色
* @returns {String} 返回处理后的颜色值
*/
export function rgbToHex(r: any, g: any, b: any) {
let reg = /^\d{1,3}$/;
if (!reg.test(r) || !reg.test(g) || !reg.test(b)) return ElMessage.warning("输入错误的rgb颜色值");
let hexs = [r.toString(16), g.toString(16), b.toString(16)];
for (let i = 0; i < 3; i++) if (hexs[i].length == 1) hexs[i] = `0${hexs[i]}`;
return `#${hexs.join("")}`;
}
/**
* @description 加深颜色值
* @param {String} color 颜色值字符串
* @param {Number} level 加深的程度限0-1之间
* @returns {String} 返回处理后的颜色值
*/
export function getDarkColor(color: string, level: number) {
let reg = /^\#?[0-9A-Fa-f]{6}$/;
if (!reg.test(color)) return ElMessage.warning("输入错误的hex颜色值");
let rgb = hexToRgb(color);
for (let i = 0; i < 3; i++) rgb[i] = Math.round(20.5 * level + rgb[i] * (1 - level));
return rgbToHex(rgb[0], rgb[1], rgb[2]);
}
/**
* @description 变浅颜色值
* @param {String} color 颜色值字符串
* @param {Number} level 加深的程度限0-1之间
* @returns {String} 返回处理后的颜色值
*/
export function getLightColor(color: string, level: number) {
let reg = /^\#?[0-9A-Fa-f]{6}$/;
if (!reg.test(color)) return ElMessage.warning("输入错误的hex颜色值");
let rgb = hexToRgb(color);
for (let i = 0; i < 3; i++) rgb[i] = Math.round(255 * level + rgb[i] * (1 - level));
return rgbToHex(rgb[0], rgb[1], rgb[2]);
}

32
src/utils/eleValidate.ts Normal file
View File

@@ -0,0 +1,32 @@
// ? Element 常用表单校验规则
/**
* @rule 手机号
*/
export function checkPhoneNumber(rule: any, value: any, callback: any) {
const regexp = /^(((13[0-9]{1})|(15[0-9]{1})|(16[0-9]{1})|(17[3-8]{1})|(18[0-9]{1})|(19[0-9]{1})|(14[5-7]{1}))+\d{8})$/;
if (value === "") callback("请输入手机号码");
if (!regexp.test(value)) {
callback(new Error("请输入正确的手机号码"));
} else {
return callback();
}
}
export function numberRexgu(value: any) {
if (value) {
if (value.toString().indexOf(".") != -1) {
let value_after = parseInt(value.toString().substring(0, value.indexOf(".")));
let value_before = value.replace(/\d+\.(\d*)/, "$1");
if (value_after.toString().length > 8) {
let newValue = value_after.toString().substring(0, 8) + "." + value_before;
return (newValue.toString().match(/\d{1,8}(\.\d{0,6})?/) || [""])[0];
} else {
return (value.toString().match(/\d{1,8}(\.\d{0,6})?/) || [""])[0];
}
}
return (value.toString().match(/\d{1,8}(\.\d{0,6})?/) || [""])[0];
} else {
return "";
}
}

39
src/utils/errorHandler.ts Normal file
View File

@@ -0,0 +1,39 @@
import { ElNotification } from "element-plus";
/**
* @description 全局代码错误捕捉
* */
const errorHandler = (error: any) => {
// 过滤 HTTP 请求错误
if (error.status || error.status == 0) return false;
let errorMap: { [key: string]: string } = {
InternalError: "Javascript引擎内部错误",
ReferenceError: "未找到对象",
TypeError: "使用了错误的类型或对象",
RangeError: "使用内置对象时,参数超范围",
SyntaxError: "语法错误",
EvalError: "错误的使用了Eval",
URIError: "URI错误"
};
let errorName = errorMap[error.name] || "未知错误";
console.log("%c" + "====================================================", "color: red");
console.error("O(∩_∩)O哈哈~,菜鸡又,又报错啦!!!");
console.error(errorName + ":", error);
console.log("%c" + "====================================================", "color: red");
const NODE_ENV: string = import.meta.env.MODE as string;
console.log(NODE_ENV);
if (NODE_ENV === "development") {
ElNotification({
title: errorName,
message: error,
type: "error",
duration: 3000
});
}
};
export default errorHandler;

338
src/utils/index.ts Normal file
View File

@@ -0,0 +1,338 @@
import { isArray } from "@/utils/is";
import { FieldNamesProps } from "@/components/ProTable/interface";
//import { cloneDeep } from "lodash-es";
/**
* @description 获取localStorage
* @param {String} key Storage名称
* @returns {String}
*/
export function localGet(key: string) {
const value = window.localStorage.getItem(key);
try {
return JSON.parse(window.localStorage.getItem(key) as string);
} catch (error) {
return value;
}
}
/**
* @description 存储localStorage
* @param {String} key Storage名称
* @param {*} value Storage值
* @returns {void}
*/
export function localSet(key: string, value: any) {
window.localStorage.setItem(key, JSON.stringify(value));
}
/**
* @description 清除localStorage
* @param {String} key Storage名称
* @returns {void}
*/
export function localRemove(key: string) {
window.localStorage.removeItem(key);
}
/**
* @description 清除所有localStorage
* @returns {void}
*/
export function localClear() {
window.localStorage.clear();
}
/**
* @description 判断数据类型
* @param {*} val 需要判断类型的数据
* @returns {String}
*/
export function isType(val: any) {
if (val === null) return "null";
if (typeof val !== "object") return typeof val;
else return Object.prototype.toString.call(val).slice(8, -1).toLocaleLowerCase();
}
/**
* @description 生成唯一 uuid
* @returns {String}
*/
export function generateUUID() {
let uuid = "";
for (let i = 0; i < 32; i++) {
let random = (Math.random() * 16) | 0;
if (i === 8 || i === 12 || i === 16 || i === 20) uuid += "-";
uuid += (i === 12 ? 4 : i === 16 ? (random & 3) | 8 : random).toString(16);
}
return uuid;
}
/**
* 判断两个对象是否相同
* @param {Object} a 要比较的对象一
* @param {Object} b 要比较的对象二
* @returns {Boolean} 相同返回 true反之 false
*/
export function isObjectValueEqual(a: { [key: string]: any }, b: { [key: string]: any }) {
if (!a || !b) return false;
let aProps = Object.getOwnPropertyNames(a);
let bProps = Object.getOwnPropertyNames(b);
if (aProps.length != bProps.length) return false;
for (let i = 0; i < aProps.length; i++) {
let propName = aProps[i];
let propA = a[propName];
let propB = b[propName];
if (!b.hasOwnProperty(propName)) return false;
if (propA instanceof Object) {
if (!isObjectValueEqual(propA, propB)) return false;
} else if (propA !== propB) {
return false;
}
}
return true;
}
/**
* @description 生成随机数
* @param {Number} min 最小值
* @param {Number} max 最大值
* @returns {Number}
*/
export function randomNum(min: number, max: number): number {
let num = Math.floor(Math.random() * (min - max) + max);
return num;
}
/**
* @description 获取当前时间对应的提示语
* @returns {String}
*/
export function getTimeState() {
let timeNow = new Date();
let hours = timeNow.getHours();
if (hours >= 6 && hours <= 10) return `早上好 ⛅`;
if (hours >= 10 && hours <= 14) return `中午好 🌞`;
if (hours >= 14 && hours <= 18) return `下午好 🌞`;
if (hours >= 18 && hours <= 24) return `晚上好 🌛`;
if (hours >= 0 && hours <= 6) return `凌晨好 🌛`;
}
/**
* @description 获取浏览器默认语言
* @returns {String}
*/
export function getBrowserLang() {
let browserLang = navigator.language ? navigator.language : navigator.browserLanguage;
let defaultBrowserLang = "";
if (["cn", "zh", "zh-cn"].includes(browserLang.toLowerCase())) {
defaultBrowserLang = "zh";
} else {
defaultBrowserLang = "en";
}
return defaultBrowserLang;
}
/**
* @description 使用递归扁平化菜单,方便添加动态路由
* @param {Array} menuList 菜单列表
* @returns {Array}
*/
export function getFlatMenuList(menuList: Menu.MenuOptions[]): Menu.MenuOptions[] {
let newMenuList: Menu.MenuOptions[] = JSON.parse(JSON.stringify(menuList));
return newMenuList.flatMap(item => [item, ...(item.children ? getFlatMenuList(item.children) : [])]);
}
/**
* @description 使用递归过滤出需要渲染在左侧菜单的列表 (需剔除 hidden == false 的菜单)
* @param {Array} menuList 菜单列表
* @returns {Array}
* */
export function getShowMenuList(menuList: Menu.MenuOptions[]) {
let newMenuList: Menu.MenuOptions[] = JSON.parse(JSON.stringify(menuList));
return newMenuList.filter(item => {
item.children?.length && (item.children = getShowMenuList(item.children));
return item?.hidden;
});
}
/**
* @description 使用递归找出所有面包屑存储到 pinia/vuex 中
* @param {Array} menuList 菜单列表
* @param {Array} parent 父级菜单
* @param {Object} result 处理后的结果
* @returns {Object}
*/
export const getAllBreadcrumbList = (menuList: Menu.MenuOptions[], parent = [], result: { [key: string]: any } = {}) => {
for (const item of menuList) {
result[item.path] = [...parent, item];
if (item.children) getAllBreadcrumbList(item.children, result[item.path], result);
}
return result;
};
/**
* @description 使用递归处理路由菜单 path生成一维数组 (第一版本地路由鉴权会用到,该函数暂未使用)
* @param {Array} menuList 所有菜单列表
* @param {Array} menuPathArr 菜单地址的一维数组 ['**','**']
* @returns {Array}
*/
export function getMenuListPath(menuList: Menu.MenuOptions[], menuPathArr: string[] = []): string[] {
for (const item of menuList) {
if (typeof item === "object" && item.path) menuPathArr.push(item.path);
if (item.children?.length) getMenuListPath(item.children, menuPathArr);
}
return menuPathArr;
}
/**
* @description 递归查询当前 path 所对应的菜单对象 (该函数暂未使用)
* @param {Array} menuList 菜单列表
* @param {String} path 当前访问地址
* @returns {Object | null}
*/
export function findMenuByPath(menuList: Menu.MenuOptions[], path: string): Menu.MenuOptions | null {
for (const item of menuList) {
if (item.path === path) return item;
if (item.children) {
const res = findMenuByPath(item.children, path);
if (res) return res;
}
}
return null;
}
export function setKeeAliveRoute(menuList: any[]) {
menuList.forEach(item => {
if (item.title !== "导出") {
item.meta.isKeepAlive = true;
if (item?.children && item?.children.length) {
setKeeAliveRoute(item?.children);
}
}
});
return menuList;
}
/**
* @description 使用递归过滤需要缓存的菜单 name (该函数暂未使用)
* @param {Array} menuList 所有菜单列表
* @param {Array} keepAliveNameArr 缓存的菜单 name ['**','**']
* @returns {Array}
* */
export function getKeepAliveRouterName(menuList: Menu.MenuOptions[], keepAliveNameArr: string[] = []) {
menuList.forEach(item => {
item.meta.isKeepAlive && item.name && keepAliveNameArr.push(item.name);
item.children?.length && getKeepAliveRouterName(item.children, keepAliveNameArr);
});
return keepAliveNameArr;
}
// 递归提取所有按钮权限
export const extractButtonPermissions: any = (routes: any[], permissionMap: any = {}): any => {
routes.forEach(route => {
// type: 0 表示是按钮权限
if (route.type === 0 && route.name) {
permissionMap[route.name] = true;
}
// 递归处理子路由
if (route.children && route.children.length > 0) {
extractButtonPermissions(route.children, permissionMap);
}
});
return permissionMap;
};
// 检查是否有权限
export const hasPermission = (permissionMap: any, permissionName: string | string[]): boolean => {
if (Array.isArray(permissionName)) {
// 多个权限满足一个即可
return permissionName.some(name => permissionMap[name]);
}
// 单个权限检查
return !!permissionMap[permissionName];
};
/**
* @description 格式化表格单元格默认值 (el-table-column)
* @param {Number} row 行
* @param {Number} col 列
* @param {*} callValue 当前单元格值
* @returns {String}
* */
export function formatTableColumn(row: number, col: number, callValue: any) {
// 如果当前值为数组,使用 / 拼接(根据需求自定义)
if (isArray(callValue)) return callValue.length ? callValue.join(" / ") : "--";
return callValue ? callValue : "--";
}
/**
* @description 处理值无数据情况
* @param {*} callValue 需要处理的值
* @returns {String}
* */
export function formatValue(callValue: any) {
// 如果当前值为数组,使用 / 拼接(根据需求自定义)
if (isArray(callValue)) return callValue.length ? callValue.join(" / ") : "--";
return callValue ? callValue : "--";
}
/**
* @description 处理 prop 为多级嵌套的情况,返回的数据 (列如: prop: user.name)
* @param {Object} row 当前行数据
* @param {String} prop 当前 prop
* @returns {*}
* */
export function handleRowAccordingToProp(row: { [key: string]: any }, prop: string) {
if (!prop.includes(".")) return row[prop] ?? "--";
prop.split(".").forEach(item => (row = row[item] ?? "--"));
return row;
}
/**
* @description 处理 prop当 prop 为多级嵌套时 ==> 返回最后一级 prop
* @param {String} prop 当前 prop
* @returns {String}
* */
export function handleProp(prop: string) {
const propArr = prop.split(".");
if (propArr.length == 1) return prop;
return propArr[propArr.length - 1];
}
/**
* @description 根据枚举列表查询当需要的数据(如果指定了 label 和 value 的 key值会自动识别格式化
* @param {String} callValue 当前单元格值
* @param {Array} enumData 字典列表
* @param {Array} fieldNames label && value && children 的 key 值
* @param {String} type 过滤类型(目前只有 tag
* @returns {String}
* */
export function filterEnum(callValue: any, enumData?: any, fieldNames?: FieldNamesProps, type?: "tag") {
const value = fieldNames?.value ?? "value";
const label = fieldNames?.label ?? "label";
const children = fieldNames?.children ?? "children";
let filterData: { [key: string]: any } = {};
// 判断 enumData 是否为数组
if (Array.isArray(enumData)) filterData = findItemNested(enumData, callValue, value, children);
// 判断是否输出的结果为 tag 类型
if (type == "tag") {
return filterData?.tagType ? filterData.tagType : "";
} else {
return filterData ? filterData[label] : "--";
}
}
/**
* @description 递归查找 callValue 对应的 enum 值
* */
export function findItemNested(enumData: any, callValue: any, value: string, children: string) {
return enumData.reduce((accumulator: any, current: any) => {
if (accumulator) return accumulator;
if (current[value] === callValue) return current;
if (current[children]) return findItemNested(current[children], callValue, value, children);
}, null);
}

125
src/utils/is/index.ts Normal file
View File

@@ -0,0 +1,125 @@
/**
* @description: 判断值是否未某个类型
*/
export function is(val: unknown, type: string) {
return Object.prototype.toString.call(val) === `[object ${type}]`;
}
/**
* @description: 是否为函数
*/
export function isFunction<T = Function>(val: unknown): val is T {
return is(val, "Function");
}
/**
* @description: 是否已定义
*/
export const isDef = <T = unknown>(val?: T): val is T => {
return typeof val !== "undefined";
};
/**
* @description: 是否未定义
*/
export const isUnDef = <T = unknown>(val?: T): val is T => {
return !isDef(val);
};
/**
* @description: 是否为对象
*/
export const isObject = (val: any): val is Record<any, any> => {
return val !== null && is(val, "Object");
};
/**
* @description: 是否为时间
*/
export function isDate(val: unknown): val is Date {
return is(val, "Date");
}
/**
* @description: 是否为数值
*/
export function isNumber(val: unknown): val is number {
return is(val, "Number");
}
/**
* @description: 是否为AsyncFunction
*/
export function isAsyncFunction<T = any>(val: unknown): val is Promise<T> {
return is(val, "AsyncFunction");
}
/**
* @description: 是否为promise
*/
export function isPromise<T = any>(val: unknown): val is Promise<T> {
return is(val, "Promise") && isObject(val) && isFunction(val.then) && isFunction(val.catch);
}
/**
* @description: 是否为字符串
*/
export function isString(val: unknown): val is string {
return is(val, "String");
}
/**
* @description: 是否为boolean类型
*/
export function isBoolean(val: unknown): val is boolean {
return is(val, "Boolean");
}
/**
* @description: 是否为数组
*/
export function isArray(val: any): val is Array<any> {
return val && Array.isArray(val);
}
/**
* @description: 是否客户端
*/
export const isClient = () => {
return typeof window !== "undefined";
};
/**
* @description: 是否为浏览器
*/
export const isWindow = (val: any): val is Window => {
return typeof window !== "undefined" && is(val, "Window");
};
/**
* @description: 是否为 element 元素
*/
export const isElement = (val: unknown): val is Element => {
return isObject(val) && !!val.tagName;
};
/**
* @description: 是否为 null
*/
export function isNull(val: unknown): val is null {
return val === null;
}
/**
* @description: 是否为 null || undefined
*/
export function isNullOrUnDef(val: unknown): val is null | undefined {
return isUnDef(val) || isNull(val);
}
/**
* @description: 是否为 16 进制颜色
*/
export const isHexColor = (str: string) => {
return /^#?([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(str);
};

5
src/utils/mittBus.ts Normal file
View File

@@ -0,0 +1,5 @@
import mitt from "mitt";
const $Bus = mitt();
export default $Bus;

View File

@@ -0,0 +1,9 @@
//只允许输入CTN开头并且CTN后面只能跟数字
export const boxCodeCtn = (target: any) => {
console.log(target.length);
return target.replace(/[^C|c|T|t|N|n]/g, "");
if ((target.length === 1 && target !== "c") || target !== "C") {
console.log("123232323");
return "";
}
};

View File

@@ -0,0 +1,7 @@
import { cloneDeep } from "lodash-es";
//将中文逗号(,)和分号(;)替换为英文逗号(,)
export const convertSeparators = (str: string) => {
let strClone = cloneDeep(str);
return strClone.replace(//g, ",");
};

View File

@@ -0,0 +1,8 @@
import { inputEnterRexg } from "./inputEnterRexg";
import { numberRexg } from "./numberRexg";
import { productRexg } from "./productRexg";
import { integerRexg } from "./integerRexg";
import { unitMultipleInputRexg } from "./unitMultipleInputRexg";
import { numberRexg1 } from "./numberRexg1";
import { numberDecimalSeparatorRexg } from "./numberDecimalSeparatorRexg";
export { numberRexg, inputEnterRexg, productRexg, integerRexg, unitMultipleInputRexg, numberRexg1, numberDecimalSeparatorRexg };

View File

@@ -0,0 +1,26 @@
import { useMsg } from "@/hooks/useMsg";
//只允许输入数字和6位小数
export const inputEnterRexg = function (inputValue: any, empty?: any) {
inputValue = inputValue.replace(/[^\d.]/g, ""); // 清除"数字"和"."以外的字符 只能输入数字和小数点
inputValue = inputValue.replace(/\.{2,}/g, "."); // 不能连续输入两个及以上小数点
inputValue = inputValue.replace(".", "$#$").replace(/\./g, "").replace("$#$", "."); // 只保留第一个".", 清除多余的"."
inputValue = inputValue.replace(/^(-)*(\d+)\.(\d\d\d\d\d\d).*$/, "$1$2.$3"); // 只能输入六位小数
if (inputValue && inputValue.indexOf(".") < 0 && inputValue != "") {
inputValue = parseFloat(inputValue);
inputValue = inputValue + "";
inputValue = inputValue.slice(0, 8);
} // 如果没有小数点,首位不能为类似于 01、02的值
// 输入过程中只能输入六位小数且六位小数都为零则清空小数点和后面的六个零如果输入完成了只输入四个零则在blur事件中处理
if (inputValue.indexOf(".") > 0 && inputValue.length - inputValue.indexOf(".") > 6) {
let str = inputValue.slice(inputValue.indexOf("."), inputValue.length);
if (str / 1 <= 0) {
inputValue = inputValue.replace(str, "");
}
}
if (inputValue.length > 15) {
useMsg("warning", "仅限数字输入小数点后最多6位小数点前最多8位,请重新输入");
return empty ? "" : 0;
} else {
return inputValue;
}
};

View File

@@ -0,0 +1,3 @@
export const integer = (target: any) => {
return target.replace(/[^1-9]/g, "");
};

View File

@@ -0,0 +1,6 @@
export const integerNumber = (target: any) => {
if (!target) {
return target;
}
return target.replace(/[^0-9]/g, "");
};

View File

@@ -0,0 +1,8 @@
//只允许输入整数
export const integerRexg = (value: any) => {
if (!value) {
return;
}
let result = value.replace(/^(0+)|[^\d]+/g, "");
return result;
};

View File

@@ -0,0 +1,11 @@
//只允许输入数字和小数点
export const numberDecimalSeparatorRexg = (value: any) => {
if (!value) {
return;
}
value = value.replace(/[^\d.]/g, ""); // 清除"数字"和"."以外的字符 只能输入数字和小数点
value = value.replace(/\.{2,}/g, "."); // 不能连续输入两个及以上小数点
value = value.replace(".", "$#$").replace(/\./g, "").replace("$#$", "."); // 只保留第一个".", 清除多余的"."
return value;
};

View File

@@ -0,0 +1,18 @@
// 数字验证小数点前8位&小数点后4位
export const numberRexg = (value: any) => {
if (value) {
if (value.toString().indexOf(".") != -1) {
let value_after = parseInt(value.toString().substring(0, value.indexOf(".")));
let value_before = value.replace(/\d+\.(\d*)/, "$1");
if (value_after.toString().length > 8) {
let newValue = value_after.toString().substring(0, 8) + "." + value_before;
return (newValue.toString().match(/\d{1,8}(\.\d{0,4})?/) || [""])[0];
} else {
return (value.toString().match(/\d{1,8}(\.\d{0,4})?/) || [""])[0];
}
}
return (value.toString().match(/\d{1,8}(\.\d{0,4})?/) || [""])[0];
} else {
return "";
}
};

View File

@@ -0,0 +1,17 @@
//前3后4
export const numberRexg1 = (value: any) => {
if (!value) {
return;
}
if (value.toString().indexOf(".") != -1) {
let value_after = parseInt(value.toString().substring(0, value.indexOf(".")));
let value_before = value.replace(/\d+\.(\d*)/, "$1");
if (value_after.toString().length > 3) {
let newValue = value_after.toString().substring(0, 3) + "." + value_before;
return (newValue.toString().match(/\d{1,3}(\.\d{0,4})?/) || [""])[0];
} else {
return (value.toString().match(/\d{1,3}(\.\d{0,4})?/) || [""])[0];
}
}
return (value.toString().match(/\d{1,3}(\.\d{0,4})?/) || [""])[0];
};

View File

@@ -0,0 +1,17 @@
//尺寸/质量信息输入验证
export const productRexg = (value: any) => {
if (!value) {
return;
}
let result = value
.toString()
.replace(/^0/)
.replace(/[^\d.]/g, "")
.replace(/\.{2,}/g, ".")
.replace(/^\./g, "")
.replace(".", "$#$")
.replace(/\./g, "")
.replace("$#$", ".")
.replace(/^(-)*(\d+)\.(\d\d\d\d).*$/, "$1$2.$3");
return result;
};

View File

@@ -0,0 +1,9 @@
import { cloneDeep } from "lodash-es";
//去除所有空格
export const removeSpaces = (str: any) => {
let strClone = cloneDeep(str);
if (Array.isArray(strClone) && strClone.length) {
strClone = strClone.join("");
}
return strClone.replace(/\s+/g, "");
};

View File

@@ -0,0 +1,13 @@
export const unitMultipleInputRexg = (value: any) => {
if (!value) {
return;
}
let result = value
.toString()
.replace(/[^\d^\\.]+/g, "")
.replace(".", "$#$")
.replace(/\./g, "")
.replace("$#$", ".")
.replace(/^(\\-)*(\d+)\.(\d\d\d\d\d\d\d\d).*$/, "$1$2.$3");
return result;
};

17
src/utils/serviceDict.ts Normal file
View File

@@ -0,0 +1,17 @@
// ? 系统全局字典
/**
* @description用户性别
*/
export const genderType = [
{ label: "男", value: 1 },
{ label: "女", value: 2 }
];
/**
* @description用户状态
*/
export const userStatus = [
{ label: "启用", value: 1 },
{ label: "禁用", value: 0 }
];

13
src/utils/svg.ts Normal file
View File

@@ -0,0 +1,13 @@
/**
* @description Loading Svg
*/
export const loadingSvg = `
<path class="path" d="
M 30 15
L 28 17
M 25.61 25.61
A 15 15, 0, 0, 1, 15 30
A 15 15, 0, 1, 1, 27.99 7.5
L 15 15
" style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
`;