Skip to content

Commit

Permalink
feat(1.0.0-rc.6): fix conflicts of merge
Browse files Browse the repository at this point in the history
  • Loading branch information
bailicangdu committed Jul 29, 2024
2 parents 0731a12 + 4849e7e commit 2a20aff
Show file tree
Hide file tree
Showing 122 changed files with 4,515 additions and 2,788 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/issue-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
body: |
Hello @${{ github.event.issue.user.login }}. We totally like your proposal/feedback, welcome to send us a Pull Request for it. Please be sure to submit compliant commit message, provide changelog/documentation/test cases, we will review it soon. We appreciate your effort in advance and looking forward to your contribution!
您好 @${{ github.event.issue.user.login }},我们完全同意您的提议/反馈,欢迎直接在此仓库创建一个 Pull Request 来解决这个问题。请务必填写符合规范的commit message,提供改动所需相应的 changelog、测试用例、文档等,我们会尽快进行 Review,提前感谢和期待您的贡献。
- name: pls use issue template
if: github.event.label.name == 'pls use issue template'
uses: actions-cool/[email protected]
Expand All @@ -26,6 +27,7 @@ jobs:
body: |
Hello @${{ github.event.issue.user.login }}. Please use the issue template to report. This issue will be closed.
您好 @${{ github.event.issue.user.login }},请使用 issue 模板反馈问题。该 issue 将要被关闭。
- name: Need Reproduction
if: github.event.label.name == 'Need Reproduction'
uses: actions-cool/[email protected]
Expand All @@ -35,3 +37,13 @@ jobs:
body: |
Hello @${{ github.event.issue.user.login }}. In order to facilitate location and troubleshooting, we need you to provide a realistic GitHub repository.
您好 @${{ github.event.issue.user.login }}, 为了方便定位和排查问题,我们需要您提供一个重现实例,请提供一个尽可能精简的 GitHub 仓库地址。
- name: fixed
if: github.event.label.name == 'fixed'
uses: actions-cool/[email protected]
with:
actions: 'create-comment, close-issue'
issue-number: ${{ github.event.issue.number }}
body: |
Hello @${{ github.event.issue.user.login }}. The issue you reported has been fixed. This issue will be closed. Thank you for your feedback.
您好 @${{ github.event.issue.user.login }},您反馈的问题已修复,该 issue 将要被关闭,感谢反馈。
10 changes: 9 additions & 1 deletion Contact.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@

欢迎小伙伴们加入micro-app微信群交流^ ^

![IMG_8085](https://github.com/micro-zoe/micro-app/assets/14011130/f3447ec5-61dd-4c9c-a590-72478b608377)
![IMG_9187](https://github.com/user-attachments/assets/64d16edc-311a-46ea-8ce7-c6fcbe0651d3)











Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<p align="center">
<a href="https://micro-zoe.github.io/micro-app/">
<img src="https://zeroing.jd.com/micro-app/media/logo.png" alt="logo" width="200"/>
<img src="https://micro-zoe.github.io/micro-app/home/assets/logo.png" alt="logo" width="200"/>
</a>
</p>

Expand Down
1 change: 0 additions & 1 deletion dev/children/react16/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
color:#fff;
}
</style>
<!-- <link rel="stylesheet" href="https://static.rokidcdn.com/test/ar-independent/0.0.2/static/css/2.846bef85.chunk.css"> -->
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
43 changes: 42 additions & 1 deletion dev/children/react16/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,46 @@ code {
}

.test-back-var {
background-color: rgb(255 255 255 / var(--opacity));
background-color: rgb(255 255 255 / var(--opacity));;;;
}

/* @layer规则 */
@layer theme, layout, utilities;

.test-layer {
background-color: red;
}

@layer utilities {
.padding-sm {
padding: 0.5rem;
}

.padding-lg {
padding: 0.8rem;
}
}

@layer framework {
@layer layout {
.test-layer {
.test-layer-nest {
color: red;
}
}
}
}

// 错误1
.basic-layout-side-menu{.ant-menu-item-group{&:last-child{border-bottom:none!important}}}

// 错误2
.chat-message-markdown-wrap{table{width:100%!important;border:1px solid #ccc}table td,table th{border-bottom:1px solid #ccc;border-right:1px solid #ccc;padding:5px 10px}table th{text-align:center;background:#dee8ee}table th:last-child{border-right:none}table td:last-child{border-right:none}table tr:last-child td{border-bottom:none}tr:nth-child(2n){background:#eff3f5}blockquote{display:block;border-left:8px solid #d0e5f2;padding:5px 10px;margin:10px 0;line-height:1.4;font-size:100%;background-color:#f1f1f1}ul,ol{margin:10px 0 10px 20px}}

.nest-a {
.nest-b {
.nest-c {
color: red;
}
}
}
133 changes: 94 additions & 39 deletions dev/children/react16/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,27 @@ import './ant-custom.css'; // 自定义antd class前缀
import './index.css';
import Router from './router';
import { Modal, notification, ConfigProvider } from 'antd';
import subMicroApp from '@micro-zoe/micro-app';
import microApp from '@micro-zoe/micro-app';
// import './flexible';
// import '@alifd/next/dist/next.css';
// import { atan2 } from 'mathjs' // 卡死
// import './setImmediate.js'

// 循环内嵌
subMicroApp.start({
tagName: 'micro-app-sub'
microApp.start({
tagName: 'micro-app-react16'
})

ConfigProvider.config({
prefixCls: 'react16',
})

console.log('react16 通过 window.microApp.getData 获取的初始化数据:', window.microApp?.getData())

// window.setImmediate(function () {
// alert(11111111)
// })

// 数据监听
window.microApp?.addDataListener((data) => {
console.log('react16 来自基座应用的数据', data)
Expand Down Expand Up @@ -71,6 +78,7 @@ window.addEventListener('appstate-change', function (e) {
// // 注册unmount函数,卸载时会自动执行
// window.unmount = () => {
// ReactDOM.unmountComponentAtNode(document.getElementById('root'));
// // window.microApp.
// console.log('微应用react16卸载了 -- 默认模式');
// }

Expand Down Expand Up @@ -124,10 +132,10 @@ window.onunmount = () => {
// // console.log(this)
// }, false)

// document.onclick = function () {
// console.log(`子应用${window.__MICRO_APP_NAME__}内部的document.onclick绑定`)
// // console.log(this)
// }
document.onclick = function () {
console.log(`子应用${window.__MICRO_APP_NAME__}内部的document.onclick绑定`)
// console.log(this)
}

// window.addEventListener('click', function () {
// console.log(`子应用${window.__MICRO_APP_NAME__}内部的window.addEventListener绑定`)
Expand Down Expand Up @@ -373,8 +381,8 @@ if (window.__MICRO_APP_ENVIRONMENT__) {
// Vue是系统默认绑定变量
console.assert(window.Vue === undefined, 'window.Vue 应该为false')
console.assert(('Vue' in window) === false, 'Vue in window 应该为false')
window.Vue = '自定义Vue'
console.assert(window.Vue === '自定义Vue', 'window.Vue 应该为自定义Vue')
window.Vue = '子应用内部自定义Vue'
console.assert(window.Vue === '子应用内部自定义Vue', 'window.Vue 应该为子应用内部自定义Vue')

// ----------------------- scope相关---------------------结束

Expand All @@ -393,27 +401,28 @@ if (window.__MICRO_APP_ENVIRONMENT__) {
}

/* ---------------------- pureCreateElement & removeDomScope --------------------- */
if (window.__MICRO_APP_ENVIRONMENT__) {
// const unBoundDom1 = window.microApp.pureCreateElement('div')
// unBoundDom1.innerHTML = 'unBoundDom1'
// document.body.appendChild(unBoundDom1)

// /**
// * !!!! 注意removeDomScope(true)是异步清空的,这里会导致一个问题
// * 执行removeDomScope(true)后再执行window.mount方法,会导致子应用初始化失败
// */
// window.microApp.removeDomScope(true)
// const unBoundDom2 = window.document.createElement('div')
// unBoundDom2.innerHTML = 'unBoundDom2'
// document.body.appendChild(unBoundDom2)

// const unBoundDom3 = window.rawDocument.createElement('div')
// unBoundDom3.innerHTML = 'unBoundDom3'
// document.body.appendChild(unBoundDom3)

// const dynamicSvg = document.createElementNS('http://www.w3.org/2000/svg', 'svg')
// document.body.appendChild(dynamicSvg)
}
// if (window.__MICRO_APP_ENVIRONMENT__) {
// // pureCreateElement创建的元素无法拦截,插入到主应用body中
// const unBoundDom1 = window.microApp.pureCreateElement('div')
// unBoundDom1.innerHTML = 'unBoundDom1'
// document.body.appendChild(unBoundDom1)

// // 解除元素绑定,unBoundDom2插入到主应用body中
// window.microApp.removeDomScope(true) // 解除元素绑定
// const unBoundDom2 = window.document.createElement('div')
// unBoundDom2.innerHTML = 'unBoundDom2'
// document.body.appendChild(unBoundDom2)
// window.microApp.removeDomScope(false) // 恢复元素绑定

// // 元素绑定已经恢复,unBoundDom3插入到子应用 micro-app-body中
// const unBoundDom3 = window.rawDocument.createElement('div')
// unBoundDom3.innerHTML = 'unBoundDom3'
// document.body.appendChild(unBoundDom3)

// // 插入子应用 micro-app-body中
// const dynamicSvg = document.createElementNS('http://www.w3.org/2000/svg', 'svg')
// document.body.appendChild(dynamicSvg)
// }


/* ---------------------- 获取原生window 和 document --------------------- */
Expand All @@ -429,15 +438,15 @@ if (window.__MICRO_APP_ENVIRONMENT__) {
/* ---------------------- location 相关 --------------------- */
// 获取location信息
if (window.__MICRO_APP_ENVIRONMENT__) {
console.log(`${window.__MICRO_APP_NAME__} location.href`, location.href, window.rawWindow.location.href)
console.log(`${window.__MICRO_APP_NAME__} location.origin`, location.origin, window.rawWindow.location.origin)
console.log(`${window.__MICRO_APP_NAME__} location.host`, location.host, window.rawWindow.location.host)
console.log(`${window.__MICRO_APP_NAME__} location.hostname`, location.hostname, window.rawWindow.location.hostname)
console.log(`${window.__MICRO_APP_NAME__} location.port`, location.port, window.rawWindow.location.port)
console.log(`${window.__MICRO_APP_NAME__} location.protocol`, location.protocol, window.rawWindow.location.protocol)
console.log(`${window.__MICRO_APP_NAME__} location.pathname`, location.pathname, window.rawWindow.location.pathname)
console.log(`${window.__MICRO_APP_NAME__} location.hash`, location.hash, window.rawWindow.location.hash)
console.log(`${window.__MICRO_APP_NAME__} location.search`, location.search, window.rawWindow.location.search)
// console.log(`${window.__MICRO_APP_NAME__} location.href`, location.href, window.rawWindow.location.href)
// console.log(`${window.__MICRO_APP_NAME__} location.origin`, location.origin, window.rawWindow.location.origin)
// console.log(`${window.__MICRO_APP_NAME__} location.host`, location.host, window.rawWindow.location.host)
// console.log(`${window.__MICRO_APP_NAME__} location.hostname`, location.hostname, window.rawWindow.location.hostname)
// console.log(`${window.__MICRO_APP_NAME__} location.port`, location.port, window.rawWindow.location.port)
// console.log(`${window.__MICRO_APP_NAME__} location.protocol`, location.protocol, window.rawWindow.location.protocol)
// console.log(`${window.__MICRO_APP_NAME__} location.pathname`, location.pathname, window.rawWindow.location.pathname)
// console.log(`${window.__MICRO_APP_NAME__} location.hash`, location.hash, window.rawWindow.location.hash)
// console.log(`${window.__MICRO_APP_NAME__} location.search`, location.search, window.rawWindow.location.search)

// 依次放开每个注释来,尽可能覆盖所有场景
setTimeout(() => {
Expand Down Expand Up @@ -560,3 +569,49 @@ console.log('micro-app容器元素document.microAppElement', document.microAppEl
// new Promise((resolve, reject) => {
// throw 'promise 逃逸的错误'
// })

/* ---------------------- 测试iframe document.body/head 获取元素 --------------------- */
// if (window.__MICRO_APP_ENVIRONMENT__) {
// setTimeout(() => {
// // 场景1 querySelector: 不设置appName导致查询元素无法被拦截到子应用内部
// console.log(`document.body.querySelector('#root') ==>`, document.body.querySelector('#root'))
// // console.log(`获取子应用root元素 -- document.querySelector`, document.querySelector('body').querySelector('#root'))
// console.log(`document.body.querySelector('script') ==>`, document.body.querySelector('script'))
// console.log(`document.head.querySelector('script') ==>`, document.head.querySelector('script'))

// // 场景2 querySelectorAll: 不设置appName导致查询元素无法被拦截到子应用内部
// console.log(`document.body.querySelectorAll('#root') ==>`, document.body.querySelectorAll('#root'))
// // console.log(`document.querySelector('body').querySelectorAll('#root') ==>`, document.querySelector('body').querySelectorAll('#root'))
// console.log(`document.body.querySelectorAll('script') ==>`, document.body.querySelectorAll('script'))
// console.log(`document.head.querySelectorAll('script') ==>`, document.head.querySelectorAll('script'))

// console.log(`document.querySelector('script') ==>`, document.querySelector('script'))
// console.log(`document.querySelectorAll('script') ==>`, document.querySelectorAll('script'))

// console.log(`document.getElementsByTagName('head')[0].querySelector('script') ==>`, document.getElementsByTagName('head')[0].querySelector('script'))
// console.log(`document.querySelector('body').querySelectorAll('script') ==>`, document.querySelector('body').querySelectorAll('script'))


// // 场景2:设置appName导致基座元素插入子应用
// // window.microApp.removeDomScope(true)
// window.rawWindow.insertNodeFromBaseApp() // 调用主应用方法插入元素
// // window.microApp.removeDomScope(false)
// }, 1000);
// }

/* ---------------------- 测试 DocumentFragment --------------------- */
// if (window.__MICRO_APP_ENVIRONMENT__) {
// setTimeout(() => {
// // window.microApp.removeDomScope(true)
// const a = document.createDocumentFragment()
// const b = document.createElement('script')
// // const b = window.microApp.pureCreateElement('script')
// b.src = 'http://127.0.0.1:8080/js/test.js'
// // a.appendChild(b)
// // a.append(b)
// a.prepend(b)
// // Element.prototype.appendChild.call(a, b)
// document.body.prepend(a)
// // window.microApp.removeDomScope(false)
// }, 1000);
// }
5 changes: 3 additions & 2 deletions dev/children/react16/src/pages/nest/nest.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,19 @@ function Vue2 () {
{
showLoading && <Spin />
}
<micro-app-sub
<micro-app-react16
name='nest'
url={`${config.vue2}micro-app/vue2/`}
data={data}
router-mode='state'
// onBeforemount={() => hideLoading(false)}
onMounted={() => hideLoading(false)}
// shadowDOM
// destory
inline
// disableScopecss
// disableSandbox
iframe
// iframe
/>
<img src={logo} className="App-logo" alt="logo" width='100' />
</div>
Expand Down
4 changes: 2 additions & 2 deletions dev/children/react16/src/pages/page2/page2.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ const Page2 = () => {
const testClick = () => {
console.log('click from test button')
// window.dispatchEvent(new PopStateEvent('popstate', { state: window.history.state }))
window.location.href = '/micro-app/react16/page2'
window.history.go(-1)
// window.location.href = '/micro-app/react16/page2'
// window.history.go(-1)
}

const showDrawer = () => {
Expand Down
Loading

0 comments on commit 2a20aff

Please sign in to comment.