mirror of
https://github.com/NaiboWang/EasySpider.git
synced 2025-04-20 04:39:57 +08:00
78 lines
2.3 KiB
JavaScript
78 lines
2.3 KiB
JavaScript
// function isExtract() { //检测当前锚点之前的元素是否为提取数据字段
|
||
// if (app.$data.nowArrow["position"] == -1) {
|
||
// return false;
|
||
// } else if (nodeList[nodeList[app.$data.nowArrow["pId"]].sequence[app.$data.nowArrow["position"]]]["option"] == 3) {
|
||
// return true;
|
||
// } else {
|
||
// return false;
|
||
// }
|
||
// }
|
||
|
||
function DateFormat(datetime) {
|
||
let date = new Date(datetime);
|
||
|
||
// Format the date and time
|
||
let formatted = date.getFullYear() +
|
||
'-' + String(date.getMonth() + 1).padStart(2, '0') +
|
||
'-' + String(date.getDate()).padStart(2, '0') +
|
||
' ' + String(date.getHours()).padStart(2, '0') +
|
||
':' + String(date.getMinutes()).padStart(2, '0') +
|
||
':' + String(date.getSeconds()).padStart(2, '0');
|
||
return formatted;
|
||
}
|
||
|
||
function getUrlParam(name) {
|
||
let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
|
||
let r = window.location.search.substr(1).match(reg); //匹配目标参数
|
||
if (r != null) return unescape(r[2]);
|
||
return ""; //返回参数值,默认后台地址
|
||
}
|
||
|
||
// 判断字符串中英文字符的个数哪个多
|
||
function detectLang(str) {
|
||
let enCount = 0;
|
||
let cnCount = 0;
|
||
|
||
for (let i = 0; i < str.length; i++) {
|
||
const charCode = str.charCodeAt(i);
|
||
if ((charCode >= 0x0000) && (charCode <= 0x007F)) {
|
||
enCount += 1;
|
||
} else if ((charCode >= 0x4E00) && (charCode <= 0x9FA5)) {
|
||
cnCount += 1;
|
||
}
|
||
}
|
||
|
||
if (enCount === cnCount) {
|
||
return 2;
|
||
} else if (enCount > cnCount) {
|
||
return 0;
|
||
}
|
||
return 1;
|
||
}
|
||
|
||
Vue.filter('lang', function (value) {
|
||
let value1 = value.split("~")[0];
|
||
let value2 = value.split("~")[1];
|
||
let value_zh = "";
|
||
let value_en = "";
|
||
if (detectLang(value1) == 1) {
|
||
value_zh = value1;
|
||
value_en = value2;
|
||
} else {
|
||
value_zh = value2;
|
||
value_en = value1;
|
||
}
|
||
if (getUrlParam("lang") == "zh") {
|
||
return value_zh;
|
||
} else {
|
||
return value_en;
|
||
}
|
||
})
|
||
|
||
function isValidMySQLTableName(tableName) {
|
||
// 正则表达式:以字母或汉字开头,后接字母、数字、下划线或汉字的字符串,长度为1到64字符
|
||
const pattern = /^[\u4e00-\u9fa5a-zA-Z][\u4e00-\u9fa5a-zA-Z0-9_]{0,63}$/;
|
||
return pattern.test(tableName);
|
||
}
|
||
|