update client

This commit is contained in:
LazuliKao 2024-09-24 16:54:16 +08:00
parent 418124ceb0
commit f6c10df351
5 changed files with 143 additions and 5 deletions

View file

@ -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"
}
}
}

View file

@ -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"
---
<BaseLayout title="Welcome to Astro.">

133
src/types/active.d.ts vendored Normal file
View file

@ -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<string, never>
export interface components {
schemas: never
responses: never
parameters: never
requestBodies: never
headers: never
pathItems: never
}
export type $defs = Record<string, never>
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
}
}
}
}
}
}

View file

@ -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<paths>({
export const saturdayClient = createClient<saturdayPaths>({
baseUrl: "https://api.nbtca.space/v2/",
})
export const activeClient = createClient<activePaths>({
baseUrl: "https://active.nbtca.space/",
})