ua
Former-commit-id: febed2d1acecf257367a1686f38e15c243c03efa [formerly febed2d1acecf257367a1686f38e15c243c03efa [formerly febed2d1acecf257367a1686f38e15c243c03efa [formerly febed2d1acecf257367a1686f38e15c243c03efa [formerly c4c3d1f003ff78af77b81665e0d1348ea428dfab [formerly e4b1427e414700915452b62e0ebd52672ca3f040]]]]] Former-commit-id: e169aa76fb72163abe19183d517b91109fb4d613 Former-commit-id: e704e42ea987b65eaeea5f7d5199866f96771e9b Former-commit-id: aea5c30d34b1e614d6f974dd1146843fd2e9a5ab [formerly cb089b076728c3cf65bea25e88f4d77287884592] Former-commit-id: e325d443fd4eb2f011d5185cf201964a542ea190 Former-commit-id: d9da04c2f530ade77a00c0dc3fd938f8e0c2b4b2 Former-commit-id: c6514caa81e81291750100653548d8f333d3eb03 Former-commit-id: ea441446931522168551669865eb268a5b2aa900 Former-commit-id: 2dfd9e2c4bb020ce8ad3c0569e6acd591ef35be3
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import semver from 'semver'
|
import semver from 'semver'
|
||||||
import UaParser from 'ua-parser-js'
|
|
||||||
import { version } from '../../package.json'
|
import { version } from '../../package.json'
|
||||||
import log from './util.log.js'
|
import log from './util.log.js'
|
||||||
import cookies from './util.cookies.js'
|
import cookies from './util.cookies.js'
|
||||||
@@ -18,13 +17,6 @@ util.title = function (titleText) {
|
|||||||
window.document.title = `${process.env.VUE_APP_TITLE}${titleText ? ` | ${titleText}` : ''}`
|
window.document.title = `${process.env.VUE_APP_TITLE}${titleText ? ` | ${titleText}` : ''}`
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @description 获取所有的 UA 信息
|
|
||||||
*/
|
|
||||||
util.ua = function () {
|
|
||||||
return new UaParser().getResult()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 判断是否在其内
|
* @description 判断是否在其内
|
||||||
* @param {*} ele element
|
* @param {*} ele element
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ new Vue({
|
|||||||
// D2Admin 开发环境检查更新
|
// D2Admin 开发环境检查更新
|
||||||
util.checkUpdate(this)
|
util.checkUpdate(this)
|
||||||
// 获取并记录用户 UA
|
// 获取并记录用户 UA
|
||||||
this.$store.commit('d2admin/uaGet')
|
this.$store.commit('d2admin/ua/get')
|
||||||
// 展示系统信息
|
// 展示系统信息
|
||||||
util.showInfo()
|
util.showInfo()
|
||||||
// 用户登陆后从数据库加载一系列的设置
|
// 用户登陆后从数据库加载一系列的设置
|
||||||
|
|||||||
@@ -153,8 +153,7 @@ export default {
|
|||||||
'isGrayMode',
|
'isGrayMode',
|
||||||
'pagePool',
|
'pagePool',
|
||||||
'pageOpenedList',
|
'pageOpenedList',
|
||||||
'pageCurrent',
|
'pageCurrent'
|
||||||
'ua'
|
|
||||||
]),
|
]),
|
||||||
...mapGetters('d2admin', {
|
...mapGetters('d2admin', {
|
||||||
keepAliveInclude: 'keepAliveInclude',
|
keepAliveInclude: 'keepAliveInclude',
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<d2-container>
|
<d2-container>
|
||||||
<p class="d2-mt-0">useragent</p>
|
<p class="d2-mt-0">useragent</p>
|
||||||
<el-input :value="ua.ua"></el-input>
|
<el-input :value="uaData.ua"></el-input>
|
||||||
<p>格式化数据 in vuex: state.d2admin.ua</p>
|
<p>格式化数据 in vuex: state.d2admin.ua.data</p>
|
||||||
<d2-highlight :code="uaStr"/>
|
<d2-highlight :code="uaStr"/>
|
||||||
</d2-container>
|
</d2-container>
|
||||||
</template>
|
</template>
|
||||||
@@ -11,11 +11,11 @@
|
|||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
export default {
|
export default {
|
||||||
computed: {
|
computed: {
|
||||||
...mapState('d2admin', [
|
...mapState('d2admin/ua', {
|
||||||
'ua'
|
uaData: 'data'
|
||||||
]),
|
}),
|
||||||
uaStr () {
|
uaStr () {
|
||||||
const { browser, engine, os, device, cpu } = this.ua
|
const { browser, engine, os, device, cpu } = this.uaData
|
||||||
return JSON.stringify({ browser, engine, os, device, cpu }, null, 2)
|
return JSON.stringify({ browser, engine, os, device, cpu }, null, 2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
4d21835fa9e3352a4c11053634775c7e45774fae
|
33558b2365f6936e850cfc9012fbe3de139d35db
|
||||||
18
src/store/modules/d2admin/modules/ua.js
Normal file
18
src/store/modules/d2admin/modules/ua.js
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import UaParser from 'ua-parser-js'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
namespaced: true,
|
||||||
|
state: {
|
||||||
|
// 用户 UA
|
||||||
|
data: {}
|
||||||
|
},
|
||||||
|
mutations: {
|
||||||
|
/**
|
||||||
|
* @description 记录 UA
|
||||||
|
* @param {Object} state vuex state
|
||||||
|
*/
|
||||||
|
get (state) {
|
||||||
|
state.data = new UaParser().getResult()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user