Home > Web Front-end > JS Tutorial > About the implementation idea of ​​adding lock screen function in Vue project

About the implementation idea of ​​adding lock screen function in Vue project

不言
Release: 2018-06-30 16:30:23
Original
1776 people have browsed it

This article mainly introduces the implementation ideas of adding lock screen function in Vue project. This article introduces you to you in very detail and has certain reference value. Friends who need it can refer to it

1. Implementation ideas

(1) Set the lock screen password
(2) Store the password in localStorage (this project has encapsulated h5’s sessionStorage and localStorage)
( 3) vuex sets SET_LOCK state.isLock = true (true is the lock screen state)
(4) Determine isLock in vuex in the routing (true lock screen state does not allow the user to return to the url and modify the url jump page Otherwise, it is OK)

(1) Set the lock screen password

 handleSetLock() {
  this.$refs['form'].validate(valid => {
  if (valid) {
   this.$store.commit('SET_LOCK_PASSWD', this.form.passwd)
   this.handleLock()
  }
  })
 },
Copy after login

(2) Password storage localStorage setStore is a self-encapsulated method

 SET_LOCK_PASSWD: (state, lockPasswd) => {
  state.lockPasswd = lockPasswd
  setStore({
  name: 'lockPasswd',
  content: state.lockPasswd,
  type: 'session'
  })
 },
Copy after login

( 3 ) vuex sets SET_LOCK state.isLock = true and exists in the store at the same time

 SET_LOCK: (state, action) => {
  state.isLock = true
  setStore({
  name: 'isLock',
  content: state.isLock,
  type: 'session'
  })
 },
Copy after login

(4) Determine isLock in vuex in routing

 if (store.getters.isLock && to.path !== lockPage) {
  next({
  path: lockPage
  })
  NProgress.done()
Copy after login

The above is the entire content of this article, I hope it will be helpful to everyone's learning, more related content Please pay attention to PHP Chinese website!

Related recommendations:

How to use vue to quickly develop app scaffolding tools

How to use mock in the vue-cli project data

The above is the detailed content of About the implementation idea of ​​adding lock screen function in Vue project. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template