fix(admin): admin管理页面优化,增加排序过滤等

This commit is contained in:
sophie committed 2026-07-10 14:10:49 +08:00
1 parent 0939aeb0d8
commit fc843905d1
31 files changed
+1090 -671

No files matched your search

@@ -0,0 +1,62 @@
/**
* shared/components/SortableTableHeader.vue
* 用途:可点击的表格排序表头(文案 + 升/降/未排序图标)。
* 依赖:lucide 图标、common.sort i18n、table-sort 类型。
* 逻辑:管理端表格 th 内使用;点击 emit sort,由 useTableSort.toggleSort 处理。
*/
<script setup lang="ts" generic="K extends string">
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import { ArrowDown, ArrowUp, ArrowUpDown } from 'lucide-vue-next';
import type { SortDir } from '@/shared/utils/table-sort';
const props = withDefaults(
defineProps<{
/** 本列表头对应的列键 */
columnKey: K;
/** 表头展示文案 */
label: string;
/** 当前激活的排序列 */
activeKey?: K;
/** 当前排序方向 */
direction?: SortDir;
/** 对齐方式 */
align?: 'left' | 'right';
}>(),
{
direction: 'asc',
align: 'left',
},
);
const emit = defineEmits<{
sort: [key: K];
}>();
const { t } = useI18n();
const isActive = computed(() => props.activeKey === props.columnKey);
/**
* 无障碍 title:标明未排序 / 升序 / 降序。
*/
const title = computed(() => {
if (!isActive.value) return t('common.sort.unsorted');
return props.direction === 'asc' ? t('common.sort.asc') : t('common.sort.desc');
});
</script>
<template>
<button
type="button"
class="inline-flex items-center gap-1.5 hover:text-primary transition-colors"
:class="align === 'right' ? 'ml-auto' : ''"
:title="title"
@click="emit('sort', columnKey)"
>
<span>{{ label }}</span>
<ArrowUp v-if="isActive && direction === 'asc'" class="w-3.5 h-3.5 text-brand-600" />
<ArrowDown v-else-if="isActive && direction === 'desc'" class="w-3.5 h-3.5 text-brand-600" />
<ArrowUpDown v-else class="w-3.5 h-3.5 opacity-40" />
</button>
</template>