cf88d3a1d2
- #22: 高德 API fetch 加 try/catch,失败返回 503 而非泛化 500 - #23: buildNavUrl 校验 location.split(",") 结果长度和非空 - #24: handleReset/handleNarrow 检查 res.ok,失败时 toast 提示
12 lines
484 B
TypeScript
12 lines
484 B
TypeScript
import type { Restaurant } from "@/types";
|
|
|
|
export function buildNavUrl(restaurant: Restaurant): string {
|
|
if (restaurant.location) {
|
|
const parts = restaurant.location.split(",");
|
|
if (parts.length === 2 && parts[0] && parts[1]) {
|
|
return `https://uri.amap.com/marker?position=${parts[0]},${parts[1]}&name=${encodeURIComponent(restaurant.name)}&callnative=1`;
|
|
}
|
|
}
|
|
return `https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(restaurant.name)}`;
|
|
}
|