仓库地址:https://github.com/Valve/fingerprintjs2
安装
npm install fingerprintjs2 -S
示例
/**
* @method getFinger
* @description 获取匿名用户唯一标识
* @return {Promise} 用户指纹
*/
function getFinger () {
const Fingerprint2 = require('fingerprintjs2')
return new Promise(resolve => {
if (window.requestIdleCallback) {
requestIdleCallback(function () {
Fingerprint2.getV18(function (result) {
resolve(result)
})
})
} else {
setTimeout(function () {
Fingerprint2.getV18(function (result) {
resolve(result)
})
}, 500)
}
})
}
(async () => {
const f = await getFinger()
console.log('指纹: ', f) // 7592820773a07e4653af2b2515c83efd
})();
网友评论