function randomSessionId() {
let ua = new Uint8Array(20);
new DataView(ua.buffer).setUint32(0, Math.floor(+new Date() / 1000));
let crypto = window.crypto || window.msCrypto;
if (crypto) {
crypto.getRandomValues(ua.subarray(4, 20));
}
return (
"1." +
transformUint8ArrayToBase64(ua)
.replaceAll("+", "-")
.replaceAll("/", "_")
);
}
解决方法为:
function randomSessionId() {
let ua = new Uint8Array(20);
new DataView(ua.buffer).setUint32(0, Math.floor(+new Date() / 1000));
let crypto = window.crypto || window.msCrypto;
if (crypto) {
crypto.getRandomValues(ua.subarray(4, 20));
}
return (
"1." +
transformUint8ArrayToBase64(ua)
.replace(/\+/g, "-")
.replace(/\//g, "_")
);
}