From 6afb82b92c7de7a3d5551e721b4c8de39bd7de9d Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 30 十二月 2022 13:25:28 +0800
Subject: [PATCH] 2022-12-30

---
 src/mob/mobshell/index.jsx |  106 +++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 91 insertions(+), 15 deletions(-)

diff --git a/src/mob/mobshell/index.jsx b/src/mob/mobshell/index.jsx
index ee23621..0063894 100644
--- a/src/mob/mobshell/index.jsx
+++ b/src/mob/mobshell/index.jsx
@@ -4,8 +4,6 @@
 import { Empty, notification, Modal } from 'antd'
 
 import Utils from '@/utils/utils.js'
-import MKEmitter from '@/utils/events.js'
-import MenuUtils from '@/utils/utils-custom.js'
 import Card from './card'
 import './index.scss'
 
@@ -18,6 +16,10 @@
     const _cards = update(cards, { $splice: [[index, 1], [atIndex, 0, card]] })
     handleList({...menu, components: _cards})
     setCards(_cards)
+  }
+
+  if (menu.components.length > cards.length) {
+    setCards(menu.components)
   }
   
   const findCard = id => {
@@ -46,13 +48,10 @@
       })
     }
 
-    let uuids = MenuUtils.getDelButtonIds(card)
-
     confirm({
-      title: `纭畾鍒犻櫎銆�${card.name}銆嬪悧锛焋,
+      title: `纭畾鍒犻櫎${card.name ? `銆�${card.name}銆媊 : '缁勪欢'}鍚楋紵`,
       content: hasComponent ? '褰撳墠缁勪欢涓惈鏈夊瓙缁勪欢锛�' : '',
       onOk() {
-        MKEmitter.emit('delButtons', uuids)
         const _cards = cards.filter(item => item.uuid !== card.uuid)
         handleList({...menu, components: _cards})
         setCards(_cards)
@@ -69,11 +68,54 @@
         return
       }
 
+      let style = null
+
       if (item.component === 'search') { // 鎼滅储缁勪欢涓嶅彲閲嶅娣诲姞
+        if (cards.filter(card => card.type === 'topbar' && card.wrap.type !== 'navbar').length > 0) {
+          notification.warning({
+            top: 92,
+            message: '瀵艰埅鏍忎娇鐢ㄤ簡鎼滅储锛屼笉鍙坊鍔犳悳绱㈢粍浠讹紒',
+            duration: 5
+          })
+          return
+        }
         if (cards.filter(card => card.type === 'search').length > 0) {
           notification.warning({
             top: 92,
             message: '鎼滅储鏉′欢涓嶅彲閲嶅娣诲姞锛�',
+            duration: 5
+          })
+          return
+        }
+      } else if (item.component === 'navbar') {
+        if (cards.filter(card => card.type === 'navbar').length > 0) {
+          notification.warning({
+            top: 92,
+            message: '鑿滃崟鏍忎笉鍙噸澶嶆坊鍔狅紒',
+            duration: 5
+          })
+          return
+        }
+        if (!menu.style.paddingBottom) {
+          style = {...menu.style, paddingBottom: '50px'}
+        }
+      } else if (item.component === 'topbar') {
+        if (cards.filter(card => card.type === 'topbar').length > 0) {
+          notification.warning({
+            top: 92,
+            message: '瀵艰埅鏍忎笉鍙噸澶嶆坊鍔狅紒',
+            duration: 5
+          })
+          return
+        }
+        if (!menu.style.paddingTop) {
+          style = {...menu.style, paddingTop: '50px'}
+        }
+      } else if (item.component === 'officialAccount') {
+        if (cards.filter(card => card.type === 'officialAccount').length > 0) {
+          notification.warning({
+            top: 92,
+            message: '鍏虫敞缁勪欢涓嶅彲閲嶅娣诲姞锛�',
             duration: 5
           })
           return
@@ -92,8 +134,17 @@
         editor: '瀵屾枃鏈�',
         code: '鑷畾涔�',
         carousel: '杞挱',
+        dashboard: '浠〃鐩�',
         form: '琛ㄥ崟',
-        card: '鍗$墖'
+        card: '鍗$墖',
+        navbar: '瀵艰埅鏍�',
+        menubar: '鑿滃崟鏍�',
+        balcony: '娴姩鍗�',
+        timeline: '鏃堕棿杞�',
+        officialAccount: '鍏虫敞鍏紬鍙�',
+        sharecode: '鍒嗕韩鐮�',
+        iframe: 'iframe',
+        login: '鐧诲綍'
       }
       let i = 1
       
@@ -111,7 +162,6 @@
         subtype: item.subtype,
         config: item.config,
         width: item.width || 24,
-        dataName: Utils.getdataName(),
         name: name,
         floor: 1,   // 缁勪欢鐨勫眰绾�
         isNew: true // 鏂版坊鍔犳爣蹇楋紝鐢ㄤ簬鍒濆鍖�
@@ -127,16 +177,42 @@
       }
 
       const { index: overIndex } = findCard(`${targetId}`)
-      const _cards = update(cards, { $splice: [[overIndex + 1, 0, newcard]] })
+      let _cards = update(cards, { $splice: [[overIndex + 1, 0, newcard]] })
+      let Topbar = null
+      let Navbar = null
+      _cards = _cards.filter(item => {
+        if (item.type === 'topbar') {
+          Topbar = item
+        } else if (item.type === 'navbar') {
+          Navbar = item
+        }
 
-      handleList({...menu, components: _cards})
+        return item.type !== 'topbar' && item.type !== 'navbar'
+      })
+
+      if (Topbar) {
+        _cards.unshift(Topbar)
+      }
+      if (Navbar) {
+        _cards.push(Navbar)
+      }
+
+      if (style) {
+        handleList({...menu, style, components: _cards})
+      } else {
+        handleList({...menu, components: _cards})
+      }
       setCards(_cards)
     }
   })
 
+  let style = JSON.stringify(menu.style || {})
+  style = style.replace(/@mywebsite@\//ig, window.GLOB.baseurl)
+  style = JSON.parse(style)
+
   return (
-    <div ref={drop} className="mob-shell-inner" id="menu-shell-inner" style={menu.style}>
-      <div className="ant-row">
+    <div ref={drop} className="mob-shell-inner" id="menu-shell-inner">
+      <div className="ant-row" style={style}>
         {cards.map(card => (
           <Card
             id={card.uuid}
@@ -148,10 +224,10 @@
             updateConfig={updateConfig}
           />
         ))}
+        {cards.length === 0 ?
+          <Empty description="璇锋坊鍔犵粍浠�" /> : null
+        }
       </div>
-      {cards.length === 0 ?
-        <Empty description="璇锋坊鍔犵粍浠�" /> : null
-      }
     </div>
   )
 }

--
Gitblit v1.8.0