From 8e3b4c6dede34e8be6ba47a20ecd9a70576675cf Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 13 一月 2025 18:02:33 +0800
Subject: [PATCH] 2025-01-13

---
 src/views/mobdesign/index.jsx |   75 +++++++++++++++++++++++++++++++++----
 1 files changed, 67 insertions(+), 8 deletions(-)

diff --git a/src/views/mobdesign/index.jsx b/src/views/mobdesign/index.jsx
index b15aa97..2fcc5eb 100644
--- a/src/views/mobdesign/index.jsx
+++ b/src/views/mobdesign/index.jsx
@@ -4,7 +4,7 @@
 import { is, fromJS } from 'immutable'
 import HTML5Backend from 'react-dnd-html5-backend'
 import { notification, Modal, Collapse, Switch, Button, message, Spin, Typography } from 'antd'
-import { DoubleLeftOutlined, DoubleRightOutlined, HomeOutlined, LoginOutlined, ArrowLeftOutlined, EyeOutlined, EyeInvisibleOutlined } from '@ant-design/icons'
+import { DoubleLeftOutlined, DoubleRightOutlined, HomeOutlined, LoginOutlined, ArrowLeftOutlined, EyeOutlined, EyeInvisibleOutlined, CopyOutlined } from '@ant-design/icons'
 import moment from 'moment'
 import md5 from 'md5'
 
@@ -1988,11 +1988,22 @@
   insert = (item) => {
     let config = fromJS(this.state.config).toJS()
 
-    if (item.type === 'topbar' && !config.style.paddingTop) {
-      config.style.paddingTop = '50px'
+    if (item.copyType === 'components') {
+      if (item.components.findIndex(m => m.type === 'topbar') > -1 && !config.style.paddingTop) {
+        config.style.paddingTop = '50px'
+      }
+      config.components.push(...item.components)
+      if (!config.interfaces) {
+        config.interfaces = item.interfaces
+      } else {
+        config.interfaces.push(...item.interfaces)
+      }
+    } else {
+      if (item.type === 'topbar' && !config.style.paddingTop) {
+        config.style.paddingTop = '50px'
+      }
+      config.components.push(item)
     }
-
-    config.components.push(item)
 
     this.setState({config})
     window.GLOB.customMenu = config
@@ -2170,6 +2181,53 @@
     return is(fromJS(oriConfig), fromJS(config))
   }
 
+  copyMenu = () => {
+    const { config } = this.state
+
+    if (!config.enabled) {
+      notification.warning({
+        top: 92,
+        message: '鑿滃崟鏈惎鐢紝涓嶅彲澶嶅埗銆�',
+        duration: 5
+      })
+    } else {
+      let msg = { copyType: 'components', type: 'mob' }
+
+      msg.components = []
+      msg.interfaces = config.interfaces || []
+
+      config.components.forEach(item => {
+        if (item.type === 'navbar') return
+
+        msg.components.push(item)
+      })
+
+      if (msg.components.length === 0) {
+        notification.warning({
+          top: 92,
+          message: '鏈坊鍔犵粍浠讹紝涓嶅彲澶嶅埗銆�',
+          duration: 5
+        })
+        return
+      }
+
+      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) => {
     config.open_edition = this.state.config.open_edition || ''
     
@@ -2217,8 +2275,9 @@
                     <UrlFieldComponent config={config} updateConfig={this.updateConfig}/>
                     {/* 琛ㄥ悕娣诲姞 */}
                     <TableComponent config={config} updatetable={this.updateConfig}/>
-                    <Paragraph style={{padding: '15px 0px 0px 18px'}} copyable={{ text: MenuId }}>鑿滃崟ID</Paragraph>
-                    <Paragraph style={{padding: '10px 0px 0px 18px'}} copyable={{ text:  `${window.GLOB.baseurl}mob/index.html#/index/${sessionStorage.getItem('kei_no')}/${sessionStorage.getItem('typename')}/${sessionStorage.getItem('lang')}/${MenuId}/@BID@` }}>鑿滃崟閾炬帴</Paragraph>
+                    <Paragraph style={{padding: '15px 0px 0px 37px'}} copyable={{ text: MenuId }}>鑿滃崟ID</Paragraph>
+                    <Paragraph style={{padding: '0px 0px 0px 23px'}} copyable={{ text:  `${window.GLOB.baseurl}mob/index.html#/index/${sessionStorage.getItem('kei_no')}/${sessionStorage.getItem('typename')}/${sessionStorage.getItem('lang')}/${MenuId}/@BID@` }}>鑿滃崟閾炬帴</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>
@@ -2247,7 +2306,7 @@
               {config ? <Debug config={config}/> : null}
               <Button className="mk-border-purple" onClick={() => this.setState({eyeopen: !eyeopen})}>{!eyeopen ? <EyeOutlined /> : <EyeInvisibleOutlined />} 缁勪欢鍚�</Button>
               <CreateView resetmenu={this.getAppMenus} />
-              <PasteController insert={this.insert} />
+              <PasteController vType="mob" insert={this.insert} />
               <TableNodes config={config} />
               <ViewNodes config={config} MenuId={MenuId}/>
               <SysInterface config={config} updateConfig={this.updateConfig}/>

--
Gitblit v1.8.0