update
This commit is contained in:
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user