This commit is contained in:
2026-01-12 03:16:35 +08:00
parent c2dcc53018
commit 5310ff28ae
48 changed files with 1349 additions and 254 deletions

View File

@@ -4,6 +4,7 @@ export type CNBCoreOptions<T = {}> = {
* 对 cnb 界面操作定制模块功能时需要传入 cookie
*/
cookie?: string;
cnb?: CNBCore;
} & T;
export type RequestOptions = {
@@ -18,11 +19,19 @@ export type RequestOptions = {
};
export class CNBCore {
baseURL = 'https://api.cnb.cool';
token: string;
cookie?: string;
public token: string;
public cookie?: string;
constructor(options: CNBCoreOptions) {
this.token = options.token;
this.cookie = options.cookie;
if (options?.cnb) {
if (!options.token) {
this.token = options.cnb.token;
}
if (!options.cookie) {
this.cookie = options.cnb.cookie;
}
}
}
async request({ url, method = 'GET', data, params, headers, body, useCookie, useOrigin }: RequestOptions): Promise<any> {