Files
dcalc/frontendNew/src/pages/Dcalc/DnfHelper/list.vue
T
2026-05-11 00:32:03 +08:00

85 lines
2.6 KiB
Vue

<script setup lang="ts">
import { computed } from "vue";
import { Button } from "@/components/ui/button";
// import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import {
Card,
CardContent,
CardDescription,
// CardFooter,
CardHeader,
CardTitle,
} from "@/components/ui/card";
import { useDnfHelperStore } from "@/stores/dnfhelper";
import { Grip, RefreshCcw } from "lucide-vue-next";
const props = defineProps<{
list: {
roleId: string;
roleName: string;
roleJob: string;
avatarLink: string;
fame: number;
}[];
}>();
const { list } = toRefs(props);
const helperStore = useDnfHelperStore();
const sortedList = computed(() => {
return [...list.value].sort((left, right) => right.fame - left.fame);
});
const formatFame = (fame: number) => {
return new Intl.NumberFormat("zh-CN").format(fame);
};
</script>
<template>
<header
class="sticky top-0 z-10 flex shrink-0 flex-col gap-3 border-b bg-background/95 px-1 py-2 backdrop-blur md:flex-row md:items-center md:justify-between px-6"
>
<div>
<h1 class="text-lg font-semibold">角色列表</h1>
<p class="text-sm text-muted-foreground">共 {{ sortedList.length }} 个角色</p>
</div>
<div class="flex flex-wrap gap-2">
<Button variant="outline" @click="$router.push('/dcalc/home')"> <Grip /> 选择职业 </Button>
<Button
variant="outline"
:disabled="helperStore.loading"
@click="helperStore.refreshHelperInfo(helperStore.helperInfo?.id)"
>
<RefreshCcw :class="{ 'animate-spin': helperStore.loading }" />
刷新
</Button>
<Button variant="secondary" @click="helperStore.logout">取消绑定</Button>
</div>
</header>
<div class="grid grid-cols-1 gap-4 py-4 px-6 sm:grid-cols-2 xl:grid-cols-4">
<template v-for="item in sortedList" :key="item.roleId">
<Card class="w-full">
<CardHeader class="pb-3">
<CardTitle class="text-base flex">
{{ item.roleName }}
<Button class="ml-auto" size="sm" variant="outline" @click="$router.push('/dcalc/home')"
>导入</Button
>
</CardTitle>
<CardDescription class="flex justify-between">
<span>
{{ item.roleJob }}
</span>
<span>名望: {{ formatFame(item.fame) }}</span>
</CardDescription>
</CardHeader>
<CardContent class="flex items-center justify-center">
<img :src="item.avatarLink" :alt="item.roleName" class="h-40 w-auto rounded" />
</CardContent>
</Card>
</template>
</div>
</template>