Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions modules/tool/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ export const BuiltInToolBaseURL = isProd
* @returns Icon path if found, default svg path otherwise
*/
function findToolIcon(toolId: string) {
const iconBasePath = path.join(process.cwd(), 'dist', 'public', 'imgs', 'tools');
const iconBasePath = isProd
? path.join(process.cwd(), 'dist', 'public', 'imgs', 'tools')
: path.join(process.cwd(), 'public', 'imgs', 'tools');

// Check for existing icon files with different formats
for (const format of iconFormats) {
Expand Down Expand Up @@ -93,13 +95,15 @@ export const LoadToolsByFilename = async (
}
} else {
const tool = (await import(toolRootPath)).default as ToolConfigWithCbType;
const icon = tool.icon || findToolIcon(tool.toolId!) || '';
// NOTE: fallback to filename only when the plugin service running in dev mode.
const toolId = tool.toolId || filename;
const icon = tool.icon || findToolIcon(toolId) || '';

tools.push({
...tool,
type: tool.type || ToolTypeEnum.tools,
icon,
toolId: tool.toolId || filename,
toolId,
toolDirName: `${toolSource}/${filename}`,
toolSource
});
Expand Down