Skip to content

Commit 24d9134

Browse files
author
开冲
committed
fix: demo
1 parent de63a6b commit 24d9134

File tree

8 files changed

+1862
-1834
lines changed

8 files changed

+1862
-1834
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ yarn-error.log*
2020
*.njsproj
2121
*.sln
2222
*.sw?
23+
24+
.cache

app1/.gitignore

Lines changed: 0 additions & 21 deletions
This file was deleted.

app1/.rescriptsrc.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ module.exports = {
1111
},
1212

1313
devServer: _ => {
14-
const config = {};
14+
const config = _;
1515

16-
config.port = '7100';
1716
config.headers = {
1817
'Access-Control-Allow-Origin': '*',
1918
};

app1/src/components/HelloModal.js

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,8 @@
1-
import React, { useState, useEffect } from 'react';
1+
import React, { useState } from 'react';
22
import { Button, Modal } from 'antd';
33

4-
const dispatchUIEvent = () => {
5-
const $a = document.createElement('a');
6-
$a.onclick = () => {
7-
console.log('log from UIEvent');
8-
};
9-
const evt = new MouseEvent('click', {
10-
view: window,
11-
bubbles: true,
12-
cancelable: false,
13-
});
14-
$a.dispatchEvent(evt);
15-
};
16-
174
export default function() {
185
const [visible, setVisible] = useState(false);
19-
useEffect(() => {
20-
dispatchUIEvent();
21-
}, []);
226
return (
237
<>
248
<Button onClick={() => setVisible(true)}>CLICK ME</Button>

app1/src/index.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import './public-path';
12
import React from 'react';
23
import ReactDOM from 'react-dom';
34
import App from './App';
4-
import './public-path';
55
import * as serviceWorker from './serviceWorker';
66

77
function render(props) {
@@ -35,11 +35,7 @@ export async function mount(props) {
3535

3636
export async function unmount(props) {
3737
const { container } = props;
38-
ReactDOM.unmountComponentAtNode(
39-
container
40-
? container.querySelector('#root')
41-
: document.querySelector('#root')
42-
);
38+
ReactDOM.unmountComponentAtNode(container ? container.querySelector('#root') : document.querySelector('#root'));
4339
}
4440

4541
// If you want your app to work offline and load faster, you can change

app1/yarn.lock

Lines changed: 1852 additions & 1772 deletions
Large diffs are not rendered by default.

portal/index.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,14 @@ registerMicroApps(
2222
[
2323
{
2424
name: 'app1',
25-
entry: '//192.168.2.192:7100',
26-
// entry: process.env.NODE_ENV === 'production' ? '//main.ppap.live:7100' : '//localhost:7100',
25+
entry: process.env.NODE_ENV === 'production' ? '//main.ppap.live:7100' : '//localhost:7100',
2726
container: '#subapp-viewport',
2827
loader,
2928
activeRule: '/app1',
3029
},
3130
{
3231
name: 'app2',
33-
entry: '//192.168.2.192:7101',
34-
// entry: process.env.NODE_ENV === 'production' ? '//main.ppap.live:7101' : '//localhost:7101',
32+
entry: process.env.NODE_ENV === 'production' ? '//main.ppap.live:7101' : '//localhost:7101',
3533
container: '#subapp-viewport',
3634
loader,
3735
activeRule: '/app2',
@@ -128,22 +126,12 @@ function initPortal(){
128126
}else{
129127
document.querySelector('.mainapp-sidemenu').style.visibility = 'visible'
130128
}
131-
if(location.pathname.indexOf('login') > -1){
132-
document.querySelector('.mainapp-header').style.display = 'block'
133-
}else{
134-
document.querySelector('.mainapp-header').style.display = 'none'
135-
}
136129

137130
//监听浏览器前进回退
138131
window.addEventListener('popstate', () => {
139132
if(location.pathname === '/'){
140133
document.querySelector('.mainapp-sidemenu').style.visibility = 'visible'
141134
}
142-
if(location.pathname.indexOf('login') > -1){
143-
document.querySelector('.mainapp-header').style.display = 'block'
144-
}else{
145-
document.querySelector('.mainapp-header').style.display = 'none'
146-
}
147135
}, false)
148136
}
149137

portal/index.less

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ body {
1010
}
1111

1212
.mainapp-header {
13-
position: fixed;
13+
position: relative;
1414
z-index: 98;
1515
top: 0;
1616
left: 0;
17-
display: none;
17+
display: block;
1818

1919
>h1 {
2020
color: #333;

0 commit comments

Comments
 (0)