Allow manual 3x-ui sync without prior save; persist form credentials.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
orohi
2026-07-26 00:25:56 +03:00
co-authored by Cursor
parent d1eb49cb83
commit 69886f130c
2 changed files with 54 additions and 12 deletions
+19 -7
View File
@@ -881,23 +881,35 @@
const btn = document.getElementById('xuiSyncNowBtn');
const text = document.getElementById('xuiSyncNowBtnText');
const spinner = document.getElementById('xuiSyncNowSpinner');
const syncForm = document.getElementById('syncForm');
btn.disabled = true;
text.textContent = _('sync_running');
spinner.classList.remove('hidden');
try {
const res = await fetch('/api/settings/xui_sync_now', { method: 'POST' });
const payload = {
xui_sync: true,
xui_sync_users: true,
xui_url: syncForm.xui_url.value.trim(),
xui_username: syncForm.xui_username.value.trim(),
xui_password: syncForm.xui_password.value,
xui_api_token: syncForm.xui_api_token.value.trim(),
xui_create_conns: syncForm.xui_create_conns.checked,
xui_server_id: parseInt(syncForm.xui_server_id.value || '0'),
xui_protocol: syncForm.xui_protocol.value
};
const res = await fetch('/api/settings/xui_sync_now', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload)
});
const data = await res.json();
if (data.status === 'success') {
showToast(_('sync_success').replace('{}', data.count), 'success');
if (data.message && data.count === 0) {
showToast(data.message, 'error');
} else {
setTimeout(() => window.location.reload(), 1500);
}
setTimeout(() => window.location.reload(), 1500);
} else {
throw new Error(data.message || 'Error occurred');
throw new Error(data.message || data.error || 'Error occurred');
}
} catch (err) {
showToast(`${_('error')}: ` + err.message, 'error');