增加removeContact、appendContact
This commit is contained in:
@@ -5,9 +5,8 @@
|
|||||||
#### 特性
|
#### 特性
|
||||||
|
|
||||||
- 拥有丰富的自定义功能,任意搭配出不同风格的聊天界面
|
- 拥有丰富的自定义功能,任意搭配出不同风格的聊天界面
|
||||||
- 可以单独使用内部组件,比如编辑框/按钮/popover 等
|
- 不依赖任何第三方 UI 组件库
|
||||||
- 不依赖任何第三方组件库
|
- 可任意扩展聊天消息类型
|
||||||
- 可任意扩展的聊天消息类型
|
|
||||||
|
|
||||||
#### 安装
|
#### 安装
|
||||||
|
|
||||||
@@ -28,3 +27,5 @@ Vue.use(LemonIMUI);
|
|||||||
#### 示例 · 文档
|
#### 示例 · 文档
|
||||||
|
|
||||||
[lemon-imui](http://june000.gitee.io/lemon-im).
|
[lemon-imui](http://june000.gitee.io/lemon-im).
|
||||||
|
|
||||||
|
[QQ 交流群:1081773406](https://qm.qq.com/cgi-bin/qm/qr?k=MzwO4MT20zYQEXP8gq-GbjSJFA0qK15_&jump_from=webapi).
|
||||||
|
|||||||
Vendored
+32
@@ -8376,6 +8376,29 @@ var renderDrawerContent = function renderDrawerContent() {};
|
|||||||
return a.index.localeCompare(b.index);
|
return a.index.localeCompare(b.index);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
appendContact: function appendContact(contact) {
|
||||||
|
if (isEmpty(contact.id) || isEmpty(contact.displayName)) {
|
||||||
|
console.error('id | displayName cant be empty');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.hasContact(contact.id)) return true;
|
||||||
|
this.contacts.push(Object.assign(_defineProperty({
|
||||||
|
id: '',
|
||||||
|
displayName: '',
|
||||||
|
avatar: '',
|
||||||
|
index: '',
|
||||||
|
unread: 0,
|
||||||
|
lastSendTime: ''
|
||||||
|
}, "lastSendTime", ''), contact));
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
removeContact: function removeContact(id) {
|
||||||
|
var index = this.findContactIndexById(id);
|
||||||
|
if (index === -1) return false;
|
||||||
|
this.contacts.splice(index, 1);
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改联系人数据
|
* 修改联系人数据
|
||||||
@@ -8409,6 +8432,15 @@ var renderDrawerContent = function renderDrawerContent() {};
|
|||||||
return item.id == contactId;
|
return item.id == contactId;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据 id 查找判断是否存在联系人
|
||||||
|
* @param contactId 联系人 id
|
||||||
|
* @return {Boolean}
|
||||||
|
*/
|
||||||
|
hasContact: function hasContact(contactId) {
|
||||||
|
return this.findContactIndexById(contactId) !== -1;
|
||||||
|
},
|
||||||
findMessage: function findMessage(messageId) {
|
findMessage: function findMessage(messageId) {
|
||||||
return Object.values(allMessages).flat().find(function (_ref3) {
|
return Object.values(allMessages).flat().find(function (_ref3) {
|
||||||
var id = _ref3.id;
|
var id = _ref3.id;
|
||||||
|
|||||||
Vendored
+32
@@ -8385,6 +8385,29 @@ var renderDrawerContent = function renderDrawerContent() {};
|
|||||||
return a.index.localeCompare(b.index);
|
return a.index.localeCompare(b.index);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
appendContact: function appendContact(contact) {
|
||||||
|
if (isEmpty(contact.id) || isEmpty(contact.displayName)) {
|
||||||
|
console.error('id | displayName cant be empty');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.hasContact(contact.id)) return true;
|
||||||
|
this.contacts.push(Object.assign(_defineProperty({
|
||||||
|
id: '',
|
||||||
|
displayName: '',
|
||||||
|
avatar: '',
|
||||||
|
index: '',
|
||||||
|
unread: 0,
|
||||||
|
lastSendTime: ''
|
||||||
|
}, "lastSendTime", ''), contact));
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
removeContact: function removeContact(id) {
|
||||||
|
var index = this.findContactIndexById(id);
|
||||||
|
if (index === -1) return false;
|
||||||
|
this.contacts.splice(index, 1);
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改联系人数据
|
* 修改联系人数据
|
||||||
@@ -8418,6 +8441,15 @@ var renderDrawerContent = function renderDrawerContent() {};
|
|||||||
return item.id == contactId;
|
return item.id == contactId;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据 id 查找判断是否存在联系人
|
||||||
|
* @param contactId 联系人 id
|
||||||
|
* @return {Boolean}
|
||||||
|
*/
|
||||||
|
hasContact: function hasContact(contactId) {
|
||||||
|
return this.findContactIndexById(contactId) !== -1;
|
||||||
|
},
|
||||||
findMessage: function findMessage(messageId) {
|
findMessage: function findMessage(messageId) {
|
||||||
return Object.values(allMessages).flat().find(function (_ref3) {
|
return Object.values(allMessages).flat().find(function (_ref3) {
|
||||||
var id = _ref3.id;
|
var id = _ref3.id;
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+27
-5
@@ -4,7 +4,12 @@
|
|||||||
<div class="logo">
|
<div class="logo">
|
||||||
<div class="logo-text"><b>Lemon</b> IMUI<span class="logo-badge">{{this.packageData.version}}</span></div>
|
<div class="logo-text"><b>Lemon</b> IMUI<span class="logo-badge">{{this.packageData.version}}</span></div>
|
||||||
<div class="logo-sub">{{this.packageData.description}}</div>
|
<div class="logo-sub">{{this.packageData.description}}</div>
|
||||||
<div class="link"><span>源码下载 </span><a target="_blank" href="https://github.com/fanjyy/lemon-imui">Github</a><a target="_blank" href="https://gitee.com/june000/lemon-im">Gitee</a></div>
|
<div class="link">
|
||||||
|
<span>源码下载 </span>
|
||||||
|
<a target="_blank" href="https://github.com/fanjyy/lemon-imui">Github</a>
|
||||||
|
<a target="_blank" href="https://gitee.com/june000/lemon-im">Gitee</a>
|
||||||
|
<a target="_blank" href="https://qm.qq.com/cgi-bin/qm/qr?k=xzUa9CPYQ5KCNQ86h7ep4Z3TtkqJxRZE&jump_from=webapi">QQ交流群:1081773406</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="imui-center">
|
<div class="imui-center">
|
||||||
<lemon-imui
|
<lemon-imui
|
||||||
@@ -438,7 +443,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>appendMessage</td>
|
<td>appendMessage</td>
|
||||||
<td>新增一条新消息, 如果当前焦点在该联系人的聊天窗口,设置 scrollToBottom=true 添加之后自动定位到消息窗口底部</td>
|
<td>新增一条消息, 如果当前焦点在该联系人的聊天窗口,设置 scrollToBottom=true 添加之后自动定位到消息窗口底部</td>
|
||||||
<td>Function(Message,scrollToBottom=false)</td>
|
<td>Function(Message,scrollToBottom=false)</td>
|
||||||
<td>-</td>
|
<td>-</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
@@ -457,6 +462,20 @@
|
|||||||
<td>-</td>
|
<td>-</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>appendContact</td>
|
||||||
|
<td>添加联系人</td>
|
||||||
|
<td>Function(Contact)</td>
|
||||||
|
<td>-</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>removeContact</td>
|
||||||
|
<td>删除联系人</td>
|
||||||
|
<td>Function(Contact.id)</td>
|
||||||
|
<td>-</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>updateContact</td>
|
<td>updateContact</td>
|
||||||
<td>修改联系人,根据 Contact.id 查找联系人并覆盖传入的值</td>
|
<td>修改联系人,根据 Contact.id 查找联系人并覆盖传入的值</td>
|
||||||
@@ -474,7 +493,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>getCurrentContact</td>
|
<td>getCurrentContact</td>
|
||||||
<td>返回当前聊天窗口的联系人信息</td>
|
<td>返回当前聊天窗口的联系人信息</td>
|
||||||
<td>Function()=>[Message]</td>
|
<td>Function()=>Contact</td>
|
||||||
<td>-</td>
|
<td>-</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -819,7 +838,7 @@ export default {
|
|||||||
id: "contact-4",
|
id: "contact-4",
|
||||||
displayName: "如花",
|
displayName: "如花",
|
||||||
avatar: "https://dss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=4275424924,2201401076&fm=111&gp=0.jpg",
|
avatar: "https://dss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=4275424924,2201401076&fm=111&gp=0.jpg",
|
||||||
index: "R",
|
index: "",
|
||||||
unread: 1,
|
unread: 1,
|
||||||
lastSendTime: 3,
|
lastSendTime: 3,
|
||||||
lastContent: "吃饭了嘛"
|
lastContent: "吃饭了嘛"
|
||||||
@@ -827,6 +846,9 @@ export default {
|
|||||||
|
|
||||||
const { IMUI } = this.$refs;
|
const { IMUI } = this.$refs;
|
||||||
|
|
||||||
|
setTimeout(()=>{
|
||||||
|
console.log(IMUI.hasContact('cont1act-3'));
|
||||||
|
},2000);
|
||||||
|
|
||||||
IMUI.setLastContentRender('event',(message)=>{
|
IMUI.setLastContentRender('event',(message)=>{
|
||||||
return '[有人邀请你加入群组]';
|
return '[有人邀请你加入群组]';
|
||||||
@@ -1487,7 +1509,7 @@ a
|
|||||||
.logo-badge
|
.logo-badge
|
||||||
position absolute
|
position absolute
|
||||||
top -10px
|
top -10px
|
||||||
right -40px
|
left 230px
|
||||||
background #000
|
background #000
|
||||||
border-radius 16px
|
border-radius 16px
|
||||||
color #f9f9f9
|
color #f9f9f9
|
||||||
|
|||||||
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
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.436859f0.css rel=preload as=style><link href=js/chunk-vendors.e4810482.js rel=preload as=script><link href=js/index.0fb261d4.js rel=preload as=script><link href=css/index.436859f0.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.0fb261d4.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.9ef31261.css rel=preload as=style><link href=js/chunk-vendors.e4810482.js rel=preload as=script><link href=js/index.9a55b7ef.js rel=preload as=script><link href=css/index.9ef31261.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.9a55b7ef.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",
|
"name": "lemon-imui",
|
||||||
"version": "1.3.2",
|
"version": "1.3.3",
|
||||||
"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": "https://github.com/fanjyy/lemon-imui",
|
||||||
|
|||||||
@@ -735,6 +735,29 @@ export default {
|
|||||||
return a.index.localeCompare(b.index);
|
return a.index.localeCompare(b.index);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
appendContact(contact){
|
||||||
|
if(isEmpty(contact.id) || isEmpty(contact.displayName)){
|
||||||
|
console.error('id | displayName cant be empty');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(this.hasContact(contact.id)) return true;
|
||||||
|
this.contacts.push(Object.assign({
|
||||||
|
id:'',
|
||||||
|
displayName:'',
|
||||||
|
avatar:'',
|
||||||
|
index:'',
|
||||||
|
unread:0,
|
||||||
|
lastSendTime:'',
|
||||||
|
lastSendTime:'',
|
||||||
|
},contact));
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
removeContact(id){
|
||||||
|
const index = this.findContactIndexById(id);
|
||||||
|
if(index === -1) return false;
|
||||||
|
this.contacts.splice(index,1);
|
||||||
|
return true;
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* 修改联系人数据
|
* 修改联系人数据
|
||||||
* @param {Contact} data 修改的数据,根据 data.id 查找联系人并覆盖传入的值
|
* @param {Contact} data 修改的数据,根据 data.id 查找联系人并覆盖传入的值
|
||||||
@@ -766,6 +789,14 @@ export default {
|
|||||||
findContactIndexById(contactId) {
|
findContactIndexById(contactId) {
|
||||||
return this.contacts.findIndex(item => item.id == contactId);
|
return this.contacts.findIndex(item => item.id == contactId);
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* 根据 id 查找判断是否存在联系人
|
||||||
|
* @param contactId 联系人 id
|
||||||
|
* @return {Boolean}
|
||||||
|
*/
|
||||||
|
hasContact(contactId){
|
||||||
|
return this.findContactIndexById(contactId) !== -1;
|
||||||
|
},
|
||||||
findMessage(messageId){
|
findMessage(messageId){
|
||||||
return Object.values(allMessages).flat().find(({id})=>id == messageId);
|
return Object.values(allMessages).flat().find(({id})=>id == messageId);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user