From f6c10df351bd481bf709433185e704ba68d9854b Mon Sep 17 00:00:00 2001 From: LazuliKao Date: Tue, 24 Sep 2024 16:54:16 +0800 Subject: [PATCH] update client --- package.json | 5 +- src/pages/freshman/join.astro | 2 +- .../freshman/react/{acontent.tsx => join.tsx} | 0 src/types/active.d.ts | 133 ++++++++++++++++++ src/utils/client.ts | 8 +- 5 files changed, 143 insertions(+), 5 deletions(-) rename src/pages/freshman/react/{acontent.tsx => join.tsx} (100%) create mode 100644 src/types/active.d.ts diff --git a/package.json b/package.json index 6a04d17..f2de77a 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,8 @@ "lint": "eslint", "astro": "astro", "prepare": "husky", - "gen-type": "openapi-typescript http://localhost:4000/openapi-3.0.json -o ./src/types/saturday.d.ts" + "gen-type": "openapi-typescript http://localhost:4000/openapi-3.0.json -o ./src/types/saturday.d.ts", + "active": "openapi-typescript https://active.nbtca.space/openapi.json -o ./src/types/active.d.ts" }, "dependencies": { "@astrojs/react": "^3.3.1", @@ -65,4 +66,4 @@ "lint-staged": { "*.{js,jsx,mjs,ts,tsx,mts,astro}": "eslint --fix" } -} +} \ No newline at end of file diff --git a/src/pages/freshman/join.astro b/src/pages/freshman/join.astro index a11f902..0438a4a 100644 --- a/src/pages/freshman/join.astro +++ b/src/pages/freshman/join.astro @@ -1,7 +1,7 @@ --- import BaseLayout from "../../layouts/BaseLayout.astro" // import { Button } from "@nextui-org/react"; -import ReactChild from "./react/acontent" +import ReactChild from "./react/join.tsx" --- diff --git a/src/pages/freshman/react/acontent.tsx b/src/pages/freshman/react/join.tsx similarity index 100% rename from src/pages/freshman/react/acontent.tsx rename to src/pages/freshman/react/join.tsx diff --git a/src/types/active.d.ts b/src/types/active.d.ts new file mode 100644 index 0000000..a03951c --- /dev/null +++ b/src/types/active.d.ts @@ -0,0 +1,133 @@ +/** + * This file was auto-generated by openapi-typescript. + * Do not make direct changes to the file. + */ + +export interface paths { + "/api/freshman": { + parameters: { + query?: never + header?: never + path?: never + cookie?: never + } + /** 获取新人列表 */ + get: operations["get_FreshmanList"] + put?: never + /** 添加新人 */ + post: operations["post_FreshmanAdd"] + delete?: never + options?: never + head?: never + patch?: never + trace?: never + } +} +export type webhooks = Record +export interface components { + schemas: never + responses: never + parameters: never + requestBodies: never + headers: never + pathItems: never +} +export type $defs = Record +export interface operations { + get_FreshmanList: { + parameters: { + query?: never + header?: never + path?: never + cookie?: never + } + requestBody?: never + responses: { + /** @description Returns a list of tasks */ + 200: { + headers: { + [name: string]: unknown + } + content: { + "application/json": { + success: boolean + list: { + /** @example lorem */ + name: string + /** @example 3240000000 */ + number: string + /** @example 计算机科学与技术 */ + major: string + /** @example 计科2001 */ + class: string + /** @example xxx@qq.com */ + email: string + /** @example 12345678901 */ + phone: string + /** @example 123456789 */ + qq: string + }[] + } + } + } + } + } + post_FreshmanAdd: { + parameters: { + query?: never + header?: never + path?: never + cookie?: never + } + requestBody?: { + content: { + "application/json": { + /** @example lorem */ + name: string + /** @example 3240000000 */ + number: string + /** @example 计算机科学与技术 */ + major: string + /** @example 计科2001 */ + class: string + /** @example xxx@qq.com */ + email: string + /** @example 12345678901 */ + phone: string + /** @example 123456789 */ + qq: string + } + } + } + responses: { + /** @description Returns the created task */ + 200: { + headers: { + [name: string]: unknown + } + content: { + "application/json": { + success: boolean + result?: { + /** @example lorem */ + name: string + /** @example 3240000000 */ + number: string + /** @example 计算机科学与技术 */ + major: string + /** @example 计科2001 */ + class: string + /** @example xxx@qq.com */ + email: string + /** @example 12345678901 */ + phone: string + /** @example 123456789 */ + qq: string + } + error?: string + } + } + } + } + } +} diff --git a/src/utils/client.ts b/src/utils/client.ts index 9908795..2bbdfb8 100644 --- a/src/utils/client.ts +++ b/src/utils/client.ts @@ -1,6 +1,10 @@ import createClient from "openapi-fetch" -import type { paths } from "../types/saturday" +import type { paths as saturdayPaths } from "../types/saturday" +import type { paths as activePaths } from "../types/active" -export const saturdayClient = createClient({ +export const saturdayClient = createClient({ baseUrl: "https://api.nbtca.space/v2/", }) +export const activeClient = createClient({ + baseUrl: "https://active.nbtca.space/", +})