feat: 增加移动端检测功能并优化widget参数传递 & v0.9.69
This commit is contained in:
+7
-2
@@ -78,6 +78,8 @@
|
||||
script.src = `${origin}${manifest.files["widget.js"]}`;
|
||||
script.onload = () => {
|
||||
// 脚本加载完成后,需要手动初始化 React 应用到 shadow DOM
|
||||
// 检测父窗口是否为移动端
|
||||
const isMobile = w.innerWidth < 768;
|
||||
const params = new URLSearchParams({
|
||||
id,
|
||||
host: hostId,
|
||||
@@ -97,7 +99,8 @@
|
||||
closeWidth,
|
||||
closeHeight,
|
||||
openWidth,
|
||||
openHeight
|
||||
openHeight,
|
||||
isMobile
|
||||
});
|
||||
|
||||
// 将参数传递给 shadow DOM 内的应用
|
||||
@@ -131,9 +134,11 @@
|
||||
const wrapper = d.createElement("iframe");
|
||||
wrapper.id = "VOCECHAT_WIDGET";
|
||||
Object.assign(wrapper.style, baseStyles);
|
||||
// 检测父窗口是否为移动端
|
||||
const isMobile = w.innerWidth < 768;
|
||||
wrapper.src = `${origin}/widget.html?id=${id}&host=${hostId}&autoReg=${autoReg}&token=${loginToken}&themeColor=${encodeURIComponent(
|
||||
themeColor
|
||||
)}&from=${encodeURIComponent(location.hostname)}&welcome=${encodeURIComponent(welcome)}&title=${encodeURIComponent(title)}&logo=${encodeURIComponent(logo)}&popupTitle=${encodeURIComponent(popupTitle)}&popupSubtitle=${encodeURIComponent(popupSubtitle)}&popupImage=${encodeURIComponent(popupImage)}&popupClosable=${popupClosable}&showPopup=${showPopup}`;
|
||||
)}&from=${encodeURIComponent(location.hostname)}&welcome=${encodeURIComponent(welcome)}&title=${encodeURIComponent(title)}&logo=${encodeURIComponent(logo)}&popupTitle=${encodeURIComponent(popupTitle)}&popupSubtitle=${encodeURIComponent(popupSubtitle)}&popupImage=${encodeURIComponent(popupImage)}&popupClosable=${popupClosable}&showPopup=${showPopup}&isMobile=${isMobile}`;
|
||||
wrapper.width = actualCloseWidth;
|
||||
wrapper.height = actualCloseHeight;
|
||||
wrapper.frameborder = 0;
|
||||
|
||||
Reference in New Issue
Block a user