printCodes(mode,len){ // 1: "上单码模式", // 2: "下单码模式", // 3: "双码模式", // 4: "上2下1码模式", // 5: "上1下2码模式", // 6: "四码模式", let code = '' let start = Date.now() for(let i = len; i > 0; i--){ let code1 = `https://www.outside.com/${getUUID(18,10)}` let code2 = `${getUUID(5,61)}` let code3 = `https://www.inside.com/${getUUID(18,10)}` let code4 = `${getUUID(5,61)}` let currentCode = '' switch(mode){ case 1: let desc = i + '' currentCode = `${code1}\n` break; case 2: currentCode = `${code3}\n` break; case 3: currentCode = `${code1},${code3}\n` break; case 4: currentCode = `${code1}*${code2},${code3}\n` break; case 5: currentCode = `${code1},${code3}*${code4}\n` break; case 6: currentCode = `${code1}*${code2},${code3}*${code4}\n` break; } code += currentCode if(i % 1000 == 0){ writeLog(code.trim()) code = '' } if(code.trim() && i === 1){ writeLog(code.trim()) } } let dy = Date.now() - start writeLog(`${len}条数据,耗时:${dy}ms`) } getUUID(len, radix) { var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""); var uuid = []; var i; radix = radix || chars.length; if (len) { for (i = 0; i < len; i++) uuid[i] = chars[0 | (Math.random() * radix)]; } else { var r; uuid[8] = uuid[13] = uuid[18] = uuid[23] = "-"; uuid[14] = "4"; for (i = 0; i < 36; i++) { if (!uuid[i]) { r = 0 | (Math.random() * 16); uuid[i] = chars[i === 19 ? (r & 0x3) | 0x8 : r]; } } } return uuid.join(""); }
标签:code,uuid,写入,len,break,let,currentCode,txt,生码 From: https://www.cnblogs.com/daifuchao/p/18413403