Browse Source

fix: 修改bug 第一轮

bill 3 months ago
parent
commit
4d26003910
40 changed files with 270 additions and 97 deletions
  1. 1 1
      .env.jm
  2. 2 2
      .env.jmdev
  3. 2 2
      .env.jmtest
  4. 73 0
      public/static/kankan.html
  5. 5 3
      src/core/components/arrow/arrow.vue
  6. 1 1
      src/core/components/arrow/index.ts
  7. 3 3
      src/core/components/circle/circle.vue
  8. 1 1
      src/core/components/circle/index.ts
  9. 3 3
      src/core/components/icon/icon.vue
  10. 25 13
      src/core/components/line/single-line.vue
  11. 5 1
      src/core/components/line/temp-line.vue
  12. 0 1
      src/core/components/polygon/index.ts
  13. 3 3
      src/core/components/polygon/polygon.vue
  14. 1 1
      src/core/components/rectangle/index.ts
  15. 3 3
      src/core/components/rectangle/rectangle.vue
  16. 3 3
      src/core/components/sequent-line/line.vue
  17. 4 0
      src/core/components/share/edit-line.vue
  18. 4 0
      src/core/components/share/edit-point.vue
  19. 1 1
      src/core/components/share/size-line.vue
  20. 5 5
      src/core/components/table/table.vue
  21. 3 3
      src/core/components/text/index.ts
  22. 3 1
      src/core/components/triangle/index.ts
  23. 3 3
      src/core/components/triangle/triangle.vue
  24. 9 6
      src/core/helper/split-line.vue
  25. 2 2
      src/core/hook/use-expose.ts
  26. 1 1
      src/core/hook/use-transformer.ts
  27. 4 2
      src/core/hook/use-viewer.ts
  28. 1 1
      src/core/html-mount/propertys/describes.json
  29. 1 1
      src/example/components/header/actions.ts
  30. 2 2
      src/example/components/slide/actions.ts
  31. 3 3
      src/example/components/slide/slide.vue
  32. 20 6
      src/example/dialog/ai/ai.vue
  33. 7 1
      src/example/dialog/dialog.vue
  34. 1 1
      src/example/dialog/vr/vr.vue
  35. 3 0
      src/example/env.ts
  36. 33 12
      src/example/fuse/enter.ts
  37. 13 1
      src/example/fuse/views/overview/header.vue
  38. 13 1
      src/example/fuse/views/tabulation/header.vue
  39. 1 0
      src/utils/resource.ts
  40. 2 3
      vite.config.ts

+ 1 - 1
.env.jm

@@ -8,7 +8,7 @@ VITE_MESH_API='/'
 VITE_CLOUD_API='/'
 VITE_FUSE_API='/'
 
-VITE_MESH_VIEW='/spg.html?m={m}&lang=zh'
+VITE_MESH_VIEW='./static/kankan.html?m={m}&lang=zh&env=prod&token={token}'
 VITE_CLOUD_VIEW='/swss/index.html?m={m}&lang=zh'
 VITE_FUSE_VIEW='/code/'
 VITE_LOGIN_VIEW='/admin/index.html#/login?redirect={redirect}'

+ 2 - 2
.env.jmdev

@@ -1,6 +1,6 @@
 VITE_PRIMARY='#109BE0'
 VITE_TITLE='绘图'
-VITE_ENTRY='./example/fuse/enter.ts'
+VITE_ENTRY='/example/fuse/enter.ts'
 VITE_ENTRY_EXAMPLE='./main.ts'
 VITE_MOCK_ENV=jmtest
 
@@ -11,7 +11,7 @@ VITE_MESH_API='/meshAPI/'
 VITE_CLOUD_API='/cloudAPI/'
 VITE_FUSE_API='/fuseAPI/'
 
-VITE_MESH_VIEW='http://192.168.0.25/spg.html?m={m}&lang=zh&token={token}'
+VITE_MESH_VIEW='./static/kankan.html?m={m}&lang=zh&env=dev&token={token}'
 VITE_CLOUD_VIEW='http://192.168.0.25/swss/index.html?m={m}&lang=zh&token={token}'
 VITE_FUSE_VIEW='http://192.168.0.25/code/'
 VITE_LOGIN_VIEW='http://192.168.0.25/admin/index.html#/login?redirect={redirect}'

+ 2 - 2
.env.jmtest

@@ -1,6 +1,6 @@
 VITE_PRIMARY='#109BE0'
 VITE_TITLE='绘图'
-VITE_ENTRY='./example/fuse/enter.ts'
+VITE_ENTRY='/example/fuse/enter.ts'
 VITE_ENTRY_EXAMPLE='./main.ts'
 
 
@@ -10,7 +10,7 @@ VITE_MESH_API='http://192.168.0.25/'
 VITE_CLOUD_API='http://192.168.0.25/'
 VITE_FUSE_API='http://192.168.0.25/'
 
-VITE_MESH_VIEW='http://192.168.0.25/spg.html?m={m}&lang=zh'
+VITE_MESH_VIEW='./static/kankan.html?m={m}&lang=zh&env=dev'
 VITE_CLOUD_VIEW='http://192.168.0.25/swss/index.html?m={m}&lang=zh'
 VITE_FUSE_VIEW='http://192.168.0.25/code/'
 VITE_LOGIN_VIEW='http://192.168.0.25/admin/#/statistics/scene?redirect={redirect}'

+ 73 - 0
public/static/kankan.html

@@ -0,0 +1,73 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+  <meta charset="UTF-8">
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
+  <title>Document</title>
+  <style>
+    html,
+    body {
+      width: 100%;
+      height: 100%;
+      margin: 0;
+      overflow: hidden;
+    }
+
+    .scene {
+      width: 100%;
+      height: 100%;
+    }
+  </style>
+</head>
+
+<body>
+  <div id="scene" class="scene"></div>
+  <div class="map"></div>
+  <script>
+    const params = new URLSearchParams(location.search)
+    const env = params.get('env')
+    console.log(env)
+    let host = 'http://192.168.0.25'
+    if (env === 'prod') {
+      host = ''
+    }
+
+    const $script1 = document.createElement('script')
+    $script1.src = `${host}/sdk/kankan-sdk-deps.js`
+    document.documentElement.appendChild($script1)
+
+    const $script2 = document.createElement('script')
+    $script2.src = `${host}/sdk/kankan-sdk.js`
+    document.documentElement.appendChild($script2)
+
+
+    let loadPackCount = 0
+    $script1.onload = () => {
+      ++loadPackCount
+      init()
+    }
+    $script2.onload = () => {
+      ++loadPackCount
+      init()
+    }
+
+    const init = () => {
+      if (loadPackCount < 2) return;
+      var kankan = new KanKan({
+        dom: '#scene',
+        num: params.get('m'),
+        server: host,
+        resource: host + '/oss/'
+      })
+      kankan.render()
+    }
+  </script>
+
+  <script src="//4dkk.4dage.com/v4/sdk/4.10.5/kankan-sdk-deps.js"></script>
+  <script src="//4dkk.4dage.com/v4/sdk/4.10.5/kankan-sdk.js"></script>
+  <script>
+  </script>
+</body>
+
+</html>

+ 5 - 3
src/core/components/arrow/arrow.vue

@@ -60,9 +60,9 @@ const { shape, tData, operateMenus, describes, data } = useComponentStatus<
   props,
   getMouseStyle,
   defaultStyle,
-  alignment(data, mat) {
-    return matResponse({ mat, data, increment: true });
-  },
+  // alignment(data, mat) {
+  //   return matResponse({ mat, data, increment: true });
+  // },
   transformType: "line",
   getRepShape(): Line {
     return new Line({
@@ -86,6 +86,8 @@ const { shape, tData, operateMenus, describes, data } = useComponentStatus<
     // "zIndex",
   ],
 });
+describes.fill.label = "颜色";
+describes.strokeWidth.label = "粗细";
 
 // const draw = useInteractiveDrawShapeAPI();
 // const store = useStore();

+ 1 - 1
src/core/components/arrow/index.ts

@@ -18,7 +18,7 @@ export const shapeName = "箭头";
 export const defaultStyle = {
   fill: '#000000',
   pointerPosition: PointerPosition.end,
-  strokeWidth: 2,
+  strokeWidth: 5,
   pointerLength: 10,
 };
 

+ 3 - 3
src/core/components/circle/circle.vue

@@ -47,9 +47,9 @@ const { shape, tData, data, operateMenus, describes } = useComponentStatus<
   props,
   getMouseStyle,
   defaultStyle,
-  alignment: (data, mat) => {
-    return matResponse({ data, mat: mat.multiply(new Transform(data.mat)) });
-  },
+  // alignment: (data, mat) => {
+  //   return matResponse({ data, mat: mat.multiply(new Transform(data.mat)) });
+  // },
   transformType: "custom",
   customTransform(callback, shape, data) {
     let initRadius: Pos;

+ 1 - 1
src/core/components/circle/index.ts

@@ -19,7 +19,7 @@ export const defaultStyle = {
   dash: [30, 0],
   stroke: '#000000',
   strokeWidth: 5,
-  fontSize: 16,
+  fontSize: 22,
   align: "center",
   fontStyle: "normal",
   fontColor: '#000000',

+ 3 - 3
src/core/components/icon/icon.vue

@@ -72,9 +72,9 @@ const { shape, tData, data, operateMenus, describes } = useComponentStatus({
     });
   },
   defaultStyle,
-  alignment(data, mat) {
-    return matResponse({ data, mat, increment: true });
-  },
+  // alignment(data, mat) {
+  //   return matResponse({ data, mat, increment: true });
+  // },
   copyHandler(mat, data) {
     return matResponse({ data, mat, increment: true });
   },

+ 25 - 13
src/core/components/line/single-line.vue

@@ -20,7 +20,13 @@
   />
 
   <SizeLine
-    v-if="config.showComponentSize || isDrawIng || dragIng"
+    v-if="
+      status.active ||
+      config.showComponentSize ||
+      isDrawIng ||
+      dragPointIds?.includes(line.a) ||
+      dragPointIds?.includes(line.b)
+    "
     :points="points"
     :strokeWidth="style.strokeWidth"
     :stroke="style.stroke"
@@ -53,7 +59,7 @@
     :name="shapeName"
     @change="
       () => {
-        isStartChange || emit('updateBefore');
+        isStartChange || emit('updateBefore', []);
         emit('updateLine', { ...line });
         emit('update');
         isStartChange = false;
@@ -81,7 +87,10 @@ import { ComponentSnapInfo } from "../index.ts";
 import { useCustomSnapInfos } from "@/core/hook/use-snap.ts";
 import { mergeDescribes } from "@/core/html-mount/propertys/index.ts";
 import { PropertyUpdate, Operate } from "../../html-mount/propertys/index.ts";
-import { useAnimationMouseStyle } from "@/core/hook/use-mouse-status.ts";
+import {
+  useAnimationMouseStyle,
+  useMouseShapeStatus,
+} from "@/core/hook/use-mouse-status.ts";
 import { themeColor } from "@/constant";
 
 const mode = useMode();
@@ -91,6 +100,7 @@ const props = defineProps<{
   addMode?: boolean;
   canEdit?: boolean;
   data: LineData;
+  dragPointIds?: string[];
 }>();
 
 const emit = defineEmits<{
@@ -99,7 +109,7 @@ const emit = defineEmits<{
   (e: "delPoint", value: LineData["points"][number]): void;
   (e: "delLine"): void;
   (e: "updateLine", value: LineData["lines"][number]): void;
-  (e: "updateBefore"): void;
+  (e: "updateBefore", value: string[]): void;
   (e: "update"): void;
 }>();
 
@@ -110,7 +120,11 @@ const points = computed(() => [
 ]);
 const lineData = computed(() => props.line);
 const describes = mergeDescribes(lineData, {}, ["stroke", "strokeWidth"]);
-(describes.strokeWidth.props as any).proportion = true;
+const d = describes as any;
+d.strokeWidth.props.proportion = true;
+d.strokeWidth.label = "粗细";
+d.stroke.label = "颜色";
+
 let isStartChange = false;
 describes.length = {
   type: "inputNum",
@@ -121,7 +135,7 @@ describes.length = {
   },
   set value(val) {
     if (!isStartChange) {
-      emit("updateBefore");
+      emit("updateBefore", [props.line.a, props.line.b]);
     }
     isStartChange = true;
     const aCount = props.data.lines.filter(
@@ -151,7 +165,7 @@ describes.length = {
 };
 
 const delHandler = () => {
-  emit("updateBefore");
+  emit("updateBefore", [props.line.a, props.line.b]);
   emit("delLine");
   emit("update");
 };
@@ -162,6 +176,7 @@ const menus = [
   },
 ];
 
+const status = useMouseShapeStatus(shape);
 const [mstyle] = useAnimationMouseStyle({
   shape,
   getMouseStyle,
@@ -177,24 +192,22 @@ const style = computed(() =>
 );
 
 const addPoint = (pos: Pos) => {
-  emit("updateBefore");
+  emit("updateBefore", []);
   emit("addPoint", { ...points.value[0], ...pos, id: onlyId() });
   emit("update");
 };
 
 const config = useConfig();
 const delPoint = (point: LineData["points"][number]) => {
-  emit("updateBefore");
+  emit("updateBefore", []);
   emit("delPoint", point);
   emit("update");
 };
 
 const infos = useCustomSnapInfos();
 let snapInfos: ComponentSnapInfo[];
-let dragIng = ref(false);
 const dragstartHandler = (eIds: string[]) => {
-  dragIng.value = true;
-  emit("updateBefore");
+  emit("updateBefore", eIds);
 
   snapInfos = getSnapInfos({
     ...props.data,
@@ -208,7 +221,6 @@ const dragstartHandler = (eIds: string[]) => {
   });
 };
 const dragendHandler = () => {
-  dragIng.value = false;
   emit("update");
   // snapInfos.forEach((item) => infos.remove(item));
 };

+ 5 - 1
src/core/components/line/temp-line.vue

@@ -7,6 +7,7 @@
       :data="data"
       :add-mode="addMode"
       :can-edit="!initData"
+      :dragPointIds="dragPointIds"
       @add-point="(p) => addPointHandler(p, item)"
       @del-point="delPointHandler"
       @update-point="updatePointHandler"
@@ -42,9 +43,11 @@ const data = computed(() => {
   return initData.value;
 });
 
+const dragPointIds = ref<string[]>();
 let track = false;
 let ctx: NLineDataCtx;
-const updateBeforeHandler = () => {
+const updateBeforeHandler = (ids: string[]) => {
+  dragPointIds.value = ids;
   track = true;
   ctx = getInitCtx();
 };
@@ -107,6 +110,7 @@ const updateHandler = () => {
   normalLineData(props.data, ctx);
   emit("updateShape");
   track = false;
+  dragPointIds.value = undefined;
 };
 
 const shape = ref<DC<Group>>();

+ 0 - 1
src/core/components/polygon/index.ts

@@ -11,7 +11,6 @@ export { default as TempComponent } from "./temp-polygon.vue";
 export const shapeName = "多边形";
 export const defaultStyle = {
   stroke: "#000000",
-  fill: "#ffffff",
   strokeWidth: 5,
   dash: [30, 0],
 };

+ 3 - 3
src/core/components/polygon/polygon.vue

@@ -41,9 +41,9 @@ const { shape, tData, data, operateMenus, describes } = useComponentStatus({
   getMouseStyle,
   transformType: "line",
   defaultStyle,
-  alignment(data, mat) {
-    return matResponse({ mat, data, increment: true });
-  },
+  // alignment(data, mat) {
+  //   return matResponse({ mat, data, increment: true });
+  // },
   copyHandler(mat, data) {
     return matResponse({ mat, data, increment: true });
   },

+ 1 - 1
src/core/components/rectangle/index.ts

@@ -13,7 +13,7 @@ export const defaultStyle = {
   dash: [30, 0],
   strokeWidth: 5,
   stroke: "#000000",
-  fontSize: 16,
+  fontSize: 22,
   align: "center",
   fontStyle: "normal",
   fontColor: "#000000",

+ 3 - 3
src/core/components/rectangle/rectangle.vue

@@ -39,9 +39,9 @@ const { shape, tData, data, operateMenus, describes } = useComponentStatus({
   getMouseStyle,
   defaultStyle,
   transformType: "line",
-  alignment(data, mat) {
-    return matResponse({ mat, data, increment: true });
-  },
+  // alignment(data, mat) {
+  //   return matResponse({ mat, data, increment: true });
+  // },
   copyHandler(mat, data) {
     return matResponse({ mat, data, increment: true });
   },

+ 3 - 3
src/core/components/sequent-line/line.vue

@@ -40,9 +40,9 @@ const { shape, tData, data, operateMenus, describes } = useComponentStatus({
   props,
   getMouseStyle,
   transformType: "line",
-  alignment(data, mat) {
-    return matResponse({ mat, data, increment: true });
-  },
+  // alignment(data, mat) {
+  //   return matResponse({ mat, data, increment: true });
+  // },
   // type: "line",
   defaultStyle,
   copyHandler(mat, data) {

+ 4 - 0
src/core/components/share/edit-line.vue

@@ -33,6 +33,7 @@ import { getMouseColors } from "@/utils/colors";
 import { themeColor } from "@/constant";
 import { Circle } from "konva/lib/shapes/Circle";
 import { SLineData } from "../sequent-line";
+import { useViewer } from "@/core/hook/use-viewer";
 
 type LData = Required<Pick<SLineData, "strokeWidth" | "stroke">>;
 const props = defineProps<{
@@ -53,6 +54,7 @@ const emit = defineEmits<{
 
 const line = ref<DC<Line>>();
 const offset = useShapeDrag(line);
+const viewer = useViewer();
 const [isHover] = useShapeIsHover(line);
 const cursor = useCursor();
 watch(isHover, (hover, _, onCleanup) => {
@@ -70,6 +72,7 @@ const clearInfos = () => {
   addedInfos.forEach(infos.remove);
 };
 const dragStartHandler = () => {
+  viewer.disabled.value = true;
   clearInfos();
   const ndx = props.ndx;
   const geos = [
@@ -116,6 +119,7 @@ watch(offset, (offset, oldOffsert) => {
   } else {
     clearInfos();
     emit("dragend");
+    viewer.disabled.value = false;
   }
 });
 

+ 4 - 0
src/core/components/share/edit-point.vue

@@ -22,6 +22,7 @@ import { useCursor } from "@/core/hook/use-global-vars";
 import { rangMod } from "@/utils/shared";
 import { Operate } from "../../html-mount/propertys/index.ts";
 import { collapseItemProps } from "element-plus";
+import { useViewer } from "@/core/hook/use-viewer.ts";
 
 const props = defineProps<{
   points: Pos[];
@@ -45,6 +46,7 @@ const emit = defineEmits<{
 
 const position = computed(() => props.points[props.ndx]);
 
+const viewer = useViewer();
 const style = computed(() => {
   const color = getMouseColors(props.color || themeColor);
   const size = props.size || 5;
@@ -64,6 +66,7 @@ const clearInfos = () => {
 };
 
 const startHandler = () => {
+  viewer.disabled.value = true;
   clearInfos();
   const ndx = props.ndx;
   const geos = [
@@ -136,6 +139,7 @@ watch(offset, (offset, oldOffsert) => {
     cursor.pop();
     clearInfos();
     dragIng.value = false;
+    viewer.disabled.value = false;
   }
 });
 

+ 1 - 1
src/core/components/share/size-line.vue

@@ -61,7 +61,7 @@ const getLine = (ndx: number) =>
 const isClockwise = computed(() => getPolygonDirection(props.points) <= 0);
 
 const proportion = useProportion();
-const getWidthText = (val: number) => Math.floor(proportion.transform(val)).toString();
+const getWidthText = (val: number) => Math.round(proportion.transform(val)).toString();
 const margin = computed(() =>
   props.margin !== undefined ? props.margin! : -10 - style.value.strokeWidth * 2
 );

+ 5 - 5
src/core/components/table/table.vue

@@ -211,11 +211,11 @@ const { shape, tData, data, operateMenus, describes } = useComponentStatus<
   props,
   getMouseStyle,
   defaultStyle,
-  alignment: (data, mat) => {
-    matResponse({ data, mat, increment: true });
-    sync(data);
-    return data;
-  },
+  // alignment: (data, mat) => {
+  //   matResponse({ data, mat, increment: true });
+  //   sync(data);
+  //   return data;
+  // },
   transformType: "custom",
   customTransform(callback, shape, data) {
     useCustomTransformer(shape, data, {

+ 3 - 3
src/core/components/text/index.ts

@@ -24,12 +24,12 @@ const supportedFont = getSupportedFont([
   'sans-serif'
 ]);
 
-export const shapeName = "文";
+export const shapeName = "文";
 export const defaultStyle = {
   fill: '#000000',
   // strokeWidth: 0,
   fontFamily: supportedFont,
-  fontSize: 16,
+  fontSize: 22,
   align: "center",
   fontStyle: "normal",
 };
@@ -84,7 +84,7 @@ export const interactiveToData: InteractiveTo<"text"> = ({
       ...defaultStyle,
       ...getBaseItem(),
       ...preset,
-      content: preset.content || "文",
+      content: preset.content || "文",
     } as unknown as TextData;
     return interactiveFixData({ ...args, info, data: item });
   }

+ 3 - 1
src/core/components/triangle/index.ts

@@ -11,7 +11,7 @@ export const shapeName = "三角形";
 export const defaultStyle = {
   stroke: '#000000',
   strokeWidth: 5,
-  fontSize: 16,
+  fontSize: 22,
   align: "center",
   fontStyle: "normal",
   fontColor: '#000000',
@@ -24,6 +24,7 @@ export const getMouseStyle = (data: TriangleData) => {
   const strokeStatus = data.stroke && getMouseColors(data.stroke);
   const strokeWidth = data.strokeWidth;
 
+  console.log(data)
   return {
     default: {
       fill: data.fill,
@@ -61,6 +62,7 @@ export const interactiveToData: InteractiveTo<"triangle"> = ({
     const item = {
       ...getBaseItem(),
       ...preset,
+      ...defaultStyle,
       points: [],
     } as unknown as TriangleData;
     return interactiveFixData({ ...args, info, data: item });

+ 3 - 3
src/core/components/triangle/triangle.vue

@@ -39,9 +39,9 @@ const { shape, tData, operateMenus, describes, data } = useComponentStatus({
   getMouseStyle,
   defaultStyle,
   transformType: "line",
-  alignment(data, mat) {
-    return matResponse({ mat, data, increment: true });
-  },
+  // alignment(data, mat) {
+  //   return matResponse({ mat, data, increment: true });
+  // },
   copyHandler(mat, data) {
     return matResponse({ mat, data, increment: true });
   },

+ 9 - 6
src/core/helper/split-line.vue

@@ -17,7 +17,7 @@
 </template>
 
 <script lang="ts" setup>
-import { computed, onUnmounted } from "vue";
+import { computed, onUnmounted, watchEffect } from "vue";
 import { components } from "../components";
 import { useComponentsAttach } from "../hook/use-component";
 import {
@@ -143,11 +143,14 @@ const rectAxisSteps = computed(() => {
       axis[i] = cur;
     }
   };
-
-  for (const point of points.value) {
-    const pixel = viewerTransform.value.point(point);
-    pushStep(pixel.x > center.value.x ? axis.right : axis.left, pixel.y, pixel);
-    pushStep(pixel.y > center.value.y ? axis.bottom : axis.top, pixel.x, pixel);
+  const pixels = points.value.map((p) => viewerTransform.value.point(p));
+  const ph = [...pixels].sort((a, b) => a.x - b.x);
+  const pv = [...pixels].sort((a, b) => a.y - b.y);
+  for (const point of pv) {
+    pushStep(point.x > center.value.x ? axis.right : axis.left, point.y, point);
+  }
+  for (const point of ph) {
+    pushStep(point.y > center.value.y ? axis.bottom : axis.top, point.x, point);
   }
   return axis;
 });

+ 2 - 2
src/core/hook/use-expose.ts

@@ -109,7 +109,7 @@ export const useShortcutKey = () => {
         history.hasRedo.value && history.redo();
       } else if (ev.key === "s" && ev.ctrlKey) {
         // 保存
-        history.saveLocal();
+        // history.saveLocal();
       } else if (ev.key === "Delete" || ev.key === "Backspace") {
         // 删除
         
@@ -186,7 +186,7 @@ export const useAutoService = () => {
 
     const unloadHandler = () => {
       if (history.hasRedo.value || history.hasUndo.value) {
-        history.saveLocal();
+        // history.saveLocal();
       }
     };
     history.setLocalId(id);

+ 1 - 1
src/core/hook/use-transformer.ts

@@ -81,7 +81,7 @@ export const useTransformer = installGlobalVar(() => {
     $g.y($g.y() - 2 * $text.fontSize());
 
     const updateText = () => {
-      const rotation = transformer.rotation();
+      const rotation = transformer.rotation() % 360;
       $text.rotation(-rotation).text(` ${round(rotation, 1)}°`);
     };
 

+ 4 - 2
src/core/hook/use-viewer.ts

@@ -19,6 +19,7 @@ export const useViewer = installGlobalVar(() => {
   const can = useCan();
   const size = useResize();
   const transform = ref(new Transform());
+  const disabled = ref(false)
   const sizeMat = ref<Transform | null>(null);
 
   const init = (dom: HTMLDivElement) => {
@@ -29,7 +30,7 @@ export const useViewer = installGlobalVar(() => {
           downEv = ev;
         },
         move: ({ end, prev, ev }) => {
-          if (downEv.button === 2) return;
+          if (downEv.button === 2 || disabled.value) return;
           if (can.viewMode) {
             viewer.movePixel({ x: end.x - prev.x, y: end.y - prev.y });
           }
@@ -37,7 +38,7 @@ export const useViewer = installGlobalVar(() => {
         notPrevent: true,
       }),
       scaleListener(dom, (info) => {
-        if (can.viewMode) {
+        if (can.viewMode || disabled.value) {
           viewer.scalePixel(info.center, info.scale);
         }
       }),
@@ -62,6 +63,7 @@ export const useViewer = installGlobalVar(() => {
       transform: transform,
       viewer,
       sizeMat,
+      disabled
     },
     onDestroy: globalWatch(
       () => can.viewMouseReact,

+ 1 - 1
src/core/html-mount/propertys/describes.json

@@ -139,7 +139,7 @@
     "type": "num",
     "label": "文字大小",
     "props": {
-      "min": 2,
+      "min": 1,
       "step": 1,
       "max": 100
     },

+ 1 - 1
src/example/components/header/actions.ts

@@ -99,7 +99,7 @@ export const getHeaderActions = (draw: Draw) => {
               draw.config.showGrid = oldShowGrid
             })
           },
-          text: "jpeg",
+          text: "jpg",
           icon: "a-visible",
         },
         {

+ 2 - 2
src/example/components/slide/actions.ts

@@ -77,11 +77,11 @@ export const imp: MenuItem = {
       icon: "local_i",
       name: "本地",
       handler: async (draw: Draw) => {
-        const files = await selectFile(false, 'image/jpeg,image/png')
+        const files = await selectFile(false, '.png, .jpg, .jpeg')
         const url = await window.platform.uploadResourse(files[0])
         const image = await getImage(url)
         ElMessage.warning('请在画图面板中选择放置位置,鼠标右键取消')
-
+        console.log(image)
         draw.enterDrawShape('image', {
           width: image.width,
           height: image.height,

+ 3 - 3
src/example/components/slide/slide.vue

@@ -37,10 +37,10 @@ const activeMenu = computed(() =>
 );
 
 watch(activeMenu, (menu, oldMenu) => {
+  if (oldMenu?.payload?.type) {
+    props.draw.quitDrawShape();
+  }
   if (!menu || menu.mount) {
-    if (oldMenu?.payload?.type) {
-      props.draw.quitDrawShape();
-    }
     return;
   }
   if (menu.handler) {

+ 20 - 6
src/example/dialog/ai/ai.vue

@@ -1,11 +1,20 @@
 <template>
   <div style="padding: 20px 20px 40px">
-    <VR v-model:value="scene" class="vr-layout" label="场景" />
+    <VR v-model:value="scene" class="vr-layout" label="请选择场景" />
     <div v-if="floors?.length" class="tagging-layout">
-      <p class="title">楼层</p>
-      <el-radio-group v-model="syncFloor" style="width: 200px">
+      <p class="title" style="margin-bottom: 10px">楼层</p>
+
+      <el-select v-model="syncFloor" style="width: 100%">
+        <el-option
+          :key="item.name"
+          :label="item.name"
+          :value="item.name"
+          v-for="item in floors"
+        />
+      </el-select>
+      <!-- <el-radio-group v-model="syncFloor" style="width: 200px">
         <el-radio :label="item.name" :value="item.name" v-for="item in floors" />
-      </el-radio-group>
+      </el-radio-group> -->
     </div>
     <div v-if="scene" class="tagging-layout">
       <p class="title">图例</p>
@@ -21,9 +30,9 @@
 </template>
 
 <script lang="ts" setup>
-import { ref, watch } from "vue";
+import { computed, ref, watch } from "vue";
 import VR from "../vr/vr.vue";
-import { ElRadioGroup, ElRadio, ElMessage } from "element-plus";
+import { ElRadioGroup, ElRadio, ElMessage, ElSelect, ElOption } from "element-plus";
 import {
   compassGets,
   getFloors,
@@ -69,7 +78,12 @@ watch(scene, () => {
 });
 
 defineExpose({
+  disabled: computed(() => !scene.value),
   submit: async (): Promise<AIExposeData> => {
+    if (!scene.value) {
+      ElMessage.error("请选择同步场景");
+      throw "请选择同步场景";
+    }
     if (!syncTag.value) {
       ElMessage.error("请选择同步标签");
       throw "请选择同步标签";

+ 7 - 1
src/example/dialog/dialog.vue

@@ -17,7 +17,13 @@
     <template #footer>
       <div class="dialog-footer">
         <el-button @click="props.cancel">取消</el-button>
-        <el-button type="primary" @click="submits[i]()"> 确定 </el-button>
+        <el-button
+          type="primary"
+          @click="submits[i]()"
+          :disabled="contentRefs[i]?.disabled"
+        >
+          确定
+        </el-button>
       </div>
     </template>
   </ElDialog>

+ 1 - 1
src/example/dialog/vr/vr.vue

@@ -19,7 +19,7 @@
       <el-option
         v-for="item in scenes"
         :key="item.m"
-        :label="SceneTypeNames[item.type] + '-' + item.title"
+        :label="item.title"
         :value="item.id"
       />
     </el-select>

+ 3 - 0
src/example/env.ts

@@ -46,6 +46,7 @@ const sParams = new URLSearchParams(location.search);
 });
 const updateParams = () => {
   const rParams = urlGetQuery(location.href);
+  console.log('updateParams', rParams)
   if (inRevise(rParams, params.value)) {
     params.value = rParams;
   }
@@ -55,6 +56,7 @@ watch(
   params,
   () => {
     const sParams = new URLSearchParams();
+    console.log('变化?')
     for (const key in params.value) {
       params.value[key] && sParams.append(key, params.value[key]);
     }
@@ -68,6 +70,7 @@ watch(
   { deep: true }
 );
 
+    console.log('变化?123123')
 updateParams();
 window.addEventListener("hashchange", updateParams);
 

+ 33 - 12
src/example/fuse/enter.ts

@@ -4,6 +4,7 @@ import type { StoreData } from "@/core/store/store";
 import { token, params, urlUpdateQuery, urlGetQuery } from "../env";
 import { genLoading } from "../loadding";
 import { tempStrFill } from "@/utils/shared";
+import { ElMessage } from "element-plus";
 
 const SCENE_TYPE = {
   fuse: "fuse",
@@ -11,7 +12,6 @@ const SCENE_TYPE = {
   cloud: "cloud",
 } as const;
 
-console.log(import.meta.env.VITE_OSS_ROOT)
 const resourceURLS = {
   oss: import.meta.env.VITE_MESH_OSS,
   ossRoot: import.meta.env.VITE_OSS_ROOT,
@@ -42,7 +42,6 @@ const get = (url: string, params: Record<string, any>) => {
 
 const post = (url: string, data: Record<string, any>) => {
   const l = `${resourceURLS[SCENE_TYPE.fuse]}${url}`;
-  console.log(data)
   return after(
     fetch(l, {
       headers: {
@@ -72,21 +71,37 @@ const postFile = (url: string, data: Record<string, any>) => {
 };
 
 const login = (isBack = true) => {
+  if (import.meta.env.DEV && params.value.caseId) {
+    post("/service/manage/login", {
+      password: "JwiuK95dExMjM0NTY=7nHGf5ySQWSuC4G1An",
+      username: "super-admin",
+      userName: "super-admin",
+    }).then((res) => {
+      params.value.token = res.token;
+      // console.log(res.token, {...params.value})
+      // setTimeout(() => location.reload(), 1000)
+      console.error('login')
+    });
+    return;
+  }
+
   if (import.meta.env.VITE_LOGIN_VIEW) {
     const p: any = { ...params.value };
     delete p.token;
 
     const cur = urlUpdateQuery(location.href, p, true);
-    let link = tempStrFill(import.meta.env.VITE_LOGIN_VIEW, { redirect: escape(cur) })
-    
+    let link = tempStrFill(import.meta.env.VITE_LOGIN_VIEW, {
+      redirect: escape(cur),
+    });
+
     if (!isBack) {
       const url = new URL(link);
       url.searchParams.delete("redirect");
-      const query = urlGetQuery(url.toString())
-      delete query['redirect']
-      link = urlUpdateQuery(url.toString(), query, true)
+      const query = urlGetQuery(url.toString());
+      delete query["redirect"];
+      link = urlUpdateQuery(url.toString(), query, true);
     }
-    location.replace(link);
+    // location.replace(link);
   }
 };
 
@@ -104,10 +119,6 @@ const after = async (fet: Promise<Response>) => {
   }
 };
 
-if (!params.value.caseId || !token) {
-  login(!!params.value.caseId);
-}
-
 const getSceneList = genLoading(async (keyword: string): Promise<Scene[]> => {
   const list = await post(`fusion/case/sceneListPost`, {
     caseId: params.value.caseId,
@@ -123,6 +134,7 @@ const getSceneList = genLoading(async (keyword: string): Promise<Scene[]> => {
   }));
 });
 
+
 const getOverviewData = genLoading(async (id: string) => {
   if (!id) {
     return {
@@ -182,6 +194,14 @@ const getTabulationData = genLoading(async (id: string) => {
   };
 });
 
+
+if (!params.value.caseId || !token) {
+  ElMessage.error('当前项目号不存在!')
+  login(!!params.value.caseId);
+} else {
+  setTimeout(() => getSceneList(''), 500)
+}
+
 const saveTabulationData = genLoading(
   async (
     id: string,
@@ -232,5 +252,6 @@ window.platform = {
   getTabulationId,
 };
 
+
 /* @vite-ignore */
 import(import.meta.env.VITE_ENTRY_EXAMPLE);

+ 13 - 1
src/example/fuse/views/overview/header.vue

@@ -24,7 +24,7 @@ import {
   tableCoverWidth,
   tableCoverHeight,
 } from "../../store.ts";
-import { nextTick } from "vue";
+import { nextTick, onUnmounted } from "vue";
 import { DataGroupId } from "@/constant/index.ts";
 import { Group } from "konva/lib/Group";
 import { Mode } from "@/constant/mode.ts";
@@ -32,6 +32,7 @@ import { lineLen } from "@/utils/math.ts";
 import { repTabulationStore } from "../tabulation/gen-tab.ts";
 import { router } from "../../router.ts";
 import { overviewId, tabulationId } from "@/example/env.ts";
+import { listener } from "@/utils/event.ts";
 
 const draw = useDraw();
 
@@ -111,7 +112,9 @@ const setViewToTableCover = async () => {
   ] as const;
 };
 
+let isUpload = false;
 const saveHandler = async () => {
+  isUpload = true;
   const storeData = draw.getData();
   const [blob, scale, rect] = await draw.enterTemp(async () => {
     const [rect, recover] = await setViewToTableCover();
@@ -158,8 +161,17 @@ const saveHandler = async () => {
     store: tabStore,
     overviewId: overviewId.value,
   });
+  isUpload = false;
 };
 
+onUnmounted(
+  listener(document.documentElement, "keydown", (ev) => {
+    if (!isUpload && ev.ctrlKey && ev.key.toUpperCase() === "S") {
+      saveHandler();
+    }
+  })
+);
+
 const gotoTabulation = async () => {
   await saveHandler();
   router.push({ ...router.currentRoute.value, name: "tabulation" } as any);

+ 13 - 1
src/example/fuse/views/tabulation/header.vue

@@ -19,10 +19,11 @@ import { grayscaleImage } from "@/utils/dom.ts";
 import saveAs from "@/utils/file-serve.ts";
 import { jsPDF } from "jspdf";
 import { getImage as getResourceImage } from "@/utils/resource.ts";
-import { nextTick } from "vue";
+import { nextTick, onUnmounted } from "vue";
 import { tabulationData } from "../../store.ts";
 import { Mode } from "@/constant/mode.ts";
 import { tabulationId } from "@/example/env.ts";
+import { listener } from "@/utils/event.ts";
 
 const draw = useDraw();
 
@@ -102,12 +103,23 @@ const actions = [
   ],
 ];
 
+onUnmounted(
+  listener(document.documentElement, "keydown", (ev) => {
+    if (!isUpload && ev.ctrlKey && ev.key.toUpperCase() === "S") {
+      saveHandler();
+    }
+  })
+);
+
+let isUpload = false;
 const saveHandler = async () => {
+  isUpload = true;
   tabulationId.value = await window.platform.saveTabulationData(tabulationId.value, {
     store: draw!.getData(),
     viewport: draw!.viewer.transform.m,
     paperKey: tabulationData.value.paperKey,
     isAutoGen: tabulationData.value.isAutoGen && !draw.history.hasUndo.value,
   });
+  isUpload = false;
 };
 </script>

+ 1 - 0
src/utils/resource.ts

@@ -29,6 +29,7 @@ export let getImage = (url: string): Promise<HTMLImageElement> => {
         imageCache1[url] = image
       };
       image.onerror = (e) => {
+        console.error(e)
         reject(e);
       };
       image.src = url;

+ 2 - 3
vite.config.ts

@@ -35,7 +35,6 @@ export default ({ mode }: any) => {
   console.log(proxy);
 
   return defineConfig({
-    base: "./",
     resolve: {
       alias: {
         "@/": `${path.resolve(__dirname, "src")}/`,
@@ -70,7 +69,7 @@ export default ({ mode }: any) => {
       }),
       createHtmlPlugin({
         template: "index.html",
-        entry: path.resolve("src", env.VITE_ENTRY),
+        entry: `/src${env.VITE_ENTRY}`,
         inject: {
           data: {
             title: env.VITE_TITLE,
@@ -81,6 +80,6 @@ export default ({ mode }: any) => {
     ],
     define: {
       __VERSION__: JSON.stringify(version),
-    },
+    }
   });
 };