update loading style

This commit is contained in:
weichengwu 2025-11-22 11:05:04 +08:00
parent 2aba907e54
commit 2d590bd028
3 changed files with 188 additions and 72 deletions

3
components.d.ts vendored
View File

@ -13,10 +13,7 @@ declare module 'vue' {
export interface GlobalComponents { export interface GlobalComponents {
ImageViewer: typeof import('./src/components/ImageViewer.vue')['default'] ImageViewer: typeof import('./src/components/ImageViewer.vue')['default']
Loading: typeof import('./src/components/Loading.vue')['default'] Loading: typeof import('./src/components/Loading.vue')['default']
Message: typeof import('./src/components/Message.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink'] RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView'] RouterView: typeof import('vue-router')['RouterView']
VanButton: typeof import('vant/es')['Button']
VanDialog: typeof import('vant/es')['Dialog']
} }
} }

View File

@ -8,6 +8,10 @@
}" }"
:style="containerStyle" :style="containerStyle"
> >
<div class="loading-card" :class="{ 'loading-card-inline': !fullscreen }">
<span class="loading-ambient loading-ambient-primary"></span>
<span class="loading-ambient loading-ambient-secondary"></span>
<div class="loading-spinner-wrapper" :style="spinnerWrapperStyle"> <div class="loading-spinner-wrapper" :style="spinnerWrapperStyle">
<!-- 旋转圆环样式 --> <!-- 旋转圆环样式 -->
<div v-if="type === 'spinner'" class="loading-spinner" :style="spinnerStyle"> <div v-if="type === 'spinner'" class="loading-spinner" :style="spinnerStyle">
@ -74,6 +78,7 @@
</div> </div>
</div> </div>
</div> </div>
</div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@ -110,7 +115,9 @@ const props = defineProps<{
const containerStyle = computed(() => { const containerStyle = computed(() => {
const style: any = {} const style: any = {}
if (props.fullscreen) { if (props.fullscreen) {
style.backgroundColor = props.background || 'rgba(255, 255, 255, 0.9)' style.background =
props.background ||
'radial-gradient(circle at 20% 20%, rgba(255,247,249,0.95), rgba(255,236,240,0.72))'
style.opacity = props.opacity ?? 1 style.opacity = props.opacity ?? 1
} }
return style return style
@ -118,8 +125,10 @@ const containerStyle = computed(() => {
// spinner // spinner
const spinnerWrapperStyle = computed(() => { const spinnerWrapperStyle = computed(() => {
const color = props.color || '#E8424D'
return { return {
color: props.color || '#1890ff' color,
'--loading-color': color
} }
}) })
@ -204,6 +213,13 @@ const textStyle = computed(() => {
</script> </script>
<style scoped> <style scoped>
.loading-container {
display: flex;
justify-content: center;
align-items: center;
padding: 16px;
}
/* 全屏容器样式 */ /* 全屏容器样式 */
.loading-container-fullscreen { .loading-container-fullscreen {
position: fixed; position: fixed;
@ -211,29 +227,101 @@ const textStyle = computed(() => {
left: 0; left: 0;
right: 0; right: 0;
bottom: 0; bottom: 0;
display: flex;
justify-content: center;
align-items: center;
z-index: 9999; z-index: 9999;
background: radial-gradient(circle at 30% 20%, rgba(255, 247, 249, 0.95), rgba(255, 236, 240, 0.75));
} }
/* 内联容器样式 */ /* 内联容器样式 */
.loading-container-inline { .loading-container-inline {
display: inline-flex; display: inline-flex;
padding: 8px;
}
.loading-card {
position: relative;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
padding: 18px 20px;
border-radius: 18px;
width: 260px;
max-width: min(72vw, 340px);
min-width: 220px;
aspect-ratio: 3 / 2;
background: linear-gradient(135deg, rgba(255, 247, 249, 0.95), rgba(255, 255, 255, 0.9));
border: 1px solid rgba(232, 66, 77, 0.12);
box-shadow: 0 18px 45px rgba(232, 66, 77, 0.16), 0 4px 12px rgba(232, 66, 77, 0.08);
}
.loading-card-inline {
min-width: auto;
padding: 10px 14px;
width: auto;
max-width: none;
aspect-ratio: auto;
box-shadow: 0 10px 26px rgba(232, 66, 77, 0.14);
border-radius: 14px;
}
.loading-ambient {
position: absolute;
border-radius: 50%;
filter: blur(28px);
opacity: 0.65;
animation: float 6s ease-in-out infinite alternate;
}
.loading-ambient-primary {
width: 160px;
height: 160px;
top: -40px;
right: -30px;
background: radial-gradient(circle, rgba(255, 184, 193, 0.55), rgba(255, 228, 234, 0.15));
}
.loading-ambient-secondary {
width: 140px;
height: 140px;
bottom: -50px;
left: -20px;
background: radial-gradient(circle, rgba(255, 221, 230, 0.6), rgba(255, 255, 255, 0.2));
animation-delay: 0.8s;
}
.loading-spinner-wrapper {
position: relative;
z-index: 1;
display: flex;
flex-direction: column;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
gap: 12px;
color: var(--loading-color);
} }
/* 旋转圆环样式 */ /* 旋转圆环样式 */
.loading-spinner { .loading-spinner {
position: relative;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
filter: drop-shadow(0 8px 18px rgba(232, 66, 77, 0.18));
}
.loading-spinner::before {
content: '';
position: absolute;
inset: -20%;
border-radius: 50%;
background: radial-gradient(circle at 30% 30%, rgba(255, 184, 193, 0.35), rgba(255, 255, 255, 0));
animation: pulseGlow 2.4s ease-in-out infinite;
} }
.loading-svg { .loading-svg {
animation: rotate 1.4s linear infinite; animation: rotate 1.4s linear infinite;
transform-origin: center center; transform-origin: center center;
filter: drop-shadow(0 6px 14px rgba(232, 66, 77, 0.14));
} }
/* 确保SVG中的circle元素也正确居中 */ /* 确保SVG中的circle元素也正确居中 */
@ -243,6 +331,8 @@ const textStyle = computed(() => {
.loading-path { .loading-path {
animation: dash 1.4s ease-in-out infinite; animation: dash 1.4s ease-in-out infinite;
stroke: currentColor;
stroke-linecap: round;
} }
/* 点状加载样式 */ /* 点状加载样式 */
@ -268,6 +358,7 @@ const textStyle = computed(() => {
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
position: relative;
} }
.loading-ring-circle { .loading-ring-circle {
@ -277,13 +368,17 @@ const textStyle = computed(() => {
border-radius: 50%; border-radius: 50%;
animation: spin 1.4s linear infinite; animation: spin 1.4s linear infinite;
transform-origin: center center; transform-origin: center center;
box-shadow: 0 10px 20px rgba(232, 66, 77, 0.14);
} }
/* 加载文本样式 */ /* 加载文本样式 */
.loading-text { .loading-text {
font-size: 14px; font-size: 15px;
text-align: center; text-align: center;
white-space: nowrap; white-space: nowrap;
font-weight: 600;
color: #c3414c;
letter-spacing: 0.3px;
} }
/* 动画定义 */ /* 动画定义 */
@ -346,4 +441,28 @@ const textStyle = computed(() => {
transform: rotate(360deg); transform: rotate(360deg);
} }
} }
@keyframes pulseGlow {
0% {
transform: scale(0.92);
opacity: 0.8;
}
50% {
transform: scale(1);
opacity: 1;
}
100% {
transform: scale(1.05);
opacity: 0.9;
}
}
@keyframes float {
from {
transform: translateY(0);
}
to {
transform: translateY(-12px);
}
}
</style> </style>

View File

@ -47,11 +47,11 @@ export function showLoading(options: LoadingOptions = {}): LoadingInstance {
// 默认配置 // 默认配置
const defaultOptions: LoadingOptions = { const defaultOptions: LoadingOptions = {
type: 'spinner', type: 'spinner',
size: 40, size: 42,
color: '#1890ff', color: '#E8424D',
fullscreen: true, fullscreen: true,
text: '', text: '',
background: 'rgba(0, 0, 0, 0.3)', background: 'rgba(255, 241, 243, 0.8)',
opacity: 1, opacity: 1,
strokeWidth: 3, strokeWidth: 3,
strokeLinecap: 'round' strokeLinecap: 'round'