mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-12 09:18:14 +08:00
🎨 t-loading 外部用 t-overlay 实现
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<transition enter-from-class="out-enter-from" name="out">
|
<TOverlay v-model="show">
|
||||||
<div v-show="showOut" class="loading-box">
|
<div class="loading-div">
|
||||||
<transition enter-from-class="in-enter-from" name="in">
|
|
||||||
<div v-show="showIn" class="loading-div">
|
|
||||||
<div class="loading-content">
|
<div class="loading-content">
|
||||||
<div class="loading-title">
|
<div class="loading-title">
|
||||||
{{ title }}
|
{{ title }}
|
||||||
@@ -22,13 +20,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</transition>
|
</TOverlay>
|
||||||
</div>
|
|
||||||
</transition>
|
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
// vue
|
// vue
|
||||||
import { ref, watch } from "vue";
|
import { watch, ref } from "vue";
|
||||||
|
import TOverlay from "./t-overlay.vue";
|
||||||
|
|
||||||
interface LoadingProps {
|
interface LoadingProps {
|
||||||
modelValue: boolean;
|
modelValue: boolean;
|
||||||
@@ -38,8 +35,7 @@ interface LoadingProps {
|
|||||||
empty?: boolean;
|
empty?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const showOut = ref(false);
|
const show = ref(false);
|
||||||
const showIn = ref(false);
|
|
||||||
|
|
||||||
const props = withDefaults(defineProps<LoadingProps>(), {
|
const props = withDefaults(defineProps<LoadingProps>(), {
|
||||||
modelValue: false,
|
modelValue: false,
|
||||||
@@ -49,79 +45,11 @@ const props = withDefaults(defineProps<LoadingProps>(), {
|
|||||||
empty: false,
|
empty: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(
|
watch(() => props.modelValue, (v) => {
|
||||||
() => props.modelValue,
|
show.value = v;
|
||||||
(v) => {
|
});
|
||||||
if (v) {
|
|
||||||
showOut.value = true;
|
|
||||||
showIn.value = true;
|
|
||||||
} else {
|
|
||||||
setTimeout(() => {
|
|
||||||
showIn.value = false;
|
|
||||||
}, 100);
|
|
||||||
setTimeout(() => {
|
|
||||||
showOut.value = false;
|
|
||||||
}, 300);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<style lang="css" scoped>
|
<style lang="css" scoped>
|
||||||
.out-enter-active,
|
|
||||||
.out-leave-active,
|
|
||||||
.in-enter-active {
|
|
||||||
transition: all 0.3s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.in-leave-active {
|
|
||||||
transition: all 0.5s ease-in-out;
|
|
||||||
}
|
|
||||||
|
|
||||||
.out-enter-from,
|
|
||||||
.in-enter-from {
|
|
||||||
opacity: 0;
|
|
||||||
transform: scale(1.5);
|
|
||||||
}
|
|
||||||
|
|
||||||
.out-enter-to,
|
|
||||||
.in-enter-to {
|
|
||||||
opacity: 1;
|
|
||||||
transform: scale(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.out-leave-from {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.out-leave-to {
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.in-leave-from {
|
|
||||||
opacity: 1;
|
|
||||||
transform: scale(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.in-leave-to {
|
|
||||||
opacity: 0;
|
|
||||||
transform: scale(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
.loading-box {
|
|
||||||
position: fixed;
|
|
||||||
left: 0;
|
|
||||||
top: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
background: rgb(0 0 0 / 50%);
|
|
||||||
backdrop-filter: blur(20px);
|
|
||||||
z-index: 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
.loading-div {
|
.loading-div {
|
||||||
display: flex;
|
display: flex;
|
||||||
width: 50%;
|
width: 50%;
|
||||||
|
|||||||
Reference in New Issue
Block a user