提交 ba93d1f6 作者: 方治民

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

上级 4dfec567
{ {
"name": "Beta App", "name" : "Beta App",
"appid": "__UNI__2E9441A", "appid" : "__UNI__2E9441A",
"description": "APP 基础工程", "description" : "APP 基础工程",
"versionName": "1.0.1", "versionName" : "1.0.1",
"versionCode": 10001, "versionCode" : 10001,
"transformPx": false, "transformPx" : false,
"locale": "zh-Hans", "locale" : "zh-Hans",
"vueVersion": "3", "vueVersion" : "3",
/* 5+App特有相关 */// 配置文件详细说明 /* 5+App特有相关 */// 配置文件详细说明
// https://uniapp.dcloud.net.cn/collocation/manifest-app.html#full-manifest // https://uniapp.dcloud.net.cn/collocation/manifest-app.html#full-manifest
"app-plus": { "app-plus" : {
"usingComponents": true, "usingComponents" : true,
"nvueCompiler": "uni-app", "nvueCompiler" : "uni-app",
"nvueStyleCompiler": "uni-app", "nvueStyleCompiler" : "uni-app",
"nvueLaunchMode": "fast", "nvueLaunchMode" : "fast",
"compilerVersion": 3, "compilerVersion" : 3,
"splashscreen": { "splashscreen" : {
"alwaysShowBeforeRender": false, "alwaysShowBeforeRender" : false,
"autoclose": false, "autoclose" : false,
"waiting": true "waiting" : true
}, },
"screenOrientation": ["portrait-primary", "landscape-primary"], "screenOrientation" : [ "portrait-primary", "landscape-primary" ],
"compatible": { "compatible" : {
// 忽略版本提示 // 忽略版本提示
"ignoreVersion": true "ignoreVersion" : true
}, },
/* 模块配置 */ /* 模块配置 */
"modules": { "modules" : {
"Geolocation": {}, "Geolocation" : {},
"Camera": {} "Camera" : {}
}, },
/* 应用发布信息 */ /* 应用发布信息 */
"distribute": { "distribute" : {
/* android打包配置 */ /* android打包配置 */
"android": { "android" : {
"permissions": [ "permissions" : [
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>", "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>", "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>", "<uses-permission android:name=\"android.permission.VIBRATE\"/>",
...@@ -51,97 +51,97 @@ ...@@ -51,97 +51,97 @@
"<uses-feature android:name=\"android.hardware.camera\"/>", "<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>" "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
], ],
"permissionPhoneState": { "permissionPhoneState" : {
// app首次启动关闭权限申请 // app首次启动关闭权限申请
"request": "none" "request" : "none"
}, },
"minSdkVersion": 23, "minSdkVersion" : 23,
"targetSdkVersion": 30, "targetSdkVersion" : 30,
"abiFilters": ["armeabi-v7a", "arm64-v8a"] "abiFilters" : [ "armeabi-v7a", "arm64-v8a" ]
}, },
/* ios打包配置 */ /* ios打包配置 */
"ios": { "ios" : {
"dSYMs": false, "dSYMs" : false,
"privacyDescription": { "privacyDescription" : {
"NSUserTrackingUsageDescription": "请放心,开启权限不会获取您在其他站点的隐私信息,该权限仅用于标识设备并保障服务安全与提示浏览体验", "NSUserTrackingUsageDescription" : "请放心,开启权限不会获取您在其他站点的隐私信息,该权限仅用于标识设备并保障服务安全与提示浏览体验",
"NSLocationAlwaysAndWhenInUseUsageDescription": "该应用需要你的地理位置,以便检查你当前位置信息", "NSLocationAlwaysAndWhenInUseUsageDescription" : "该应用需要你的地理位置,以便检查你当前位置信息",
"NSLocationAlwaysUsageDescription": "该应用需要你的地理位置,以便检查你当前位置信息", "NSLocationAlwaysUsageDescription" : "该应用需要你的地理位置,以便检查你当前位置信息",
"NSLocationWhenInUseUsageDescription": "该应用需要你的地理位置,以便检查你当前位置信息", "NSLocationWhenInUseUsageDescription" : "该应用需要你的地理位置,以便检查你当前位置信息",
"NSPhotoLibraryUsageDescription": "请允许访问您的照片图库,以便能够上传应用异常问题的截图" "NSPhotoLibraryUsageDescription" : "请允许访问您的照片图库,以便能够上传应用异常问题的截图"
} }
}, },
/* SDK配置 */ /* SDK配置 */
"sdkConfigs": { "sdkConfigs" : {
"ad": {}, "ad" : {},
"statics": {}, "statics" : {},
"geolocation": { "geolocation" : {
"system": { "system" : {
"__platform__": ["ios", "android"] "__platform__" : [ "ios", "android" ]
} }
} }
}, },
"icons": { "icons" : {
"android": { "android" : {
"hdpi": "unpackage/res/icons/72x72.png", "hdpi" : "unpackage/res/icons/72x72.png",
"xhdpi": "unpackage/res/icons/96x96.png", "xhdpi" : "unpackage/res/icons/96x96.png",
"xxhdpi": "unpackage/res/icons/144x144.png", "xxhdpi" : "unpackage/res/icons/144x144.png",
"xxxhdpi": "unpackage/res/icons/192x192.png" "xxxhdpi" : "unpackage/res/icons/192x192.png"
}, },
"ios": { "ios" : {
"appstore": "unpackage/res/icons/1024x1024.png", "appstore" : "unpackage/res/icons/1024x1024.png",
"ipad": { "ipad" : {
"app": "unpackage/res/icons/76x76.png", "app" : "unpackage/res/icons/76x76.png",
"app@2x": "unpackage/res/icons/152x152.png", "app@2x" : "unpackage/res/icons/152x152.png",
"notification": "unpackage/res/icons/20x20.png", "notification" : "unpackage/res/icons/20x20.png",
"notification@2x": "unpackage/res/icons/40x40.png", "notification@2x" : "unpackage/res/icons/40x40.png",
"proapp@2x": "unpackage/res/icons/167x167.png", "proapp@2x" : "unpackage/res/icons/167x167.png",
"settings": "unpackage/res/icons/29x29.png", "settings" : "unpackage/res/icons/29x29.png",
"settings@2x": "unpackage/res/icons/58x58.png", "settings@2x" : "unpackage/res/icons/58x58.png",
"spotlight": "unpackage/res/icons/40x40.png", "spotlight" : "unpackage/res/icons/40x40.png",
"spotlight@2x": "unpackage/res/icons/80x80.png" "spotlight@2x" : "unpackage/res/icons/80x80.png"
}, },
"iphone": { "iphone" : {
"app@2x": "unpackage/res/icons/120x120.png", "app@2x" : "unpackage/res/icons/120x120.png",
"app@3x": "unpackage/res/icons/180x180.png", "app@3x" : "unpackage/res/icons/180x180.png",
"notification@2x": "unpackage/res/icons/40x40.png", "notification@2x" : "unpackage/res/icons/40x40.png",
"notification@3x": "unpackage/res/icons/60x60.png", "notification@3x" : "unpackage/res/icons/60x60.png",
"settings@2x": "unpackage/res/icons/58x58.png", "settings@2x" : "unpackage/res/icons/58x58.png",
"settings@3x": "unpackage/res/icons/87x87.png", "settings@3x" : "unpackage/res/icons/87x87.png",
"spotlight@2x": "unpackage/res/icons/80x80.png", "spotlight@2x" : "unpackage/res/icons/80x80.png",
"spotlight@3x": "unpackage/res/icons/120x120.png" "spotlight@3x" : "unpackage/res/icons/120x120.png"
} }
} }
}, },
"splashscreen": { "splashscreen" : {
"useOriginalMsgbox": true "useOriginalMsgbox" : true
} }
}, },
"uniStatistics": { "uniStatistics" : {
"enable": true "enable" : true
} }
}, },
"uniStatistics": { "uniStatistics" : {
"enable": true, "enable" : true,
"version": "2", "version" : "2",
"debug": true "debug" : true
}, },
/* 快应用特有相关 */ /* 快应用特有相关 */
"quickapp": {}, "quickapp" : {},
/* 小程序特有相关 */ /* 小程序特有相关 */
"mp-weixin": { "mp-weixin" : {
"appid": "", "appid" : "",
"setting": { "setting" : {
"urlCheck": false "urlCheck" : false
}, },
"usingComponents": true "usingComponents" : true
}, },
"mp-alipay": { "mp-alipay" : {
"usingComponents": true "usingComponents" : true
}, },
"mp-baidu": { "mp-baidu" : {
"usingComponents": true "usingComponents" : true
}, },
"mp-toutiao": { "mp-toutiao" : {
"usingComponents": true "usingComponents" : true
} }
} }
...@@ -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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论