/** 头像 URL 解析（排行榜等页面共用） */
export function getDefaultAvatarUrl(app) {
  const g = app || getApp();
  const oss = g.globalData.ossImageUrl || '';
  const def = g.globalData.morentouxiang || '';
  if (!def) return '';
  if (def.startsWith('http')) return def;
  return oss + def.replace(/^\//, '');
}

export function resolveAvatarUrl(path, app) {
  if (!path || path === 'null' || path === 'undefined') return '';
  const s = String(path).trim();
  if (!s) return '';
  if (s.startsWith('http')) return s;
  const g = app || getApp();
  const oss = g.globalData.ossImageUrl || '';
  return oss + s.replace(/^\//, '');
}
