import React, { PureComponent } from 'react';
import { Tabs } from 'antd';
import style from "styled-components";
import NoAuthority from '../../common/NoAuthority';

const store = require("store");

const { TabPane } = Tabs;

export default class OneKeySearch extends PureComponent {
  constructor(props, context) {
    super(props, context);
    this.state = {
      // currentURL: "http://localhost:3000/#/course/manage",
    };
  }

  componentDidMount() {
    // 隐藏左侧菜单栏
    document.querySelector('.ant-layout-sider').style.display = 'none';
    document.querySelector('.ant-layout-content').style.margin = '0px';
    document.querySelector('.oneKeySearchHidden').style.display = 'none';
    // console.log('innerHTML', document.getElementById("OneKeySearch").innerHTML);
    // document.getElementById("OneKeySearch").innerHTML = '<object type="text/html" data="http://www.alloyteam.com/nav/" width="100%" height="100%"></object>';
  }

  componentWillUnmount() {
    // 显示左侧菜单栏
    document.querySelector('.ant-layout-sider').style.display = 'block';
    document.querySelector('.ant-layout-content').style.margin = '16px';
    document.querySelector('.oneKeySearchHidden').style.display = 'block';
  }
  render() {
    // const { currentURL } = this.state;
    return (
      <Container className="lalal">
        {/* <Tabs>
          <TabPane tab="一键搜" key="1" />
        </Tabs> */}
        {store.get("OneKeySearchURL")&&store.get("OneKeySearchURL")["OneKeySearchURL"]?(
          <iframe title="一键搜" src={store.get("OneKeySearchURL")["OneKeySearchURL"]} width="100%" height={window.innerHeight} frameBorder="0">
          您的浏览器不支持iframe，请升级
          </iframe>
        ): (
          <NoAuthority></NoAuthority>
        )}
        {/* {store.get("OneKeySearchURL") !== undefined ? (
          <iframe title="一键搜" src={store.get("OneKeySearchURL")["OneKeySearchURL"]} width="100%" height={window.innerHeight} frameBorder="0">
            您的浏览器不支持iframe，请升级
            </iframe>
        ) : ''
        } */}

        {/*
            {store.get("coursewareLibraryManagementURL") !== undefined ? (
              <iframe title="课程库管理" src={currentURL + '?sessionId=' + store.get("saas")["sessionId"]} width="100%" height="100%" frameBorder="0">
                您的浏览器不支持iframe，请升级
              </iframe>
            ) : ''
            }
            */}
        {/*
            课件库管理
            <div id="OneKeySearch" />
            <iframe title="ds" src="http://www.alloyteam.com/nav/" width="100%" height="100%" frameBorder="0">
              您的浏览器不支持iframe，请升级
            </iframe>
            <div style={{ width: '100%', height: '800px' }}>
              <iframe title="ds" src="http://120.76.218.179:9149/pxxtfront/train-office/#/product" width="100%" height="100%" frameBorder="0">
                您的浏览器不支持iframe，请升级
              </iframe>
          </div>
          */}
      </Container>
    );
  }
}

const Container = style.div`
  // padding:10px 24px 24px;
  width:100%;
  height:100%;
`;
