1.20.1 • Published 8 months ago

@stbzmi/imsdk v1.20.1

Weekly downloads
-
License
-
Repository
-
Last release
8 months ago

运行

npm run dev #运行开发服务器,项目入口 example
#暂无build sdk
npm run build #仅打包模块,不打包依赖
npm run build:all_dep #打包并且将依赖打包进去

npm package name

项目相关

  • 添加模块请加入 peerDependencies or devDependencies , 尽可能不加入 dependencies

文档

文件结构

  • example 例子
  • sdkAssets sdk受用不同项目,资源通过npm scripts切换。不同资源放置不同位置
  • src
    • api 接口代码
    • assets 资源文件
    • common 各平台通用,满足ECMA-262 2015+环境即可,跟SDK相关逻辑
      • log.ts
      • exception.ts 抛出异常
    • components 视图组件
    • context instance上下文
      • db
        • operator 提供dao所需要的数据库表的读写能力,操作适配层
        • dao 对接数据库表访问,提供持久化能力
      • net socket请求实例
      • store 视图状态层
    • platform 平台相关
      • node NodeJs平台代码
      • browser Browser平台代码
    • services 对应不同表的不同行为
    • types 一些公共类型
    • utils 工具函数,和common不同的是提供存粹的js工具函数
    • IMSDK.ts 暴露类

开发事项

持久化数据

./src/utils/fileSystem/index.ts

提供了前端文件读写的能力,文件目录下README提供了使用例子。支持流式API读写。数据落地到idb。优点不需要区分环境。缓存随着清理消失。缺点相较于系统读写慢,可做日志存储,缓存存储。

如何输出日志

//实例logger到需要打印的类中
//例如
Context.loggerService = new LoggerService()

//...code
try{
  throw new ApiException({xxx})
} catch (exception) {
  Context.loggerService.error(exception.message)
}

//全局日志
IMSDK.logger.xxx() 

如何抛出错误

import {ApiException,/* ...more exception */} from '@/common/exception'

throw new ApiException({})

worker运行某部分功能

import {WorkerEx} from '@/utils'
function add(a: any, b: any): number {
  return a + b;
}
const worker = new WorkerEx(
  (a, b) => {
    return add(a, b);
  },
  { add: add }
);
worker.init();
const result = await worker.run(1, 2);
console.log("main :", result);

业务层ID转换到SDK ID

业务层ID为A开头的对应ID

import {ChatId} from '@/common/id'

//所有的id转换都在id下
ChatId.create(message.achatId)

销毁器

  • 规范销毁方式
const disposer = new Disposer();
disposer.add(()=>{console.log('dispose xxx')})


disposer.dispose()

开发组件

  • 参考 example/route.tsx
  • 新增 route, 添加自己的组件即可,隔离上下文只用来开发视图
1.2.0

8 months ago

1.2.1

8 months ago

1.20.1

8 months ago

1.10.46

1 year ago

1.10.45

1 year ago

1.10.44

1 year ago

1.10.43

1 year ago

1.10.42

1 year ago

1.10.41

1 year ago

1.10.40

1 year ago

1.10.38

1 year ago

1.10.36

1 year ago

1.0.1

2 years ago

1.0.0

2 years ago