diff --git a/app.js b/app.js index 0bad1a0..13fc9b3 100644 --- a/app.js +++ b/app.js @@ -58,7 +58,9 @@ App({ console.error('获取科室排名失败', err) resolve([]) }) - }) + }) + + this.checkUpdate(); }, onShow(options) { @@ -66,7 +68,9 @@ App({ wx.login({ success: res => { if (res.code) { - request.post('https://api.huashengtec.com/user/wxsignin', { code: res.code }) + request.post('https://api.huashengtec.com/user/wxsignin', { + code: res.code + }) .then((data) => { if (data.code == 0) { this.globalData.user = data.data.user @@ -110,6 +114,36 @@ App({ this.globalData.chatSocket = socket }, + checkUpdate() { + // 获取小程序更新管理器实例 + const updateManager = wx.getUpdateManager(); + + // 监听检查更新事件,当小程序有新版本时会触发此回调 + updateManager.onCheckForUpdate(function (res) { + // 请求完新版本信息的回调 + console.log(res.hasUpdate); // 打印是否有新版本 + }); + + // 监听更新准备就绪事件,当新版本下载完成时会触发此回调 + updateManager.onUpdateReady(function () { + wx.showModal({ + title: '更新提示', + content: '新版本已经准备好,可以重启应用小程序了!', + success(res) { + if (res.confirm) { + // 用户确认更新,调用 applyUpdate 应用新版本并重启小程序 + updateManager.applyUpdate(); + } + } + }); + }); + + // 监听更新失败事件,当新版本下载失败时会触发此回调 + updateManager.onUpdateFailed(function () { + // 新版本下载失败,可以在这里处理失败逻辑,例如提示用户稍后再试 + }); + }, + globalData: { appId: '', user: null, diff --git a/pages/ai/aichat.json b/pages/ai/aichat.json index 813e909..1b8c9d4 100644 --- a/pages/ai/aichat.json +++ b/pages/ai/aichat.json @@ -1,6 +1,7 @@ { "navigationBarTitleText": "AI陪诊助手", "usingComponents": { - "t-icon": "tdesign-miniprogram/icon/icon" + "t-icon": "tdesign-miniprogram/icon/icon", + "t-chat-markdown": "tdesign-miniprogram/chat-markdown/chat-markdown" } } \ No newline at end of file diff --git a/pages/ai/aichat.wxml b/pages/ai/aichat.wxml index a2a9ff2..12c37a4 100644 --- a/pages/ai/aichat.wxml +++ b/pages/ai/aichat.wxml @@ -39,7 +39,12 @@ - {{item.content}} + + {{item.content}} - {{item.content}} + + {{item.content}}