@@ -71,15 +71,36 @@ public void InstallJudgeDisplay4B()
7171 }
7272 }
7373
74+ public class UnsupportedConfigApiVersionException ( ) : Exception ( "无法兼容的配置文件版本" ) ;
75+
76+ public class AquaMaiNotInstalledException( ) : Exception ( "AquaMai 没有安装" ) ;
77+
78+ [ NonAction]
79+ private static void CheckConfigApiVersion( HeadlessConfigInterface configInterface )
80+ {
81+ var currentSupportedApiVersion = new Version ( 1 , 0 ) ;
82+ var configApiVersion = new Version ( configInterface . ApiVersion ) ;
83+ if ( currentSupportedApiVersion . Major ! = configApiVersion . Major )
84+ {
85+ throw new UnsupportedConfigApiVersionException ( ) ;
86+ }
87+
88+ if ( currentSupportedApiVersion . Minor < configApiVersion . Minor )
89+ {
90+ throw new UnsupportedConfigApiVersionException( ) ;
91+ }
92+ }
93+
7494 [ HttpGet ]
7595 public AquaMaiConfigDto. ConfigDto GetAquaMaiConfig( )
7696 {
7797 if ( ! IsAquaMaiInstalled( ) )
7898 {
79- throw new InvalidOperationException ( "AquaMai 没有安装" ) ;
99+ throw new AquaMaiNotInstalledException ( ) ;
80100 }
81101
82102 var configInterface = HeadlessConfigLoader. LoadFromPacked( AquaMaiDllInstalledPath) ;
103+ CheckConfigApiVersion( configInterface) ;
83104 var view = configInterface. CreateConfigView( System . IO . File . ReadAllText ( AquaMaiConfigPath ) ) ;
84105 var migrationManager = configInterface. GetConfigMigrationManager( ) ;
85106
@@ -123,6 +144,7 @@ public void SetAquaMaiConfig(AquaMaiConfigDto.ConfigSaveDto config)
123144 jsonOptions. Converters. Add( new JsonStringEnumConverter( ) ) ;
124145
125146 var configInterface = HeadlessConfigLoader. LoadFromPacked( AquaMaiDllInstalledPath) ;
147+ CheckConfigApiVersion( configInterface) ;
126148 var configEdit = configInterface. CreateConfig( ) ;
127149
128150 foreach ( var section in configEdit. ReflectionManager. Sections)
0 commit comments