Skip to content

Commit cffabc4

Browse files
committed
fix: 针对企业微信环境判断处理
1 parent 07abaaf commit cffabc4

File tree

1 file changed

+17
-0
lines changed
  • apps/miniprogram-agent-ui/miniprogram/components/agent-ui

1 file changed

+17
-0
lines changed

apps/miniprogram-agent-ui/miniprogram/components/agent-ui/tools.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
export const checkConfig = (chatMode,agentConfig,modelConfig) => {
22
const { botId } = agentConfig||{}
33
const { modelProvider,quickResponseModel,deepReasoningModel } = modelConfig||{}
4+
// 检测不在微信环境,提示用户
5+
try {
6+
const systemInfo = wx.getSystemInfoSync()
7+
console.log('systemInfo', systemInfo)
8+
if(systemInfo.environment === 'wxwork') {
9+
return [false,'请前往微信客户端扫码打开小程序']
10+
}
11+
}catch(e) {
12+
console.log('getSystemInfoSync 接口废弃')
13+
// 使用 getAppBaseInfo 兜底
14+
const appBaseInfo = wx.getAppBaseInfo();
15+
console.log('appBaseInfo', appBaseInfo)
16+
if(appBaseInfo.host.env === 'SDK') {
17+
return [false,'请前往微信客户端扫码打开小程序']
18+
}
19+
}
20+
421
// 检测AI能力,不存在提示用户
522
if(!wx.cloud.extend||!wx.cloud.extend.AI){
623
return [false,'使用AI能力需基础库为3.7.7及以上,请升级基础库版本或微信客户端']

0 commit comments

Comments
 (0)