eskill 1.0.11 → 1.0.13
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/cli.js +14 -3
- package/lib/search.js +1 -1
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -115,12 +115,23 @@ program
|
|
|
115
115
|
process.exit(1);
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
// 从 API 返回的数据结构中提取技能和分页信息
|
|
119
|
+
const skills = result.data?.skills || result.data || result.skills || result.results || [];
|
|
120
|
+
const pagination = result.data?.pagination || result.pagination || {};
|
|
121
|
+
const total = pagination.total || result.total || skills.length;
|
|
122
|
+
|
|
123
|
+
// 确保 skills 是数组
|
|
124
|
+
if (!Array.isArray(skills)) {
|
|
125
|
+
console.log('搜索返回数据格式异常');
|
|
126
|
+
console.log('调试信息:', JSON.stringify(result, null, 2));
|
|
127
|
+
process.exit(1);
|
|
128
|
+
}
|
|
129
|
+
|
|
119
130
|
console.log(formatSkillList(skills));
|
|
120
131
|
|
|
121
132
|
// 显示分页信息
|
|
122
|
-
if (
|
|
123
|
-
console.log(`总计: ${
|
|
133
|
+
if (total > 0) {
|
|
134
|
+
console.log(`总计: ${total} 个技能\n`);
|
|
124
135
|
}
|
|
125
136
|
|
|
126
137
|
// 显示安装提示
|
package/lib/search.js
CHANGED
|
@@ -71,7 +71,7 @@ export async function searchSkills(query, options = {}) {
|
|
|
71
71
|
* 格式化技能列表显示
|
|
72
72
|
*/
|
|
73
73
|
export function formatSkillList(skills, showIndex = true) {
|
|
74
|
-
if (!skills || skills.length === 0) {
|
|
74
|
+
if (!skills || !Array.isArray(skills) || skills.length === 0) {
|
|
75
75
|
return '未找到相关技能';
|
|
76
76
|
}
|
|
77
77
|
|