mirror of
https://github.com/kuaifan/dootask.git
synced 2026-02-18 14:13:58 +00:00
perf: 优化通讯录刷新机制
This commit is contained in:
parent
11308829a6
commit
be3fcb55fb
@ -350,6 +350,7 @@ class UsersController extends AbstractController
|
|||||||
* - keys.no_project_id 不在指定项目ID
|
* - keys.no_project_id 不在指定项目ID
|
||||||
* @apiParam {Object} sorts 排序方式
|
* @apiParam {Object} sorts 排序方式
|
||||||
* - sorts.az 按字母:asc|desc
|
* - sorts.az 按字母:asc|desc
|
||||||
|
* @apiParam {Number} updated_time 在这个时间戳之后更新的
|
||||||
*
|
*
|
||||||
* @apiParam {Number} [take] 获取数量,10-100
|
* @apiParam {Number} [take] 获取数量,10-100
|
||||||
* @apiParam {Number} [page] 当前页,默认:1(赋值分页模式,take参数无效)
|
* @apiParam {Number} [page] 当前页,默认:1(赋值分页模式,take参数无效)
|
||||||
@ -365,6 +366,7 @@ class UsersController extends AbstractController
|
|||||||
//
|
//
|
||||||
$keys = Request::input('keys');
|
$keys = Request::input('keys');
|
||||||
$sorts = Request::input('sorts');
|
$sorts = Request::input('sorts');
|
||||||
|
$updatedTime = intval(Request::input('updated_time'));
|
||||||
$keys = is_array($keys) ? $keys : [];
|
$keys = is_array($keys) ? $keys : [];
|
||||||
$sorts = is_array($sorts) ? $sorts : [];
|
$sorts = is_array($sorts) ? $sorts : [];
|
||||||
//
|
//
|
||||||
@ -379,6 +381,9 @@ class UsersController extends AbstractController
|
|||||||
} elseif (intval($keys['disable']) == 2) {
|
} elseif (intval($keys['disable']) == 2) {
|
||||||
$builder->whereNotNull("disable_at");
|
$builder->whereNotNull("disable_at");
|
||||||
}
|
}
|
||||||
|
if ($updatedTime > 0) {
|
||||||
|
$builder->where("updated_at", ">=", Carbon::createFromTimestamp($updatedTime));
|
||||||
|
}
|
||||||
if (intval($keys['project_id']) > 0) {
|
if (intval($keys['project_id']) > 0) {
|
||||||
$builder->whereIn('userid', function ($query) use ($keys) {
|
$builder->whereIn('userid', function ($query) use ($keys) {
|
||||||
$query->select('userid')->from('project_users')->where('project_id', $keys['project_id']);
|
$query->select('userid')->from('project_users')->where('project_id', $keys['project_id']);
|
||||||
|
|||||||
@ -171,6 +171,7 @@ export default {
|
|||||||
contactsData: null,
|
contactsData: null,
|
||||||
contactsCurrentPage: 1,
|
contactsCurrentPage: 1,
|
||||||
contactsHasMorePages: false,
|
contactsHasMorePages: false,
|
||||||
|
contactsLastTime: 0,
|
||||||
|
|
||||||
operateItem: {},
|
operateItem: {},
|
||||||
operateStyles: {},
|
operateStyles: {},
|
||||||
@ -346,7 +347,14 @@ export default {
|
|||||||
tabActive: {
|
tabActive: {
|
||||||
handler(val) {
|
handler(val) {
|
||||||
if (val == 'contacts') {
|
if (val == 'contacts') {
|
||||||
this.contactsData === null && this.getContactsList(1);
|
if ($A.Time() - this.contactsLastTime > 24 * 3600) {
|
||||||
|
this.contactsData = null; // 24个小时重新加载列表
|
||||||
|
}
|
||||||
|
if (this.contactsData === null) {
|
||||||
|
this.getContactsList(1);
|
||||||
|
} else {
|
||||||
|
this.updateContactsList(1000);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.updateDialogs(1000);
|
this.updateDialogs(1000);
|
||||||
}
|
}
|
||||||
@ -477,9 +485,38 @@ export default {
|
|||||||
this.contactsHasMorePages = false;
|
this.contactsHasMorePages = false;
|
||||||
}).finally(_ => {
|
}).finally(_ => {
|
||||||
this.contactsLoad--;
|
this.contactsLoad--;
|
||||||
|
this.contactsLastTime = $A.Time()
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
updateContactsList(timeout) {
|
||||||
|
this.__updateContactsList && clearTimeout(this.__updateContactsList)
|
||||||
|
if (timeout > -1) {
|
||||||
|
this.__updateContactsList = setTimeout(_ => {
|
||||||
|
if (this.tabActive === 'contacts') {
|
||||||
|
this.$store.dispatch("call", {
|
||||||
|
url: 'users/search',
|
||||||
|
data: {
|
||||||
|
updated_time: this.contactsLastTime,
|
||||||
|
take: 100
|
||||||
|
},
|
||||||
|
}).then(({data}) => {
|
||||||
|
data.some((user) => {
|
||||||
|
const index = this.contactsData.findIndex(item => item.userid == user.userid);
|
||||||
|
if (index > -1) {
|
||||||
|
this.contactsData.splice(index, 1, user);
|
||||||
|
} else {
|
||||||
|
this.contactsData.push(user);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}).finally(_ => {
|
||||||
|
this.contactsLastTime = $A.Time()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, timeout)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
formatLastMsg(data) {
|
formatLastMsg(data) {
|
||||||
if ($A.isJson(data)) {
|
if ($A.isJson(data)) {
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user