UI-UX/src/lib/tos.ts
iye 8d8451baa3
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 4m26s
chore(tos): bump cache version 6 → 7 for 014-2 recrop
The closeup studio cello shot (now atmosphere 2 after the swap)
had too much empty ceiling above the head. Recropped from
1440x2560 to 1440x1920 (3:4) with top offset 450px so the head sits
near the top of the frame and the full upper body is visible.

TOS upload: portraits/014-2.webp (overwrite).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-15 18:40:11 +08:00

24 lines
990 B
TypeScript

/**
* TOS 资源 URL 拼接工具
*
* 用法:
* tosUrl("portraits/001.webp")
* → https://cyberstar.tos-cn-shanghai.volces.com/cyber-star/portraits/001.webp?v=2
*
* 环境变量 NEXT_PUBLIC_TOS_DOMAIN 配置:
* .env.local / .env.production → 完整的桶 + 路径前缀 (含 scheme, 不含末尾 /)
* 未设置时 fallback 到相对路径 (/path/...), 适合本地用 public/ 静态文件托管的场景。
*
* 缓存版本号 TOS_VERSION:每次有 TOS 文件被原地覆盖更新(图片/视频),
* 把这个数字 +1。浏览器和 CDN 会把带新版本号的 URL 当作全新资源,
* 立即看到更新后的内容,不必等 TTL 过期或手动 invalidate。
*/
const TOS_BASE = (process.env.NEXT_PUBLIC_TOS_DOMAIN ?? "").replace(/\/+$/, "");
const TOS_VERSION = "7";
export function tosUrl(path: string): string {
const clean = path.replace(/^\/+/, "");
const base = TOS_BASE ? `${TOS_BASE}/${clean}` : `/${clean}`;
return `${base}?v=${TOS_VERSION}`;
}