diff --git a/hubcmdui/README.md b/hubcmdui/README.md index 591f14d..e713bb4 100644 --- a/hubcmdui/README.md +++ b/hubcmdui/README.md @@ -91,7 +91,7 @@ docker logs -f [容器ID或名称] - +
@@ -101,7 +101,7 @@ docker logs -f [容器ID或名称] -> 浏览器输入 `服务器地址/admin:30080` 访问后端页面,默认登入账号密码: root/admin +> 浏览器输入 `服务器地址/admin:30080` 访问后端页面,默认登入账号密码: root/admin@123 diff --git a/hubcmdui/config.json b/hubcmdui/config.json index 5b0f17c..433c91e 100644 --- a/hubcmdui/config.json +++ b/hubcmdui/config.json @@ -8,14 +8,14 @@ }, { "text": "GitHub", - "link": "", - "newTab": false + "link": "https://github.com/dqzboy/Docker-Proxy", + "newTab": true } ], "adImages": [ { "url": "https://cdn.jsdelivr.net/gh/dqzboy/Blog-Image/BlogCourse/guanggao.png", - "link": "https://www.dqzboy.com" + "link": "https://github.com/dqzboy/Docker-Proxy" } ], "proxyDomain": "dqzboy.github.io" diff --git a/hubcmdui/server.js b/hubcmdui/server.js index 430d29b..436e0f5 100644 --- a/hubcmdui/server.js +++ b/hubcmdui/server.js @@ -121,8 +121,9 @@ app.post('/api/change-password', async (req, res) => { return res.status(401).json({ error: 'Not logged in' }); } const { currentPassword, newPassword } = req.body; - if (!/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,16}$/.test(newPassword)) { - return res.status(400).json({ error: 'Password must be 8-16 characters long and contain at least one letter and one number' }); + const passwordRegex = /^(?=.*[A-Za-z])(?=.*\d)(?=.*[.,\-_+=()[\]{}|\\;:'"<>?/@$!%*#?&])[A-Za-z\d.,\-_+=()[\]{}|\\;:'"<>?/@$!%*#?&]{8,16}$/; + if (!passwordRegex.test(newPassword)) { + return res.status(400).json({ error: 'Password must be 8-16 characters long and contain at least one letter, one number, and one special character' }); } const users = await readUsers(); const user = users.users.find(u => u.username === req.session.user.username); diff --git a/hubcmdui/users.json b/hubcmdui/users.json index fd6d461..69dc18f 100644 --- a/hubcmdui/users.json +++ b/hubcmdui/users.json @@ -2,7 +2,7 @@ "users": [ { "username": "root", - "password": "$2b$10$wKdemJNjB1I6IpOycHWjwO2MgDFj3QC6KLSMxZE6rHIofuSf.BX/m" + "password": "$2b$10$tu.ceN0qpkl.RSR3fi/uy.9FfJGazUdWJCEPaJCDAhh6mPFbP0GxC" } ] } \ No newline at end of file diff --git a/hubcmdui/web/admin.html b/hubcmdui/web/admin.html index 07e74ca..c1b2ef4 100644 --- a/hubcmdui/web/admin.html +++ b/hubcmdui/web/admin.html @@ -392,13 +392,14 @@ } function renderAdItems() { + console.log('Rendering ad items:', adImages); const tbody = document.getElementById('adTableBody'); tbody.innerHTML = ''; adImages.forEach((ad, index) => { const row = ` - +
@@ -424,6 +425,7 @@ linkInput.disabled = false; button.textContent = '保存'; editingIndex = row.getAttribute('data-index'); + console.log(`Editing ad at index ${editingIndex}:`, { url: urlInput.value, link: linkInput.value }); } else { const url = urlInput.value || ''; const link = linkInput.value || ''; @@ -546,6 +548,7 @@ } async function saveAd(index, ad) { + console.log(`Saving ad at index ${index}:`, ad); const config = { adImages: adImages }; config.adImages[index] = ad; await saveConfig(config); @@ -629,7 +632,7 @@ async function changePassword() { const currentPassword = document.getElementById('currentPassword').value; const newPassword = document.getElementById('newPassword').value; - const passwordRegex = /^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]{8,16}$/; + const passwordRegex = /^(?=.*[A-Za-z])(?=.*\d)(?=.*[.,\-_+=()[\]{}|\\;:'"<>?/@$!%*#?&])[A-Za-z\d.,\-_+=()[\]{}|\\;:'"<>?/@$!%*#?&]{8,16}$/; if (!currentPassword || !newPassword) { alert('请填写当前密码和新密码'); @@ -647,6 +650,17 @@ }); if (response.ok) { alert('密码已修改'); + // 清除当前会话并显示登录模态框 + localStorage.removeItem('isLoggedIn'); + isLoggedIn = false; + document.getElementById('loginModal').style.display = 'block'; + document.getElementById('adminContainer').classList.add('hidden'); + refreshCaptcha(); + + // 清除登录表单中的输入数据 + document.getElementById('username').value = ''; + document.getElementById('password').value = ''; + document.getElementById('captcha').value = ''; } else { alert('修改密码失败'); } @@ -659,7 +673,7 @@ const newPassword = document.getElementById('newPassword').value; const passwordHint = document.getElementById('passwordHint'); - const passwordRegex = /^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]{8,16}$/; + const passwordRegex = /^(?=.*[A-Za-z])(?=.*\d)(?=.*[.,\-_+=()[\]{}|\\;:'"<>?/@$!%*#?&])[A-Za-z\d.,\-_+=()[\]{}|\\;:'"<>?/@$!%*#?&]{8,16}$/; if (!passwordRegex.test(newPassword)) { passwordHint.style.display = 'block'; @@ -670,28 +684,28 @@ // 页面加载时检查登录状态 window.onload = async function() { - try { - const response = await fetch('/api/check-session'); - if (response.ok) { - isLoggedIn = localStorage.getItem('isLoggedIn') === 'true'; - if (isLoggedIn) { - document.getElementById('loginModal').style.display = 'none'; - document.getElementById('adminContainer').classList.remove('hidden'); - loadConfig(); - } else { + try { + const response = await fetch('/api/check-session'); + if (response.ok) { + isLoggedIn = localStorage.getItem('isLoggedIn') === 'true'; + if (isLoggedIn) { + document.getElementById('loginModal').style.display = 'none'; + document.getElementById('adminContainer').classList.remove('hidden'); + loadConfig(); + } else { + document.getElementById('loginModal').style.display = 'block'; + refreshCaptcha(); + } + } else { + localStorage.removeItem('isLoggedIn'); + document.getElementById('loginModal').style.display = 'block'; + refreshCaptcha(); + } + } catch (error) { + localStorage.removeItem('isLoggedIn'); document.getElementById('loginModal').style.display = 'block'; refreshCaptcha(); } - } else { - localStorage.removeItem('isLoggedIn'); - document.getElementById('loginModal').style.display = 'block'; - refreshCaptcha(); - } - } catch (error) { - localStorage.removeItem('isLoggedIn'); - document.getElementById('loginModal').style.display = 'block'; - refreshCaptcha(); - } }; function updateAdImage(adImages) { diff --git a/install/DockerProxy_Install.sh b/install/DockerProxy_Install.sh index 465ea82..287ffe8 100644 --- a/install/DockerProxy_Install.sh +++ b/install/DockerProxy_Install.sh @@ -1809,7 +1809,7 @@ INFO "请用浏览器访问 HubCMD-UI 面板: " INFO "公网访问地址: ${UNDERLINE}http://$PUBLIC_IP:30080${RESET}" INFO "内网访问地址: ${UNDERLINE}http://$INTERNAL_IP:30080${RESET}" INFO -INFO "后端访问地址: 地址后面跟admin,例: ${UNDERLINE}http://$INTERNAL_IP/admin:30080${RESET}" +INFO "后端访问地址: 地址后面跟admin,例: ${UNDERLINE}http://$INTERNAL_IP:30080/admin${RESET}" INFO "默认账号密码: ${LIGHT_GREEN}root${RESET}/${LIGHT_CYAN}admin${RESET}" INFO INFO "服务安装路径: ${LIGHT_BLUE}${CMDUI_DIR}${RESET}"