All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 3m43s
14号 gallery atmospheres 1 & 2 swapped + atmosphere 1 recropped to 3:4 to frame the upper body. Same TOS URLs with new content, version bump forces CDN/browsers to refetch. TOS uploads: portraits/014.webp (overwrite, now wide-orchestra cropped to 3:4), portraits/014-2.webp (overwrite, now closeup studio shot). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
24 lines
990 B
TypeScript
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 = "6";
|
|
|
|
export function tosUrl(path: string): string {
|
|
const clean = path.replace(/^\/+/, "");
|
|
const base = TOS_BASE ? `${TOS_BASE}/${clean}` : `/${clean}`;
|
|
return `${base}?v=${TOS_VERSION}`;
|
|
}
|