@gt6/sdk 1.0.26 → 1.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/types.d.ts +8 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/gt6-sdk.cjs.js +55 -0
- package/dist/gt6-sdk.cjs.js.map +1 -1
- package/dist/gt6-sdk.esm.js +55 -0
- package/dist/gt6-sdk.esm.js.map +1 -1
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/modules/articles.d.ts +14 -0
- package/dist/modules/articles.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/gt6-sdk.esm.js
CHANGED
@@ -127,6 +127,15 @@ class ArticlesAPI {
|
|
127
127
|
const response = await this.client.request(`/article-categories/platform-${config.platformId_p}-root-${categoryId}.json`);
|
128
128
|
return response.categories;
|
129
129
|
}
|
130
|
+
/**
|
131
|
+
* 2.2 获取文章分类列表(使用下级平台ID)
|
132
|
+
*/
|
133
|
+
async getCategories_a(rootCategoryId) {
|
134
|
+
const config = this.client.getConfig();
|
135
|
+
const categoryId = rootCategoryId || config.rootCategoryId;
|
136
|
+
const response = await this.client.request(`/big-article-categories/platform-${config.platformId}-root-${categoryId}.json`);
|
137
|
+
return response.categories;
|
138
|
+
}
|
130
139
|
/**
|
131
140
|
* 3. 获取文章标签列表
|
132
141
|
*/
|
@@ -283,6 +292,40 @@ class ArticlesAPI {
|
|
283
292
|
limit
|
284
293
|
};
|
285
294
|
}
|
295
|
+
/**
|
296
|
+
* 4.3 根据分类ID获取文章列表(使用大型分类静态文件)
|
297
|
+
* 只支持单个分类ID,从大型分类静态文件获取文章ID列表
|
298
|
+
*/
|
299
|
+
async getArticlesByCategory_a(categoryId, options) {
|
300
|
+
// 从大型分类静态文件获取该分类的文章ID列表
|
301
|
+
const categoryData = await this.client.request(`/big-article-categories/${categoryId}.json`);
|
302
|
+
if (!categoryData || !categoryData.articleIds || categoryData.articleIds.length === 0) {
|
303
|
+
return {
|
304
|
+
articles: [],
|
305
|
+
total: 0,
|
306
|
+
page: options?.page || 1,
|
307
|
+
limit: options?.limit || 10
|
308
|
+
};
|
309
|
+
}
|
310
|
+
// 应用分页
|
311
|
+
const page = options?.page || 1;
|
312
|
+
const limit = options?.limit || 10;
|
313
|
+
const offset = (page - 1) * limit;
|
314
|
+
const paginatedArticleIds = categoryData.articleIds.slice(offset, offset + limit);
|
315
|
+
// 获取文章详情(使用上级平台数据)
|
316
|
+
const articles = await Promise.all(paginatedArticleIds.map(articleId => this.getArticle_p(articleId)));
|
317
|
+
// 应用状态过滤
|
318
|
+
let filteredArticles = articles;
|
319
|
+
if (options?.status) {
|
320
|
+
filteredArticles = articles.filter(article => article.status === options.status);
|
321
|
+
}
|
322
|
+
return {
|
323
|
+
articles: filteredArticles,
|
324
|
+
total: categoryData.articleIds.length,
|
325
|
+
page,
|
326
|
+
limit
|
327
|
+
};
|
328
|
+
}
|
286
329
|
/**
|
287
330
|
* 5. 根据标签ID获取文章列表
|
288
331
|
* 支持单个标签ID或标签ID数组
|
@@ -2564,6 +2607,12 @@ class GT6SDK {
|
|
2564
2607
|
async getCategories_p(rootCategoryId_p) {
|
2565
2608
|
return this.articles.getCategories_p(rootCategoryId_p);
|
2566
2609
|
}
|
2610
|
+
/**
|
2611
|
+
* 2.2. 便捷方法:获取文章分类列表(使用下级平台ID)
|
2612
|
+
*/
|
2613
|
+
async getCategories_a(rootCategoryId) {
|
2614
|
+
return this.articles.getCategories_a(rootCategoryId);
|
2615
|
+
}
|
2567
2616
|
/**
|
2568
2617
|
* 3. 便捷方法:获取文章标签列表
|
2569
2618
|
*/
|
@@ -2594,6 +2643,12 @@ class GT6SDK {
|
|
2594
2643
|
async getArticlesByCategory_t(categoryId, options) {
|
2595
2644
|
return this.articles.getArticlesByCategory_t(categoryId, options);
|
2596
2645
|
}
|
2646
|
+
/**
|
2647
|
+
* 4.3. 便捷方法:根据分类ID获取文章列表(从大型静态JSON文件获取)
|
2648
|
+
*/
|
2649
|
+
async getArticlesByCategory_a(categoryId, options) {
|
2650
|
+
return this.articles.getArticlesByCategory_a(categoryId, options);
|
2651
|
+
}
|
2597
2652
|
/**
|
2598
2653
|
* 5. 便捷方法:根据标签ID获取文章列表
|
2599
2654
|
*/
|