export const getQuery = (url) => { // str为?之后的参数部分字符串 const str = url.substr(url.indexOf('?') + 1) // arr每个元素都是完整的参数键值 const arr = str.split('&') // result为存储参数键值的集合 const result = {} for (let i = 0; i < arr.length; i++) { // item的两个元素分别为参数名和参数值 const item = arr[i].split('=') result[item[0]] = item[1] } return result } export function extractValuesFromString(inputString) { // 使用正则表达式来匹配 "&" 前面的 6 个字符和 "type" 及其值 const regex = /([^&]{6})&type=([^&]+)/; const matches = inputString.match(regex); if (matches) { const extractedValueBeforeAmpersand = matches[1]; const extractedType = matches[2]; return { value: `8b${extractedValueBeforeAmpersand}`, type: extractedType }; } return false; // 如果没有匹配,返回 null 或者其他适当的值 } // 定时器 export function waitByTime(settime = 100) { return new Promise((resolve) => { setTimeout(() => { resolve() }, settime) }) }