Merge branch 'feature/menu_search' into develop
Former-commit-id: 1b92128e89b29eda735f274243b152009c9fda1d [formerly 1b92128e89b29eda735f274243b152009c9fda1d [formerly 1b92128e89b29eda735f274243b152009c9fda1d [formerly 1b92128e89b29eda735f274243b152009c9fda1d [formerly 6d0ad889c8a55b39aed1234f33bd4289becb382f [formerly 628b796b47811eac1da0c6ef7a2857a0dc93762a]]]]] Former-commit-id: b643ffbe716bc602991a675857c899fe4598de6b Former-commit-id: 89177da3733ab7fd98ff5c038c2c2618353d1521 Former-commit-id: 1d1328895a0adc0e43e207167b48db8a77ea49f9 [formerly 75f6252347dc0048f1ce40a56690da8f0971f95a] Former-commit-id: 422e9a18552f63ec5390a3f79688bdd733a72047 Former-commit-id: facbc0e703cfb4a43a2af3348cd69f63b7e1f425 Former-commit-id: 27f70579ee35411203e52c565854c81af6060e89 Former-commit-id: 85d532f0d569c2681dc4bd6cf2f39c3078ea30c5 Former-commit-id: 76aa5b8cc5b7097c23ddb18c93817d47591e100b
This commit is contained in:
@@ -10,6 +10,7 @@ import ua from './modules/ua'
|
||||
import gray from './modules/gray'
|
||||
import page from './modules/page'
|
||||
import transition from './modules/transition'
|
||||
import search from './modules/search'
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
@@ -25,6 +26,7 @@ export default {
|
||||
ua,
|
||||
gray,
|
||||
page,
|
||||
transition
|
||||
transition,
|
||||
search
|
||||
}
|
||||
}
|
||||
|
||||
55
src/store/modules/d2admin/modules/search.js
Normal file
55
src/store/modules/d2admin/modules/search.js
Normal file
@@ -0,0 +1,55 @@
|
||||
import setting from '@/setting.js'
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
// 搜索面板激活状态
|
||||
active: true,
|
||||
// 快捷键
|
||||
hotkey: {
|
||||
open: setting.hotkey.search.open,
|
||||
close: setting.hotkey.search.close
|
||||
},
|
||||
// 所有可以搜索的页面
|
||||
pool: []
|
||||
},
|
||||
mutations: {
|
||||
/**
|
||||
* @description 切换激活状态
|
||||
* @param {Object} state vuex state
|
||||
*/
|
||||
toggle (state) {
|
||||
state.active = !state.active
|
||||
},
|
||||
/**
|
||||
* @description 设置激活模式
|
||||
* @param {Object} state vuex state
|
||||
* @param {Boolean} active active
|
||||
*/
|
||||
set (state, active) {
|
||||
state.active = active
|
||||
},
|
||||
/**
|
||||
* @description 初始化
|
||||
* @param {Object} state vuex state
|
||||
* @param {Array} menus menus
|
||||
*/
|
||||
init (state, menus) {
|
||||
const pool = []
|
||||
const push = function (menus, titlePrefix = []) {
|
||||
menus.forEach(menu => {
|
||||
if (menu.children) {
|
||||
push(menu.children, [ ...titlePrefix, menu.title ])
|
||||
} else {
|
||||
pool.push({
|
||||
...menu,
|
||||
fullTitle: [ ...titlePrefix, menu.title ].join(' / ')
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
push(menus)
|
||||
state.pool = pool
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user