This commit is contained in:
xiongxiao
2026-01-13 17:04:43 +08:00
parent 1d7a51f76c
commit cedf3236b0
6 changed files with 39 additions and 384 deletions

View File

@@ -69,12 +69,12 @@ export class CNBCore {
headers: _headers,
body: _body,
});
const res = (data: any, message?: string) => {
const res = (data: any, message?: string, code?: number) => {
if (useOrigin) {
return data;
}
return {
code: 200,
code: code ?? 200,
message: message || 'success',
data,
};
@@ -83,7 +83,7 @@ export class CNBCore {
const errorText = await response.text();
if (useOrigin)
throw new Error(`Request failed with status ${response.status}: ${errorText}`);
return res(null, `Request failed with status ${response.status}: ${errorText}`);
return res(null, `Request failed with status ${response.status}: ${errorText}`, response.status);
}
const contentType = response.headers.get('Content-Type');

View File

@@ -31,7 +31,6 @@ export class CNB extends CNBCore {
const cookie = this.cookie;
const options = { token, cookie };
this.workspace = new Workspace(options.token);
const group = cnbOptions?.group || '';
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 });
@@ -39,10 +38,6 @@ export class CNB extends CNBCore {
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 });
this.group = group;
}
setGroup(group: string) {
this.group = group;
}
setToken(token: string) {
this.token = token;