avatarUpload.ts 679 Bytes
/**
 * 判断头像是否已是服务端/公网可持久化地址(无需再 uploadFile)。
 * 相册/相机返回的 wxfile、tmp、blob 等需先上传得到 /uploads/... 再写入资料接口。
 */
export function isAlreadyPersistedAvatarUrl(path: string): boolean {
  const p = path.trim();
  if (!p) return true;
  if (p.startsWith("/uploads/")) return true;
  if (p.startsWith("wxfile://") || p.startsWith("file://")) return false;
  if (p.startsWith("blob:") || p.startsWith("data:")) return false;
  if (p.startsWith("http://tmp") || p.startsWith("https://tmp")) return false;
  if (p.startsWith("http://") || p.startsWith("https://")) return true;
  return false;
}