File tree Expand file tree Collapse file tree
components/UserConfigPanel Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ export interface Config {
3535 max ?: number ;
3636 min ?: number ;
3737 rows ?: number ; // textarea行数
38+ index : number ; // 配置项排序位置
3839}
3940
4041export type UserConfig = { [ key : string ] : { [ key : string ] : Config } } ;
Original file line number Diff line number Diff line change @@ -45,7 +45,6 @@ const UserConfigPanel: React.FC<{
4545 onOk = { ( ) => {
4646 if ( formRefs . current [ tab ] ) {
4747 const saveValues = formRefs . current [ tab ] . getFieldsValue ( ) ;
48- console . log ( "saveValues" , saveValues ) ;
4948 // 更新value
5049 const valueClient = new ValueClient ( message ) ;
5150 Object . keys ( saveValues ) . forEach ( ( key ) => {
@@ -72,6 +71,10 @@ const UserConfigPanel: React.FC<{
7271 >
7372 { Object . keys ( userConfig ) . map ( ( itemKey ) => {
7473 const value = userConfig [ itemKey ] ;
74+ const keys = Object . keys ( value ) . sort ( ( a , b ) => {
75+ return ( value [ a ] . index || 0 ) - ( value [ b ] . index || 0 ) ;
76+ } ) ;
77+ console . log ( "keys" , value , keys ) ;
7578 return (
7679 < TabPane key = { itemKey } title = { itemKey } >
7780 < Form
@@ -86,7 +89,7 @@ const UserConfigPanel: React.FC<{
8689 formRefs . current [ itemKey ] = el ;
8790 } }
8891 >
89- { Object . keys ( value ) . map ( ( key ) => (
92+ { keys . map ( ( key ) => (
9093 < FormItem key = { key } label = { value [ key ] . title } field = { `${ itemKey } .${ key } ` } >
9194 { ( ) => {
9295 const item = value [ key ] ;
Original file line number Diff line number Diff line change @@ -405,7 +405,10 @@ function ScriptEditor() {
405405 useEffect ( ( ) => {
406406 // 防止开发模式下重复初始化
407407 if ( initRef . current ) {
408- return ;
408+ // 恢复标题
409+ return ( ) => {
410+ document . title = "Home - ScriptCat" ;
411+ } ;
409412 }
410413 initRef . current = true ;
411414
Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ export function parseUserConfig(code: string): UserConfig | undefined {
1313 const obj : UserConfig = parse ( val ) ;
1414 Object . keys ( obj || { } ) . forEach ( ( key ) => {
1515 ret [ key ] = obj [ key ] ;
16+ Object . keys ( ret [ key ] || { } ) . forEach ( ( subKey , subIndex ) => {
17+ ret [ key ] [ subKey ] . index = ret [ key ] [ subKey ] . index || subIndex ; // 确保index存在
18+ } ) ;
1619 } ) ;
1720 } ) ;
1821 return ret ;
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ declare interface Config {
1717 max?: number;
1818 min?: number;
1919 rows?: number; // textarea行数
20+ index: number; // 配置项排序位置
2021}
2122
2223declare type UserConfig = { [key: string]: { [key: string]: Config } };
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ declare interface Config {
1717 max ?: number ;
1818 min ?: number ;
1919 rows ?: number ; // textarea行数
20+ index : number ; // 配置项排序位置
2021}
2122
2223declare type UserConfig = { [ key : string ] : { [ key : string ] : Config } } ;
You can’t perform that action at this time.
0 commit comments