Browse Source

feat: 🚀 添加退出判断

pull/1/head
jiangx 3 years ago
parent
commit
b53b84139a
  1. 2
      src/base/Logout/Logout.vue
  2. 15
      src/composables/useLogout.ts
  3. 1
      tsconfig.json

2
src/base/Logout/Logout.vue

@ -1,6 +1,6 @@
<template> <template>
<div v-if="modelValue" class="logout-container"> <div v-if="modelValue" class="logout-container">
<div class="dialog-wrapper animate__animated animate__zoomIn">
<div class="dialog-wrapper">
<p class="out-icon" @click="close"> <p class="out-icon" @click="close">
<img src="./chahao.svg" class="close-icon" /> <img src="./chahao.svg" class="close-icon" />
</p> </p>

15
src/composables/useLogout.ts

@ -1,10 +1,11 @@
import { ref, nextTick } from 'vue'
import { ref, nextTick, watch } from 'vue'
export const useLogout = () => { export const useLogout = () => {
const logout = ref(false) const logout = ref(false)
const clickedNumberTotal = ref(0) const clickedNumberTotal = ref(0)
const timer = ref()
const MAX_NUMBER = 10 const MAX_NUMBER = 10
const DELAY_TIME = 10000
const SAFE_COORDINATES = 200 const SAFE_COORDINATES = 200
function resetClickNumber() { function resetClickNumber() {
@ -35,5 +36,15 @@ export const useLogout = () => {
} }
} }
watch(clickedNumberTotal, newVal => {
clearTimeout(timer.value)
timer.value = setTimeout(() => {
if (newVal !== 0) {
clearTimeout(timer.value)
resetClickNumber()
}
}, DELAY_TIME)
})
return { resetClickNumber, addTotalClick, setLogout, logout } return { resetClickNumber, addTotalClick, setLogout, logout }
} }

1
tsconfig.json

@ -6,7 +6,6 @@
"jsx": "preserve", "jsx": "preserve",
"moduleResolution": "node", "moduleResolution": "node",
"skipLibCheck": true, "skipLibCheck": true,
"ignoreDeprecations": "5.0",
"suppressImplicitAnyIndexErrors": true, "suppressImplicitAnyIndexErrors": true,
"esModuleInterop": true, "esModuleInterop": true,
"allowJs": true, "allowJs": true,

Loading…
Cancel
Save