|
@@ -1,42 +1,45 @@
|
|
|
-import {findMenuByAttr, generateMixMenus as generateMixMenusRaw} from '@/utils/menus'
|
|
|
-import {nextTick, ref} from "vue";
|
|
|
-import {useAsyncSDK, useSDK} from "@/hook";
|
|
|
-import {laserModeStack, modeDisabled} from '@/hook/custom/index'
|
|
|
-import {Mode} from "@/sdk";
|
|
|
-import {baseLines} from "@/store/baseLine";
|
|
|
-import {fixPoints} from "@/store/fixPoint";
|
|
|
-import {basePoints} from "@/store/basePoint";
|
|
|
-import {list} from "@/store/measure";
|
|
|
+import {
|
|
|
+ findMenuByAttr,
|
|
|
+ generateMixMenus as generateMixMenusRaw,
|
|
|
+} from "@/utils/menus";
|
|
|
+import { nextTick, ref } from "vue";
|
|
|
+import { useAsyncSDK, useSDK } from "@/hook";
|
|
|
+import { laserModeStack, modeDisabled } from "@/hook/custom/index";
|
|
|
+import { Mode } from "@/sdk";
|
|
|
+import { baseLines } from "@/store/baseLine";
|
|
|
+import { fixPoints } from "@/store/fixPoint";
|
|
|
+import { basePoints } from "@/store/basePoint";
|
|
|
+import { list } from "@/store/measure";
|
|
|
|
|
|
export type MenuRaw = {
|
|
|
- key: string,
|
|
|
- text: string,
|
|
|
- continued?: boolean
|
|
|
- defaultSelect?: true | (() => boolean),
|
|
|
- icon?: string,
|
|
|
- disabled?: boolean | (() => boolean),
|
|
|
- border?: boolean,
|
|
|
- children?: MenuRaw[],
|
|
|
- onClick?: () => void | (() => void)
|
|
|
-}
|
|
|
+ key: string;
|
|
|
+ text: string;
|
|
|
+ continued?: boolean;
|
|
|
+ defaultSelect?: true | (() => boolean);
|
|
|
+ icon?: string;
|
|
|
+ disabled?: boolean | (() => boolean);
|
|
|
+ border?: boolean;
|
|
|
+ children?: MenuRaw[];
|
|
|
+ onClick?: () => void | (() => void);
|
|
|
+};
|
|
|
|
|
|
export enum menuEnum {
|
|
|
- SAVE = 'save',
|
|
|
- CLEAR = 'clear',
|
|
|
- MEASURE_ROW = 'L_LINE',
|
|
|
- MEASURE_COLUMN = 'V_LINE',
|
|
|
- MEASURE_FREE = 'LINE',
|
|
|
- FIX_POINT = 'fixPoint',
|
|
|
- BASE_LINE = 'baseLine',
|
|
|
- BASE_POINT = 'basePoint',
|
|
|
+ SAVE = "save",
|
|
|
+ CLEAR = "clear",
|
|
|
+ MEASURE_ROW = "L_LINE",
|
|
|
+ MEASURE_COLUMN = "V_LINE",
|
|
|
+ MEASURE_FREE = "LINE",
|
|
|
+ FIX_POINT = "fixPoint",
|
|
|
+ BASE_LINE = "baseLine",
|
|
|
+ BASE_POINT = "basePoint",
|
|
|
}
|
|
|
|
|
|
-const vView = ref(false)
|
|
|
-useAsyncSDK().then(sdk => {
|
|
|
- sdk.scene.on('viewChange', (view) => {
|
|
|
- vView.value = view === "Top" || view === "Bottom"
|
|
|
- })
|
|
|
-})
|
|
|
+const vView = ref(false);
|
|
|
+useAsyncSDK().then((sdk) => {
|
|
|
+ sdk.scene.on("viewChange", (view) => {
|
|
|
+ vView.value = view === "Top" || view === "Bottom";
|
|
|
+ });
|
|
|
+});
|
|
|
|
|
|
export const menus: MenuRaw[] = [
|
|
|
// {
|
|
@@ -46,10 +49,15 @@ export const menus: MenuRaw[] = [
|
|
|
// },
|
|
|
{
|
|
|
icon: "clear",
|
|
|
- text: "清除",
|
|
|
+ text: "清空",
|
|
|
key: menuEnum.CLEAR,
|
|
|
- disabled: () => (baseLines.value.length + fixPoints.value.length + list.value.length + basePoints.value.length) === 0,
|
|
|
- border: true
|
|
|
+ disabled: () =>
|
|
|
+ baseLines.value.length +
|
|
|
+ fixPoints.value.length +
|
|
|
+ list.value.length +
|
|
|
+ basePoints.value.length ===
|
|
|
+ 0,
|
|
|
+ border: true,
|
|
|
},
|
|
|
{
|
|
|
icon: "measure",
|
|
@@ -61,22 +69,22 @@ export const menus: MenuRaw[] = [
|
|
|
continued: true,
|
|
|
text: "水平",
|
|
|
defaultSelect: true,
|
|
|
- key: menuEnum.MEASURE_ROW
|
|
|
+ key: menuEnum.MEASURE_ROW,
|
|
|
},
|
|
|
{
|
|
|
icon: "line_v",
|
|
|
continued: true,
|
|
|
disabled: () => vView.value,
|
|
|
text: "垂直",
|
|
|
- key: menuEnum.MEASURE_COLUMN
|
|
|
+ key: menuEnum.MEASURE_COLUMN,
|
|
|
},
|
|
|
{
|
|
|
icon: "line_f",
|
|
|
continued: true,
|
|
|
text: "自由",
|
|
|
- key: menuEnum.MEASURE_FREE
|
|
|
- }
|
|
|
- ]
|
|
|
+ key: menuEnum.MEASURE_FREE,
|
|
|
+ },
|
|
|
+ ],
|
|
|
},
|
|
|
{
|
|
|
icon: "point_f",
|
|
@@ -87,30 +95,31 @@ export const menus: MenuRaw[] = [
|
|
|
defaultSelect: true,
|
|
|
icon: "point_a",
|
|
|
text: "固定点",
|
|
|
- key: menuEnum.FIX_POINT
|
|
|
+ key: menuEnum.FIX_POINT,
|
|
|
},
|
|
|
- ]
|
|
|
+ ],
|
|
|
},
|
|
|
{
|
|
|
icon: "standard",
|
|
|
text: "基准",
|
|
|
key: "baseLineOrPoint",
|
|
|
onClick() {
|
|
|
- const sdk = useSDK()
|
|
|
- const doms = document.querySelectorAll("#navCube, #home") as NodeListOf<HTMLElement>;
|
|
|
- laserModeStack.push(ref(Mode.cloud))
|
|
|
- modeDisabled.push(ref(true))
|
|
|
- doms.forEach(dom => dom.style.display = "none");
|
|
|
- nextTick(() => sdk.enterTopView())
|
|
|
-
|
|
|
+ const sdk = useSDK();
|
|
|
+ const doms = document.querySelectorAll(
|
|
|
+ "#navCube, #home"
|
|
|
+ ) as NodeListOf<HTMLElement>;
|
|
|
+ laserModeStack.push(ref(Mode.cloud));
|
|
|
+ modeDisabled.push(ref(true));
|
|
|
+ doms.forEach((dom) => (dom.style.display = "none"));
|
|
|
+ nextTick(() => sdk.enterTopView());
|
|
|
|
|
|
return () => {
|
|
|
- doms.forEach(dom => dom.style.display = "block");
|
|
|
- sdk.leaveTopView()
|
|
|
- modeDisabled.pop()
|
|
|
- laserModeStack.pop()
|
|
|
- console.log("pop")
|
|
|
- }
|
|
|
+ doms.forEach((dom) => (dom.style.display = "block"));
|
|
|
+ sdk.leaveTopView();
|
|
|
+ modeDisabled.pop();
|
|
|
+ laserModeStack.pop();
|
|
|
+ console.log("pop");
|
|
|
+ };
|
|
|
},
|
|
|
children: [
|
|
|
{
|
|
@@ -118,44 +127,43 @@ export const menus: MenuRaw[] = [
|
|
|
icon: "line",
|
|
|
text: "基准线",
|
|
|
key: menuEnum.BASE_LINE,
|
|
|
- disabled: () => !!baseLines.value.length
|
|
|
+ disabled: () => !!baseLines.value.length,
|
|
|
},
|
|
|
{
|
|
|
defaultSelect: true,
|
|
|
icon: "point",
|
|
|
continued: true,
|
|
|
text: "基准点",
|
|
|
- key: menuEnum.BASE_POINT
|
|
|
+ key: menuEnum.BASE_POINT,
|
|
|
},
|
|
|
- ]
|
|
|
- }
|
|
|
-]
|
|
|
+ ],
|
|
|
+ },
|
|
|
+];
|
|
|
|
|
|
export const generateMixMenus = <T extends {}, K extends keyof MenuRaw>(
|
|
|
childKey: K,
|
|
|
generateFn: (men: MenuRaw) => T,
|
|
|
mainMenus: MenuRaw[] = menus
|
|
|
) => {
|
|
|
- const itemActiveKey = ref("")
|
|
|
+ const itemActiveKey = ref("");
|
|
|
return {
|
|
|
...generateMixMenusRaw(
|
|
|
- childKey,
|
|
|
- generateFn,
|
|
|
- mainMenus,
|
|
|
- menu => {
|
|
|
- if (itemActiveKey.value === menu.key) {
|
|
|
- itemActiveKey.value = null
|
|
|
- } else {
|
|
|
- menu.onClick && menu.onClick()
|
|
|
- itemActiveKey.value = menu.key
|
|
|
- }
|
|
|
-
|
|
|
- },
|
|
|
- () => itemActiveKey.value
|
|
|
- ),
|
|
|
- itemActiveKey
|
|
|
- }
|
|
|
-}
|
|
|
+ childKey,
|
|
|
+ generateFn,
|
|
|
+ mainMenus,
|
|
|
+ (menu) => {
|
|
|
+ if (itemActiveKey.value === menu.key) {
|
|
|
+ itemActiveKey.value = null;
|
|
|
+ } else {
|
|
|
+ menu.onClick && menu.onClick();
|
|
|
+ itemActiveKey.value = menu.key;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ () => itemActiveKey.value
|
|
|
+ ),
|
|
|
+ itemActiveKey,
|
|
|
+ };
|
|
|
+};
|
|
|
|
|
|
export const findMenuByKey = (value: menuEnum) =>
|
|
|
- findMenuByAttr(value, 'key', menus)
|
|
|
+ findMenuByAttr(value, "key", menus);
|