Compare commits
4 Commits
a8863f911b
...
4003fd5bc1
Author | SHA1 | Date | |
---|---|---|---|
![]() |
4003fd5bc1 | ||
![]() |
afd4981ba7 | ||
![]() |
77c38cd17d | ||
![]() |
0c3d9d7287 |
@ -6,11 +6,11 @@
|
||||
<h2>🔐 登录信息</h2>
|
||||
<form method="post" action="/login">
|
||||
<div class="mb-3">
|
||||
<label for="user" class="form-label">用户名</label>
|
||||
<label for="user" class="form-label" id="user-label">用户名</label>
|
||||
<input type="text" class="form-control" id="user" name="user">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="pw" class="form-label">密码</label>
|
||||
<label for="pw" class="form-label" id="pw-label">密码</label>
|
||||
<input type="password" class="form-control" id="pw" name="pw">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
@ -38,4 +38,31 @@
|
||||
{% if message %}
|
||||
<div class="alert alert-{{ 'success' if success else 'danger' }} mt-4">{{ message }}</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const tokenInput = document.getElementById('token');
|
||||
const inputs = [document.getElementById('user'), document.getElementById('pw')];
|
||||
const labels = [document.getElementById('user-label'), document.getElementById('pw-label')];
|
||||
const fieldClasses = ['bg-body-secondary', 'text-body-secondary', 'text-decoration-line-through'];
|
||||
|
||||
function toggleCredFields() {
|
||||
const inactive = tokenInput.value.trim() !== '';
|
||||
inputs.forEach(el => {
|
||||
el.readOnly = inactive;
|
||||
el.tabIndex = inactive ? -1 : 0;
|
||||
el.style.pointerEvents = inactive ? 'none' : '';
|
||||
if (inactive && document.activeElement === el) {
|
||||
el.blur();
|
||||
}
|
||||
fieldClasses.forEach(cls => el.classList.toggle(cls, inactive));
|
||||
});
|
||||
labels.forEach(el => {
|
||||
['text-decoration-line-through', 'text-body-secondary'].forEach(cls => el.classList.toggle(cls, inactive));
|
||||
});
|
||||
}
|
||||
|
||||
tokenInput.addEventListener('input', toggleCredFields);
|
||||
toggleCredFields();
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
Loading…
Reference in New Issue
Block a user