diff --git a/src/layouts/modules/global-header/index.vue b/src/layouts/modules/global-header/index.vue index 705b41c66..ae372c490 100644 --- a/src/layouts/modules/global-header/index.vue +++ b/src/layouts/modules/global-header/index.vue @@ -7,6 +7,7 @@ import { useRouteStore } from '@/store/modules/route'; import HorizontalMenu from '../global-menu/base-menu.vue'; import GlobalLogo from '../global-logo/index.vue'; import GlobalBreadcrumb from '../global-breadcrumb/index.vue'; +import GlobalSearch from '../global-search/index.vue'; import { useMixMenuContext } from '../../hooks/use-mix-menu'; import ThemeButton from './components/theme-button.vue'; import UserAvatar from './components/user-avatar.vue'; @@ -54,6 +55,7 @@ const headerMenus = computed(() => {
+ +defineOptions({ name: 'SearchFooter' }); + + + + + diff --git a/src/layouts/modules/global-search/components/search-modal.vue b/src/layouts/modules/global-search/components/search-modal.vue new file mode 100644 index 000000000..3ebf78e21 --- /dev/null +++ b/src/layouts/modules/global-search/components/search-modal.vue @@ -0,0 +1,115 @@ + + + + + diff --git a/src/layouts/modules/global-search/components/search-result.vue b/src/layouts/modules/global-search/components/search-result.vue new file mode 100644 index 000000000..830391ade --- /dev/null +++ b/src/layouts/modules/global-search/components/search-result.vue @@ -0,0 +1,57 @@ + + + + + diff --git a/src/layouts/modules/global-search/index.vue b/src/layouts/modules/global-search/index.vue new file mode 100644 index 000000000..bb925582d --- /dev/null +++ b/src/layouts/modules/global-search/index.vue @@ -0,0 +1,20 @@ + + + + + diff --git a/src/store/modules/route/index.ts b/src/store/modules/route/index.ts index 94a374c4b..04e416992 100644 --- a/src/store/modules/route/index.ts +++ b/src/store/modules/route/index.ts @@ -19,6 +19,7 @@ import { getSelectedMenuKeyPathByKey, isRouteExistByRouteName, sortRoutesByOrder, + transformMenuToSearchMenus, updateLocaleOfGlobalMenus } from './shared'; @@ -52,6 +53,7 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => { /** Global menus */ const menus = ref([]); + const searchMenus = computed(() => transformMenuToSearchMenus(menus.value)); /** Get global menus */ function getGlobalMenus(routes: ElegantConstRoute[]) { @@ -275,6 +277,7 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => { resetStore, routeHome, menus, + searchMenus, updateGlobalMenusByLocale, cacheRoutes, reCacheRoutesByKey, diff --git a/src/store/modules/route/shared.ts b/src/store/modules/route/shared.ts index c7cfb8217..4212f7fec 100644 --- a/src/store/modules/route/shared.ts +++ b/src/store/modules/route/shared.ts @@ -310,3 +310,22 @@ export function getBreadcrumbsByRoute( return []; } + +/** + * Transform menu to searchMenus + * + * @param menus - menus + * @param treeMap + */ +export function transformMenuToSearchMenus(menus: App.Global.Menu[], treeMap: App.Global.Menu[] = []) { + if (menus && menus.length === 0) return []; + return menus.reduce((acc, cur) => { + if (!cur.children) { + acc.push(cur); + } + if (cur.children && cur.children.length > 0) { + transformMenuToSearchMenus(cur.children, treeMap); + } + return acc; + }, treeMap); +} diff --git a/src/typings/components.d.ts b/src/typings/components.d.ts index 8f0d632f8..afeb02d08 100644 --- a/src/typings/components.d.ts +++ b/src/typings/components.d.ts @@ -14,6 +14,7 @@ declare module 'vue' { DarkModeContainer: typeof import('./../components/common/dark-mode-container.vue')['default'] ExceptionBase: typeof import('./../components/common/exception-base.vue')['default'] FullScreen: typeof import('./../components/common/full-screen.vue')['default'] + IconAntDesignEnterOutlined: typeof import('~icons/ant-design/enter-outlined')['default'] IconAntDesignReloadOutlined: typeof import('~icons/ant-design/reload-outlined')['default'] IconAntDesignSettingOutlined: typeof import('~icons/ant-design/setting-outlined')['default'] IconGridiconsFullscreen: typeof import('~icons/gridicons/fullscreen')['default'] @@ -24,8 +25,13 @@ declare module 'vue' { IconIcRoundSearch: typeof import('~icons/ic/round-search')['default'] IconLocalBanner: typeof import('~icons/local/banner')['default'] IconLocalLogo: typeof import('~icons/local/logo')['default'] + IconMdiArrowDownThin: typeof import('~icons/mdi/arrow-down-thin')['default'] + IconMdiArrowUpThin: typeof import('~icons/mdi/arrow-up-thin')['default'] IconMdiDrag: typeof import('~icons/mdi/drag')['default'] + IconMdiKeyboardEsc: typeof import('~icons/mdi/keyboard-esc')['default'] + IconMdiKeyboardReturn: typeof import('~icons/mdi/keyboard-return')['default'] IconMdiRefresh: typeof import('~icons/mdi/refresh')['default'] + IconUilSearch: typeof import('~icons/uil/search')['default'] LangSwitch: typeof import('./../components/common/lang-switch.vue')['default'] LookForward: typeof import('./../components/custom/look-forward.vue')['default'] MenuToggler: typeof import('./../components/common/menu-toggler.vue')['default'] @@ -43,6 +49,7 @@ declare module 'vue' { NDrawer: typeof import('naive-ui')['NDrawer'] NDrawerContent: typeof import('naive-ui')['NDrawerContent'] NDropdown: typeof import('naive-ui')['NDropdown'] + NEmpty: typeof import('naive-ui')['NEmpty'] NForm: typeof import('naive-ui')['NForm'] NFormItem: typeof import('naive-ui')['NFormItem'] NFormItemGi: typeof import('naive-ui')['NFormItemGi'] @@ -56,11 +63,13 @@ declare module 'vue' { NLoadingBarProvider: typeof import('naive-ui')['NLoadingBarProvider'] NMenu: typeof import('naive-ui')['NMenu'] NMessageProvider: typeof import('naive-ui')['NMessageProvider'] + NModal: typeof import('naive-ui')['NModal'] NNotificationProvider: typeof import('naive-ui')['NNotificationProvider'] NPopconfirm: typeof import('naive-ui')['NPopconfirm'] NPopover: typeof import('naive-ui')['NPopover'] NRadio: typeof import('naive-ui')['NRadio'] NRadioGroup: typeof import('naive-ui')['NRadioGroup'] + NScrollbar: typeof import('naive-ui')['NScrollbar'] NSelect: typeof import('naive-ui')['NSelect'] NSpace: typeof import('naive-ui')['NSpace'] NStatistic: typeof import('naive-ui')['NStatistic']