customs-ui-kit-mcp 1.0.3 → 1.0.4
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/index.js +19 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -197,8 +197,26 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => {
|
|
|
197
197
|
],
|
|
198
198
|
};
|
|
199
199
|
});
|
|
200
|
-
// 获取组件示例 (读取 Storybook
|
|
200
|
+
// 获取组件示例 (读取 Storybook 文件或 examples 目录)
|
|
201
201
|
function getComponentExamples(componentName) {
|
|
202
|
+
const examplesDir = path.join(UI_PACKAGE_PATH, componentName, "examples");
|
|
203
|
+
// 1. 如果存在 examples 目录,优先读取里面的所有 .vue 文件作为示例
|
|
204
|
+
if (fs.existsSync(examplesDir)) {
|
|
205
|
+
const files = fs.readdirSync(examplesDir).filter(f => f.endsWith('.vue'));
|
|
206
|
+
if (files.length > 0) {
|
|
207
|
+
let combinedExamples = `# ${componentName} 组件使用示例1\n\n`;
|
|
208
|
+
for (const file of files) {
|
|
209
|
+
const content = fs.readFileSync(path.join(examplesDir, file), "utf-8");
|
|
210
|
+
const exampleName = file.replace('.vue', '');
|
|
211
|
+
combinedExamples += `## 示例: ${exampleName}\n` +
|
|
212
|
+
`\`\`\`vue\n` +
|
|
213
|
+
content +
|
|
214
|
+
`\n\`\`\`\n\n`;
|
|
215
|
+
}
|
|
216
|
+
return combinedExamples;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
// 2. 降级方案:读取旧版的 .stories.ts 文件
|
|
202
220
|
const storyPath = path.join(UI_PACKAGE_PATH, componentName, `${componentName}.stories.ts`);
|
|
203
221
|
if (!fs.existsSync(storyPath)) {
|
|
204
222
|
return `No examples found for component ${componentName}.`;
|