mirror of
https://github.com/ialley-workshop-open/uni-halo.git
synced 2026-11-13 22:11:42 +08:00
refactor: 整理项目代码风格与修复细节问题
本次提交包含多项优化: 1. 修复htmlToPlainText入参类型校验逻辑 2. 移除冗余的overflow-hidden类名,调整分类组件样式 3. 新增自定义导航占位hook统一处理导航栏间距 4. 优化投票筛选选项文字大小,修复文章摘要获取逻辑 5. 重构画廊页面分类吸顶逻辑,调整分类项样式与滚动行为 6. 统一about与contact页面的模糊样式类名,调整页面内文字大小与间距 7. 重构useDataLoading工具函数的导入与代码格式 8. 优化设置页面的UI样式与按钮文字大小 9. 统一投票卡片组件的代码缩进与文字样式 10. 重构联系页面的代码格式,统一变量声明风格
This commit is contained in:
@@ -1,95 +1,91 @@
|
||||
<script lang="ts" setup>
|
||||
import { formatTime as formatTimeUtil } from '@/utils/formatTime'
|
||||
import { formatTime as formatTimeUtil } from '@/utils/formatTime'
|
||||
|
||||
interface IVoteCardOption {
|
||||
id?: string
|
||||
title?: string
|
||||
checked?: boolean
|
||||
_uh_percent?: number
|
||||
[key: string]: unknown
|
||||
}
|
||||
interface IVoteCardOption {
|
||||
id ?: string
|
||||
title ?: string
|
||||
checked ?: boolean
|
||||
_uh_percent ?: number
|
||||
[key : string] : unknown
|
||||
}
|
||||
|
||||
interface IVoteCardData {
|
||||
metadata?: { name?: string, [key: string]: unknown }
|
||||
spec?: {
|
||||
title?: string
|
||||
remark?: string
|
||||
type?: string
|
||||
timeLimit?: string
|
||||
startDate?: string
|
||||
endDate?: string
|
||||
isVoted?: boolean
|
||||
_uh_type?: string
|
||||
_uh_state?: { state: string, color: string, bgColor: string }
|
||||
options?: IVoteCardOption[]
|
||||
[key: string]: unknown
|
||||
}
|
||||
stats?: { voteCount?: number, voteDataList?: { id?: string, voteCount?: number }[] }
|
||||
[key: string]: unknown
|
||||
}
|
||||
interface IVoteCardData {
|
||||
metadata ?: { name ?: string, [key : string] : unknown }
|
||||
spec ?: {
|
||||
title ?: string
|
||||
remark ?: string
|
||||
type ?: string
|
||||
timeLimit ?: string
|
||||
startDate ?: string
|
||||
endDate ?: string
|
||||
isVoted ?: boolean
|
||||
_uh_type ?: string
|
||||
_uh_state ?: { state : string, color : string, bgColor : string }
|
||||
options ?: IVoteCardOption[]
|
||||
[key : string] : unknown
|
||||
}
|
||||
stats ?: { voteCount ?: number, voteDataList ?: { id ?: string, voteCount ?: number }[] }
|
||||
[key : string] : unknown
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
vote: IVoteCardData
|
||||
}>()
|
||||
const props = defineProps<{
|
||||
vote : IVoteCardData
|
||||
}>()
|
||||
|
||||
/** 跳转投票详情 */
|
||||
function handleToDetail() {
|
||||
uni.navigateTo({
|
||||
url: `/pages-blog/vote-detail/vote-detail?name=${props.vote?.metadata?.name || ''}`,
|
||||
})
|
||||
}
|
||||
/** 跳转投票详情 */
|
||||
function handleToDetail() {
|
||||
uni.navigateTo({
|
||||
url: `/pages-blog/vote-detail/vote-detail?name=${props.vote?.metadata?.name || ''}`,
|
||||
})
|
||||
}
|
||||
|
||||
/** 格式化时间 */
|
||||
function formatTime(date?: string, fmt = 'yyyy-MM-dd HH:mm'): string {
|
||||
return date ? formatTimeUtil({ d: date, f: fmt }) : ''
|
||||
}
|
||||
/** 格式化时间 */
|
||||
function formatTime(date ?: string, fmt = 'yyyy-MM-dd HH:mm') : string {
|
||||
return date ? formatTimeUtil({ d: date, f: fmt }) : ''
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="uh-global-card-glass box-border w-full rounded-2xl p-4" @click="handleToDetail">
|
||||
<!-- 头部:类型/状态/已投票 -->
|
||||
<view class="flex items-center justify-between">
|
||||
<view class="flex flex-wrap items-center gap-1">
|
||||
<text
|
||||
v-if="vote.spec?._uh_type"
|
||||
class="rounded-md bg-secondary px-1.5 py-0.5 text-[22rpx] text-[#4d7c0f]"
|
||||
>
|
||||
{{ vote.spec._uh_type }}
|
||||
</text>
|
||||
<text
|
||||
v-if="vote.spec?._uh_state"
|
||||
class="rounded-md px-1.5 py-0.5 text-[22rpx]"
|
||||
:class="[vote.spec._uh_state.color, vote.spec._uh_state.bgColor]"
|
||||
>
|
||||
{{ vote.spec._uh_state.state }}
|
||||
</text>
|
||||
<text v-if="vote.spec?.isVoted" class="rounded-md bg-primary/15 px-1.5 py-0.5 text-[22rpx] text-primary">
|
||||
已投票
|
||||
</text>
|
||||
</view>
|
||||
<wd-icon name="arrow-right" size="32rpx" class="text-primary" />
|
||||
</view>
|
||||
<view class="uh-global-card-glass box-border w-full rounded-2xl p-4" @click="handleToDetail">
|
||||
<!-- 头部:类型/状态/已投票 -->
|
||||
<view class="flex items-center justify-between">
|
||||
<view class="flex flex-wrap items-center gap-1">
|
||||
<text v-if="vote.spec?._uh_type"
|
||||
class="rounded-md bg-secondary px-1.5 py-0.5 text-xs text-[#4d7c0f]">
|
||||
{{ vote.spec._uh_type }}
|
||||
</text>
|
||||
<text v-if="vote.spec?._uh_state" class="rounded-md px-1.5 py-0.5 text-xs"
|
||||
:class="[vote.spec._uh_state.color, vote.spec._uh_state.bgColor]">
|
||||
{{ vote.spec._uh_state.state }}
|
||||
</text>
|
||||
<text v-if="vote.spec?.isVoted"
|
||||
class="rounded-md bg-primary/15 px-1.5 py-0.5 text-xs text-primary">
|
||||
已投票
|
||||
</text>
|
||||
</view>
|
||||
<wd-icon name="arrow-right" size="32rpx" class="text-primary" />
|
||||
</view>
|
||||
|
||||
<!-- 标题 + 备注 -->
|
||||
<view class="vote-title mt-2 text-[30rpx] font-bold text-gray-900">
|
||||
{{ vote.spec?.title }}
|
||||
</view>
|
||||
<view v-if="vote.spec?.remark" class="vote-desc mt-1 text-[24rpx] text-gray-400">
|
||||
{{ vote.spec.remark }}
|
||||
</view>
|
||||
<!-- 标题 + 备注 -->
|
||||
<view class="vote-title mt-2 text-sm font-bold text-gray-900">
|
||||
{{ vote.spec?.title }}
|
||||
</view>
|
||||
<view v-if="vote.spec?.remark" class="vote-desc mt-1 text-[24rpx] text-gray-400">
|
||||
{{ vote.spec.remark }}
|
||||
</view>
|
||||
|
||||
<!-- 底部:时间 + 参与人数 -->
|
||||
<view class="vote-card-foot mt-3 flex items-center justify-between border-t border-black/5 pt-2">
|
||||
<text v-if="vote.spec?.timeLimit === 'permanent'" class="text-[22rpx] text-gray-400">
|
||||
结束:永久有效
|
||||
</text>
|
||||
<text v-else-if="vote.spec?._uh_state?.state === '未开始'" class="text-[22rpx] text-gray-400">
|
||||
开始:{{ formatTime(vote.spec?.startDate) }}
|
||||
</text>
|
||||
<text v-else class="text-[22rpx] text-gray-400">
|
||||
结束:{{ formatTime(vote.spec?.endDate) }}
|
||||
</text>
|
||||
<text class="text-[22rpx] text-gray-400">{{ vote.stats?.voteCount || 0 }} 人已参与</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<!-- 底部:时间 + 参与人数 -->
|
||||
<view class="vote-card-foot mt-3 flex items-center justify-between border-t border-black/5 pt-2">
|
||||
<text v-if="vote.spec?.timeLimit === 'permanent'" class="text-xs text-gray-400">
|
||||
结束:永久有效
|
||||
</text>
|
||||
<text v-else-if="vote.spec?._uh_state?.state === '未开始'" class="text-xs text-gray-400">
|
||||
开始:{{ formatTime(vote.spec?.startDate) }}
|
||||
</text>
|
||||
<text v-else class="text-xs text-gray-400">
|
||||
结束:{{ formatTime(vote.spec?.endDate) }}
|
||||
</text>
|
||||
<text class="text-xs text-gray-400">{{ vote.stats?.voteCount || 0 }} 人已参与</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
Reference in New Issue
Block a user