demo/playground/ua
Former-commit-id: a96394ff0be7a95a5d96adf54391339d69af9fd5 [formerly a96394ff0be7a95a5d96adf54391339d69af9fd5 [formerly a96394ff0be7a95a5d96adf54391339d69af9fd5 [formerly a96394ff0be7a95a5d96adf54391339d69af9fd5 [formerly 0d5cde6f3159acbcd0da4cafbfd1beeb4a2dcf53 [formerly 9d7bd149e7a497dae325b8a76ec2327acb928591]]]]] Former-commit-id: 44d07b4ce0e2fda3c4f12e4677053a93fdf3e287 Former-commit-id: 0878c077a3e58ca7ae2550563f3277afb2a1505e Former-commit-id: dd4ec1cd40077c87e04a46b7916b1cb695772598 [formerly 260ba0013721f93c1b750c9a4baced47d846d2b0] Former-commit-id: f386481937b2dee6b5cb5a55e4150e62194a0d74 Former-commit-id: d6f7d9662b1c5208fb39887b22d91e3ba65f515a Former-commit-id: c0d04a36620b3811b1ee061c66844a4c45208130 Former-commit-id: 73acb00308ff05f3fb15065b4187126dc5715aa0 Former-commit-id: 0a2e96437f1090566da11b05c19d9b38738890fa
This commit is contained in:
@@ -25,6 +25,7 @@ export default {
|
|||||||
{ path: `${pre}theme`, title: '主题', icon: 'flask' },
|
{ path: `${pre}theme`, title: '主题', icon: 'flask' },
|
||||||
{ path: `${pre}fullscreen`, title: '全屏', icon: 'arrows-alt' },
|
{ path: `${pre}fullscreen`, title: '全屏', icon: 'arrows-alt' },
|
||||||
{ path: `${pre}gray`, title: '灰度模式', icon: 'eye' },
|
{ path: `${pre}gray`, title: '灰度模式', icon: 'eye' },
|
||||||
{ path: `${pre}db`, title: '数据持久化', icon: 'database' }
|
{ path: `${pre}db`, title: '数据持久化', icon: 'database' },
|
||||||
|
{ path: `${pre}ua`, title: '浏览器信息', icon: 'info-circle' }
|
||||||
])('/demo/playground/')
|
])('/demo/playground/')
|
||||||
}
|
}
|
||||||
|
|||||||
23
src/pages/demo/playground/ua/index.vue
Normal file
23
src/pages/demo/playground/ua/index.vue
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<template>
|
||||||
|
<d2-container>
|
||||||
|
<p class="d2-mt-0">useragent</p>
|
||||||
|
<el-input :value="ua.ua"></el-input>
|
||||||
|
<p>格式化数据 in vuex: state.d2admin.ua</p>
|
||||||
|
<d2-highlight :code="uaStr"/>
|
||||||
|
</d2-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { mapState } from 'vuex'
|
||||||
|
export default {
|
||||||
|
computed: {
|
||||||
|
...mapState({
|
||||||
|
ua: state => state.d2admin.ua
|
||||||
|
}),
|
||||||
|
uaStr () {
|
||||||
|
const { browser, engine, os, device, cpu } = this.ua
|
||||||
|
return JSON.stringify({ browser, engine, os, device, cpu }, null, 2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
2
src/pages/login/config/README.md
Normal file
2
src/pages/login/config/README.md
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
// 例子插件配置地址
|
||||||
|
// https://vincentgarreau.com/particles.js/#default
|
||||||
@@ -56,12 +56,9 @@
|
|||||||
<script>
|
<script>
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
require('particles.js')
|
require('particles.js')
|
||||||
// 配置地址
|
|
||||||
// https://vincentgarreau.com/particles.js/#default
|
|
||||||
import config from './config/default'
|
import config from './config/default'
|
||||||
import Cookies from 'js-cookie'
|
import Cookies from 'js-cookie'
|
||||||
import { mapMutations } from 'vuex'
|
import { mapMutations, mapActions } from 'vuex'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
@@ -113,6 +110,9 @@ export default {
|
|||||||
'd2adminUserInfoSet',
|
'd2adminUserInfoSet',
|
||||||
'd2adminLoginSuccessLoad'
|
'd2adminLoginSuccessLoad'
|
||||||
]),
|
]),
|
||||||
|
...mapActions([
|
||||||
|
'd2adminLogin'
|
||||||
|
]),
|
||||||
/**
|
/**
|
||||||
* @description 接收选择一个用户快速登陆的事件
|
* @description 接收选择一个用户快速登陆的事件
|
||||||
* @param {object} user 用户信息
|
* @param {object} user 用户信息
|
||||||
@@ -129,39 +129,11 @@ export default {
|
|||||||
submit () {
|
submit () {
|
||||||
this.$refs.loginForm.validate((valid) => {
|
this.$refs.loginForm.validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
// 开始请求登录接口
|
this.d2adminLogin({
|
||||||
this.$axios({
|
vm: this,
|
||||||
method: 'post',
|
username: this.formLogin.username,
|
||||||
url: '/login',
|
password: this.formLogin.password
|
||||||
data: {
|
|
||||||
username: this.formLogin.username,
|
|
||||||
password: this.formLogin.password
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.then(res => {
|
|
||||||
// cookie 一天的有效期
|
|
||||||
const setting = {
|
|
||||||
expires: 1
|
|
||||||
}
|
|
||||||
// 设置 cookie 一定要存 uuid 和 token 两个 cookie,整个系统依赖这两个数据进行校验和存储
|
|
||||||
Cookies.set('uuid', res.data.uuid, setting)
|
|
||||||
Cookies.set('token', res.data.token, setting)
|
|
||||||
// 设置 vuex 用户信息
|
|
||||||
this.d2adminUserInfoSet({
|
|
||||||
name: res.data.name
|
|
||||||
})
|
|
||||||
// 用户登陆后从数据库加载一系列的设置
|
|
||||||
this.d2adminLoginSuccessLoad()
|
|
||||||
// 跳转路由
|
|
||||||
this.$router.push({
|
|
||||||
name: 'index'
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
console.group('登陆结果')
|
|
||||||
console.log('err: ', err)
|
|
||||||
console.groupEnd()
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
d1fc661cca201ded872328bf7926689075938e00
|
8f76893e76107fa094818a6c495320ab7023c0ab
|
||||||
@@ -1 +1 @@
|
|||||||
5c74482dc6e71d5efa34bc5fdfb5c40943d5d386
|
87f7615f1492b3bc4534633f7da875df831a5940
|
||||||
Reference in New Issue
Block a user