// 读取记录的主键，兼容多种 ID 字段名
export function pickId(row) {
  return row?.id ?? row?.mapId ?? row?.map_id ?? row?.ID ?? row?.MapId;
}

// === 根据真实路由配置构造跳转对象 ===

// Nav route: name: 'Navigation', path: '/map/maplist/navigation/index/:mapId(\\d+)', params: { mapId }
export function buildNavTo(row) {
  const id = pickId(row);
  return { 
    name: 'Navigation', 
    params: { mapId: id } 
  };
}

// Edit route: name: 'Edit', path: '/map/maplist/edit/index/:mapId(\\d+)', params: { mapId }
export function buildEditTo(row) {
  const id = pickId(row);
  return { 
    name: 'Edit', 
    params: { mapId: id } 
  };
}

// Calibration route: name: 'Calibration', path: '/map/maplist/calibration/index/:mapId(\\d+)', params: { mapId }
export function buildCalibrateTo(row) {
  const id = pickId(row);
  return { 
    name: 'Calibration', 
    params: { mapId: id } 
  };
}

// Build route (fallback implementation as no specific route was found)
export function buildConstructTo(row) {
  const id = pickId(row);
  // 使用通用路径，因为未找到特定的构建地图路由
  return { path: '/map/build', query: { id } };
}