@@ -327,26 +327,50 @@ export const useExtensionPage = () => {
327327 return data ;
328328 } ) ;
329329
330+ const sortPluginsByName = ( plugins ) => {
331+ return plugins
332+ . map ( ( plugin , index ) => ( { plugin, index } ) )
333+ . sort ( ( a , b ) => {
334+ const nameA = String ( a . plugin ?. name ?? "" ) ;
335+ const nameB = String ( b . plugin ?. name ?? "" ) ;
336+ const nameCompare = nameA . localeCompare ( nameB , undefined , {
337+ sensitivity : "base" ,
338+ } ) ;
339+ if ( nameCompare !== 0 ) {
340+ return nameCompare ;
341+ }
342+ return a . index - b . index ;
343+ } )
344+ . map ( ( item ) => item . plugin ) ;
345+ } ;
346+
330347 // 通过搜索过滤插件
331348 const filteredPlugins = computed ( ( ) => {
332- if ( ! pluginSearch . value ) {
333- return filteredExtensions . value ;
349+ const plugins = filteredExtensions . value ;
350+ let filtered = plugins ;
351+
352+ if ( pluginSearch . value ) {
353+ const search = pluginSearch . value . toLowerCase ( ) ;
354+ filtered = plugins . filter ( ( plugin ) => {
355+ const pluginName = ( plugin . name ?? "" ) . toLowerCase ( ) ;
356+ const pluginDesc = ( plugin . desc ?? "" ) . toLowerCase ( ) ;
357+ const pluginAuthor = ( plugin . author ?? "" ) . toLowerCase ( ) ;
358+ const supportPlatforms = Array . isArray ( plugin . support_platforms )
359+ ? plugin . support_platforms . join ( " " ) . toLowerCase ( )
360+ : "" ;
361+ const astrbotVersion = ( plugin . astrbot_version ?? "" ) . toLowerCase ( ) ;
362+
363+ return (
364+ pluginName . includes ( search ) ||
365+ pluginDesc . includes ( search ) ||
366+ pluginAuthor . includes ( search ) ||
367+ supportPlatforms . includes ( search ) ||
368+ astrbotVersion . includes ( search )
369+ ) ;
370+ } ) ;
334371 }
335-
336- const search = pluginSearch . value . toLowerCase ( ) ;
337- return filteredExtensions . value . filter ( ( plugin ) => {
338- const supportPlatforms = Array . isArray ( plugin . support_platforms )
339- ? plugin . support_platforms . join ( " " ) . toLowerCase ( )
340- : "" ;
341- const astrbotVersion = ( plugin . astrbot_version ?? "" ) . toLowerCase ( ) ;
342- return (
343- plugin . name ?. toLowerCase ( ) . includes ( search ) ||
344- plugin . desc ?. toLowerCase ( ) . includes ( search ) ||
345- plugin . author ?. toLowerCase ( ) . includes ( search ) ||
346- supportPlatforms . includes ( search ) ||
347- astrbotVersion . includes ( search )
348- ) ;
349- } ) ;
372+
373+ return sortPluginsByName ( [ ...filtered ] ) ;
350374 } ) ;
351375
352376 // 过滤后的插件市场数据(带搜索)
0 commit comments