Commit 4daf5a06 authored by Allen Bai's avatar Allen Bai

feat: 添加测试用例

parent 2ad658db
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>异步挂载</title>
<style>
* {
margin: 0;
padding: 0;
}
html,
body {
background-color: rgb(35, 155, 86);
}
.detail-main {
height: 200px;
position: relative;
transform: translateY(50%);
border: 3px solid black;
}
</style>
</head>
<body>
<div id="view" style="height: 200vh;border:5px slateblue solid">
<p>挂载到异步生成的dom节点上</p>
</div>
<script>
(function (e) {
const IPCFooterConfig = {
dom: '.detail-main',
footerStyles: {
position: 'static',
margin: '8px 0 60px 0'
}
}
function loadScript() {
var r = document.createElement("script");
(r.async = !0),
(r.src = "../../dist/IPCHelper.main.js"),
(r.crossOrigin = "anonymous"),
(r.onload = function () {
window.__TUIA_IPC_HELPER__ && window.__TUIA_IPC_HELPER__.mountIPCFooter(IPCFooterConfig)
}),
document.body && document.body.appendChild(r);
};
loadScript()
})(window);
</script>
<script>
var view = document.querySelector('#view')
setTimeout(() => {
let ele = document.createElement('div')
ele.classList.add('detail-main')
view.appendChild(ele)
}, 2000)
</script>
</body>
</html>
......@@ -4,7 +4,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>线上页面引入方法</title>
<title>自定义参数</title>
<style>
* {
margin: 0;
......@@ -15,12 +15,24 @@
body {
background-color: rgb(35, 155, 86);
}
.detail-main {
height: 200px;
position: relative;
transform: translateY(50%);
border: 3px solid black;
}
</style>
</head>
<body>
<div style="height: 200vh;border:5px slateblue solid"></div>
<div style="height: 200vh;border:5px slateblue solid">
<p>自定义参数</p>
<div class="detail-main">
</div>
</div>
<script>
// 自定义参数
// 百奇商品详情页建议用这个
(function (e) {
const IPCFooterConfig = {
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>remount测试</title>
<style>
* {
margin: 0;
padding: 0;
}
html,
body {
background-color: rgb(35, 155, 86);
}
.detail-main {
height: 200px;
position: relative;
transform: translateY(50%);
border: 3px solid black;
}
</style>
</head>
<body>
<div id="view" style="height: 200vh;border:5px slateblue solid">
<p>在第一次挂载之前,调用remount方法</p>
</div>
<script>
(function (e) {
const IPCFooterConfig = {
dom: '.detail-main',
footerStyles: {
position: 'static',
margin: '8px 0 60px 0'
}
}
function loadScript() {
var r = document.createElement("script");
(r.async = !0),
(r.src = "../../dist/IPCHelper.main.js"),
(r.crossOrigin = "anonymous"),
(r.onload = function () {
window.__TUIA_IPC_HELPER__ && window.__TUIA_IPC_HELPER__.mountIPCFooter(IPCFooterConfig)
}),
document.body && document.body.appendChild(r);
};
loadScript()
})(window);
</script>
<script>
var view = document.querySelector('#view')
setTimeout(() => {
let ele = document.createElement('div')
ele.classList.add('detail-main')
view.appendChild(ele)
window.__TUIA_IPC_HELPER__.remount({
dom: '.detail-main',
footerStyles: {
position: 'static',
margin: '8px 0 60px 0',
},
boardStyles: {
backgroundColor: 'yellow'
}
})
}, 2000)
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>remount测试</title>
<style>
* {
margin: 0;
padding: 0;
}
html,
body {
background-color: rgb(35, 155, 86);
}
.detail-main {
height: 200px;
position: relative;
transform: translateY(50%);
border: 3px solid black;
}
</style>
</head>
<body>
<div id="view" style="height: 200vh;border:5px slateblue solid">
<p>在第一次挂载之后,调用remount方法</p>
</div>
<script>
(function (e) {
const IPCFooterConfig = {
dom: '.detail-main',
footerStyles: {
position: 'static',
margin: '8px 0 60px 0'
}
}
function loadScript() {
var r = document.createElement("script");
(r.async = !0),
(r.src = "../../dist/IPCHelper.main.js"),
(r.crossOrigin = "anonymous"),
(r.onload = function () {
window.__TUIA_IPC_HELPER__ && window.__TUIA_IPC_HELPER__.mountIPCFooter(IPCFooterConfig)
}),
document.body && document.body.appendChild(r);
};
loadScript()
})(window);
</script>
<script>
var view = document.querySelector('#view')
setTimeout(() => {
let ele = document.createElement('div')
ele.classList.add('detail-main')
view.appendChild(ele)
setTimeout(() => {
window.__TUIA_IPC_HELPER__.remount({
dom: '.detail-main',
footerStyles: {
position: 'static',
margin: '8px 0 60px 0',
},
boardStyles: {
backgroundColor: 'yellow'
}
})
}, 1000)
}, 2000)
</script>
</body>
</html>
......@@ -125,23 +125,22 @@ async function mountIPCFooter(opts: IPCFooterOptions = {}) {
IPCFooter.id = '__IPC_footer__'
IPCBoard.id = '__IPC_board__'
addStyles(IPCFooter, { ...defaultFooterStyles, ...(opts.footerStyles || {}) })
addStyles(IPCBoard, { ...defaultBoardStyles, ...(opts.footerStyles || {}) })
addStyles(IPCBoard, { ...defaultBoardStyles, ...(opts.boardStyles || {}) })
IPCBoard.innerText = (IPCNumberString as string) || 'IPC备-'
IPCBoard.href = 'https://beian.miit.gov.cn/#/Integrated/index'
IPCFooter.appendChild(IPCBoard)
let tryCount = 6
let tryCount = 10
function __mount__() {
let targetDom
if (opts.dom === undefined || opts.dom === null) {
targetDom = document.querySelector('body')
} else if (typeof opts.dom === 'string') {
targetDom = document.querySelector(targetDom)
targetDom = document.querySelector(opts.dom)
} else {
targetDom = opts.dom
}
if (!targetDom) {
// 可能目标dom节点还没挂载
if (tryCount > 0) {
......
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