|
@@ -0,0 +1,130 @@
|
|
1
|
+<template>
|
|
2
|
+ <div
|
|
3
|
+ class="loader-wrapper"
|
|
4
|
+ @touchmove.prevent
|
|
5
|
+ @mousewheel.prevent
|
|
6
|
+ >
|
|
7
|
+ <div class="loader-mask">
|
|
8
|
+ <img :src="maskImg" alt="" @load="onLoad">
|
|
9
|
+ <div class="mask-fill" :style="fillStyle"></div>
|
|
10
|
+ </div>
|
|
11
|
+ <div class="back-blank" v-if="showBack" :style="bbStyle">
|
|
12
|
+ <div class="back-move" :style="bmStyle"></div>
|
|
13
|
+ </div>
|
|
14
|
+ <p class="percent">{{percent}}%</p>
|
|
15
|
+ </div>
|
|
16
|
+</template>
|
|
17
|
+
|
|
18
|
+<script setup>
|
|
19
|
+ import { computed, reactive, ref, watch } from "vue"
|
|
20
|
+
|
|
21
|
+ const props = defineProps({
|
|
22
|
+ tip: {
|
|
23
|
+ type: String,
|
|
24
|
+ default: 'loading...'
|
|
25
|
+ },
|
|
26
|
+ percent: {
|
|
27
|
+ type: Number,
|
|
28
|
+ default: 0
|
|
29
|
+ },
|
|
30
|
+ loading: Boolean
|
|
31
|
+ })
|
|
32
|
+
|
|
33
|
+ const elRef = ref();
|
|
34
|
+ const showBack = ref(false);
|
|
35
|
+ const progressStyle = computed(() => ({ width: `${props.percent}%` }));
|
|
36
|
+
|
|
37
|
+ const maskImg = './mask.png';
|
|
38
|
+ const maskFontHeight = [186, 726]; // mask.png 字的高度
|
|
39
|
+
|
|
40
|
+ const fillStyle = ref({});
|
|
41
|
+ const bbStyle = ref({});
|
|
42
|
+
|
|
43
|
+ const bmStyle = computed(() => {
|
|
44
|
+ return {
|
|
45
|
+ top: `${0 - props.percent}%`,
|
|
46
|
+ }
|
|
47
|
+ })
|
|
48
|
+
|
|
49
|
+ const onLoad = e => {
|
|
50
|
+ const { height, naturalHeight } = e.target;
|
|
51
|
+ const yRate = height / naturalHeight;
|
|
52
|
+
|
|
53
|
+ fillStyle.value = { top: `${height}px` };
|
|
54
|
+ showBack.value = true;
|
|
55
|
+ bbStyle.value = {
|
|
56
|
+ height: `${yRate * (maskFontHeight[1] - maskFontHeight[0])}px`,
|
|
57
|
+ top: `${yRate * maskFontHeight[0]}px`,
|
|
58
|
+ }
|
|
59
|
+ }
|
|
60
|
+
|
|
61
|
+</script>
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+<style lang="less" scoped>
|
|
65
|
+@tip-color: #933D33;
|
|
66
|
+
|
|
67
|
+.loader-wrapper {
|
|
68
|
+ position: fixed;
|
|
69
|
+ top: 0;
|
|
70
|
+ left: 0;
|
|
71
|
+ width: 100%;
|
|
72
|
+ height: 100%;
|
|
73
|
+ z-index: 100;
|
|
74
|
+ overflow: hidden;
|
|
75
|
+ background: transparent;
|
|
76
|
+
|
|
77
|
+ .loader-mask {
|
|
78
|
+ background: transparent;
|
|
79
|
+ position: absolute;
|
|
80
|
+ top: 0;
|
|
81
|
+ left: 0;
|
|
82
|
+ width: 100%;
|
|
83
|
+ height: 100%;
|
|
84
|
+ z-index: 20;
|
|
85
|
+ overflow: hidden;
|
|
86
|
+
|
|
87
|
+ img {
|
|
88
|
+ display: block;
|
|
89
|
+ width: 100%;
|
|
90
|
+ }
|
|
91
|
+
|
|
92
|
+ .mask-fill {
|
|
93
|
+ background: var(--bg-color);
|
|
94
|
+ width: 100%;
|
|
95
|
+ height: 100%;
|
|
96
|
+ left: 0;
|
|
97
|
+ }
|
|
98
|
+ }
|
|
99
|
+ .percent {
|
|
100
|
+ position: absolute;
|
|
101
|
+ color: @tip-color;
|
|
102
|
+ text-align: center;
|
|
103
|
+ width: 100%;
|
|
104
|
+ bottom: 120px;
|
|
105
|
+ left: 0;
|
|
106
|
+ z-index: 30;
|
|
107
|
+ font-size: 24px;
|
|
108
|
+ font-weight: bold;
|
|
109
|
+ }
|
|
110
|
+
|
|
111
|
+ .back-blank {
|
|
112
|
+ position: absolute;
|
|
113
|
+ top: 0;
|
|
114
|
+ left: 0;
|
|
115
|
+ width: 100%;
|
|
116
|
+ height: 100%;
|
|
117
|
+
|
|
118
|
+ .back-move {
|
|
119
|
+ background: var(--bg-color);
|
|
120
|
+
|
|
121
|
+ position: absolute;
|
|
122
|
+ top: 0;
|
|
123
|
+ left: 0;
|
|
124
|
+ width: 100%;
|
|
125
|
+ height: 100%;
|
|
126
|
+ }
|
|
127
|
+ }
|
|
128
|
+}
|
|
129
|
+
|
|
130
|
+</style>
|