|
|
@@ -81,13 +81,18 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div style="overflow: auto">
|
|
|
+ <div style="overflow: auto; position: relative">
|
|
|
<canvas
|
|
|
width="400"
|
|
|
height="400"
|
|
|
id="mapEditCanvas"
|
|
|
style="border: 1px solid #ccc"
|
|
|
></canvas>
|
|
|
+ <ContextMenu
|
|
|
+ :visible="menuVisible"
|
|
|
+ :position="mousePosition"
|
|
|
+ :set-default="handleSetDefault"
|
|
|
+ />
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -107,6 +112,7 @@
|
|
|
import { useGlobSetting } from '@/hooks/setting';
|
|
|
import { computed } from 'vue';
|
|
|
import { Search } from '@element-plus/icons-vue';
|
|
|
+ import ContextMenu from './MapBase/ContextMenu.vue';
|
|
|
|
|
|
const miniMap = useMiniMap();
|
|
|
const globSetting = useGlobSetting();
|
|
|
@@ -115,10 +121,15 @@
|
|
|
|
|
|
let map: CameraMap;
|
|
|
const selectedCamera = ref<CameraImage | null>(null);
|
|
|
+ /** 右键选中的摄像机 */
|
|
|
+ const rightSelectedCamera = ref<CameraImage | null>(null);
|
|
|
const cameraOptions = ref<{ label: string; value: string }[]>([]);
|
|
|
const defaultCameraId = ref('');
|
|
|
const searchKey = ref('');
|
|
|
|
|
|
+ const mousePosition = ref<{ left: number; top: number }>({ left: 0, top: 0 });
|
|
|
+ const menuVisible = ref(false);
|
|
|
+
|
|
|
const handleAvatarSuccess = (e) => {
|
|
|
const imgPath = e.data;
|
|
|
const imgUrl = urlJoin(globSetting.imgUrl!, imgPath);
|
|
|
@@ -151,7 +162,11 @@
|
|
|
if (selectedShopId.value) {
|
|
|
getShopContent();
|
|
|
}
|
|
|
- map = new CameraMap({ canvasId: 'mapEditCanvas', onSelect: onSelectCamera });
|
|
|
+ map = new CameraMap({
|
|
|
+ canvasId: 'mapEditCanvas',
|
|
|
+ onSelect: onSelectCamera,
|
|
|
+ onRightClick: handleRightClick,
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
const keyupListener = (e) => {
|
|
|
@@ -203,6 +218,13 @@
|
|
|
const onSelectCamera = (cameraImg: CameraImage) => {
|
|
|
console.log('onSelectCamera', cameraImg);
|
|
|
selectedCamera.value = cameraImg;
|
|
|
+ menuVisible.value = false;
|
|
|
+ };
|
|
|
+
|
|
|
+ const handleRightClick = (e) => {
|
|
|
+ mousePosition.value = { left: e.pointer.x, top: e.pointer.y };
|
|
|
+ menuVisible.value = true;
|
|
|
+ rightSelectedCamera.value = e.target;
|
|
|
};
|
|
|
|
|
|
const mapJSONToOptions = () => {
|
|
|
@@ -238,6 +260,14 @@
|
|
|
}
|
|
|
selectedCamera.value = null;
|
|
|
};
|
|
|
+
|
|
|
+ const handleSetDefault = () => {
|
|
|
+ const cameraId = rightSelectedCamera.value?.cameraId;
|
|
|
+ if (!cameraId) return;
|
|
|
+ defaultCameraId.value = cameraId;
|
|
|
+ /** 选择完成后隐藏 */
|
|
|
+ menuVisible.value = false;
|
|
|
+ };
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|