Blame view

稻城亚丁小程序/uniapp/src/utils/avatarUpload.ts 679 Bytes
bc518174   王天杨   提交两个项目文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
  /**
   * 判断头像是否已是服务端/公网可持久化地址(无需再 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;
  }