强制使用谷歌浏览器

This commit is contained in:
guoyue 2022-09-13 09:38:00 +08:00
parent 1e06abbf11
commit 7996d8a701
1 changed files with 163 additions and 123 deletions

View File

@ -15,22 +15,16 @@
</a-input> </a-input>
</a-form-item> </a-form-item>
<a-form-item> <a-form-item>
<a-input <a-input v-model:value="form.password" type="password" placeholder="Password">
v-model:value="form.password"
type="password"
placeholder="Password"
>
<template v-slot:prefix> <template v-slot:prefix>
<LockOutlined style="color: rgba(0, 0, 0, 0.25)" /> <LockOutlined style="color: rgba(0, 0, 0, 0.25)" />
</template> </template>
</a-input> </a-input>
</a-form-item> </a-form-item>
<a-form-item> <a-form-item>
<a-button <!-- IE Chrome -->
type="primary" <a-button type="primary" html-type="submit"
html-type="submit" :disabled="form.username === '' || form.password === '' || judgeAgent() !== 'Chrome'">
:disabled="form.username === '' || form.password === ''"
>
登录 登录
</a-button> </a-button>
</a-form-item> </a-form-item>
@ -42,128 +36,174 @@
</div> </div>
</template> </template>
<script> <script>
import { dependencies, devDependencies } from '*/package.json' import { dependencies, devDependencies } from '*/package.json'
import { mapActions, mapGetters } from 'vuex' import { mapActions, mapGetters } from 'vuex'
import { Encrypt } from '@/utils/crypto' import { Encrypt } from '@/utils/crypto'
import { UserOutlined, LockOutlined } from '@ant-design/icons-vue' import { UserOutlined, LockOutlined } from '@ant-design/icons-vue'
import { message } from 'ant-design-vue' import { message, Modal } from 'ant-design-vue'
export default { export default {
name: 'Login', name: 'Login',
components: { components: {
UserOutlined, UserOutlined,
LockOutlined, LockOutlined,
},
data() {
return {
form: {
username: '',
password: '',
},
redirect: undefined,
dependencies: dependencies,
devDependencies: devDependencies,
}
},
computed: {
...mapGetters({
logo: 'settings/logo',
title: 'settings/title',
}),
},
watch: {
$route: {
handler(route) {
this.redirect = (route.query && route.query.redirect) || '/'
},
immediate: true,
}, },
data() { },
return { mounted() {
form: { this.form.username = ''
username: '', this.form.password = ''
password: '', /* setTimeout(() => {
}, this.handleSubmit()
redirect: undefined, }, 3000) */
dependencies: dependencies, if (this.judgeAgent() !== 'Chrome') {
devDependencies: devDependencies, Modal.warning({
title: '提示',
content: '请使用谷歌浏览器!',
});
}
},
methods: {
...mapActions({
login: 'user/login',
}),
//
judgeAgent() {
let userAgent = navigator.userAgent // userAgent
let isOpera = userAgent.indexOf('Opera') > -1
//Opera
if (isOpera) {
return 'Opera'
}
//Firefox
if (userAgent.indexOf('Firefox') > -1) {
return 'FF'
}
//chorme
if (userAgent.indexOf('Chrome') > -1) {
return 'Chrome'
}
//Safari
if (userAgent.indexOf('Safari') > -1) {
return 'Safari'
}
//IE
if (
userAgent.indexOf('compatible') > -1 &&
userAgent.indexOf('MSIE') > -1 &&
!isOpera
) {
return 'IE'
}
//Edge
if (userAgent.indexOf('Trident') > -1) {
return 'Edge'
} }
}, },
computed: { handleRoute() {
...mapGetters({ return this.redirect === '/404' || this.redirect === '/403'
logo: 'settings/logo', ? '/home'
title: 'settings/title', : this.redirect
}),
}, },
watch: { async handleSubmit() {
$route: { // debugger
handler(route) { try {
this.redirect = (route.query && route.query.redirect) || '/' // console.log('', Decrypt(Encrypt(this.form.password)))
}, if (this.form.password !== this.form.password.trim()) {
immediate: true,
},
},
mounted() {
this.form.username = ''
this.form.password = ''
/* setTimeout(() => {
this.handleSubmit()
}, 3000) */
},
methods: {
...mapActions({
login: 'user/login',
}),
handleRoute() {
return this.redirect === '/404' || this.redirect === '/403'
? '/home'
: this.redirect
},
async handleSubmit() {
// debugger
try {
// console.log('', Decrypt(Encrypt(this.form.password)))
if (this.form.password !== this.form.password.trim()) {
message.error('登陆失败,用户名或密码错误!')
return
}
await this.login({
password: Encrypt(this.form.password),
username: this.form.username,
})
window.sessionStorage.setItem('visits', JSON.stringify([]))
console.log('添加visits========================================>')
// console.log(this.handleRoute())
await this.$router.push('/home')
} catch (error) {
message.error('登陆失败,用户名或密码错误!') message.error('登陆失败,用户名或密码错误!')
return
} }
}, await this.login({
password: Encrypt(this.form.password),
username: this.form.username,
})
window.sessionStorage.setItem('visits', JSON.stringify([]))
console.log('添加visits========================================>')
// console.log(this.handleRoute())
await this.$router.push('/home')
} catch (error) {
message.error('登陆失败,用户名或密码错误!')
}
}, },
} },
}
</script> </script>
<style lang="less"> <style lang="less">
.login-container { .login-container {
width: 100%; width: 100%;
height: 100vh; height: 100vh;
background: url('~@/assets/login_images/login_background.png'); background: url('~@/assets/login_images/login_background.png');
background-size: cover; background-size: cover;
&-form {
width: calc(100% - 40px); &-form {
height: 380px; width: calc(100% - 40px);
padding: 4vh; height: 380px;
margin-top: calc((100vh - 380px) / 2); padding: 4vh;
margin-right: 20px; margin-top: calc((100vh - 380px) / 2);
margin-left: 20px; margin-right: 20px;
background: url('~@/assets/login_images/login_form.png'); margin-left: 20px;
background-size: 100% 100%; background: url('~@/assets/login_images/login_form.png');
border-radius: 10px; background-size: 100% 100%;
box-shadow: 0 2px 8px 0 rgba(7, 17, 27, 0.06); border-radius: 10px;
} box-shadow: 0 2px 8px 0 rgba(7, 17, 27, 0.06);
&-hello {
font-size: 32px;
color: #fff;
}
&-title {
margin-bottom: 30px;
font-size: 20px;
color: #fff;
}
&-tips {
position: fixed;
bottom: @vab-margin;
width: 100%;
height: 40px;
color: rgba(255, 255, 255, 0.856);
text-align: center;
}
.ant-col {
width: 100%;
padding: 0 10px 0 10px;
}
.ant-input {
height: 35px;
}
.ant-btn {
width: 100%;
height: 45px;
border-radius: 99px;
}
} }
&-hello {
font-size: 32px;
color: #fff;
}
&-title {
margin-bottom: 30px;
font-size: 20px;
color: #fff;
}
&-tips {
position: fixed;
bottom: @vab-margin;
width: 100%;
height: 40px;
color: rgba(255, 255, 255, 0.856);
text-align: center;
}
.ant-col {
width: 100%;
padding: 0 10px 0 10px;
}
.ant-input {
height: 35px;
}
.ant-btn {
width: 100%;
height: 45px;
border-radius: 99px;
}
}
</style> </style>