feat: 更新版本至 0.0.63,升级依赖项并添加 setPrefix 和 getRelativePath 方法

This commit is contained in:
2026-03-12 01:31:50 +08:00
parent 571f05bcba
commit db67c1e69e
3 changed files with 48 additions and 33 deletions

View File

@@ -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<Result<Stat>> {
const url = `${this.prefix}${filepath}`;