update about page

This commit is contained in:
lyq 2024-04-25 22:28:42 +08:00
parent 5903e98a67
commit 8c9dde0f68
2 changed files with 73 additions and 12 deletions

41
src/data/otherMembers.ts Normal file
View file

@ -0,0 +1,41 @@
interface Member {
memberId: string
alias: string
avatar: string
profile: string
}
const otherMembers: Member[] = [
{
memberId: undefined,
alias: "鲁冠泽",
profile: "Java, Web。",
avatar: "",
},
{
memberId: undefined,
alias: "江蕾",
profile: "前端。",
avatar: "",
},
{
memberId: undefined,
alias: "黄文轩",
profile: "网安, Linux和C/C++。",
avatar: "",
},
{
memberId: undefined,
alias: "陈学书",
profile: "Mac, 人工智能, Web和流水账。",
avatar: "",
},
{
memberId: undefined,
alias: "章晟玮",
profile: "算法记录。",
avatar: "",
},
]
export default otherMembers

View file

@ -2,29 +2,48 @@
import BaseLayout from "../layouts/BaseLayout.astro"
import { computed } from "vue"
import MemberCard from "../components/MemberCard.astro"
import otherMembers from "../data/otherMembers.ts"
const members: {
memberId: string
alias: string
avatar: string
profile: string
}[] = await fetch("https://api.nbtca.space/v2/members").then(res => {
}[] = await fetch("https://api.nbtca.space/v2/members").then((res) => {
return res.json()
})
otherMembers.forEach((member) => {
members.push(member)
})
// memberId is like "3232323233", the second and third number is the year of the member
const memberGroupByYear = computed(() => {
const group = members
// TODO delete the test member
.filter(member => member.memberId != "0000000000" && member.memberId != "2333333333")
.reduce((acc, cur) => {
const year = parseInt("20" + cur.memberId.slice(1, 3))
if (!acc[year]) {
acc[year] = []
}
acc[year].push(cur)
return acc
}, {} as Record<string, typeof members>)
.filter(
(member) =>
member.memberId != "0000000000" && member.memberId != "2333333333"
)
.reduce(
(acc, cur) => {
if (!cur.memberId) {
const year = "往届"
if (!acc[year]) {
acc[year] = []
}
acc[year].push(cur)
return acc
}
const year = parseInt("20" + cur.memberId.slice(1, 3))
if (!acc[year]) {
acc[year] = []
}
acc[year].push(cur)
return acc
},
{} as Record<string, typeof members>
)
return group
})
---
@ -32,17 +51,18 @@ const memberGroupByYear = computed(() => {
<BaseLayout primaryTitle="关于">
<section class="pb-20 bg-[#f5f5f7]">
<div class="section-content">
<!-- <div class="text-[32px] leading-[1.125] font-bold py-6">友情链接</div> -->
<div class="text-[32px] leading-[1.125] font-bold py-6">协会成员</div>
<div>
{
Object.keys(memberGroupByYear.value)
.sort((a, b) => parseInt(b) - parseInt(a))
.map(year => {
.map((year) => {
return (
<div class="py-4 first:pt-2">
<div class="text-[24px] font-bold pb-2">{year}</div>
<div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-x-6 gap-y-8">
{memberGroupByYear.value[year].map(member => (
{memberGroupByYear.value[year].map((member) => (
<MemberCard member={member} />
))}
</div>