修改appendMessage逻辑,可以给任意联系人发送消息
This commit is contained in:
Vendored
+82
-7
@@ -2826,6 +2826,52 @@ module.exports = function (TO_STRING) {
|
||||
};
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "7333":
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// 19.1.2.1 Object.assign(target, source, ...)
|
||||
var DESCRIPTORS = __webpack_require__("9e1e");
|
||||
var getKeys = __webpack_require__("0d58");
|
||||
var gOPS = __webpack_require__("2621");
|
||||
var pIE = __webpack_require__("52a7");
|
||||
var toObject = __webpack_require__("4bf8");
|
||||
var IObject = __webpack_require__("626a");
|
||||
var $assign = Object.assign;
|
||||
|
||||
// should work with symbols and should have deterministic property order (V8 bug)
|
||||
module.exports = !$assign || __webpack_require__("79e5")(function () {
|
||||
var A = {};
|
||||
var B = {};
|
||||
// eslint-disable-next-line no-undef
|
||||
var S = Symbol();
|
||||
var K = 'abcdefghijklmnopqrst';
|
||||
A[S] = 7;
|
||||
K.split('').forEach(function (k) { B[k] = k; });
|
||||
return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
|
||||
}) ? function assign(target, source) { // eslint-disable-line no-unused-vars
|
||||
var T = toObject(target);
|
||||
var aLen = arguments.length;
|
||||
var index = 1;
|
||||
var getSymbols = gOPS.f;
|
||||
var isEnum = pIE.f;
|
||||
while (aLen > index) {
|
||||
var S = IObject(arguments[index++]);
|
||||
var keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S);
|
||||
var length = keys.length;
|
||||
var j = 0;
|
||||
var key;
|
||||
while (length > j) {
|
||||
key = keys[j++];
|
||||
if (!DESCRIPTORS || isEnum.call(S, key)) T[key] = S[key];
|
||||
}
|
||||
} return T;
|
||||
} : $assign;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "7514":
|
||||
@@ -5286,6 +5332,17 @@ $export($export.P + $export.F * __webpack_require__("5147")(STARTS_WITH), 'Strin
|
||||
})(document);
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "f751":
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
// 19.1.3.1 Object.assign(target, source)
|
||||
var $export = __webpack_require__("5ca1");
|
||||
|
||||
$export($export.S + $export.F, 'Object', { assign: __webpack_require__("7333") });
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "f772":
|
||||
@@ -7350,6 +7407,9 @@ function _toConsumableArray(arr) {
|
||||
// EXTERNAL MODULE: ./node_modules/core-js/modules/es6.string.starts-with.js
|
||||
var es6_string_starts_with = __webpack_require__("f559");
|
||||
|
||||
// EXTERNAL MODULE: ./node_modules/core-js/modules/es6.object.assign.js
|
||||
var es6_object_assign = __webpack_require__("f751");
|
||||
|
||||
// EXTERNAL MODULE: ./node_modules/core-js/modules/es6.array.sort.js
|
||||
var es6_array_sort = __webpack_require__("55dd");
|
||||
|
||||
@@ -7473,6 +7533,8 @@ function () {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function componentsvue_type_script_lang_js_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
||||
|
||||
function componentsvue_type_script_lang_js_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { componentsvue_type_script_lang_js_ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { componentsvue_type_script_lang_js_ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
||||
@@ -7655,22 +7717,35 @@ var renderDrawerContent = function renderDrawerContent() {};
|
||||
},
|
||||
|
||||
/**
|
||||
* 在当前聊天窗口新增一条消息
|
||||
* 新增一条消息
|
||||
*/
|
||||
appendMessage: function appendMessage(message) {
|
||||
var scrollToBottom = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
||||
if (!this.currentContactId) return false;
|
||||
|
||||
this._addMessage(message, this.currentContactId, 1);
|
||||
if (componentsvue_type_script_lang_js_messages[message.toContactId] === undefined) {
|
||||
this.updateContact(message.toContactId, {
|
||||
unread: "+1",
|
||||
lastSendTime: message.sendTime,
|
||||
lastContent: this.lastContentRender(message)
|
||||
});
|
||||
} else {
|
||||
this._addMessage(message, message.toContactId, 1);
|
||||
|
||||
var updateContact = {
|
||||
lastContent: this.lastContentRender(message),
|
||||
lastSendTime: message.sendTime
|
||||
};
|
||||
|
||||
if (message.toContactId == this.currentContactId) {
|
||||
if (scrollToBottom == true) {
|
||||
this.messageViewToBottom();
|
||||
}
|
||||
} else {
|
||||
updateContact.unread = '+1';
|
||||
}
|
||||
|
||||
this.updateContact(this.currentContactId, {
|
||||
lastContent: this.lastContentRender(message),
|
||||
lastSendTime: message.sendTime
|
||||
});
|
||||
this.updateContact(message.toContactId, updateContact);
|
||||
}
|
||||
},
|
||||
_emitSend: function _emitSend(message, next, file) {
|
||||
var _this3 = this;
|
||||
|
||||
Vendored
+82
-7
@@ -2835,6 +2835,52 @@ module.exports = function (TO_STRING) {
|
||||
};
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "7333":
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// 19.1.2.1 Object.assign(target, source, ...)
|
||||
var DESCRIPTORS = __webpack_require__("9e1e");
|
||||
var getKeys = __webpack_require__("0d58");
|
||||
var gOPS = __webpack_require__("2621");
|
||||
var pIE = __webpack_require__("52a7");
|
||||
var toObject = __webpack_require__("4bf8");
|
||||
var IObject = __webpack_require__("626a");
|
||||
var $assign = Object.assign;
|
||||
|
||||
// should work with symbols and should have deterministic property order (V8 bug)
|
||||
module.exports = !$assign || __webpack_require__("79e5")(function () {
|
||||
var A = {};
|
||||
var B = {};
|
||||
// eslint-disable-next-line no-undef
|
||||
var S = Symbol();
|
||||
var K = 'abcdefghijklmnopqrst';
|
||||
A[S] = 7;
|
||||
K.split('').forEach(function (k) { B[k] = k; });
|
||||
return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
|
||||
}) ? function assign(target, source) { // eslint-disable-line no-unused-vars
|
||||
var T = toObject(target);
|
||||
var aLen = arguments.length;
|
||||
var index = 1;
|
||||
var getSymbols = gOPS.f;
|
||||
var isEnum = pIE.f;
|
||||
while (aLen > index) {
|
||||
var S = IObject(arguments[index++]);
|
||||
var keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S);
|
||||
var length = keys.length;
|
||||
var j = 0;
|
||||
var key;
|
||||
while (length > j) {
|
||||
key = keys[j++];
|
||||
if (!DESCRIPTORS || isEnum.call(S, key)) T[key] = S[key];
|
||||
}
|
||||
} return T;
|
||||
} : $assign;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "7514":
|
||||
@@ -5295,6 +5341,17 @@ $export($export.P + $export.F * __webpack_require__("5147")(STARTS_WITH), 'Strin
|
||||
})(document);
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "f751":
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
// 19.1.3.1 Object.assign(target, source)
|
||||
var $export = __webpack_require__("5ca1");
|
||||
|
||||
$export($export.S + $export.F, 'Object', { assign: __webpack_require__("7333") });
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "f772":
|
||||
@@ -7359,6 +7416,9 @@ function _toConsumableArray(arr) {
|
||||
// EXTERNAL MODULE: ./node_modules/core-js/modules/es6.string.starts-with.js
|
||||
var es6_string_starts_with = __webpack_require__("f559");
|
||||
|
||||
// EXTERNAL MODULE: ./node_modules/core-js/modules/es6.object.assign.js
|
||||
var es6_object_assign = __webpack_require__("f751");
|
||||
|
||||
// EXTERNAL MODULE: ./node_modules/core-js/modules/es6.array.sort.js
|
||||
var es6_array_sort = __webpack_require__("55dd");
|
||||
|
||||
@@ -7482,6 +7542,8 @@ function () {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function componentsvue_type_script_lang_js_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
||||
|
||||
function componentsvue_type_script_lang_js_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { componentsvue_type_script_lang_js_ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { componentsvue_type_script_lang_js_ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
||||
@@ -7664,22 +7726,35 @@ var renderDrawerContent = function renderDrawerContent() {};
|
||||
},
|
||||
|
||||
/**
|
||||
* 在当前聊天窗口新增一条消息
|
||||
* 新增一条消息
|
||||
*/
|
||||
appendMessage: function appendMessage(message) {
|
||||
var scrollToBottom = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
||||
if (!this.currentContactId) return false;
|
||||
|
||||
this._addMessage(message, this.currentContactId, 1);
|
||||
if (componentsvue_type_script_lang_js_messages[message.toContactId] === undefined) {
|
||||
this.updateContact(message.toContactId, {
|
||||
unread: "+1",
|
||||
lastSendTime: message.sendTime,
|
||||
lastContent: this.lastContentRender(message)
|
||||
});
|
||||
} else {
|
||||
this._addMessage(message, message.toContactId, 1);
|
||||
|
||||
var updateContact = {
|
||||
lastContent: this.lastContentRender(message),
|
||||
lastSendTime: message.sendTime
|
||||
};
|
||||
|
||||
if (message.toContactId == this.currentContactId) {
|
||||
if (scrollToBottom == true) {
|
||||
this.messageViewToBottom();
|
||||
}
|
||||
} else {
|
||||
updateContact.unread = '+1';
|
||||
}
|
||||
|
||||
this.updateContact(this.currentContactId, {
|
||||
lastContent: this.lastContentRender(message),
|
||||
lastSendTime: message.sendTime
|
||||
});
|
||||
this.updateContact(message.toContactId, updateContact);
|
||||
}
|
||||
},
|
||||
_emitSend: function _emitSend(message, next, file) {
|
||||
var _this3 = this;
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+3
-8
@@ -432,7 +432,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td>appendMessage</td>
|
||||
<td>在当前聊天窗口插入一条新消息, scrollToBottom=true 添加之后滚动到消息窗口底部</td>
|
||||
<td>新增一条新消息, 如果当前焦点在该联系人的聊天窗口,设置 scrollToBottom=true 添加之后自动定位到消息窗口底部</td>
|
||||
<td>Function(Message,scrollToBottom=false)</td>
|
||||
<td>-</td>
|
||||
<td></td>
|
||||
@@ -1273,7 +1273,7 @@ export default {
|
||||
content: '语音消息',
|
||||
params1:'1',
|
||||
params2:'2',
|
||||
toContactId:IMUI.currentContactId,
|
||||
toContactId:'contact-1',
|
||||
fromUser:this.user
|
||||
};
|
||||
IMUI.appendMessage(message,true);
|
||||
@@ -1281,17 +1281,12 @@ export default {
|
||||
appendMessage() {
|
||||
const { IMUI } = this.$refs;
|
||||
const contact = IMUI.currentContact;
|
||||
const message = generateMessage();
|
||||
const message = generateMessage('contact-3');
|
||||
message.fromUser = {
|
||||
...message.fromUser,
|
||||
...this.user
|
||||
};
|
||||
IMUI.appendMessage(message,true);
|
||||
IMUI.updateContact(contact.id, {
|
||||
unread: "+1",
|
||||
lastSendTime: getTime(),
|
||||
lastContent: IMUI.lastContentRender(message)
|
||||
});
|
||||
},
|
||||
updateContact() {
|
||||
this.$refs.IMUI.updateContact("contact-3", {
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"><link rel=icon href=favicon.ico><title>Lemon IMUI</title><link href=css/index.ac259e1d.css rel=preload as=style><link href=js/chunk-vendors.e4810482.js rel=preload as=script><link href=js/index.db7a84af.js rel=preload as=script><link href=css/index.ac259e1d.css rel=stylesheet></head><body><noscript><strong>We're sorry but flat-im doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=js/chunk-vendors.e4810482.js></script><script src=js/index.db7a84af.js></script></body></html>
|
||||
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"><link rel=icon href=favicon.ico><title>Lemon IMUI</title><link href=css/index.ac259e1d.css rel=preload as=style><link href=js/chunk-vendors.e4810482.js rel=preload as=script><link href=js/index.a2961444.js rel=preload as=script><link href=css/index.ac259e1d.css rel=stylesheet></head><body><noscript><strong>We're sorry but flat-im doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=js/chunk-vendors.e4810482.js></script><script src=js/index.a2961444.js></script></body></html>
|
||||
Vendored
+1
File diff suppressed because one or more lines are too long
Vendored
-1
File diff suppressed because one or more lines are too long
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "lemon-imui",
|
||||
"version": "1.2.2",
|
||||
"version": "1.2.3",
|
||||
"main": "dist/index.umd.min.js",
|
||||
"description": "基于 VUE2.0 的 IM 聊天组件",
|
||||
"homepage": "https://github.com/fanjyy/lemon-imui",
|
||||
|
||||
@@ -151,18 +151,30 @@ export default {
|
||||
};
|
||||
},
|
||||
/**
|
||||
* 在当前聊天窗口新增一条消息
|
||||
* 新增一条消息
|
||||
*/
|
||||
appendMessage(message,scrollToBottom = false) {
|
||||
if(!this.currentContactId) return false;
|
||||
this._addMessage(message, this.currentContactId, 1);
|
||||
if(messages[message.toContactId] === undefined){
|
||||
this.updateContact(message.toContactId, {
|
||||
unread: "+1",
|
||||
lastSendTime: message.sendTime,
|
||||
lastContent: this.lastContentRender(message)
|
||||
});
|
||||
}else{
|
||||
this._addMessage(message,message.toContactId, 1);
|
||||
const updateContact = {
|
||||
lastContent: this.lastContentRender(message),
|
||||
lastSendTime: message.sendTime
|
||||
}
|
||||
if(message.toContactId == this.currentContactId){
|
||||
if(scrollToBottom == true){
|
||||
this.messageViewToBottom();
|
||||
}
|
||||
this.updateContact(this.currentContactId, {
|
||||
lastContent: this.lastContentRender(message),
|
||||
lastSendTime: message.sendTime
|
||||
});
|
||||
}else{
|
||||
updateContact.unread = '+1';
|
||||
}
|
||||
this.updateContact(message.toContactId,updateContact);
|
||||
}
|
||||
},
|
||||
_emitSend(message, next, file) {
|
||||
this.$emit(
|
||||
|
||||
Reference in New Issue
Block a user