| | |
| | | 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' |
| | | |
| | |
| | | }) |
| | | } |
| | | |
| | | let uuids = MenuUtils.getDelButtonIds(card) |
| | | |
| | | confirm({ |
| | | title: `确定删除${card.name ? `《${card.name}》` : '组件'}吗?`, |
| | | content: hasComponent ? '当前组件中含有子组件!' : '', |
| | |
| | | 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() {} |
| | | }) |
| | |
| | | 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, |
| | |
| | | }) |
| | | 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 |
| | |
| | | card: '卡片', |
| | | navbar: '导航栏', |
| | | menubar: '菜单栏', |
| | | balcony: '浮动卡', |
| | | timeline: '时间轴', |
| | | officialAccount: '关注公众号', |
| | | sharecode: '分享码', |
| | | iframe: 'iframe', |
| | | login: '登录' |
| | | } |
| | | let i = 1 |
| | |
| | | subtype: item.subtype, |
| | | config: item.config, |
| | | width: item.width || 24, |
| | | dataName: Utils.getdataName(), |
| | | name: name, |
| | | floor: 1, // 组件的层级 |
| | | isNew: true // 新添加标志,用于初始化 |
| | |
| | | _cards.push(Navbar) |
| | | } |
| | | |
| | | handleList({...menu, components: _cards}) |
| | | 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"> |
| | | <div className="ant-row" style={menu.style}> |
| | | <div className="ant-row" style={style}> |
| | | {cards.map(card => ( |
| | | <Card |
| | | id={card.uuid} |