Skip to content

Commit 7379731

Browse files
committed
feat: 更新 LivePhoto 组件的指示器样式,添加纯 CSS 图标支持
1 parent cbfacd0 commit 7379731

File tree

2 files changed

+76
-25
lines changed

2 files changed

+76
-25
lines changed

src/uni_modules/uni-ui-plus/components/livephoto/index.scss

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -122,34 +122,64 @@
122122
&__indicator-icon {
123123
display: flex;
124124
align-items: center;
125-
justify-content: space-between;
125+
justify-content: center;
126+
gap: 8rpx;
126127
}
127128

128-
&__indicator-svg {
129+
// 纯 CSS 图标 - 兼容所有平台
130+
&__indicator-css {
131+
position: relative;
132+
width: 48rpx;
133+
height: 48rpx;
129134
display: flex;
130135
align-items: center;
131136
justify-content: center;
132-
box-sizing: border-box;
133-
padding: 0 2rpx;
134-
135-
:global(svg) {
136-
width: 32rpx;
137-
height: 32rpx;
138-
color: #ffffff;
139-
}
140-
141-
:global(.live-icon) {
142-
color: #ffffff;
137+
transform: scale(0.6); // 缩小到更小的显示尺寸
138+
}
139+
140+
&__indicator-center {
141+
position: absolute;
142+
width: 8rpx;
143+
height: 8rpx;
144+
background-color: #ffffff;
145+
border-radius: 50%;
146+
z-index: 3;
147+
}
148+
149+
&__indicator-inner-ring {
150+
position: absolute;
151+
width: 20rpx;
152+
height: 20rpx;
153+
border: 3rpx solid #ffffff; // 增加边框粗细
154+
border-radius: 50%;
155+
z-index: 2;
156+
}
157+
158+
&__indicator-dots {
159+
position: absolute;
160+
width: 48rpx;
161+
height: 48rpx;
162+
}
163+
164+
&__indicator-progress-dot {
165+
position: absolute;
166+
width: 5rpx; // 增加圆点大小
167+
height: 5rpx; // 增加圆点大小
168+
background-color: rgba(255, 255, 255, 0.3);
169+
border-radius: 50%;
170+
transition: background-color 0.3s ease-out;
171+
172+
&--active {
173+
background-color: #ffffff;
143174
}
144175
}
145176

146177
&__indicator-text {
147178
font-size: 24rpx;
148179
font-weight: 500;
149180
color: #ffffff;
181+
letter-spacing: 0.5rpx;
150182
line-height: 1;
151-
margin-left: 8rpx;
152-
margin-right: 6rpx;
153183
}
154184

155185
&__hint {

src/uni_modules/uni-ui-plus/components/livephoto/livephoto.vue

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { addUnit, isDef, objToStyle } from '../_utils'
44
import UpImage from '../image/image.vue'
55
import type { LivePhotoEmits, LivePhotoProps } from './livephoto'
66
import { livePhotoProps } from './livephoto'
7-
import { liveIcon, createProgressLiveIcon } from './icons'
87
98
// Props 定义
109
const props = defineProps(livePhotoProps)
@@ -78,13 +77,21 @@ const rootClass = computed(() => {
7877
return `up-live-photo ${props.customClass}`
7978
})
8079
81-
// 计算指示器图标
82-
const indicatorIcon = computed(() => {
83-
if (isVideoLoading.value) {
84-
return createProgressLiveIcon(videoLoadProgress.value)
80+
// 计算圆点位置
81+
function getDotPosition(index: number) {
82+
const angle = (index * 30 - 90) * (Math.PI / 180) // 从顶部开始,转换为弧度
83+
const radius = 20 // 圆点到中心的距离
84+
const centerX = 24 // 容器中心 X (48/2)
85+
const centerY = 24 // 容器中心 Y (48/2)
86+
87+
const x = centerX + radius * Math.cos(angle)
88+
const y = centerY + radius * Math.sin(angle)
89+
90+
return {
91+
left: `${x - 2.5}rpx`, // 减去圆点半径(5rpx/2)
92+
top: `${y - 2.5}rpx` // 减去圆点半径(5rpx/2)
8593
}
86-
return liveIcon
87-
})
94+
}
8895
8996
// 监听视频源变化,重置加载状态
9097
watch(
@@ -410,9 +417,23 @@ export default {
410417
<!-- Live Photo 指示器 - 独立于交互层,避免动画影响 -->
411418
<view v-if="showIndicator" class="up-live-photo__indicator" :class="{ 'up-live-photo__indicator--active': isPressed }">
412419
<view class="up-live-photo__indicator-icon">
413-
<!-- SVG 图标 -->
414-
<!-- eslint-disable-next-line vue/no-v-text-v-html-on-component -->
415-
<view class="up-live-photo__indicator-svg" v-html="indicatorIcon"></view>
420+
<!-- 纯 CSS 图标 - 兼容所有平台 -->
421+
<view class="up-live-photo__indicator-css">
422+
<!-- 中心圆点 -->
423+
<view class="up-live-photo__indicator-center"></view>
424+
<!-- 内圆环 -->
425+
<view class="up-live-photo__indicator-inner-ring"></view>
426+
<!-- 外围进度圆点 -->
427+
<view class="up-live-photo__indicator-dots">
428+
<view
429+
v-for="(dot, index) in 12"
430+
:key="index"
431+
class="up-live-photo__indicator-progress-dot"
432+
:class="{ 'up-live-photo__indicator-progress-dot--active': (isVideoLoading && index / 12 <= videoLoadProgress / 100) || isVideoLoaded }"
433+
:style="getDotPosition(index)"
434+
></view>
435+
</view>
436+
</view>
416437
<!-- LIVE 文字 -->
417438
<text class="up-live-photo__indicator-text">LIVE</text>
418439
</view>

0 commit comments

Comments
 (0)