@@ -10,7 +10,6 @@ import extensionLibraryContent, {
1010 galleryMore
1111} from '../lib/libraries/extensions/index.jsx' ;
1212import LibraryComponent from '../components/library/library.jsx' ;
13- import ccwIcon from '../lib/libraries/extensions/custom/ccw.svg' ;
1413import libraryStyles from '../components/library/library.css' ;
1514import { APP_NAME } from '../lib/brand.js' ;
1615import log from '../lib/log' ;
@@ -625,6 +624,7 @@ class ExtensionLibrary extends React.PureComponent {
625624 'getActionLabel' ,
626625 'getBatchSelectableItems' ,
627626 'getCardProps' ,
627+ 'getCCWSortControl' ,
628628 'getLibraryItems' ,
629629 'getNormalizedItems' ,
630630 'getQuickFilterButtons' ,
@@ -633,6 +633,7 @@ class ExtensionLibrary extends React.PureComponent {
633633 'getSourceLabel' ,
634634 'getSections' ,
635635 'handleBatchImport' ,
636+ 'handleCCWSortChange' ,
636637 'handleClearFilters' ,
637638 'handleClearQuery' ,
638639 'handleClearSelection' ,
@@ -660,6 +661,7 @@ class ExtensionLibrary extends React.PureComponent {
660661 galleryTimedOut : false ,
661662 ccwItems : [ ] ,
662663 ccwLoading : false ,
664+ ccwSortField : 'updatedAt' ,
663665 query : '' ,
664666 quickFilters : {
665667 favorites : false ,
@@ -1041,13 +1043,18 @@ class ExtensionLibrary extends React.PureComponent {
10411043 favorites
10421044 } ) ;
10431045 }
1046+ handleCCWSortChange ( event ) {
1047+ const sortField = event . target . value ;
1048+ this . setState ( { ccwSortField : sortField } ) ;
1049+ this . fetchAndSetCCWItems ( this . state . query , sortField ) ;
1050+ }
10441051 handleSourceSelect ( selectedSource ) {
10451052 this . setState ( {
10461053 selectedSource
10471054 } ) ;
10481055 // 切换到CCW时触发实时搜索
10491056 if ( selectedSource === SOURCE_KEYS . CCW || selectedSource === SOURCE_KEYS . ALL ) {
1050- this . fetchAndSetCCWItems ( this . state . query , 'updatedAt' ) ;
1057+ this . fetchAndSetCCWItems ( this . state . query , this . state . ccwSortField ) ;
10511058 }
10521059 }
10531060 handleQueryChange ( query ) {
@@ -1059,7 +1066,7 @@ class ExtensionLibrary extends React.PureComponent {
10591066 clearTimeout ( this . _queryTimeout ) ;
10601067 }
10611068 this . _queryTimeout = setTimeout ( ( ) => {
1062- this . fetchAndSetCCWItems ( query , 'updatedAt' ) ;
1069+ this . fetchAndSetCCWItems ( query , this . state . ccwSortField ) ;
10631070 } , 500 ) ;
10641071 }
10651072 handleToggleQuickFilter ( filterKey ) {
@@ -1272,6 +1279,52 @@ class ExtensionLibrary extends React.PureComponent {
12721279 sourceTone : sourceToneMap [ item . source ] || 'Other'
12731280 } ;
12741281 }
1282+ getCCWSortControl ( ) {
1283+ return (
1284+ < div style = { { marginTop : '0.75rem' } } >
1285+ < div className = { libraryStyles . sidebarTitle } style = { { marginBottom : '0.5rem' , opacity : 0.6 , fontSize : '0.75rem' } } >
1286+ 排序方式
1287+ </ div >
1288+ < button
1289+ type = "button"
1290+ className = { [
1291+ libraryStyles . sidebarButton ,
1292+ libraryStyles . sidebarActionButton
1293+ ] . join ( ' ' ) }
1294+ style = { { cursor : 'default' , background : '#00baad' } }
1295+ >
1296+ < div className = { libraryStyles . sidebarButtonLabel } >
1297+ < select
1298+ value = { this . state . ccwSortField }
1299+ onChange = { this . handleCCWSortChange }
1300+ style = { {
1301+ width : '100%' ,
1302+ appearance : 'none' ,
1303+ WebkitAppearance : 'none' ,
1304+ MozAppearance : 'none' ,
1305+ padding : 0 ,
1306+ border : 'none' ,
1307+ borderRadius : 0 ,
1308+ fontSize : 'inherit' ,
1309+ fontWeight : 'inherit' ,
1310+ color : 'inherit' ,
1311+ outline : 'none' ,
1312+ backgroundColor : 'transparent' ,
1313+ cursor : 'pointer' ,
1314+ fontFamily : 'inherit' ,
1315+ textAlign : 'left'
1316+ } }
1317+ >
1318+ < option value = "updatedAt" > 最近更新</ option >
1319+ < option value = "likeCount" > 最多喜欢</ option >
1320+ < option value = "donateCount" > 最多投币</ option >
1321+ < option value = "createdAt" > 最新创建</ option >
1322+ </ select >
1323+ </ div >
1324+ </ button >
1325+ </ div >
1326+ ) ;
1327+ }
12751328 getSidebar ( counts ) {
12761329 return (
12771330 < React . Fragment >
@@ -1310,6 +1363,7 @@ class ExtensionLibrary extends React.PureComponent {
13101363 </ div >
13111364 </ button >
13121365 </ div >
1366+ { this . state . selectedSource === SOURCE_KEYS . CCW && this . getCCWSortControl ( ) }
13131367 </ React . Fragment >
13141368 ) ;
13151369 }
0 commit comments