king
2021-07-28 137fb8ea6af2789b3238b22bac31d80bced41dfe
src/mob/mobshell/index.jsx
@@ -19,6 +19,10 @@
    handleList({...menu, components: _cards})
    setCards(_cards)
  }
  if (menu.components.length > cards.length) {
    setCards(menu.components)
  }
  
  const findCard = id => {
    const card = cards.filter(c => `${c.uuid}` === id)[0]
@@ -49,13 +53,16 @@
    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)
        if (uuids.length === 0) return
        MKEmitter.emit('delButtons', uuids)
      },
      onCancel() {}
    })
@@ -78,6 +85,24 @@
          })
          return
        }
      } else if (item.component === 'navbar') {
        if (cards.filter(card => card.type === 'navbar').length > 0) {
          notification.warning({
            top: 92,
            message: '菜单栏不可重复添加!',
            duration: 5
          })
          return
        }
      } else if (item.component === 'topbar') {
        if (cards.filter(card => card.type === 'topbar').length > 0) {
          notification.warning({
            top: 92,
            message: '导航栏不可重复添加!',
            duration: 5
          })
          return
        }
      }
      let name = ''
@@ -92,8 +117,12 @@
        editor: '富文本',
        code: '自定义',
        carousel: '轮播',
        dashboard: '仪表盘',
        form: '表单',
        card: '卡片'
        card: '卡片',
        navbar: '导航栏',
        menubar: '菜单栏',
        login: '登录'
      }
      let i = 1
      
@@ -127,7 +156,25 @@
      }
      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
        }
        return item.type !== 'topbar' && item.type !== 'navbar'
      })
      if (Topbar) {
        _cards.unshift(Topbar)
      }
      if (Navbar) {
        _cards.push(Navbar)
      }
      handleList({...menu, components: _cards})
      setCards(_cards)
@@ -135,8 +182,8 @@
  })
  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={menu.style}>
        {cards.map(card => (
          <Card
            id={card.uuid}
@@ -148,10 +195,10 @@
            updateConfig={updateConfig}
          />
        ))}
        {cards.length === 0 ?
          <Empty description="请添加组件" /> : null
        }
      </div>
      {cards.length === 0 ?
        <Empty description="请添加组件" /> : null
      }
    </div>
  )
}