Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
basic-uniapp-v3
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-uniapp-v3
Commits
ba93d1f6
提交
ba93d1f6
authored
10月 29, 2024
作者:
方治民
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 更新 Chat 模块,修复 iOS 17.1 后出现的界面兼容性问题,补充低端设备兼容性测试提醒
上级
4dfec567
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
128 行增加
和
99 行删除
+128
-99
manifest.json
src/manifest.json
+93
-93
pages.json
src/pages.json
+5
-0
index.vue
src/pages/example/chat/index.vue
+29
-5
index.vue
src/pages/example/index.vue
+1
-1
没有找到文件。
src/manifest.json
浏览文件 @
ba93d1f6
差异被折叠。
点击展开。
src/pages.json
浏览文件 @
ba93d1f6
...
@@ -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
H
5
"titleNView"
:
false
,
//
#endif
"disableScroll"
:
true
,
"app-plus"
:
{
"app-plus"
:
{
"titleNView"
:
false
,
"titleNView"
:
false
,
"bounce"
:
"none"
"bounce"
:
"none"
...
...
src/pages/example/chat/index.vue
浏览文件 @
ba93d1f6
...
@@ -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
...
...
src/pages/example/index.vue
浏览文件 @
ba93d1f6
...
@@ -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%22
Hd1w0dc49QzvaAGlDONiA%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%22
BCsVIvFQTfR6aaoq9rRlj%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
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论