|
@@ -352,6 +352,57 @@ const XML_EXPORT_BASE = (() => {
|
|
|
}
|
|
}
|
|
|
return '';
|
|
return '';
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 随机生成机器信息码:CPU信息;硬盘序列号;mac地址;
|
|
|
|
|
+ // 保存在localStorage中
|
|
|
|
|
+ function generateHardwareId() {
|
|
|
|
|
+ const hardwareCacheId = window.localStorage.getItem('hardwareId');
|
|
|
|
|
+ if (hardwareCacheId) {
|
|
|
|
|
+ return hardwareCacheId;
|
|
|
|
|
+ }
|
|
|
|
|
+ const charList = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D',
|
|
|
|
|
+ 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U',
|
|
|
|
|
+ 'V', 'W', 'X', 'Y', 'Z'];
|
|
|
|
|
+ function generateCpuId() {
|
|
|
|
|
+ let id = '';
|
|
|
|
|
+ let count = 16;
|
|
|
|
|
+ while (count--) {
|
|
|
|
|
+ const randomIdx = parseInt(Math.random() * 16);
|
|
|
|
|
+ id += charList[randomIdx];
|
|
|
|
|
+ }
|
|
|
|
|
+ return id;
|
|
|
|
|
+ }
|
|
|
|
|
+ function generateDiskId() {
|
|
|
|
|
+ let id = '';
|
|
|
|
|
+ let count = 8;
|
|
|
|
|
+ while (count--) {
|
|
|
|
|
+ const randomIdx = parseInt(Math.random() * 36);
|
|
|
|
|
+ id += charList[randomIdx];
|
|
|
|
|
+ }
|
|
|
|
|
+ return id;
|
|
|
|
|
+ }
|
|
|
|
|
+ function generateMacId() {
|
|
|
|
|
+ const idList = [];
|
|
|
|
|
+ let outerCount = 6;
|
|
|
|
|
+ while (outerCount--) {
|
|
|
|
|
+ let tempId = '';
|
|
|
|
|
+ let innerCount = 2;
|
|
|
|
|
+ while (innerCount--) {
|
|
|
|
|
+ const randomIdx = parseInt(Math.random() * 16);
|
|
|
|
|
+ tempId += charList[randomIdx];
|
|
|
|
|
+ }
|
|
|
|
|
+ idList.push(tempId);
|
|
|
|
|
+ }
|
|
|
|
|
+ return idList.join('-');
|
|
|
|
|
+ }
|
|
|
|
|
+ const cpuId = generateCpuId();
|
|
|
|
|
+ const diskId = generateDiskId();
|
|
|
|
|
+ const macId = generateMacId();
|
|
|
|
|
+ const hardwareId = [cpuId, diskId, macId].join(';');
|
|
|
|
|
+ window.localStorage.setItem('hardwareId', hardwareId);
|
|
|
|
|
+ return hardwareId;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 数组打平成对象
|
|
// 数组打平成对象
|
|
|
function arrayToObj(arr) {
|
|
function arrayToObj(arr) {
|
|
|
let rst = {};
|
|
let rst = {};
|
|
@@ -680,6 +731,7 @@ const XML_EXPORT_BASE = (() => {
|
|
|
setTimeoutSync,
|
|
setTimeoutSync,
|
|
|
getFee,
|
|
getFee,
|
|
|
getValueByKey,
|
|
getValueByKey,
|
|
|
|
|
+ generateHardwareId,
|
|
|
arrayToObj,
|
|
arrayToObj,
|
|
|
validDepth,
|
|
validDepth,
|
|
|
checkUnique,
|
|
checkUnique,
|