优化设备控制,提交后,实时获取设备返回状态信息
This commit is contained in:
16
utils/function.js
Normal file
16
utils/function.js
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* 生成短ID (16位字符)
|
||||
*/
|
||||
export const generateShortId = () => {
|
||||
const crypto = window.crypto || window.msCrypto;
|
||||
|
||||
if (crypto?.getRandomValues) {
|
||||
return Array.from(crypto.getRandomValues(new Uint32Array(3)))
|
||||
.map(n => n.toString(36))
|
||||
.join('')
|
||||
.slice(0, 16);
|
||||
}
|
||||
|
||||
return Date.now().toString(36) + Math.random().toString(36).substr(2, 8);
|
||||
};
|
||||
export default generateShortId;
|
Reference in New Issue
Block a user