diff --git a/src/main/resources/templates/dashboard/user-list.html b/src/main/resources/templates/dashboard/user-list.html index 2561ff4..e8cee22 100644 --- a/src/main/resources/templates/dashboard/user-list.html +++ b/src/main/resources/templates/dashboard/user-list.html @@ -2,6 +2,7 @@

用户列表

+
@@ -29,11 +30,11 @@

用户列表

'X-Admin-Password': adminPassword } }) - .then(response => response.json()) - .then(users => { + 。then(response => response.json()) + 。then(users => { renderUserList(users); }) - .catch(error => { + 。catch(error => { console.error('Error fetching user data:', error); document.getElementById('user-table-body').innerHTML = ''; }); @@ -208,5 +209,51 @@

用户列表

); } + function addDaysToAll() { + mdui.prompt('请输入要为所有用户增加的天数:', '批量增加天数', + function (value) { + let days = parseInt(value); + if (isNaN(days) || days <= 0) { + mdui.alert('请输入一个有效的正整数'); + return; + } + + fetch('/admin/listUsers', { + headers: { + 'X-Admin-Password': adminPassword + } + }) + .then(response => response.json()) + .then(users => { + const promises = users + .filter(user => user.expire !== -1) + .map(user => + fetch(`/admin/renew/${user.username}?day=${days}`, { + method: 'POST', + headers: { + 'X-Admin-Password': adminPassword + }, + }) + ); + + return Promise.all(promises); + }) + .then(() => { + mdui.alert(`已为所有非无限期用户增加 ${days} 天`); + fetchUserData(); // 重新加载用户列表 + }) + .catch(error => { + console.error('Error adding days to all users:', error); + mdui.alert('批量增加天数失败,请稍后再试'); + }); + }, + function (value) {}, + { + confirmText: '确认', + cancelText: '取消' + } + ); + } + fetchUserData()
Error loading user data