feat: home iconMap

This commit is contained in:
KUN1007 2023-10-04 01:59:10 +08:00
parent cc4a69826f
commit 5cee4cd046
7 changed files with 51 additions and 7 deletions

View file

@ -42,6 +42,7 @@ function replaceTimeUnits(input: string, language: string) {
(languageOptions as Record<string, any>)[language] || languageOptions.en (languageOptions as Record<string, any>)[language] || languageOptions.en
const replacements: Record<string, string> = { const replacements: Record<string, string> = {
an: '1', // 将 "an" 替换为 "1"
a: '1', // 将 "a" 替换为 "1" a: '1', // 将 "a" 替换为 "1"
second: languageOption.second, second: languageOption.second,
seconds: languageOption.seconds, seconds: languageOption.seconds,

View file

@ -6,6 +6,10 @@ import { storeToRefs } from 'pinia'
// //
import { navSortItem } from './navSortItem' import { navSortItem } from './navSortItem'
import { ref } from 'vue'
//
const ascClass = ref('')
const { sortField, sortOrder } = storeToRefs(useKUNGalgameHomeStore()) const { sortField, sortOrder } = storeToRefs(useKUNGalgameHomeStore())
@ -17,18 +21,37 @@ const handleSortByField = (field: string) => {
const orderAscending = () => { const orderAscending = () => {
useKUNGalgameHomeStore().resetPageStatus() useKUNGalgameHomeStore().resetPageStatus()
sortOrder.value = 'asc' sortOrder.value = 'asc'
//
ascClass.value = 'active'
} }
const orderDescending = () => { const orderDescending = () => {
useKUNGalgameHomeStore().resetPageStatus() useKUNGalgameHomeStore().resetPageStatus()
sortOrder.value = 'desc' sortOrder.value = 'desc'
ascClass.value = ''
}
const iconMap: Record<string, string> = {
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)
} }
</script> </script>
<template> <template>
<div class="container"> <div class="container" :class="ascClass">
<span>{{ $tm('mainPage.header.filter') }}</span> <span>{{ $tm('mainPage.header.filter') }}</span>
<Icon class="filter" icon="bi:sort-down" /> <span class="filter">
<Icon v-if="isSortField()" :icon="iconMap[sortField]" />
</span>
<!-- 排序的二级菜单 --> <!-- 排序的二级菜单 -->
<div class="sort-container"> <div class="sort-container">
<div class="sort-submenu"> <div class="sort-submenu">
@ -68,7 +91,7 @@ const orderDescending = () => {
} }
/* 筛选 */ /* 筛选 */
.container { .container {
background-color: var(--kungalgame-trans-red-3); background-color: var(--kungalgame-trans-blue-3);
flex-grow: 1; flex-grow: 1;
border-radius: 5px 0 0 0; border-radius: 5px 0 0 0;
position: relative; position: relative;
@ -85,8 +108,12 @@ const orderDescending = () => {
position: absolute; position: absolute;
} }
.filter { .filter {
display: flex;
justify-content: center;
align-items: center;
font-size: 18px; font-size: 18px;
margin-left: 7px; margin-left: 7px;
color: var(--kungalgame-blue-4);
} }
.sort-submenu { .sort-submenu {
display: none; display: none;
@ -141,4 +168,12 @@ const orderDescending = () => {
} }
} }
} }
/* 点击升序后的样式 */
.active {
background-color: var(--kungalgame-trans-red-3);
.filter {
color: var(--kungalgame-red-4);
}
}
</style> </style>

View file

@ -8,13 +8,13 @@ interface Sort {
export const navSortItem: Sort[] = [ export const navSortItem: Sort[] = [
{ {
index: 1, index: 1,
icon: 'line-md:rotate-270', icon: 'bi:sort-down',
name: 'updated', name: 'updated',
sortField: 'updated', sortField: 'updated',
}, },
{ {
index: 2, index: 2,
icon: 'svg-spinners:clock', icon: 'eos-icons:hourglass',
name: 'time', name: 'time',
sortField: 'time', sortField: 'time',
}, },

View file

@ -58,7 +58,7 @@ onMounted(async () => {
<div class="topic"> <div class="topic">
<div class="title">{{ kun.title }}</div> <div class="title">{{ kun.title }}</div>
<div class="new"> <div class="new">
<Icon icon="svg-spinners:clock" /> <Icon icon="eos-icons:hourglass" />
<span>{{ <span>{{
formatTimeDifference( formatTimeDifference(
kun.time, kun.time,

View file

@ -14,7 +14,12 @@ export const asideNavItem: navItem[] = [
icon: 'line-md:arrows-vertical', icon: 'line-md:arrows-vertical',
name: 'floorSort', name: 'floorSort',
}, },
{ index: 2, sortField: 'time', icon: 'svg-spinners:clock', name: 'timeSort' }, {
index: 2,
sortField: 'time',
icon: 'eos-icons:hourglass',
name: 'timeSort',
},
{ {
index: 3, index: 3,
sortField: 'likes', sortField: 'likes',

View file

@ -104,6 +104,7 @@ defineProps<{
@media (max-width: 700px) { @media (max-width: 700px) {
.kungalgame-topic-content { .kungalgame-topic-content {
width: 100%; width: 100%;
margin-top: 0;
} }
} }
</style> </style>

View file

@ -148,6 +148,8 @@ const handleClickUpvote = async () => {
props.master.uid props.master.uid
) )
console.log(res.code)
if (res.code === 200) { if (res.code === 200) {
// //
actions.upvotes.length++ actions.upvotes.length++