feat: add ApprovalCenterView with animated rolling values

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
2026-05-01 00:41:52 +08:00
parent 7d6dbc4ac0
commit 99fde07826
3 changed files with 796 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
import { onBeforeUnmount, onMounted, ref, watch } from 'vue'
export function useAnimationProgress(deps = [], duration = 1100) {
const progress = ref(0)
let frameId = 0
const easeOutCubic = (value) => 1 - Math.pow(1 - value, 3)
function start() {
cancelAnimationFrame(frameId)
if (window.matchMedia?.('(prefers-reduced-motion: reduce)').matches) {
progress.value = 1
return
}
const startedAt = performance.now()
progress.value = 0
function tick(now) {
const elapsed = Math.min((now - startedAt) / duration, 1)
progress.value = easeOutCubic(elapsed)
if (elapsed < 1) frameId = requestAnimationFrame(tick)
}
frameId = requestAnimationFrame(tick)
}
onMounted(start)
onBeforeUnmount(() => cancelAnimationFrame(frameId))
if (deps.length) {
watch(deps, start)
}
return progress
}