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
const replacements: Record<string, string> = {
an: '1', // 将 "an" 替换为 "1"
a: '1', // 将 "a" 替换为 "1"
second: languageOption.second,
seconds: languageOption.seconds,

View file

@ -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<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>
<template>
<div class="container">
<div class="container" :class="ascClass">
<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-submenu">
@ -68,7 +91,7 @@ const orderDescending = () => {
}
/* 筛选 */
.container {
background-color: var(--kungalgame-trans-red-3);
background-color: var(--kungalgame-trans-blue-3);
flex-grow: 1;
border-radius: 5px 0 0 0;
position: relative;
@ -85,8 +108,12 @@ const orderDescending = () => {
position: absolute;
}
.filter {
display: flex;
justify-content: center;
align-items: center;
font-size: 18px;
margin-left: 7px;
color: var(--kungalgame-blue-4);
}
.sort-submenu {
display: none;
@ -141,4 +168,12 @@ const orderDescending = () => {
}
}
}
/* 点击升序后的样式 */
.active {
background-color: var(--kungalgame-trans-red-3);
.filter {
color: var(--kungalgame-red-4);
}
}
</style>

View file

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

View file

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

View file

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

View file

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

View file

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