更新版本号至0.0.15,并优化CNB和Workspace类的构造函数以支持更多选项
This commit is contained in:
22
src/index.ts
22
src/index.ts
@@ -21,21 +21,23 @@ export class CNB extends CNBCore {
|
||||
mission!: Mission;
|
||||
ai!: AiBase;
|
||||
constructor(options: CNBOptions) {
|
||||
super({ token: options.token, cookie: options.cookie, cnb: options.cnb });
|
||||
super({ ...options, token: options.token, cookie: options.cookie, cnb: options.cnb });
|
||||
this.init(options);
|
||||
}
|
||||
init(cnbOptions?: CNBOptions) {
|
||||
const token = this.token;
|
||||
const cookie = this.cookie;
|
||||
const options = { token, cookie };
|
||||
this.workspace = new Workspace(options.token);
|
||||
this.knowledgeBase = new KnowledgeBase({ token: options.token, cookie: options.cookie });
|
||||
this.repo = new Repo({ token: options.token, cookie: options.cookie });
|
||||
this.user = new User({ token: options.token, cookie: options.cookie });
|
||||
this.build = new Build({ token: options.token, cookie: options.cookie });
|
||||
this.issue = new Issue({ token: options.token, cookie: options.cookie });
|
||||
this.mission = new Mission({ token: options.token, cookie: options.cookie });
|
||||
this.ai = new AiBase({ token: options.token, cookie: options.cookie });
|
||||
const cors = cnbOptions?.cors || {}
|
||||
const cnb = cnbOptions?.cnb
|
||||
const options = { token, cookie, cors, cnb };
|
||||
this.workspace = new Workspace(options);
|
||||
this.knowledgeBase = new KnowledgeBase(options);
|
||||
this.repo = new Repo(options);
|
||||
this.user = new User(options);
|
||||
this.build = new Build(options);
|
||||
this.issue = new Issue(options);
|
||||
this.mission = new Mission(options);
|
||||
this.ai = new AiBase(options);
|
||||
}
|
||||
setToken(token: string) {
|
||||
this.token = token;
|
||||
|
||||
Reference in New Issue
Block a user