|
|
@@ -14,7 +14,7 @@ export class TikHubClient {
|
|
|
constructor(config?: Partial<TikHubConfig>) {
|
|
|
// 允许通过配置覆盖默认 Key 和 URL
|
|
|
this.apiKey = config?.apiKey || 'tKIbAsEM8X+GmE2vHqGW7D/ICwK1Q5V4viKFrWiPB6HholGdLFqZJmmyNw==';
|
|
|
- this.baseURL = config?.serverURL || 'https://api.tikhub.io/api/v1';
|
|
|
+ this.baseURL = config?.serverURL || 'https://server.fmode.cn/thapi/v1';
|
|
|
|
|
|
this.headers = {
|
|
|
'Authorization': `Bearer ${this.apiKey}`,
|
|
|
@@ -26,7 +26,10 @@ export class TikHubClient {
|
|
|
* 构建完整 URL(包含查询参数)
|
|
|
*/
|
|
|
private buildURL(path: string, params?: Record<string, any>): string {
|
|
|
- const url = new URL(path, this.baseURL);
|
|
|
+ // 移除 path 开头的 /,避免 new URL 替换掉 baseURL 的路径
|
|
|
+ const cleanPath = path.startsWith('/') ? path.slice(1) : path;
|
|
|
+ const fullPath = this.baseURL.endsWith('/') ? this.baseURL + cleanPath : this.baseURL + '/' + cleanPath;
|
|
|
+ const url = new URL(fullPath);
|
|
|
|
|
|
if (params) {
|
|
|
Object.entries(params).forEach(([key, value]) => {
|