MapKeyGuide.tsx
1.18 KB
import { ExclamationCircleFilled } from '@ant-design/icons';
interface Props {
error: { code: string; message: string; hint: string } | null;
}
/**
* 高德地图未就绪时的引导卡。
*
* 两个高频阻塞场景都收敛到这里:
* - NO_KEY 未配置 Key,页面白屏前先给明确指引
* - LOAD_FAILED 脚本加载失败(无外网 / 域名白名单)
* 不打断式覆盖,用户按提示配好后热重载即可。
*/
export function MapKeyGuide({ error }: Props) {
if (!error) return null;
return (
<div className="hm-map__overlay">
<div className="hm-guide">
<div className="hm-guide__title">
<ExclamationCircleFilled style={{ color: 'var(--hm-warn)' }} />
地图未就绪
<span className="hm-guide__badge">{error.code}</span>
</div>
<div className="hm-guide__text">{error.message}</div>
<div className="hm-guide__hint">{error.hint}</div>
<div className="hm-guide__code">{`# 配置高德 Key(Web端 JS API 类型,并绑定 localhost)\ncp .env.example .env.local\n# 在 .env.local 填入 VITE_AMAP_KEY 与 VITE_AMAP_SECURITY_CODE\npnpm dev`}</div>
</div>
</div>
);
}