|
@@ -21,8 +21,8 @@
|
|
|
placeholder="你的密码..." maxlength="32" />
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
- <div @keyup.enter="sureLog">
|
|
|
- <el-button class="loginBtn" type="primary" @click="sureLog">登录</el-button>
|
|
|
+ <div @keyup.enter="debouncedSureLog">
|
|
|
+ <el-button class="loginBtn" type="primary" @click="debouncedSureLog">登录</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
@@ -33,7 +33,7 @@
|
|
|
<script>
|
|
|
import { ref, onMounted, onBeforeUnmount } from "vue"
|
|
|
import { useRouter } from 'vue-router'
|
|
|
-import { ElMessage } from "element-plus"
|
|
|
+import { ElMessage, ElLoading } from "element-plus"
|
|
|
import login from "@/api/login"
|
|
|
import { useDataStore } from '@/store/modules/golbal-data';
|
|
|
const userStoreCode = useDataStore();
|
|
@@ -46,6 +46,7 @@ export default {
|
|
|
})
|
|
|
let isLogin = ref(false)
|
|
|
let router = useRouter()
|
|
|
+ let timer = ref(null)//添加防抖,防止用户多次点击
|
|
|
function encryptPassword(password) {
|
|
|
if (typeof SmCrypto == 'undefined') {
|
|
|
window.location.reload()
|
|
@@ -66,6 +67,20 @@ export default {
|
|
|
return val
|
|
|
}
|
|
|
}
|
|
|
+ // 防抖函数
|
|
|
+ function debouncedSureLog() {
|
|
|
+ clearTimeout(timer); // 清除之前的定时器
|
|
|
+ const loading = ElLoading.service({
|
|
|
+ lock: true,
|
|
|
+ text: "正在登陆",
|
|
|
+ background: "rgba(0, 0, 0, 0.7)",
|
|
|
+ });
|
|
|
+ timer = setTimeout(() => {
|
|
|
+ sureLog();
|
|
|
+ loading.close()
|
|
|
+ }, 500); // 设置防抖延迟时间为500毫秒
|
|
|
+ };
|
|
|
+
|
|
|
function sureLog() {
|
|
|
let kis = encryptPassword(loginForm.value.userpass)
|
|
|
login.LoginNow({
|
|
@@ -97,7 +112,7 @@ export default {
|
|
|
// 添加键盘事件监听器
|
|
|
function handleKeyUp(event) {
|
|
|
if (event.key === 'Enter') {
|
|
|
- sureLog();
|
|
|
+ debouncedSureLog();
|
|
|
}
|
|
|
};
|
|
|
function WinClose() {
|
|
@@ -127,6 +142,7 @@ export default {
|
|
|
WinMin,
|
|
|
WinClose,
|
|
|
handleKeyUp,
|
|
|
+ debouncedSureLog,//防抖函数
|
|
|
}
|
|
|
}
|
|
|
}
|