diff --git a/.env b/.env index 0026c71..e041584 100644 --- a/.env +++ b/.env @@ -5,3 +5,6 @@ WEB_PUSH_CONTACT="mailto:example@gmail.com" # VAPID_KEY NEXT_PUBLIC_VAPID_KEY="BDeQByhHcxy084_JFou3rHlqiSpFvPZhUWjQKb1QlU6TjXL8mJd3usKDsQDzEeZ1HJOuultQgtPRlGOqgrrLnQA" PRIVATE_VAPID_KEY="rZpj98WVatLMqzgWkC_mQgAbzG3WAZAtiw9hiMW3taY" +# 填入高德地图的key +NEXT_PUBLIC_AMAP_JSCODE="" +NEXT_PUBLIC_AMAP_KEY="" \ No newline at end of file diff --git a/src/app/admin/locations/page.tsx b/src/app/admin/locations/page.tsx index 2b183a9..a19cf34 100644 --- a/src/app/admin/locations/page.tsx +++ b/src/app/admin/locations/page.tsx @@ -71,7 +71,7 @@ export default function page() { function loadMap() { AMapLoader.load({ - key: "4f77082b3a2e028ff3c03d0fe2742b78", + key: process.env.NEXT_PUBLIC_AMAP_KEY, version: "2.0", }) .then((AMap) => { diff --git a/src/components/admin/Map.tsx b/src/components/admin/Map.tsx index d94a7b8..7d5c008 100644 --- a/src/components/admin/Map.tsx +++ b/src/components/admin/Map.tsx @@ -32,10 +32,10 @@ export default function Map() { // 加载地图函数,在这里可以设置地图 async function loadMap() { (window as any)._AMapSecurityConfig = { - securityJsCode: "3741a106252939f5dbc7076539dc79fb", + securityJsCode: process.env.NEXT_PUBLIC_AMAP_JSCODE, }; window.AMap = await AMapLoader.load({ - key: "4f77082b3a2e028ff3c03d0fe2742b78", + key: process.env.NEXT_PUBLIC_AMAP_KEY, version: "2.0", }); const mapOptions: AMap.MapOptions = {