Skip to content

Commit

Permalink
perf: 添加全局搜索功能
Browse files Browse the repository at this point in the history
  • Loading branch information
kuaifan committed Mar 3, 2025
1 parent 1c4c4fe commit f03600b
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 6 deletions.
44 changes: 41 additions & 3 deletions resources/assets/js/components/SearchBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,14 @@ export default {
switch (type) {
case 'task':
return this.$L('任务')
case 'project':
return this.$L('项目')
case 'message':
return this.$L('消息')
case 'contact':
return this.$L('联系人')
case 'file':
return this.$L('文件')
case 'project':
return this.$L('项目')
}
return type;
},
Expand All @@ -182,7 +182,45 @@ export default {
},
onClick(item) {
console.log(item);
switch (item.type) {
case 'task':
this.$store.dispatch('openTask', item.rawData)
this.onHide()
break;
case 'project':
this.goForward({name: 'manage-project', params: {projectId: item.id}})
this.onHide()
break;
case 'message':
this.$store.dispatch("openDialog", item.id).then(() => {
this.onHide()
this.goForward({name: 'manage-messenger', params: {dialogAction: 'dialog'}})
this.$store.state.dialogSearchMsgId = /^\d+$/.test(item.rawData.search_msg_id) ? item.rawData.search_msg_id : 0
}).catch(({msg}) => {
$A.modalError(msg || this.$L('打开会话失败'))
})
break;
case 'contact':
this.$store.dispatch("openDialogUserid", item.id).then(_ => {
this.onHide()
this.goForward({name: 'manage-messenger', params: {dialogAction: 'dialog'}})
}).catch(({msg}) => {
$A.modalError(msg || this.$L('打开会话失败'))
});
break;
case 'file':
this.goForward({name: 'manage-file', params: {folderId: item.rawData.pid, fileId: null, shakeId: item.id}})
this.$store.state.fileShakeId = item.id
setTimeout(() => {
this.$store.state.fileShakeId = 0
}, 1000)
this.onHide()
break;
}
},
onShow() {
Expand Down
5 changes: 3 additions & 2 deletions resources/assets/js/pages/manage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -976,13 +976,14 @@ export default {
this.onAddShow()
break;
case 70: // F - 搜索
case 70:
case 191: // F、/ - 搜索
e.preventDefault();
this.$refs.searchBox.onShow();
break;
case 75:
case 78: // K/N - 新建任务
case 78: // KN - 新建任务
e.preventDefault();
this.onAddMenu('task')
break;
Expand Down
6 changes: 5 additions & 1 deletion resources/assets/js/pages/manage/file.vue
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ export default {
},
computed: {
...mapState(['systemConfig', 'userIsAdmin', 'userInfo', 'fileLists', 'wsOpenNum', 'windowWidth', 'filePackLists']),
...mapState(['systemConfig', 'userIsAdmin', 'userInfo', 'fileLists', 'wsOpenNum', 'windowWidth', 'filePackLists', 'fileShakeId']),
pid() {
const {folderId} = this.$route.params;
Expand Down Expand Up @@ -959,6 +959,10 @@ export default {
},
deep: true
},
fileShakeId(shakeId) {
shakeId && this.shakeFile(shakeId)
}
},
methods: {
Expand Down
1 change: 1 addition & 0 deletions resources/assets/js/store/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export default {
fileLists: [],
fileLinks: [],
filePackLists: [],
fileShakeId: 0,

// 项目任务
projectId: 0,
Expand Down

0 comments on commit f03600b

Please sign in to comment.