From 76a4300654a18d228838c3f27455dc8e7a8cd616 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 15 一月 2021 17:04:42 +0800 Subject: [PATCH] Merge branch 'master' into bms --- src/tabviews/iframe/index.jsx | 64 ++++++++++++++++++++++++++++++- 1 files changed, 61 insertions(+), 3 deletions(-) diff --git a/src/tabviews/iframe/index.jsx b/src/tabviews/iframe/index.jsx index 11b6299..2dea067 100644 --- a/src/tabviews/iframe/index.jsx +++ b/src/tabviews/iframe/index.jsx @@ -1,16 +1,74 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' +import { Button, message } from 'antd' +import MKEmitter from '@/utils/events.js' +import mzhCN from '@/locales/zh-CN/main.js' +import menUS from '@/locales/en-US/main.js' class Iframe extends Component { static propTypes = { title: PropTypes.string, + MenuID: PropTypes.string, // 鑿滃崟Id + MenuNo: PropTypes.string, // 鑿滃崟鍙傛暟 url: PropTypes.string } + state = { + visible: true, + dict: localStorage.getItem('lang') !== 'en-US' ? mzhCN : menUS, + debug: sessionStorage.getItem('debug') === 'true' + } + + componentDidMount () { + MKEmitter.addListener('reloadMenuView', this.reloadMenuView) + } + + /** + * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊 + */ + componentWillUnmount () { + this.setState = () => { + return + } + MKEmitter.removeListener('reloadMenuView', this.reloadMenuView) + } + + reloadMenuView = (menuId) => { + const { MenuID } = this.props + + if (MenuID !== menuId) return + + this.setState({visible: false}, () => { + this.setState({visible: true}) + }) + } + + copyMenuNo = (e) => { + const { MenuNo } = this.props + + e.stopPropagation() + let oInput = document.createElement('input') + oInput.value = MenuNo || '' + document.body.appendChild(oInput) + oInput.select() + document.execCommand('Copy') + oInput.className = 'oInput' + oInput.style.display = 'none' + message.success(this.state.dict['main.copy.success']) + } + render () { - return ( - <iframe title={this.props.title} src={this.props.url} /> - ) + const { visible, debug } = this.state + + return (<div> + {visible ? <iframe title={this.props.title} src={this.props.url} /> : null} + {debug ? <Button + icon="copy" + shape="circle" + className={'main-copy ifr-copy'} + onClick={this.copyMenuNo} + /> : null} + </div>) } } -- Gitblit v1.8.0