25/09/24 10:00~11:30 停机维护

This commit is contained in:
Cai
2025-09-24 18:12:45 +08:00
parent 07cf2363ab
commit 3ad36c29ed
13 changed files with 2997 additions and 224 deletions

View File

@@ -30,7 +30,8 @@ body {
border-radius: 15px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
width: 100%;
max-width: 500px;
min-width: 400px;
max-width: 600px;
text-align: center;
}

View File

@@ -0,0 +1,69 @@
.username-group { position: relative; }
.field-tip {
position: absolute;
top: 40%;
left: calc(60% + 10px); /* 紧挨输入框右侧 */
transform: translateY(-50%);
width: 260px;
background: #fff;
border: 1px solid #e5e7eb;
border-radius: 8px;
box-shadow: 0 8px 24px rgba(0,0,0,0.08);
padding: 10px 12px;
font-size: 12px;
line-height: 1.5;
color: #111827;
/* 初始隐藏 */
opacity: 0;
visibility: hidden;
pointer-events: none;
transition: opacity .15s ease, visibility .15s ease;
z-index: 10;
}
.field-tip::after { /* 小三角箭头 */
content: "";
position: absolute;
top: 50%;
left: -6px;
transform: translateY(-50%);
border-width: 6px;
border-style: solid;
border-color: transparent #e5e7eb transparent transparent;
}
.field-tip::before { /* 箭头内层白色 */
content: "";
position: absolute;
top: 50%;
left: -5px;
transform: translateY(-50%);
border-width: 5px;
border-style: solid;
border-color: transparent #fff transparent transparent;
z-index: 1;
}
.field-tip strong { display: block; margin-bottom: 6px; }
.field-tip ul { margin: 0; padding-left: 16px; }
.field-tip li { margin: 2px 0; color: #374151; }
.field-tip span { font-weight: 600; color: #111827; }
/* 显示状态 */
.field-tip.is-visible {
opacity: 1;
visibility: visible;
}
/* 小屏时把提示框放到输入框下方,避免遮挡 */
@media (max-width: 640px) {
.field-tip {
top: calc(60% + 8px);
left: 0;
transform: none;
width: min(92vw, 320px);
}
.field-tip::after,
.field-tip::before {
display: none;
}
}

View File

@@ -8,7 +8,11 @@ document.addEventListener('DOMContentLoaded', function() {
const email = document.getElementById('email').value;
const password = document.getElementById('password').value;
const confirmPassword = document.getElementById('confirm-password').value;
const u = validateLinuxUsername(username);
if (!u.ok) {
alert(u.error);
return;
}
if (password !== confirmPassword) {
alert('密码和确认密码不一致');
return;
@@ -36,4 +40,36 @@ document.addEventListener('DOMContentLoaded', function() {
alert('注册失败');
});
});
});
});
// 校验 Linux 用户名
function validateLinuxUsername(name) {
// 基本字符规则:^[a-z_][a-z0-9_-]*[$]?$
const basic = /^[a-z_][a-z0-9_-]*[$]?$/;
if (typeof name !== 'string' || name.length === 0) {
return { ok: false, error: '用户名不能为空' };
}
// 长度限制(常见系统为 <= 32
if (name.length > 32) {
return { ok: false, error: '用户名长度不能超过 32 个字符' };
}
if (!basic.test(name)) {
return {
ok: false,
error:
'用户名需以小写字母或下划线开头,仅包含小写字母、数字、下划线、连字符,允许以 $ 结尾'
};
}
// 可选:避免纯数字用户名(多数系统不推荐)
if (/^[0-9]+$/.test(name)) {
return { ok: false, error: '用户名不能为纯数字' };
}
// 可选:避免使用保留名
const reserved = new Set(['root', 'daemon', 'bin', 'sys', 'sync', 'games', 'man']);
if (reserved.has(name)) {
return { ok: false, error: '该用户名为系统保留名,请更换' };
}
return { ok: true };
}

View File

@@ -0,0 +1,27 @@
(function () {
let usernameInput = document.getElementById('username');
if (!usernameInput){
usernameInput = document.getElementById('teacher-username');
}
const tip = document.getElementById('username-tip');
function showTip() {
tip.classList.add('is-visible');
tip.setAttribute('aria-hidden', 'false');
}
function hideTip() {
tip.classList.remove('is-visible');
tip.setAttribute('aria-hidden', 'true');
}
usernameInput.addEventListener('focus', showTip);
usernameInput.addEventListener('blur', hideTip);
// 当用户点击提示框自身时不影响(比如复制文本)
tip.addEventListener('mousedown', e => e.preventDefault());
// 可选:输入时也显示(防止因某些浏览器失焦导致闪烁)
usernameInput.addEventListener('input', () => {
if (document.activeElement === usernameInput) showTip();
});
})();

View File

@@ -8,7 +8,11 @@ document.addEventListener('DOMContentLoaded', function() {
const email = document.getElementById('teacher-email').value;
const password = document.getElementById('teacher-password').value;
const confirmPassword = document.getElementById('teacher-confirm-password').value;
const u = validateLinuxUsername(username);
if (!u.ok) {
alert(u.error);
return;
}
// 检查密码和确认密码是否一致
if (password !== confirmPassword) {
alert('密码和确认密码不一致');
@@ -39,3 +43,35 @@ document.addEventListener('DOMContentLoaded', function() {
});
});
});
// 校验 Linux 用户名
function validateLinuxUsername(name) {
// 基本字符规则:^[a-z_][a-z0-9_-]*[$]?$
const basic = /^[a-z_][a-z0-9_-]*[$]?$/;
if (typeof name !== 'string' || name.length === 0) {
return { ok: false, error: '用户名不能为空' };
}
// 长度限制(常见系统为 <= 32
if (name.length > 32) {
return { ok: false, error: '用户名长度不能超过 32 个字符' };
}
if (!basic.test(name)) {
return {
ok: false,
error:
'用户名需以小写字母或下划线开头,仅包含小写字母、数字、下划线、连字符,允许以 $ 结尾'
};
}
// 可选:避免纯数字用户名(多数系统不推荐)
if (/^[0-9]+$/.test(name)) {
return { ok: false, error: '用户名不能为纯数字' };
}
// 可选:避免使用保留名
const reserved = new Set(['root', 'daemon', 'bin', 'sys', 'sync', 'games', 'man']);
if (reserved.has(name)) {
return { ok: false, error: '该用户名为系统保留名,请更换' };
}
return { ok: true };
}