feat(auth): rebuild the sign-in surfaces on the shared sign-card contract

The login/register page and the auth modal had drifted into a parallel
system: floating-input fields, a sign-page-card shell and a bespoke
jio-auth-modal wrapper that none of the theme's own sign CSS targeted.
The reference card rules (.sign, .sign-img, .sign-content, .line-form-input,
.scale-placeholder, .social_loginbar, .title-h-left, #u_sign .modal-dialog,
.qrcode-signin-container) have been in main.css all along, so the fix is to
render the reference DOM instead of re-styling a second one.

auth-content.php now emits one .sign.jio-panel.blur-bg.relative card with a
.tab-content of #tab-sign-in / #tab-sign-up / #tab-resetpassword /
#tab-qrcode-signin / #tab-bind panes. Each pane opens with a
.title-h-left.fa-2x heading plus a .muted-color.px12 link, fields are
.relative.line-form.mb10 > .line-form-input + .scale-placeholder +
.line-form-line, the verification trigger is the .yztx.abs-right captchsubmit
button, and submits are .but.radius.jb-blue|jb-green.padding-lg.btn-block.
Social entries come from the shared render_social_buttons() separator +
.social_loginbar, and the OAuth bind pane uses the oauth-data-box avatar card.

The modal shell is #u_sign.modal > .modal-dialog > .sign-content >
.sign-img.absolute.hide-sm + .sign, and the page shell is the reference
.container.sign-page > .row.sign-row.gutters-5 > .col-md-6(.col-md-offset-6/
.col-md-offset-3).sign-col with a .fixed.lazyload background and a blurred
fixed footer. auth.js drives .in instead of .is-open, toggles the new
password/signin-mode/invite-gate controls and no longer touches the retired
markup. The page also drops two footer-hook removals that targeted functions
which no longer exist, and opts out of the fixed-nav offset.

The sign page's custom theme setting now actually applies: Router answers
jio_forced_theme_mode, jioData.themeForced wins over the stored cookie in
theme.js, theme-toggle positions are suppressed, and the page marks html/body
dark or white accordingly.

sign.css shrinks from ~114 lines of bespoke component styling to a thin
positioning layer, and the retired classes are gone rather than kept.

Verification: php -l on every changed PHP file, node --check on both JS files,
node --test across widget-system, navigation and front-submit (873 passing),
and tools/audit-psr4-paths.php / audit-admin-contracts.php both at 0 errors.
assets/js/runtime/main.min.js was rebuilt because theme.js gained the forced
theme branch.
This commit is contained in:
kate522 committed 2026-11-04 16:04:24 +08:00
1 parent d40906b4a3
commit 41366e7fc4
15 files changed
+664 -281

No files matched your search

+58 -26
View File
@@ -156,7 +156,7 @@
function isRootActive(root) {
if (!root || root.dataset.activeTab !== 'oauth' || document.visibilityState !== 'visible') return false;
if (root.dataset.surface !== 'modal') return document.documentElement.contains(root);
return !!modal && modal.classList.contains('is-open') && modal.contains(root);
return !!modal && modal.classList.contains('in') && modal.contains(root);
}
function stopQr(root) {
@@ -329,6 +329,8 @@
root.querySelectorAll('[data-auth-panel]').forEach(function (item) {
var active = item === panel;
item.hidden = !active;
item.classList.toggle('active', active);
item.classList.toggle('in', active);
item.setAttribute('aria-hidden', active ? 'false' : 'true');
});
root.querySelectorAll('[data-auth-tab]').forEach(function (item) {
@@ -340,8 +342,12 @@
url.searchParams.set('tab', tab);
window.history.replaceState({}, '', url.toString());
}
var focus = panel.querySelector('input:not([type="hidden"]), button, a[href], [tabindex]:not([tabindex="-1"])');
if (focus) window.setTimeout(function () { focus.focus(); }, 30);
// Only prompt for input on a real user switch; the initial boot should not
// steal focus (and scroll) on the modal or the full page.
if (updateUrl) {
var focus = panel.querySelector('input:not([type="hidden"]), button, a[href], [tabindex]:not([tabindex="-1"])');
if (focus) window.setTimeout(function () { focus.focus(); }, 30);
}
if (tab === 'oauth') loadQr(root, false);
}
@@ -369,11 +375,13 @@
}
function setBusy(form, busy) {
var button = form.querySelector('.sign-submit');
var button = form.querySelector('button[type="submit"]');
if (!button) return;
button.disabled = busy;
var spinner = button.querySelector('.fa-spinner');
if (spinner) spinner.hidden = !busy;
var label = button.querySelector('[data-submit-label]');
if (label) label.hidden = busy;
}
function startCountdown(button, seconds) {
@@ -483,14 +491,13 @@
});
}
function toggleLoginMode(root, button) {
var password = root.querySelector('[data-auth-password-fields]');
var code = root.querySelector('[data-auth-code-fields]');
if (!password || !code) return;
var showCode = code.hidden;
code.hidden = !showCode;
password.hidden = showCode;
button.textContent = showCode ? '使用账号密码登录' : '使用验证码登录';
function switchSigninMode(root, mode) {
root.querySelectorAll('[data-signin-panel]').forEach(function (panel) {
var active = panel.dataset.signinPanel === mode;
panel.hidden = !active;
panel.classList.toggle('active', active);
panel.classList.toggle('in', active);
});
}
function setOAuthRedirect(root, redirect) {
@@ -538,9 +545,6 @@
}
function initRoot(root) {
root.querySelectorAll('input').forEach(function (input) {
if (!input.hasAttribute('placeholder')) input.setAttribute('placeholder', ' ');
});
root.querySelectorAll('form').forEach(function (form) { form.noValidate = true; });
root.querySelectorAll('[data-auth-tab]').forEach(function (tab) {
tab.setAttribute('role', 'tab');
@@ -556,7 +560,7 @@
var initial = root.dataset.initialTab || 'signin';
if (initial === 'oauth' && window.matchMedia && window.matchMedia('(max-width: 767px)').matches) initial = 'signin';
var mayActivateQr = initial !== 'oauth' || document.visibilityState === 'visible';
if (root.dataset.surface === 'modal' && (!modal || !modal.classList.contains('is-open'))) mayActivateQr = false;
if (root.dataset.surface === 'modal' && (!modal || !modal.classList.contains('in'))) mayActivateQr = false;
if (!mayActivateQr) initial = 'signin';
activate(root, initial, false);
root.addEventListener('click', function (event) {
@@ -568,12 +572,15 @@
}
var password = event.target.closest('[data-password-show]');
if (password) {
var input = password.closest('.floating-input').querySelector('input');
var field = password.closest('.line-form') || password.parentElement;
var input = field ? field.querySelector('input') : null;
if (!input) return;
var visible = input.type === 'password';
input.type = visible ? 'text' : 'password';
password.setAttribute('aria-label', visible ? '隐藏密码' : '显示密码');
password.setAttribute('aria-pressed', visible ? 'true' : 'false');
password.querySelector('i').className = visible ? 'fa fas fa-eye-slash' : 'fa fas fa-eye';
var glyph = password.querySelector('i');
if (glyph) glyph.className = visible ? 'fa fas fa-eye-slash' : 'fa fas fa-eye';
return;
}
var send = event.target.closest('[data-send-code]');
@@ -582,10 +589,33 @@
sendCode(send);
return;
}
var mode = event.target.closest('[data-login-mode]');
var mode = event.target.closest('[data-signin-mode]');
if (mode) {
event.preventDefault();
toggleLoginMode(root, mode);
switchSigninMode(root, mode.dataset.signinMode);
return;
}
var inviteGate = event.target.closest('[data-invite-gate]');
if (inviteGate) {
event.preventDefault();
var gateInput = root.querySelector('[data-invite-gate-input]');
var gatePanel = root.querySelector('[data-invite-gate-panel]');
var formPanel = root.querySelector('[data-invite-form-panel]');
if (!gateInput || !formPanel) return;
var code = gateInput.value.trim();
if (!code) {
gateInput.setAttribute('aria-invalid', 'true');
notify('请输入邀请码', 'warning');
return;
}
gateInput.setAttribute('aria-invalid', 'false');
var hiddenInvite = formPanel.querySelector('[data-invite-value]');
if (hiddenInvite) hiddenInvite.value = code;
if (gatePanel) { gatePanel.hidden = true; gatePanel.classList.remove('active', 'in'); }
formPanel.hidden = false;
formPanel.classList.add('active', 'in');
var focus = formPanel.querySelector('input:not([type="hidden"])');
if (focus) window.setTimeout(function () { focus.focus(); }, 30);
return;
}
var refreshQr = event.target.closest('[data-auth-refresh-qr]');
@@ -639,9 +669,10 @@
return;
}
lastModalTrigger = trigger || document.activeElement;
modal.classList.add('is-open');
modal.style.display = 'block';
modal.classList.add('in');
modal.setAttribute('aria-hidden', 'false');
document.body.classList.add('auth-modal-open');
document.body.classList.add('auth-modal-open', 'modal-open');
var root = modal.querySelector('[data-jio-auth]');
if (root) {
var targetRedirect = redirect || window.location.href;
@@ -654,12 +685,13 @@
}
function closeModal(storeDismissal) {
if (!modal || !modal.classList.contains('is-open')) return;
if (!modal || !modal.classList.contains('in')) return;
var root = modal.querySelector('[data-jio-auth]');
if (root) stopQr(root);
modal.classList.remove('is-open');
modal.classList.remove('in');
modal.style.display = '';
modal.setAttribute('aria-hidden', 'true');
document.body.classList.remove('auth-modal-open');
document.body.classList.remove('auth-modal-open', 'modal-open');
if (storeDismissal && Number(modal.dataset.autoExpires) > 0) {
var until = Date.now() + Number(modal.dataset.autoExpires) * 3600000;
window.localStorage.setItem('jioAuthAutoUntil', String(until));
@@ -670,7 +702,7 @@
}
function handleModalKeydown(event) {
if (!modal || !modal.classList.contains('is-open')) return;
if (!modal || !modal.classList.contains('in')) return;
if (event.key === 'Escape') {
event.preventDefault();
closeModal(true);