diff --git a/src/layouts/modules/global-header/index.vue b/src/layouts/modules/global-header/index.vue index 705b41c6..ae372c49 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(() => {
+ +import { $t } from '@/locales'; + +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 00000000..7259f935 --- /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 00000000..844c7c09 --- /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 00000000..46d954ae --- /dev/null +++ b/src/layouts/modules/global-search/index.vue @@ -0,0 +1,21 @@ + + + + + diff --git a/src/locales/langs/en-us.ts b/src/locales/langs/en-us.ts index 7f6afc3c..3ffc7ebe 100644 --- a/src/locales/langs/en-us.ts +++ b/src/locales/langs/en-us.ts @@ -9,6 +9,7 @@ const local: App.I18n.Schema = { backToHome: 'Back to home', batchDelete: 'Batch Delete', cancel: 'Cancel', + close: 'Close', check: 'Check', columnSetting: 'Column Setting', confirm: 'Confirm', @@ -17,16 +18,19 @@ const local: App.I18n.Schema = { confirmDelete: 'Are you sure you want to delete?', edit: 'Edit', index: 'Index', + keywordSearch: 'Please enter keyword', logout: 'Logout', logoutConfirm: 'Are you sure you want to log out?', lookForward: 'Coming soon', modify: 'Modify', modifySuccess: 'Modify Success', + noData: 'No Data', operate: 'Operate', pleaseCheckValue: 'Please check whether the value is valid', refresh: 'Refresh', reset: 'Reset', search: 'Search', + switch: 'Switch', tip: 'Tip', update: 'Update', updateSuccess: 'Update Success', diff --git a/src/locales/langs/zh-cn.ts b/src/locales/langs/zh-cn.ts index 9b670d04..d22501eb 100644 --- a/src/locales/langs/zh-cn.ts +++ b/src/locales/langs/zh-cn.ts @@ -9,6 +9,7 @@ const local: App.I18n.Schema = { backToHome: '返回首页', batchDelete: '批量删除', cancel: '取消', + close: '关闭', check: '勾选', columnSetting: '列设置', confirm: '确认', @@ -17,16 +18,19 @@ const local: App.I18n.Schema = { confirmDelete: '确认删除吗?', edit: '编辑', index: '序号', + keywordSearch: '请输入关键词搜索', logout: '退出登录', logoutConfirm: '确认退出登录吗?', lookForward: '敬请期待', modify: '修改', modifySuccess: '修改成功', + noData: '无数据', operate: '操作', pleaseCheckValue: '请检查输入的值是否合法', refresh: '刷新', reset: '重置', search: '搜索', + switch: '切换', tip: '提示', update: '更新', updateSuccess: '更新成功', diff --git a/src/store/modules/route/index.ts b/src/store/modules/route/index.ts index 94a374c4..04e41699 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 c7cfb821..4212f7fe 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/app.d.ts b/src/typings/app.d.ts index d4ae3a47..6dcf1ce0 100644 --- a/src/typings/app.d.ts +++ b/src/typings/app.d.ts @@ -255,6 +255,7 @@ declare namespace App { backToHome: string; batchDelete: string; cancel: string; + close: string; check: string; columnSetting: string; confirm: string; @@ -263,16 +264,19 @@ declare namespace App { confirmDelete: string; edit: string; index: string; + keywordSearch: string; logout: string; logoutConfirm: string; lookForward: string; modify: string; modifySuccess: string; + noData: string; operate: string; pleaseCheckValue: string; refresh: string; reset: string; search: string; + switch: string; tip: string; update: string; updateSuccess: string; diff --git a/src/typings/components.d.ts b/src/typings/components.d.ts index 8f0d632f..afeb02d0 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']