@imean/sdk
Advanced tools
Comparing version 0.0.9 to 0.0.10
@@ -1,1 +0,6 @@ | ||
export default function render(): void; | ||
export default function render({ handleReplay }: { | ||
handleReplay: (item: any) => void; | ||
}): { | ||
elMain: HTMLDivElement; | ||
elHelpIframe: HTMLIFrameElement; | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function render() { | ||
console.log('TODO render help'); | ||
var def_1 = require("../def"); | ||
var images_1 = require("../images"); | ||
var setCss_1 = require("../setCss"); | ||
function render(_a) { | ||
var handleReplay = _a.handleReplay; | ||
var elMain = document.createElement('div'); | ||
elMain.setAttribute('id', def_1.MAIN_HELP_KEY); | ||
var elBtn = document.createElement('div'); | ||
elMain.appendChild(elBtn); | ||
(0, setCss_1.default)(elBtn, { | ||
position: 'fixed', | ||
bottom: '20px', | ||
right: '20px', | ||
padding: '10px', | ||
background: '#2F54EB1A', | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
borderRadius: '28px', | ||
cursor: 'pointer', | ||
opacity: '0.5', | ||
userSelect: 'none', | ||
}); | ||
var elBtnIcon = document.createElement('img'); | ||
elBtn.appendChild(elBtnIcon); | ||
elBtnIcon.src = (0, images_1.default)('logo'); | ||
(0, setCss_1.default)(elBtnIcon, { | ||
height: '28px', | ||
width: '28px', | ||
}); | ||
var elBtnText = document.createElement('div'); | ||
elBtn.appendChild(elBtnText); | ||
elBtnText.innerText = '帮助中心'; | ||
(0, setCss_1.default)(elBtnText, { | ||
fontSize: '14px', | ||
fontWeight: 'bold', | ||
paddingLeft: '8px', | ||
paddingRight: '16px', | ||
color: '#2F54EB', | ||
display: 'none', | ||
}); | ||
var elHelpIframe = document.createElement('iframe'); | ||
(0, setCss_1.default)(elHelpIframe, { | ||
position: 'fixed', | ||
zIndex: '99997', | ||
border: '0', | ||
outline: 'none', | ||
top: '0px', | ||
right: '0px', | ||
bottom: '0px', | ||
width: '376px', | ||
height: '100%', | ||
borderLeft: '1px solid rgba(0, 0, 0, 0.08)', | ||
boxShadow: '0px 5px 4px -4px rgba(0,0,0.5)', | ||
display: 'none', | ||
background: '#FFF', | ||
}); | ||
elHelpIframe.onload = function () { | ||
console.log(' elHelpIframe.onload'); | ||
window.addEventListener('message', function (e) { | ||
console.log(e); | ||
if (e.data.action === 'replay') { | ||
handleReplay === null || handleReplay === void 0 ? void 0 : handleReplay(e.data.data); | ||
} | ||
if (e.data.action === 'exit') { | ||
elHelpIframe.src = ''; | ||
(0, setCss_1.default)(elBtn, { | ||
display: 'flex', | ||
}); | ||
(0, setCss_1.default)(elHelpIframe, { | ||
display: 'none', | ||
}); | ||
} | ||
}); | ||
}; | ||
elBtn.addEventListener('mouseover', function () { | ||
(0, setCss_1.default)(elBtn, { | ||
opacity: '1', | ||
}); | ||
(0, setCss_1.default)(elBtnText, { | ||
display: 'block', | ||
}); | ||
}); | ||
elBtn.addEventListener('mouseleave', function () { | ||
(0, setCss_1.default)(elBtn, { | ||
opacity: '0.5', | ||
}); | ||
(0, setCss_1.default)(elBtnText, { | ||
display: 'none', | ||
}); | ||
}); | ||
elBtn.addEventListener('click', function () { | ||
// elHelpIframe.src = 'http://localhost:3000/home/help'; | ||
elHelpIframe.src = 'https://imean.starblazer.cn/home/help'; | ||
(0, setCss_1.default)(elBtn, { | ||
display: 'none', | ||
}); | ||
(0, setCss_1.default)(elHelpIframe, { | ||
display: 'block', | ||
}); | ||
}); | ||
elMain.appendChild(elHelpIframe); | ||
document.body.insertBefore(elMain, document.body.children[0]); | ||
return { | ||
elMain: elMain, | ||
elHelpIframe: elHelpIframe, | ||
}; | ||
} | ||
exports.default = render; |
@@ -55,3 +55,17 @@ "use strict"; | ||
if (!hideHelp) { | ||
(0, render_2.default)(); | ||
(0, render_2.default)({ | ||
handleReplay: function (item) { | ||
var STATE = { | ||
currentIndex: 0, | ||
steps: item.steps, | ||
}; | ||
STATE.steps = STATE.steps.filter(function (x) { return ['click', 'dblclick', 'type'].includes(x.type); }); | ||
localStorage.setItem(def_1.STORAGE_KEY, JSON.stringify(STATE)); | ||
if (STATE.steps[0].host) { | ||
window.location.href = STATE.steps[0].host; | ||
} | ||
else { | ||
} | ||
}, | ||
}); | ||
} | ||
@@ -58,0 +72,0 @@ }, { once: true }); |
{ | ||
"name": "@imean/sdk", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"main": "lib/index.js", | ||
@@ -5,0 +5,0 @@ "types": "lib/index.d.ts", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30476
17
768