提交 ba93d1f6 作者: 方治民

feat: 更新 Chat 模块,修复 iOS 17.1 后出现的界面兼容性问题,补充低端设备兼容性测试提醒

上级 4dfec567
...@@ -37,6 +37,11 @@ ...@@ -37,6 +37,11 @@
"path": "pages/example/chat/index", "path": "pages/example/chat/index",
"style": { "style": {
"navigationStyle": "custom", "navigationStyle": "custom",
"backgroundColor": "#ffffff",
// #ifdef H5
"titleNView": false,
// #endif
"disableScroll": true,
"app-plus": { "app-plus": {
"titleNView": false, "titleNView": false,
"bounce": "none" "bounce": "none"
......
...@@ -36,16 +36,31 @@ ...@@ -36,16 +36,31 @@
Message.loading() Message.loading()
// #ifdef APP-PLUS // #ifdef APP-PLUS
const system = uni.getSystemInfoSync()
// 对于不安全或不信任的网站地址或可能触发 plus API 的来源,采用手动创建 webview 的方式打开 // 对于不安全或不信任的网站地址或可能触发 plus API 的来源,采用手动创建 webview 的方式打开
const webview = plus.webview.create(page.link, 'no-security-webview', { const webview = plus.webview.create(page.link, 'no-security-webview', {
progress: page.styles.progress, progress: page.styles.progress,
}) })
// FIXED: 处理 iOS 下意外的高度兼容性问题
if (system.platform === 'ios') {
webview.setStyle({
popGesture: 'none',
scrollIndicator: 'none',
top: `${system.statusBarHeight}px`,
bottom: `${system.safeAreaInsets.bottom}px`,
background: 'transparent',
})
}
webview.addEventListener( webview.addEventListener(
'loaded', 'loaded',
() => { () => {
let paddingTop = '0px' // FIX: classId 可能随着每个 Web SDK 版本会更新,需要注意,一旦发生变更可能会丢失部分样式(用户头像)
if (uni.getSystemInfoSync().platform === 'android') { const classId = 'ca5e07ec94ad125e02ca'
paddingTop = '30px' let paddingTop = `${system.statusBarHeight}px`
if (system.platform === 'ios') {
paddingTop = '0px'
} }
webview.appendJsFile('_www/static/uni.webview.1.5.6.js') webview.appendJsFile('_www/static/uni.webview.1.5.6.js')
...@@ -65,7 +80,7 @@ ...@@ -65,7 +80,7 @@
// 隐藏底部描述和图片上传能力 // 隐藏底部描述和图片上传能力
var style = document.createElement('style') var style = document.createElement('style')
style.id = 'no-security-webview-style' style.id = 'no-security-webview-style'
style.innerHTML = 'footer, .semi-upload-add { display: none !important; } .close-btn { position: absolute; right: 12px; top: calc(18px + ${paddingTop}); padding: 8px; } html { padding-top: calc(0px + ${paddingTop}) }' style.innerHTML = 'footer { display: none !important; } .close-btn { z-index: 99999; position: absolute; right: 12px; top: calc(18px + ${paddingTop}); padding: 8px; } html { padding-top: ${paddingTop}; background: transparent; } .semi-avatar>img { border-radius: 50% !important; } .${classId}-content>div:last-child .semi-avatar-img img { opacity: 0; } .${classId}-content>div:last-child .semi-avatar-img { position: relative; background-image: url(https://hntq.yiring.com/minio/public/system/ai/hntq-ai-user-2.png); background-size: cover; background-position: center; }'
document.body.appendChild(style) document.body.appendChild(style)
// 添加关闭按钮 // 添加关闭按钮
...@@ -76,6 +91,15 @@ ...@@ -76,6 +91,15 @@
uni.navigateBack() uni.navigateBack()
} }
document.body.appendChild(div) document.body.appendChild(div)
window.onerror = function(e) {
var message = JSON.stringify(e)
// alert('页面加载异常:' + message)
if (message.indexOf('ReferenceError') !== -1) {
var ok = confirm('抱歉,发现了不兼容的问题,请您检查系统版本是否过于旧,欢迎升级后再尝试体验,感谢您的支持~')
uni.navigateBack()
}
}
`) `)
}, },
false, false,
...@@ -84,7 +108,7 @@ ...@@ -84,7 +108,7 @@
const pages = getCurrentPages() const pages = getCurrentPages()
const currentPage = pages[pages.length - 1] const currentPage = pages[pages.length - 1]
const currentWebview = currentPage.$getAppWebview() const currentWebview = currentPage.$getAppWebview()
currentWebview.setStyle({ progress: page.styles.progress }) currentWebview.setStyle({ progress: page.styles.progress, popGesture: 'none' })
currentWebview.append(webview) currentWebview.append(webview)
// #endif // #endif
// #ifndef APP-PLUS // #ifndef APP-PLUS
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
{ {
name: 'Chat AI 对话', name: 'Chat AI 对话',
icon: 'emojione-cowboy-hat-face', icon: 'emojione-cowboy-hat-face',
page: `/pages/example/chat/index?link=${encodeURIComponent('https://api.coze.cn/open-platform/sdk/chatapp?params=%7B%22chatClientId%22%3A%22Hd1w0dc49QzvaAGlDONiA%22%2C%22chatConfig%22%3A%7B%22bot_id%22%3A%227426295021118488587%22%2C%22user%22%3A%22NmAh7FUtuyO6RPrzYMg4v%22%2C%22conversation_id%22%3A%22cqnuKy6c3lmYTdjF0vslj%22%7D%2C%22componentProps%22%3A%7B%22layout%22%3A%22mobile%22%2C%22lang%22%3A%22zh_CN%22%2C%22uploadable%22%3Atrue%2C%22title%22%3A%22%E6%B9%96%E5%8D%97%E5%A4%A9%E6%B0%94%20AI%20%E6%99%BA%E8%83%BD%E5%8A%A9%E7%90%86%22%2C%22icon%22%3A%22https%3A%2F%2Fhntq-res.oss-cn-shenzhen.aliyuncs.com%2Fhntq-ai-logo.png%22%7D%7D')}`, page: `/pages/example/chat/index?link=${encodeURIComponent('https://api.coze.cn/open-platform/sdk/chatapp?params=%7B%22chatClientId%22%3A%22BCsVIvFQTfR6aaoq9rRlj%22%2C%22chatConfig%22%3A%7B%22bot_id%22%3A%227426295021118488587%22%2C%22user%22%3A%22yUDCvvY6bwgJlKOR4z64X%22%2C%22conversation_id%22%3A%22ugG5MOjgpB5QidAIG8Yf1%22%7D%2C%22componentProps%22%3A%7B%22layout%22%3A%22mobile%22%2C%22lang%22%3A%22zh-CN%22%2C%22uploadable%22%3Atrue%2C%22title%22%3A%22%E6%B9%96%E5%8D%97%E5%A4%A9%E6%B0%94%20AI%20%E5%B0%8F%E5%8A%A9%E6%89%8B%22%2C%22icon%22%3A%22https%3A%2F%2Fhntq.yiring.com%2Fminio%2Fpublic%2Fsystem%2Fai%2Fhntq-ai-logo.png%22%7D%7D')}`,
animationType: 'slide-in-bottom', animationType: 'slide-in-bottom',
}, },
{ {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论