Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
e5ced8a4
authored
Jul 09, 2026
by
Finley Ge
Committed by
GitHub
Jul 09, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(marketplace): filter empty tool card tags (#7285)
parent
986b2f1f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
6 deletions
+33
-6
packages/web/components/core/plugin/tool/ToolCard.tsx
+15
-6
packages/web/components/core/plugin/tool/utils.ts
+5
-0
projects/app/test/components/core/plugin/tool/utils.test.ts
+13
-0
No files found.
packages/web/components/core/plugin/tool/ToolCard.tsx
View file @
e5ced8a4
...
...
@@ -7,6 +7,7 @@ import MyIcon from '../../../common/Icon';
import
{
parseI18nString
}
from
'@fastgpt/global/common/i18n/utils'
;
import
{
PluginStatusEnum
,
type
PluginStatusType
}
from
'@fastgpt/global/core/plugin/type'
;
import
DebugToolTag
from
'./DebugToolTag'
;
import
{
normalizeToolCardTags
}
from
'./utils'
;
const
marketplaceOfficialSource
=
'official'
;
...
...
@@ -62,7 +63,8 @@ const ToolCard = ({
})
=>
{
const
{
t
,
i18n
}
=
useTranslation
();
const
tagsContainerRef
=
useRef
<
HTMLDivElement
>
(
null
);
const
[
visibleTagsCount
,
setVisibleTagsCount
]
=
useState
(
item
.
tags
?.
length
||
0
);
const
displayTags
=
useMemo
(()
=>
normalizeToolCardTags
(
item
.
tags
),
[
item
.
tags
]);
const
[
visibleTagsCount
,
setVisibleTagsCount
]
=
useState
(
displayTags
.
length
);
const
isMarketplaceVariant
=
variant
===
'marketplace'
;
const
showOfficialBadge
=
isMarketplaceVariant
&&
(
!
item
.
source
||
item
.
source
===
marketplaceOfficialSource
);
...
...
@@ -70,9 +72,16 @@ const ToolCard = ({
isMarketplaceVariant
&&
mode
===
'admin'
&&
item
.
installed
&&
!
showActionButton
;
useEffect
(()
=>
{
if
(
displayTags
.
length
===
0
)
{
setVisibleTagsCount
(
0
);
return
;
}
setVisibleTagsCount
(
displayTags
.
length
);
const
calculate
=
()
=>
{
const
container
=
tagsContainerRef
.
current
;
if
(
!
container
||
!
item
.
tags
?.
length
)
return
;
if
(
!
container
)
return
;
const
containerWidth
=
container
.
offsetWidth
;
const
tagElements
=
container
.
querySelectorAll
(
'[data-tag-item]'
);
...
...
@@ -99,7 +108,7 @@ const ToolCard = ({
clearTimeout
(
timer
);
observer
.
disconnect
();
};
},
[
item
.
t
ags
]);
},
[
displayT
ags
]);
const
statusLabel
=
useMemo
(()
=>
{
if
(
mode
===
'marketplace'
)
return
null
;
...
...
@@ -305,7 +314,7 @@ const ToolCard = ({
overflow=
{
'hidden'
}
ref=
{
tagsContainerRef
}
>
{
item
.
tags
?
.
slice
(
0
,
visibleTagsCount
).
map
((
tag
)
=>
{
{
displayTags
.
slice
(
0
,
visibleTagsCount
).
map
((
tag
)
=>
{
return
(
<
Box
key=
{
tag
}
...
...
@@ -325,7 +334,7 @@ const ToolCard = ({
</
Box
>
);
})
}
{
item
.
tags
&&
item
.
t
ags
.
length
>
visibleTagsCount
&&
(
{
displayT
ags
.
length
>
visibleTagsCount
&&
(
<
Box
px=
{
isMarketplaceVariant
?
'9px'
:
2
}
py=
{
isMarketplaceVariant
?
'5px'
:
1
}
...
...
@@ -338,7 +347,7 @@ const ToolCard = ({
color=
{
isMarketplaceVariant
?
'#383F50'
:
'myGray.700'
}
flexShrink=
{
0
}
>
+
{
item
.
t
ags
.
length
-
visibleTagsCount
}
+
{
displayT
ags
.
length
-
visibleTagsCount
}
</
Box
>
)
}
</
Flex
>
...
...
packages/web/components/core/plugin/tool/utils.ts
0 → 100644
View file @
e5ced8a4
/**
* 归一化工具卡片展示标签,过滤掉异步字典未命中或脏数据产生的空标签。
*/
export
const
normalizeToolCardTags
=
(
tags
?:
string
[]
|
null
)
=>
tags
?.
map
((
tag
)
=>
tag
.
trim
()).
filter
(
Boolean
)
??
[];
projects/app/test/components/core/plugin/tool/utils.test.ts
0 → 100644
View file @
e5ced8a4
import
{
describe
,
expect
,
it
}
from
'vitest'
;
import
{
normalizeToolCardTags
}
from
'@fastgpt/web/components/core/plugin/tool/utils'
;
describe
(
'normalizeToolCardTags'
,
()
=>
{
it
(
'filters empty tag labels generated by missing marketplace tag mappings'
,
()
=>
{
expect
(
normalizeToolCardTags
([
''
,
'工具'
,
' '
,
'生产力'
])).
toEqual
([
'工具'
,
'生产力'
]);
});
it
(
'returns an empty list for nullish tags'
,
()
=>
{
expect
(
normalizeToolCardTags
(
null
)).
toEqual
([]);
expect
(
normalizeToolCardTags
(
undefined
)).
toEqual
([]);
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment