From 236caed041a7a23827d9afbd83591737afd8549a Mon Sep 17 00:00:00 2001 From: abearxiong Date: Thu, 5 Feb 2026 23:53:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC=E5=8F=B7?= =?UTF-8?q?=E8=87=B30.0.18=EF=BC=8C=E4=BC=98=E5=8C=96=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=EF=BC=8C=E6=9B=B4=E6=96=B0@types/node?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=E8=87=B325.2.1=EF=BC=8C=E5=B9=B6=E9=87=8D?= =?UTF-8?q?=E6=9E=84CNBCore=E7=B1=BB=E4=BB=A5=E6=8F=90=E9=AB=98=E5=8F=AF?= =?UTF-8?q?=E8=AF=BB=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 7 ++++--- pnpm-lock.yaml | 14 +++++++------- src/cnb-core.ts | 16 +++++++++++----- test/issue.ts | 19 +++++++++++++------ 4 files changed, 35 insertions(+), 21 deletions(-) diff --git a/package.json b/package.json index e62fd9c..684dcbd 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,11 @@ { "name": "@kevisual/cnb", - "version": "0.0.16", + "version": "0.0.18", "description": "", "main": "index.js", "scripts": { - "build": "bun run bun.config.ts" + "build": "bun bun.config.ts", + "flow":"ev npm patch && pnpm build && ev npm publish npm -p" }, "keywords": [], "files": [ @@ -24,7 +25,7 @@ "@kevisual/types": "^0.0.12", "@opencode-ai/plugin": "^1.1.51", "@types/bun": "^1.3.8", - "@types/node": "^25.2.0", + "@types/node": "^25.2.1", "@types/ws": "^8.18.1", "dayjs": "^1.11.19", "dotenv": "^17.2.3" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index dd4b3dc..71b8fff 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -55,8 +55,8 @@ importers: specifier: ^1.3.8 version: 1.3.8 '@types/node': - specifier: ^25.2.0 - version: 25.2.0 + specifier: ^25.2.1 + version: 25.2.1 '@types/ws': specifier: ^8.18.1 version: 8.18.1 @@ -118,8 +118,8 @@ packages: '@types/bun@1.3.8': resolution: {integrity: sha512-3LvWJ2q5GerAXYxO2mffLTqOzEu5qnhEAlh48Vnu8WQfnmSwbgagjGZV6BoHKJztENYEDn6QmVd949W4uESRJA==} - '@types/node@25.2.0': - resolution: {integrity: sha512-DZ8VwRFUNzuqJ5khrvwMXHmvPe+zGayJhr2CDNiKB1WBE1ST8Djl00D0IC4vvNmHMdj6DlbYRIaFE7WHjlDl5w==} + '@types/node@25.2.1': + resolution: {integrity: sha512-CPrnr8voK8vC6eEtyRzvMpgp3VyVRhgclonE7qYi6P9sXwYb59ucfrnmFBTaP0yUi8Gk4yZg/LlTJULGxvTNsg==} '@types/ws@8.18.1': resolution: {integrity: sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==} @@ -328,13 +328,13 @@ snapshots: dependencies: bun-types: 1.3.8 - '@types/node@25.2.0': + '@types/node@25.2.1': dependencies: undici-types: 7.16.0 '@types/ws@8.18.1': dependencies: - '@types/node': 25.2.0 + '@types/node': 25.2.1 anymatch@3.1.3: dependencies: @@ -343,7 +343,7 @@ snapshots: bun-types@1.3.8: dependencies: - '@types/node': 25.2.0 + '@types/node': 25.2.1 chokidar@5.0.0: dependencies: diff --git a/src/cnb-core.ts b/src/cnb-core.ts index c239187..fb27784 100644 --- a/src/cnb-core.ts +++ b/src/cnb-core.ts @@ -20,9 +20,11 @@ export type RequestOptions = { useCookie?: boolean; useOrigin?: boolean; }; +const API_BASER_URL = 'https://api.cnb.cool' +const API_HACK_URL = 'https://cnb.cool' export class CNBCore { - baseURL = 'https://api.cnb.cool'; - hackURL = 'https://cnb.cool' + baseURL = API_BASER_URL; + hackURL = API_HACK_URL; public token: string; public cookie?: string; constructor(options: CNBCoreOptions) { @@ -37,8 +39,8 @@ export class CNBCore { } } if (options?.cors?.baseUrl) { - this.baseURL = options.cors.baseUrl + '/' + this.baseURL; - this.hackURL = options.cors.baseUrl + '/' + this.hackURL; + this.baseURL = options.cors.baseUrl + '/' + API_BASER_URL.replace('https://', ''); + this.hackURL = options.cors.baseUrl + '/' + API_HACK_URL.replace('https://', ''); } } @@ -107,7 +109,11 @@ export class CNBCore { if (url && url.startsWith('http')) { return url; } - return new URL(url || '', this.baseURL).toString(); + console.log('url', url, this.baseURL) + if (url.startsWith('/')) { + return this.baseURL + url; + } + return this.baseURL + '/' + url; } get({ url, ...REST }: RequestOptions): Promise { const fullUrl = this.makeUrl(url); diff --git a/test/issue.ts b/test/issue.ts index ff447f6..eaa3dd6 100644 --- a/test/issue.ts +++ b/test/issue.ts @@ -2,7 +2,14 @@ import { Issue } from "../src/issue/index.ts"; import { token, showMore, cookie } from "./common.ts"; // group: "kevisual", -const issue = new Issue({ token: token, cookie: cookie }); +const issue = new Issue({ + token: token, cookie: cookie, + cors: { + // baseUrl: 'http://localhost:8080' + // baseUrl: 'https://cors.kevisual.cn' + baseUrl: 'http://cors.kevisual.cn:11111' + } +}); // const res = await issue.createIssue("cnb", { // title: "测试通过 API 创建 Issue", // }) @@ -16,13 +23,13 @@ const issue = new Issue({ token: token, cookie: cookie }); // }); // console.log(showMore(updateIssueRes)); -const itemIssueRes = await issue.getItem("cnb", 1); -console.log(showMore(itemIssueRes)); +// const itemIssueRes = await issue.getItem("cnb", 1); +// console.log(showMore(itemIssueRes)); -const listIssueRes = await issue.getList("cnb", { +const listIssueRes = await issue.getList("kevisual/kevisual", { state: "open", }); console.log(showMore(listIssueRes)); -const commentListRes = await issue.getCommentList("cnb", 1); -console.log(showMore(commentListRes)); \ No newline at end of file +// const commentListRes = await issue.getCommentList("kevisual/kevisual", 1); +// console.log(showMore(commentListRes)); \ No newline at end of file