1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- import TIM from 'tim-js-sdk'
- // 发送图片、文件等消息需要的 COS SDK
- import COS from "cos-js-sdk-v5"
- import config from '../config.js'
- let options = {
- SDKAppID: config.sdkAppId // 即时通信应用的 SDKAppID
- };
- // 创建 SDK 实例,TIM.create() 方法对于同一个 SDKAppID 只会返回同一份实例
- const tim = TIM.create(options); // SDK 实例通常用 tim 表示
- const TIMData = TIM
- // 注册 COS SDK 插件
- tim.registerPlugin({
- 'cos-js-sdk': COS
- });
- function genTestUserSig(userID) {
- const SDKAPPID = config.sdkAppId;
- const EXPIRETIME = 604800;
- const SECRETKEY = config.secretKey;
- if (SDKAPPID === '' || SECRETKEY === '') {
- alert(
- '请先配置好您的账号信息: SDKAPPID 及 SECRETKEY ' +
- '\r\n\r\nPlease configure your SDKAPPID/SECRETKEY in js/debug/GenerateTestUserSig.js'
- );
- }
- const generator = new LibGenerateTestUserSig(SDKAPPID, SECRETKEY, EXPIRETIME);
- const userSig = generator.genTestUserSig(userID);
- return {
- sdkAppId: SDKAPPID,
- userSig: userSig
- };
- }
- export default {
- tim,
- TIMData,
- genTestUserSig
- }
|