登录注册页的背景动画在移动端上默认关闭

修复侧边栏在移动端点击未收起的问题
master
toesbieya 6 years ago
parent e054b2f08f
commit ca342c87d6
  1. 2
      vue/src/layout/components/Sidebar/index.vue
  2. 15
      vue/src/layout/mixin/ResizeHandler.js
  3. 3
      vue/src/store/modules/app.js
  4. 7
      vue/src/utils/browser.js
  5. 17
      vue/src/views/app/login.vue
  6. 13
      vue/src/views/app/register.vue

@ -92,6 +92,8 @@
this.$nextTick(() => this.$router.replace({path: '/redirect' + this.$route.fullPath})) this.$nextTick(() => this.$router.replace({path: '/redirect' + this.$route.fullPath}))
} }
else this.$router.push(index) else this.$router.push(index)
//mobile
this.device === 'mobile' && this.$store.commit('setting/sidebarCollapse', true)
} }
}, },
mounted() { mounted() {

@ -1,20 +1,13 @@
import {debounce} from '@/utils' import {debounce} from '@/utils'
import {isMobile} from "@/utils/browser"
const {body} = document
const WIDTH = 768
function $_isMobile() {
const rect = body.getBoundingClientRect()
return rect.width - 1 < WIDTH
}
export default { export default {
methods: { methods: {
$_resizeHandler() { $_resizeHandler() {
if (!document.hidden) { if (!document.hidden) {
const isMobile = $_isMobile() const mobile = isMobile()
this.$store.commit('app/device', isMobile ? 'mobile' : 'pc') this.$store.commit('app/device', mobile ? 'mobile' : 'pc')
isMobile && this.$store.commit('setting/sidebarCollapse', true) mobile && this.$store.commit('setting/sidebarCollapse', true)
} }
} }
}, },

@ -1,11 +1,12 @@
import {getLocalPersonalSettings} from "@/utils/localStorage" import {getLocalPersonalSettings} from "@/utils/localStorage"
import {createMutations} from "@/utils" import {createMutations} from "@/utils"
import {isMobile} from "@/utils/browser"
const localSettings = getLocalPersonalSettings() const localSettings = getLocalPersonalSettings()
const state = { const state = {
//区分pc和移动端(mobile) //区分pc和移动端(mobile)
device: 'pc', device: isMobile() ? 'mobile' : 'pc',
//登陆页背景动画 //登陆页背景动画
loginPageBackgroundAnimation: 'firework', loginPageBackgroundAnimation: 'firework',
//注册页背景动画 //注册页背景动画

@ -0,0 +1,7 @@
const {body} = document
const WIDTH = 768
export function isMobile() {
const rect = body.getBoundingClientRect()
return rect.width - 1 < WIDTH
}

@ -62,8 +62,9 @@
</template> </template>
<script> <script>
import {isEmpty} from "@/utils" import {mapState} from 'vuex'
import md5 from "js-md5" import md5 from "js-md5"
import {isEmpty} from "@/utils"
import {elSuccess} from "@/utils/message" import {elSuccess} from "@/utils/message"
import SetAnimation from "./components/SetAnimation" import SetAnimation from "./components/SetAnimation"
@ -90,17 +91,16 @@
animation: null animation: null
} }
}, },
computed: { computed: mapState('app', {
loginPageBackgroundAnimation() { device: state => state.device,
return this.$store.state.app.loginPageBackgroundAnimation loginPageBackgroundAnimation: state => state.loginPageBackgroundAnimation
} }),
},
methods: { methods: {
showPwd() { showPwd() {
this.passwordType = this.passwordType === 'password' ? '' : 'password' this.passwordType = this.passwordType === 'password' ? '' : 'password'
this.$nextTick(() => this.$refs.password.focus()) this.$nextTick(() => this.$refs.password.focus())
}, },
login({pageX, pageY}) { login() {
if (this.loading) return if (this.loading) return
this.$refs.form.validate(valid => { this.$refs.form.validate(valid => {
if (!valid) return if (!valid) return
@ -144,7 +144,8 @@
} }
}, },
mounted() { mounted() {
this.setAnimation(this.loginPageBackgroundAnimation) //
this.device !== 'mobile' && this.setAnimation(this.loginPageBackgroundAnimation)
this.addCapsLockEvent() this.addCapsLockEvent()
if (isEmpty(this.form.username)) this.$refs.username.focus() if (isEmpty(this.form.username)) this.$refs.username.focus()
else this.$refs.password.focus() else this.$refs.password.focus()

@ -48,6 +48,7 @@
</template> </template>
<script> <script>
import {mapState} from 'vuex'
import md5 from "js-md5" import md5 from "js-md5"
import {register} from "@/api/account" import {register} from "@/api/account"
import {checkName} from "@/api/system/user" import {checkName} from "@/api/system/user"
@ -93,11 +94,10 @@
animation: null animation: null
} }
}, },
computed: { computed: mapState('app', {
registerPageBackgroundAnimation() { device: state => state.device,
return this.$store.state.app.registerPageBackgroundAnimation registerPageBackgroundAnimation: state => state.registerPageBackgroundAnimation
} }),
},
methods: { methods: {
register() { register() {
if (this.loading) return if (this.loading) return
@ -136,7 +136,8 @@
} }
}, },
mounted() { mounted() {
this.setAnimation(this.registerPageBackgroundAnimation) //
this.device !== 'mobile' && this.setAnimation(this.registerPageBackgroundAnimation)
this.addEvent() this.addEvent()
this.$nextTick(() => this.$refs.username.focus()) this.$nextTick(() => this.$refs.username.focus())
}, },

Loading…
Cancel
Save