Initial commit

This commit is contained in:
wfz
2026-05-13 16:24:00 +08:00
commit 5728d3cbda
55 changed files with 37267 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
export function getVideoUrl(name: string): string {
return `https://pub-7d4a6640bc77480c99842eea19bb2b69.r2.dev/${name}`
}
export function clamp(value: number, min: number, max: number): number {
return Math.min(Math.max(value, min), max)
}
export function isMobileDevice(): boolean {
if (typeof window === 'undefined') return false
return window.innerWidth < 768 || 'ontouchstart' in window
}
export function getOS(): 'mac' | 'windows' | 'linux' | 'unknown' {
if (typeof window === 'undefined') return 'unknown'
const userAgent = window.navigator.userAgent
if (userAgent.includes('Mac')) return 'mac'
if (userAgent.includes('Windows')) return 'windows'
if (userAgent.includes('Linux')) return 'linux'
return 'unknown'
}
export function debounce<T extends (...args: unknown[]) => void>(fn: T, delay: number): T {
let timeoutId: ReturnType<typeof setTimeout>
return ((...args: Parameters<T>) => {
clearTimeout(timeoutId)
timeoutId = setTimeout(() => fn(...args), delay)
}) as T
}
export function throttle<T extends (...args: unknown[]) => void>(fn: T, delay: number): T {
let lastCall = 0
return ((...args: Parameters<T>) => {
const now = Date.now()
if (now - lastCall >= delay) {
lastCall = now
fn(...args)
}
}) as T
}