Former-commit-id: bb8db2a25ef717137a9d4e473538c0f954ba9eae [formerly bb8db2a25ef717137a9d4e473538c0f954ba9eae [formerly bb8db2a25ef717137a9d4e473538c0f954ba9eae [formerly bb8db2a25ef717137a9d4e473538c0f954ba9eae [formerly 6048998b71a5d72480e0bd1e221dbab02a31053f [formerly 0507967735e3772d1574716b94858068a8b045a6]]]]] Former-commit-id: cbe63cc098a79ac9ebaafb9d68b1cab37bd9f14f Former-commit-id: 687b0834254a9afb6bd9ab786fcd0ac70974e9eb Former-commit-id: 1ee65e08e4be2da3c4872b382cd00b22d0c70803 [formerly 077722278a2e61df580803cb3dd8338717496920] Former-commit-id: 157231d84ac7a4a1361c466a2aeb660202593193 Former-commit-id: 5f841aa4b756af37c4bd3d7ffc1cf79b15cb653d Former-commit-id: 3f7e0fd74011f90411a3f811b0123b19eb5f2c28 Former-commit-id: 39b9cdfcff6656ba65f35796cd14e4ca9ad2a26f Former-commit-id: 11ae87bd38fa19408ca8cb6d20a74268c90cc6a7
59 lines
1.3 KiB
JavaScript
59 lines
1.3 KiB
JavaScript
import { mapState, mapMutations } from 'vuex'
|
|
|
|
import hotkeys from 'hotkeys-js'
|
|
|
|
export default {
|
|
components: {
|
|
'd2-panel-search': () => import('../components/panel-search')
|
|
},
|
|
mounted () {
|
|
// 绑定搜索功能快捷键 [ 打开 ]
|
|
hotkeys(this.searchHotkey.open, event => {
|
|
event.preventDefault()
|
|
this.searchPanelOpen()
|
|
})
|
|
// 绑定搜索功能快捷键 [ 关闭 ]
|
|
hotkeys(this.searchHotkey.close, event => {
|
|
event.preventDefault()
|
|
this.searchPanelClose()
|
|
})
|
|
},
|
|
beforeDestroy () {
|
|
hotkeys.unbind(this.searchHotkey.open)
|
|
hotkeys.unbind(this.searchHotkey.close)
|
|
},
|
|
computed: {
|
|
...mapState('d2admin', {
|
|
searchActive: state => state.search.active,
|
|
searchHotkey: state => state.search.hotkey
|
|
})
|
|
},
|
|
methods: {
|
|
...mapMutations({
|
|
searchToggle: 'd2admin/search/toggle',
|
|
searchSet: 'd2admin/search/set'
|
|
}),
|
|
/**
|
|
* 接收点击搜索按钮
|
|
*/
|
|
handleSearchClick () {
|
|
this.searchToggle()
|
|
if (this.searchActive) {
|
|
this.$refs.panelSearch.focus()
|
|
}
|
|
},
|
|
searchPanelOpen () {
|
|
if (!this.searchActive) {
|
|
this.searchSet(true)
|
|
this.$refs.panelSearch.focus()
|
|
}
|
|
},
|
|
// 关闭搜索面板
|
|
searchPanelClose () {
|
|
if (this.searchActive) {
|
|
this.searchSet(false)
|
|
}
|
|
}
|
|
}
|
|
}
|