front/src/utils/avatar.ts
zzh 5a26ae0048 feat: 小红书模块迁移、登录重构与 xhs-agent-desktop 桌面 Agent
- 新增小红书前端模块(启动服务、内容分析、爆款创作、发布记录、技能卡片、拟人设置、AI 助手)

- 新增 xhs-agent-desktop 独立桌面 Agent,对接 OMS 任务调度

- 登录页重构,整合微信登录与 OMS JWT 认证

- 订单、渠道、用户中心等页面与 API 增强

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 16:13:13 +08:00

26 lines
827 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/** 系统默认头像(public 静态资源) */
export const DEFAULT_AVATAR_URL = '/images/default-avatar.svg'
const IMAGE_EXT_PATTERN = /\.(png|jpe?g|gif|webp|svg|bmp|ico)(\?.*)?$/i
/** 判断是否为可用的头像地址(过滤 "1234" 等无效占位) */
export function isValidAvatarUrl(url?: string | null): boolean {
if (!url?.trim()) return false
const value = url.trim()
if (
value.startsWith('http://') ||
value.startsWith('https://') ||
value.startsWith('data:image/') ||
value.startsWith('blob:') ||
value.startsWith('/')
) {
return true
}
return IMAGE_EXT_PATTERN.test(value)
}
/** 无头像或无效地址时返回系统默认头像 */
export function resolveAvatarUrl(url?: string | null): string {
return isValidAvatarUrl(url) ? url!.trim() : DEFAULT_AVATAR_URL
}