From 10294c3939e03fc181a7aef7c68f5348221bfcda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?TOP=E7=B3=AF=E7=B1=B3?= <1130395124@qq.com> Date: Sat, 8 Apr 2023 16:10:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96loading=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/widgets/loading/loading.vue | 2 +- src/core/libs/loading.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/widgets/loading/loading.vue b/src/components/widgets/loading/loading.vue index f2d0777..89b90ad 100644 --- a/src/components/widgets/loading/loading.vue +++ b/src/components/widgets/loading/loading.vue @@ -44,7 +44,7 @@ export default { width: 270rpx; margin: 0 auto; transform: translateY(-50%); - background-color: #646464; + background-color: #4e4e4e; box-sizing: border-box; padding: 20rpx; border-radius: 10rpx; diff --git a/src/core/libs/loading.js b/src/core/libs/loading.js index ba95314..601a902 100644 --- a/src/core/libs/loading.js +++ b/src/core/libs/loading.js @@ -1,12 +1,21 @@ import $store from '@/store/index' export default { + timer: null, + timeout: 10, show(title) { + clearTimeout(this.timer); $store.commit('loading/show', true); if (title) { $store.commit('loading/title', title); } + // 10秒后自动hide + let that = this; + this.timer = setTimeout(() => { + that.hide(); + }, this.timeout * 1000); }, hide() { + clearTimeout(this.timer); $store.commit('loading/show', false); $store.commit('loading/title', ""); }