mirror of
https://github.com/m1ngsama/FUJI.git
synced 2025-12-24 10:51:27 +00:00
Merge branch 'dev' of https://github.com/nbtca/Home into dev
This commit is contained in:
commit
4f94c77dbe
8 changed files with 193 additions and 32 deletions
|
|
@ -1,11 +1,10 @@
|
||||||
---
|
---
|
||||||
import BaseLayout from "../../layouts/BaseLayout.astro"
|
import BaseLayout from "../../layouts/BaseLayout.astro"
|
||||||
// import { Button } from "@nextui-org/react";
|
import ReactChild from "./react/join.tsx";
|
||||||
import ReactChild from "./react/join.tsx"
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<BaseLayout title="Welcome to Astro.">
|
<BaseLayout title="加入我们">
|
||||||
<main>
|
<main>
|
||||||
<ReactChild client:visible />
|
<ReactChild client:load />
|
||||||
</main>
|
</main>
|
||||||
</BaseLayout>
|
</BaseLayout>
|
||||||
|
|
|
||||||
10
src/pages/freshman/list.astro
Normal file
10
src/pages/freshman/list.astro
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
import BaseLayout from "../../layouts/BaseLayout.astro"
|
||||||
|
import ReactChild from "./react/list.tsx";
|
||||||
|
---
|
||||||
|
|
||||||
|
<BaseLayout title="加入我们">
|
||||||
|
<main>
|
||||||
|
<ReactChild client:load />
|
||||||
|
</main>
|
||||||
|
</BaseLayout>
|
||||||
|
|
@ -1,27 +1,97 @@
|
||||||
import { Button } from "@nextui-org/react"
|
import { useState } from "react"
|
||||||
|
import { Button, Input, Card, CardBody, CardFooter } from "@nextui-org/react"
|
||||||
import { activeClient } from "../../../utils/client"
|
import { activeClient } from "../../../utils/client"
|
||||||
|
|
||||||
export default function Page() {
|
export default function JoinForm() {
|
||||||
|
const [formData, setFormData] = useState({
|
||||||
|
name: "",
|
||||||
|
class: "",
|
||||||
|
number: "",
|
||||||
|
major: "",
|
||||||
|
phone: "",
|
||||||
|
qq: "",
|
||||||
|
email: "",
|
||||||
|
})
|
||||||
|
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
const { name, value } = e.target
|
||||||
|
setFormData(prevData => ({
|
||||||
|
...prevData,
|
||||||
|
[name]: value,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
const handleSubmit = async () => {
|
||||||
|
try {
|
||||||
|
await activeClient.freshman.postFreshmanAdd({
|
||||||
|
requestBody: formData,
|
||||||
|
})
|
||||||
|
alert("提交成功! 后续请加群获取!")
|
||||||
|
window.location.href = "/about"
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.error("Error submitting form:", error)
|
||||||
|
alert("Failed to submit form.")
|
||||||
|
}
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Button
|
<form>
|
||||||
onClick={() => {
|
<Card>
|
||||||
// 提交表单
|
<CardBody>
|
||||||
activeClient.freshman.postFreshmanAdd({
|
<Input
|
||||||
requestBody: {
|
name="name"
|
||||||
class: "1",
|
placeholder="姓名"
|
||||||
name: "1",
|
value={formData.name}
|
||||||
phone: "1",
|
onChange={handleChange}
|
||||||
qq: "1",
|
required
|
||||||
email: "1",
|
/>
|
||||||
number: "1",
|
<Input
|
||||||
major: "1",
|
name="class"
|
||||||
},
|
placeholder="班级"
|
||||||
})
|
value={formData.class}
|
||||||
}}
|
onChange={handleChange}
|
||||||
>
|
required
|
||||||
提交表单
|
/>
|
||||||
</Button>
|
<Input
|
||||||
|
name="number"
|
||||||
|
placeholder="学号"
|
||||||
|
value={formData.number}
|
||||||
|
onChange={handleChange}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<Input
|
||||||
|
name="major"
|
||||||
|
placeholder="专业"
|
||||||
|
value={formData.major}
|
||||||
|
onChange={handleChange}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<Input
|
||||||
|
name="phone"
|
||||||
|
placeholder="电话"
|
||||||
|
value={formData.phone}
|
||||||
|
onChange={handleChange}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<Input
|
||||||
|
name="qq"
|
||||||
|
placeholder="QQ"
|
||||||
|
value={formData.qq}
|
||||||
|
onChange={handleChange}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<Input
|
||||||
|
name="email"
|
||||||
|
placeholder="邮箱"
|
||||||
|
value={formData.email}
|
||||||
|
onChange={handleChange}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</CardBody>
|
||||||
|
<CardFooter>
|
||||||
|
<Button onClick={handleSubmit}>提交表单</Button>
|
||||||
|
</CardFooter>
|
||||||
|
</Card>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
61
src/pages/freshman/react/list.tsx
Normal file
61
src/pages/freshman/react/list.tsx
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
import {
|
||||||
|
// Button,
|
||||||
|
// Input,
|
||||||
|
Card,
|
||||||
|
CardBody,
|
||||||
|
CardFooter,
|
||||||
|
// PaginationItem,
|
||||||
|
} from "@nextui-org/react"
|
||||||
|
import {
|
||||||
|
activeClient,
|
||||||
|
type GetFreshmanListResponse,
|
||||||
|
} from "../../../utils/client"
|
||||||
|
// activeClient.freshman.getFreshmanList();
|
||||||
|
import { useEffect, useState } from "react"
|
||||||
|
// import { Pagination } from "@nextui-org/react";
|
||||||
|
const FreshmanList = () => {
|
||||||
|
const [freshmen, setFreshmen] = useState<GetFreshmanListResponse>({
|
||||||
|
list: [],
|
||||||
|
total: 0,
|
||||||
|
})
|
||||||
|
const [currentPage] = useState(1) // setCurrentPage
|
||||||
|
useEffect(() => {
|
||||||
|
const fetchFreshmen = async () => {
|
||||||
|
const result = await activeClient.freshman.getFreshmanList({
|
||||||
|
page: currentPage,
|
||||||
|
})
|
||||||
|
setFreshmen(result)
|
||||||
|
}
|
||||||
|
fetchFreshmen()
|
||||||
|
}, [])
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Card>
|
||||||
|
<CardBody>
|
||||||
|
{freshmen.list.map(freshman => (
|
||||||
|
<div key={freshman.number}>
|
||||||
|
<div>{freshman.name}</div>
|
||||||
|
<div>{freshman.number}</div>
|
||||||
|
<div>{freshman.major}</div>
|
||||||
|
<div>{freshman.class}</div>
|
||||||
|
<div>{freshman.email}</div>
|
||||||
|
<div>{freshman.phone}</div>
|
||||||
|
<div>{freshman.qq}</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</CardBody>
|
||||||
|
<CardFooter>
|
||||||
|
{/* <PaginationItem
|
||||||
|
// count={Math.ceil(freshmen.total / ITEMS_PER_PAGE)}
|
||||||
|
page={currentPage}
|
||||||
|
onChange={(page) => {
|
||||||
|
setCurrentPage(page);
|
||||||
|
}}
|
||||||
|
/> */}
|
||||||
|
</CardFooter>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default FreshmanList
|
||||||
|
|
@ -4,10 +4,12 @@ import Tile from "../layouts/Tile.astro"
|
||||||
import MoreTile from "../layouts/MoreTile.astro"
|
import MoreTile from "../layouts/MoreTile.astro"
|
||||||
const allPosts = await Astro.glob("../pages/posts/*.md")
|
const allPosts = await Astro.glob("../pages/posts/*.md")
|
||||||
const Blogs = await Astro.glob("../pages/posts/blogs/**/*.md")
|
const Blogs = await Astro.glob("../pages/posts/blogs/**/*.md")
|
||||||
allPosts.sort(
|
allPosts.sort((a, b) => {
|
||||||
(a, b) =>
|
if ((a.frontmatter.title as string).startsWith("计算机协会入社指南")) {
|
||||||
Date.parse(b.frontmatter.pubDate) - Date.parse(a.frontmatter.pubDate),
|
return -99999999999
|
||||||
)
|
}
|
||||||
|
return Date.parse(b.frontmatter.pubDate) - Date.parse(a.frontmatter.pubDate)
|
||||||
|
})
|
||||||
|
|
||||||
Blogs.sort(
|
Blogs.sort(
|
||||||
(a, b) =>
|
(a, b) =>
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import type { BaseHttpRequest } from "./core/BaseHttpRequest";
|
||||||
import type {
|
import type {
|
||||||
PostFreshmanAddData,
|
PostFreshmanAddData,
|
||||||
PostFreshmanAddResponse,
|
PostFreshmanAddResponse,
|
||||||
|
GetFreshmanListData,
|
||||||
GetFreshmanListResponse,
|
GetFreshmanListResponse,
|
||||||
} from "./types.gen";
|
} from "./types.gen";
|
||||||
|
|
||||||
|
|
@ -15,7 +16,7 @@ export class FreshmanService {
|
||||||
* 添加新人
|
* 添加新人
|
||||||
* @param data The data for the request.
|
* @param data The data for the request.
|
||||||
* @param data.requestBody
|
* @param data.requestBody
|
||||||
* @returns unknown Returns the created task
|
* @returns unknown 返回创建结果
|
||||||
* @throws ApiError
|
* @throws ApiError
|
||||||
*/
|
*/
|
||||||
public postFreshmanAdd(
|
public postFreshmanAdd(
|
||||||
|
|
@ -31,13 +32,23 @@ export class FreshmanService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取新人列表
|
* 获取新人列表
|
||||||
* @returns unknown Returns a list of tasks
|
* @param data The data for the request.
|
||||||
|
* @param data.page 页码
|
||||||
|
* @returns unknown 返回列表
|
||||||
* @throws ApiError
|
* @throws ApiError
|
||||||
*/
|
*/
|
||||||
public getFreshmanList(): CancelablePromise<GetFreshmanListResponse> {
|
public getFreshmanList(
|
||||||
|
data: GetFreshmanListData = {},
|
||||||
|
): CancelablePromise<GetFreshmanListResponse> {
|
||||||
return this.httpRequest.request({
|
return this.httpRequest.request({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: "/api/freshman",
|
url: "/api/freshman",
|
||||||
|
query: {
|
||||||
|
page: data.page,
|
||||||
|
},
|
||||||
|
errors: {
|
||||||
|
500: "服务器错误",
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,14 @@ export type PostFreshmanAddResponse = {
|
||||||
error?: string;
|
error?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type GetFreshmanListData = {
|
||||||
|
/**
|
||||||
|
* 页码
|
||||||
|
*/
|
||||||
|
page?: number;
|
||||||
|
};
|
||||||
|
|
||||||
export type GetFreshmanListResponse = {
|
export type GetFreshmanListResponse = {
|
||||||
success: boolean;
|
|
||||||
list: Array<{
|
list: Array<{
|
||||||
name: string;
|
name: string;
|
||||||
number: string;
|
number: string;
|
||||||
|
|
@ -37,4 +43,5 @@ export type GetFreshmanListResponse = {
|
||||||
phone: string;
|
phone: string;
|
||||||
qq: string;
|
qq: string;
|
||||||
}>;
|
}>;
|
||||||
|
total: number;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -11,3 +11,4 @@ export const saturdayClient = createClient<saturdayPaths>({
|
||||||
export const activeClient = new ApiClient({
|
export const activeClient = new ApiClient({
|
||||||
BASE: "/active",
|
BASE: "/active",
|
||||||
})
|
})
|
||||||
|
export * from "./active/types.gen"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue