// import { map } from "core-js/core/array";

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

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

// Nav route: name: 'MapNavigation', path: '/map/maplist/navigation/index/:mapId(\\d+)', params: { mapId }, query: { mapName }
export function buildNavTo(row) {
  const id = pickId(row);
  const mapName = pickName(row);
    console.log("id的值:", id);
  return { 
    name: 'MapNavigation', 
    params: { mapId: id },
    query: { mapName: mapName }
  };
}

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

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

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