vue(版本2.xx) + 环信web sdk(版本1.8.3)
2021-02-01 20:14
标签:文本 用户 dimens 类型 对话 ons sdk loading https 1.准备工作 npm引入sdk及 strophe.js(坑:刚开始下载的最新版的sdk,但是下载下来总是少文件src,挣扎半天,换了1.8.3版本的sdk好了,可能跟我项目的哪些东西的版本有不兼容的吧) (1)cnpm i easemob-websdk@1.8.3 --save (2)cnpm i strophe.js@1.2.16 --save (3)下载webim.config.js: https://gitee.com/weimingye/web-im/blob/master/demo/javascript/dist/webim.config.js# 2.修改sdk的connection.js文件(注意新增代码的位置,放在11行声明变量的后边) 代码: 3.修改strophe.js 代码: 4.修改webim.config.js(首行、最后一行,把自己公司的appkey换上去) 5.main.js新增配置 6.聊天中的表情编码对应文件 emoji.js index.js(暂时未用到) 7.图片文件存放在static文件夹下,图片大致都差不多,网上应该可以查到 8.表情组件 8.页面中使用 vue(版本2.xx) + 环信web sdk(版本1.8.3) 标签:文本 用户 dimens 类型 对话 ons sdk loading https 原文地址:https://www.cnblogs.com/duanzhenzhen/p/13151139.html//新增代码***********start
var Strophe = require(‘../../strophe.js/dist/strophe.js‘).Strophe;
var meStrophe = require(‘../../strophe.js/dist/strophe.js‘);
$iq = meStrophe.$iq;
$build = meStrophe.$build;
$msg = meStrophe.$msg;
$pres = meStrophe.$pres;
//新增代码***********end
//新增代码***********start
setJid: function (jid) {
this.jid = jid;
this.authzid = Strophe.getBareJidFromJid(this.jid);
this.authcid = Strophe.getNodeFromJid(this.jid);
},
getJid: function () {
return this.jid;
},
//新增代码***********end
//环信start
require(‘./assets/webim.config.js‘)
let WebIM = require(‘easemob-websdk‘)
Vue.prototype.$webim = WebIM
const conn = new WebIM.connection({
isMultiLoginSessions: WebIM.config.isMultiLoginSessions,
https: typeof WebIM.config.https === ‘boolean‘ ? WebIM.config.https : location.protocol === ‘https:‘,
url: WebIM.config.xmppURL,
heartBeatWait: WebIM.config.heartBeatWait,
autoReconnectNumMax: WebIM.config.autoReconnectNumMax,
autoReconnectInterval: WebIM.config.autoReconnectInterval,
apiUrl: WebIM.config.apiURL,
isAutoLogin: true
})
const options = {
apiUrl: WebIM.config.apiURL,
user: ‘‘,//用户名
pwd: ‘‘,//密码
appKey: WebIM.config.appkey,
success:function (res) {
console.log(‘链接服务器正常‘)
},
error:function (err) {
alert(err)
}
}
Vue.prototype.$imconn = conn
Vue.prototype.$imoption = options
//环信end
module.exports = {
path: "../../static/faces",
obj: {
"[):]": "ee_1.png",
"[:D]": "ee_2.png",
"[;)]": "ee_3.png",
"[:-o]": "ee_4.png",
"[:p]": "ee_5.png",
"[(H)]": "ee_6.png",
"[:@]": "ee_7.png",
"[:s]": "ee_8.png",
"[:$]": "ee_9.png",
"[:(]": "ee_10.png",
"[:‘(]": "ee_11.png",
"[:|]": "ee_18.png",
"[(a)]": "ee_13.png",
"[8o|]": "ee_14.png",
"[8-|]": "ee_15.png",
"[+o(]": "ee_16.png",
"[
const _WIDTH = window.screen.availWidth > 350 ? 350 : window.screen.availWidth;
export default {
// whether auto check media query and dispatch by redux or not ?
reduxMatchMedia: true,
// map of media query breakpoints
dimensionMap: {
xs: "480px",
sm: "768px",
md: "992px",
lg: "1200px",
xl: "1600px"
},
name: "Web IM",
logo: "",
SIDER_COL_BREAK: "sm", // md
SIDER_COL_WIDTH: 80,
SIDER_WIDTH: 350,
RIGHT_SIDER_WIDTH: _WIDTH,
// imgType: {
// gif: 1,
// bmp: 1,
// jpg: 1,
// png: 1,
// },
PAGE_NUM: 20
};
上一篇:Web服务器相关
下一篇:http权威指南总结
文章标题:vue(版本2.xx) + 环信web sdk(版本1.8.3)
文章链接:http://soscw.com/index.php/essay/49640.html