Git Product home page Git Product logo

Comments (1)

buqiyuan avatar buqiyuan commented on May 28, 2024

这个锁屏功能本身也是做着玩的,如果仅靠纯前端做锁屏,肯定是不够严谨的,稍微懂点浏览器调试技巧的都可以轻松破解,防君子不防小人的
当然,你也可以做的更严谨一些,例如:如果当前处于锁屏状态的话,你可以监听 localStorage 的修改,然后对于锁屏时的任何修改都立刻重置回修改前的状态就可以了。

未经测试的伪代码如下:

import { watch } from 'vue'
import { useStorage } from '@vueuse/core'
import { cloneDeep, isEqual }

// 锁屏前的值
let afterLockValue

const state = useStorage('my-store', { hello: 'hi', greeting: 'Hello' })

watch(IS_LOCKSCREEN, (val, oldValue) => {
 // 保存刚锁屏时的状态
 if (val) {
  afterLockValue = deepClone(state.value)
 }
})

watch(state, (val) => {
 // 如果当前处于锁屏状态,则对localstorage的任何修改重置回锁屏时的状态
 if (IS_LOCKSCREEN && !isEqual(val, beforLockValue)) {
  state.value = afterLockValue
 }
})

from vue3-antdv-admin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.