From b1d024f734b9d5fe713e0ac8429157202d83cf25 Mon Sep 17 00:00:00 2001 From: n0099 Date: Fri, 15 Mar 2024 07:36:58 +0800 Subject: [PATCH] - `shared/fontAwesome.ts` in favor of import each icons from `@fortawesome/free-*-svg-icons` and reference them via `` for tree-shakeing + type `Nav` to share common parts of types `Route` & `DropDown` @ `` * replace the icon for timestamps with `regular` variant @ `Post/badges/` @ components * put imports from `@fortawesome` and `luxon` before `lodash` & `echarts` but after `*/*vue*{,/**}` for rule `import/order` @ .eslintrc.cjs @ fe --- fe/.eslintrc.cjs | 7 +++-- fe/src/components/GlobalNavBar.vue | 15 ++++++---- fe/src/components/Post/PostNav.vue | 7 +++-- .../Post/badges/BadgePostCommon.vue | 10 ++++--- .../components/Post/badges/BadgePostTime.vue | 7 +++-- .../components/Post/queryForm/QueryForm.vue | 9 +++--- .../Post/renderers/list/ReplyItem.vue | 4 ++- .../Post/renderers/list/ThreadItem.vue | 16 +++++----- fe/src/components/widgets/TimeRange.vue | 2 +- fe/src/main.ts | 4 --- fe/src/shared/fontAwesome.ts | 30 ------------------- fe/src/views/BilibiliVote.vue | 7 +++-- 12 files changed, 50 insertions(+), 68 deletions(-) delete mode 100644 fe/src/shared/fontAwesome.ts diff --git a/fe/.eslintrc.cjs b/fe/.eslintrc.cjs index 7757f695..0d0a1580 100644 --- a/fe/.eslintrc.cjs +++ b/fe/.eslintrc.cjs @@ -36,10 +36,13 @@ const eslintPluginImport = { // as of eslint-plugin-import@2.29.1 { pattern: '@/**', group: 'internal', position: 'before' }, { pattern: 'vue*', group: 'external', position: 'before' }, // vue vue-router { pattern: 'pinia', group: 'external', position: 'before' }, - { pattern: '*vue*{,/**}', group: 'external', position: 'before' }, // ant-design-vue @vueuse/core - { pattern: '*/*vue*{,/**}', group: 'external', position: 'before' }, // @unhead/vue @fortawesome/vue-fontawesome + { pattern: '@fortawesome/vue-fontawesome', group: 'external', position: 'after' }, // fontawesome + { pattern: '@fortawesome{,/**}', group: 'external', position: 'after' }, // fontawesome + { pattern: 'luxon{,/**}', group: 'external', position: 'after' }, { pattern: 'lodash{,-{es,fp}}{,/**}', group: 'external', position: 'after' }, // lodash { pattern: 'echarts{,/**}', group: 'external', position: 'after' }, + { pattern: '*vue*{,/**}', group: 'external', position: 'before' }, // ant-design-vue @vueuse/core + { pattern: '*/*vue*{,/**}', group: 'external', position: 'before' }, // @unhead/vue @fortawesome/vue-fontawesome @tanstack/vue-query ], pathGroupsExcludedImportTypes: [], // https://github.com/import-js/eslint-plugin-import/issues/2897 distinctGroup: false, diff --git a/fe/src/components/GlobalNavBar.vue b/fe/src/components/GlobalNavBar.vue index 2bc6eb2c..10e425b4 100644 --- a/fe/src/components/GlobalNavBar.vue +++ b/fe/src/components/GlobalNavBar.vue @@ -37,24 +37,27 @@ import { reactive, watch } from 'vue'; import { RouterLink, useRoute } from 'vue-router'; import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'; +import type { IconDefinition } from '@fortawesome/free-solid-svg-icons'; +import { faCommentDots, faPaperPlane, faSearch, faUsers } from '@fortawesome/free-solid-svg-icons'; const route = useRoute(); const envInstanceName = import.meta.env.VITE_INSTANCE_NAME; -interface Route { route: string, title: string, icon?: string, isActive?: boolean } -interface DropDown { title: string, icon: string, routes: Route[], isActive?: boolean } +interface Nav { title: string, icon?: IconDefinition, isActive?: boolean } +interface Route extends Nav { route: string } +interface DropDown extends Nav { routes: Route[], icon: IconDefinition } const navs = reactive>([ { title: '查询', - icon: 'search', + icon: faSearch, routes: [ - { route: 'post', title: '帖子', icon: 'comment-dots' }, - { route: 'user', title: '用户', icon: 'users' } + { route: 'post', title: '帖子', icon: faCommentDots }, + { route: 'user', title: '用户', icon: faUsers } ] }, { title: '专题', - icon: 'paper-plane', + icon: faPaperPlane, routes: [ { route: 'bilibiliVote', title: 'bilibili吧公投' } ] diff --git a/fe/src/components/Post/PostNav.vue b/fe/src/components/Post/PostNav.vue index 460867e3..f900db23 100644 --- a/fe/src/components/Post/PostNav.vue +++ b/fe/src/components/Post/PostNav.vue @@ -35,8 +35,8 @@ }" class="post-nav-expand col-auto align-items-center d-flex vh-100 sticky-top border-light-subtle"> - - + + @@ -53,8 +53,9 @@ import { useRoute, useRouter } from 'vue-router'; import { useToggle } from '@vueuse/core'; import { Menu, MenuItem, SubMenu } from 'ant-design-vue'; import type { MenuClickEventHandler } from 'ant-design-vue/lib/menu/src/interface'; -import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'; import scrollIntoView from 'scroll-into-view-if-needed'; +import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'; +import { faAngleLeft, faAngleRight } from '@fortawesome/free-solid-svg-icons'; import * as _ from 'lodash-es'; const props = defineProps<{ postPages: Array }>(); diff --git a/fe/src/components/Post/badges/BadgePostCommon.vue b/fe/src/components/Post/badges/BadgePostCommon.vue index 917c99c5..68b43e50 100644 --- a/fe/src/components/Post/badges/BadgePostCommon.vue +++ b/fe/src/components/Post/badges/BadgePostCommon.vue @@ -4,7 +4,7 @@ :to="{ hash: `#${postIDKey === 'tid' ? 't' : ''}${props.post[props.postIDKey]}` }" :data-tippy-content="`跳至本${postTypeText}链接`" class="badge bg-light rounded-pill link-dark"> - + - + - + - + @@ -37,6 +37,8 @@ import type { Pid, Post, PostIDOf, PostTypeTextOf, Spid, Tid, UnixTimestamp } fr import { tiebaPostLink } from '@/shared'; import { RouterLink } from 'vue-router'; import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'; +import { faClock } from '@fortawesome/free-regular-svg-icons'; +import { faArrowUpRightFromSquare, faHashtag, faLink } from '@fortawesome/free-solid-svg-icons'; import { DateTime } from 'luxon'; // https://github.com/vuejs/language-tools/issues/3267 diff --git a/fe/src/components/Post/badges/BadgePostTime.vue b/fe/src/components/Post/badges/BadgePostTime.vue index 3e1911d9..907fa246 100644 --- a/fe/src/components/Post/badges/BadgePostTime.vue +++ b/fe/src/components/Post/badges/BadgePostTime.vue @@ -13,16 +13,16 @@ - + - + - + @@ -42,6 +42,7 @@ import { postTypeText, undefinedOr } from '@/shared'; import { computed } from 'vue'; import { createReusableTemplate } from '@vueuse/core'; import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'; +import { faAnglesUp, faChevronDown, faChevronUp } from '@fortawesome/free-solid-svg-icons'; import { DateTime } from 'luxon'; defineOptions({ inheritAttrs: false }); diff --git a/fe/src/components/Post/queryForm/QueryForm.vue b/fe/src/components/Post/queryForm/QueryForm.vue index 4c3d626b..1bd2d248 100644 --- a/fe/src/components/Post/queryForm/QueryForm.vue +++ b/fe/src/components/Post/queryForm/QueryForm.vue @@ -4,7 +4,7 @@
- +