|
@@ -1,3 +1,5 @@
|
|
|
|
|
+import { conforms } from "lodash";
|
|
|
|
|
+
|
|
|
export const calcDate = (date1, date2) => {
|
|
export const calcDate = (date1, date2) => {
|
|
|
let date3 = date2 - date1;
|
|
let date3 = date2 - date1;
|
|
|
|
|
|
|
@@ -204,6 +206,10 @@ export function getYearDate() {
|
|
|
const date = new Date();
|
|
const date = new Date();
|
|
|
return date.getFullYear()
|
|
return date.getFullYear()
|
|
|
}
|
|
}
|
|
|
|
|
+export function getMonthDate() {
|
|
|
|
|
+ const date = new Date();
|
|
|
|
|
+ return date.getMonth()+1
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 获取 n 天后的日期
|
|
* 获取 n 天后的日期
|
|
@@ -227,8 +233,50 @@ function addZero(num) {
|
|
|
}
|
|
}
|
|
|
return num;
|
|
return num;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+//验证英文
|
|
|
export function verifyEnglish(str) {
|
|
export function verifyEnglish(str) {
|
|
|
- const regex = /^[A-Za-z0-9\n .,!?:()|/+-_;'"$&@%*#]+$/;
|
|
|
|
|
- return regex.test(str?str:null);
|
|
|
|
|
|
|
+ const regex = /^[A-Za-z0-9\r\n .,!?:()|/+-_;'"$&@%*#]+$/;
|
|
|
|
|
+ return regex.test(str ? str : null);
|
|
|
|
|
+}
|
|
|
|
|
+//验证符号
|
|
|
|
|
+export function verifySymbol(str) {
|
|
|
|
|
+ const regex = /^[A-Za-z0-9\r\n .,!?:()|/+-_;'"$&@%*#]+$/;
|
|
|
|
|
+ return regex.test(str ? str : null);
|
|
|
}
|
|
}
|
|
|
|
|
+// 匹配常见全角符号的正则表达式(包括标点、字母、数字等)
|
|
|
|
|
+export function checkFullWidthSymbols(text) {
|
|
|
|
|
+ if (text) {
|
|
|
|
|
+ const fullWidthRegex = /[\u3000-\u303F\uFF01-\uFF5E\uFFE0-\uFFE5]/g;
|
|
|
|
|
+ const matchesItem = [];
|
|
|
|
|
+ let lines = text.split('\n')
|
|
|
|
|
+ let match;
|
|
|
|
|
+ lines.forEach((ln, index, array) => {
|
|
|
|
|
+ while ((match = fullWidthRegex.exec(ln)) !== null) {
|
|
|
|
|
+ matchesItem.push({
|
|
|
|
|
+ row: index + 1, // 行号
|
|
|
|
|
+ index: match.index, // 符号的位置
|
|
|
|
|
+ symbol: match[0] // 符号本身
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ let matches = [];
|
|
|
|
|
+ matches = matchesItem.reduce((acc, item) => {
|
|
|
|
|
+ const existingItem = acc.find(i => i.row === item.row);
|
|
|
|
|
+ if (existingItem) {
|
|
|
|
|
+ existingItem.symbol += ` ${item.symbol}`; // 合并值
|
|
|
|
|
+ } else {
|
|
|
|
|
+ acc.push({ ...item }); // 添加新项
|
|
|
|
|
+ }
|
|
|
|
|
+ return acc;
|
|
|
|
|
+ }, []);
|
|
|
|
|
+ return {
|
|
|
|
|
+ hasFullWidth: matches.length > 0, // 是否包含全角符号
|
|
|
|
|
+ positions: matches // 符号的详细位置和内容
|
|
|
|
|
+ };
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return {
|
|
|
|
|
+ hasFullWidth: false, // 是否包含全角符号
|
|
|
|
|
+ positions: [] // 符号的详细位置和内容
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+}
|