From bd09cb381540993cfa59a3d6fd3b0b908acbe699 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Wed, 28 Sep 2022 14:50:16 +0800 Subject: [PATCH] feat: add global search support (halo-dev/console#623) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /kind feature /milestone 2.0 #### What this PR does / why we need it: 添加全局搜索框支持。 #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/1924 #### Screenshots: image image image #### Special notes for your reviewer: /cc @halo-dev/sig-halo-console 测试方式: 1. 本地 Console 切换到当前 PR 的分支,需要 `pnpm install && pnpm build:packages` 2. 使用 Ctrl + K(Windows/Linux) 或者 Command + K(macOS)调起搜索框 3. 可以使用键盘上/下键(或者 Ctrl + J / Ctrl + K)选择搜索条目,回车键确认选择。 #### Does this PR introduce a user-facing change? ```release-note 后台添加全局搜索的支持 ``` --- package.json | 2 +- .../components/src/components/modal/Modal.vue | 19 +- packages/shared/src/layouts/BasicLayout.vue | 24 +- pnpm-lock.yaml | 26 +- src/App.vue | 22 +- .../global-search/GlobalSearchModal.vue | 456 ++++++++++++++++++ .../contents/attachments/AttachmentList.vue | 32 +- src/modules/contents/comments/module.ts | 1 + src/modules/contents/pages/module.ts | 3 + src/modules/contents/posts/module.ts | 4 + src/modules/dashboard/module.ts | 1 + src/modules/interface/menus/module.ts | 1 + src/modules/interface/themes/module.ts | 1 + src/modules/system/plugins/module.ts | 1 + src/modules/system/roles/module.ts | 1 + src/modules/system/users/module.ts | 1 + 16 files changed, 556 insertions(+), 39 deletions(-) create mode 100644 src/components/global-search/GlobalSearchModal.vue diff --git a/package.json b/package.json index 430bb5475..ac0a1eb79 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "emoji-mart": "^5.2.2", "filepond": "^4.30.4", "floating-vue": "2.0.0-beta.20", + "fuse.js": "^6.6.2", "lodash.clonedeep": "^4.5.0", "lodash.isequal": "^4.5.0", "lodash.merge": "^4.6.2", @@ -55,7 +56,6 @@ "pinia": "^2.0.22", "pretty-bytes": "^6.0.0", "qs": "^6.11.0", - "unsplash-js": "^7.0.15", "uuid": "^8.3.2", "vue": "^3.2.39", "vue-filepond": "^7.0.3", diff --git a/packages/components/src/components/modal/Modal.vue b/packages/components/src/components/modal/Modal.vue index f959657d1..6b8572df0 100644 --- a/packages/components/src/components/modal/Modal.vue +++ b/packages/components/src/components/modal/Modal.vue @@ -11,6 +11,7 @@ const props = withDefaults( fullscreen?: boolean; bodyClass?: string[]; mountToBody?: boolean; + centered?: boolean; }>(), { visible: false, @@ -20,6 +21,7 @@ const props = withDefaults( fullscreen: false, bodyClass: undefined, mountToBody: false, + centered: true, } ); @@ -34,6 +36,7 @@ const modelWrapper = ref(); const wrapperClasses = computed(() => { return { "modal-wrapper-fullscreen": props.fullscreen, + "modal-wrapper-centered": props.centered, }; }); @@ -123,14 +126,15 @@ watch(