|
|
@@ -1,3 +1,6 @@
|
|
|
+import Vue from 'vue'
|
|
|
+import FingerprintJS from '@fingerprintjs/fingerprintjs'
|
|
|
+
|
|
|
const USER_ACCESS_TOKEN = 'ACCESS-TOKEN'
|
|
|
const USER_REFRESH_TOKEN = 'REFRESH-TOKEN'
|
|
|
const USER_INFO = 'TNB-USERINFO'
|
|
|
@@ -95,3 +98,23 @@ export function removeAll() {
|
|
|
localStorage.removeItem(USER_REFRESH_TOKEN)
|
|
|
localStorage.removeItem(USER_INFO)
|
|
|
}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 浏览器指纹
|
|
|
+ */
|
|
|
+export async function getBrowserFingerprint() {
|
|
|
+ // 初始化FingerprintJS
|
|
|
+ const fp = await FingerprintJS.load()
|
|
|
+ // 获取访问者的指纹
|
|
|
+ const result = await fp.get()
|
|
|
+ const {
|
|
|
+ plugins,
|
|
|
+ ...components
|
|
|
+ } = result.components
|
|
|
+ const extendedComponents = {
|
|
|
+ ...components
|
|
|
+ }
|
|
|
+ // const deviceInfo = JSON.stringify(extendedComponents)
|
|
|
+ const fingerprintId = FingerprintJS.hashComponents(extendedComponents)
|
|
|
+ Vue.$cookies.set('fp', fingerprintId, -1)
|
|
|
+}
|