This commit is contained in:
zk
2023-12-19 12:41:15 +08:00
parent 9b5be1af25
commit 5342774ca5
9 changed files with 50 additions and 39 deletions
+3 -13
View File
@@ -1,18 +1,8 @@
#后台地址 #后台地址
#VITE_GLOB_API_URL=https://api.cqygjk.com VITE_GLOB_API_URL=https://api.cqygjk.com
#应急求助-websocket #应急求助-websocket
#VITE_GLOB_API_YIN_JI=wss://api.cqygjk.com/health-watch/websocket/watchMonitor VITE_GLOB_API_YIN_JI=wss://api.cqygjk.com/health-watch/websocket/watchMonitor
#健康监测工具报警-websocket #健康监测工具报警-websocket
#VITE_GLOB_API_JIAN_CE=wss://api.cqygjk.com/health-emergency/websocket/emergency VITE_GLOB_API_JIAN_CE=wss://api.cqygjk.com/health-emergency/websocket/emergency
# 王昊地址
#VITE_GLOB_API_URL=http://192.168.1.3
#开发环境
VITE_GLOB_API_URL=http://cqyt.dev.yg.dt.io
#应急求助-websocket
VITE_GLOB_API_YIN_JI=ws://cqyt.dev.yg.dt.io/health-watch/websocket/watchMonitor
#健康监测工具报警-websocket
VITE_GLOB_API_JIAN_CE=ws://cqyt.dev.yg.dt.io/health-emergency/websocket/emergency
-1
View File
@@ -14,7 +14,6 @@
</script> </script>
<!-- <script type="text/javascript"--> <!-- <script type="text/javascript"-->
<!-- src="https://webapi.amap.com/maps?v=2.0&key=4bbcb216b889f2d612cbed05ae6979c8&plugin=AMap.Driving,AMap.ToolBar,AMap.Driving,AMap.GeoJSON,AMap.MarkerCluster"></script>--> <!-- src="https://webapi.amap.com/maps?v=2.0&key=4bbcb216b889f2d612cbed05ae6979c8&plugin=AMap.Driving,AMap.ToolBar,AMap.Driving,AMap.GeoJSON,AMap.MarkerCluster"></script>-->
<script type="module" src="./public/amap.js"></script>
</head> </head>
<style> <style>
html, body, #app { html, body, #app {
+1
View File
@@ -46,6 +46,7 @@
"less": "^4.2.0", "less": "^4.2.0",
"typescript": "^5.0.2", "typescript": "^5.0.2",
"vite": "^4.4.5", "vite": "^4.4.5",
"vite-plugin-resolve-externals": "^0.2.2",
"vue-tsc": "^1.8.5" "vue-tsc": "^1.8.5"
} }
} }
+12 -1
View File
@@ -1,3 +1,4 @@
import AMapLoader from '@amap/amap-jsapi-loader';
import china from '/@/assets/lngLat/china.ts'; import china from '/@/assets/lngLat/china.ts';
import chinaInner from '/@/assets/lngLat/chinaInner.ts'; import chinaInner from '/@/assets/lngLat/chinaInner.ts';
import { createCircle, createIcon, typeToIcon } from '/@/assets/mapUtils/commonFun.ts'; import { createCircle, createIcon, typeToIcon } from '/@/assets/mapUtils/commonFun.ts';
@@ -11,6 +12,7 @@ export const defaultOption = {
mapStyle: 'darkblue', //地图样式 mapStyle: 'darkblue', //地图样式
}; };
export const mapPlugin = ['AMap.ToolBar', 'AMap.Driving', 'AMap.GeoJSON', 'AMap.MarkerCluster', 'AMap.PlaceSearch']; export const mapPlugin = ['AMap.ToolBar', 'AMap.Driving', 'AMap.GeoJSON', 'AMap.MarkerCluster', 'AMap.PlaceSearch'];
let AMap = null;
export const Map = { export const Map = {
map: null, map: null,
overlayGroup: null, // 地图中marker overlayGroup: null, // 地图中marker
@@ -25,19 +27,28 @@ export const Map = {
* @param option 地图配置 * @param option 地图配置
*/ */
initMap({ el, option }: InitMap) { initMap({ el, option }: InitMap) {
AMapLoader.load({
key: '4bbcb216b889f2d612cbed05ae6979c8', // 申请好的Web端开发者Key,首次调用 load 时必填
// version: '1.4.15', // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
version: '2.0', // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
plugins: mapPlugin, // 需要使用的的插件列表,如比例尺'AMap.Scale'等
}).then((res) => {
AMap = res;
const { zoom, center, mapStyle } = { ...defaultOption, ...option }; const { zoom, center, mapStyle } = { ...defaultOption, ...option };
//基本地图加载 //基本地图加载
this.map = new AMap.Map(el, { this.map = new AMap.Map(el, {
resizeEnable: true, resizeEnable: true,
center: center, center: center,
zoom: zoom, zoom: zoom,
mapStyle: 'amap://styles/' + mapStyle, mapStyle: 'amap://styles/darkblue',
version: '2.0',
}); });
// 异步同时加载多个插件 // 异步同时加载多个插件
new AMap.plugin(mapPlugin, () => { new AMap.plugin(mapPlugin, () => {
this.drawInnerLine(); this.drawInnerLine();
this.drawOutLine(); this.drawOutLine();
}); });
});
} /** } /**
* @desc 中国外层边界线 * @desc 中国外层边界线
*/, */,
@@ -61,7 +61,6 @@
const watchDialogRef = ref(); const watchDialogRef = ref();
function openWatchList(item) { function openWatchList(item) {
console.log('item', item);
if (item.key == 'allotDeviceNum') { if (item.key == 'allotDeviceNum') {
watchDialogRef.value.openModal(item.extData?.deptId); watchDialogRef.value.openModal(item.extData?.deptId);
} }
@@ -110,13 +109,13 @@
const { detailLeft, detailRight, setDetail } = useAlarmDetail(); const { detailLeft, detailRight, setDetail } = useAlarmDetail();
onMounted(() => { onMounted(() => {
init(); // init();
//点击预警定位 // //点击预警定位
$bus.on(earlyWarning, (params) => { // $bus.on(earlyWarning, (params) => {
setDetail(params); // setDetail(params);
drawMarker(params); // drawMarker(params);
setIsShowAlarm(true); // setIsShowAlarm(true);
}); // });
}); });
/** /**
-1
View File
@@ -8,7 +8,6 @@ import registerGlobComp from './assets/ts/antd.ts';
import directiveMethods from './assets/ts/directive'; import directiveMethods from './assets/ts/directive';
import { setupStore } from './store/index.ts'; import { setupStore } from './store/index.ts';
const app = createApp(App); const app = createApp(App);
// 注册自定义事件 // 注册自定义事件
directiveMethods(app); directiveMethods(app);
+3
View File
@@ -8,6 +8,9 @@
"DOM", "DOM",
"DOM.Iterable" "DOM.Iterable"
], ],
"types": [
"vite/client"
],
"skipLibCheck": true, "skipLibCheck": true,
"baseUrl": ".", "baseUrl": ".",
/* */ /* */
+4
View File
@@ -0,0 +1,4 @@
declare interface Window {
AMap: any;
initAMap: any;
}
+5
View File
@@ -2,6 +2,8 @@ import {defineConfig} from 'vite';
import vue from '@vitejs/plugin-vue'; import vue from '@vitejs/plugin-vue';
import { resolve } from 'path'; import { resolve } from 'path';
import resolveExternalsPlugin from 'vite-plugin-resolve-externals';
function pathResolve(dir: string) { function pathResolve(dir: string) {
return resolve(process.cwd(), '.', dir); return resolve(process.cwd(), '.', dir);
} }
@@ -10,6 +12,9 @@ function pathResolve(dir: string) {
export default defineConfig({ export default defineConfig({
plugins: [ plugins: [
vue(), vue(),
resolveExternalsPlugin({
AMap: 'AMap',
}),
], ],
css: { css: {
preprocessorOptions: { preprocessorOptions: {