This commit is contained in:
X1627315083
2024-01-15 13:20:53 +08:00
parent 3b839bcb44
commit 2fca178eeb
9 changed files with 302 additions and 131 deletions

23
package-lock.json generated
View File

@@ -10,12 +10,14 @@
"dependencies": { "dependencies": {
"@ans1998/vue3-color": "^3.0.7", "@ans1998/vue3-color": "^3.0.7",
"@flaticon/flaticon-uicons": "^2.3.0", "@flaticon/flaticon-uicons": "^2.3.0",
"@types/fingerprintjs2": "^2.0.0",
"ant-design-vue": "^3.2.12", "ant-design-vue": "^3.2.12",
"axios": "^1.4.0", "axios": "^1.4.0",
"core-js": "^3.8.3", "core-js": "^3.8.3",
"driver.js": "^1.3.1", "driver.js": "^1.3.1",
"element-plus": "^2.4.2", "element-plus": "^2.4.2",
"file-saver": "^2.0.5", "file-saver": "^2.0.5",
"fingerprintjs2": "^2.1.4",
"html2canvas": "^1.4.1", "html2canvas": "^1.4.1",
"jszip": "^3.10.1", "jszip": "^3.10.1",
"md5": "^2.3.0", "md5": "^2.3.0",
@@ -2304,6 +2306,11 @@
"@types/range-parser": "*" "@types/range-parser": "*"
} }
}, },
"node_modules/@types/fingerprintjs2": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@types/fingerprintjs2/-/fingerprintjs2-2.0.0.tgz",
"integrity": "sha512-isSTwNnW5I6zGZnpkinmVcV9pJqr7cLELns+tXDYzskIOAb2J+iCQ0mQJ9bRjHJhZfdlTFXZoCYK9ZgT3oMWXQ=="
},
"node_modules/@types/html-minifier-terser": { "node_modules/@types/html-minifier-terser": {
"version": "6.1.0", "version": "6.1.0",
"resolved": "https://registry.npmmirror.com/@types/html-minifier-terser/-/html-minifier-terser-6.1.0.tgz", "resolved": "https://registry.npmmirror.com/@types/html-minifier-terser/-/html-minifier-terser-6.1.0.tgz",
@@ -6515,6 +6522,12 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/fingerprintjs2": {
"version": "2.1.4",
"resolved": "https://registry.npmjs.org/fingerprintjs2/-/fingerprintjs2-2.1.4.tgz",
"integrity": "sha512-veP2yVsnYvjDVkzZMyIEwpqCAQfsBLH+U4PK5MlFAnLjZrttbdRqEArE1fPcnJFz5oS5CrdONbsV7J6FGpIJEQ==",
"deprecated": "Package has been renamed to @fingerprintjs/fingerprintjs. Install @fingerprintjs/fingerprintjs to get updates."
},
"node_modules/flat-cache": { "node_modules/flat-cache": {
"version": "3.0.4", "version": "3.0.4",
"resolved": "https://registry.npmmirror.com/flat-cache/-/flat-cache-3.0.4.tgz", "resolved": "https://registry.npmmirror.com/flat-cache/-/flat-cache-3.0.4.tgz",
@@ -14057,6 +14070,11 @@
"@types/range-parser": "*" "@types/range-parser": "*"
} }
}, },
"@types/fingerprintjs2": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@types/fingerprintjs2/-/fingerprintjs2-2.0.0.tgz",
"integrity": "sha512-isSTwNnW5I6zGZnpkinmVcV9pJqr7cLELns+tXDYzskIOAb2J+iCQ0mQJ9bRjHJhZfdlTFXZoCYK9ZgT3oMWXQ=="
},
"@types/html-minifier-terser": { "@types/html-minifier-terser": {
"version": "6.1.0", "version": "6.1.0",
"resolved": "https://registry.npmmirror.com/@types/html-minifier-terser/-/html-minifier-terser-6.1.0.tgz", "resolved": "https://registry.npmmirror.com/@types/html-minifier-terser/-/html-minifier-terser-6.1.0.tgz",
@@ -17428,6 +17446,11 @@
"path-exists": "^4.0.0" "path-exists": "^4.0.0"
} }
}, },
"fingerprintjs2": {
"version": "2.1.4",
"resolved": "https://registry.npmjs.org/fingerprintjs2/-/fingerprintjs2-2.1.4.tgz",
"integrity": "sha512-veP2yVsnYvjDVkzZMyIEwpqCAQfsBLH+U4PK5MlFAnLjZrttbdRqEArE1fPcnJFz5oS5CrdONbsV7J6FGpIJEQ=="
},
"flat-cache": { "flat-cache": {
"version": "3.0.4", "version": "3.0.4",
"resolved": "https://registry.npmmirror.com/flat-cache/-/flat-cache-3.0.4.tgz", "resolved": "https://registry.npmmirror.com/flat-cache/-/flat-cache-3.0.4.tgz",

View File

@@ -12,12 +12,14 @@
"dependencies": { "dependencies": {
"@ans1998/vue3-color": "^3.0.7", "@ans1998/vue3-color": "^3.0.7",
"@flaticon/flaticon-uicons": "^2.3.0", "@flaticon/flaticon-uicons": "^2.3.0",
"@types/fingerprintjs2": "^2.0.0",
"ant-design-vue": "^3.2.12", "ant-design-vue": "^3.2.12",
"axios": "^1.4.0", "axios": "^1.4.0",
"core-js": "^3.8.3", "core-js": "^3.8.3",
"driver.js": "^1.3.1", "driver.js": "^1.3.1",
"element-plus": "^2.4.2", "element-plus": "^2.4.2",
"file-saver": "^2.0.5", "file-saver": "^2.0.5",
"fingerprintjs2": "^2.1.4",
"html2canvas": "^1.4.1", "html2canvas": "^1.4.1",
"jszip": "^3.10.1", "jszip": "^3.10.1",
"md5": "^2.3.0", "md5": "^2.3.0",

View File

@@ -13,10 +13,21 @@ import VueLazyload from "vue-lazyload";
import i18n from './lang/index' import i18n from './lang/index'
import GO from './tool/GO' import GO from './tool/GO'
import "../node_modules/@flaticon/flaticon-uicons/css/all/all.css" import "../node_modules/@flaticon/flaticon-uicons/css/all/all.css"
import Fingerprint2 from 'fingerprintjs2';//获取浏览器唯一标识
flexible() flexible()
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
// console.log(process.env) // console.log(process.env)
Fingerprint2.get(function(components) {
const values = components.map(function(component,index) {
if (index === 0) { //把微信浏览器里UA的wifi或4G等网络替换成空,不然切换网络会ID不一样
return component.value.replace(/\bNetType\/\w+\b/, '')
}
return component.value
})
// 生成最终id murmur
const murmur = Fingerprint2.x64hash128(values.join(''), 31);
console.log('浏览器指纹码:'+murmur )
})
let loadingParam = { let loadingParam = {
loading: require('./assets/images/homePage/loading.gif'), loading: require('./assets/images/homePage/loading.gif'),
attempt: 1 attempt: 1

View File

@@ -44,6 +44,11 @@ const routes: Array<RouteRecordRaw> = [
name: 'trialApproval', name: 'trialApproval',
component: _import('trialApproval') component: _import('trialApproval')
}, },
{
path: '/setIdentification',
name: 'setIdentification',
component: _import('setIdentification')
},
] ]
const router = createRouter({ const router = createRouter({

View File

@@ -1,7 +1,7 @@
const setCookie = (name,value) => { const setCookie = (name,value) => {
var Days = 30; var Days = 30;
var exp = new Date(); var exp = new Date();
exp.setTime(exp.getTime() + Days*24*60*60*30); exp.setTime(exp.getTime() + Days*24*60*60*1000);
document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString(); document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
} }

View File

@@ -80,7 +80,7 @@ axios.interceptors.response.use((res) =>{
} }
}, function(error) { }, function(error) {
if(error?.response?.status === 401){ if(error?.response?.status === 401&&router.currentRoute._value.name != 'setIdentification'){//如果是记录浏览器页面就不跳转login
router.replace('/login') router.replace('/login')
return Promise.reject() return Promise.reject()
} }
@@ -89,7 +89,6 @@ axios.interceptors.response.use((res) =>{
return Promise.reject(data_new); return Promise.reject(data_new);
}); });
export const Https = { export const Https = {
httpUrls: { httpUrls: {
interfaceUrl: '', interfaceUrl: '',

View File

@@ -155,7 +155,33 @@ const isMoible = () => {
} }
function getBrowserInfo() {//获取是什么浏览器
var agent = navigator.userAgent.toLowerCase();
var userAgent = navigator.userAgent;
var regStr_ie = /msie [\d.]+;/gi;
var regStr_ff = /firefox\/[\d.]+/gi
var regStr_chrome = /chrome\/[\d.]+/gi;
var regStr_saf = /safari\/[\d.]+/gi;
var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1; //判断是否IE<11浏览器
var isEdge = userAgent.indexOf("Edge") > -1 && !isIE; //判断是否IE的Edge浏览器
console.log(isIE,isEdge);
//IE
if (agent.indexOf("msie") > 0) {
return agent.match(regStr_ie);
}
//firefox
if (agent.indexOf("firefox") > 0) {
return agent.match(regStr_ff);
}
//Chrome
if (agent.indexOf("chrome") > 0) {
return agent.match(regStr_chrome);
}
//Safari
if (agent.indexOf("safari") > 0 && agent.indexOf("chrome") < 0) {
return agent.match(regStr_saf);
}
}
export { export {
isEmail, isEmail,
getUploadUrl, getUploadUrl,
@@ -167,4 +193,5 @@ export{
dataURLtoBlob, dataURLtoBlob,
isMoible, isMoible,
downloadIamge, downloadIamge,
getBrowserInfo,
} }

View File

@@ -463,6 +463,8 @@ export default defineComponent({
Https.axiosPost(Https.httpUrls.accountLogin, data).then( Https.axiosPost(Https.httpUrls.accountLogin, data).then(
(rv: any) => { (rv: any) => {
if (rv) { if (rv) {
console.log(rv);
this.createTimer(); this.createTimer();
let isTest = rv.isTrial == 1?true:false let isTest = rv.isTrial == 1?true:false
let isBeginner = rv.isBeginner == 1?true:false let isBeginner = rv.isBeginner == 1?true:false

View File

@@ -0,0 +1,102 @@
<template>
<div class="identification_page">
<div>密钥<input type="text" autofocus /></div>
<div class="button" @click="getFingerprint2">记录浏览器</div>
</div>
</template>
<script lang="ts">
import { defineComponent, ref, createVNode, computed } from "vue";
import { setCookie, getCookie, WriteCookie } from "@/tool/cookie";
import HeaderComponent from "@/component/HomePage/Header.vue";
import HistoryDetail from "@/component/Detail/HistoryDetail.vue";
import router from "@/router/index";
import { Https } from "@/tool/https";
import { formatTime, getBrowserInfo } from "@/tool/util";
import { Modal, message } from "ant-design-vue";
import RobotAssist from "@/component/HomePage/RobotAssist.vue";
import { ExclamationCircleOutlined } from "@ant-design/icons-vue";
import { useI18n } from "vue-i18n";
import Fingerprint2 from "fingerprintjs2"; //获取浏览器唯一标识
export default defineComponent({
components: {
HeaderComponent,
HistoryDetail,
RobotAssist,
},
setup() {
let collectionList: any = ref([]);
let userInfo: any = {};
let status: any = ref(0);
let voluntarily: any = ref(false);
return {
collectionList,
userInfo,
status,
voluntarily,
};
},
data() {
return {};
},
mounted() {
// this.userInfo = JSON.parse(getCookie("userInfo") as any);
// if (this.userInfo.userId == 83) {
// } else {
// router.replace("/home");
// return
// }
},
methods: {
async getFingerprint2() {
let murmur:any = ''
await new Promise((resolve,reject)=>{
Fingerprint2.get(function (components: any) {
const values = components.map(function (
component: any,
index: any
) {
if (index === 0) {
//把微信浏览器里UA的wifi或4G等网络替换成空,不然切换网络会ID不一样
return component.value.replace(/\bNetType\/\w+\b/, "");
}
return component.value;
});
// 生成最终id murmur
murmur = Fingerprint2.x64hash128(values.join(""), 31);
console.log("浏览器指纹码:" + murmur);
resolve('')
});
})
let data = {}
console.log(11);
// Https.axiosPost(Https.httpUrls.designSingle, data)
// .then((rv) => {
// // designItemDetail.clothes[index].printObject.path = rv.clothes[0].printObject.path
// })
// .catch((res) => {
// });
},
},
});
</script>
<style lang="less">
.identification_page {
margin-top: 200px;
display: flex;
flex-direction: column;
align-items: center;
input {
padding-left: 10px;
border: 2px solid rgba(0, 0, 0, 0.2);
border-radius: 10px;
}
.button {
margin-top: 20px;
border: 2px solid;
border-radius: 20px;
padding: 0 20px;
cursor: pointer;
}
}
</style>