Просмотр исходного кода

style: 格式化代,修改单词错误

奔跑的面条 3 лет назад
Родитель
Сommit
f0e860f306

+ 1 - 1
src/packages/public/publicConfig.ts

@@ -104,5 +104,5 @@ export class PublicGroupConfigClass extends publicConfig implements CreateCompon
   // 标识
   public id = getUUID()
   // 基本信息
-  public attr = { w: 0, h: 0, x: 0, y: 0, zIndex: -1 }
+  public attr = { w: 0, h: 0, x: 0, y: 0, offsetX: 0, offsetY: 0, zIndex: -1 }
 }

+ 4 - 1
src/settings/designSetting.ts

@@ -25,7 +25,10 @@ export const chartInitConfig = {
   x: 50,
   y: 50,
   w: 500,
-  h: 300
+  h: 300,
+  // 不建议动 offset
+  offsetX: 0,
+  offsetY: 0,
 }
 
 // dialog 图标的大小

+ 10 - 10
src/store/modules/chartEditStore/chartEditStore.ts

@@ -314,16 +314,16 @@ export const useChartEditStore = defineStore({
       }
     },
     // * 重置组件位置
-    resetComponentPostion(item: CreateComponentType | CreateComponentGroupType, isForward: boolean):void{
+    resetComponentPosition(item: CreateComponentType | CreateComponentGroupType, isForward: boolean): void {
       const index = this.fetchTargetIndex(item.id)
-      if(index > -1){
+      if (index > -1) {
         const componentInstance = this.getComponentList[index]
-        if(isForward){
+        if (isForward) {
           componentInstance.attr = Object.assign(componentInstance.attr, {
             x: item.attr.x + item.attr.offsetX,
             y: item.attr.y + item.attr.offsetY
           })
-        }else{
+        } else {
           componentInstance.attr = Object.assign(componentInstance.attr, {
             x: item.attr.x,
             y: item.attr.y
@@ -332,7 +332,7 @@ export const useChartEditStore = defineStore({
       }
     },
     // * 移动组件
-    moveComponentList(item: CreateComponentType | CreateComponentGroupType){
+    moveComponentList(item: CreateComponentType | CreateComponentGroupType) {
       chartHistoryStore.createMoveHistory([item])
     },
     // * 更新组件列表某一项的值
@@ -554,9 +554,9 @@ export const useChartEditStore = defineStore({
 
       // 处理移动
       const isMove = HistoryItem.actionType === HistoryActionTypeEnum.MOVE
-      if(isMove){
+      if (isMove) {
         historyData.forEach(item => {
-          this.resetComponentPostion(item, isForward)
+          this.resetComponentPosition(item, isForward)
         })
         return
       }
@@ -593,12 +593,12 @@ export const useChartEditStore = defineStore({
       if (isGroup || isUnGroup) {
         if ((isGroup && isForward) || (isUnGroup && !isForward)) {
           const ids: string[] = []
-          if(historyData.length > 1) {
+          if (historyData.length > 1) {
             historyData.forEach(item => {
               ids.push(item.id)
             })
           } else {
-            (historyData[0] as CreateComponentGroupType).groupList.forEach(item => {
+            ;(historyData[0] as CreateComponentGroupType).groupList.forEach(item => {
               ids.push(item.id)
             })
           }
@@ -606,7 +606,7 @@ export const useChartEditStore = defineStore({
           return
         }
         // 都需使用子组件的id去解组
-        if(historyData.length > 1) {
+        if (historyData.length > 1) {
           this.setUnGroup([(historyData[0] as CreateComponentType).id], undefined, false)
         } else {
           this.setUnGroup([(historyData[0] as CreateComponentGroupType).groupList[0].id], undefined, false)

+ 3 - 3
src/views/chart/ContentEdit/hooks/useDrag.hook.ts

@@ -111,7 +111,7 @@ export const mousedownBoxSelect = (e: MouseEvent, item?: CreateComponentType | C
       selectAttr.x1 = Math.round(startOffsetX - (startScreenX - moveEvent.screenX) / scale)
       selectAttr.y1 = startOffsetY
       selectAttr.x2 = startOffsetX
-      selectAttr.y2 = Math.round(startOffsetY + (moveEvent.screenY - startScreenY ) / scale)
+      selectAttr.y2 = Math.round(startOffsetY + (moveEvent.screenY - startScreenY) / scale)
       // 左下方向
     } else {
       // 左上方向
@@ -223,7 +223,7 @@ export const useMouseHandle = () => {
     const startY = e.screenY
 
     // 记录历史位置
-    let prevComponentInstance:CreateComponentType | CreateComponentGroupType
+    let prevComponentInstance: CreateComponentType | CreateComponentGroupType
     chartEditStore.getTargetChart.selectId.forEach(id => {
       if (!targetMap.has(id)) return
 
@@ -278,7 +278,7 @@ export const useMouseHandle = () => {
       chartEditStore.setMousePosition(0, 0, 0, 0)
       chartEditStore.setEditCanvas(EditCanvasTypeEnum.IS_DRAG, false)
       // 加入历史栈
-      if(prevComponentInstance){
+      if (prevComponentInstance) {
         chartEditStore.getTargetChart.selectId.forEach(id => {
           if (!targetMap.has(id)) return
           const index = chartEditStore.fetchTargetIndex(id)