- 页面:pose-hub 选择动作,pose-coach 跟练(教练小甄示范 + 摄像头动作识别计数) - 动作:徒手深蹲、原地高抬腿、低冲击开合、站姿侧平举 - VisionKit 人体识别,按动作幅度计数、评分、纠错;没有摄像头或识别不可用时自动进入领练模式 - 教练逐帧动画:分包内置 600px 帧,COS 高清帧全部加载完后无缝切换 - 语音报数与口令(WechatSI),舒缓背景音乐(COS,教练说话时自动压低,可关闭) - 逻辑单测:npm run test:pose
103 lines
2.1 KiB
Vue
103 lines
2.1 KiB
Vue
<template>
|
|
<view class="ring" :class="'is-' + theme" :style="{ background: ringBg }">
|
|
<view class="ring__inner">
|
|
<text :key="'n' + count" class="ring__n">{{ count }}</text>
|
|
<text class="ring__target">/ {{ target }}</text>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
/**
|
|
* 计数环:大号次数 + 完成进度环。人站在两米外也要看得清,所以数字要大。
|
|
* 次数变化时数字弹一下。
|
|
*/
|
|
import { computed } from 'vue'
|
|
|
|
const props = withDefaults(
|
|
defineProps<{
|
|
count: number
|
|
target: number
|
|
color?: string
|
|
/** light:亮色舞台上;dark:摄像头画面上 */
|
|
theme?: 'light' | 'dark'
|
|
}>(),
|
|
{ color: '#34d399', theme: 'light' },
|
|
)
|
|
|
|
const ringBg = computed(() => {
|
|
const deg = Math.round(Math.min(1, props.count / Math.max(1, props.target)) * 360)
|
|
const track = props.theme === 'light' ? 'rgba(22,29,25,0.08)' : 'rgba(255,255,255,0.22)'
|
|
return `conic-gradient(${props.color} ${deg}deg, ${track} ${deg}deg)`
|
|
})
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.ring {
|
|
width: 196rpx;
|
|
height: 196rpx;
|
|
border-radius: 50%;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
box-shadow: 0 12rpx 36rpx rgba(22, 29, 25, 0.12);
|
|
}
|
|
|
|
.ring__inner {
|
|
width: 164rpx;
|
|
height: 164rpx;
|
|
border-radius: 50%;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.is-light .ring__inner {
|
|
background: #fff;
|
|
}
|
|
|
|
.is-dark .ring__inner {
|
|
background: rgba(15, 23, 20, 0.72);
|
|
}
|
|
|
|
.ring__n {
|
|
font-size: 84rpx;
|
|
line-height: 1;
|
|
font-weight: 900;
|
|
font-variant-numeric: tabular-nums;
|
|
animation: ring-bump 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
}
|
|
|
|
.is-light .ring__n {
|
|
color: #161d19;
|
|
}
|
|
|
|
.is-dark .ring__n {
|
|
color: #fff;
|
|
}
|
|
|
|
.ring__target {
|
|
margin-top: 4rpx;
|
|
font-size: 24rpx;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.is-light .ring__target {
|
|
color: #6b7a72;
|
|
}
|
|
|
|
.is-dark .ring__target {
|
|
color: rgba(255, 255, 255, 0.75);
|
|
}
|
|
|
|
@keyframes ring-bump {
|
|
0% {
|
|
transform: scale(1.35);
|
|
}
|
|
100% {
|
|
transform: scale(1);
|
|
}
|
|
}
|
|
</style>
|