king
2025-01-13 8e3b4c6dede34e8be6ba47a20ecd9a70576675cf
src/views/menudesign/index.jsx
@@ -4,8 +4,8 @@
import { is, fromJS } from 'immutable'
import moment from 'moment'
import HTML5Backend from 'react-dnd-html5-backend'
import { notification, Modal, Collapse, Card, Switch, Button, Typography, Spin } from 'antd'
import { DoubleLeftOutlined, DoubleRightOutlined, EyeOutlined, EyeInvisibleOutlined } from '@ant-design/icons'
import { notification, Modal, Collapse, Card, Switch, Button, Typography, Spin, message } from 'antd'
import { DoubleLeftOutlined, DoubleRightOutlined, EyeOutlined, EyeInvisibleOutlined, CopyOutlined } from '@ant-design/icons'
import html2canvas from 'html2canvas'
import md5 from 'md5'
@@ -1230,7 +1230,16 @@
  insert = (item) => {
    let config = fromJS(this.state.config).toJS()
    config.components.push(item)
    if (item.copyType === 'components') {
      config.components.push(...item.components)
      if (!config.interfaces) {
        config.interfaces = item.interfaces
      } else {
        config.interfaces.push(...item.interfaces)
      }
    } else {
      config.components.push(item)
    }
    this.setState({config})
    window.GLOB.customMenu = config
@@ -1249,6 +1258,44 @@
    const { oriConfig, config } = this.state
    return is(fromJS(oriConfig), fromJS(config))
  }
  copyMenu = () => {
    const { config } = this.state
    if (!config.enabled) {
      notification.warning({
        top: 92,
        message: '菜单未启用,不可复制。',
        duration: 5
      })
    } else if (config.components.length === 0) {
      notification.warning({
        top: 92,
        message: '未添加组件,不可复制。',
        duration: 5
      })
    } else {
      let msg = { copyType: 'components', type: 'admin' }
      msg.components = config.components || []
      msg.interfaces = config.interfaces || []
      try {
        msg = window.btoa(window.encodeURIComponent(JSON.stringify(msg)))
      } catch (e) {
        console.warn('Stringify Failure')
        msg = ''
      }
      let oInput = document.createElement('input')
      oInput.value = msg
      document.body.appendChild(oInput)
      oInput.select()
      document.execCommand('Copy')
      document.body.removeChild(oInput)
      message.success('复制成功。')
    }
  }
  updateLogConfig = (config) => {
@@ -1306,7 +1353,8 @@
                      />
                      {/* 表名添加 */}
                      <TableComponent config={config} updatetable={this.updateConfig}/>
                      <Paragraph style={{padding: '15px 0px 0px 18px'}} copyable={{ text: MenuId }}>菜单ID</Paragraph>
                      <Paragraph style={{padding: '15px 0px 0px 37px'}} copyable={{ text: MenuId }}>菜单ID</Paragraph>
                      <Paragraph style={{padding: '0px 0px 0px 18px'}}>菜单组件:<CopyOutlined onClick={this.copyMenu} style={{cursor: 'pointer', color: '#1890ff'}} /></Paragraph>
                      <NormalCss config={config} updateConfig={this.updateConfig}/>
                    </> : null}
                  </Panel>
@@ -1333,7 +1381,7 @@
                    <SysInterface config={config} updateConfig={this.updateConfig}/>
                    <PictureController/>
                    <StyleCombControlButton menu={config} />
                    <PasteController insert={this.insert} />
                    <PasteController vType="admin" insert={this.insert} />
                    {config ? <Switch className="big" checkedChildren="启" unCheckedChildren="停" checked={config.enabled} onChange={this.onEnabledChange} /> : null}
                    <Button type="primary" id="save-config" disabled={!config} className={needUpdate ? 'update-tip' : ''} onClick={this.submitConfig} loading={menuloading}>保存</Button>
                    <Button type="default" disabled={menuloading} onClick={this.closeView}>关闭</Button>