From f560a7dd46a50bb6e86ea04e3c6ed8586ef21d65 Mon Sep 17 00:00:00 2001 From: KUN1007 Date: Wed, 4 Oct 2023 01:59:10 +0800 Subject: [PATCH] feat: home iconMap --- src/utils/formatTime.ts | 1 + .../article/components/header/SortTopic.vue | 41 +++++++++++++++++-- .../article/components/header/navSortItem.ts | 4 +- .../Home/content/aside/components/Topic.vue | 2 +- .../topic/aside/components/asideNavItem.ts | 7 +++- src/views/topic/components/Content.vue | 1 + src/views/topic/components/MasterFooter.vue | 2 + 7 files changed, 51 insertions(+), 7 deletions(-) diff --git a/src/utils/formatTime.ts b/src/utils/formatTime.ts index b1054135..9e00515c 100644 --- a/src/utils/formatTime.ts +++ b/src/utils/formatTime.ts @@ -42,6 +42,7 @@ function replaceTimeUnits(input: string, language: string) { (languageOptions as Record)[language] || languageOptions.en const replacements: Record = { + an: '1', // 将 "an" 替换为 "1" a: '1', // 将 "a" 替换为 "1" second: languageOption.second, seconds: languageOption.seconds, diff --git a/src/views/Home/content/article/components/header/SortTopic.vue b/src/views/Home/content/article/components/header/SortTopic.vue index 3bbbdcb1..3a8bfe8a 100644 --- a/src/views/Home/content/article/components/header/SortTopic.vue +++ b/src/views/Home/content/article/components/header/SortTopic.vue @@ -6,6 +6,10 @@ import { storeToRefs } from 'pinia' // 导入排序列表的字段 import { navSortItem } from './navSortItem' +import { ref } from 'vue' + +// 升序和降序的样式 +const ascClass = ref('') const { sortField, sortOrder } = storeToRefs(useKUNGalgameHomeStore()) @@ -17,18 +21,37 @@ const handleSortByField = (field: string) => { const orderAscending = () => { useKUNGalgameHomeStore().resetPageStatus() sortOrder.value = 'asc' + // 更改样式 + ascClass.value = 'active' } const orderDescending = () => { useKUNGalgameHomeStore().resetPageStatus() sortOrder.value = 'desc' + ascClass.value = '' +} + +const iconMap: Record = { + updated: 'bi:sort-down', + time: 'eos-icons:hourglass', + popularity: 'bi:fire', + views: 'ic:outline-remove-red-eye', + likes: 'line-md:thumbs-up-twotone', + replies: 'ri:reply-line', + comments: 'fa-regular:comment-dots', +} + +const isSortField = () => { + return Object.keys(iconMap).includes(sortField.value) }