index.vue
1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<template>
<div v-show="visible"
class="global-loading"
:style="{ backgroundColor: overlayColor }"
@touchmove.prevent>
<div class="global-loading__panel">
<van-loading vertical
:color="spinnerColor"
:size="size"
:type="type">
{{ text }}
</van-loading>
</div>
</div>
</template>
<script>
export default {
name: "GlobalLoading",
data() {
return {
visible: false,
text: "加载中...",
type: "spinner",
size: "24px",
spinnerColor: "#ffffff",
overlayColor: "rgba(0, 0, 0, 0.35)",
};
},
methods: {
open(options = {}) {
const config = typeof options === "string" ? { text: options } : options;
this.text = config.text || config.message || "加载中...";
this.type = config.type || "spinner";
this.size = config.size || "24px";
this.spinnerColor = config.color || "#ffffff";
this.overlayColor = config.overlayColor || "rgba(0, 0, 0, 0.35)";
this.visible = true;
},
close() {
this.visible = false;
},
},
};
</script>
<style lang="scss" scoped>
.global-loading {
position: fixed;
inset: 0;
z-index: 3000;
display: flex;
align-items: center;
justify-content: center;
padding: 24px;
box-sizing: border-box;
&__panel {
min-width: 96px;
max-width: min(60vw, 180px);
padding: 16px 18px;
border-radius: 12px;
background: rgba(0, 0, 0, 0.72);
backdrop-filter: blur(4px);
box-sizing: border-box;
::v-deep .van-loading {
align-items: center;
}
::v-deep .van-loading__text {
margin-top: 10px;
font-size: 14px;
line-height: 20px;
color: #ffffff;
text-align: center;
word-break: break-word;
}
}
}
</style>