mirror of
https://github.com/chaos-zhu/easynode.git
synced 2026-10-07 16:18:31 +08:00
feat: 移动端AI 开关关闭不再校验字段
This commit is contained in:
@@ -319,23 +319,29 @@ class _AiAgentSettingsPageState extends ConsumerState<AiAgentSettingsPage> {
|
||||
|
||||
Future<void> _save(AgentProviderConfig original) async {
|
||||
final models = _parseModels(_models.text);
|
||||
setState(() => _modelsInvalid = models.isEmpty);
|
||||
if (_formKey.currentState?.validate() != true || models.isEmpty) return;
|
||||
if (_nativeAgentEnabled) {
|
||||
setState(() => _modelsInvalid = models.isEmpty);
|
||||
if (_formKey.currentState?.validate() != true || models.isEmpty) return;
|
||||
}
|
||||
|
||||
final config = _nativeAgentEnabled
|
||||
? original.copyWith(
|
||||
providerType: _provider,
|
||||
apiUrl: _url.text.trim(),
|
||||
apiKey: _key.text.trim(),
|
||||
models: models,
|
||||
contextLimit: int.parse(_contextLimit.text),
|
||||
maxSteps: int.parse(_maxSteps.text),
|
||||
nativeAgentEnabled: true,
|
||||
)
|
||||
: original.copyWith(nativeAgentEnabled: false);
|
||||
|
||||
setState(() => _saving = true);
|
||||
try {
|
||||
await ref
|
||||
.read(agentSettingsProvider.notifier)
|
||||
.saveSettings(
|
||||
config: original.copyWith(
|
||||
providerType: _provider,
|
||||
apiUrl: _url.text.trim(),
|
||||
apiKey: _key.text.trim(),
|
||||
models: models,
|
||||
contextLimit: int.parse(_contextLimit.text),
|
||||
maxSteps: int.parse(_maxSteps.text),
|
||||
nativeAgentEnabled: _nativeAgentEnabled,
|
||||
),
|
||||
config: config,
|
||||
hostPolicies: _hostPolicies,
|
||||
changedHostPolicies: _hostPolicies
|
||||
.where((policy) => _changedHostIds.contains(policy.hostId))
|
||||
|
||||
@@ -65,11 +65,13 @@ class AgentSettingsNotifier extends AsyncNotifier<AgentSettingsData> {
|
||||
// Provider data and UI preferences use separate endpoints. Keeping the
|
||||
// existing preference out of the provider write prevents a stale settings
|
||||
// form from overwriting another client's UI preference.
|
||||
await _repository.saveProvider(
|
||||
config.copyWith(
|
||||
nativeAgentEnabled: previousEnabled ?? config.nativeAgentEnabled,
|
||||
),
|
||||
);
|
||||
if (config.nativeAgentEnabled) {
|
||||
await _repository.saveProvider(
|
||||
config.copyWith(
|
||||
nativeAgentEnabled: previousEnabled ?? config.nativeAgentEnabled,
|
||||
),
|
||||
);
|
||||
}
|
||||
var savedEnabled = config.nativeAgentEnabled;
|
||||
if (previousEnabled == null ||
|
||||
previousEnabled != config.nativeAgentEnabled) {
|
||||
|
||||
@@ -52,12 +52,7 @@ class _FakeDisabledSettingsNotifier extends AgentSettingsNotifier {
|
||||
|
||||
@override
|
||||
Future<AgentSettingsData> build() async => AgentSettingsData(
|
||||
config: AgentProviderConfig(
|
||||
apiUrl: 'https://api.openai.com/v1',
|
||||
apiKey: 'secret',
|
||||
models: const ['gpt-5.6'],
|
||||
nativeAgentEnabled: false,
|
||||
),
|
||||
config: AgentProviderConfig(nativeAgentEnabled: false),
|
||||
hostPolicies: const [],
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user