Files
JayuCloud/docs/design/system-settings-redesign/index.html
T

1481 lines
56 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>系统设置 · 布局重排 Demo(A / B)</title>
<style>
:root {
--c-primary: #247B63;
--c-primary-dark: #1E6B55;
--c-primary-soft: #E5F4ED;
--c-bg: #F3F7F4;
--c-card: #FFFFFF;
--c-border: #E7ECE9;
--c-input-border: #D9D9D9;
--c-ink: #17211F;
--c-muted: #71807A;
--c-warn: #AD6800;
--c-warn-bg: #FFF7E6;
--c-danger: #CF1322;
--c-danger-bg: #FFF1F0;
--c-radius: 8px;
--shadow-card: 0 1px 2px rgba(23, 33, 31, 0.03);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
min-width: 320px;
background: var(--c-bg);
color: var(--c-ink);
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
font-size: 13px;
line-height: 1.5;
-webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
/* ============ demo chrome ============ */
.demo-bar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
padding: 10px clamp(16px, 3vw, 40px);
background: #17211F;
color: #FFFFFF;
}
.demo-bar__label { font-size: 12px; letter-spacing: .02em; color: rgba(255,255,255,.72); }
.demo-bar__label strong { color: #FFFFFF; font-weight: 600; margin-right: 8px; }
.seg { display: inline-flex; padding: 3px; border-radius: 8px; background: rgba(255,255,255,.1); }
.seg__btn {
height: 26px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent;
color: rgba(255,255,255,.68); font-size: 12px; cursor: pointer; white-space: nowrap;
}
.seg__btn:hover { color: #FFFFFF; }
.seg__btn.is-active { background: #FFFFFF; color: #17211F; font-weight: 600; }
/* ============ page ============ */
.page {
max-width: 1440px;
margin: 0 auto;
padding: 18px clamp(16px, 3vw, 40px) 34px;
}
.page__top {
display: flex;
align-items: center;
justify-content: space-between;
gap: 20px;
padding: 2px 0 12px;
border-bottom: 1px solid var(--c-border);
}
.tabs { display: flex; align-items: center; gap: 26px; min-width: 0; }
.tab {
position: relative;
display: inline-flex;
align-items: center;
gap: 6px;
padding: 8px 1px 9px;
border: 0;
background: none;
color: var(--c-muted);
font-size: 14px;
cursor: pointer;
white-space: nowrap;
}
.tab:hover { color: var(--c-primary); }
.tab.is-active { color: var(--c-ink); font-weight: 600; }
.tab.is-active::after {
content: "";
position: absolute;
left: 0; right: 0; bottom: -1px;
height: 2px;
border-radius: 2px;
background: var(--c-primary);
}
.tab__alert {
width: 6px; height: 6px; border-radius: 50%;
background: var(--c-danger);
box-shadow: 0 0 0 2px var(--c-danger-bg);
}
.env {
display: inline-flex;
align-items: center;
gap: 7px;
color: var(--c-muted);
font-size: 12px;
white-space: nowrap;
}
.env i { width: 7px; height: 7px; border-radius: 50%; background: var(--c-primary); }
/* ============ layout ============ */
.layout { padding-top: 16px; }
.layout--nav {
display: grid;
grid-template-columns: 194px minmax(0, 1fr);
gap: 18px;
align-items: start;
}
.subnav {
position: sticky;
top: 16px;
display: flex;
flex-direction: column;
gap: 2px;
padding: 8px;
border: 1px solid var(--c-border);
border-radius: 12px;
background: var(--c-card);
box-shadow: var(--shadow-card);
}
.subnav__label {
padding: 6px 8px 8px;
color: var(--c-muted);
font-size: 10px;
font-weight: 700;
letter-spacing: .1em;
text-transform: uppercase;
}
.subnav__item {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
width: 100%;
min-height: 34px;
padding: 7px 9px;
border: 0;
border-radius: 7px;
background: none;
color: var(--c-muted);
font-size: 12px;
text-align: left;
cursor: pointer;
}
.subnav__item:hover { background: #F7FAF8; color: var(--c-primary); }
.subnav__item.is-active { background: var(--c-primary-soft); color: var(--c-primary); font-weight: 600; }
.subnav__item em {
flex: none;
min-width: 18px;
height: 18px;
padding: 0 5px;
border-radius: 9px;
background: #FFFFFF;
border: 1px solid var(--c-border);
color: var(--c-muted);
font-size: 10px;
font-style: normal;
line-height: 16px;
text-align: center;
}
.content { min-width: 0; }
.groups { display: flex; flex-direction: column; gap: 14px; }
.group { scroll-margin-top: 16px; }
/* ============ group card ============ */
.group {
min-width: 0;
border: 1px solid var(--c-border);
border-radius: 14px;
background: var(--c-card);
box-shadow: var(--shadow-card);
}
.group__head {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 14px;
padding: 15px 18px 12px;
border-bottom: 1px solid var(--c-border);
}
.group__head-main { min-width: 0; }
.group__title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.group__title h2 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: .01em; }
.group__desc { margin: 4px 0 0; color: var(--c-muted); font-size: 11.5px; line-height: 1.55; }
.group__head-actions { display: flex; flex: none; align-items: center; gap: 8px; }
.group__body { padding: 15px 18px 17px; }
.group__footnote {
margin: 12px 0 0;
color: var(--c-muted);
font-size: 11px;
line-height: 1.65;
}
.meta { flex: none; color: var(--c-muted); font-size: 11px; white-space: nowrap; }
.tag {
flex: none;
padding: 1px 6px;
border: 1px solid var(--c-border);
border-radius: 5px;
background: #F7F9F8;
color: var(--c-muted);
font-size: 10px;
font-weight: 500;
letter-spacing: .08em;
}
/* ============ fields ============ */
.field-grid { display: grid; gap: 12px; }
.field-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field {
display: flex;
flex-direction: column;
min-width: 0;
padding: 12px 14px 11px;
border: 1px solid var(--c-border);
border-radius: 10px;
background: #FBFCFB;
}
.field--wide { grid-column: span 2; }
.field__label { color: var(--c-ink); font-size: 13px; font-weight: 600; }
.field__desc {
min-height: 32px;
margin: 3px 0 10px;
color: var(--c-muted);
font-size: 11px;
line-height: 1.5;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.field__control { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; margin-top: auto; }
.field__foot {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 6px 8px;
margin-top: 10px;
padding-top: 9px;
border-top: 1px dashed #E9EFEB;
}
.hint { color: var(--c-muted); font-size: 11px; }
.link {
color: var(--c-primary);
font-size: 11px;
text-decoration: none;
margin-left: auto;
white-space: nowrap;
}
.link:hover { text-decoration: underline; }
/* 单字段紧凑行 */
.inline-field {
display: grid;
grid-template-columns: minmax(0, 1.15fr) minmax(220px, .85fr) auto;
gap: 16px;
align-items: center;
}
.inline-field__copy { display: grid; gap: 3px; min-width: 0; }
.inline-field__copy strong { font-size: 13px; font-weight: 600; }
.inline-field__copy span { color: var(--c-muted); font-size: 11px; line-height: 1.5; }
.inline-field__control { display: flex; align-items: center; gap: 8px; min-width: 0; }
.inline-field__foot { display: flex; align-items: center; gap: 8px; }
/* ============ controls ============ */
.input-wrap {
display: flex;
align-items: center;
flex: 1 1 0;
min-width: 0;
height: 32px;
border: 1px solid var(--c-input-border);
border-radius: 6px;
background: #FFFFFF;
transition: border-color .15s, box-shadow .15s;
}
.input-wrap:focus-within { border-color: var(--c-primary); box-shadow: 0 0 0 2px rgba(36,123,99,.12); }
.input-wrap input {
flex: 1 1 0;
min-width: 0;
height: 30px;
padding: 0 9px;
border: 0;
outline: 0;
background: transparent;
font-size: 13px;
}
.input-wrap input::placeholder { color: #A9B4AE; }
.input-wrap--number { max-width: 220px; }
.input-suffix {
display: flex;
flex: none;
align-items: center;
height: 30px;
padding: 0 8px;
border: 0;
background: none;
color: var(--c-muted);
cursor: pointer;
}
.input-suffix:hover { color: var(--c-primary); }
.input-addon {
display: flex;
flex: none;
align-items: center;
height: 30px;
padding: 0 10px;
border-left: 1px solid var(--c-input-border);
border-radius: 0 6px 6px 0;
background: #FAFCFB;
color: var(--c-muted);
font-size: 12px;
}
.select-wrap { position: relative; flex: 1 1 0; min-width: 0; }
.select {
width: 100%;
height: 32px;
padding: 0 28px 0 9px;
border: 1px solid var(--c-input-border);
border-radius: 6px;
outline: 0;
background: #FFFFFF;
font-size: 13px;
color: var(--c-ink);
appearance: none;
cursor: pointer;
}
.select:focus { border-color: var(--c-primary); box-shadow: 0 0 0 2px rgba(36,123,99,.12); }
.select-wrap .ic-caret {
position: absolute;
top: 50%;
right: 9px;
transform: translateY(-50%);
color: #9AA7A1;
pointer-events: none;
}
.readonly {
display: flex;
flex: 1 1 0;
align-items: center;
min-width: 0;
height: 32px;
padding: 0 10px;
border: 1px solid var(--c-border);
border-radius: 6px;
background: #F7F9F8;
color: #41504B;
font-size: 12px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.switch {
display: inline-flex;
align-items: center;
gap: 7px;
padding: 0;
border: 0;
background: none;
color: var(--c-muted);
font-size: 11px;
cursor: pointer;
}
.switch__track {
position: relative;
width: 36px;
height: 20px;
border-radius: 999px;
background: #D9D9D9;
transition: background .18s;
}
.switch__track::after {
content: "";
position: absolute;
top: 2px;
left: 2px;
width: 16px;
height: 16px;
border-radius: 50%;
background: #FFFFFF;
box-shadow: 0 1px 2px rgba(0,0,0,.18);
transition: left .18s;
}
.switch.is-on .switch__track { background: var(--c-primary); }
.switch.is-on .switch__track::after { left: 18px; }
.switch.is-on .switch__text { color: var(--c-ink); }
.switch:focus-visible { outline: 2px solid rgba(36,123,99,.4); outline-offset: 3px; border-radius: 6px; }
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 5px;
height: 30px;
padding: 0 12px;
border: 1px solid var(--c-input-border);
border-radius: 6px;
background: #FFFFFF;
color: var(--c-ink);
font-size: 12px;
white-space: nowrap;
cursor: pointer;
transition: border-color .15s, color .15s, background .15s;
}
.btn:hover { border-color: var(--c-primary); color: var(--c-primary); }
.btn--primary { border-color: var(--c-primary); background: var(--c-primary); color: #FFFFFF; }
.btn--primary:hover { border-color: var(--c-primary-dark); background: var(--c-primary-dark); color: #FFFFFF; }
.btn--sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn--text {
height: 24px;
padding: 0 4px;
border: 0;
background: none;
color: var(--c-primary);
font-size: 11.5px;
}
.btn--text:hover { text-decoration: underline; }
.btn--text.btn--danger { color: var(--c-danger); }
.btn--icon {
width: 24px;
height: 24px;
padding: 0;
border: 0;
background: none;
color: var(--c-muted);
}
.btn--icon:hover { color: var(--c-primary); background: var(--c-primary-soft); }
.btn--icon:disabled { color: #C9D2CD; cursor: not-allowed; background: none; }
.btn--end { margin-left: auto; }
.btn.is-busy { opacity: .65; cursor: default; }
.pill {
display: inline-flex;
align-items: center;
gap: 5px;
height: 22px;
padding: 0 8px;
border-radius: 999px;
background: #F4F7F5;
color: var(--c-muted);
font-size: 11px;
white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill--pass { background: var(--c-primary-soft); color: var(--c-primary); }
.pill--warn { background: var(--c-warn-bg); color: var(--c-warn); }
.pill--fail { background: var(--c-danger-bg); color: var(--c-danger); }
.pill--pending { background: var(--c-warn-bg); color: var(--c-warn); }
.pill--idle { background: #F4F7F5; color: #8C9A94; }
/* ============ 接入诊断 ============ */
.svc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.svc {
display: flex;
flex-direction: column;
gap: 9px;
min-width: 0;
padding: 12px 14px;
border: 1px solid var(--c-border);
border-radius: 10px;
background: #FBFCFB;
}
.svc__head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.svc__name { flex: none; font-size: 13px; font-weight: 600; white-space: nowrap; }
.svc__desc {
flex: 1 1 auto;
min-width: 0;
color: var(--c-muted);
font-size: 11px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.svc__head .pill { flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
display: inline-flex;
align-items: center;
gap: 5px;
height: 29px;
padding: 0 8px;
border: 1px solid var(--c-border);
border-radius: 8px;
background: #FFFFFF;
color: var(--c-ink);
font-size: 11px;
cursor: pointer;
transition: border-color .15s, background .15s;
}
.chip:hover:not(.chip--idle) { border-color: #BFDCD0; background: #F8FCFA; }
.chip.is-open { border-color: var(--c-primary); background: var(--c-primary-soft); }
.chip--idle { cursor: default; background: #F7F9F8; color: var(--c-muted); }
.chip__dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: #A9B4AE; }
.chip__dot--pass { background: var(--c-primary); }
.chip__dot--warn { background: #D48806; }
.chip__dot--fail { background: var(--c-danger); }
.chip__dot--pending { background: #D48806; }
.chip__dot--idle { background: #B7C1BC; }
.chip__status { font-weight: 600; }
.chip--pass .chip__status { color: var(--c-primary); }
.chip--warn .chip__status, .chip--pending .chip__status { color: var(--c-warn); }
.chip--fail .chip__status { color: var(--c-danger); }
.chip--idle .chip__status { color: #8C9A94; font-weight: 500; }
.chip__time { color: var(--c-muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.chip__chev { display: inline-flex; color: #9AA7A1; transition: transform .15s; }
.chip.is-open .chip__chev { transform: rotate(180deg); color: var(--c-primary); }
.svc__detail {
padding: 8px 10px 9px;
border: 1px solid var(--c-border);
border-radius: 8px;
background: #F7FAF8;
}
.svc__detail[hidden] { display: none; }
.svc__detail-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
padding-bottom: 5px;
color: var(--c-muted);
font-size: 10.5px;
}
.check-row {
display: grid;
grid-template-columns: minmax(88px, 132px) 56px minmax(0, 1fr);
gap: 8px;
align-items: baseline;
padding: 5px 0;
border-top: 1px dashed #E4EBE7;
font-size: 11px;
}
.check-row:first-of-type { border-top: 0; }
.check-row > em { font-style: normal; font-weight: 600; }
.check-row__detail { color: var(--c-muted); overflow-wrap: anywhere; }
.status-text--pass { color: var(--c-primary); }
.status-text--warn, .status-text--pending { color: var(--c-warn); }
.status-text--fail { color: var(--c-danger); }
.status-text--idle { color: #8C9A94; }
/* ============ 对象存储顺序 ============ */
.order-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.order-item {
display: flex;
align-items: center;
gap: 8px;
min-width: 0;
height: 36px;
padding: 0 7px 0 9px;
border: 1px solid var(--c-border);
border-radius: 8px;
background: #FFFFFF;
}
.order-index {
display: inline-flex;
flex: none;
align-items: center;
justify-content: center;
width: 20px;
height: 20px;
border-radius: 50%;
background: var(--c-primary-soft);
color: var(--c-primary);
font-size: 11px;
font-weight: 700;
}
.order-item strong { flex: 1 1 auto; min-width: 0; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order-actions { display: flex; flex: none; gap: 1px; }
/* ============ 微信指引 ============ */
.guide {
margin-top: 12px;
border: 1px solid var(--c-border);
border-radius: 10px;
background: #F7FAF8;
}
.guide summary {
display: flex;
align-items: center;
gap: 8px;
padding: 10px 12px;
color: var(--c-ink);
font-size: 12px;
font-weight: 600;
cursor: pointer;
list-style: none;
}
.guide summary::-webkit-details-marker { display: none; }
.guide summary::before {
content: "";
width: 6px; height: 6px;
border-right: 1.5px solid var(--c-muted);
border-bottom: 1.5px solid var(--c-muted);
transform: rotate(-45deg);
transition: transform .15s;
}
.guide[open] summary::before { transform: rotate(45deg); }
.guide summary span { color: var(--c-muted); font-size: 10px; font-weight: 500; }
.guide__body { padding: 0 14px 12px 26px; color: var(--c-muted); font-size: 11.5px; line-height: 1.7; }
.guide__body ol { margin: 0; padding-left: 16px; }
.guide__body li + li { margin-top: 3px; }
.guide__links { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; }
.guide__links a { color: var(--c-primary); font-size: 11px; text-decoration: none; }
.guide__links a:hover { text-decoration: underline; }
/* ============ 当前账号 ============ */
.account-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.account-tile {
display: flex;
flex-direction: column;
gap: 7px;
min-width: 0;
padding: 13px 15px;
border: 1px solid var(--c-border);
border-radius: 10px;
background: #FBFCFB;
}
.account-tile__label { color: var(--c-muted); font-size: 11px; }
.account-tile strong { font-size: 16px; font-weight: 600; letter-spacing: .01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-tile__foot { display: flex; align-items: center; gap: 8px; }
.account-note {
display: flex;
flex-wrap: wrap;
gap: 6px 14px;
margin-top: 12px;
color: var(--c-muted);
font-size: 11px;
line-height: 1.6;
}
/* ============ footer note / toast ============ */
.demo-note {
margin: 16px 0 0;
color: #8C9A94;
font-size: 10.5px;
line-height: 1.6;
}
.toast {
position: fixed;
right: 20px;
bottom: 20px;
z-index: 20;
max-width: min(360px, calc(100vw - 40px));
padding: 9px 13px;
border: 1px solid var(--c-border);
border-radius: 8px;
background: #FFFFFF;
color: var(--c-ink);
font-size: 12px;
box-shadow: 0 6px 20px rgba(23,33,31,.14);
opacity: 0;
transform: translateY(8px);
pointer-events: none;
transition: opacity .18s, transform .18s;
}
.toast.is-show { opacity: 1; transform: translateY(0); }
/* ============ responsive ============ */
@media (max-width: 1280px) {
.field-grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field--wide { grid-column: auto; }
}
@media (max-width: 1180px) {
.layout--nav { grid-template-columns: 1fr; gap: 12px; }
.subnav {
position: static;
flex-direction: row;
align-items: center;
gap: 4px;
padding: 7px;
overflow-x: auto;
scrollbar-width: none;
}
.subnav::-webkit-scrollbar { display: none; }
.subnav__label { display: none; }
.subnav__item { width: auto; flex: none; min-height: 30px; padding: 5px 10px; white-space: nowrap; }
}
@media (max-width: 960px) {
.svc-grid { grid-template-columns: 1fr; }
.inline-field { grid-template-columns: 1fr; gap: 10px; }
.inline-field__foot { justify-self: start; }
.order-list { grid-template-columns: 1fr; }
.account-grid { grid-template-columns: 1fr; }
.account-tile strong { font-size: 15px; }
}
@media (max-width: 760px) {
.page__top { gap: 10px; }
.tabs { gap: 18px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { font-size: 13px; }
.env { font-size: 11px; }
.group__head { flex-wrap: wrap; padding: 13px 14px 11px; }
.group__head-actions { width: 100%; justify-content: flex-end; }
.group__body { padding: 13px 14px 15px; }
.field-grid.cols-2, .field-grid.cols-3 { grid-template-columns: 1fr; }
.field__desc { min-height: 0; }
.svc__desc { white-space: normal; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
.check-row { grid-template-columns: 1fr auto; }
.check-row__detail { grid-column: 1 / -1; }
.group__head-actions .btn { flex: 1 1 auto; }
}
@media (max-width: 560px) {
.demo-bar { flex-wrap: wrap; gap: 8px; }
.seg__btn { padding: 0 9px; }
.env { display: none; }
.field__foot .link { margin-left: 0; }
.svc__head { flex-wrap: wrap; }
.svc__desc { flex-basis: 100%; order: 3; }
}
</style>
</head>
<body>
<div class="demo-bar">
<div class="demo-bar__label"><strong>系统设置 · 布局重排 Demo</strong>同一套数据,两种布局方案</div>
<div class="seg" role="group" aria-label="布局方案切换">
<button class="seg__btn is-active" data-version="A">方案 A · 卡片栅格</button>
<button class="seg__btn" data-version="B">方案 B · 组内导航</button>
</div>
</div>
<div class="page">
<div class="page__top">
<nav class="tabs" role="tablist" aria-label="系统设置">
<button class="tab is-active" role="tab" aria-selected="true" data-tab="runtime">运行参数</button>
<button class="tab" role="tab" aria-selected="false" data-tab="services">服务接入<i class="tab__alert" title="存在失败的接入测试项"></i></button>
<button class="tab" role="tab" aria-selected="false" data-tab="account">当前账号</button>
</nav>
<span class="env"><i></i>当前环境设置</span>
</div>
<main id="panel" class="layout" aria-live="polite"></main>
<p class="demo-note">演示数据说明:诊断结果与时间取自现状截图;短信服务、微信订阅消息为源码中真实存在、截图中未显示的服务,其状态为示例值。</p>
</div>
<div id="toast" class="toast" role="status" aria-live="polite"></div>
<script>
(function () {
"use strict";
var ICON = {
caret: '<svg class="ic-caret" width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M6 9l6 6 6-6"/></svg>',
eye: '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><path d="M2 12s3.5-6 10-6 10 6 10 6-3.5 6-10 6S2 12 2 12z"/><circle cx="12" cy="12" r="2.6"/></svg>',
copy: '<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><rect x="9" y="9" width="11" height="11" rx="2"/><path d="M5 15V5a2 2 0 0 1 2-2h8"/></svg>',
refresh: '<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M20 11a8 8 0 1 1-2.3-5.7"/><path d="M20 4v7h-7"/></svg>',
chevron: '<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M6 9l6 6 6-6"/></svg>',
up: '<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M6 14l6-6 6 6"/></svg>',
down: '<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M6 10l6 6 6-6"/></svg>'
};
var STATUS = {
pass: { label: '通过', cls: 'pass' },
warn: { label: '需关注', cls: 'warn' },
fail: { label: '失败', cls: 'fail' },
pending: { label: '等待回调', cls: 'pending' },
idle: { label: '未测试', cls: 'idle' }
};
var PROBE = [
{
id: 'moderation',
name: '微信内容审核',
desc: '检查当前 Provider、凭据和回调;文本使用固定无害内容,图片需等待回调。',
ops: [
{
code: 'CONFIG', label: '配置诊断', status: 'pass', time: '2026/11/4 16:00:26',
summary: '内容审核配置诊断完成',
checks: [
{ name: '审核渠道', status: 'pass', detail: 'WECHAT · 微信内容安全审核' },
{ name: '小程序凭据', status: 'pass', detail: 'AppID 已配置 · AppSecret 已配置' },
{ name: '回调地址', status: 'pass', detail: '公网 HTTPS,路径与回调接口一致' },
{ name: '加密主密钥', status: 'pass', detail: '服务端主密钥已配置' }
]
},
{
code: 'TEXT', label: '文本接口测试', status: 'pass', time: '2026/11/4 16:00:30',
summary: '微信文本审核接口调用成功',
checks: [
{ name: 'AccessToken', status: 'pass', detail: '获取成功,有效期 7200 秒' },
{ name: '文本安全检测', status: 'pass', detail: '固定无害文本返回“通过”' },
{ name: '接口耗时', status: 'pass', detail: '128 ms' }
]
},
{
code: 'IMAGE_CALLBACK', label: '图片回调测试', status: 'fail', time: '2026/11/4 17:51:32',
summary: '微信审核请求参数格式无效,请核对接口字段',
checks: [
{ name: '临时图片上传', status: 'pass', detail: '测试图已上传并生成签名地址' },
{ name: '异步审核提交', status: 'fail', detail: 'errcode 47001 · 请求参数格式无效' },
{ name: '回调接收', status: 'pending', detail: '尚未收到微信回调,可稍后刷新' }
]
}
]
},
{
id: 'map',
name: '地图服务',
desc: '同时查看 Web / 小程序 Key 状态,并可请求固定地址验证当前 Web Key。',
ops: [
{
code: 'CONFIG', label: '配置诊断', status: 'warn', time: '2026/11/4 16:01:08',
summary: '地图接入配置诊断完成',
checks: [
{ name: 'Web Key', status: 'pass', detail: '腾讯 Web Key 已配置' },
{ name: '小程序 Key', status: 'warn', detail: '高德小程序 Key 待配置' },
{ name: '加密主密钥', status: 'pass', detail: 'AES-256-GCM 主密钥已配置' }
]
},
{
code: 'REQUEST', label: '真实请求', status: 'fail', time: '2026/11/4 16:01:10',
summary: '地图服务调用失败,请检查网络与 Key 域名白名单',
checks: [
{ name: 'Web Key 鉴权', status: 'pass', detail: 'Key 校验通过' },
{ name: '固定地址请求', status: 'fail', detail: '请求超时(10s),未返回有效坐标' }
]
}
]
},
{
id: 'storage',
name: '对象存储三副本',
desc: '逐渠道临时上传、读取并访问签名地址,完成后自动清理。',
ops: [
{
code: 'CONFIG', label: '配置诊断', status: 'pass', time: '2026/11/4 16:01:19',
summary: '对象存储配置完整',
checks: [
{ name: 'MinIO', status: 'pass', detail: '连通,测试文件读写正常' },
{ name: '七牛云', status: 'pass', detail: '签名地址可访问' },
{ name: '阿里云 OSS', status: 'pass', detail: '三副本配置完整' }
]
},
{
code: 'ROUND_TRIP', label: '往返测试', status: 'fail', time: '2026/11/4 16:01:22',
summary: '对象存储存在未知链路问题',
checks: [
{ name: 'MinIO 往返', status: 'pass', detail: '上传、读取、删除均成功' },
{ name: '七牛云往返', status: 'fail', detail: '签名地址返回 403,请检查密钥与空间域名' },
{ name: '阿里云 OSS 往返', status: 'warn', detail: '读取成功,删除略有延迟' }
]
}
]
},
{
id: 'sms',
name: '短信服务',
desc: '诊断 MessageHub 场景和渠道;真实短信需填写号码并确认。',
ops: [
{
code: 'CONFIG', label: '配置诊断', status: 'pass', time: '2026/11/4 16:01:25',
summary: '短信渠道配置完整',
checks: [
{ name: 'MessageHub 场景', status: 'pass', detail: '登录、绑定、找回密码场景齐备' },
{ name: '供应商通道', status: 'pass', detail: 'Spug 短信通道可用' }
]
},
{ code: 'SEND', label: '真实发送', status: 'idle', time: '', summary: '', checks: [] }
]
},
{
id: 'subscribe',
name: '微信订阅消息',
desc: '检查小程序凭据和固定模板;真实消息会消耗订阅额度。',
ops: [
{
code: 'CONFIG', label: '配置诊断', status: 'warn', time: '2026/11/4 16:01:31',
summary: '订阅消息模板待确认',
checks: [
{ name: '小程序凭据', status: 'pass', detail: 'AppID 与 AppSecret 已配置' },
{ name: '订阅模板', status: 'warn', detail: '模板 ID 未确认,真实发送可能失败' }
]
},
{ code: 'SEND', label: '真实发送', status: 'idle', time: '', summary: '', checks: [] }
]
}
];
var CONFIG_GROUPS = [
{
id: 'map',
name: '地图服务',
tags: ['安全接入'],
desc: '默认渠道与加密保存的 Web / 小程序 Key;停用后店铺地图选点不再调用已保存渠道。',
action: '保存地图设置',
cols: 3,
fields: [
{ label: '默认地图渠道', desc: '店铺选点和后台地图展示使用的默认渠道。', type: 'select', value: '腾讯地图', options: ['腾讯地图', '高德地图'], status: { k: 'pass', t: '启用' } },
{ label: '地图服务状态', desc: '停用后店铺地图选点不会调用已保存的渠道。', type: 'switch', on: true, status: { k: 'pass', t: '启用' } },
{ label: '腾讯 Web Key', desc: '用于后台腾讯地图选点。', type: 'password', placeholder: '填写腾讯 Web Key;留空保持原值', status: { k: 'pass', t: '已配置' }, link: '获取 Key' },
{ label: '高德 Web Key', desc: '用于后台高德地图选点。', type: 'password', placeholder: '填写高德 Web Key;留空保持原值', status: { k: 'idle', t: '待配置' }, link: '获取 Key' },
{ label: '高德小程序 Key', desc: '供 Salon 小程序地图能力使用。', type: 'password', placeholder: '填写高德小程序 Key;留空保持原值', status: { k: 'idle', t: '待配置' }, wide: true, link: '获取 Key' }
],
footnote: '密钥以 AES-256-GCM 加密保存在当前环境数据库,设置接口不回传密钥;Web Key 请在地图开放平台限制可用域名,并为 DEV / SIT / PROD 分别创建 Key。'
},
{
id: 'moderation',
name: '微信内容审核',
tags: ['安全回调'],
desc: '审核渠道、小程序凭据与回调密钥;配置不完整时内容保持隔离,不会自动放行。',
action: '保存审核设置',
cols: 2,
fields: [
{ label: '审核渠道', desc: '未启用或配置不完整时,内容保持隔离,不会自动放行。', type: 'select', value: '未启用(失败关闭)', options: ['未启用(失败关闭)', '微信内容安全审核'], status: { k: 'idle', t: '待配置' } },
{ label: '小程序凭据', desc: '服务端需配置当前环境的 AppID 与 AppSecret。', type: 'readonly', value: 'wx8a1c9f2d6031e7b4 · AppSecret 已配置', status: { k: 'pass', t: '已就绪' } },
{ label: '微信服务器回调 URL', desc: '复制到微信公众平台「开发管理 → 开发设置 → 消息推送」的 URL。', type: 'joined', value: 'https://admin.example.com/api/integration/wechat/content-moderation/callback', status: { k: 'pass', t: '公网 HTTPS' }, wide: true },
{ label: '回调 Token', desc: '3-32 位英文字母或数字;留空表示不修改已保存值。', type: 'password', placeholder: '填写新的 Token,留空保持原值', status: { k: 'pass', t: '已配置' }, clear: true },
{ label: 'EncodingAESKey', desc: '微信平台生成的 43 位密钥;消息加密方式必须选择「安全模式」。', type: 'password', placeholder: '填写 43 位 EncodingAESKey,留空保持原值', status: { k: 'pass', t: '已配置' }, clear: true }
],
guide: true,
footnote: 'URL 验证通过后再把审核渠道切换为「微信内容安全审核」并保存;Core 公网出口 IP 需加入小程序接口白名单。'
},
{
id: 'storage',
name: '对象存储读取顺序',
tags: ['FILE'],
desc: '头像、作品等资源按此顺序生成签名访问地址,并回退到可用副本。',
action: '保存读取顺序',
custom: 'order',
footnote: '仅作用于签名访问地址生成与可用副本回退;不影响上传首选、三副本要求和副本修复顺序。其他服务实例最多 30 秒完成同步。'
},
{
id: 'sms',
name: '短信服务',
tags: ['SMS'],
desc: '统一控制登录、绑定和找回密码的验证码发送通道。',
action: '保存短信设置',
custom: 'sms'
}
];
var state = { version: 'A', tab: 'runtime' };
function statusPill(kind, text) {
var k = STATUS[kind] ? STATUS[kind].cls : 'idle';
return '<span class="pill pill--' + k + '">' + (text || (STATUS[kind] ? STATUS[kind].label : '未测试')) + '</span>';
}
function shortTime(t) {
if (!t) return '';
var parts = t.split(' ');
return parts.length > 1 ? parts[1] : t;
}
function switchControl(on, onLabel, offLabel, cls) {
var text = on ? (onLabel || '启用') : (offLabel || '停用');
return '<button type="button" class="switch ' + (on ? 'is-on' : '') + (cls ? ' ' + cls : '') +
'" role="switch" aria-checked="' + (on ? 'true' : 'false') +
'" data-switch data-on-label="' + (onLabel || '启用') + '" data-off-label="' + (offLabel || '停用') + '">' +
'<span class="switch__track"></span><span class="switch__text">' + text + '</span></button>';
}
function inputPassword(placeholder, configured) {
return '<div class="input-wrap"><input type="password" value="" placeholder="' + placeholder + '">' +
'<button type="button" class="input-suffix" data-eye aria-label="显示或隐藏密码">' + ICON.eye + '</button></div>' +
(configured ? '' : '');
}
function runtimeField(f) {
var foot = '<div class="field__foot">' + statusPill(f.statusKind, f.statusText) +
(f.hint ? '<span class="hint">' + f.hint + '</span>' : '') +
(f.action ? '<button type="button" class="btn btn--text btn--end" data-toast="已保存:' + f.label + '(演示)">' + f.action + '</button>' : '') +
'</div>';
return '<article class="field">' +
'<div class="field__label">' + f.label + '</div>' +
'<p class="field__desc">' + f.desc + '</p>' +
'<div class="field__control">' + f.control + '</div>' +
foot +
'</article>';
}
function runtimeHTML() {
var fields1 = [
{
label: '后台新增用户默认密码',
desc: '新增或重置店长账号时使用,不影响已有账号。',
control: inputPassword('请输入 8-32 位强密码', true) + switchControl(true, '启用', '停用'),
statusKind: 'pass', statusText: '启用', action: '保存密码设置',
hint: '至少包含 3 类字符'
},
{
label: '店长员工审核提醒',
desc: '店长登录小程序时提醒处理待审核员工申请。',
control: switchControl(true, '显示', '隐藏'),
statusKind: 'pass', statusText: '启用', action: '保存提醒设置'
},
{
label: '内容审核通过后自动批准',
desc: '仅当门店资料内容审核通过时自动通过;关闭后人工复核。',
control: switchControl(false, '自动', '人工'),
statusKind: 'idle', statusText: '人工审核', action: '保存审核模式'
}
];
return '<div class="groups">' +
'<section class="group" id="g-account">' +
'<header class="group__head">' +
'<div class="group__head-main">' +
'<div class="group__title"><h2>账号与登录</h2><span class="tag">USER</span><span class="tag">WORKBENCH</span></div>' +
'<p class="group__desc">控制账号创建和店长登录后的默认行为,三项参数分别独立保存。</p>' +
'</div>' +
'<span class="meta">3 项参数</span>' +
'</header>' +
'<div class="group__body">' +
'<div class="field-grid cols-3">' + fields1.map(runtimeField).join('') + '</div>' +
'<p class="group__footnote">默认密码仍按后台账号接口校验;员工审核入口和数量角标不受登录提醒开关影响。</p>' +
'</div>' +
'</section>' +
'<section class="group" id="g-shop">' +
'<header class="group__head">' +
'<div class="group__head-main">' +
'<div class="group__title"><h2>门店经营</h2><span class="tag">SHOP</span></div>' +
'<p class="group__desc">新门店默认经营有效期,按审核通过当天起算。</p>' +
'</div>' +
'<span class="meta">1 项参数</span>' +
'</header>' +
'<div class="group__body">' +
'<div class="inline-field">' +
'<div class="inline-field__copy">' +
'<strong>新门店默认有效期</strong>' +
'<span>店长注册审核通过当天计为第 1 天;单个门店可在门店管理中单独调整到期日。</span>' +
'</div>' +
'<div class="inline-field__control">' +
'<div class="input-wrap input-wrap--number"><input type="number" value="30" min="1" max="3650"><span class="input-addon">天</span></div>' +
'<span class="hint">1–3650 天</span>' +
'</div>' +
'<div class="inline-field__foot">' + statusPill('pass', '生效中') +
'<button type="button" class="btn btn--text" data-toast="已保存:新门店默认有效期(演示)">保存有效期</button>' +
'</div>' +
'</div>' +
'<p class="group__footnote">门店到期只限制新增普通预约,不影响既有预约与历史数据。</p>' +
'</div>' +
'</section>' +
'</div>';
}
function summaryOf(ops) {
var counts = { pass: 0, warn: 0, fail: 0, pending: 0, idle: 0 };
ops.forEach(function (op) { counts[op.status] = (counts[op.status] || 0) + 1; });
var parts = [];
if (counts.pass) parts.push(counts.pass + ' 通过');
if (counts.warn) parts.push(counts.warn + ' 需关注');
if (counts.fail) parts.push(counts.fail + ' 失败');
if (counts.pending) parts.push(counts.pending + ' 等待回调');
if (counts.idle) parts.push(counts.idle + ' 未测试');
var kind = counts.fail ? 'fail' : counts.warn ? 'warn' : counts.pass ? 'pass' : 'idle';
return { text: parts.join(' · '), kind: kind };
}
function probeHTML() {
var totalFail = 0, totalWarn = 0;
PROBE.forEach(function (svc) {
svc.ops.forEach(function (op) {
if (op.status === 'fail') totalFail++;
if (op.status === 'warn') totalWarn++;
});
});
var cards = PROBE.map(function (svc) {
var summary = summaryOf(svc.ops);
var chips = svc.ops.map(function (op) {
var st = STATUS[op.status] || STATUS.idle;
var hasChecks = !!op.checks.length;
var cls = 'chip chip--' + st.cls + (op.status === 'idle' ? ' chip--idle' : '');
return '<button type="button" class="' + cls + '" data-chip data-svc="' + svc.id + '" data-code="' + op.code +
'" aria-expanded="false"' + (hasChecks ? '' : ' aria-disabled="true"') + '>' +
'<span class="chip__dot chip__dot--' + st.cls + '"></span>' +
'<span class="chip__label">' + op.label + '</span>' +
'<span class="chip__status">' + st.label + '</span>' +
(op.time ? '<span class="chip__time">' + shortTime(op.time) + '</span>' : '') +
(hasChecks ? '<span class="chip__chev">' + ICON.chevron + '</span>' : '') +
'</button>';
}).join('');
return '<article class="svc">' +
'<div class="svc__head">' +
'<span class="svc__name">' + svc.name + '</span>' +
'<span class="svc__desc" title="' + svc.desc + '">' + svc.desc + '</span>' +
statusPill(summary.kind, summary.text) +
'</div>' +
'<div class="chips">' + chips + '</div>' +
'<div class="svc__detail" data-detail hidden></div>' +
'</article>';
}).join('');
return '<div class="groups">' +
'<section class="group" id="g-probe">' +
'<header class="group__head">' +
'<div class="group__head-main">' +
'<div class="group__title"><h2>接入诊断</h2><span class="tag">TEST</span></div>' +
'<p class="group__desc">配置保存后再测试;点击测试项可展开检查项明细,真实发送会产生外部副作用。</p>' +
'</div>' +
'<div class="group__head-actions">' +
(totalFail ? statusPill('fail', totalFail + ' 项失败') : '') +
(totalWarn ? statusPill('warn', totalWarn + ' 项需关注') : '') +
'<button type="button" class="btn btn--sm" data-refresh>' + ICON.refresh + '<span>刷新最近结果</span></button>' +
'</div>' +
'</header>' +
'<div class="group__body">' +
'<div class="svc-grid">' + cards + '</div>' +
'<p class="group__footnote">短信和订阅消息默认只诊断,真实发送会产生外部副作用并要求二次确认;对象存储测试文件会自动清理。微信图片测试提交后显示等待回调,不会把异步结果误报为失败。</p>' +
'</div>' +
'</section>' +
CONFIG_GROUPS.map(configGroupHTML).join('') +
'</div>';
}
function fieldHTML(f) {
var control = '';
if (f.type === 'select') {
control = '<div class="select-wrap"><select class="select" aria-label="' + f.label + '">' +
f.options.map(function (o) {
return '<option' + (o === f.value ? ' selected' : '') + '>' + o + '</option>';
}).join('') + '</select>' + ICON.caret + '</div>';
} else if (f.type === 'password') {
control = inputPassword(f.placeholder || '', true);
} else if (f.type === 'joined') {
control = '<div class="input-wrap"><input type="text" value="' + f.value + '">' +
'<button type="button" class="input-suffix" data-toast="回调 URL 已复制(演示)" aria-label="复制回调 URL">' + ICON.copy + '</button></div>';
} else if (f.type === 'readonly') {
control = '<div class="readonly" title="' + f.value + '">' + f.value + '</div>';
} else if (f.type === 'switch') {
control = switchControl(!!f.on, '启用', '停用');
}
var foot = '<div class="field__foot">' + statusPill(f.status.k, f.status.t) +
(f.hint ? '<span class="hint">' + f.hint + '</span>' : '') +
(f.link ? '<a href="#" class="link" data-toast="演示:将打开地图开放平台 Key 管理页">' + f.link + ' ↗</a>' : '') +
(f.clear ? '<button type="button" class="btn btn--text btn--danger" data-toast="已标记为“保存后清除”(演示)">清除</button>' : '') +
'</div>';
return '<article class="field' + (f.wide ? ' field--wide' : '') + '">' +
'<div class="field__label">' + f.label + '</div>' +
'<p class="field__desc">' + f.desc + '</p>' +
'<div class="field__control">' + control + '</div>' +
foot +
'</article>';
}
function guideHTML() {
return '<details class="guide">' +
'<summary>微信平台填写指引<span>4 步</span></summary>' +
'<div class="guide__body">' +
'<ol>' +
'<li>先选择「未启用(失败关闭)」,填写 Token、EncodingAESKey 和公网 URL 后保存。</li>' +
'<li>在微信平台选择「安全模式」并完成 URL 验证,确认 AppID 与当前环境一致。</li>' +
'<li>URL 验证通过后回到本页,将审核渠道切换为「微信内容安全审核」并保存。</li>' +
'<li>将当前环境 Core 的公网出口 IP 加入小程序接口 IP 白名单。</li>' +
'</ol>' +
'<div class="guide__links">' +
'<a href="#" data-toast="演示:将打开微信公众平台">打开微信公众平台 ↗</a>' +
'<a href="#" data-toast="演示:将打开消息推送配置说明">消息推送配置说明 ↗</a>' +
'</div>' +
'</div>' +
'</details>';
}
function storageOrderHTML() {
var providers = ['MinIO', '七牛云', '阿里云 OSS'];
var items = providers.map(function (name, i) {
return '<div class="order-item">' +
'<span class="order-index">' + (i + 1) + '</span>' +
'<strong>' + name + '</strong>' +
'<div class="order-actions">' +
'<button type="button" class="btn btn--icon" data-move="up" aria-label="上移 ' + name + '"' + (i === 0 ? ' disabled' : '') + '>' + ICON.up + '</button>' +
'<button type="button" class="btn btn--icon" data-move="down" aria-label="下移 ' + name + '"' + (i === providers.length - 1 ? ' disabled' : '') + '>' + ICON.down + '</button>' +
'</div>' +
'</div>';
}).join('');
return '<div class="order-list" aria-label="对象存储读取优先级">' + items + '</div>';
}
function smsHTML() {
return '<div class="inline-field">' +
'<div class="inline-field__copy"><strong>短信供应商</strong><span>统一控制登录、绑定和找回密码的验证码通道。</span></div>' +
'<div class="inline-field__control"><div class="select-wrap"><select class="select" aria-label="短信供应商">' +
'<option selected>Spug 短信</option><option>阿里云短信认证服务</option>' +
'</select>' + ICON.caret + '</div></div>' +
'<div class="inline-field__foot"><span class="pill pill--warn">切换会影响全部验证码</span></div>' +
'</div>';
}
function configGroupHTML(g) {
var body;
if (g.custom === 'order') {
body = storageOrderHTML();
} else if (g.custom === 'sms') {
body = smsHTML();
} else {
body = '<div class="field-grid ' + (g.cols === 2 ? 'cols-2' : 'cols-3') + '">' +
g.fields.map(fieldHTML).join('') + '</div>' +
(g.guide ? guideHTML() : '');
}
return '<section class="group" id="g-' + g.id + '">' +
'<header class="group__head">' +
'<div class="group__head-main">' +
'<div class="group__title"><h2>' + g.name + '</h2>' +
g.tags.map(function (t) { return '<span class="tag">' + t + '</span>'; }).join('') +
'</div>' +
'<p class="group__desc">' + g.desc + '</p>' +
'</div>' +
'<div class="group__head-actions"><button type="button" class="btn btn--primary btn--sm" data-toast="已保存:' + g.name + '(演示)">' + g.action + '</button></div>' +
'</header>' +
'<div class="group__body">' + body +
(g.footnote ? '<p class="group__footnote">' + g.footnote + '</p>' : '') +
'</div>' +
'</section>';
}
function accountHTML() {
return '<div class="groups">' +
'<section class="group" id="g-account-info">' +
'<header class="group__head">' +
'<div class="group__head-main">' +
'<div class="group__title"><h2>账号信息</h2><span class="tag">ACCOUNT</span></div>' +
'<p class="group__desc">查看后台登录账号与当前会话状态。</p>' +
'</div>' +
'<div class="group__head-actions">' + statusPill('pass', '会话正常') + '</div>' +
'</header>' +
'<div class="group__body">' +
'<div class="account-grid">' +
'<div class="account-tile"><span class="account-tile__label">登录账号</span><strong>admin</strong><div class="account-tile__foot">' + statusPill('pass', '当前账号') + '</div></div>' +
'<div class="account-tile"><span class="account-tile__label">显示昵称</span><strong>平台管理员</strong><div class="account-tile__foot">' + statusPill('idle', '只读') + '</div></div>' +
'<div class="account-tile"><span class="account-tile__label">后台会话</span><strong>已登录</strong><div class="account-tile__foot">' + statusPill('pass', '正常') + '</div></div>' +
'</div>' +
'<div class="account-note"><span>后台请求使用管理员身份校验。</span><span>退出登录后当前会话立即失效。</span></div>' +
'</div>' +
'</section>' +
'</div>';
}
function navItemsFor(tab) {
if (tab === 'runtime') {
return [
{ id: 'g-account', label: '账号与登录' },
{ id: 'g-shop', label: '门店经营' }
];
}
if (tab === 'services') {
return [
{ id: 'g-probe', label: '接入诊断', badge: '5' },
{ id: 'g-map', label: '地图服务' },
{ id: 'g-moderation', label: '微信内容审核' },
{ id: 'g-storage', label: '对象存储读取顺序' },
{ id: 'g-sms', label: '短信服务' }
];
}
return [{ id: 'g-account-info', label: '账号信息' }];
}
function render() {
var panel = document.getElementById('panel');
var content = state.tab === 'runtime' ? runtimeHTML()
: state.tab === 'services' ? probeHTML()
: accountHTML();
var nav = '';
if (state.version === 'B') {
nav = '<aside class="subnav" aria-label="页内分组导航"><span class="subnav__label">分组导航</span>' +
navItemsFor(state.tab).map(function (item, i) {
return '<button type="button" class="subnav__item' + (i === 0 ? ' is-active' : '') + '" data-nav="' + item.id + '">' +
'<span>' + item.label + '</span>' + (item.badge ? '<em>' + item.badge + '</em>' : '') + '</button>';
}).join('') +
'</aside>';
}
panel.className = 'layout' + (state.version === 'B' ? ' layout--nav' : '');
panel.innerHTML = nav + '<div class="content">' + content + '</div>';
Array.prototype.forEach.call(document.querySelectorAll('[data-tab]'), function (btn) {
var active = btn.getAttribute('data-tab') === state.tab;
btn.classList.toggle('is-active', active);
btn.setAttribute('aria-selected', active ? 'true' : 'false');
});
Array.prototype.forEach.call(document.querySelectorAll('[data-version]'), function (btn) {
btn.classList.toggle('is-active', btn.getAttribute('data-version') === state.version);
});
}
/* ---------- interactions ---------- */
function toast(msg) {
var box = document.getElementById('toast');
box.textContent = msg;
box.classList.add('is-show');
clearTimeout(toast._timer);
toast._timer = setTimeout(function () { box.classList.remove('is-show'); }, 2200);
}
function findSvc(id) {
for (var i = 0; i < PROBE.length; i++) if (PROBE[i].id === id) return PROBE[i];
return null;
}
function detailHTML(svc, op) {
return '<div class="svc__detail-head"><span>' + svc.name + ' · ' + op.label + ' · ' +
(op.time || '未测试') + '</span><button type="button" class="btn btn--text" data-close-detail>收起</button></div>' +
op.checks.map(function (check) {
var st = STATUS[check.status] || STATUS.idle;
return '<div class="check-row"><span>' + check.name + '</span>' +
'<em class="status-text--' + st.cls + '">' + st.label + '</em>' +
'<span class="check-row__detail">' + check.detail + '</span></div>';
}).join('');
}
function closeDetails(card, except) {
Array.prototype.forEach.call(card.querySelectorAll('[data-chip]'), function (chip) {
if (chip === except) return;
chip.classList.remove('is-open');
chip.setAttribute('aria-expanded', 'false');
});
if (!except) {
var panel = card.querySelector('[data-detail]');
panel.hidden = true;
panel.innerHTML = '';
}
}
document.addEventListener('click', function (event) {
var target = event.target;
var tabBtn = target.closest('[data-tab]');
if (tabBtn) {
state.tab = tabBtn.getAttribute('data-tab');
render();
return;
}
var verBtn = target.closest('[data-version]');
if (verBtn) {
state.version = verBtn.getAttribute('data-version');
render();
return;
}
var navBtn = target.closest('[data-nav]');
if (navBtn) {
var group = document.getElementById(navBtn.getAttribute('data-nav'));
if (group) group.scrollIntoView({ behavior: 'smooth', block: 'start' });
var siblings = navBtn.parentNode.querySelectorAll('[data-nav]');
Array.prototype.forEach.call(siblings, function (el) { el.classList.remove('is-active'); });
navBtn.classList.add('is-active');
return;
}
var chip = target.closest('[data-chip]');
if (chip) {
var card = chip.closest('.svc');
var panel = card.querySelector('[data-detail]');
var expanded = chip.getAttribute('aria-expanded') === 'true';
if (expanded) {
chip.classList.remove('is-open');
chip.setAttribute('aria-expanded', 'false');
panel.hidden = true;
panel.innerHTML = '';
return;
}
if (chip.getAttribute('aria-disabled') === 'true') return;
var svc = findSvc(chip.getAttribute('data-svc'));
if (!svc) return;
var op = null;
for (var i = 0; i < svc.ops.length; i++) {
if (svc.ops[i].code === chip.getAttribute('data-code')) { op = svc.ops[i]; break; }
}
if (!op || !op.checks.length) return;
closeDetails(card, chip);
chip.classList.add('is-open');
chip.setAttribute('aria-expanded', 'true');
panel.innerHTML = detailHTML(svc, op);
panel.hidden = false;
return;
}
var closeBtn = target.closest('[data-close-detail]');
if (closeBtn) {
var host = closeBtn.closest('.svc');
closeDetails(host, null);
return;
}
var sw = target.closest('[data-switch]');
if (sw) {
var on = !sw.classList.contains('is-on');
sw.classList.toggle('is-on', on);
sw.setAttribute('aria-checked', on ? 'true' : 'false');
var label = sw.querySelector('.switch__text');
if (label) label.textContent = on ? sw.getAttribute('data-on-label') : sw.getAttribute('data-off-label');
return;
}
var eye = target.closest('[data-eye]');
if (eye) {
var wrap = eye.closest('.input-wrap');
var input = wrap ? wrap.querySelector('input') : null;
if (input) input.type = input.type === 'password' ? 'text' : 'password';
return;
}
var moveBtn = target.closest('[data-move]');
if (moveBtn && !moveBtn.disabled) {
var item = moveBtn.closest('.order-item');
var list = item ? item.parentNode : null;
if (list) {
var direction = moveBtn.getAttribute('data-move');
if (direction === 'up' && item.previousElementSibling) {
list.insertBefore(item, item.previousElementSibling);
} else if (direction === 'down' && item.nextElementSibling) {
list.insertBefore(item.nextElementSibling, item);
}
Array.prototype.forEach.call(list.querySelectorAll('.order-item'), function (node, index) {
var idx = node.querySelector('.order-index');
if (idx) idx.textContent = String(index + 1);
var up = node.querySelector('[data-move="up"]');
var down = node.querySelector('[data-move="down"]');
if (up) up.disabled = index === 0;
if (down) down.disabled = index === list.children.length - 1;
});
}
return;
}
var refresh = target.closest('[data-refresh]');
if (refresh) {
if (refresh.classList.contains('is-busy')) return;
refresh.classList.add('is-busy');
var text = refresh.querySelector('span');
if (text) text.textContent = '刷新中…';
setTimeout(function () {
refresh.classList.remove('is-busy');
var now = new Date();
var hh = String(now.getHours()).padStart(2, '0');
var mm = String(now.getMinutes()).padStart(2, '0');
var ss = String(now.getSeconds()).padStart(2, '0');
if (text) text.textContent = '刷新于 ' + hh + ':' + mm + ':' + ss;
toast('最近接入测试结果已更新(演示)');
}, 900);
return;
}
var toastBtn = target.closest('[data-toast]');
if (toastBtn) {
if (toastBtn.tagName === 'A') event.preventDefault();
toast(toastBtn.getAttribute('data-toast'));
}
});
render();
})();
</script>
</body>
</html>