liwei 1 year ago
parent
commit
3af37bd227

+ 7 - 3
src/modules/editor/components/CompUI/basicUI/Transfer/select.tsx

@@ -3,7 +3,7 @@ import { CompToolbars } from "@/modules/editor/objects/Toolbars";
 import { css } from "@linaria/core";
 import { defineComponent, onMounted, onUnmounted, ref, nextTick } from "vue";
 import { useEditor } from "../../../..";
-import { styles } from "dom7";
+
 
 export const SelectTransfer = defineComponent({
   setup() {
@@ -20,7 +20,10 @@ export const SelectTransfer = defineComponent({
         comp = selectCtrl.selected[0].comp;
         //@ts-ignore
         toolbarOpts = CompToolbars[comp.compKey] || toolbarOpts;
+      }  else {
+        toolbarOpts = CompToolbars.MultiSelector;
       }
+
       const w = selectCtrl.objContainer?.getBound();
       const isTextEdit = selectCtrl.selected.length == 1 && selectCtrl.selected[0].comp.compKey == "Text";
 
@@ -42,7 +45,7 @@ export const SelectTransfer = defineComponent({
               left: w?.x + "px",
             }}
           >
-            {comp &&
+            {
               toolbarOpts.map((item) => {
                 return item.getVisible.call(editor, comp) ? (
                   <item.component
@@ -51,7 +54,8 @@ export const SelectTransfer = defineComponent({
                     onClick={() => item.onClick.call(editor, comp)}
                   />
                 ) : null;
-              })}
+              })
+            }
           </div>
 
           <div

+ 11 - 0
src/modules/editor/module/actions/edit.ts

@@ -178,6 +178,17 @@ export const editActions = EditorModule.action({
     const parentComp = this.helper.findParentComp(compId);
     parentComp && this.store.setCurrComp(parentComp.id);
   },
+
+  // 删除组件
+  removeSelectComps() {
+    const selected = this.store.selected.slice(0);
+    this.actions.selectObjs([]);
+    let n = selected.length;
+    while( n--) {
+      this.actions.removeComp(selected[n]);
+    }
+  },
+
   // 删除组件
   removeComp(compId: string) {
     if (this.helper.isCompCanDelete(compId)) {

+ 5 - 2
src/modules/editor/objects/Toolbars/CompToolbars.ts

@@ -1,4 +1,4 @@
-import { ICompToolbars, toolbars } from "./default";
+import { ICompToolbars, toolbars, multiSelToolbar } from "./default";
 
 export const CompToolbars: ICompToolbars = {
   default: [
@@ -13,5 +13,8 @@ export const CompToolbars: ICompToolbars = {
   ],
   Group: [
     toolbars.cancelGroup,
-  ]
+  ],
+  MultiSelector: [
+    multiSelToolbar.delete,
+  ],
 };

+ 2 - 1
src/modules/editor/objects/Toolbars/TreeToolbars.ts

@@ -1,4 +1,4 @@
-import { ICompToolbars, toolbars } from "./default";
+import { ICompToolbars, toolbars, multiSelToolbar } from "./default";
 
 export const TreeToolbars: ICompToolbars = {
   default: [
@@ -10,4 +10,5 @@ export const TreeToolbars: ICompToolbars = {
     toolbars.delete,
   ],
   Page: [],
+  MultiSelector: [multiSelToolbar.delete]
 };

+ 44 - 0
src/modules/editor/objects/Toolbars/default.ts

@@ -33,6 +33,7 @@ class ToolbarItem {
 
 export type ICompToolbars = { [name in ICompKeys]?: ToolbarItem[] } & {
   default: ToolbarItem[];
+  MultiSelector: ToolbarItem[];
 };
 
 function createToolbars<T extends Record<string, ItemParams>>(obj: T) {
@@ -43,6 +44,49 @@ function createToolbars<T extends Record<string, ItemParams>>(obj: T) {
   return data as { [name in keyof T]: ToolbarItem };
 }
 
+export const multiSelToolbar = createToolbars({
+    // 删除
+  delete: {
+    component: TipIcons.Delete,
+    getVisible() {
+      return true;
+    },
+    onClick() {
+      this.actions.removeSelectComps();
+    },
+  },
+  // // 清除变换
+  // clearTransform: {
+  //   component: TipIcons.ClearTransform,
+  //   getVisible() {
+  //     return true;
+  //   },
+  //   onClick() {
+  //     //this.actions.clearCompTransform(comp);
+  //   },
+  // },
+  // // 定位图层上移
+  // layerUp: {
+  //   component: TipIcons.LayerUp,
+  //   getVisible() {
+  //     return true;
+  //   },
+  //   onClick() {
+  //     // this.actions.setCompLayer(comp, 1);
+  //   },
+  // },
+  // // 定位图层下移
+  // layerDown: {
+  //   component: TipIcons.LayerDown,
+  //   getVisible() {
+  //     return true;
+  //   },
+  //   onClick() {
+  //     // this.actions.setCompLayer(comp, -1);
+  //   },
+  // },
+})
+
 export const toolbars = createToolbars({
   // 显示/隐藏
   visible: {

+ 2 - 2
src/pages/website/components/layout/LeftContent.tsx

@@ -62,8 +62,8 @@ export default defineUI({
             <Avatar size={76} src={userInfo.avatar} />
             <div class="ml-20px flex-1">
               <p class="mb-10px text-16px font-bold">{userInfo.name}</p>
-              <div class="text-12px text-gray">
-                {userInfo.desc || "这个人很懒,什么都没留下..."}
+              <div class="text-12px text-gray" style={{color:"#E88B00"}}>
+                { "免费版(限3个推广)" }
               </div>
             </div>
           </div>