feat(profile): rebuild account settings page

This commit is contained in:
2026-10-05 18:58:49 +08:00
parent f00c3faeaa
commit 346146b4fa
14 changed files with 609 additions and 750 deletions
-1
View File
@@ -1,3 +1,2 @@
@import url("profile/layout.css");
@import url("profile/lists.css");
@import url("profile/modals.css");
+4 -127
View File
@@ -452,49 +452,15 @@
}
/* ==================== 账号设置区 ==================== */
.settings-section {
margin-bottom: 20px;
}
.settings-section__header {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 14px;
}
.settings-icon {
display: flex;
align-items: center;
justify-content: center;
width: 32px;
height: 32px;
border-radius: 8px;
background: var(--color-primary);
color: var(--color-on-primary, #fff);
font-size: 16px;
flex-shrink: 0;
}
.settings-icon i,
.security-action-icon i,
.aksrt-modal__icon i,
.aksrt-modal__close i {
line-height: 1;
}
.settings-hint {
font-size: 13px;
color: var(--color-ink-4);
margin: 4px 0 12px;
}
.settings-hint--top {
margin-top: 0;
margin-bottom: 10px;
line-height: 1.6;
}
.settings-hint--bottom {
margin-top: 8px;
}
.settings-section__title {
margin: 0;
border: 0;
}
.settings-empty {
font-size: 13px;
color: var(--color-ink-4);
@@ -502,22 +468,7 @@
text-align: center;
}
/* ---- 第三方绑定列表 ---- */
.binding-list {
display: flex;
flex-direction: column;
gap: 8px;
}
.binding-item {
display: flex;
align-items: center;
gap: 10px;
padding: 11px 14px;
background: var(--surface-1);
border: 1px solid var(--color-line);
border-radius: 8px;
transition: border-color 0.15s, background 0.15s;
}
/* ---- 第三方绑定列表公共行为 ---- */
.binding-item--linkable {
cursor: pointer;
text-decoration: none;
@@ -539,13 +490,6 @@
font-size: 22px;
line-height: 1;
}
.binding-item__meta {
display: flex;
flex: 1;
align-items: center;
gap: 8px;
min-width: 0;
}
.binding-status {
display: inline-flex;
align-items: center;
@@ -558,13 +502,9 @@
.binding-status--idle {
color: var(--color-ink-4);
}
.binding-item__name {
font-size: 14px;
font-weight: 600;
min-width: 0;
.badge__icon {
line-height: 1;
}
/* ---- 徽章 ---- */
.badge {
display: inline-flex;
align-items: center;
@@ -576,18 +516,6 @@
line-height: 1.5;
white-space: nowrap;
}
.badge__icon {
line-height: 1;
}
.badge--bound {
background: #ecfdf5;
color: #059669;
}
.badge--bind {
background: #eff6ff;
color: var(--color-primary);
border: 1px solid var(--color-primary-soft);
}
/* ---- 解绑按钮 ---- */
.binding-unbind-btn {
@@ -605,57 +533,6 @@
background: rgba(239, 68, 68, 0.08);
}
/* ---- 安全设置操作区 ---- */
.security-actions {
display: flex;
flex-direction: column;
gap: 12px;
}
.security-action-item {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
padding: 16px;
background: var(--surface-1);
border: 1px solid var(--color-line);
border-radius: 10px;
}
.security-action-info {
display: flex;
align-items: center;
gap: 12px;
flex: 1;
min-width: 0;
}
.security-action-icon {
display: flex;
align-items: center;
justify-content: center;
width: 38px;
height: 38px;
border-radius: 10px;
background: var(--color-primary-soft);
color: var(--color-primary);
flex-shrink: 0;
font-size: 18px;
}
.security-action-text {
display: flex;
flex-direction: column;
gap: 2px;
min-width: 0;
}
.security-action-title {
font-size: 14px;
font-weight: 600;
color: var(--color-ink);
}
.security-action-desc {
font-size: 12px;
color: var(--color-ink-4);
}
/* legacy-style user tabs: one panel outside, flat rows inside. */
.dashboard--public .profile-list,
.uc-content #panel-posts .profile-list,
-251
View File
@@ -1,251 +0,0 @@
/* ==================== Modal 弹窗 ==================== */
.aksrt-modal {
display: none;
position: fixed;
inset: 0;
z-index: 99998;
align-items: center;
justify-content: center;
}
.aksrt-modal[hidden] {
display: none !important;
}
.aksrt-modal.is-open {
display: flex;
}
.aksrt-modal__overlay {
position: absolute;
inset: 0;
background: rgba(18, 18, 18, 0.48);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
animation: modalFadeIn 0.2s ease forwards;
}
.aksrt-modal__box {
position: relative;
width: 92%;
max-width: 440px;
max-height: 90vh;
overflow-y: auto;
background: var(--surface-1);
border: none;
border-radius: var(--radius-2xl, 16px);
box-shadow: var(--shadow-drawer);
animation: modalSlideUp 0.28s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes modalFadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes modalSlideUp {
from { opacity: 0; transform: translateY(24px) scale(0.96); }
to { opacity: 1; transform: translateY(0) scale(1); }
}
/* Modal 头部 */
.aksrt-modal__header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 18px 20px;
border-bottom: 1px solid var(--color-line);
}
.aksrt-modal__title-wrap {
display: flex;
align-items: center;
gap: 8px;
}
.aksrt-modal__icon {
display: flex;
align-items: center;
width: 30px;
height: 30px;
border-radius: 8px;
background: var(--color-primary-soft);
color: var(--color-primary);
font-size: 16px;
}
.aksrt-modal__title-wrap h4 {
margin: 0;
font-size: 16px;
font-weight: 700;
color: var(--color-ink);
}
.aksrt-modal__close {
display: flex;
align-items: center;
justify-content: center;
width: 32px;
height: 32px;
border: none;
border-radius: 8px;
background: transparent;
color: var(--color-ink-4);
cursor: pointer;
font-size: 18px;
transition: background 0.15s, color 0.15s;
}
.aksrt-modal__close:hover {
background: var(--surface-2);
color: var(--color-ink);
}
/* Modal 表单字段 */
.aksrt-modal__box form {
padding: 20px;
}
.modal-field {
position: relative;
margin-bottom: 16px;
}
.modal-field label {
display: block;
margin-bottom: 6px;
font-size: 13px;
font-weight: 600;
color: var(--color-ink-2);
}
.modal-field input[type="password"],
.modal-field input[type="email"],
.modal-field input[type="tel"],
.modal-field input[type="text"] {
display: block;
width: 100%;
padding: 10px 40px 10px 14px;
font-size: 14px;
line-height: 1.5;
color: var(--color-ink);
background: var(--surface-4, var(--surface-2));
border: 1px solid var(--color-line);
border-radius: 8px;
outline: none;
transition: border-color 0.2s, box-shadow 0.2s;
box-sizing: border-box;
}
.modal-field input:focus {
border-color: var(--color-primary);
box-shadow: 0 0 0 3px var(--color-primary-soft);
background: var(--surface-1);
}
.toggle-pwd {
position: absolute;
right: 10px;
top: 31px;
width: 34px;
height: 34px;
border: none;
border-radius: 6px;
background: transparent;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
color: var(--color-ink-4);
font-size: 16px;
}
.toggle-pwd:hover {
color: var(--color-ink);
}
/* 只读显示(当前邮箱) */
.readonly-display {
display: block;
padding: 10px 14px;
font-size: 14px;
color: var(--color-ink-4);
background: var(--surface-2);
border: 1.5px solid var(--color-line);
border-radius: 8px;
word-break: break-all;
}
/* 验证码输入组 */
.code-input-group {
display: flex;
gap: 8px;
align-items: stretch;
}
.code-input-group input {
flex: 1;
min-width: 0;
padding: 10px 14px !important;
font-family: inherit !important;
letter-spacing: 2px;
font-weight: 600;
}
.code-send-btn {
flex-shrink: 0;
white-space: nowrap;
min-width: 110px;
}
.code-send-btn.is-counting {
pointer-events: none;
opacity: 0.65;
}
/* 密码强度条 */
.pwd-strength {
display: flex;
gap: 4px;
margin-top: 7px;
height: 4px;
border-radius: 2px;
overflow: hidden;
background: var(--surface-3);
}
.pwd-strength__fill {
width: 0%;
height: 100%;
border-radius: 2px;
transition: width 0.3s ease, background-color 0.3s ease;
background-color: var(--color-error);
}
.pwd-strength__fill.level-weak { width: 33%; background-color: var(--color-error); }
.pwd-strength__fill.level-medium { width: 66%; background-color: var(--color-warning); }
.pwd-strength__fill.level-strong { width: 100%; background-color: var(--color-success); }
.pwd-strength__text {
font-size: 11px;
margin-top: 4px;
font-weight: 500;
transition: color 0.2s;
}
.pwd-strength__text.level-weak { color: var(--color-error); }
.pwd-strength__text.level-medium { color: var(--color-warning); }
.pwd-strength__text.level-strong { color: var(--color-success); }
/* 人机验证容器在弹窗中的适配 */
.aksrt-modal .aksrt-captcha-wrap {
margin: 14px 0 8px;
}
.aksrt-modal .aksrt-captcha-box {
display: block !important;
}
/* Modal 底部按钮栏 */
.aksrt-modal__footer {
display: flex;
justify-content: flex-end;
gap: 10px;
margin-top: 20px;
padding-top: 16px;
border-top: 1px solid var(--color-line);
}
/* Modal mobile */
@media (max-width: 640px) {
.aksrt-modal__box {
width: 96%;
max-height: 92vh;
border-radius: 14px;
}
.aksrt-modal__footer {
flex-direction: column-reverse;
}
.aksrt-modal__footer .btn,
.aksrt-modal__footer button {
width: 100%;
}
.code-input-group {
flex-direction: column;
}
.code-send-btn {
width: 100%;
}
}
+225 -31
View File
@@ -144,52 +144,155 @@
min-width: 112px;
}
/* 设置区增强 */
.uc-content .settings-section {
margin-bottom: 24px;
/* 账号设置:按参考主题 account-set / box-body / oauth-bind-box 分区与排布。 */
.uc-content #panel-settings .aksrt-account-settings {
margin: -24px;
overflow: hidden;
border-radius: inherit;
}
.uc-content .settings-section__header {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 16px;
.aksrt-account-settings__section {
padding: 15px;
border-bottom: 1px solid var(--color-line-soft, rgba(0, 0, 0, .06));
}
.uc-content .settings-icon {
width: 36px;
height: 36px;
border-radius: 10px;
.aksrt-account-settings__section:last-child { border-bottom: 0; }
.aksrt-account-settings__heading {
display: flex;
align-items: center;
justify-content: center;
background: var(--color-primary);
color: #fff;
align-items: flex-start;
justify-content: space-between;
gap: 16px;
margin-bottom: 20px;
}
.aksrt-account-settings__heading .title-h-left {
margin: 0 0 8px;
font-size: 16px;
flex-shrink: 0;
}
.uc-content .settings-section__title {
.aksrt-account-settings__heading p {
margin: 0;
border: 0;
font-size: 16px;
color: var(--muted-2-color, var(--color-ink-4, #999));
font-size: 14px;
line-height: 1.6;
}
.uc-content .settings-section__title::before {
display: none;
.aksrt-account-list {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 10px;
}
/* 安全操作项增强 */
.uc-content .security-action-item {
border: 1px solid var(--color-line-soft, rgba(0,0,0,0.06));
border-radius: 10px;
padding: 16px;
transition: border-color 0.2s, box-shadow 0.2s;
.aksrt-account-row {
display: grid;
grid-template-columns: minmax(116px, .85fr) minmax(0, 1fr) auto;
align-items: center;
gap: 12px;
min-width: 0;
padding: 12px 14px;
border-radius: var(--main-radius, 8px);
background: var(--muted-border-color, var(--surface-2, #f5f6f7));
color: inherit;
}
.uc-content .security-action-item:hover {
border-color: var(--color-primary-soft);
box-shadow: 0 2px 8px rgba(0,0,0,0.04);
.aksrt-account-row__identity {
display: flex;
align-items: center;
gap: 6px;
min-width: 0;
}
.aksrt-account-row__icon {
display: grid;
place-items: center;
width: 26px;
height: 26px;
flex: 0 0 26px;
border-radius: 50%;
background: var(--this-bg, rgba(41, 151, 247, .12));
color: var(--this-color, #2997f7);
}
.aksrt-account-row__icon--blue { --this-bg: rgba(41, 151, 247, .12); --this-color: #2997f7; }
.aksrt-account-row__icon--blue-2 { --this-bg: rgba(73, 174, 231, .12); --this-color: #49aee7; }
.aksrt-account-row__icon--purple { --this-bg: rgba(136, 84, 230, .12); --this-color: #8854e6; }
.aksrt-account-row__copy {
display: block;
min-width: 0;
overflow: hidden;
color: var(--color-ink, #333);
font-size: 14px;
font-weight: 400;
text-overflow: ellipsis;
white-space: nowrap;
}
.aksrt-account-row__social-name {
overflow: hidden;
color: var(--color-ink, #333);
font-size: 13px;
font-weight: 400;
text-overflow: ellipsis;
white-space: nowrap;
}
.aksrt-account-row__value {
overflow: hidden;
min-width: 0;
color: var(--muted-2-color, var(--color-ink-3, #777));
font-size: 12px;
text-align: right;
text-overflow: ellipsis;
white-space: nowrap;
}
.aksrt-account-row__action {
flex: 0 0 auto;
margin: 0;
padding: 4px 10px;
border-radius: 999px;
font-size: 12px;
line-height: 1.5;
white-space: nowrap;
}
.aksrt-account-row--simple { grid-template-columns: minmax(0, 1fr) auto; }
.aksrt-account-row__action--unavailable { color: var(--muted-2-color, #999); }
.aksrt-account-settings__section--social .binding-captcha { margin-bottom: 12px; }
.aksrt-account-list--social .binding-item { border: 0; }
.aksrt-account-list--social .aksrt-account-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto auto; text-decoration: none; }
.aksrt-account-list--social .binding-item__icon { display: grid; place-items: center; width: 24px; height: 24px; color: var(--color-ink, #333); }
.aksrt-account-list--social .binding-item__icon i { font-size: 22px; line-height: 1; }
.aksrt-account-list--social .binding-status { display: inline-flex; align-items: center; gap: 4px; color: var(--color-success, #16a34a); font-size: 11px; white-space: nowrap; }
.aksrt-account-list--social .binding-status--idle { color: var(--muted-2-color, var(--color-ink-4, #999)); }
.aksrt-account-list--social .binding-unbind-btn { color: var(--this-color, #e4a11b); }
.aksrt-account-list--social .binding-item--linkable:hover { background: var(--color-primary-softer, var(--color-primary-soft, rgba(41, 151, 247, .08))); }
@media (max-width: 640px) {
.aksrt-account-list { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 767px) {
.uc-content #panel-settings .aksrt-account-settings { margin: -16px; }
}
@media (max-width: 520px) {
.uc-content #panel-settings .aksrt-account-settings { margin: -16px; }
.aksrt-account-settings__section { padding: 15px; }
.aksrt-account-row { grid-template-columns: minmax(0, 1fr) auto; gap: 8px 10px; padding: 12px; }
.aksrt-account-row__identity { grid-column: 1; }
.aksrt-account-row__value { grid-column: 1; grid-row: 2; padding-left: 38px; text-align: left; }
.aksrt-account-row__action { grid-column: 2; grid-row: 1 / span 2; }
.aksrt-account-list--social .aksrt-account-row { grid-template-columns: 24px minmax(0, 1fr) auto; gap: 6px 8px; }
.aksrt-account-list--social .binding-status { grid-column: 2; grid-row: 2; }
.aksrt-account-list--social .aksrt-account-row__action { grid-column: 3; grid-row: 1 / span 2; }
}
@media (max-width: 480px) {
.uc-content #panel-settings .aksrt-account-settings { margin: -14px; }
}
/* 邀请区增强 */
@@ -502,6 +605,97 @@
margin-top: 4px;
}
/* 账号设置弹窗:使用 AksrtModalRuntime,几何和标题区对齐参考 modal-mini。 */
.aksrt-modal-runtime.aksrt-user-settings-modal:not(.aksrt-modal-runtime--bottom) .aksrt-modal-runtime__dialog {
width: 400px;
max-width: calc(100vw - 20px);
max-height: calc(100vh - 20px);
max-height: calc(100dvh - 20px);
overflow: auto;
border-radius: var(--main-radius, 8px);
}
.aksrt-user-settings-modal .aksrt-modal-runtime__content { padding: 0; }
.aksrt-settings-modal {
position: relative;
overflow: hidden;
border-radius: var(--main-radius, 8px);
background: var(--main-bg-color, var(--surface-1, #fff));
}
.aksrt-settings-modal .modal-colorful-header {
position: absolute;
top: 0;
right: 0;
left: 0;
z-index: 1;
height: 120px;
border-radius: var(--main-radius, 8px) var(--main-radius, 8px) 0 0;
}
.aksrt-settings-modal .modal-colorful-header > .close {
width: 30px;
height: 30px;
padding: 0;
border: 0;
background: transparent;
cursor: pointer;
}
.aksrt-settings-modal form {
position: relative;
z-index: 0;
margin-top: 120px;
padding: 18px 15px 0;
}
.aksrt-settings-modal__fields { padding: 0 2px; }
.aksrt-settings-modal .modal-field { position: relative; margin-bottom: 14px; }
.aksrt-settings-modal .modal-field label { display: block; margin-bottom: 6px; color: var(--muted-2-color, #777); font-size: 12px; font-weight: 400; }
.aksrt-settings-modal .modal-field input,
.aksrt-settings-modal .readonly-display {
display: block;
width: 100%;
min-height: 38px;
box-sizing: border-box;
padding: 8px 38px 8px 11px;
border: 1px solid var(--main-border-color, var(--color-line, rgba(50, 50, 50, .12)));
border-radius: var(--mini-radius, 4px);
background: var(--main-bg-color, var(--surface-1, #fff));
color: var(--color-ink, #333);
font-size: 13px;
outline: 0;
}
.aksrt-settings-modal .readonly-display { padding-right: 11px; color: var(--muted-2-color, #777); word-break: break-all; }
.aksrt-settings-modal .modal-field input:focus { border-color: var(--focus-color, var(--color-primary, #2997f7)); box-shadow: 0 0 0 2px var(--focus-color-opacity1, rgba(41, 151, 247, .12)); }
.aksrt-settings-modal .toggle-pwd { position: absolute; right: 7px; bottom: 4px; width: 30px; height: 30px; padding: 0; border: 0; background: transparent; color: var(--muted-2-color, #999); cursor: pointer; }
.aksrt-settings-modal .toggle-pwd:hover { color: var(--color-ink, #333); }
.aksrt-settings-modal .code-input-group { display: flex; align-items: stretch; gap: 7px; }
.aksrt-settings-modal .code-input-group input { min-width: 0; padding-right: 11px; letter-spacing: 2px; }
.aksrt-settings-modal .code-send-btn { min-width: 112px; padding: 6px 10px; white-space: nowrap; }
.aksrt-settings-modal .code-send-btn.is-counting { pointer-events: none; opacity: .6; }
.aksrt-settings-modal .pwd-strength { height: 3px; margin-top: 6px; border-radius: 2px; background: var(--muted-border-color, #eee); overflow: hidden; }
.aksrt-settings-modal .pwd-strength__fill { width: 0; height: 100%; border-radius: inherit; transition: width .2s ease, background-color .2s ease; }
.aksrt-settings-modal .pwd-strength__fill.level-weak { width: 33%; background: var(--color-error, #ef4444); }
.aksrt-settings-modal .pwd-strength__fill.level-medium { width: 66%; background: var(--color-warning, #f59e0b); }
.aksrt-settings-modal .pwd-strength__fill.level-strong { width: 100%; background: var(--color-success, #10b981); }
.aksrt-settings-modal .pwd-strength__text { display: block; min-height: 16px; margin-top: 3px; color: var(--muted-2-color, #999); font-size: 11px; }
.aksrt-settings-modal .pwd-strength__text.level-weak { color: var(--color-error, #ef4444); }
.aksrt-settings-modal .pwd-strength__text.level-medium { color: var(--color-warning, #f59e0b); }
.aksrt-settings-modal .pwd-strength__text.level-strong { color: var(--color-success, #10b981); }
.aksrt-settings-modal .aksrt-captcha-wrap { margin: 12px 0 8px; }
.aksrt-settings-modal__footer { margin: 0 -15px; border-radius: 0 0 var(--main-radius, 8px) var(--main-radius, 8px); }
.aksrt-settings-modal__footer > .but { min-height: 46px; }
@media (max-width: 768px) {
.aksrt-modal-runtime.aksrt-user-settings-modal.aksrt-modal-runtime--bottom .aksrt-modal-runtime__dialog {
max-height: calc(100dvh - env(safe-area-inset-bottom));
}
.aksrt-settings-modal .code-input-group { gap: 6px; }
.aksrt-settings-modal .code-send-btn { min-width: 104px; }
}
/* ==================== 官方认证面板 ==================== */
/* 面板内容为 Zibll 同款 colorful-bg hero 卡片(参考主题 1:1),去掉外层白卡壳 */
+1 -1
View File
@@ -93,7 +93,7 @@
var url = new URL(window.location.href);
var action = url.searchParams.get('oauth_action');
if (['login', 'bind', 'error'].indexOf(action) === -1) return;
var userCenterOwnsBind = action === 'bind' && /\/user(?:\/settings)?\/?$/.test(url.pathname) && document.querySelector('[data-identity-root], .settings-section');
var userCenterOwnsBind = action === 'bind' && /\/user(?:\/settings)?\/?$/.test(url.pathname) && document.querySelector('[data-identity-root], [data-aksrt-settings-root]');
if (userCenterOwnsBind) return;
document.documentElement.dataset.aksrtOauthResultHandled = 'true';
+169 -116
View File
@@ -709,93 +709,113 @@
if (!ajaxUrl || !settingsNonce) return;
root = root || document;
function openModal(id) {
var m = document.getElementById(id);
if (!m) return;
m.hidden = false;
m.classList.add('is-open');
document.body.style.overflow = 'hidden';
var firstInput = m.querySelector('input:not([type=hidden])');
if (firstInput) setTimeout(function() { firstInput.focus(); }, 200);
}
function closeModal(m) {
if (typeof m === 'string') m = document.getElementById(m);
if (!m) return;
m.classList.remove('is-open');
m.hidden = true;
document.body.style.overflow = '';
var f = m.querySelector('form');
var sceneMap = { 'pwd-modal': 'change_password', 'email-modal': 'change_email', 'phone-modal': 'bind_phone' };
var scene = m.id && sceneMap[m.id] ? sceneMap[m.id] : '';
if (f) {
f.reset();
var bar = document.getElementById('pwd-strength-bar');
var txt = document.getElementById('pwd-strength-text');
if (bar && bar.firstChild) { bar.style.width = '0'; bar.firstChild.className = 'pwd-strength__fill'; }
if (txt) { txt.textContent = ''; txt.className = 'pwd-strength__text'; }
}
if (scene) resetCaptcha(scene, f || m);
}
root.querySelectorAll('.security-trigger').forEach(function(btn) {
if (btn.dataset.aksrtSettingsInitialized === 'true') return;
btn.dataset.aksrtSettingsInitialized = 'true';
btn.addEventListener('click', function() { openModal(this.getAttribute('data-modal')); });
});
root.querySelectorAll('[data-close-modal], [data-modal-close]').forEach(function(el) {
if (el.dataset.aksrtSettingsInitialized === 'true') return;
el.dataset.aksrtSettingsInitialized = 'true';
el.addEventListener('click', function() { closeModal(this.closest('.aksrt-modal')); });
});
if (document.documentElement.dataset.aksrtSettingsKeyboardInitialized !== 'true') {
document.documentElement.dataset.aksrtSettingsKeyboardInitialized = 'true';
document.addEventListener('keydown', function(e) {
if (e.key === 'Escape') {
var openM = document.querySelector('.aksrt-modal.is-open');
if (openM) closeModal(openM);
}
function openSettingsModal(kind) {
var runtime = window.AksrtModalRuntime;
var template = document.querySelector('template[data-aksrt-settings-modal-template="' + kind + '"]');
if (!runtime || typeof runtime.open !== 'function' || !template) return;
var title = kind === 'password' ? '修改密码' : (kind === 'email' ? '更改邮箱' : '绑定手机');
runtime.open({
html: template.innerHTML,
kind: 'account-settings',
className: 'aksrt-user-settings-modal modal-mini',
mobileBottom: true,
onContent: function (_, session) {
var shell = session && session.shell;
if (!shell) return;
shell.setAttribute('aria-label', title);
var firstInput = shell.querySelector('input:not([type="hidden"]), textarea, select');
if (firstInput) firstInput.focus();
bindModalFields(shell);
initBindPhone(shell);
},
});
}
// 密码显隐切换
root.querySelectorAll('#pwd-modal .toggle-pwd, #email-modal .toggle-pwd').forEach(function(btn) {
function bindModalFields(scope) {
if (!scope) return;
scope.querySelectorAll('.toggle-pwd').forEach(function(btn) {
if (btn.dataset.aksrtSettingsInitialized === 'true') return;
btn.dataset.aksrtSettingsInitialized = 'true';
btn.addEventListener('click', function() {
var inp = scope.querySelector('#' + this.getAttribute('data-target'));
if (!inp) return;
inp.type = inp.type === 'password' ? 'text' : 'password';
this.classList.toggle('is-visible');
var icon = this.querySelector('i');
if (icon) {
icon.classList.toggle('fa-eye', inp.type === 'password');
icon.classList.toggle('fa-eye-slash', inp.type === 'text');
}
});
});
var pInput = scope.querySelector('#pwd-new');
var sBar = scope.querySelector('#pwd-strength-bar');
var sTxt = scope.querySelector('#pwd-strength-text');
if (pInput && sBar && sTxt) {
pInput.addEventListener('input', function() {
var v = this.value;
var fill = sBar.querySelector('.pwd-strength__fill');
if (!v) { fill.className = 'pwd-strength__fill'; sTxt.className = 'pwd-strength__text'; sTxt.textContent = ''; return; }
var score = 0;
if (v.length >= 6) score++;
if (v.length >= 10) score++;
if (/[a-z]/.test(v) && /[A-Z]/.test(v)) score++;
if (/\d/.test(v)) score++;
if (/[^a-zA-Z0-9]/.test(v)) score++;
var level = score <= 1 ? 'weak' : (score <= 3 ? 'medium' : 'strong');
var label = score <= 1 ? '弱' : (score <= 3 ? '中' : '强');
fill.className = 'pwd-strength__fill level-' + level;
sTxt.className = 'pwd-strength__text level-' + level;
sTxt.textContent = '密码强度: ' + label;
});
}
bindSend('pwd-send-code', 'pwd-form', 'change_password', scope);
bindSend('email-send-code', 'email-form', 'change_email', scope);
submitForm('pwd-form', 'aksrt_change_password', scope);
submitForm('email-form', 'aksrt_change_email', scope);
}
function resetSettingsModal(shell) {
if (!shell || !shell.classList.contains('aksrt-user-settings-modal')) return;
shell.dataset.aksrtSettingsModalClosed = 'true';
var forms = shell.querySelectorAll('form');
var sceneMap = { 'pwd-form': 'change_password', 'email-form': 'change_email', 'aksrt-bind-phone-form': 'bind_phone' };
forms.forEach(function(form) {
form.reset();
var scene = sceneMap[form.id];
if (scene) resetCaptcha(scene, form);
form.querySelectorAll('[data-aksrt-countdown]').forEach(function(button) {
if (button.__aksrtCountdownTimer) window.clearInterval(button.__aksrtCountdownTimer);
button.__aksrtCountdownTimer = null;
button.disabled = false;
button.classList.remove('is-counting');
button.textContent = button.getAttribute('data-idle-label') || button.textContent;
});
});
var bar = shell.querySelector('#pwd-strength-bar');
var fill = bar && bar.querySelector('.pwd-strength__fill');
var text = shell.querySelector('#pwd-strength-text');
if (fill) fill.className = 'pwd-strength__fill';
if (text) { text.textContent = ''; text.className = 'pwd-strength__text'; }
}
if (document.documentElement.dataset.aksrtSettingsModalCleanupInitialized !== 'true') {
document.documentElement.dataset.aksrtSettingsModalCleanupInitialized = 'true';
document.addEventListener('aksrt:modal:close', function(event) {
var shell = event.detail && event.detail.shell;
resetSettingsModal(shell);
});
}
root.querySelectorAll('[data-aksrt-settings-modal]').forEach(function(btn) {
if (btn.dataset.aksrtSettingsInitialized === 'true') return;
btn.dataset.aksrtSettingsInitialized = 'true';
btn.addEventListener('click', function() {
var inp = document.getElementById(this.getAttribute('data-target'));
if (!inp) return;
inp.type = (inp.type === 'password') ? 'text' : 'password';
this.classList.toggle('is-visible');
openSettingsModal(this.getAttribute('data-aksrt-settings-modal'));
});
});
// 密码强度
var pInput = document.getElementById('pwd-new');
var sBar = document.getElementById('pwd-strength-bar');
var sTxt = document.getElementById('pwd-strength-text');
if (pInput && sBar && sTxt && pInput.dataset.aksrtSettingsInitialized !== 'true') {
pInput.dataset.aksrtSettingsInitialized = 'true';
pInput.addEventListener('input', function() {
var v = this.value;
var f = sBar.querySelector('.pwd-strength__fill');
if (!v) { f.className = 'pwd-strength__fill'; sTxt.className = 'pwd-strength__text'; sTxt.textContent = ''; return; }
var s = 0;
if (v.length >= 6) s++;
if (v.length >= 10) s++;
if (/[a-z]/.test(v) && /[A-Z]/.test(v)) s++;
if (/\d/.test(v)) s++;
if (/[^a-zA-Z0-9]/.test(v)) s++;
var lv = '', tx = '';
if (s <= 1) { lv = 'weak'; tx = '弱'; }
else if (s <= 3) { lv = 'medium'; tx = '中'; }
else { lv = 'strong'; tx = '强'; }
f.className = 'pwd-strength__fill level-' + lv;
sTxt.className = 'pwd-strength__text level-' + lv;
sTxt.textContent = '密码强度: ' + tx;
});
}
// 验证码发送
function getSendBtnIdleText(btnId) {
if (btnId === 'pwd-send-code') return i18n.sendToCurrentEmail || '发送到当前邮箱';
@@ -803,20 +823,22 @@
return i18n.sendCode || '发送验证码';
}
function bindSend(btnId, formId, scene) {
var b = document.getElementById(btnId);
function bindSend(btnId, formId, scene, scope) {
var container = scope || document;
var b = container.querySelector ? container.querySelector('#' + btnId) : document.getElementById(btnId);
if (!b) return;
if (b.dataset.aksrtSettingsInitialized === 'true') return;
b.dataset.aksrtSettingsInitialized = 'true';
b.addEventListener('click', function() {
if (this.classList.contains('is-counting')) return;
var self = this;
var form = document.getElementById(formId);
var form = container.querySelector ? container.querySelector('#' + formId) : document.getElementById(formId);
var toastId = scene === 'change_password'
? 'aksrt-settings-password-code-toast'
: 'aksrt-settings-email-code-toast';
runCaptcha(scene, form).then(function(captchaPayload) {
if (captchaPayload === null) return;
if (container.dataset && container.dataset.aksrtSettingsModalClosed === 'true') return;
self.disabled = true;
self.textContent = i18n.sending || '发送中...';
notyf(i18n.sending || '正在发送验证码…', 'load', '', toastId);
@@ -835,13 +857,17 @@
.then(function(r) { return r.json(); }).then(function(res) {
if (res.success) {
notyf((res.data && res.data.message) || i18n.codeSent || '验证码已发送', 'success', 5, toastId);
if (container.dataset && container.dataset.aksrtSettingsModalClosed === 'true') return;
var sec = 60;
self.classList.add('is-counting');
self.textContent = sec + 's 后重发';
self.setAttribute('data-aksrt-countdown', '');
self.setAttribute('data-idle-label', getSendBtnIdleText(btnId));
var t = setInterval(function() {
sec--;
if (sec <= 0) {
clearInterval(t);
self.__aksrtCountdownTimer = null;
self.disabled = false;
self.classList.remove('is-counting');
self.textContent = getSendBtnIdleText(btnId);
@@ -849,6 +875,7 @@
self.textContent = sec + 's 后重发';
}
}, 1000);
self.__aksrtCountdownTimer = t;
} else {
notyf((res.data && res.data.message) || i18n.sendFailed || '发送失败', 'danger', 5, toastId);
self.disabled = false;
@@ -870,12 +897,10 @@
});
}
bindSend('pwd-send-code', 'pwd-form', 'change_password');
bindSend('email-send-code', 'email-form', 'change_email');
// 表单提交
function submitForm(fid, act) {
var fm = document.getElementById(fid);
function submitForm(fid, act, scope) {
var container = scope || document;
var fm = container.querySelector ? container.querySelector('#' + fid) : document.getElementById(fid);
if (!fm) return;
if (fm.dataset.aksrtSettingsInitialized === 'true') return;
fm.dataset.aksrtSettingsInitialized = 'true';
@@ -891,8 +916,8 @@
if (!reqs[i].value.trim()) { reqs[i].focus(); notyf(i18n.fillRequired || '请填写必填项', 'warning'); return; }
}
if (fid === 'pwd-form') {
var pwdNew = document.getElementById('pwd-new');
var pwdConfirm = document.getElementById('pwd-new-confirm');
var pwdNew = fm.querySelector('#pwd-new');
var pwdConfirm = fm.querySelector('#pwd-new-confirm');
if (pwdNew && pwdConfirm && pwdNew.value !== pwdConfirm.value) {
pwdConfirm.focus();
notyf(i18n.passwordMismatch || '两次输入的新密码不一致', 'warning');
@@ -902,12 +927,15 @@
if (btn) { btn.disabled = true; btn.textContent = i18n.submitting || '提交中...'; }
notyf(i18n.submitting || '正在提交…', 'load', '', toastId);
var scene = fid === 'pwd-form' ? 'change_password' : 'change_email';
runCaptcha(scene, fm).then(function(captchaPayload) {
if (captchaPayload === null) {
if (btn) { btn.disabled = false; btn.textContent = orig; }
return null;
}
var d = new FormData(fm);
runCaptcha(scene, fm).then(function(captchaPayload) {
if (captchaPayload === null) {
if (btn) { btn.disabled = false; btn.textContent = orig; }
return null;
}
if (container.dataset && container.dataset.aksrtSettingsModalClosed === 'true') return null;
var modalShell = fm.closest('.aksrt-user-settings-modal');
if (modalShell && modalShell.dataset.aksrtSettingsModalClosed === 'true') return null;
var d = new FormData(fm);
d.set('action', act);
d.set('_settings_nonce', settingsNonce);
Object.keys(captchaPayload || {}).forEach(function(key) { d.set(key, captchaPayload[key]); });
@@ -919,7 +947,10 @@
if (btn) { btn.disabled = false; btn.textContent = orig; }
if (r.success) {
notyf((r.data && r.data.message) || '操作成功', 'success', 5, toastId);
closeModal(fm.closest('.aksrt-modal'));
var activeModal = window.AksrtModalRuntime && window.AksrtModalRuntime.getActive();
if (activeModal && activeModal.classList.contains('aksrt-user-settings-modal') && activeModal.contains(fm)) {
window.AksrtModalRuntime.close('settings-submit');
}
if (r.data && r.data.redirect_to) setTimeout(function() { window.location.href = r.data.redirect_to; }, 2500);
} else {
notyf((r.data && r.data.message) || i18n.operationFailed || '操作失败', 'danger', 5, toastId);
@@ -935,9 +966,6 @@
});
}
submitForm('pwd-form', 'aksrt_change_password');
submitForm('email-form', 'aksrt_change_email');
root.querySelectorAll('.binding-item--linkable').forEach(function(link) {
if (link.dataset.aksrtBindCaptchaInitialized === 'true') return;
link.dataset.aksrtBindCaptchaInitialized = 'true';
@@ -1127,12 +1155,14 @@
var nonce = (window.aksrtData && aksrtData.restNonce) || '';
sendButton.disabled = true;
notyf('正在发送验证码…', 'load', '', toastId);
runCaptcha('bind_phone', form).then(function(captchaPayload) {
if (captchaPayload === null) {
sendButton.disabled = false;
return null;
}
return fetch(String(restRoot).replace(/\/$/, '') + '/user/phone-code', {
runCaptcha('bind_phone', form).then(function(captchaPayload) {
if (captchaPayload === null) {
sendButton.disabled = false;
return null;
}
var modalShell = form.closest('.aksrt-user-settings-modal');
if (modalShell && modalShell.dataset.aksrtSettingsModalClosed === 'true') return null;
return fetch(String(restRoot).replace(/\/$/, '') + '/user/phone-code', {
method: 'POST', credentials: 'same-origin',
headers: { 'Content-Type': 'application/json', 'X-WP-Nonce': nonce },
body: JSON.stringify(Object.assign({ phone: phone }, captchaPayload || {}))
@@ -1141,8 +1171,24 @@
if (!res) return;
if (!res.ok || !res.json.success) throw new Error(res.json.message || '发送失败');
notyf(res.json.message || '验证码已发送', 'success', 5, toastId);
var modalShell = form.closest('.aksrt-user-settings-modal');
if (modalShell && modalShell.dataset.aksrtSettingsModalClosed === 'true') return;
var left = Number((res.json.data && res.json.data.countdown) || 60);
var timer = setInterval(function () { left -= 1; sendButton.textContent = left + 's'; if (left <= 0) { clearInterval(timer); sendButton.disabled = false; sendButton.textContent = '获取验证码'; } }, 1000);
sendButton.setAttribute('data-aksrt-countdown', '');
sendButton.setAttribute('data-idle-label', '获取验证码');
sendButton.classList.add('is-counting');
var timer = setInterval(function () {
left -= 1;
sendButton.textContent = left + 's';
if (left <= 0) {
clearInterval(timer);
sendButton.__aksrtCountdownTimer = null;
sendButton.disabled = false;
sendButton.classList.remove('is-counting');
sendButton.textContent = sendButton.getAttribute('data-idle-label');
}
}, 1000);
sendButton.__aksrtCountdownTimer = timer;
}).catch(function (error) { sendButton.disabled = false; notyf(error.message || '发送失败', 'danger', 5, toastId); })
.finally(function () { resetCaptcha('bind_phone', form); });
});
@@ -1160,8 +1206,9 @@
notyf('请输入短信验证码', 'warning');
return;
}
var submitBtn = form.querySelector('[type="submit"]');
if (submitBtn) {
var submitBtn = form.querySelector('[type="submit"]');
var submitIdleText = submitBtn ? submitBtn.textContent : '';
if (submitBtn) {
submitBtn.disabled = true;
submitBtn.textContent = '绑定中...';
}
@@ -1183,13 +1230,17 @@
.then(function (res) {
if (res.ok && res.json && res.json.success) {
notyf(res.json.message || '绑定成功', 'success', 5, toastId);
var activeModal = window.AksrtModalRuntime && window.AksrtModalRuntime.getActive();
if (activeModal && activeModal.classList.contains('aksrt-user-settings-modal') && activeModal.contains(form)) {
window.AksrtModalRuntime.close('settings-submit');
}
setTimeout(function () { window.location.reload(); }, 600);
return;
}
notyf((res.json && (res.json.message || res.json.error)) || '绑定失败', 'danger', 5, toastId);
if (submitBtn) {
submitBtn.disabled = false;
submitBtn.textContent = '确认绑定';
submitBtn.textContent = submitIdleText;
}
})
.catch(function () {
@@ -1201,14 +1252,16 @@
});
}
runCaptcha('bind_phone', form).then(function(captchaPayload) {
if (captchaPayload === null) {
if (submitBtn) {
submitBtn.disabled = false;
submitBtn.textContent = '确认绑定';
}
return null;
}
return doBind(captchaPayload);
if (captchaPayload === null) {
if (submitBtn) {
submitBtn.disabled = false;
submitBtn.textContent = submitIdleText;
}
return null;
}
var modalShell = form.closest('.aksrt-user-settings-modal');
if (modalShell && modalShell.dataset.aksrtSettingsModalClosed === 'true') return null;
return doBind(captchaPayload);
}).finally(function() {
resetCaptcha('bind_phone', form);
});
@@ -1,132 +0,0 @@
<?php
/** Internal account modal renderer. @package AKSRT */
defined('ABSPATH') || exit;
$context = is_array($args['context'] ?? null) ? $args['context'] : [];
extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract
?>
<!-- ==================== 修改密码弹窗 ==================== -->
<div id="pwd-modal" class="aksrt-modal" hidden role="dialog" aria-modal="true" aria-label="<?php esc_attr_e( '修改密码', 'aksrt' ); ?>">
<div class="aksrt-modal__overlay" data-close-modal></div>
<div class="aksrt-modal__box">
<div class="aksrt-modal__header">
<div class="aksrt-modal__title-wrap">
<span class="aksrt-modal__icon"><i class="fa fas fa-lock" aria-hidden="true"></i></span>
<h4><?php esc_html_e( '修改密码', 'aksrt' ); ?></h4>
</div>
<button type="button" class="aksrt-modal__close" data-close-modal title="<?php esc_attr_e( '关闭', 'aksrt' ); ?>"><i class="fa fas fa-times" aria-hidden="true"></i></button>
</div>
<form id="pwd-form" autocomplete="off" novalidate>
<div class="modal-field">
<label for="pwd-old"><?php esc_html_e( '原密码', 'aksrt' ); ?></label>
<input type="password" id="pwd-old" name="old_password" required minlength="1">
<button type="button" class="toggle-pwd" data-target="pwd-old"></button>
</div>
<div class="modal-field">
<label for="pwd-new"><?php esc_html_e( '新密码', 'aksrt' ); ?></label>
<input type="password" id="pwd-new" name="new_password" required minlength="6" placeholder="<?php esc_attr_e( '至少6位字符', 'aksrt' ); ?>">
<button type="button" class="toggle-pwd" data-target="pwd-new"></button>
<div class="pwd-strength" id="pwd-strength-bar">
<div class="pwd-strength__fill"></div>
</div>
<span class="pwd-strength__text" id="pwd-strength-text"></span>
</div>
<div class="modal-field">
<label for="pwd-new-confirm"><?php esc_html_e( '确认新密码', 'aksrt' ); ?></label>
<input type="password" id="pwd-new-confirm" name="new_password_confirm" required minlength="6" placeholder="<?php esc_attr_e( '再次输入新密码', 'aksrt' ); ?>">
<button type="button" class="toggle-pwd" data-target="pwd-new-confirm"></button>
</div>
<div class="modal-field modal-field--code">
<label for="pwd-code"><?php esc_html_e( '当前邮箱验证码', 'aksrt' ); ?></label>
<div class="code-input-group">
<input type="text" id="pwd-code" name="email_code" maxlength="6" inputmode="numeric" pattern="[0-9]*" placeholder="6位数字验证码" required>
<button type="button" class="btn-ghost btn-sm code-send-btn" id="pwd-send-code"><?php esc_html_e( '发送到当前邮箱', 'aksrt' ); ?></button>
</div>
</div>
<?php aksrt_render_captcha('change_password'); ?>
<div class="aksrt-modal__footer">
<button type="button" class="btn-ghost btn-sm" data-close-modal><?php esc_html_e( '取消', 'aksrt' ); ?></button>
<button type="submit" class="btn-primary btn-sm" id="pwd-submit"><?php esc_html_e( '确认修改', 'aksrt' ); ?></button>
</div>
</form>
</div>
</div>
<!-- ==================== 更改邮箱弹窗 ==================== -->
<div id="email-modal" class="aksrt-modal" hidden role="dialog" aria-modal="true" aria-label="<?php esc_attr_e( '更改邮箱', 'aksrt' ); ?>">
<div class="aksrt-modal__overlay" data-close-modal></div>
<div class="aksrt-modal__box">
<div class="aksrt-modal__header">
<div class="aksrt-modal__title-wrap">
<span class="aksrt-modal__icon"><i class="fa fas fa-envelope" aria-hidden="true"></i></span>
<h4><?php esc_html_e( '更改邮箱', 'aksrt' ); ?></h4>
</div>
<button type="button" class="aksrt-modal__close" data-close-modal title="<?php esc_attr_e( '关闭', 'aksrt' ); ?>"><i class="fa fas fa-times" aria-hidden="true"></i></button>
</div>
<form id="email-form" autocomplete="off" novalidate>
<div class="modal-field">
<label><?php esc_html_e( '当前邮箱', 'aksrt' ); ?></label>
<div class="readonly-display"><?php echo esc_html( $user_email ); ?></div>
</div>
<div class="modal-field">
<label for="email-current-password"><?php esc_html_e( '当前密码', 'aksrt' ); ?></label>
<input type="password" id="email-current-password" name="current_password" required minlength="1" placeholder="<?php esc_attr_e( '请输入当前登录密码', 'aksrt' ); ?>">
<button type="button" class="toggle-pwd" data-target="email-current-password"></button>
</div>
<div class="modal-field">
<label for="email-new"><?php esc_html_e( '新邮箱', 'aksrt' ); ?></label>
<input type="email" id="email-new" name="new_email" required placeholder="<?php esc_attr_e( '请输入新的邮箱地址', 'aksrt' ); ?>">
</div>
<div class="modal-field modal-field--code">
<label for="email-code"><?php esc_html_e( '新邮箱验证码', 'aksrt' ); ?></label>
<div class="code-input-group">
<input type="text" id="email-code" name="email_code" maxlength="6" inputmode="numeric" pattern="[0-9]*" placeholder="6位数字验证码" required>
<button type="button" class="btn-ghost btn-sm code-send-btn" id="email-send-code"><?php esc_html_e( '发送到新邮箱', 'aksrt' ); ?></button>
</div>
<p class="settings-hint settings-hint--bottom"><?php esc_html_e( '验证码将发送到你填写的新邮箱,验证通过后才会正式切换。', 'aksrt' ); ?></p>
</div>
<?php aksrt_render_captcha('change_email'); ?>
<div class="aksrt-modal__footer">
<button type="button" class="btn-ghost btn-sm" data-close-modal><?php esc_html_e( '取消', 'aksrt' ); ?></button>
<button type="submit" class="btn-primary btn-sm" id="email-submit"><?php esc_html_e( '确认更改', 'aksrt' ); ?></button>
</div>
</form>
</div>
</div>
<div id="phone-modal" class="aksrt-modal" hidden role="dialog" aria-modal="true" aria-labelledby="phone-modal-title">
<div class="aksrt-modal__overlay" data-close-modal></div>
<div class="aksrt-modal__box">
<div class="aksrt-modal__header">
<div class="aksrt-modal__title-wrap">
<span class="aksrt-modal__icon"><i class="fa fas fa-mobile-alt" aria-hidden="true"></i></span>
<h4 id="phone-modal-title"><?php esc_html_e('绑定手机', 'aksrt'); ?></h4>
</div>
<button type="button" class="aksrt-modal__close" data-close-modal title="<?php esc_attr_e('关闭', 'aksrt'); ?>"><i class="fa fas fa-times" aria-hidden="true"></i></button>
</div>
<form id="aksrt-bind-phone-form" autocomplete="off" novalidate data-aksrt-bind-phone-form>
<div class="modal-field">
<label for="bind-phone-input"><?php esc_html_e('手机号', 'aksrt'); ?></label>
<input type="tel" id="bind-phone-input" name="phone" data-aksrt-phone-input inputmode="tel" autocomplete="tel" required placeholder="<?php esc_attr_e('请输入手机号', 'aksrt'); ?>">
</div>
<div class="modal-field modal-field--code">
<label for="bind-phone-code"><?php esc_html_e('短信验证码', 'aksrt'); ?></label>
<div class="code-input-group">
<input type="text" id="bind-phone-code" name="code" maxlength="6" inputmode="numeric" autocomplete="one-time-code" required placeholder="<?php esc_attr_e('请输入验证码', 'aksrt'); ?>">
<button type="button" class="btn-ghost btn-sm code-send-btn" data-aksrt-sms-trigger data-aksrt-sms-scene="bind_phone" data-aksrt-sms-phone="#bind-phone-input"><?php esc_html_e('获取验证码', 'aksrt'); ?></button>
</div>
</div>
<?php if (function_exists('aksrt_render_captcha')) : ?>
<?php aksrt_render_captcha('bind_phone'); ?>
<?php endif; ?>
<div class="aksrt-modal__footer">
<button type="button" class="btn-ghost btn-sm" data-close-modal><?php esc_html_e('取消', 'aksrt'); ?></button>
<button type="submit" class="btn-primary btn-sm"><?php esc_html_e('确认绑定', 'aksrt'); ?></button>
</div>
</form>
</div>
</div>
@@ -11,7 +11,5 @@ $context = is_array($args['context'] ?? null) ? $args['context'] : [];
extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract
$dir = __DIR__;
require $dir . '/settings-bindings.php';
require $dir . '/settings-security.php';
require $dir . '/settings-account.php';
require $dir . '/settings-runtime-fields.php';
require $dir . '/profile-account-modals.php';
@@ -0,0 +1,144 @@
<?php
/**
* User center account settings rows and runtime modal templates.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
$account_user = isset($target_user) && $target_user instanceof WP_User
? $target_user
: wp_get_current_user();
$account_user_id = $account_user instanceof WP_User ? (int) $account_user->ID : (int) ($user_id ?? 0);
$account_email = $account_user instanceof WP_User ? (string) $account_user->user_email : '';
$account_phone = $account_user_id > 0 ? (string) get_user_meta($account_user_id, 'aksrt_phone', true) : '';
$user_settings = class_exists('\\AKSRT\\Settings\\Settings') ? \AKSRT\Settings\Settings::get_all() : [];
$sms_settings = class_exists('\\AKSRT\\Sms\\SMS') ? \AKSRT\Sms\SMS::get_instance()->get_provider_config() : [];
$phone_available = !empty($user_settings['bind_phone']) && (($sms_settings['sms_sdk'] ?? 'null') !== 'null');
$phone_visible = $account_phone !== '' || $phone_available;
$phone_label = $account_phone !== '' ? $account_phone : __('暂未绑定', 'aksrt');
$email_action = $account_email !== '' ? __('修改', 'aksrt') : __('绑定', 'aksrt');
$phone_action = $account_phone !== '' ? __('修改', 'aksrt') : __('绑定', 'aksrt');
$render_row = static function (string $icon, string $title, string $value, string $action, string $modal, string $icon_tone, string $action_tone, bool $interactive = true): void {
?>
<div class="aksrt-account-row<?php echo $value === '' ? ' aksrt-account-row--simple' : ''; ?>">
<div class="aksrt-account-row__identity">
<span class="aksrt-account-row__icon aksrt-account-row__icon--<?php echo esc_attr($icon_tone); ?>"><i class="fa fas <?php echo esc_attr($icon); ?>" aria-hidden="true"></i></span>
<strong class="aksrt-account-row__copy"><?php echo esc_html($title); ?></strong>
</div>
<?php if ($value !== '') : ?>
<div class="aksrt-account-row__value" title="<?php echo esc_attr($value); ?>"><?php echo esc_html($value); ?></div>
<?php endif; ?>
<?php if ($interactive) : ?>
<button type="button" class="but hollow <?php echo esc_attr($action_tone); ?> aksrt-account-row__action" data-aksrt-settings-modal="<?php echo esc_attr($modal); ?>">
<?php echo esc_html($action); ?>
</button>
<?php else : ?>
<span class="aksrt-account-row__action aksrt-account-row__action--unavailable"><?php esc_html_e('暂不可修改', 'aksrt'); ?></span>
<?php endif; ?>
</div>
<?php
};
?>
<section class="aksrt-account-settings" data-aksrt-settings-root data-aksrt-captcha-scope>
<div class="aksrt-account-settings__section">
<div class="aksrt-account-settings__heading">
<div>
<h3 class="title-h-left"><b><?php esc_html_e('绑定邮箱', 'aksrt'); ?></b></h3>
<p><?php esc_html_e('绑定邮箱账号,及时接收订单、审核等重要信息', 'aksrt'); ?></p>
</div>
</div>
<div class="aksrt-account-list">
<?php $render_row('fa-envelope', __('邮箱', 'aksrt'), $account_email !== '' ? $account_email : __('暂未绑定', 'aksrt'), $email_action, 'email', 'blue', $account_email !== '' ? 'c-yellow-2' : 'c-blue'); ?>
</div>
</div>
<?php if ($phone_visible) : ?>
<div class="aksrt-account-settings__section">
<div class="aksrt-account-settings__heading">
<div>
<h3 class="title-h-left"><b><?php esc_html_e('绑定手机', 'aksrt'); ?></b></h3>
<p><?php esc_html_e('绑定手机号,提高账户安全性', 'aksrt'); ?></p>
</div>
</div>
<div class="aksrt-account-list">
<?php $render_row('fa-phone', __('手机号', 'aksrt'), $phone_label, $phone_action, 'phone', 'blue-2', $account_phone !== '' ? 'c-yellow' : 'c-blue', $phone_available); ?>
</div>
</div>
<?php endif; ?>
<?php require __DIR__ . '/settings-bindings.php'; ?>
<div class="aksrt-account-settings__section">
<div class="aksrt-account-settings__heading">
<div>
<h3 class="title-h-left"><b><?php esc_html_e('账户密码', 'aksrt'); ?></b></h3>
<p><?php esc_html_e('定期修改密码有助于账户安全', 'aksrt'); ?></p>
</div>
</div>
<div class="aksrt-account-list">
<?php $render_row('fa-unlock-alt', __('账户密码', 'aksrt'), '', __('修改密码', 'aksrt'), 'password', 'purple', 'c-blue-2'); ?>
</div>
</div>
<template data-aksrt-settings-modal-template="password">
<div class="aksrt-settings-modal">
<div class="modal-colorful-header colorful-bg jb-yellow">
<button type="button" class="close" data-aksrt-modal-close aria-label="<?php esc_attr_e('关闭', 'aksrt'); ?>"><i class="fa fas fa-times" aria-hidden="true"></i></button>
<div class="colorful-make"></div>
<div class="text-center"><div class="em2x"><i class="fa fas fa-unlock-alt" aria-hidden="true"></i></div><div class="mt10 em12 padding-w10"><?php esc_html_e('修改密码', 'aksrt'); ?></div></div>
</div>
<form id="pwd-form" autocomplete="off" novalidate>
<div class="aksrt-settings-modal__fields">
<div class="modal-field"><label for="pwd-old"><?php esc_html_e('原密码', 'aksrt'); ?></label><input type="password" id="pwd-old" name="old_password" required minlength="1"><button type="button" class="toggle-pwd" data-target="pwd-old" aria-label="<?php esc_attr_e('显示或隐藏密码', 'aksrt'); ?>"><i class="fa fa-eye" aria-hidden="true"></i></button></div>
<div class="modal-field"><label for="pwd-new"><?php esc_html_e('新密码', 'aksrt'); ?></label><input type="password" id="pwd-new" name="new_password" required minlength="6" placeholder="<?php esc_attr_e('至少6位字符', 'aksrt'); ?>"><button type="button" class="toggle-pwd" data-target="pwd-new" aria-label="<?php esc_attr_e('显示或隐藏密码', 'aksrt'); ?>"><i class="fa fa-eye" aria-hidden="true"></i></button><div class="pwd-strength" id="pwd-strength-bar"><div class="pwd-strength__fill"></div></div><span class="pwd-strength__text" id="pwd-strength-text"></span></div>
<div class="modal-field"><label for="pwd-new-confirm"><?php esc_html_e('确认新密码', 'aksrt'); ?></label><input type="password" id="pwd-new-confirm" name="new_password_confirm" required minlength="6" placeholder="<?php esc_attr_e('再次输入新密码', 'aksrt'); ?>"><button type="button" class="toggle-pwd" data-target="pwd-new-confirm" aria-label="<?php esc_attr_e('显示或隐藏密码', 'aksrt'); ?>"><i class="fa fa-eye" aria-hidden="true"></i></button></div>
<div class="modal-field modal-field--code"><label for="pwd-code"><?php esc_html_e('当前邮箱验证码', 'aksrt'); ?></label><div class="code-input-group"><input type="text" id="pwd-code" name="email_code" maxlength="6" inputmode="numeric" pattern="[0-9]*" placeholder="<?php esc_attr_e('6位数字验证码', 'aksrt'); ?>" required><button type="button" class="but hollow code-send-btn" id="pwd-send-code"><?php esc_html_e('发送到当前邮箱', 'aksrt'); ?></button></div></div>
<?php aksrt_render_captcha('change_password'); ?>
</div>
<div class="but-average modal-buts aksrt-settings-modal__footer"><button type="button" class="but" data-aksrt-modal-close><?php esc_html_e('取消', 'aksrt'); ?></button><button type="submit" class="but c-blue" id="pwd-submit"><?php esc_html_e('确认修改', 'aksrt'); ?></button></div>
</form>
</div>
</template>
<template data-aksrt-settings-modal-template="email">
<div class="aksrt-settings-modal">
<div class="modal-colorful-header colorful-bg jb-blue">
<button type="button" class="close" data-aksrt-modal-close aria-label="<?php esc_attr_e('关闭', 'aksrt'); ?>"><i class="fa fas fa-times" aria-hidden="true"></i></button>
<div class="colorful-make"></div>
<div class="text-center"><div class="em2x"><i class="fa fas fa-envelope" aria-hidden="true"></i></div><div class="mt10 em12 padding-w10"><?php echo esc_html($account_email !== '' ? __('更改邮箱', 'aksrt') : __('绑定邮箱', 'aksrt')); ?></div></div>
</div>
<form id="email-form" autocomplete="off" novalidate>
<div class="aksrt-settings-modal__fields">
<?php if ($account_email !== '') : ?><div class="modal-field"><label><?php esc_html_e('当前邮箱', 'aksrt'); ?></label><div class="readonly-display"><?php echo esc_html($account_email); ?></div></div><?php endif; ?>
<div class="modal-field"><label for="email-current-password"><?php esc_html_e('当前密码', 'aksrt'); ?></label><input type="password" id="email-current-password" name="current_password" required minlength="1" placeholder="<?php esc_attr_e('请输入当前登录密码', 'aksrt'); ?>"><button type="button" class="toggle-pwd" data-target="email-current-password" aria-label="<?php esc_attr_e('显示或隐藏密码', 'aksrt'); ?>"><i class="fa fa-eye" aria-hidden="true"></i></button></div>
<div class="modal-field"><label for="email-new"><?php esc_html_e('新邮箱', 'aksrt'); ?></label><input type="email" id="email-new" name="new_email" required placeholder="<?php esc_attr_e('请输入新的邮箱地址', 'aksrt'); ?>"></div>
<div class="modal-field modal-field--code"><label for="email-code"><?php esc_html_e('新邮箱验证码', 'aksrt'); ?></label><div class="code-input-group"><input type="text" id="email-code" name="email_code" maxlength="6" inputmode="numeric" pattern="[0-9]*" placeholder="<?php esc_attr_e('6位数字验证码', 'aksrt'); ?>" required><button type="button" class="but hollow code-send-btn" id="email-send-code"><?php esc_html_e('发送到新邮箱', 'aksrt'); ?></button></div><p class="settings-hint settings-hint--bottom"><?php esc_html_e('验证码将发送到你填写的新邮箱,验证通过后才会正式切换。', 'aksrt'); ?></p></div>
<?php aksrt_render_captcha('change_email'); ?>
</div>
<div class="but-average modal-buts aksrt-settings-modal__footer"><button type="button" class="but" data-aksrt-modal-close><?php esc_html_e('取消', 'aksrt'); ?></button><button type="submit" class="but c-blue" id="email-submit"><?php echo esc_html($account_email !== '' ? __('确认更改', 'aksrt') : __('确认绑定', 'aksrt')); ?></button></div>
</form>
</div>
</template>
<?php if ($phone_available) : ?>
<template data-aksrt-settings-modal-template="phone">
<div class="aksrt-settings-modal">
<div class="modal-colorful-header colorful-bg jb-blue">
<button type="button" class="close" data-aksrt-modal-close aria-label="<?php esc_attr_e('关闭', 'aksrt'); ?>"><i class="fa fas fa-times" aria-hidden="true"></i></button>
<div class="colorful-make"></div>
<div class="text-center"><div class="em2x"><i class="fa fas fa-mobile-alt" aria-hidden="true"></i></div><div class="mt10 em12 padding-w10"><?php echo esc_html($account_phone !== '' ? __('修改手机', 'aksrt') : __('绑定手机', 'aksrt')); ?></div></div>
</div>
<form id="aksrt-bind-phone-form" autocomplete="off" novalidate data-aksrt-bind-phone-form>
<div class="aksrt-settings-modal__fields">
<div class="modal-field"><label for="bind-phone-input"><?php esc_html_e('手机号', 'aksrt'); ?></label><input type="tel" id="bind-phone-input" name="phone" data-aksrt-phone-input inputmode="tel" autocomplete="tel" required placeholder="<?php esc_attr_e('请输入手机号', 'aksrt'); ?>"></div>
<div class="modal-field modal-field--code"><label for="bind-phone-code"><?php esc_html_e('短信验证码', 'aksrt'); ?></label><div class="code-input-group"><input type="text" id="bind-phone-code" name="code" maxlength="6" inputmode="numeric" autocomplete="one-time-code" required placeholder="<?php esc_attr_e('请输入验证码', 'aksrt'); ?>"><button type="button" class="but hollow code-send-btn" data-aksrt-sms-trigger data-aksrt-sms-scene="bind_phone" data-aksrt-sms-phone="#bind-phone-input"><?php esc_html_e('获取验证码', 'aksrt'); ?></button></div></div>
<?php if (function_exists('aksrt_render_captcha')) : ?><?php aksrt_render_captcha('bind_phone'); ?><?php endif; ?>
</div>
<div class="but-average modal-buts aksrt-settings-modal__footer"><button type="button" class="but" data-aksrt-modal-close><?php esc_html_e('取消', 'aksrt'); ?></button><button type="submit" class="but c-blue"><?php echo esc_html($account_phone !== '' ? __('确认修改', 'aksrt') : __('确认绑定', 'aksrt')); ?></button></div>
</form>
</div>
</template>
<?php endif; ?>
</section>
@@ -48,41 +48,38 @@ foreach ((array) ($oauth_data['available'] ?? []) as $binding) {
];
}
?>
<div class="settings-section" data-aksrt-captcha-scope>
<div class="settings-section__header">
<span class="settings-icon"><i class="fa fas fa-link" aria-hidden="true"></i></span>
<h3 class="widget-title settings-section__title"><?php esc_html_e('社交账号绑定', 'aksrt'); ?></h3>
<div class="aksrt-account-settings__section aksrt-account-settings__section--social">
<div class="aksrt-account-settings__heading">
<div>
<h3 class="title-h-left"><b><?php esc_html_e('绑定社交账号', 'aksrt'); ?></b></h3>
<p><?php esc_html_e('绑定社交账号,您可更安全、更快速的登录本站', 'aksrt'); ?></p>
</div>
</div>
<?php if (!empty($binding_rows)) : ?>
<p class="settings-hint settings-hint--top"><?php esc_html_e('点击下方按钮管理第三方账号绑定状态:', 'aksrt'); ?></p>
<?php if (function_exists('aksrt_render_captcha')) : ?>
<div class="binding-captcha" data-aksrt-oauth-bind-captcha><?php aksrt_render_captcha('bind'); ?></div>
<?php endif; ?>
<div class="binding-list">
<div class="aksrt-account-list aksrt-account-list--social">
<?php foreach ($binding_rows as $binding) : ?>
<?php if (!empty($binding['is_bound'])) : ?>
<div class="binding-item">
<div class="aksrt-account-row binding-item">
<span class="binding-item__icon"><?php echo $binding['icon']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></span>
<span class="binding-item__meta">
<span class="binding-status">
<i class="fa fas fa-check-circle badge__icon" aria-hidden="true"></i>
<?php esc_html_e('已绑定', 'aksrt'); ?>
</span>
<span class="binding-item__name"><?php echo esc_html($binding['name']); ?></span>
<span class="aksrt-account-row__social-name"><?php echo esc_html($binding['name']); ?></span>
<span class="binding-status">
<i class="fa fas fa-check-circle badge__icon" aria-hidden="true"></i>
<?php esc_html_e('已绑定', 'aksrt'); ?>
</span>
<button type="button" class="binding-unbind-btn" data-provider="<?php echo esc_attr($binding['key']); ?>">
<button type="button" class="but hollow c-yellow aksrt-account-row__action binding-unbind-btn" data-provider="<?php echo esc_attr($binding['key']); ?>">
<?php esc_html_e('解绑', 'aksrt'); ?>
</button>
</div>
<?php else : ?>
<a href="<?php echo esc_url($binding['url']); ?>" class="binding-item binding-item--linkable" target="_self" data-provider="<?php echo esc_attr($binding['key']); ?>" data-bind-start-url="<?php echo esc_url($binding['url']); ?>">
<a href="<?php echo esc_url($binding['url']); ?>" class="aksrt-account-row binding-item binding-item--linkable" target="_self" data-provider="<?php echo esc_attr($binding['key']); ?>" data-bind-start-url="<?php echo esc_url($binding['url']); ?>">
<span class="binding-item__icon"><?php echo $binding['icon']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></span>
<span class="binding-item__meta">
<span class="binding-status binding-status--idle"><?php esc_html_e('未绑定', 'aksrt'); ?></span>
<span class="binding-item__name"><?php echo esc_html($binding['name']); ?></span>
</span>
<span class="badge badge--bind"><?php esc_html_e('绑定', 'aksrt'); ?></span>
<span class="aksrt-account-row__social-name"><?php echo esc_html($binding['name']); ?></span>
<span class="binding-status binding-status--idle"><?php esc_html_e('未绑定', 'aksrt'); ?></span>
<span class="but hollow c-blue aksrt-account-row__action"><?php esc_html_e('绑定', 'aksrt'); ?></span>
</a>
<?php endif; ?>
<?php endforeach; ?>
@@ -1,53 +0,0 @@
<?php
/**
* User center settings: security actions (password / email).
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
?>
<div class="settings-section">
<div class="settings-section__header">
<span class="settings-icon"><i class="fa fas fa-lock" aria-hidden="true"></i></span>
<h3 class="widget-title settings-section__title"><?php esc_html_e('安全设置', 'aksrt'); ?></h3>
</div>
<div class="security-actions">
<div class="security-action-item">
<div class="security-action-info">
<span class="security-action-icon"><i class="fa fas fa-lock" aria-hidden="true"></i></span>
<div class="security-action-text">
<span class="security-action-title"><?php esc_html_e('修改密码', 'aksrt'); ?></span>
<span class="security-action-desc"><?php esc_html_e('通过邮箱验证码验证后可更改登录密码', 'aksrt'); ?></span>
</div>
</div>
<button type="button" class="btn-primary btn-sm security-trigger" data-modal="pwd-modal">
<?php esc_html_e('修改', 'aksrt'); ?>
</button>
</div>
<div class="security-action-item">
<div class="security-action-info">
<span class="security-action-icon"><i class="fa fas fa-envelope" aria-hidden="true"></i></span>
<div class="security-action-text">
<span class="security-action-title"><?php esc_html_e('更改邮箱', 'aksrt'); ?></span>
<span class="security-action-desc"><?php esc_html_e('更新用于接收通知和找回密码的邮箱地址', 'aksrt'); ?></span>
</div>
</div>
<button type="button" class="btn-primary btn-sm security-trigger" data-modal="email-modal">
<?php esc_html_e('更改', 'aksrt'); ?>
</button>
</div>
<div class="security-action-item">
<div class="security-action-info">
<span class="security-action-icon"><i class="fa fas fa-mobile-alt" aria-hidden="true"></i></span>
<div class="security-action-text">
<span class="security-action-title"><?php esc_html_e('绑定手机', 'aksrt'); ?></span>
<span class="security-action-desc"><?php esc_html_e('绑定手机号后可使用短信验证码登录', 'aksrt'); ?></span>
</div>
</div>
<button type="button" class="btn-primary btn-sm security-trigger" data-modal="phone-modal">
<?php esc_html_e('绑定', 'aksrt'); ?>
</button>
</div>
</div>
</div>
+1 -1
View File
@@ -323,7 +323,7 @@ trait ScriptsPart1b {
// Enqueue every profile leaf directly. Nested @imports are not versioned,
// so browsers can otherwise retain stale layout/modal rules after deploys.
$profile_parts = ['layout', 'lists', 'modals'];
$profile_parts = ['layout', 'lists'];
$profile_deps = [$core_dep];
foreach ($profile_parts as $part_index => $part) {
$part_path = get_template_directory() . '/assets/css/routes/profile/' . $part . '.css';
@@ -452,24 +452,25 @@ test('article visual matrix pins every breakpoint, state and strict threshold',
assert.equal(matrix.acceptance.pixelDifferencePercentMax, 1.5);
});
test('profile routes load versioned leaf styles and keep dialogs hidden initially', () => {
test('profile routes load versioned leaf styles and settings dialogs use the shared runtime', () => {
const scripts = read('src/Core/ScriptsPart1b.php');
const accountModals = read('inc/helpers/user-center-renderers/profile-account-modals.php');
const settingsSecurity = read('inc/helpers/user-center-renderers/settings-security.php');
const settingsAccount = read('inc/helpers/user-center-renderers/settings-account.php');
const settingsBindings = read('inc/helpers/user-center-renderers/settings-bindings.php');
const userCenterJs = read('assets/js/routes/user-center.js');
const settingsCss = read('assets/css/routes/user-center/settings.css');
const profileListsCss = read('assets/css/routes/profile/lists.css');
const userHomeCss = read('assets/css/routes/user-home.css');
const profileLayoutCss = read('assets/css/routes/profile/layout.css');
const frontendLayoutCss = read('assets/css/frontend/layout.css');
const publicBundleCss = read('assets/css/build/public.css');
const userCenterShellCss = read('assets/css/routes/user-center/shell.css');
const profileModalsCss = read('assets/css/routes/profile/modals.css');
const userCenterCreditsCss = read('assets/css/routes/user-center/credits.css');
const profileCredits = read('inc/helpers/user-center-renderers/profile-credits.php');
const profileOrders = read('inc/helpers/user-center-renderers/profile-orders.php');
const ordersCss = read('assets/css/routes/orders.css');
const orderCenterJs = read('assets/js/order-center.js');
assert.ok(scripts.includes("$profile_parts = ['layout', 'lists', 'modals'];"));
assert.ok(scripts.includes("$profile_parts = ['layout', 'lists'];"));
for (const part of ['user-center/shell', 'user-center/credits', 'user-center/vip', 'user-center/level', 'user-center/settings', 'user-center/revenue', 'user-center/revenue-earnings', 'user-center/responsive']) {
assert.ok(scripts.includes(`'${part}'`), `missing direct route leaf ${part}`);
}
@@ -482,9 +483,39 @@ test('profile routes load versioned leaf styles and keep dialogs hidden initiall
assert.doesNotMatch(scripts, /assets\/css\/routes\/profile\.css/);
assert.doesNotMatch(scripts, /assets\/css\/routes\/user-center\.css/);
assert.match(accountModals, /id="pwd-modal" class="aksrt-modal" hidden/);
assert.match(accountModals, /id="email-modal" class="aksrt-modal" hidden/);
assert.match(userCenterJs, /function closeModal\(m\)[\s\S]*?m\.hidden = true;/);
assert.match(settingsAccount, /data-aksrt-settings-modal="<\?php echo esc_attr\(\$modal\); \?>"/);
assert.match(settingsAccount, /\$render_row\([^;]*'email'/);
assert.match(settingsAccount, /\$render_row\([^;]*'phone'/);
assert.match(settingsAccount, /\$render_row\([^;]*'password'/);
assert.match(settingsAccount, /template data-aksrt-settings-modal-template="password"/);
assert.match(settingsAccount, /template data-aksrt-settings-modal-template="email"/);
assert.match(settingsAccount, /template data-aksrt-settings-modal-template="phone"/);
assert.ok(settingsAccount.indexOf('绑定邮箱') < settingsAccount.indexOf('绑定手机'));
assert.ok(settingsAccount.indexOf('绑定手机') < settingsAccount.indexOf("require __DIR__ . '/settings-bindings.php'"));
assert.ok(settingsAccount.indexOf("require __DIR__ . '/settings-bindings.php'") < settingsAccount.indexOf('账户密码'));
assert.ok(settingsBindings.indexOf('绑定社交账号') < settingsBindings.indexOf('aksrt-account-list--social'));
assert.match(settingsAccount, /!empty\(\$user_settings\['bind_phone'\]\)/);
assert.match(settingsBindings, /aksrt-account-list--social/);
assert.match(settingsBindings, /binding-unbind-btn/);
assert.match(userCenterJs, /runtime\.open\(\{/);
assert.match(userCenterJs, /className: 'aksrt-user-settings-modal modal-mini'/);
assert.match(userCenterJs, /mobileBottom: true/);
assert.match(userCenterJs, /onContent: function \(_, session\)/);
assert.match(userCenterJs, /aksrt:modal:close[\s\S]*?resetSettingsModal\(shell\)/);
assert.match(userCenterJs, /resetCaptcha\(scene, form\)/);
assert.match(userCenterJs, /aksrt_change_password/);
assert.match(userCenterJs, /aksrt_change_email/);
assert.match(userCenterJs, /AksrtModalRuntime\.close\('settings-submit'\)/);
assert.match(settingsCss, /\.aksrt-modal-runtime\.aksrt-user-settings-modal:not\(\.aksrt-modal-runtime--bottom\)[\s\S]*?width: 400px/);
assert.match(settingsCss, /\.aksrt-settings-modal \.modal-colorful-header[\s\S]*?height: 120px/);
assert.match(settingsAccount, /class="colorful-make"/);
assert.doesNotMatch(userCenterJs, /function closeModal\(|\.aksrt-modal\.is-open|security-trigger|data-close-modal/);
for (const deletedPath of [
'inc/helpers/user-center-renderers/profile-account-modals.php',
'inc/helpers/user-center-renderers/settings-security.php',
'assets/css/routes/profile/modals.css',
]) assert.equal(fs.existsSync(path.join(root, deletedPath)), false, `stale settings modal file: ${deletedPath}`);
assert.doesNotMatch(profileListsCss, /aksrt-modal__icon|aksrt-modal__close|security-action/);
assert.match(userHomeCss, /\.aksrt-profile-details-modal\[hidden\]\s*\{\s*display:\s*none\s*!important;\s*\}/);
assert.match(userHomeCss, /\.aksrt-user-home \.aksrt-user-home__post-list\[data-view="list"\] \.posts-item\s*\{[^}]*background:\s*transparent;[^}]*box-shadow:\s*none;/);
assert.match(userHomeCss, /@media \(min-width: 992px\)\s*\{[\s\S]*?\.aksrt-user-home \.aksrt-user-home__post-list\[data-view="list"\]\s*\{[^}]*display:\s*grid;[^}]*grid-template-columns:\s*repeat\(2,\s*minmax\(0,\s*1fr\)\);/);
@@ -515,11 +546,10 @@ test('profile routes load versioned leaf styles and keep dialogs hidden initiall
assert.match(userCenterShellCss, /\.aksrt-profile\.content-shell > \.content-wrap,[\s\S]*?\.aksrt-profile\.content-shell \.uc-header\s*\{[\s\S]*?width:\s*100%;[\s\S]*?max-width:\s*none/);
assert.match(profileLayoutCss, /\.aksrt-cover-menu__panel\[hidden\]\s*\{\s*display:\s*none\s*!important;\s*\}/);
assert.match(profileLayoutCss, /#aksrt-bg-file-input\[hidden\],[\s\S]*?#aksrt-avatar-file-input\[hidden\][\s\S]*?display:\s*none\s*!important;/);
assert.match(settingsSecurity, /data-modal="email-modal"[\s\S]*?<\/button>\s*<\/div>\s*<div class="security-action-item">[\s\S]*?data-modal="phone-modal"/);
assert.match(accountModals, /id="phone-modal" class="aksrt-modal" hidden role="dialog"[\s\S]*?aksrt-modal__overlay" data-close-modal[\s\S]*?aksrt-modal__box/);
assert.match(accountModals, /id="phone-modal"[\s\S]*?class="modal-field modal-field--code"[\s\S]*?class="code-input-group"[\s\S]*?class="aksrt-modal__footer"/);
assert.doesNotMatch(accountModals, /id="phone-modal"[\s\S]*?aksrt-modal__(?:dialog|body|actions)/);
assert.match(profileModalsCss, /\.modal-field input\[type="tel"\]/);
assert.match(settingsAccount, /id="aksrt-bind-phone-form"[\s\S]*?data-aksrt-sms-trigger/);
assert.match(settingsAccount, /class="modal-colorful-header colorful-bg jb-blue"/);
assert.match(settingsAccount, /class="modal-colorful-header colorful-bg jb-yellow"/);
assert.doesNotMatch(settingsAccount, /class="aksrt-modal"|aksrt-modal__overlay|aksrt-modal__box/);
assert.match(userCenterCreditsCss, /#panel-credits\.dashboard-panel\s*\{[^}]*background:\s*transparent;[^}]*box-shadow:\s*none;/);
assert.match(userCenterCreditsCss, /\.uc-asset-tabs\s*\{[^}]*background:\s*var\(--surface-1,\s*#fff\);[^}]*border:[^;}]+;[^}]*box-shadow:[^;}]+;/);
assert.doesNotMatch(profileCredits, /credits-signin\.php|data-aksrt-signin-calendar/);
+4 -1
View File
@@ -335,6 +335,7 @@ test('profile save uses AJAX rehydrate and a fixed-id notyf flow without query f
test('settings actions use rehydrated fixed-id notyf flows', () => {
const userCenter = read('assets/js/routes/user-center.js');
const auth = read('assets/js/auth.js');
const settings = read('inc/helpers/user-center-renderers/profile-settings.php');
const context = read('inc/helpers/aksrt-user-center.php');
const page = read('templates/pages/page-profile.php');
@@ -355,6 +356,8 @@ test('settings actions use rehydrated fixed-id notyf flows', () => {
assert.match(userCenter, /aksrtSettingsInitialized/);
assert.match(userCenter, /oauth_action[\s\S]*?notyf\(message, type\)[\s\S]*?history\.replaceState/);
assert.doesNotMatch(userCenter, /oauth_unbound/);
assert.match(auth, /\[data-identity-root\], \[data-aksrt-settings-root\]/);
assert.doesNotMatch(auth, /\.settings-section/);
assert.match(userCenter, /'aksrt-settings-phone-code-toast'/);
assert.match(userCenter, /notyf\('正在发送验证码…', 'load', '', toastId\)/);
@@ -362,7 +365,7 @@ test('settings actions use rehydrated fixed-id notyf flows', () => {
assert.match(userCenter, /notyf\([^;]+?'danger', 5, toastId\)/);
assert.match(userCenter, /\/user\/phone-code/);
assert.match(settings, /require \$dir \. '\/profile-account-modals\.php';/);
assert.match(settings, /require \$dir \. '\/settings-account\.php';/);
assert.doesNotMatch(context, /account_modals_html|'account-modals'/);
assert.doesNotMatch(page, /user-center\/account-modals/);
assert.equal(fs.existsSync(path.join(root, 'templates/parts/user-center/account-modals.php')), false);