@@ -272,7 +272,25 @@ onUnmounted(() => {
272272 }
273273})
274274
275- const pluginCategories = [' 前端' , ' 后端' ]
275+ const mixedAlphabeticalCompare = (a : string , b : string ): number => {
276+ return a .localeCompare (b , ' zh-CN' , {
277+ sensitivity: ' base' ,
278+ numeric: true ,
279+ ignorePunctuation: true
280+ })
281+ }
282+
283+ const pluginCategories = computed (() => {
284+ const allTags = new Set <string >()
285+ props .items .forEach (item => {
286+ item .tags .forEach (tag => {
287+ if (tag !== ' unfree' ) {
288+ allTags .add (tag )
289+ }
290+ })
291+ })
292+ return Array .from (allTags ).sort ((a , b ) => mixedAlphabeticalCompare (a , b ))
293+ })
276294
277295const baseFilteredItems = computed (() => {
278296 let result = [... props .items ]
@@ -314,14 +332,6 @@ const getTypeSortWeight = (item: PluginItem): number => {
314332 return 3
315333}
316334
317- const mixedAlphabeticalCompare = (a : string , b : string ): number => {
318- return a .localeCompare (b , ' zh-CN' , {
319- sensitivity: ' base' ,
320- numeric: true ,
321- ignorePunctuation: true
322- })
323- }
324-
325335const filteredItems = computed (() => {
326336 const result = [... baseFilteredItems .value ]
327337
@@ -348,7 +358,12 @@ const resetFilters = () => {
348358 sortOption .value = ' category'
349359}
350360
351- const colors = {
361+ const predefinedColors = {
362+ ' unfree' : {
363+ color: ' #ff5733' ,
364+ backgroundColor: ' rgba(255, 87, 51, 0.1)' ,
365+ borderColor: ' rgba(255, 87, 51, 0.2)' ,
366+ },
352367 ' mysql' : {
353368 color: ' #006484' ,
354369 backgroundColor: ' rgba(0, 100, 132, 0.1)' ,
@@ -371,6 +386,22 @@ const colors = {
371386 },
372387}
373388
389+ const colors = computed (() => {
390+ const colorMap: Record <string , any > = { ... predefinedColors }
391+ const allTags = [... new Set (props .items .flatMap (item => item .tags ))]
392+ allTags .forEach ((tag , index ) => {
393+ if (! colorMap [tag ]) {
394+ const hue = (index * 137.5 ) % 360
395+ colorMap [tag ] = {
396+ color: ` hsl(${ hue }, 65%, 50%) ` ,
397+ backgroundColor: ` hsl(${ hue }, 65%, 50%, 0.1) ` ,
398+ borderColor: ` hsl(${ hue }, 65%, 50%, 0.2) `
399+ }
400+ }
401+ })
402+ return colorMap
403+ })
404+
374405const handleCardClick = (item : PluginItem ) => {
375406 if (item .link ) {
376407 window .open (item .link , ' _blank' )
0 commit comments