()
| 1123 | } |
| 1124 | |
| 1125 | async function handleSaveAutoRegistration() { |
| 1126 | const autoCheckInterval = parseInt(elements.autoRegistrationCheckInterval.value, 10) || 60; |
| 1127 | const autoMinReady = parseInt(elements.autoRegistrationMinReady.value, 10) || 1; |
| 1128 | const autoEmailServiceId = parseInt(elements.autoRegistrationEmailServiceId.value, 10) || 0; |
| 1129 | const autoConcurrency = parseInt(elements.autoRegistrationConcurrency.value, 10) || 1; |
| 1130 | const autoIntervalMin = parseInt(elements.autoRegistrationIntervalMin.value, 10) || 0; |
| 1131 | const autoIntervalMax = parseInt(elements.autoRegistrationIntervalMax.value, 10) || 0; |
| 1132 | const autoCpaServiceId = parseInt(elements.autoRegistrationCpaServiceId.value, 10) || 0; |
| 1133 | |
| 1134 | if (autoCheckInterval < 5 || autoCheckInterval > 3600) { |
| 1135 | toast.error('自动注册检查间隔必须在 5-3600 秒之间'); |
| 1136 | return; |
| 1137 | } |
| 1138 | if (autoMinReady < 1 || autoMinReady > 10000) { |
| 1139 | toast.error('自动注册保底数量必须在 1-10000 之间'); |
| 1140 | return; |
| 1141 | } |
| 1142 | if (autoIntervalMin < 0 || autoIntervalMax < autoIntervalMin) { |
| 1143 | toast.error('自动注册启动间隔参数无效'); |
| 1144 | return; |
| 1145 | } |
| 1146 | if (autoConcurrency < 1 || autoConcurrency > 100) { |
| 1147 | toast.error('自动注册并发数必须在 1-100 之间'); |
| 1148 | return; |
| 1149 | } |
| 1150 | if (elements.autoRegistrationEnabled.checked && autoCpaServiceId <= 0) { |
| 1151 | toast.error('启用自动注册前请先选择一个 CPA 服务'); |
| 1152 | return; |
| 1153 | } |
| 1154 | |
| 1155 | const data = await api.get('/settings'); |
| 1156 | const reg = data.registration || {}; |
| 1157 | const payload = { |
| 1158 | max_retries: reg.max_retries || 3, |
| 1159 | timeout: reg.timeout || 120, |
| 1160 | default_password_length: reg.default_password_length || 12, |
| 1161 | entry_flow: reg.entry_flow || 'native', |
| 1162 | sleep_min: reg.sleep_min || 5, |
| 1163 | sleep_max: reg.sleep_max || 30, |
| 1164 | auto_enabled: elements.autoRegistrationEnabled.checked, |
| 1165 | auto_check_interval: autoCheckInterval, |
| 1166 | auto_min_ready_auth_files: autoMinReady, |
| 1167 | auto_email_service_type: elements.autoRegistrationEmailServiceType.value, |
| 1168 | auto_email_service_id: autoEmailServiceId, |
| 1169 | auto_proxy: elements.autoRegistrationProxy.value.trim(), |
| 1170 | auto_interval_min: autoIntervalMin, |
| 1171 | auto_interval_max: autoIntervalMax, |
| 1172 | auto_concurrency: autoConcurrency, |
| 1173 | auto_mode: elements.autoRegistrationMode.value, |
| 1174 | auto_cpa_service_id: autoCpaServiceId, |
| 1175 | }; |
| 1176 | |
| 1177 | await api.post('/settings/registration', payload); |
| 1178 | toast.success('自动注册设置已保存'); |
| 1179 | |
| 1180 | if (elements.autoRegistrationEnabled.checked) { |
| 1181 | sessionStorage.setItem('activeTask', JSON.stringify({ mode: 'auto' })); |
| 1182 | autoMonitorLastLogIndex = 0; |
no test coverage detected