refactor(config): table-drive scalar dirty-field tracking

getNextDirtyFields already had an updateScalarDirty list for twenty fields but spelled out twenty-seven more as identical hasOwnProperty/=== blocks. Fold them into the list; payload-rule and nested streaming comparisons keep their custom equality checks.
This commit is contained in:
LTbinglingfeng
2026-06-13 02:26:56 +08:00
Unverified
parent c79f58a4ac
commit ac9cc45736
+27 -111
View File
@@ -745,120 +745,36 @@ function getNextDirtyFields(
'claudeHeaderStabilizeDeviceProfile',
'codexHeaderUserAgent',
'codexHeaderBetaFeatures',
'host',
'port',
'tlsEnable',
'tlsCert',
'tlsKey',
'rmAllowRemote',
'rmSecretKey',
'rmDisableControlPanel',
'rmPanelRepo',
'authDir',
'apiKeysText',
'debug',
'commercialMode',
'loggingToFile',
'logsMaxTotalSizeMb',
'proxyUrl',
'forceModelPrefix',
'requestRetry',
'maxRetryCredentials',
'maxRetryInterval',
'wsAuth',
'quotaSwitchProject',
'quotaSwitchPreviewModel',
'quotaAntigravityCredits',
'routingStrategy',
'routingSessionAffinity',
'routingSessionAffinityTTL',
] as Array<keyof VisualConfigValues>
).forEach(updateScalarDirty);
if (Object.prototype.hasOwnProperty.call(patch, 'host')) {
updateDirty('host', nextValues.host === baselineValues.host);
}
if (Object.prototype.hasOwnProperty.call(patch, 'port')) {
updateDirty('port', nextValues.port === baselineValues.port);
}
if (Object.prototype.hasOwnProperty.call(patch, 'tlsEnable')) {
updateDirty('tlsEnable', nextValues.tlsEnable === baselineValues.tlsEnable);
}
if (Object.prototype.hasOwnProperty.call(patch, 'tlsCert')) {
updateDirty('tlsCert', nextValues.tlsCert === baselineValues.tlsCert);
}
if (Object.prototype.hasOwnProperty.call(patch, 'tlsKey')) {
updateDirty('tlsKey', nextValues.tlsKey === baselineValues.tlsKey);
}
if (Object.prototype.hasOwnProperty.call(patch, 'rmAllowRemote')) {
updateDirty('rmAllowRemote', nextValues.rmAllowRemote === baselineValues.rmAllowRemote);
}
if (Object.prototype.hasOwnProperty.call(patch, 'rmSecretKey')) {
updateDirty('rmSecretKey', nextValues.rmSecretKey === baselineValues.rmSecretKey);
}
if (Object.prototype.hasOwnProperty.call(patch, 'rmDisableControlPanel')) {
updateDirty(
'rmDisableControlPanel',
nextValues.rmDisableControlPanel === baselineValues.rmDisableControlPanel
);
}
if (Object.prototype.hasOwnProperty.call(patch, 'rmPanelRepo')) {
updateDirty('rmPanelRepo', nextValues.rmPanelRepo === baselineValues.rmPanelRepo);
}
if (Object.prototype.hasOwnProperty.call(patch, 'authDir')) {
updateDirty('authDir', nextValues.authDir === baselineValues.authDir);
}
if (Object.prototype.hasOwnProperty.call(patch, 'apiKeysText')) {
updateDirty('apiKeysText', nextValues.apiKeysText === baselineValues.apiKeysText);
}
if (Object.prototype.hasOwnProperty.call(patch, 'debug')) {
updateDirty('debug', nextValues.debug === baselineValues.debug);
}
if (Object.prototype.hasOwnProperty.call(patch, 'commercialMode')) {
updateDirty('commercialMode', nextValues.commercialMode === baselineValues.commercialMode);
}
if (Object.prototype.hasOwnProperty.call(patch, 'loggingToFile')) {
updateDirty('loggingToFile', nextValues.loggingToFile === baselineValues.loggingToFile);
}
if (Object.prototype.hasOwnProperty.call(patch, 'logsMaxTotalSizeMb')) {
updateDirty(
'logsMaxTotalSizeMb',
nextValues.logsMaxTotalSizeMb === baselineValues.logsMaxTotalSizeMb
);
}
if (Object.prototype.hasOwnProperty.call(patch, 'proxyUrl')) {
updateDirty('proxyUrl', nextValues.proxyUrl === baselineValues.proxyUrl);
}
if (Object.prototype.hasOwnProperty.call(patch, 'forceModelPrefix')) {
updateDirty(
'forceModelPrefix',
nextValues.forceModelPrefix === baselineValues.forceModelPrefix
);
}
if (Object.prototype.hasOwnProperty.call(patch, 'requestRetry')) {
updateDirty('requestRetry', nextValues.requestRetry === baselineValues.requestRetry);
}
if (Object.prototype.hasOwnProperty.call(patch, 'maxRetryCredentials')) {
updateDirty(
'maxRetryCredentials',
nextValues.maxRetryCredentials === baselineValues.maxRetryCredentials
);
}
if (Object.prototype.hasOwnProperty.call(patch, 'maxRetryInterval')) {
updateDirty(
'maxRetryInterval',
nextValues.maxRetryInterval === baselineValues.maxRetryInterval
);
}
if (Object.prototype.hasOwnProperty.call(patch, 'wsAuth')) {
updateDirty('wsAuth', nextValues.wsAuth === baselineValues.wsAuth);
}
if (Object.prototype.hasOwnProperty.call(patch, 'quotaSwitchProject')) {
updateDirty(
'quotaSwitchProject',
nextValues.quotaSwitchProject === baselineValues.quotaSwitchProject
);
}
if (Object.prototype.hasOwnProperty.call(patch, 'quotaSwitchPreviewModel')) {
updateDirty(
'quotaSwitchPreviewModel',
nextValues.quotaSwitchPreviewModel === baselineValues.quotaSwitchPreviewModel
);
}
if (Object.prototype.hasOwnProperty.call(patch, 'quotaAntigravityCredits')) {
updateDirty(
'quotaAntigravityCredits',
nextValues.quotaAntigravityCredits === baselineValues.quotaAntigravityCredits
);
}
if (Object.prototype.hasOwnProperty.call(patch, 'routingStrategy')) {
updateDirty('routingStrategy', nextValues.routingStrategy === baselineValues.routingStrategy);
}
if (Object.prototype.hasOwnProperty.call(patch, 'routingSessionAffinity')) {
updateDirty(
'routingSessionAffinity',
nextValues.routingSessionAffinity === baselineValues.routingSessionAffinity
);
}
if (Object.prototype.hasOwnProperty.call(patch, 'routingSessionAffinityTTL')) {
updateDirty(
'routingSessionAffinityTTL',
nextValues.routingSessionAffinityTTL === baselineValues.routingSessionAffinityTTL
);
}
if (Object.prototype.hasOwnProperty.call(patch, 'payloadDefaultRules')) {
updateDirty(
'payloadDefaultRules',