初始化模版工程

This commit is contained in:
Cloud Bot
2026-03-20 07:33:46 +00:00
commit 23717e0ecd
386 changed files with 51675 additions and 0 deletions

60
http/index.ts Normal file
View File

@@ -0,0 +1,60 @@
import type { HttpDefine, HttpInjectInfo } from './type'
import { http } from './http'
export class HTTPClient {
base: HttpDefine
inject: HttpInjectInfo
constructor(base: HttpDefine, inject?: HttpInjectInfo) {
this.base = base
this.inject = inject || {}
}
request<R = any>(config: HttpDefine): Promise<R> {
return http({ ...this.base, ...config }, this.inject)
}
get<R = any>(url: string, query?: any, config?: HttpDefine): Promise<R> {
return this.request({ ...config, url, method: 'get', query })
}
delete<R = any>(url: string, query?: any, config?: HttpDefine): Promise<R> {
return this.request({ ...config, url, method: 'delete', query })
}
head<R = any>(url: string, config?: HttpDefine): Promise<R> {
return this.request({ ...config, url, method: 'head' })
}
options<R = any>(url: string, config?: HttpDefine): Promise<R> {
return this.request({ ...config, url, method: 'options' })
}
post<R = any>(url: string, body?: any, config?: HttpDefine): Promise<R> {
return this.request({
...config,
url,
method: 'post',
body,
})
}
put<R = any>(url: string, body?: any, config?: HttpDefine): Promise<R> {
return this.request({
...config,
url,
method: 'put',
body,
})
}
patch<R = any>(url: string, body?: any, config?: HttpDefine): Promise<R> {
return this.request({
...config,
url,
method: 'patch',
body,
})
}
}