From 4fe4dc8c6e2f60a8dc5bc1eff4b4b26df6632d49 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Sun, 20 Oct 2024 19:31:04 +0800 Subject: [PATCH] =?UTF-8?q?pref:=20=E4=BC=98=E5=8C=96=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E9=80=9A=E8=AE=AF=E5=BD=95=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/SystemController.php | 1 + resources/assets/js/components/UserSelect.vue | 112 ++++++++++++------ .../assets/js/pages/manage/application.vue | 4 + .../assets/js/pages/manage/messenger.vue | 16 ++- 4 files changed, 97 insertions(+), 36 deletions(-) diff --git a/app/Http/Controllers/Api/SystemController.php b/app/Http/Controllers/Api/SystemController.php index cde47f5f4..87c16fd2b 100755 --- a/app/Http/Controllers/Api/SystemController.php +++ b/app/Http/Controllers/Api/SystemController.php @@ -133,6 +133,7 @@ class SystemController extends AbstractController $setting['file_upload_limit'] = $setting['file_upload_limit'] ?: ''; $setting['unclaimed_task_reminder'] = $setting['unclaimed_task_reminder'] ?: 'close'; $setting['unclaimed_task_reminder_time'] = $setting['unclaimed_task_reminder_time'] ?: ''; + $setting['server_closeai'] = env("SERVER_CLOSEAI") ?: 'open'; $setting['server_timezone'] = config('app.timezone'); $setting['server_version'] = Base::getVersion(); // diff --git a/resources/assets/js/components/UserSelect.vue b/resources/assets/js/components/UserSelect.vue index 2baca06ad..c11b625b8 100755 --- a/resources/assets/js/components/UserSelect.vue +++ b/resources/assets/js/components/UserSelect.vue @@ -503,10 +503,13 @@ export default { }, searchContact() { - let key = this.searchKey; + const key = this.searchKey; const cache = this.searchCache.find(item => item.type === 'contact' && item.key == key); if (cache) { this.contacts = cache.data + if (!cache.more) { + return + } } // this.waitIng++ @@ -518,45 +521,80 @@ export default { setTimeout(() => { this.loadIng++ }, 300) - this.$store.dispatch("call", { - url: 'users/search', - data: { - keys: { - key, - project_id: this.projectId, - no_project_id: this.noProjectId, - dialog_id: this.dialogId, - bot: this.showBot && key ? 2 : 0, - disable: this.showDisable && key ? 2 : 0, - }, - take: 50 - }, - }).then(({data}) => { - data = data.map(item => Object.assign(item, {type: 'user'})) - this.contacts = data - // - const index = this.searchCache.findIndex(item => item.key == key); - const tmpData = {type: 'contact', key, data, time: $A.dayjs().unix()}; - if (index > -1) { - this.searchCache.splice(index, 1, tmpData) - } else { - this.searchCache.push(tmpData) - } - }).catch(({msg}) => { - this.contacts = [] - $A.messageWarning(msg) - }).finally(_ => { + this.searchRequest(key, 1, () => { this.loadIng--; this.waitIng--; - }); + }) }, this.searchCache.length > 0 ? 300 : 0) }, + searchRequest(key, page, cb) { + this.$store.dispatch("call", { + url: 'users/search', + data: { + keys: { + key, + project_id: this.projectId, + no_project_id: this.noProjectId, + dialog_id: this.dialogId, + bot: this.showBot && key ? 2 : 0, + disable: this.showDisable && key ? 2 : 0, + }, + page, + pagesize: 50 + }, + }).then(({data}) => { + if (this.searchKey != key) { + cb() + return + } + const items = data.data.map(item => Object.assign(item, {type: 'user'})) + if (data.current_page > 1) { + items.unshift(...this.contacts) + } + this.contacts = items + // + const index = this.searchCache.findIndex(item => item.type === 'contact' && item.key == key); + const tmpData = {type: 'contact', key, data: items, time: $A.dayjs().unix(), more: data.current_page < data.last_page}; + if (index > -1) { + this.searchCache.splice(index, 1, tmpData) + } else { + this.searchCache.push(tmpData) + } + // + if (!tmpData.more) { + cb() + return; + } + if (data.current_page % 5 === 0) { + $A.modalConfirm({ + content: "数据已超过" + data.to + "条,是否继续加载?", + onOk: () => { + this.searchRequest(key, data.current_page + 1, cb) + }, + onCancel: cb + }); + } else { + this.searchRequest(key, data.current_page + 1, cb) + + } + }).catch(({msg}) => { + if (page === 1) { + this.contacts = [] + } + $A.messageWarning(msg) + cb() + }); + }, + searchProject() { - let key = this.searchKey; + const key = this.searchKey; const cache = this.searchCache.find(item => item.type === 'project' && item.key == key); if (cache) { this.projects = cache.data + if (!cache.more) { + return + } } // this.waitIng++ @@ -579,11 +617,15 @@ export default { getstatistics: 'no' }, }).then(({data}) => { - data = data.data.map(item => Object.assign(item, {type: 'project'})) - this.projects = data + if (this.searchKey != key) { + return + } // - const index = this.searchCache.findIndex(item => item.key == key); - const tmpData = {type: 'project', key, data, time: $A.dayjs().unix()}; + const items = data.data.map(item => Object.assign(item, {type: 'project'})) + this.projects = items + // + const index = this.searchCache.findIndex(item => item.type === 'project' && item.key == key); + const tmpData = {type: 'project', key, data: items, time: $A.dayjs().unix(), more: false}; if (index > -1) { this.searchCache.splice(index, 1, tmpData) } else { diff --git a/resources/assets/js/pages/manage/application.vue b/resources/assets/js/pages/manage/application.vue index 57a69fb8e..2e34971fb 100644 --- a/resources/assets/js/pages/manage/application.vue +++ b/resources/assets/js/pages/manage/application.vue @@ -323,6 +323,7 @@ export default { }, computed: { ...mapState([ + 'systemConfig', 'userInfo', 'userIsAdmin', 'reportUnreadNumber', @@ -351,6 +352,9 @@ export default { { value: "word-chain", label: "群接龙", sort: 9 }, { value: "vote", label: "群投票", sort: 10 }, ]; + if (this.systemConfig.server_closeai === 'close') { + applyList = applyList.filter(h => h.value !== 'robot'); + } // wap模式 if (this.windowOrientation == 'landscape') { // 横屏模式 diff --git a/resources/assets/js/pages/manage/messenger.vue b/resources/assets/js/pages/manage/messenger.vue index 9c9ec5623..a5c5debdc 100644 --- a/resources/assets/js/pages/manage/messenger.vue +++ b/resources/assets/js/pages/manage/messenger.vue @@ -343,7 +343,17 @@ export default { }, computed: { - ...mapState(['cacheDialogs', 'loadDialogs', 'dialogId', 'dialogMsgId', 'dialogMsgs', 'messengerSearchKey', 'appNotificationPermission', 'taskColorList']), + ...mapState([ + 'systemConfig', + 'cacheDialogs', + 'loadDialogs', + 'dialogId', + 'dialogMsgId', + 'dialogMsgs', + 'messengerSearchKey', + 'appNotificationPermission', + 'taskColorList' + ]), routeName() { return this.$route.name @@ -819,6 +829,10 @@ export default { } } } + } else if (dialog.type == 'user') { + if (this.systemConfig.server_closeai === 'close' && /^ai-(.*?)@bot.system/.test(dialog.email)) { + return false + } } return true; },