...
 
Commits (4)
    https://gitcode.net/dcloud/uni-im/-/commit/6b6ed90ff1db22bdf435acc51dfc822d479f75a7 修复 解决在低版本的 nodejs 环境下不支持可先链的问题 2024-05-08T11:36:57+08:00 DCloud_JSON linju@dcloud.io https://gitcode.net/dcloud/uni-im/-/commit/a4fc7237db14962d2f8cb7332171fecceed63ed5 修复 云端扩展框架仅在部署到可写的云环境时才输出缓存文件 2024-05-08T12:32:02+08:00 DCloud_MQ maq128@126.com https://gitcode.net/dcloud/uni-im/-/commit/18014a40d81ddb0774ffea166384e1efdca60b2d add 3.0.1-3.0.2 changelog 2024-05-08T13:19:29+08:00 DCloud_JSON linju@dcloud.io https://gitcode.net/dcloud/uni-im/-/commit/12d9352225348fd31aca164575ea9b1040650046 Update package.json 2024-05-08T13:22:03+08:00 DCloud_JSON linju@dcloud.io
## 3.0.2(2024-05-08)
- 修复 解决部分云厂商的uniCloud环境不支持写缓存文件引起的问题
## 3.0.1(2024-05-08)
- 修复 解决在低版本 Node.js 环境中不支持可选链的问题
## 3.0.0(2024-05-06)
【重要】更新整体架构,支持子插件
## 2.0.11(2023-06-12)
......
{
"id": "uni-im",
"displayName": "uni-im",
"version": "3.0.0",
"version": "3.0.2",
"description": "uni-im是云端一体的、全平台的、免费的、开源即时通讯系统",
"keywords": [
"im,即时通讯,客服,聊天"
......
......@@ -67,6 +67,7 @@
const fs = require('fs');
const path = require('path');
const REGISTER_EXT_CACHE = './_registered_ext.js'
let isFsWritable = false
function getSubdirs(parent) {
try {
......@@ -166,10 +167,14 @@ function loadExtensions() {
requires.push(`const e_${extSeq} = require('${modDir.replace(/\\/g, '/')}');`)
extSeq ++
}
// 把扫描到的扩展模块写入缓存文件
if (isFsWritable) {
moduleExports = Object.keys(moduleExports).map(exp => {
return `"${exp}": [${moduleExports[exp].join(', ')}]`
}).join(',\n')
try {
// 输出缓存文件
let registeredExtCache = `
${requires.join('\n')}
......@@ -178,6 +183,10 @@ ${moduleExports}
}
`
fs.writeFileSync(path.join(__dirname, REGISTER_EXT_CACHE), registeredExtCache)
} catch (e) {
// 无法写缓存文件?
}
}
return registeredExtensionPoints
}
......@@ -191,12 +200,19 @@ let _registeredExtensionPointsPromise
* @returns {any[]} 该扩展点上挂接的所有扩展程序各自的返回值拼装在一个数组里。
*/
async function invokeExts(extensionPointName, ...args) {
isFsWritable = (this.getCloudInfo().provider === 'aliyun')
// 尝试从生成的缓存文件中加载
let registeredExtensionPoints = {}
let registeredExtensionPoints
if (isFsWritable) {
try {
registeredExtensionPoints = require(REGISTER_EXT_CACHE)
} catch (e) {
// 尚无缓存
// 尚未生成缓存文件
}
}
if (!registeredExtensionPoints) {
// 懒加载,避免在调用接口重入时重复解析扩展模块
if (!_registeredExtensionPointsPromise) {
_registeredExtensionPointsPromise = new Promise(resolve => {
......@@ -207,6 +223,7 @@ async function invokeExts(extensionPointName, ...args) {
}
// console.log('invokeExts:', Object.keys(registeredExtensionPoints), extensionPointName, args)
// 找到指定的扩展点并调用
if (!registeredExtensionPoints[extensionPointName]) return []
return Promise.all(
registeredExtensionPoints[extensionPointName]
......
......@@ -460,7 +460,7 @@ async function _createOrUpdateConversation(conversation_id, msgData, chat_source
})
.get()
// console.error('createOrUpdateConversation receiver~~~~~', receiver);
if(receiver && receiver.role?.includes('staff')){
if(receiver && receiver.role && receiver.role.includes('staff')){
// console.error('createOrUpdateConversation receiver.staff~~~~~');
check = true
}
......