Commit 7b5cda46 authored by 张烨's avatar 张烨

feat: add babel plugin and nest iframe

parent 0f4a09e3
...@@ -24,10 +24,10 @@ module.exports = options => ({ ...@@ -24,10 +24,10 @@ module.exports = options => ({
// options: options.babelQuery, // options: options.babelQuery,
options: { options: {
presets: ['@babel/preset-typescript'], presets: ['@babel/preset-typescript'],
plugins: ['@babel/plugin-proposal-optional-chaining'],
}, },
}, },
}, },
{ {
// Preprocess our own .css files // Preprocess our own .css files
// This is the place to add your own loaders (e.g. sass/less etc.) // This is the place to add your own loaders (e.g. sass/less etc.)
......
...@@ -82,6 +82,7 @@ ...@@ -82,6 +82,7 @@
"babel-core": "7.0.0-bridge.0" "babel-core": "7.0.0-bridge.0"
}, },
"dependencies": { "dependencies": {
"@babel/plugin-proposal-optional-chaining": "^7.12.1",
"@babel/polyfill": "7.4.3", "@babel/polyfill": "7.4.3",
"@babel/preset-typescript": "^7.12.1", "@babel/preset-typescript": "^7.12.1",
"@babel/runtime": "^7.10.5", "@babel/runtime": "^7.10.5",
......
import { isDev } from '@/utils/tools';
import { PageContainer } from '@ant-design/pro-layout';
import React from 'react';
import styles from './index.less';
/**
* 嵌套iframe的组件
* @param {*} props 可在路由配置里面配置url参数
*/
const FrameContainer = props => {
const { route } = props;
const url = route.url || props.url;
return (
<PageContainer
className={styles.container}
style={{
display: 'flex',
flexDirection: 'column',
height: 'calc(100% + 24px)',
}}
>
<iframe
title="iframe"
src={`${
isDev ? process.env.PROXY : window.location.origin
}${url}`.replace('//', '/')}
/>
</PageContainer>
);
};
export default FrameContainer;
.container{
// background: salmon;
.ant-pro-grid-content{
flex: 1;
.ant-pro-grid-content-children{
height: 100%;
&>div{
height: 100%;
.ant-pro-page-container-children-content{
height: 100%;
iframe{
width: 100%;
height: 100%;
}
}
}
}
}
}
\ No newline at end of file
...@@ -3,6 +3,7 @@ import { ...@@ -3,6 +3,7 @@ import {
LOAD_REPOS_ERROR, LOAD_REPOS_ERROR,
LOAD_REPOS_SUCCESS, LOAD_REPOS_SUCCESS,
SET_AUTHORITY, SET_AUTHORITY,
SET_USER_MODE,
} from './constants'; } from './constants';
export function loadRepos() { export function loadRepos() {
...@@ -32,3 +33,10 @@ export function setAuth(auth) { ...@@ -32,3 +33,10 @@ export function setAuth(auth) {
auth, auth,
}; };
} }
export function setUserMode(userMode) {
return {
type: SET_USER_MODE,
userMode,
};
}
...@@ -2,3 +2,4 @@ export const LOAD_REPOS = 'App/LOAD_REPOS'; ...@@ -2,3 +2,4 @@ export const LOAD_REPOS = 'App/LOAD_REPOS';
export const LOAD_REPOS_SUCCESS = 'App/LOAD_REPOS_SUCCESS'; export const LOAD_REPOS_SUCCESS = 'App/LOAD_REPOS_SUCCESS';
export const LOAD_REPOS_ERROR = 'App/LOAD_REPOS_ERROR'; export const LOAD_REPOS_ERROR = 'App/LOAD_REPOS_ERROR';
export const SET_AUTHORITY = 'App/SET_AUTHORITY'; export const SET_AUTHORITY = 'App/SET_AUTHORITY';
export const SET_USER_MODE = 'App/SET_USER_MODE';
...@@ -9,11 +9,13 @@ const mapState = store => { ...@@ -9,11 +9,13 @@ const mapState = store => {
return { return {
global: storeObj.global, global: storeObj.global,
auth: storeObj.global.auth, auth: storeObj.global.auth,
userMode: storeObj.global.userMode,
}; };
}; };
const mapDispatch = dispatch => ({ const mapDispatch = dispatch => ({
setAuth: auth => dispatch(actionCreators.setAuth(auth)), setAuth: auth => dispatch(actionCreators.setAuth(auth)),
logout: () => dispatch(actionCreators.setAuth([])), logout: () => dispatch(actionCreators.setAuth([])),
setUserMode: userMode => dispatch(actionCreators.setUserMode(userMode)),
}); });
const appConnector = connect( const appConnector = connect(
......
...@@ -5,6 +5,7 @@ import { ...@@ -5,6 +5,7 @@ import {
LOAD_REPOS_ERROR, LOAD_REPOS_ERROR,
LOAD_REPOS_SUCCESS, LOAD_REPOS_SUCCESS,
SET_AUTHORITY, SET_AUTHORITY,
SET_USER_MODE,
} from './constants'; } from './constants';
export const initialState = fromJS({ export const initialState = fromJS({
...@@ -15,6 +16,7 @@ export const initialState = fromJS({ ...@@ -15,6 +16,7 @@ export const initialState = fromJS({
userData: { userData: {
repositories: false, repositories: false,
}, },
userMode: '',
}); });
/* eslint-disable default-case, no-param-reassign */ /* eslint-disable default-case, no-param-reassign */
...@@ -46,6 +48,10 @@ const appReducer = (state = initialState, action) => { ...@@ -46,6 +48,10 @@ const appReducer = (state = initialState, action) => {
return state.merge({ return state.merge({
auth: action.auth, auth: action.auth,
}); });
case SET_USER_MODE:
return state.merge({
userMode: action.userMode,
});
default: default:
return state; return state;
} }
......
...@@ -21,7 +21,7 @@ const LoginMessage = ({ content }) => ( ...@@ -21,7 +21,7 @@ const LoginMessage = ({ content }) => (
); );
const Login = props => { const Login = props => {
const { userLogin = {}, submitting, setAuth } = props; const { userLogin = {}, submitting, setAuth, setUserMode } = props;
const { status, type: loginType } = userLogin; const { status, type: loginType } = userLogin;
const history = useHistory(); const history = useHistory();
// const [autoLogin, setAutoLogin] = useState(true); // const [autoLogin, setAutoLogin] = useState(true);
...@@ -36,7 +36,8 @@ const Login = props => { ...@@ -36,7 +36,8 @@ const Login = props => {
console.log(result); console.log(result);
if (result.success === true && result.pass === true) { if (result.success === true && result.pass === true) {
const { userMode } = result; const { userMode } = result;
localStorage.setItem('userMode', userMode); // localStorage.setItem('userMode', userMode);
setUserMode(userMode);
if (userMode === USER_MODE.ADMIN || userMode === USER_MODE.SUPER) { if (userMode === USER_MODE.ADMIN || userMode === USER_MODE.SUPER) {
const authority = [AUTHORITY.LOGIN, AUTHORITY[userMode]]; const authority = [AUTHORITY.LOGIN, AUTHORITY[userMode]];
setAuthority(authority); setAuthority(authority);
......
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { PageContainer } from '@ant-design/pro-layout'; import { PageContainer } from '@ant-design/pro-layout';
import { Tabs } from 'antd'; import { Tabs } from 'antd';
import { getWebModuleTree } from '@/services/webConfig/api';
import menuTreeMock from '@/services/mocks/web4site'; import menuTreeMock from '@/services/mocks/web4site';
import styles from './index.less'; import styles from './index.less';
import SiteConfig from './components/siteConfigDrawer'; import SiteConfig from './components/siteConfigDrawer';
import { appConnector } from '@/containers/App/store';
const { TabPane } = Tabs; const { TabPane } = Tabs;
const getMenuTree = () => const getMenuTree = userMode =>
new Promise((r, j) => { getWebModuleTree(userMode).then(res => console.log(res));
setTimeout(() => {
r(menuTreeMock);
}, 1000);
});
const WebConfigPage = props => { const WebConfigPage = props => {
const [configVisible, setConfigVisible] = useState(false); const [configVisible, setConfigVisible] = useState(false);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [menuTree, setMeneTree] = useState({ children: [] }); const [menuTree, setMenuTree] = useState({ children: [] });
const [configObj, setConfigObj] = useState({}); const [configObj, setConfigObj] = useState({});
const renderPage = () => {}; const renderPage = () => {};
useEffect(() => { useEffect(() => {
getMenuTree().then(res => { getMenuTree(props.userMode).then(res => {
setMeneTree(res); setMenuTree(res);
setLoading(false); setLoading(false);
}); });
}, []); }, []);
...@@ -51,7 +49,7 @@ const WebConfigPage = props => { ...@@ -51,7 +49,7 @@ const WebConfigPage = props => {
<PageContainer loading={loading}> <PageContainer loading={loading}>
<div className={styles.webConfigContainer}> <div className={styles.webConfigContainer}>
<Tabs type="editable-card" onEdit={onEdit}> <Tabs type="editable-card" onEdit={onEdit}>
{menuTree.children.map(renderTabPane)} {menuTree?.children?.map(renderTabPane)}
</Tabs> </Tabs>
<SiteConfig <SiteConfig
visible={configVisible} visible={configVisible}
...@@ -63,4 +61,4 @@ const WebConfigPage = props => { ...@@ -63,4 +61,4 @@ const WebConfigPage = props => {
); );
}; };
export default WebConfigPage; export default appConnector(WebConfigPage);
...@@ -27,6 +27,7 @@ import WebConfigPage from '@/pages/webConfig'; ...@@ -27,6 +27,7 @@ import WebConfigPage from '@/pages/webConfig';
import AppConfigPage from '@/pages/appConfig'; import AppConfigPage from '@/pages/appConfig';
import MobileConfigPage from '@/pages/mobileConfig'; import MobileConfigPage from '@/pages/mobileConfig';
import { USER_MODE } from '@/utils/constants'; import { USER_MODE } from '@/utils/constants';
import BaseFramContainer from '@/components/BaseFramContainer';
const iconStyle = { verticalAlign: '0.125em' }; const iconStyle = { verticalAlign: '0.125em' };
const superAuthority = [USER_MODE.SUPER]; const superAuthority = [USER_MODE.SUPER];
...@@ -145,12 +146,16 @@ export default { ...@@ -145,12 +146,16 @@ export default {
{ {
path: '/platformCenter/vedio', path: '/platformCenter/vedio',
name: '视频管理', name: '视频管理',
component: Welcome, url:
' http://192.168.10.151:8055/web4/?widget=product/oms/VideoConfig/VideoConfig|hideMap=true&videoType=萤石云',
component: BaseFramContainer,
}, },
{ {
path: '/platformCenter/emq', path: '/platformCenter/emq',
name: '宿主管理', name: '宿主管理',
component: Welcome, url:
'/web4/?widget=product/oms/MqttConfig/MqttConfig.js|hideMap=true',
component: BaseFramContainer,
}, },
{ {
path: '/platformCenter/dictionary', path: '/platformCenter/dictionary',
......
import qs from 'qs';
import { get, PUBLISH_SERVICE } from '../index';
export const getWebModuleTree = userMode =>
get(
`${PUBLISH_SERVICE}/PlatformCenter/WebModuleTree?${qs.stringify({
userMode,
})}`,
);
...@@ -25,6 +25,15 @@ const getMatchedConfig = requestConfig => { ...@@ -25,6 +25,15 @@ const getMatchedConfig = requestConfig => {
} }
}; };
axios.interceptors.request.use( function (request){
request.headers.token = 'token123'
return request
}, function (error) {
// Any status codes that falls outside the range of 2xx cause this function to trigger
// Do something with response error
return Promise.reject(error);
})
export const request = (config, ctx) => { export const request = (config, ctx) => {
const { const {
url, url,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment