mirror of
https://github.com/ialley-workshop-open/uni-halo.git
synced 2026-11-13 22:11:42 +08:00
feat: 新增文章投票功能,优化多项页面细节
1. 新增文章详情页投票组件,支持投票插件检查、展开收起 2. 新增下划线文本、投票卡片、投票列表页组件 3. 优化自定义tabbar样式与返回逻辑 4. 更新投票工具类与投票详情页逻辑 5. 优化公告详情页样式与功能 6. 修复部分样式与类型定义问题
This commit is contained in:
@@ -1,256 +1,265 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import type { DataLoadingStatus } from '@/hooks/useDataLoading'
|
||||
import { computed } from 'vue'
|
||||
import type { DataLoadingStatus } from '@/hooks/useDataLoading'
|
||||
|
||||
interface IProps {
|
||||
/** 加载状态(取值同 useDataLoading 返回的 status) */
|
||||
loadingStatus?: DataLoadingStatus
|
||||
/** 占位区最小高度 */
|
||||
minHeight?: string
|
||||
loadingText?: string
|
||||
errorText?: string
|
||||
emptyText?: string
|
||||
/** 各态副文案(留空则不显示副行) */
|
||||
loadingSubText?: string
|
||||
errorSubText?: string
|
||||
emptySubText?: string
|
||||
useLoadingButton?: boolean
|
||||
}
|
||||
interface IProps {
|
||||
/** 加载状态(取值同 useDataLoading 返回的 status) */
|
||||
loadingStatus ?: DataLoadingStatus
|
||||
/** 占位区最小高度 */
|
||||
minHeight ?: string
|
||||
loadingText ?: string
|
||||
errorText ?: string
|
||||
emptyText ?: string
|
||||
/** 各态副文案(留空则不显示副行) */
|
||||
loadingSubText ?: string
|
||||
errorSubText ?: string
|
||||
emptySubText ?: string
|
||||
useLoadingButton ?: boolean
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<IProps>(), {
|
||||
loadingStatus: 'loading',
|
||||
minHeight: '80vh',
|
||||
loadingText: '稍等,正在加载中哦',
|
||||
errorText: '哎呀,加载失败了呢~',
|
||||
emptyText: '啊偶,暂时没有数据呢~',
|
||||
loadingSubText: '',
|
||||
errorSubText: '请检查网络连接,或稍后再试',
|
||||
emptySubText: '稍后再来看看吧~',
|
||||
useLoadingButton: true,
|
||||
})
|
||||
const props = withDefaults(defineProps<IProps>(), {
|
||||
loadingStatus: 'loading',
|
||||
minHeight: '80vh',
|
||||
loadingText: '稍等,正在加载中哦',
|
||||
errorText: '哎呀,加载失败了呢~',
|
||||
emptyText: '啊偶,暂时没有数据呢~',
|
||||
loadingSubText: '',
|
||||
errorSubText: '请检查网络连接,或稍后再试',
|
||||
emptySubText: '稍后再来看看吧~',
|
||||
useLoadingButton: true,
|
||||
})
|
||||
|
||||
const emit = defineEmits<{ (e: 'refresh'): void }>()
|
||||
const emit = defineEmits<{ (e : 'refresh') : void }>()
|
||||
|
||||
const isLoading = computed(() => props.loadingStatus === 'loading')
|
||||
const isLoading = computed(() => props.loadingStatus === 'loading')
|
||||
|
||||
const statusScene = computed(() => {
|
||||
switch (props.loadingStatus) {
|
||||
case 'error':
|
||||
return {
|
||||
icon: '-injury',
|
||||
stageClass: 'stage-error',
|
||||
mainTextClass: 'text-red-400',
|
||||
mainText: props.errorText,
|
||||
subText: props.errorSubText,
|
||||
}
|
||||
case 'empty':
|
||||
return {
|
||||
icon: '-confused',
|
||||
stageClass: 'stage-empty',
|
||||
mainTextClass: 'text-gray-900',
|
||||
mainText: props.emptyText,
|
||||
subText: props.emptySubText,
|
||||
}
|
||||
default:
|
||||
return {
|
||||
icon: '-happy-1',
|
||||
stageClass: 'stage-loading',
|
||||
mainTextClass: 'text-primary',
|
||||
mainText: props.loadingText,
|
||||
subText: props.loadingSubText,
|
||||
}
|
||||
}
|
||||
})
|
||||
const statusScene = computed(() => {
|
||||
switch (props.loadingStatus) {
|
||||
case 'error':
|
||||
return {
|
||||
icon: '-injury',
|
||||
stageClass: 'stage-error',
|
||||
mainTextClass: 'text-red-400',
|
||||
mainText: props.errorText,
|
||||
subText: props.errorSubText,
|
||||
}
|
||||
case 'empty':
|
||||
return {
|
||||
icon: '-confused',
|
||||
stageClass: 'stage-empty',
|
||||
mainTextClass: 'text-gray-900',
|
||||
mainText: props.emptyText,
|
||||
subText: props.emptySubText,
|
||||
}
|
||||
default:
|
||||
return {
|
||||
icon: '-happy-1',
|
||||
stageClass: 'stage-loading',
|
||||
mainTextClass: 'text-primary',
|
||||
mainText: props.loadingText,
|
||||
subText: props.loadingSubText,
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view
|
||||
class="w-full flex flex-col items-center justify-center gap-y-4 text-sm"
|
||||
:style="{ minHeight: props.minHeight }"
|
||||
>
|
||||
<view class="scene relative h-[250rpx] w-[250rpx] flex items-center justify-center" :class="statusScene.stageClass">
|
||||
<view class="glow absolute inset-0 m-auto h-[220rpx] w-[220rpx] rounded-full" />
|
||||
<view class="deco-dot dot-a absolute rounded-full" />
|
||||
<view class="deco-dot dot-b absolute rounded-full" />
|
||||
<view class="bubble relative h-[150rpx] w-[150rpx] flex items-center justify-center rounded-full">
|
||||
<text class="bubble-icon">
|
||||
<wd-icon class-prefix="uhemoji-icon" :name="statusScene.icon" size="120rpx" />
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="w-full flex flex-col items-center justify-center gap-y-4 text-sm"
|
||||
:style="{ minHeight: props.minHeight }">
|
||||
<view class="scene relative h-[250rpx] w-[250rpx] flex items-center justify-center"
|
||||
:class="statusScene.stageClass">
|
||||
<view class="glow absolute inset-0 m-auto h-[220rpx] w-[220rpx] rounded-full" />
|
||||
<view class="deco-dot dot-a absolute rounded-full" />
|
||||
<view class="deco-dot dot-b absolute rounded-full" />
|
||||
<view class="bubble relative h-[150rpx] w-[150rpx] flex items-center justify-center rounded-full">
|
||||
<text class="bubble-icon">
|
||||
<wd-icon class-prefix="uhemoji-icon" :name="statusScene.icon" size="120rpx" />
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 文案区 -->
|
||||
<view class="flex flex-col items-center">
|
||||
<view class="flex items-center justify-center text-sm font-bold" :class="statusScene.mainTextClass">
|
||||
<text>{{ statusScene.mainText }}</text>
|
||||
<view v-if="isLoading" class="ml-1 flex items-end gap-1">
|
||||
<view v-for="n in 3" :key="n" class="typing-dot bg-primary" :style="{ animationDelay: `${(n - 1) * 0.15}s` }" />
|
||||
</view>
|
||||
</view>
|
||||
<text v-if="statusScene.subText" class="mt-3 text-xs text-gray-500">
|
||||
{{ statusScene.subText }}
|
||||
</text>
|
||||
<uh-button v-if="props.useLoadingButton" class="mt-5" @click="emit('refresh')">
|
||||
刷新试试
|
||||
</uh-button>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 文案区 -->
|
||||
<view class="flex flex-col items-center">
|
||||
<view class="flex items-center justify-center text-sm font-bold" :class="statusScene.mainTextClass">
|
||||
<text>{{ statusScene.mainText }}</text>
|
||||
<view v-if="isLoading" class="ml-1 flex items-end gap-1">
|
||||
<view v-for="n in 3" :key="n" class="typing-dot bg-primary"
|
||||
:style="{ animationDelay: `${(n - 1) * 0.15}s` }" />
|
||||
</view>
|
||||
</view>
|
||||
<text v-if="statusScene.subText" class="mt-3 text-xs text-gray-500">
|
||||
{{ statusScene.subText }}
|
||||
</text>
|
||||
<view v-if="props.useLoadingButton" class="mt-5 uh-global-card-glass uh-shadow-xs border rounded-lg">
|
||||
<uh-button custom-class="!rounded-lg" @click="emit('refresh')">
|
||||
刷新试试
|
||||
</uh-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.bubble {
|
||||
animation: bubble-float 2s ease-in-out infinite;
|
||||
}
|
||||
.bubble {
|
||||
animation: bubble-float 2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.bubble-icon {
|
||||
display: inline-block;
|
||||
}
|
||||
.bubble-icon {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.glow {
|
||||
animation: glow-pulse 2.4s ease-in-out infinite;
|
||||
}
|
||||
.glow {
|
||||
animation: glow-pulse 2.4s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.stage-loading .glow {
|
||||
background: rgba(185, 228, 36, 0.32);
|
||||
}
|
||||
.stage-loading .glow {
|
||||
background: rgba(185, 228, 36, 0.32);
|
||||
}
|
||||
|
||||
.stage-error .glow {
|
||||
background: rgba(248, 113, 113, 0.24);
|
||||
}
|
||||
.stage-error .glow {
|
||||
background: rgba(248, 113, 113, 0.24);
|
||||
}
|
||||
|
||||
.stage-empty .glow {
|
||||
background: rgba(217, 249, 157, 0.5);
|
||||
}
|
||||
.stage-empty .glow {
|
||||
background: rgba(217, 249, 157, 0.5);
|
||||
}
|
||||
|
||||
.deco-dot {
|
||||
animation: deco-float 2s ease-in-out infinite;
|
||||
}
|
||||
.deco-dot {
|
||||
animation: deco-float 2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.dot-a {
|
||||
top: 16rpx;
|
||||
left: 10rpx;
|
||||
width: 22rpx;
|
||||
height: 22rpx;
|
||||
background: rgba(163, 230, 53, 0.9);
|
||||
}
|
||||
.dot-a {
|
||||
top: 16rpx;
|
||||
left: 10rpx;
|
||||
width: 22rpx;
|
||||
height: 22rpx;
|
||||
background: rgba(163, 230, 53, 0.9);
|
||||
}
|
||||
|
||||
.dot-b {
|
||||
top: 4rpx;
|
||||
right: 14rpx;
|
||||
width: 14rpx;
|
||||
height: 14rpx;
|
||||
background: rgba(217, 249, 157, 0.95);
|
||||
animation-delay: -0.7s;
|
||||
}
|
||||
.dot-b {
|
||||
top: 4rpx;
|
||||
right: 14rpx;
|
||||
width: 14rpx;
|
||||
height: 14rpx;
|
||||
background: rgba(217, 249, 157, 0.95);
|
||||
animation-delay: -0.7s;
|
||||
}
|
||||
|
||||
/* —— 三态表情差异化动效(均无限循环,柔和不抢眼) —— */
|
||||
.stage-loading .bubble-icon {
|
||||
animation: sway 1.6s ease-in-out infinite;
|
||||
}
|
||||
/* —— 三态表情差异化动效(均无限循环,柔和不抢眼) —— */
|
||||
.stage-loading .bubble-icon {
|
||||
animation: sway 1.6s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.stage-error .bubble-icon {
|
||||
animation: head-shake 2.8s ease-in-out infinite;
|
||||
transform-origin: 50% 85%;
|
||||
}
|
||||
.stage-error .bubble-icon {
|
||||
animation: head-shake 2.8s ease-in-out infinite;
|
||||
transform-origin: 50% 85%;
|
||||
}
|
||||
|
||||
.stage-empty .bubble-icon {
|
||||
animation: sigh 3s ease-in-out infinite;
|
||||
transform-origin: 50% 85%;
|
||||
}
|
||||
.stage-empty .bubble-icon {
|
||||
animation: sigh 3s ease-in-out infinite;
|
||||
transform-origin: 50% 85%;
|
||||
}
|
||||
|
||||
/* —— 加载中三点跳动(错峰延迟经模板 :style 注入,避开 WXSS 不支持的 :nth-child) —— */
|
||||
.typing-dot {
|
||||
width: 10rpx;
|
||||
height: 10rpx;
|
||||
border-radius: 50%;
|
||||
animation: dot-jump 1s ease-in-out infinite;
|
||||
}
|
||||
/* —— 加载中三点跳动(错峰延迟经模板 :style 注入,避开 WXSS 不支持的 :nth-child) —— */
|
||||
.typing-dot {
|
||||
width: 10rpx;
|
||||
height: 10rpx;
|
||||
border-radius: 50%;
|
||||
animation: dot-jump 1s ease-in-out infinite;
|
||||
}
|
||||
|
||||
/* —— keyframes —— */
|
||||
@keyframes bubble-float {
|
||||
0%,
|
||||
100% {
|
||||
transform: translateY(0);
|
||||
}
|
||||
/* —— keyframes —— */
|
||||
@keyframes bubble-float {
|
||||
|
||||
50% {
|
||||
transform: translateY(-14rpx);
|
||||
}
|
||||
}
|
||||
0%,
|
||||
100% {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
@keyframes glow-pulse {
|
||||
0%,
|
||||
100% {
|
||||
transform: scale(1);
|
||||
opacity: 0.55;
|
||||
}
|
||||
50% {
|
||||
transform: translateY(-14rpx);
|
||||
}
|
||||
}
|
||||
|
||||
50% {
|
||||
transform: scale(1.1);
|
||||
opacity: 0.9;
|
||||
}
|
||||
}
|
||||
@keyframes glow-pulse {
|
||||
|
||||
@keyframes deco-float {
|
||||
0%,
|
||||
100% {
|
||||
transform: translateY(0);
|
||||
}
|
||||
0%,
|
||||
100% {
|
||||
transform: scale(1);
|
||||
opacity: 0.55;
|
||||
}
|
||||
|
||||
50% {
|
||||
transform: translateY(-12rpx);
|
||||
}
|
||||
}
|
||||
50% {
|
||||
transform: scale(1.1);
|
||||
opacity: 0.9;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes dot-jump {
|
||||
0%,
|
||||
100% {
|
||||
transform: translateY(0);
|
||||
}
|
||||
@keyframes deco-float {
|
||||
|
||||
50% {
|
||||
transform: translateY(-8rpx);
|
||||
}
|
||||
}
|
||||
0%,
|
||||
100% {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
/* 歪头左右打量(loading) */
|
||||
@keyframes sway {
|
||||
0%,
|
||||
100% {
|
||||
transform: rotate(-4deg);
|
||||
}
|
||||
50% {
|
||||
transform: translateY(-12rpx);
|
||||
}
|
||||
}
|
||||
|
||||
50% {
|
||||
transform: rotate(4deg);
|
||||
}
|
||||
}
|
||||
@keyframes dot-jump {
|
||||
|
||||
/* 缓慢左右摇头(error) */
|
||||
@keyframes head-shake {
|
||||
0%,
|
||||
100% {
|
||||
transform: rotate(0);
|
||||
}
|
||||
0%,
|
||||
100% {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
25% {
|
||||
transform: rotate(6deg);
|
||||
}
|
||||
50% {
|
||||
transform: translateY(-8rpx);
|
||||
}
|
||||
}
|
||||
|
||||
75% {
|
||||
transform: rotate(-6deg);
|
||||
}
|
||||
}
|
||||
/* 歪头左右打量(loading) */
|
||||
@keyframes sway {
|
||||
|
||||
/* 轻轻叹气缩肩(empty) */
|
||||
@keyframes sigh {
|
||||
0%,
|
||||
100% {
|
||||
transform: scaleY(1);
|
||||
}
|
||||
0%,
|
||||
100% {
|
||||
transform: rotate(-4deg);
|
||||
}
|
||||
|
||||
30%,
|
||||
70% {
|
||||
transform: scaleY(0.92);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
50% {
|
||||
transform: rotate(4deg);
|
||||
}
|
||||
}
|
||||
|
||||
/* 缓慢左右摇头(error) */
|
||||
@keyframes head-shake {
|
||||
|
||||
0%,
|
||||
100% {
|
||||
transform: rotate(0);
|
||||
}
|
||||
|
||||
25% {
|
||||
transform: rotate(6deg);
|
||||
}
|
||||
|
||||
75% {
|
||||
transform: rotate(-6deg);
|
||||
}
|
||||
}
|
||||
|
||||
/* 轻轻叹气缩肩(empty) */
|
||||
@keyframes sigh {
|
||||
|
||||
0%,
|
||||
100% {
|
||||
transform: scaleY(1);
|
||||
}
|
||||
|
||||
30%,
|
||||
70% {
|
||||
transform: scaleY(0.92);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user