优化草稿功能

This commit is contained in:
范君
2021-02-03 16:02:27 +08:00
parent 1263ed20a3
commit 0f3edc6925
8 changed files with 157 additions and 190 deletions
+51 -83
View File
@@ -2544,9 +2544,6 @@ function _toConsumableArray(arr) {
// EXTERNAL MODULE: ./node_modules/_core-js@2.6.12@core-js/modules/es6.string.starts-with.js // EXTERNAL MODULE: ./node_modules/_core-js@2.6.12@core-js/modules/es6.string.starts-with.js
var es6_string_starts_with = __webpack_require__("d31c"); var es6_string_starts_with = __webpack_require__("d31c");
// EXTERNAL MODULE: ./node_modules/_core-js@2.6.12@core-js/modules/es6.object.assign.js
var es6_object_assign = __webpack_require__("6ba0");
// EXTERNAL MODULE: ./node_modules/_core-js@2.6.12@core-js/modules/es6.array.sort.js // EXTERNAL MODULE: ./node_modules/_core-js@2.6.12@core-js/modules/es6.array.sort.js
var es6_array_sort = __webpack_require__("3441"); var es6_array_sort = __webpack_require__("3441");
@@ -2669,8 +2666,6 @@ var memory_MemoryCache = /*#__PURE__*/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_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(Object(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(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } 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(Object(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(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
@@ -3318,6 +3313,41 @@ var renderDrawerContent = function renderDrawerContent() {};
this.$refs.messages.scrollToBottom(); this.$refs.messages.scrollToBottom();
}, },
/**
* 设置联系人的草稿信息
*/
setDraft: function setDraft(contactId, editorValue) {
if (isEmpty(contactId) || isEmpty(editorValue)) return false;
var contact = this.findContact(contactId);
if (isEmpty(contact)) return false;
this.CacheDraft.set(contactId, {
editorValue: editorValue,
lastContent: contact.lastContent
});
this.updateContact({
id: contactId,
lastContent: "<span style=\"color:red;\">[\u8349\u7A3F]</span><span>".concat(this.lastContentRender({
type: "text",
content: editorValue
}), "</span>")
});
},
/**
* 清空联系人草稿信息
*/
clearDraft: function clearDraft(contactId) {
var draft = this.CacheDraft.get(contactId);
if (draft) {
this.updateContact({
id: contactId,
lastContent: draft.lastContent
});
this.CacheDraft.remove(contactId);
}
},
/** /**
* 改变聊天对象 * 改变聊天对象
* @param contactId 联系人 id * @param contactId 联系人 id
@@ -3326,7 +3356,7 @@ var renderDrawerContent = function renderDrawerContent() {};
var _changeContact = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(contactId, menuName) { var _changeContact = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(contactId, menuName) {
var _this13 = this; var _this13 = this;
var prevCurrentContactId, editorValue, draft; var editorValue, draft;
return regeneratorRuntime.wrap(function _callee2$(_context2) { return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) { while (1) {
switch (_context2.prev = _context2.next) { switch (_context2.prev = _context2.next) {
@@ -3349,47 +3379,41 @@ var renderDrawerContent = function renderDrawerContent() {};
return _context2.abrupt("return", false); return _context2.abrupt("return", false);
case 6: case 6:
prevCurrentContactId = this.currentContactId; //保存上个聊天目标的草稿 //保存上个聊天目标的草稿
if (this.currentContactId) {
if (prevCurrentContactId) {
editorValue = this.getEditorValue(); editorValue = this.getEditorValue();
if (editorValue) { if (editorValue) {
this.CacheDraft.set(prevCurrentContactId, editorValue); this.setDraft(this.currentContactId, editorValue);
this.updateContact({ this.setEditorValue();
id: prevCurrentContactId, } else {
lastContent: "<span style=\"color:red;\">[\u8349\u7A3F]</span><span>".concat(this.lastContentRender({ this.clearDraft(this.currentContactId);
type: "text",
content: editorValue
}), "</span>")
});
this.setEditorValue("");
} }
} }
this.currentContactId = contactId; this.currentContactId = contactId;
if (this.currentContactId) { if (this.currentContactId) {
_context2.next = 11; _context2.next = 10;
break; break;
} }
return _context2.abrupt("return", false); return _context2.abrupt("return", false);
case 11: case 10:
this.$emit("change-contact", this.currentContact, this); this.$emit("change-contact", this.currentContact, this);
if (!isFunction(this.currentContact.renderContainer)) { if (!isFunction(this.currentContact.renderContainer)) {
_context2.next = 14; _context2.next = 13;
break; break;
} }
return _context2.abrupt("return"); return _context2.abrupt("return");
case 14: case 13:
//填充草稿内容 //填充草稿内容
draft = this.CacheDraft.get(contactId) || ""; draft = this.CacheDraft.get(contactId);
if (draft) this.setEditorValue(draft); if (draft) this.setEditorValue(draft.editorValue);
if (this.CacheMessageLoaded.has(contactId)) { if (this.CacheMessageLoaded.has(contactId)) {
this.$refs.messages.loaded(); this.$refs.messages.loaded();
@@ -3411,7 +3435,7 @@ var renderDrawerContent = function renderDrawerContent() {};
}, 0); }, 0);
} }
case 18: case 17:
case "end": case "end":
return _context2.stop(); return _context2.stop();
} }
@@ -3697,7 +3721,8 @@ var renderDrawerContent = function renderDrawerContent() {};
getCurrentMessages: function getCurrentMessages() { getCurrentMessages: function getCurrentMessages() {
return this.currentMessages; return this.currentMessages;
}, },
setEditorValue: function setEditorValue(val) { setEditorValue: function setEditorValue() {
var val = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
if (!isString(val)) return false; if (!isString(val)) return false;
this.$refs.editor.setValue(this.emojiNameToImage(val)); this.$refs.editor.setValue(this.emojiNameToImage(val));
}, },
@@ -5467,17 +5492,6 @@ try {
} }
/***/ }),
/***/ "6ba0":
/***/ (function(module, exports, __webpack_require__) {
// 19.1.3.1 Object.assign(target, source)
var $export = __webpack_require__("e99b");
$export($export.S + $export.F, 'Object', { assign: __webpack_require__("9f15") });
/***/ }), /***/ }),
/***/ "6bf8": /***/ "6bf8":
@@ -5924,52 +5938,6 @@ module.exports = function (it) {
}; };
/***/ }),
/***/ "9f15":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// 19.1.2.1 Object.assign(target, source, ...)
var DESCRIPTORS = __webpack_require__("26df");
var getKeys = __webpack_require__("93ca");
var gOPS = __webpack_require__("0c29");
var pIE = __webpack_require__("35d4");
var toObject = __webpack_require__("8078");
var IObject = __webpack_require__("1b96");
var $assign = Object.assign;
// should work with symbols and should have deterministic property order (V8 bug)
module.exports = !$assign || __webpack_require__("0926")(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;
/***/ }), /***/ }),
/***/ "a450": /***/ "a450":
+51 -83
View File
@@ -2553,9 +2553,6 @@ function _toConsumableArray(arr) {
// EXTERNAL MODULE: ./node_modules/_core-js@2.6.12@core-js/modules/es6.string.starts-with.js // EXTERNAL MODULE: ./node_modules/_core-js@2.6.12@core-js/modules/es6.string.starts-with.js
var es6_string_starts_with = __webpack_require__("d31c"); var es6_string_starts_with = __webpack_require__("d31c");
// EXTERNAL MODULE: ./node_modules/_core-js@2.6.12@core-js/modules/es6.object.assign.js
var es6_object_assign = __webpack_require__("6ba0");
// EXTERNAL MODULE: ./node_modules/_core-js@2.6.12@core-js/modules/es6.array.sort.js // EXTERNAL MODULE: ./node_modules/_core-js@2.6.12@core-js/modules/es6.array.sort.js
var es6_array_sort = __webpack_require__("3441"); var es6_array_sort = __webpack_require__("3441");
@@ -2678,8 +2675,6 @@ var memory_MemoryCache = /*#__PURE__*/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_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(Object(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(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } 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(Object(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(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
@@ -3327,6 +3322,41 @@ var renderDrawerContent = function renderDrawerContent() {};
this.$refs.messages.scrollToBottom(); this.$refs.messages.scrollToBottom();
}, },
/**
* 设置联系人的草稿信息
*/
setDraft: function setDraft(contactId, editorValue) {
if (isEmpty(contactId) || isEmpty(editorValue)) return false;
var contact = this.findContact(contactId);
if (isEmpty(contact)) return false;
this.CacheDraft.set(contactId, {
editorValue: editorValue,
lastContent: contact.lastContent
});
this.updateContact({
id: contactId,
lastContent: "<span style=\"color:red;\">[\u8349\u7A3F]</span><span>".concat(this.lastContentRender({
type: "text",
content: editorValue
}), "</span>")
});
},
/**
* 清空联系人草稿信息
*/
clearDraft: function clearDraft(contactId) {
var draft = this.CacheDraft.get(contactId);
if (draft) {
this.updateContact({
id: contactId,
lastContent: draft.lastContent
});
this.CacheDraft.remove(contactId);
}
},
/** /**
* 改变聊天对象 * 改变聊天对象
* @param contactId 联系人 id * @param contactId 联系人 id
@@ -3335,7 +3365,7 @@ var renderDrawerContent = function renderDrawerContent() {};
var _changeContact = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(contactId, menuName) { var _changeContact = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(contactId, menuName) {
var _this13 = this; var _this13 = this;
var prevCurrentContactId, editorValue, draft; var editorValue, draft;
return regeneratorRuntime.wrap(function _callee2$(_context2) { return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) { while (1) {
switch (_context2.prev = _context2.next) { switch (_context2.prev = _context2.next) {
@@ -3358,47 +3388,41 @@ var renderDrawerContent = function renderDrawerContent() {};
return _context2.abrupt("return", false); return _context2.abrupt("return", false);
case 6: case 6:
prevCurrentContactId = this.currentContactId; //保存上个聊天目标的草稿 //保存上个聊天目标的草稿
if (this.currentContactId) {
if (prevCurrentContactId) {
editorValue = this.getEditorValue(); editorValue = this.getEditorValue();
if (editorValue) { if (editorValue) {
this.CacheDraft.set(prevCurrentContactId, editorValue); this.setDraft(this.currentContactId, editorValue);
this.updateContact({ this.setEditorValue();
id: prevCurrentContactId, } else {
lastContent: "<span style=\"color:red;\">[\u8349\u7A3F]</span><span>".concat(this.lastContentRender({ this.clearDraft(this.currentContactId);
type: "text",
content: editorValue
}), "</span>")
});
this.setEditorValue("");
} }
} }
this.currentContactId = contactId; this.currentContactId = contactId;
if (this.currentContactId) { if (this.currentContactId) {
_context2.next = 11; _context2.next = 10;
break; break;
} }
return _context2.abrupt("return", false); return _context2.abrupt("return", false);
case 11: case 10:
this.$emit("change-contact", this.currentContact, this); this.$emit("change-contact", this.currentContact, this);
if (!isFunction(this.currentContact.renderContainer)) { if (!isFunction(this.currentContact.renderContainer)) {
_context2.next = 14; _context2.next = 13;
break; break;
} }
return _context2.abrupt("return"); return _context2.abrupt("return");
case 14: case 13:
//填充草稿内容 //填充草稿内容
draft = this.CacheDraft.get(contactId) || ""; draft = this.CacheDraft.get(contactId);
if (draft) this.setEditorValue(draft); if (draft) this.setEditorValue(draft.editorValue);
if (this.CacheMessageLoaded.has(contactId)) { if (this.CacheMessageLoaded.has(contactId)) {
this.$refs.messages.loaded(); this.$refs.messages.loaded();
@@ -3420,7 +3444,7 @@ var renderDrawerContent = function renderDrawerContent() {};
}, 0); }, 0);
} }
case 18: case 17:
case "end": case "end":
return _context2.stop(); return _context2.stop();
} }
@@ -3706,7 +3730,8 @@ var renderDrawerContent = function renderDrawerContent() {};
getCurrentMessages: function getCurrentMessages() { getCurrentMessages: function getCurrentMessages() {
return this.currentMessages; return this.currentMessages;
}, },
setEditorValue: function setEditorValue(val) { setEditorValue: function setEditorValue() {
var val = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
if (!isString(val)) return false; if (!isString(val)) return false;
this.$refs.editor.setValue(this.emojiNameToImage(val)); this.$refs.editor.setValue(this.emojiNameToImage(val));
}, },
@@ -5476,17 +5501,6 @@ try {
} }
/***/ }),
/***/ "6ba0":
/***/ (function(module, exports, __webpack_require__) {
// 19.1.3.1 Object.assign(target, source)
var $export = __webpack_require__("e99b");
$export($export.S + $export.F, 'Object', { assign: __webpack_require__("9f15") });
/***/ }), /***/ }),
/***/ "6bf8": /***/ "6bf8":
@@ -5933,52 +5947,6 @@ module.exports = function (it) {
}; };
/***/ }),
/***/ "9f15":
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// 19.1.2.1 Object.assign(target, source, ...)
var DESCRIPTORS = __webpack_require__("26df");
var getKeys = __webpack_require__("93ca");
var gOPS = __webpack_require__("0c29");
var pIE = __webpack_require__("35d4");
var toObject = __webpack_require__("8078");
var IObject = __webpack_require__("1b96");
var $assign = Object.assign;
// should work with symbols and should have deterministic property order (V8 bug)
module.exports = !$assign || __webpack_require__("0926")(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;
/***/ }), /***/ }),
/***/ "a450": /***/ "a450":
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -6
View File
@@ -1205,11 +1205,6 @@ export default {
}; };
}, },
mounted() { mounted() {
const contactData1 = { const contactData1 = {
id: "contact-1", id: "contact-1",
displayName: "工作协作群", displayName: "工作协作群",
@@ -1266,7 +1261,7 @@ export default {
let contactList = [ let contactList = [
{ ...contactData1 }, { ...contactData1 },
{ ...contactData2 }, { ...contactData2 },
{ ...contactData3 }, { ...contactData3 }
//...Array(100).fill(contactData1) //...Array(100).fill(contactData1)
]; ];
+1 -1
View File
@@ -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.e91d4c69.css rel=preload as=style><link href=js/chunk-vendors.2abee366.js rel=preload as=script><link href=js/index.67dbfb3d.js rel=preload as=script><link href=css/index.e91d4c69.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.2abee366.js></script><script src=js/index.67dbfb3d.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.e91d4c69.css rel=preload as=style><link href=js/chunk-vendors.2abee366.js rel=preload as=script><link href=js/index.6db35f89.js rel=preload as=script><link href=css/index.e91d4c69.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.2abee366.js></script><script src=js/index.6db35f89.js></script></body></html>
File diff suppressed because one or more lines are too long
+11 -2
View File
@@ -1,9 +1,18 @@
{ {
"name": "lemon-imui", "name": "lemon-imui",
"version": "1.6.5", "version": "1.6.6",
"main": "dist/index.umd.min.js", "main": "dist/index.umd.min.js",
"description": "基于 VUE2.0 的 IM 聊天组件", "description": "基于 VUE2.0 的 IM 聊天组件",
"homepage": "https://github.com/fanjyy/lemon-imui", "homepage": "http://june000.gitee.io/lemon-im/",
"keywords": [
"vue",
"im",
"chat",
"vueim",
"vuechat",
"webim",
"webchat"
],
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/fanjyy/lemon-imui.git" "url": "git+https://github.com/fanjyy/lemon-imui.git"
+40 -13
View File
@@ -587,6 +587,37 @@ export default {
messageViewToBottom() { messageViewToBottom() {
this.$refs.messages.scrollToBottom(); this.$refs.messages.scrollToBottom();
}, },
/**
* 设置联系人的草稿信息
*/
setDraft(contactId, editorValue) {
if (isEmpty(contactId) || isEmpty(editorValue)) return false;
const contact = this.findContact(contactId);
if (isEmpty(contact)) return false;
this.CacheDraft.set(contactId, {
editorValue: editorValue,
lastContent: contact.lastContent
});
this.updateContact({
id: contactId,
lastContent: `<span style="color:red;">[草稿]</span><span>${this.lastContentRender(
{ type: "text", content: editorValue }
)}</span>`
});
},
/**
* 清空联系人草稿信息
*/
clearDraft(contactId) {
const draft = this.CacheDraft.get(contactId);
if (draft) {
this.updateContact({
id: contactId,
lastContent: draft.lastContent
});
this.CacheDraft.remove(contactId);
}
},
/** /**
* 改变聊天对象 * 改变聊天对象
* @param contactId 联系人 id * @param contactId 联系人 id
@@ -598,19 +629,15 @@ export default {
if (this._changeContactLock || this.currentContactId == contactId) if (this._changeContactLock || this.currentContactId == contactId)
return false; return false;
} }
const prevCurrentContactId = this.currentContactId;
//保存上个聊天目标的草稿 //保存上个聊天目标的草稿
if (prevCurrentContactId) { if (this.currentContactId) {
const editorValue = this.getEditorValue(); const editorValue = this.getEditorValue();
if (editorValue) { if (editorValue) {
this.CacheDraft.set(prevCurrentContactId, editorValue); this.setDraft(this.currentContactId, editorValue);
this.updateContact({ this.setEditorValue();
id: prevCurrentContactId, } else {
lastContent: `<span style="color:red;">[草稿]</span><span>${this.lastContentRender( this.clearDraft(this.currentContactId);
{ type: "text", content: editorValue }
)}</span>`
});
this.setEditorValue("");
} }
} }
@@ -622,8 +649,8 @@ export default {
return; return;
} }
//填充草稿内容 //填充草稿内容
const draft = this.CacheDraft.get(contactId) || ""; const draft = this.CacheDraft.get(contactId);
if (draft) this.setEditorValue(draft); if (draft) this.setEditorValue(draft.editorValue);
if (this.CacheMessageLoaded.has(contactId)) { if (this.CacheMessageLoaded.has(contactId)) {
this.$refs.messages.loaded(); this.$refs.messages.loaded();
@@ -890,7 +917,7 @@ export default {
getCurrentMessages() { getCurrentMessages() {
return this.currentMessages; return this.currentMessages;
}, },
setEditorValue(val) { setEditorValue(val = "") {
if (!isString(val)) return false; if (!isString(val)) return false;
this.$refs.editor.setValue(this.emojiNameToImage(val)); this.$refs.editor.setValue(this.emojiNameToImage(val));
}, },