...
 
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) ## 3.0.0(2024-05-06)
【重要】更新整体架构,支持子插件 【重要】更新整体架构,支持子插件
## 2.0.11(2023-06-12) ## 2.0.11(2023-06-12)
......
{ {
"id": "uni-im", "id": "uni-im",
"displayName": "uni-im", "displayName": "uni-im",
"version": "3.0.0", "version": "3.0.2",
"description": "uni-im是云端一体的、全平台的、免费的、开源即时通讯系统", "description": "uni-im是云端一体的、全平台的、免费的、开源即时通讯系统",
"keywords": [ "keywords": [
"im,即时通讯,客服,聊天" "im,即时通讯,客服,聊天"
......
...@@ -67,6 +67,7 @@ ...@@ -67,6 +67,7 @@
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
const REGISTER_EXT_CACHE = './_registered_ext.js' const REGISTER_EXT_CACHE = './_registered_ext.js'
let isFsWritable = false
function getSubdirs(parent) { function getSubdirs(parent) {
try { try {
...@@ -166,18 +167,26 @@ function loadExtensions() { ...@@ -166,18 +167,26 @@ function loadExtensions() {
requires.push(`const e_${extSeq} = require('${modDir.replace(/\\/g, '/')}');`) requires.push(`const e_${extSeq} = require('${modDir.replace(/\\/g, '/')}');`)
extSeq ++ extSeq ++
} }
moduleExports = Object.keys(moduleExports).map(exp => {
return `"${exp}": [${moduleExports[exp].join(', ')}]`
}).join(',\n')
// 输出缓存文件 // 把扫描到的扩展模块写入缓存文件
let registeredExtCache = ` if (isFsWritable) {
moduleExports = Object.keys(moduleExports).map(exp => {
return `"${exp}": [${moduleExports[exp].join(', ')}]`
}).join(',\n')
try {
// 输出缓存文件
let registeredExtCache = `
${requires.join('\n')} ${requires.join('\n')}
module.exports = { module.exports = {
${moduleExports} ${moduleExports}
} }
` `
fs.writeFileSync(path.join(__dirname, REGISTER_EXT_CACHE), registeredExtCache) fs.writeFileSync(path.join(__dirname, REGISTER_EXT_CACHE), registeredExtCache)
} catch (e) {
// 无法写缓存文件?
}
}
return registeredExtensionPoints return registeredExtensionPoints
} }
...@@ -191,12 +200,19 @@ let _registeredExtensionPointsPromise ...@@ -191,12 +200,19 @@ let _registeredExtensionPointsPromise
* @returns {any[]} 该扩展点上挂接的所有扩展程序各自的返回值拼装在一个数组里。 * @returns {any[]} 该扩展点上挂接的所有扩展程序各自的返回值拼装在一个数组里。
*/ */
async function invokeExts(extensionPointName, ...args) { async function invokeExts(extensionPointName, ...args) {
isFsWritable = (this.getCloudInfo().provider === 'aliyun')
// 尝试从生成的缓存文件中加载 // 尝试从生成的缓存文件中加载
let registeredExtensionPoints = {} let registeredExtensionPoints
try { if (isFsWritable) {
registeredExtensionPoints = require(REGISTER_EXT_CACHE) try {
} catch (e) { registeredExtensionPoints = require(REGISTER_EXT_CACHE)
// 尚无缓存 } catch (e) {
// 尚未生成缓存文件
}
}
if (!registeredExtensionPoints) {
// 懒加载,避免在调用接口重入时重复解析扩展模块 // 懒加载,避免在调用接口重入时重复解析扩展模块
if (!_registeredExtensionPointsPromise) { if (!_registeredExtensionPointsPromise) {
_registeredExtensionPointsPromise = new Promise(resolve => { _registeredExtensionPointsPromise = new Promise(resolve => {
...@@ -207,6 +223,7 @@ async function invokeExts(extensionPointName, ...args) { ...@@ -207,6 +223,7 @@ async function invokeExts(extensionPointName, ...args) {
} }
// console.log('invokeExts:', Object.keys(registeredExtensionPoints), extensionPointName, args) // console.log('invokeExts:', Object.keys(registeredExtensionPoints), extensionPointName, args)
// 找到指定的扩展点并调用
if (!registeredExtensionPoints[extensionPointName]) return [] if (!registeredExtensionPoints[extensionPointName]) return []
return Promise.all( return Promise.all(
registeredExtensionPoints[extensionPointName] registeredExtensionPoints[extensionPointName]
......
...@@ -460,7 +460,7 @@ async function _createOrUpdateConversation(conversation_id, msgData, chat_source ...@@ -460,7 +460,7 @@ async function _createOrUpdateConversation(conversation_id, msgData, chat_source
}) })
.get() .get()
// console.error('createOrUpdateConversation receiver~~~~~', receiver); // console.error('createOrUpdateConversation receiver~~~~~', receiver);
if(receiver && receiver.role?.includes('staff')){ if(receiver && receiver.role && receiver.role.includes('staff')){
// console.error('createOrUpdateConversation receiver.staff~~~~~'); // console.error('createOrUpdateConversation receiver.staff~~~~~');
check = true check = true
} }
......