From 7b33ce64bd449e90cde2e1d57cfbf8a724225a8b Mon Sep 17 00:00:00 2001 From: Ben1111 <1575995206@qq.com> Date: Tue, 6 Aug 2024 14:08:47 +0800 Subject: [PATCH] faet(projects): global-search add pinyin-pro history collect --- package.json | 2 +- .../components/search-history.vue | 143 ++++++++++++++ .../global-search/components/search-modal.vue | 174 +++++++++++++++--- src/plugins/iconify.ts | 13 +- src/theme/settings.ts | 3 +- src/typings/app.d.ts | 7 + src/typings/components.d.ts | 1 + src/typings/storage.d.ts | 4 + 8 files changed, 313 insertions(+), 34 deletions(-) create mode 100644 src/layouts/modules/global-search/components/search-history.vue diff --git a/package.json b/package.json index 23808176..ccf19ee4 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,6 @@ "naive-ui": "2.39.0", "nprogress": "0.2.0", "pinia": "2.2.0", - "pinyin-pro": "3.23.1", "print-js": "1.6.0", "swiper": "11.1.5", "tailwind-merge": "2.4.0", @@ -103,6 +102,7 @@ "eslint": "9.8.0", "eslint-plugin-vue": "9.27.0", "lint-staged": "15.2.7", + "pinyin-pro": "3.23.1", "sass": "1.77.8", "simple-git-hooks": "2.11.1", "tsx": "4.16.2", diff --git a/src/layouts/modules/global-search/components/search-history.vue b/src/layouts/modules/global-search/components/search-history.vue new file mode 100644 index 00000000..84173bdc --- /dev/null +++ b/src/layouts/modules/global-search/components/search-history.vue @@ -0,0 +1,143 @@ + + + + + + + 搜索历史 + + + + + {{ (item.i18nKey && $t(item.i18nKey)) || item.label }} + + + + + + + + + + + + 收藏记录 + + + + + + {{ (item.i18nKey && $t(item.i18nKey)) || item.label }} + + + + + + + + + + + + diff --git a/src/layouts/modules/global-search/components/search-modal.vue b/src/layouts/modules/global-search/components/search-modal.vue index 39f18a84..c639ed05 100644 --- a/src/layouts/modules/global-search/components/search-modal.vue +++ b/src/layouts/modules/global-search/components/search-modal.vue @@ -1,5 +1,6 @@ @@ -102,7 +215,7 @@ registerShortcut(); @after-leave="handleClose" > - + @@ -111,8 +224,9 @@ registerShortcut(); - - + + + diff --git a/src/plugins/iconify.ts b/src/plugins/iconify.ts index f58d669b..5c80cd6c 100644 --- a/src/plugins/iconify.ts +++ b/src/plugins/iconify.ts @@ -1,9 +1,18 @@ -import { addAPIProvider, disableCache } from '@iconify/vue'; +import { addAPIProvider, disableCache , addCollection } from '@iconify/vue'; /** Setup the iconify offline */ export function setupIconifyOffline() { const { VITE_ICONIFY_URL } = import.meta.env; - + addCollection({ + prefix: 'soybean', + icons:{ + star:{ + body: '', + width: 20, + height: 20 + } + } + }) if (VITE_ICONIFY_URL) { addAPIProvider('', { resources: [VITE_ICONIFY_URL] }); diff --git a/src/theme/settings.ts b/src/theme/settings.ts index a82fe636..d6d157f0 100644 --- a/src/theme/settings.ts +++ b/src/theme/settings.ts @@ -74,7 +74,8 @@ export const themeSettings: App.Theme.ThemeSetting = { 'base-text': 'rgb(224, 224, 224)' } } - } + }, + menuSearchHistoryMaxValue: 6 }; /** diff --git a/src/typings/app.d.ts b/src/typings/app.d.ts index f3a807f6..7c3d202a 100644 --- a/src/typings/app.d.ts +++ b/src/typings/app.d.ts @@ -109,6 +109,8 @@ declare namespace App { [K in keyof ThemeSettingToken]?: Partial; }; }; + /** menu history max value */ + menuSearchHistoryMaxValue: number } interface OtherColor { @@ -200,6 +202,11 @@ declare namespace App { children?: Menu[]; }; + /** The global search history or collect */ + type SearchHistoryOrCollect = Menu & { + type: 'history' | 'collect'; + }; + type Breadcrumb = Omit & { options?: Breadcrumb[]; }; diff --git a/src/typings/components.d.ts b/src/typings/components.d.ts index 374de604..b81b2189 100644 --- a/src/typings/components.d.ts +++ b/src/typings/components.d.ts @@ -29,6 +29,7 @@ declare module 'vue' { IconIcRoundRefresh: typeof import('~icons/ic/round-refresh')['default'] IconIcRoundRemove: typeof import('~icons/ic/round-remove')['default'] IconIcRoundSearch: typeof import('~icons/ic/round-search')['default'] + IconIonClose: typeof import('~icons/ion/close')['default'] IconLocalActivity: typeof import('~icons/local/activity')['default'] IconLocalBanner: typeof import('~icons/local/banner')['default'] IconLocalCast: typeof import('~icons/local/cast')['default'] diff --git a/src/typings/storage.d.ts b/src/typings/storage.d.ts index 0d52f33c..889e7312 100644 --- a/src/typings/storage.d.ts +++ b/src/typings/storage.d.ts @@ -35,5 +35,9 @@ declare namespace StorageType { layout: UnionKey.ThemeLayoutMode; siderCollapse: boolean; }; + /** The search history */ + searchHistory: App.Global.SearchHistoryOrCollect[] + /** The search collect */ + searchCollect: App.Global.SearchHistoryOrCollect[] } }