From db67c1e69e08030b5f49998edf0fb91e396accd1 Mon Sep 17 00:00:00 2001 From: abearxiong Date: Thu, 12 Mar 2026 01:31:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E8=87=B3=200.0.63=EF=BC=8C=E5=8D=87=E7=BA=A7=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E9=A1=B9=E5=B9=B6=E6=B7=BB=E5=8A=A0=20setPrefix=20=E5=92=8C=20?= =?UTF-8?q?getRelativePath=20=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 14 ++++----- pnpm-lock.yaml | 52 +++++++++++++++++----------------- query/query-resources/index.ts | 15 ++++++++++ 3 files changed, 48 insertions(+), 33 deletions(-) diff --git a/package.json b/package.json index 4e84b4e..c2484a1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@kevisual/api", - "version": "0.0.62", + "version": "0.0.63", "description": "", "main": "mod.ts", "scripts": { @@ -18,18 +18,18 @@ "keywords": [], "author": "abearxiong (https://www.xiongxiao.me)", "license": "MIT", - "packageManager": "pnpm@10.30.3", + "packageManager": "pnpm@10.32.1", "type": "module", "devDependencies": { "@kevisual/cache": "^0.0.5", "@kevisual/code-builder": "^0.0.6", - "@kevisual/query": "^0.0.52", - "@kevisual/remote-app": "^0.0.4", - "@kevisual/router": "^0.0.85", + "@kevisual/query": "^0.0.53", + "@kevisual/remote-app": "^0.0.6", + "@kevisual/router": "^0.1.1", "@kevisual/types": "^0.0.12", "@kevisual/use-config": "^1.0.30", "@types/bun": "^1.3.10", - "@types/node": "^25.3.3", + "@types/node": "^25.4.0", "@types/spark-md5": "^3.0.5", "dotenv": "^17.3.1", "fast-glob": "^3.3.3", @@ -37,7 +37,7 @@ }, "dependencies": { "@kevisual/context": "^0.0.8", - "@kevisual/js-filter": "^0.0.5", + "@kevisual/js-filter": "^0.0.6", "@kevisual/load": "^0.0.6", "@paralleldrive/cuid2": "^3.3.0", "es-toolkit": "^1.45.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d5c3acc..36798d4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,8 +12,8 @@ importers: specifier: ^0.0.8 version: 0.0.8 '@kevisual/js-filter': - specifier: ^0.0.5 - version: 0.0.5 + specifier: ^0.0.6 + version: 0.0.6 '@kevisual/load': specifier: ^0.0.6 version: 0.0.6 @@ -52,14 +52,14 @@ importers: specifier: ^0.0.6 version: 0.0.6 '@kevisual/query': - specifier: ^0.0.52 - version: 0.0.52 + specifier: ^0.0.53 + version: 0.0.53 '@kevisual/remote-app': - specifier: ^0.0.4 - version: 0.0.4 + specifier: ^0.0.6 + version: 0.0.6 '@kevisual/router': - specifier: ^0.0.85 - version: 0.0.85 + specifier: ^0.1.1 + version: 0.1.1 '@kevisual/types': specifier: ^0.0.12 version: 0.0.12 @@ -70,8 +70,8 @@ importers: specifier: ^1.3.10 version: 1.3.10 '@types/node': - specifier: ^25.3.3 - version: 25.3.3 + specifier: ^25.4.0 + version: 25.4.0 '@types/spark-md5': specifier: ^3.0.5 version: 3.0.5 @@ -117,8 +117,8 @@ packages: '@kevisual/context@0.0.8': resolution: {integrity: sha512-DTJpyHI34NE76B7g6f+QlIqiCCyqI2qkBMQE736dzeRDGxOjnbe2iQY9W+Rt2PE6kmymM3qyOmSfNovyWyWrkA==} - '@kevisual/js-filter@0.0.5': - resolution: {integrity: sha512-+S+Sf3K/aP6XtZI2s7TgKOr35UuvUvtpJ9YDW30a+mY0/N8gRuzyKhieBzQN7Ykayzz70uoMavBXut2rUlLgzw==} + '@kevisual/js-filter@0.0.6': + resolution: {integrity: sha512-FcbOsmS1inhwrfgXMM/XLFTGTHUxBCss32JEMYdEFWQDYCar5rN8cxD1W8FuKDTVRlpA+zBpQ/BE6XT4UaeljA==} '@kevisual/load@0.0.6': resolution: {integrity: sha512-+3YTFehRcZ1haGel5DKYMUwmi5i6f2psyaPZlfkKU/cOXgkpwoG9/BEqPCnPjicKqqnksEpixVRkyHJ+5bjLVA==} @@ -126,17 +126,17 @@ packages: '@kevisual/query@0.0.18': resolution: {integrity: sha512-I2vHTu0I6AyD9PJyr+vxyp9jIJ6rd2EZqLVHTv/+zrVKVc2SS76Tg7aGNkmAFqqLSCB8kLLsmMGtSJU1Qb8VVg==} - '@kevisual/query@0.0.52': - resolution: {integrity: sha512-m1UbyDTIxtfAQXM+EqhXA4ytE2V8rV8mXTZVBwzfW9O6+gtvAcRY7K1YYxfewTSXLVh9nwvfHe0KQ8MDL5ukyw==} + '@kevisual/query@0.0.53': + resolution: {integrity: sha512-PAhpCLBr0emz0lGNlTVHMbJiC5wrtGLbInPddRzgKE35fiyNt+SWSsUWABiD0DeNrLN/OxWyAFobt880Z/e5MQ==} - '@kevisual/remote-app@0.0.4': - resolution: {integrity: sha512-2yIlWY98pLCcxG+DJsqXXkd5YYEgymuOsyElH+31AoEPb7mlNREnYS81zN0KM9nvdSmU2G51vV4UVirJlYBZCQ==} + '@kevisual/remote-app@0.0.6': + resolution: {integrity: sha512-yc3BKAhtY+SzrvQSebeyR/QR93nPctndNMnW6ne1YPK+Kfpuf8gi7W4zlg18EJh7FEpDuDVHKqVp1klsWjESqQ==} '@kevisual/router@0.0.20': resolution: {integrity: sha512-uSwDYWh+kvAu6i0m0SJVgcLR/CYz7WvIWGz0nSF8Vg6smJuAgI+laHR4ESO8Fbz+Xn8bPHuSwmM//HHLMLx2FA==} - '@kevisual/router@0.0.85': - resolution: {integrity: sha512-ihSzPXHOMSOnZD/+Eso4yZMt4MoUXyLdfRHhXJGg90+sJBr/BjsmgAokit4pI9gWU+Rs/3JqQ2/aqA43FHtGoA==} + '@kevisual/router@0.1.1': + resolution: {integrity: sha512-+uaJc+Bf/T1mfxyfy9PmwuxJGPOLhVqrmsli2xUPqkkFvizrFIGB1vBTITuo5XP/FnwGqxgbjsitG57AMubm3w==} '@kevisual/types@0.0.10': resolution: {integrity: sha512-Q73uzzjk9UidumnmCvOpgzqDDvQxsblz22bIFuoiioUFJWwaparx8bpd8ArRyFojicYL1YJoFDzDZ9j9NN8grA==} @@ -188,8 +188,8 @@ packages: '@types/node@22.15.27': resolution: {integrity: sha512-5fF+eu5mwihV2BeVtX5vijhdaZOfkQTATrePEaXTcKqI16LhJ7gi2/Vhd9OZM0UojcdmiOCVg5rrax+i1MdoQQ==} - '@types/node@25.3.3': - resolution: {integrity: sha512-DpzbrH7wIcBaJibpKo9nnSQL0MTRdnWttGyE5haGwK86xgMOkFLp7vEyfQPGLOJh5wNYiJ3V9PmUMDhV9u8kkQ==} + '@types/node@25.4.0': + resolution: {integrity: sha512-9wLpoeWuBlcbBpOY3XmzSTG3oscB6xjBEEtn+pYXTfhyXhIxC5FsBer2KTopBlvKEiW9l13po9fq+SJY/5lkhw==} '@types/spark-md5@3.0.5': resolution: {integrity: sha512-lWf05dnD42DLVKQJZrDHtWFidcLrHuip01CtnC2/S6AMhX4t9ZlEUj4iuRlAnts0PQk7KESOqKxeGE/b6sIPGg==} @@ -503,7 +503,7 @@ snapshots: '@kevisual/context@0.0.8': {} - '@kevisual/js-filter@0.0.5': {} + '@kevisual/js-filter@0.0.6': {} '@kevisual/load@0.0.6': dependencies: @@ -517,16 +517,16 @@ snapshots: - ws - zod - '@kevisual/query@0.0.52': {} + '@kevisual/query@0.0.53': {} - '@kevisual/remote-app@0.0.4': {} + '@kevisual/remote-app@0.0.6': {} '@kevisual/router@0.0.20': dependencies: path-to-regexp: 8.2.0 selfsigned: 2.4.1 - '@kevisual/router@0.0.85': + '@kevisual/router@0.1.1': dependencies: es-toolkit: 1.45.1 @@ -582,7 +582,7 @@ snapshots: dependencies: undici-types: 6.21.0 - '@types/node@25.3.3': + '@types/node@25.4.0': dependencies: undici-types: 7.18.2 @@ -606,7 +606,7 @@ snapshots: bun-types@1.3.10: dependencies: - '@types/node': 25.3.3 + '@types/node': 25.4.0 call-bind-apply-helpers@1.0.2: dependencies: diff --git a/query/query-resources/index.ts b/query/query-resources/index.ts index 7ba7ae6..b62f220 100644 --- a/query/query-resources/index.ts +++ b/query/query-resources/index.ts @@ -26,6 +26,10 @@ export class QueryResources { setUsername(username: string) { this.prefix = `/${username}/resources/`; } + /** + * 设置prefix,类似 /{username}/resources/; + * @param prefix + */ setPrefix(prefix: string) { this.prefix = prefix; } @@ -166,6 +170,17 @@ export class QueryResources { this.onProcess?.({ type: 'uploadFinish', filename, size: file.size, process: 100 }); return { code: 200, message: '上传成功' }; } + /** + * 移除 prefix,获取相对路径 + * @param filepath + * @returns + */ + getRelativePath(filepath: string): string { + if (filepath.startsWith(this.prefix)) { + return filepath.slice(this.prefix.length); + } + return filepath; + } async getStat(filepath: string, opts?: DataOpts): Promise> { const url = `${this.prefix}${filepath}`;