mirror of
https://github.com/jasonxu114514/opencode2api.git
synced 2026-12-05 16:04:01 +00:00
Merge branch 'pr-98'
# Conflicts: # webui/styles.css
This commit is contained in:
commit
d4f1e136ed
26 files changed
+4102
-3298
No files matched your search
-1470
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,280 @@
|
||||
/* Reset, typography, focus, skip link and the two-column application shell. */
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
html {
|
||||
-webkit-text-size-adjust: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
background: var(--bg);
|
||||
color: var(--text-1);
|
||||
font: var(--fs-base) / var(--lh-base) var(--font-sans);
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
p,
|
||||
ul,
|
||||
ol,
|
||||
dl,
|
||||
dd,
|
||||
figure {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
button,
|
||||
input,
|
||||
select,
|
||||
textarea {
|
||||
font: inherit;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
button {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
a {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
code,
|
||||
pre {
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.mono {
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
|
||||
:focus-visible {
|
||||
outline: 2px solid var(--text-1);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.skip-link {
|
||||
position: fixed;
|
||||
top: -80px;
|
||||
left: var(--sp-4);
|
||||
z-index: 100;
|
||||
padding: var(--sp-2) var(--sp-4);
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border-2);
|
||||
border-radius: var(--r-md);
|
||||
}
|
||||
|
||||
.skip-link:focus {
|
||||
top: var(--sp-4);
|
||||
}
|
||||
|
||||
.app {
|
||||
display: grid;
|
||||
grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--sp-5);
|
||||
padding: var(--sp-5) var(--sp-3);
|
||||
border-right: 1px solid var(--border-1);
|
||||
background: var(--bg);
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.brand {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--sp-2);
|
||||
padding: 0 var(--sp-2);
|
||||
}
|
||||
|
||||
.brand-name {
|
||||
font-size: var(--fs-base);
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
|
||||
.nav {
|
||||
display: grid;
|
||||
gap: var(--sp-5);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.nav-group {
|
||||
display: grid;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.nav-group-title {
|
||||
padding: 0 var(--sp-2) var(--sp-1);
|
||||
font-size: var(--fs-xs);
|
||||
color: var(--text-3);
|
||||
}
|
||||
|
||||
.nav-item {
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding: 7px var(--sp-2);
|
||||
border: 0;
|
||||
border-radius: var(--r-md);
|
||||
background: transparent;
|
||||
color: var(--text-2);
|
||||
text-align: left;
|
||||
font-size: var(--fs-base);
|
||||
}
|
||||
|
||||
.nav-item:hover {
|
||||
color: var(--text-1);
|
||||
background: var(--bg-subtle);
|
||||
}
|
||||
|
||||
.nav-item.active {
|
||||
color: var(--text-1);
|
||||
background: var(--bg-subtle);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.sidebar-foot {
|
||||
margin-top: auto;
|
||||
padding: var(--sp-3) var(--sp-2) 0;
|
||||
border-top: 1px solid var(--border-1);
|
||||
font-family: var(--font-mono);
|
||||
font-size: 11px;
|
||||
color: var(--text-3);
|
||||
}
|
||||
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.topbar {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: var(--sp-4);
|
||||
width: 100%;
|
||||
max-width: var(--content-max);
|
||||
margin-inline: auto;
|
||||
padding: var(--sp-6) var(--sp-8) var(--sp-4);
|
||||
border-bottom: 1px solid var(--border-1);
|
||||
}
|
||||
|
||||
.page-title {
|
||||
font-size: var(--fs-2xl);
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.02em;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.page-sub {
|
||||
margin-top: var(--sp-1);
|
||||
max-width: 640px;
|
||||
font-size: var(--fs-sm);
|
||||
color: var(--text-2);
|
||||
}
|
||||
|
||||
.topbar-actions {
|
||||
display: flex;
|
||||
flex-shrink: 0;
|
||||
gap: var(--sp-2);
|
||||
}
|
||||
|
||||
main {
|
||||
width: 100%;
|
||||
max-width: var(--content-max);
|
||||
margin-inline: auto;
|
||||
padding: var(--sp-6) var(--sp-8) var(--sp-12);
|
||||
}
|
||||
|
||||
@media (max-width: 980px) {
|
||||
.app {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
position: static;
|
||||
height: auto;
|
||||
gap: var(--sp-3);
|
||||
padding: var(--sp-3) var(--sp-4);
|
||||
border-right: 0;
|
||||
border-bottom: 1px solid var(--border-1);
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.nav {
|
||||
display: flex;
|
||||
gap: var(--sp-4);
|
||||
overflow-x: auto;
|
||||
padding-bottom: var(--sp-1);
|
||||
}
|
||||
|
||||
.nav-group {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.nav-group-title {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.nav-item {
|
||||
width: auto;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.sidebar-foot {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.topbar {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
padding: var(--sp-5) var(--sp-4) var(--sp-3);
|
||||
}
|
||||
|
||||
.topbar-actions {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
main {
|
||||
padding: var(--sp-5) var(--sp-4) var(--sp-10);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 680px) {
|
||||
main {
|
||||
padding-inline: var(--sp-3);
|
||||
}
|
||||
|
||||
.topbar {
|
||||
padding-inline: var(--sp-3);
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
animation-duration: 0.01ms !important;
|
||||
animation-iteration-count: 1 !important;
|
||||
transition-duration: 0.01ms !important;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,520 @@
|
||||
/* Buttons, forms, sections, tables, status, chips, dialogs and shared primitives. */
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 36px;
|
||||
padding: 0 14px;
|
||||
border: 1px solid var(--border-2);
|
||||
border-radius: var(--r-md);
|
||||
background: var(--surface);
|
||||
color: var(--text-1);
|
||||
font-size: var(--fs-base);
|
||||
font-weight: 500;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.btn:hover:not(:disabled) {
|
||||
background: var(--bg-subtle);
|
||||
}
|
||||
|
||||
.btn:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
border-color: var(--inverse-bg);
|
||||
background: var(--inverse-bg);
|
||||
color: var(--inverse-text);
|
||||
}
|
||||
|
||||
.btn-primary:hover:not(:disabled) {
|
||||
border-color: var(--inverse-hover);
|
||||
background: var(--inverse-hover);
|
||||
}
|
||||
|
||||
.btn-danger {
|
||||
border-color: var(--border-2);
|
||||
color: var(--bad);
|
||||
}
|
||||
|
||||
.btn-danger:hover:not(:disabled) {
|
||||
border-color: var(--bad);
|
||||
background: var(--bad-bg);
|
||||
}
|
||||
|
||||
.btn-ghost {
|
||||
border-color: transparent;
|
||||
background: transparent;
|
||||
color: var(--text-2);
|
||||
}
|
||||
|
||||
.btn-ghost:hover:not(:disabled) {
|
||||
background: var(--bg-subtle);
|
||||
color: var(--text-1);
|
||||
}
|
||||
|
||||
.btn-sm {
|
||||
height: 30px;
|
||||
padding: 0 10px;
|
||||
font-size: var(--fs-sm);
|
||||
}
|
||||
|
||||
.btn-block {
|
||||
width: 100%;
|
||||
margin-top: var(--sp-2);
|
||||
}
|
||||
|
||||
.field {
|
||||
display: grid;
|
||||
gap: var(--sp-2);
|
||||
margin: var(--sp-4) 0;
|
||||
}
|
||||
|
||||
.field > label {
|
||||
font-size: var(--fs-sm);
|
||||
font-weight: 500;
|
||||
color: var(--text-2);
|
||||
}
|
||||
|
||||
input,
|
||||
select,
|
||||
textarea {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
padding: 8px 10px;
|
||||
border: 1px solid var(--border-2);
|
||||
border-radius: var(--r-md);
|
||||
background: var(--surface);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
input:focus,
|
||||
select:focus,
|
||||
textarea:focus {
|
||||
border-color: var(--text-1);
|
||||
box-shadow: 0 0 0 3px var(--focus-ring);
|
||||
}
|
||||
|
||||
input:focus-visible,
|
||||
select:focus-visible,
|
||||
textarea:focus-visible {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
textarea {
|
||||
min-height: 92px;
|
||||
resize: vertical;
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--fs-sm);
|
||||
line-height: 1.55;
|
||||
}
|
||||
|
||||
.check {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--sp-2);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.check input {
|
||||
width: auto;
|
||||
flex-shrink: 0;
|
||||
accent-color: var(--inverse-bg);
|
||||
}
|
||||
|
||||
.form-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
column-gap: var(--sp-5);
|
||||
}
|
||||
|
||||
.form-grid .full {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.form-error {
|
||||
min-height: 20px;
|
||||
margin-top: var(--sp-2);
|
||||
font-size: var(--fs-sm);
|
||||
color: var(--bad);
|
||||
}
|
||||
|
||||
.section {
|
||||
padding: var(--sp-5);
|
||||
border: 1px solid var(--border-1);
|
||||
border-radius: var(--r-lg);
|
||||
background: var(--surface);
|
||||
}
|
||||
|
||||
.section-head {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: var(--sp-4);
|
||||
margin-bottom: var(--sp-4);
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: var(--fs-lg);
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
|
||||
.section-caption {
|
||||
margin-top: 2px;
|
||||
font-size: var(--fs-sm);
|
||||
color: var(--text-2);
|
||||
}
|
||||
|
||||
.table-wrap {
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: var(--fs-sm);
|
||||
}
|
||||
|
||||
.table th,
|
||||
.table td {
|
||||
padding: 8px 10px;
|
||||
text-align: left;
|
||||
vertical-align: baseline;
|
||||
border-bottom: 1px solid var(--border-1);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.table th {
|
||||
padding-block: 6px;
|
||||
font-size: var(--fs-xs);
|
||||
font-weight: 500;
|
||||
color: var(--text-3);
|
||||
}
|
||||
|
||||
.table tr:last-child td {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.table tbody tr:hover {
|
||||
background: var(--bg-subtle);
|
||||
}
|
||||
|
||||
.num {
|
||||
text-align: right;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.status {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.status::before {
|
||||
content: "";
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
border-radius: 50%;
|
||||
background: currentColor;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.ok {
|
||||
color: var(--ok);
|
||||
}
|
||||
|
||||
.warn {
|
||||
color: var(--warn);
|
||||
}
|
||||
|
||||
.bad {
|
||||
color: var(--bad);
|
||||
}
|
||||
|
||||
.chips {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--sp-2);
|
||||
margin: var(--sp-2) 0;
|
||||
}
|
||||
|
||||
.chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--sp-2);
|
||||
padding: 3px 8px;
|
||||
border: 1px solid var(--border-1);
|
||||
border-radius: var(--r-sm);
|
||||
background: var(--bg-subtle);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--fs-xs);
|
||||
}
|
||||
|
||||
.chip button {
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: 2px;
|
||||
background: transparent;
|
||||
color: var(--text-3);
|
||||
font-size: var(--fs-base);
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.chip button:hover {
|
||||
color: var(--bad);
|
||||
}
|
||||
|
||||
.code-card {
|
||||
margin: var(--sp-3) 0;
|
||||
border: 1px solid var(--border-1);
|
||||
border-radius: var(--r-md);
|
||||
background: var(--surface-2);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.code-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--sp-2);
|
||||
padding: var(--sp-2) var(--sp-3);
|
||||
border-bottom: 1px solid var(--border-1);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--fs-xs);
|
||||
color: var(--text-3);
|
||||
}
|
||||
|
||||
.code-card pre {
|
||||
margin: 0;
|
||||
padding: var(--sp-3);
|
||||
overflow-x: auto;
|
||||
font-size: var(--fs-xs);
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.notice {
|
||||
padding: var(--sp-3) var(--sp-4);
|
||||
border: 1px solid var(--warn);
|
||||
border-radius: var(--r-md);
|
||||
background: var(--warn-bg);
|
||||
font-size: var(--fs-sm);
|
||||
}
|
||||
|
||||
.toast {
|
||||
position: fixed;
|
||||
right: var(--sp-5);
|
||||
bottom: var(--sp-5);
|
||||
z-index: 60;
|
||||
max-width: 360px;
|
||||
padding: var(--sp-3) var(--sp-4);
|
||||
border: 1px solid var(--border-2);
|
||||
border-radius: var(--r-md);
|
||||
background: var(--surface);
|
||||
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.14);
|
||||
font-size: var(--fs-sm);
|
||||
}
|
||||
|
||||
.toast.bad-toast {
|
||||
border-color: var(--bad);
|
||||
}
|
||||
|
||||
.dialog-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 70;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
padding: var(--sp-4);
|
||||
background: var(--overlay);
|
||||
}
|
||||
|
||||
.dialog {
|
||||
width: min(440px, 100%);
|
||||
max-height: 84vh;
|
||||
overflow: auto;
|
||||
padding: var(--sp-5);
|
||||
border: 1px solid var(--border-2);
|
||||
border-radius: var(--r-lg);
|
||||
background: var(--surface);
|
||||
}
|
||||
|
||||
.dialog-lg {
|
||||
width: min(720px, 100%);
|
||||
}
|
||||
|
||||
.dialog-title {
|
||||
font-size: var(--fs-lg);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.dialog-text {
|
||||
margin-top: var(--sp-2);
|
||||
font-size: var(--fs-sm);
|
||||
color: var(--text-2);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.dialog .field {
|
||||
margin: var(--sp-3) 0 0;
|
||||
}
|
||||
|
||||
.dialog pre {
|
||||
margin: var(--sp-3) 0 0;
|
||||
padding: var(--sp-3);
|
||||
max-height: 50vh;
|
||||
overflow: auto;
|
||||
border: 1px solid var(--border-1);
|
||||
border-radius: var(--r-md);
|
||||
background: var(--surface-2);
|
||||
font-size: var(--fs-xs);
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.dialog-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: var(--sp-2);
|
||||
margin-top: var(--sp-5);
|
||||
}
|
||||
|
||||
.facts {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: var(--sp-4) var(--sp-5);
|
||||
}
|
||||
|
||||
.fact {
|
||||
display: grid;
|
||||
gap: 3px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.fact-label {
|
||||
font-size: var(--fs-xs);
|
||||
color: var(--text-3);
|
||||
}
|
||||
|
||||
.fact-value {
|
||||
font-size: var(--fs-sm);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.empty {
|
||||
padding: var(--sp-4) var(--sp-2);
|
||||
color: var(--text-3);
|
||||
font-size: var(--fs-sm);
|
||||
}
|
||||
|
||||
.actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: var(--sp-2);
|
||||
margin-top: var(--sp-4);
|
||||
}
|
||||
|
||||
.key-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--sp-1);
|
||||
}
|
||||
|
||||
.filters {
|
||||
display: grid;
|
||||
grid-template-columns: 140px 160px minmax(180px, 1fr) auto;
|
||||
gap: var(--sp-2);
|
||||
margin-bottom: var(--sp-4);
|
||||
}
|
||||
|
||||
progress {
|
||||
width: 100%;
|
||||
height: 8px;
|
||||
border: 0;
|
||||
border-radius: 999px;
|
||||
background: var(--bg-subtle);
|
||||
overflow: hidden;
|
||||
appearance: none;
|
||||
}
|
||||
|
||||
progress::-webkit-progress-bar {
|
||||
background: var(--bg-subtle);
|
||||
}
|
||||
|
||||
progress::-webkit-progress-value {
|
||||
border-radius: 999px;
|
||||
background: var(--inverse-bg);
|
||||
}
|
||||
|
||||
progress::-moz-progress-bar {
|
||||
border-radius: 999px;
|
||||
background: var(--inverse-bg);
|
||||
}
|
||||
|
||||
@media (max-width: 680px) {
|
||||
.form-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.form-grid .full {
|
||||
grid-column: auto;
|
||||
}
|
||||
|
||||
.filters {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
|
||||
.section-head {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.dialog-actions {
|
||||
flex-direction: column-reverse;
|
||||
}
|
||||
|
||||
.dialog-actions .btn {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.tabs {
|
||||
display: flex;
|
||||
gap: var(--sp-1);
|
||||
border-bottom: 1px solid var(--border-1);
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.tab {
|
||||
padding: 7px var(--sp-3) 9px;
|
||||
margin-bottom: -1px;
|
||||
border: 0;
|
||||
border-bottom: 2px solid transparent;
|
||||
background: transparent;
|
||||
color: var(--text-2);
|
||||
font-size: var(--fs-base);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.tab:hover {
|
||||
color: var(--text-1);
|
||||
}
|
||||
|
||||
.tab.active {
|
||||
color: var(--text-1);
|
||||
border-bottom-color: var(--text-1);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.sticky-actions {
|
||||
position: sticky;
|
||||
bottom: 0;
|
||||
z-index: 5;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: var(--sp-2);
|
||||
margin-top: var(--sp-4);
|
||||
padding: var(--sp-3) 0;
|
||||
border-top: 1px solid var(--border-1);
|
||||
background: var(--bg);
|
||||
}
|
||||
@@ -0,0 +1,379 @@
|
||||
/* Page layouts: login, dashboards, charts, logs, playground and rotation. */
|
||||
.login-view {
|
||||
min-height: 100vh;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
padding: var(--sp-6);
|
||||
}
|
||||
|
||||
.login-card {
|
||||
width: min(380px, 100%);
|
||||
padding: var(--sp-8);
|
||||
border: 1px solid var(--border-1);
|
||||
border-radius: var(--r-lg);
|
||||
background: var(--surface);
|
||||
}
|
||||
|
||||
.login-name {
|
||||
margin-bottom: var(--sp-6);
|
||||
font-size: var(--fs-2xl);
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
.page {
|
||||
display: grid;
|
||||
gap: var(--sp-5);
|
||||
align-content: start;
|
||||
}
|
||||
|
||||
.split {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: var(--sp-5);
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.stack {
|
||||
display: grid;
|
||||
gap: var(--sp-5);
|
||||
align-content: start;
|
||||
}
|
||||
|
||||
.metrics {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 1px;
|
||||
border: 1px solid var(--border-1);
|
||||
border-radius: var(--r-lg);
|
||||
background: var(--border-1);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.metric {
|
||||
display: grid;
|
||||
gap: var(--sp-1);
|
||||
align-content: start;
|
||||
padding: var(--sp-4) var(--sp-5);
|
||||
background: var(--surface);
|
||||
}
|
||||
|
||||
.metric-label {
|
||||
font-size: var(--fs-sm);
|
||||
color: var(--text-2);
|
||||
}
|
||||
|
||||
.metric-value {
|
||||
margin-top: var(--sp-1);
|
||||
font-size: var(--fs-3xl);
|
||||
font-weight: 600;
|
||||
font-variant-numeric: tabular-nums;
|
||||
letter-spacing: -0.02em;
|
||||
line-height: 1.15;
|
||||
}
|
||||
|
||||
.metric-note {
|
||||
font-size: var(--fs-xs);
|
||||
color: var(--text-3);
|
||||
}
|
||||
|
||||
.breakdown {
|
||||
display: grid;
|
||||
gap: var(--sp-2);
|
||||
align-content: start;
|
||||
}
|
||||
|
||||
.breakdown h3 {
|
||||
font-size: var(--fs-sm);
|
||||
font-weight: 500;
|
||||
color: var(--text-2);
|
||||
}
|
||||
|
||||
.guide {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 1px;
|
||||
border: 1px solid var(--border-1);
|
||||
border-radius: var(--r-lg);
|
||||
background: var(--border-1);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.guide-step {
|
||||
display: grid;
|
||||
gap: var(--sp-2);
|
||||
align-content: start;
|
||||
min-height: 140px;
|
||||
padding: var(--sp-5);
|
||||
background: var(--surface);
|
||||
}
|
||||
|
||||
.guide-step h3 {
|
||||
font-size: var(--fs-base);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.guide-step p {
|
||||
font-size: var(--fs-sm);
|
||||
color: var(--text-2);
|
||||
}
|
||||
|
||||
.step-state {
|
||||
margin-top: auto;
|
||||
font-size: var(--fs-xs);
|
||||
}
|
||||
|
||||
.trend {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
gap: 2px;
|
||||
height: 200px;
|
||||
padding-top: var(--sp-4);
|
||||
border-bottom: 1px solid var(--border-2);
|
||||
}
|
||||
|
||||
.trend-bar {
|
||||
flex: 1;
|
||||
min-width: 2px;
|
||||
border-radius: 2px 2px 0 0;
|
||||
background: var(--text-3);
|
||||
}
|
||||
|
||||
.trend-bar:hover {
|
||||
background: var(--text-1);
|
||||
}
|
||||
|
||||
.trend-meta {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: var(--sp-3);
|
||||
margin-top: var(--sp-2);
|
||||
font-size: var(--fs-xs);
|
||||
color: var(--text-3);
|
||||
}
|
||||
|
||||
.tier-row {
|
||||
display: grid;
|
||||
grid-template-columns: 64px minmax(0, 1fr) 88px;
|
||||
align-items: center;
|
||||
gap: var(--sp-3);
|
||||
padding: var(--sp-2) 0;
|
||||
font-size: var(--fs-sm);
|
||||
}
|
||||
|
||||
.tier-track {
|
||||
height: 8px;
|
||||
border-radius: 999px;
|
||||
background: var(--bg-subtle);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.tier-fill {
|
||||
height: 100%;
|
||||
border-radius: 999px;
|
||||
background: var(--inverse-bg);
|
||||
}
|
||||
|
||||
.tier-value {
|
||||
text-align: right;
|
||||
font-variant-numeric: tabular-nums;
|
||||
color: var(--text-2);
|
||||
}
|
||||
|
||||
.quota-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: var(--sp-4);
|
||||
}
|
||||
|
||||
.quota-card {
|
||||
display: grid;
|
||||
gap: var(--sp-2);
|
||||
padding: var(--sp-4);
|
||||
border: 1px solid var(--border-1);
|
||||
border-radius: var(--r-md);
|
||||
}
|
||||
|
||||
.quota-card h3 {
|
||||
font-size: var(--fs-sm);
|
||||
font-weight: 500;
|
||||
color: var(--text-2);
|
||||
}
|
||||
|
||||
.quota-value {
|
||||
font-size: var(--fs-2xl);
|
||||
font-weight: 600;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.quota-reset {
|
||||
font-size: var(--fs-xs);
|
||||
color: var(--text-3);
|
||||
}
|
||||
|
||||
.quota-low progress::-webkit-progress-value {
|
||||
background: var(--warn);
|
||||
}
|
||||
|
||||
.quota-low progress::-moz-progress-bar {
|
||||
background: var(--warn);
|
||||
}
|
||||
|
||||
.quota-status {
|
||||
margin: var(--sp-4) 0;
|
||||
padding: var(--sp-3) var(--sp-4);
|
||||
border: 1px solid var(--border-1);
|
||||
border-radius: var(--r-md);
|
||||
background: var(--surface-2);
|
||||
font-size: var(--fs-sm);
|
||||
color: var(--text-2);
|
||||
}
|
||||
|
||||
.logs {
|
||||
height: 62vh;
|
||||
overflow: auto;
|
||||
border: 1px solid var(--border-1);
|
||||
border-radius: var(--r-md);
|
||||
background: var(--surface-2);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--fs-xs);
|
||||
}
|
||||
|
||||
.log {
|
||||
display: grid;
|
||||
grid-template-columns: 84px 54px 110px minmax(180px, 1fr);
|
||||
gap: var(--sp-3);
|
||||
padding: 6px var(--sp-3);
|
||||
border-bottom: 1px solid var(--border-1);
|
||||
}
|
||||
|
||||
.log:hover {
|
||||
background: var(--bg-subtle);
|
||||
}
|
||||
|
||||
.log-time,
|
||||
.log-fields {
|
||||
color: var(--text-3);
|
||||
}
|
||||
|
||||
.log-fields {
|
||||
grid-column: 4;
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.play-layout {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
||||
gap: var(--sp-5);
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.json-editor {
|
||||
min-height: 420px;
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--fs-xs);
|
||||
line-height: 1.6;
|
||||
background: var(--surface-2);
|
||||
}
|
||||
|
||||
.key-env {
|
||||
margin: var(--sp-3) 0;
|
||||
padding: var(--sp-4);
|
||||
border: 1px solid var(--border-1);
|
||||
border-radius: var(--r-md);
|
||||
background: var(--surface-2);
|
||||
font-size: var(--fs-xs);
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
#api-key-created {
|
||||
border-color: var(--ok);
|
||||
}
|
||||
|
||||
#account-form {
|
||||
max-width: 660px;
|
||||
}
|
||||
|
||||
.head-search {
|
||||
max-width: 240px;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.rotation-group .field {
|
||||
max-width: 360px;
|
||||
}
|
||||
|
||||
.rotation-current {
|
||||
margin-top: var(--sp-2);
|
||||
font-size: var(--fs-sm);
|
||||
color: var(--text-2);
|
||||
}
|
||||
|
||||
.rotation-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--sp-1);
|
||||
}
|
||||
|
||||
.rotation-switches {
|
||||
display: grid;
|
||||
gap: var(--sp-1);
|
||||
margin-top: var(--sp-4);
|
||||
font-size: var(--fs-sm);
|
||||
color: var(--text-2);
|
||||
}
|
||||
|
||||
.rotation-switches h3 {
|
||||
font-size: var(--fs-sm);
|
||||
font-weight: 500;
|
||||
color: var(--text-3);
|
||||
}
|
||||
|
||||
#rotation-attempts td {
|
||||
max-width: 280px;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
@media (max-width: 980px) {
|
||||
.metrics {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.split,
|
||||
.play-layout {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 680px) {
|
||||
.metrics,
|
||||
.guide,
|
||||
.quota-grid,
|
||||
.facts {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.json-editor {
|
||||
min-height: 300px;
|
||||
}
|
||||
|
||||
.head-search {
|
||||
max-width: none;
|
||||
width: 100%;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.log {
|
||||
grid-template-columns: 72px 48px minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.log-component {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.log-fields {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/* Design tokens: monochrome scale, semantic status colors, type and spacing. */
|
||||
:root {
|
||||
color-scheme: light;
|
||||
|
||||
--bg: #fafafa;
|
||||
--bg-subtle: #f1f1f1;
|
||||
--surface: #ffffff;
|
||||
--surface-2: #fafafa;
|
||||
--text-1: #0a0a0a;
|
||||
--text-2: #5e5e5e;
|
||||
--text-3: #8f8f8f;
|
||||
--border-1: #e6e6e6;
|
||||
--border-2: #d4d4d4;
|
||||
--inverse-bg: #0a0a0a;
|
||||
--inverse-text: #ffffff;
|
||||
--inverse-hover: #333333;
|
||||
--focus-ring: rgba(10, 10, 10, 0.14);
|
||||
--overlay: rgba(0, 0, 0, 0.45);
|
||||
|
||||
--ok: #1a7f37;
|
||||
--warn: #9a6700;
|
||||
--warn-bg: #fff8c5;
|
||||
--bad: #cf222e;
|
||||
--bad-bg: #ffebe9;
|
||||
|
||||
--font-sans:
|
||||
system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans",
|
||||
"PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
|
||||
--font-mono:
|
||||
ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
|
||||
|
||||
--fs-xs: 12px;
|
||||
--fs-sm: 13px;
|
||||
--fs-base: 14px;
|
||||
--fs-lg: 16px;
|
||||
--fs-2xl: 24px;
|
||||
--fs-3xl: 30px;
|
||||
|
||||
--lh-base: 1.6;
|
||||
|
||||
--sp-1: 4px;
|
||||
--sp-2: 8px;
|
||||
--sp-3: 12px;
|
||||
--sp-4: 16px;
|
||||
--sp-5: 20px;
|
||||
--sp-6: 24px;
|
||||
--sp-8: 32px;
|
||||
--sp-10: 40px;
|
||||
--sp-12: 48px;
|
||||
|
||||
--r-sm: 4px;
|
||||
--r-md: 6px;
|
||||
--r-lg: 10px;
|
||||
|
||||
--sidebar-w: 232px;
|
||||
--content-max: 1280px;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
color-scheme: dark;
|
||||
|
||||
--bg: #0a0a0a;
|
||||
--bg-subtle: #171717;
|
||||
--surface: #121212;
|
||||
--surface-2: #0d0d0d;
|
||||
--text-1: #ededed;
|
||||
--text-2: #a0a0a0;
|
||||
--text-3: #787878;
|
||||
--border-1: #262626;
|
||||
--border-2: #3a3a3a;
|
||||
--inverse-bg: #ededed;
|
||||
--inverse-text: #0a0a0a;
|
||||
--inverse-hover: #cfcfcf;
|
||||
--focus-ring: rgba(237, 237, 237, 0.18);
|
||||
--overlay: rgba(0, 0, 0, 0.6);
|
||||
|
||||
--ok: #3fb950;
|
||||
--warn: #d29922;
|
||||
--warn-bg: rgba(210, 153, 34, 0.15);
|
||||
--bad: #f85149;
|
||||
--bad-bg: rgba(248, 81, 73, 0.15);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -7,5 +7,5 @@ import (
|
||||
|
||||
// Assets contains the static management interface served by the admin listener.
|
||||
//
|
||||
//go:embed index.html app.js styles.css
|
||||
//go:embed index.html css js
|
||||
var Assets embed.FS
|
||||
+927
-888
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,50 @@
|
||||
// fetch wrapper: JSON handling, CSRF for writes, 401 routed to the login view.
|
||||
import * as store from "./store.js";
|
||||
|
||||
let csrf = "";
|
||||
let onUnauthorized = null;
|
||||
|
||||
export function setCsrf(value) {
|
||||
csrf = value || "";
|
||||
}
|
||||
|
||||
export function clearCsrf() {
|
||||
csrf = "";
|
||||
}
|
||||
|
||||
export function hasSession() {
|
||||
return csrf !== "";
|
||||
}
|
||||
|
||||
export function setUnauthorizedHandler(handler) {
|
||||
onUnauthorized = handler;
|
||||
}
|
||||
|
||||
export async function api(path, options = {}) {
|
||||
const headers = { ...(options.headers || {}), Accept: "application/json" };
|
||||
if (options.body) headers["Content-Type"] = "application/json";
|
||||
if (csrf && !["GET", "HEAD"].includes((options.method || "GET").toUpperCase()))
|
||||
headers["X-CSRF-Token"] = csrf;
|
||||
const response = await fetch(path, { ...options, headers });
|
||||
if (response.status === 204) return null;
|
||||
const data = await response.json().catch(() => ({}));
|
||||
if (!response.ok) {
|
||||
// The login endpoint answers 401 for bad credentials: surface its message
|
||||
// instead of treating the attempt as an expired session.
|
||||
if (response.status === 401 && path !== "/api/auth/login") {
|
||||
if (onUnauthorized) onUnauthorized();
|
||||
throw new Error("登录已失效");
|
||||
}
|
||||
throw new Error(data.error?.message || `HTTP ${response.status}`);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
// Client-facing API base derived from the configured listen address.
|
||||
export function derivedAPIBase() {
|
||||
const config = store.get("config");
|
||||
const listen = config?.effective?.listen || config?.listen || ":8080";
|
||||
const match = listen.match(/^\[.*\]:(\d+)$/) || listen.match(/:(\d+)$/);
|
||||
const port = match?.[1] || "8080";
|
||||
return `${location.protocol}//${location.hostname}:${port}`;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// Shared API loaders that populate the console store.
|
||||
import { api } from "./api.js";
|
||||
import * as store from "./store.js";
|
||||
import { toast } from "./ui.js";
|
||||
|
||||
export async function refreshMonitor() {
|
||||
try {
|
||||
store.set("monitor", await api("/api/monitor"));
|
||||
} catch {
|
||||
// The 3s poll stays silent; transient failures surface in the log stream.
|
||||
}
|
||||
}
|
||||
|
||||
export async function loadConfig() {
|
||||
store.set("config", await api("/api/config"));
|
||||
}
|
||||
|
||||
export async function loadDebugModels() {
|
||||
try {
|
||||
const data = await api("/api/debug/models");
|
||||
if (data.last_inference) store.set("lastPlayground", data.last_inference);
|
||||
store.set("debug", data);
|
||||
} catch (error) {
|
||||
toast(error.message, true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
// Live log stream: SSE connection, bounded buffer and rendering. The
|
||||
// connection lifecycle is owned by the console shell.
|
||||
import { $, el, timeOnly, toast } from "./ui.js";
|
||||
|
||||
let events = [];
|
||||
let source = null;
|
||||
let paused = false;
|
||||
let visible = false;
|
||||
let renderPending = false;
|
||||
|
||||
function render() {
|
||||
const level = $("#log-level").value;
|
||||
const component = $("#log-component").value.toLowerCase();
|
||||
const query = $("#log-search").value.toLowerCase();
|
||||
const rows = events
|
||||
.filter(
|
||||
(item) =>
|
||||
(!level || item.level === level) &&
|
||||
(!component || (item.component || "").toLowerCase().includes(component)) &&
|
||||
(!query || JSON.stringify(item).toLowerCase().includes(query)),
|
||||
)
|
||||
.slice(-500);
|
||||
const host = $("#log-list");
|
||||
host.replaceChildren();
|
||||
rows.forEach((item) => {
|
||||
const levelClass =
|
||||
item.level === "error" ? "bad" : item.level === "warn" ? "warn" : item.level === "info" ? "ok" : "";
|
||||
host.append(
|
||||
el("div", { class: "log" }, [
|
||||
el("span", { class: "log-time", text: timeOnly(item.time) }),
|
||||
el("span", { class: levelClass, text: item.level }),
|
||||
el("span", { class: "log-component", text: item.component || "core" }),
|
||||
el("span", { class: "log-message", text: item.message }),
|
||||
el("span", { class: "log-fields", text: JSON.stringify(item.fields || {}) }),
|
||||
]),
|
||||
);
|
||||
});
|
||||
if (!rows.length) host.append(el("div", { class: "empty", text: "等待日志事件…" }));
|
||||
host.scrollTop = host.scrollHeight;
|
||||
}
|
||||
|
||||
export function connect() {
|
||||
disconnect();
|
||||
// The server replays its recent ring on every subscribe; start from a clean
|
||||
// buffer so a re-login does not duplicate the previous session's events.
|
||||
events = [];
|
||||
source = new EventSource("/api/logs/stream");
|
||||
source.addEventListener("log", (event) => {
|
||||
events.push(JSON.parse(event.data));
|
||||
if (events.length > 2000) events.shift();
|
||||
if (!paused && visible && !renderPending) {
|
||||
renderPending = true;
|
||||
requestAnimationFrame(() => {
|
||||
renderPending = false;
|
||||
render();
|
||||
});
|
||||
}
|
||||
});
|
||||
source.addEventListener("gap", () => toast("较早日志已从内存清除", true));
|
||||
}
|
||||
|
||||
export function disconnect() {
|
||||
if (source) source.close();
|
||||
source = null;
|
||||
}
|
||||
|
||||
// The stream tab reports its visibility so hidden panels skip rendering while
|
||||
// the buffer keeps filling.
|
||||
export function setVisible(value) {
|
||||
visible = value;
|
||||
if (visible) render();
|
||||
}
|
||||
|
||||
export function bind() {
|
||||
["#log-level", "#log-component", "#log-search"].forEach((selector) =>
|
||||
$(selector).addEventListener("input", render),
|
||||
);
|
||||
$("#log-pause").addEventListener("click", () => {
|
||||
paused = !paused;
|
||||
$("#log-pause").textContent = paused ? "继续" : "暂停";
|
||||
if (!paused) render();
|
||||
});
|
||||
}
|
||||
|
||||
export { render };
|
||||
@@ -0,0 +1,122 @@
|
||||
// Console shell: boot, login, navigation and shared data loading.
|
||||
import { api, setCsrf, clearCsrf, setUnauthorizedHandler } from "./api.js";
|
||||
import { refreshMonitor, loadConfig, loadDebugModels } from "./data.js";
|
||||
import * as store from "./store.js";
|
||||
import { $, $$, toast } from "./ui.js";
|
||||
import * as logstream from "./logstream.js";
|
||||
|
||||
import overview from "./pages/overview.js";
|
||||
import diagnostics from "./pages/diagnostics.js";
|
||||
import access from "./pages/access.js";
|
||||
import apiKeys from "./pages/api-keys.js";
|
||||
import quotas from "./pages/model-quotas.js";
|
||||
import rotation from "./pages/rotation.js";
|
||||
import configPage from "./pages/config.js";
|
||||
import account from "./pages/account.js";
|
||||
|
||||
const PAGES = [overview, diagnostics, access, apiKeys, quotas, rotation, configPage, account];
|
||||
const byId = new Map(PAGES.map((page) => [page.id, page]));
|
||||
|
||||
// Hrefs from the previous 13-page layout keep working.
|
||||
const HASH_ALIASES = {
|
||||
guide: "overview",
|
||||
usage: "overview",
|
||||
playground: "diagnostics",
|
||||
logs: "diagnostics",
|
||||
availability: "model-quotas",
|
||||
};
|
||||
|
||||
let current = null;
|
||||
let monitorTimer = null;
|
||||
|
||||
function openPage(id) {
|
||||
const page = byId.get(id);
|
||||
if (!page) return;
|
||||
current?.hide?.();
|
||||
history.replaceState(null, "", `#${id}`);
|
||||
$$(".nav-item").forEach((button) =>
|
||||
button.classList.toggle("active", button.dataset.page === id),
|
||||
);
|
||||
$$(".page").forEach((node) => node.classList.toggle("hidden", node.id !== `page-${id}`));
|
||||
$("#page-title").textContent = page.title;
|
||||
$("#page-sub").textContent = page.sub;
|
||||
current = page;
|
||||
page.show?.();
|
||||
}
|
||||
|
||||
function showLogin() {
|
||||
clearCsrf();
|
||||
current?.hide?.();
|
||||
current = null;
|
||||
$("#app").classList.add("hidden");
|
||||
$("#login").classList.remove("hidden");
|
||||
clearInterval(monitorTimer);
|
||||
monitorTimer = null;
|
||||
logstream.disconnect();
|
||||
for (const page of PAGES) page.reset?.();
|
||||
}
|
||||
|
||||
async function enterConsole(session) {
|
||||
setCsrf(session.csrf_token);
|
||||
$("#login").classList.add("hidden");
|
||||
$("#app").classList.remove("hidden");
|
||||
await loadConfig();
|
||||
await Promise.all([refreshMonitor(), loadDebugModels()]);
|
||||
clearInterval(monitorTimer);
|
||||
monitorTimer = setInterval(refreshMonitor, 3000);
|
||||
logstream.connect();
|
||||
const hash = location.hash.slice(1);
|
||||
const id = byId.has(hash) ? hash : HASH_ALIASES[hash];
|
||||
openPage(id && byId.has(id) ? id : "overview");
|
||||
}
|
||||
|
||||
async function boot() {
|
||||
try {
|
||||
await enterConsole(await api("/api/auth/session"));
|
||||
} catch {
|
||||
showLogin();
|
||||
}
|
||||
}
|
||||
|
||||
setUnauthorizedHandler(showLogin);
|
||||
|
||||
store.on("monitor", (data) => {
|
||||
$("#version").textContent = `v${data.version}`;
|
||||
});
|
||||
|
||||
for (const page of PAGES) page.init?.();
|
||||
|
||||
$$(".nav-item").forEach((button) => {
|
||||
button.addEventListener("click", () => openPage(button.dataset.page));
|
||||
});
|
||||
|
||||
$("#refresh-now").addEventListener("click", async () => {
|
||||
await Promise.all([refreshMonitor(), loadConfig(), loadDebugModels()]);
|
||||
await current?.refresh?.();
|
||||
toast("状态已刷新");
|
||||
});
|
||||
|
||||
$("#logout").addEventListener("click", async () => {
|
||||
try {
|
||||
await api("/api/auth/logout", { method: "POST", body: "{}" });
|
||||
} finally {
|
||||
showLogin();
|
||||
}
|
||||
});
|
||||
|
||||
$("#login-form").addEventListener("submit", async (event) => {
|
||||
event.preventDefault();
|
||||
$("#login-error").textContent = "";
|
||||
try {
|
||||
const session = await api("/api/auth/login", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ username: $("#login-user").value, password: $("#login-pass").value }),
|
||||
});
|
||||
$("#login-pass").value = "";
|
||||
await enterConsole(session);
|
||||
} catch (error) {
|
||||
$("#login-error").textContent = error.message;
|
||||
}
|
||||
});
|
||||
|
||||
boot();
|
||||
@@ -0,0 +1,47 @@
|
||||
// Page: 接入手册 — derived API base, protocol and SDK examples with copy buttons.
|
||||
import { derivedAPIBase } from "../api.js";
|
||||
import * as store from "../store.js";
|
||||
import { $, el, copyText } from "../ui.js";
|
||||
|
||||
function codeCard(label, text) {
|
||||
const copy = el("button", { type: "button", class: "btn btn-sm btn-ghost", text: "复制" });
|
||||
copy.addEventListener("click", () => copyText(text, "示例已复制"));
|
||||
return el("div", { class: "code-card" }, [
|
||||
el("div", { class: "code-head" }, [el("span", { text: label }), copy]),
|
||||
el("pre", {}, [el("code", { text })]),
|
||||
]);
|
||||
}
|
||||
|
||||
function render() {
|
||||
const config = store.get("config");
|
||||
if (!config) return;
|
||||
const base = derivedAPIBase();
|
||||
const model = $("#access-model")?.value.trim() || "YOUR_MODEL";
|
||||
$("#access-base-value").value = base;
|
||||
const protocols = $("#access-protocol-examples");
|
||||
const sdks = $("#access-sdk-examples");
|
||||
protocols.replaceChildren();
|
||||
sdks.replaceChildren();
|
||||
const chat = `curl ${base}/v1/chat/completions \\\n -H "Authorization: Bearer YOUR_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d '{"model":"${model}","messages":[{"role":"user","content":"Hello"}]}'`;
|
||||
const responses = `curl ${base}/v1/responses \\\n -H "Authorization: Bearer YOUR_API_KEY" \\\n -H "Content-Type: application/json" \\\n -d '{"model":"${model}","input":"Hello"}'`;
|
||||
const anthropic = `curl ${base}/v1/messages \\\n -H "x-api-key: YOUR_API_KEY" \\\n -H "anthropic-version: 2023-06-01" \\\n -H "Content-Type: application/json" \\\n -d '{"model":"${model}","max_tokens":512,"messages":[{"role":"user","content":"Hello"}]}'`;
|
||||
protocols.append(
|
||||
codeCard("Chat Completions", chat),
|
||||
codeCard("Responses", responses),
|
||||
codeCard("Anthropic Messages", anthropic),
|
||||
);
|
||||
const python = `from openai import OpenAI\n\nclient = OpenAI(base_url="${base}/v1", api_key="YOUR_API_KEY")\nresponse = client.chat.completions.create(\n model="${model}",\n messages=[{"role": "user", "content": "Hello"}],\n)\nprint(response.choices[0].message.content)`;
|
||||
const javascript = `import OpenAI from "openai";\n\nconst client = new OpenAI({\n baseURL: "${base}/v1",\n apiKey: "YOUR_API_KEY",\n});\nconst response = await client.responses.create({\n model: "${model}",\n input: "Hello",\n});\nconsole.log(response.output_text);`;
|
||||
sdks.append(codeCard("Python · OpenAI SDK", python), codeCard("JavaScript · OpenAI SDK", javascript));
|
||||
}
|
||||
|
||||
export default {
|
||||
id: "access",
|
||||
title: "接入手册",
|
||||
sub: "Chat、Responses、Anthropic 与 SDK 示例。",
|
||||
init() {
|
||||
store.on("config", render);
|
||||
$("#access-model").addEventListener("input", render);
|
||||
},
|
||||
show: render,
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
// Page: 账号安全 — update admin credentials; all sessions are revoked afterwards.
|
||||
import { api } from "../api.js";
|
||||
import { $, toast } from "../ui.js";
|
||||
|
||||
export default {
|
||||
id: "account",
|
||||
title: "账号安全",
|
||||
sub: "更新账号后撤销全部管理会话。",
|
||||
init() {
|
||||
$("#account-form").addEventListener("submit", async (event) => {
|
||||
event.preventDefault();
|
||||
try {
|
||||
await api("/api/account", {
|
||||
method: "PUT",
|
||||
body: JSON.stringify({
|
||||
current_password: $("#a-current").value,
|
||||
username: $("#a-user").value,
|
||||
new_password: $("#a-new").value,
|
||||
}),
|
||||
});
|
||||
toast("账号已更新,请重新登录");
|
||||
setTimeout(() => location.reload(), 800);
|
||||
} catch (error) {
|
||||
toast(error.message, true);
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,143 @@
|
||||
// Page: API Key 管理 — create, rename, enable/disable and delete caller keys.
|
||||
import { api, derivedAPIBase, hasSession } from "../api.js";
|
||||
import { loadConfig } from "../data.js";
|
||||
import * as store from "../store.js";
|
||||
import { $, el, emptyRow, formatNumber, localTime, confirmDialog, copyText, promptDialog, toast } from "../ui.js";
|
||||
|
||||
let keysLoading = false;
|
||||
let createdKey = "";
|
||||
|
||||
async function load() {
|
||||
if (keysLoading) return;
|
||||
keysLoading = true;
|
||||
$("#api-key-refresh").disabled = true;
|
||||
try {
|
||||
const data = await api("/api/api-keys");
|
||||
if (hasSession()) render(data.keys);
|
||||
} catch (error) {
|
||||
$("#api-key-status").textContent = `读取失败:${error.message}`;
|
||||
} finally {
|
||||
keysLoading = false;
|
||||
$("#api-key-refresh").disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function mutate(id, method, body, button) {
|
||||
button.disabled = true;
|
||||
try {
|
||||
const data = await api(`/api/api-keys/${encodeURIComponent(id)}`, {
|
||||
method,
|
||||
...(body ? { body: JSON.stringify(body) } : {}),
|
||||
});
|
||||
if (!hasSession()) return;
|
||||
render(data.keys);
|
||||
await loadConfig();
|
||||
toast("已保存并立即生效");
|
||||
} catch (error) {
|
||||
toast(error.message, true);
|
||||
} finally {
|
||||
button.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
function render(keys) {
|
||||
keys = keys || [];
|
||||
$("#api-key-count").textContent = `${keys.length} 个`;
|
||||
$("#api-key-status").textContent = `${keys.filter((key) => key.enabled).length} 个已启用`;
|
||||
const host = $("#api-key-list");
|
||||
host.replaceChildren();
|
||||
for (const key of keys) {
|
||||
const usage = key.usage || {};
|
||||
const summary = (value = {}) =>
|
||||
`${formatNumber(value.requests)} 次 · ${formatNumber(value.total_tokens)} tokens`;
|
||||
const rename = el("button", { type: "button", class: "btn btn-sm btn-ghost", text: "重命名" });
|
||||
rename.addEventListener("click", async () => {
|
||||
const name = await promptDialog({
|
||||
title: "重命名 API Key",
|
||||
label: "密钥名称",
|
||||
value: key.name,
|
||||
confirmLabel: "保存",
|
||||
});
|
||||
if (name !== null) mutate(key.id, "PATCH", { name }, rename);
|
||||
});
|
||||
const toggle = el("button", {
|
||||
type: "button",
|
||||
class: "btn btn-sm btn-ghost",
|
||||
text: key.enabled ? "停用" : "启用",
|
||||
});
|
||||
toggle.addEventListener("click", () => mutate(key.id, "PATCH", { enabled: !key.enabled }, toggle));
|
||||
const remove = el("button", { type: "button", class: "btn btn-sm btn-danger", text: "删除" });
|
||||
remove.addEventListener("click", async () => {
|
||||
const ok = await confirmDialog({
|
||||
title: "删除 API Key",
|
||||
message: `删除「${key.name}」后,使用它的应用将无法继续访问。确定删除?`,
|
||||
confirmLabel: "删除",
|
||||
danger: true,
|
||||
});
|
||||
if (ok) mutate(key.id, "DELETE", null, remove);
|
||||
});
|
||||
host.append(
|
||||
el("tr", {}, [
|
||||
el("td", { text: key.name }),
|
||||
el("td", { class: "mono", text: key.display }),
|
||||
el("td", { class: `status ${key.enabled ? "ok" : "warn"}`, text: key.enabled ? "已启用" : "已停用" }),
|
||||
el("td", { text: `${summary(usage.last_hour)} / ${summary(usage.lifetime)}` }),
|
||||
el("td", { text: key.created_at ? localTime(key.created_at) : "已有配置" }),
|
||||
el("td", {}, [el("div", { class: "key-actions" }, [rename, toggle, remove])]),
|
||||
]),
|
||||
);
|
||||
}
|
||||
if (!keys.length) emptyRow(host, 6, "暂无 API Key");
|
||||
}
|
||||
|
||||
async function create(event) {
|
||||
event.preventDefault();
|
||||
const button = $("#api-key-create");
|
||||
button.disabled = true;
|
||||
try {
|
||||
const data = await api("/api/api-keys", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ name: $("#api-key-name").value, value: $("#api-key-value").value }),
|
||||
});
|
||||
if (!hasSession()) return;
|
||||
createdKey = data.key;
|
||||
const goModels = store.get("debug")?.models?.filter((item) => item.available_go) || [];
|
||||
const model =
|
||||
goModels.find((item) => item.model === "glm-5.3-flash")?.model ||
|
||||
goModels[0]?.model ||
|
||||
"YOUR_MODEL";
|
||||
$("#api-key-env").textContent = `OPENAI_API_KEY=${data.key}\nOPENAI_BASE_URL=${derivedAPIBase()}/v1\nOPENAI_MODEL=${model}`;
|
||||
$("#api-key-created").classList.remove("hidden");
|
||||
$("#api-key-form").reset();
|
||||
render(data.keys);
|
||||
await loadConfig();
|
||||
toast("API Key 已创建");
|
||||
} catch (error) {
|
||||
toast(error.message, true);
|
||||
} finally {
|
||||
button.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
function resetCreated() {
|
||||
createdKey = "";
|
||||
$("#api-key-env").textContent = "";
|
||||
$("#api-key-created").classList.add("hidden");
|
||||
$("#api-key-value").value = "";
|
||||
}
|
||||
|
||||
export default {
|
||||
id: "api-keys",
|
||||
title: "API Key 管理",
|
||||
sub: "给每个调用方独立的访问密钥。",
|
||||
init() {
|
||||
$("#api-key-form").addEventListener("submit", create);
|
||||
$("#api-key-refresh").addEventListener("click", load);
|
||||
$("#api-key-dismiss").addEventListener("click", resetCreated);
|
||||
$("#api-key-copy").addEventListener("click", () => copyText(createdKey));
|
||||
$("#api-key-copy-env").addEventListener("click", () => copyText($("#api-key-env").textContent));
|
||||
},
|
||||
show: load,
|
||||
refresh: load,
|
||||
reset: resetCreated,
|
||||
};
|
||||
@@ -0,0 +1,191 @@
|
||||
// Page: 配置中心 — masked config editing with validation, hot reload and reveal.
|
||||
import { api } from "../api.js";
|
||||
import { loadConfig, loadDebugModels } from "../data.js";
|
||||
import * as store from "../store.js";
|
||||
import { $, bindTabs, el, openDialog, toast } from "../ui.js";
|
||||
|
||||
function renderChips(name) {
|
||||
const host = $(`#${name}-chips`);
|
||||
host.replaceChildren();
|
||||
(store.get("config")?.[name] || []).forEach((item) => {
|
||||
const remove = el("button", { type: "button", title: "移除", text: "×" });
|
||||
const chip = el("span", { class: "chip", dataset: { id: item.id } });
|
||||
remove.addEventListener("click", () => chip.remove());
|
||||
chip.append(el("span", { text: item.display }), remove);
|
||||
host.append(chip);
|
||||
});
|
||||
}
|
||||
|
||||
function secretInputs(name) {
|
||||
const kept = [...$(`#${name}-chips`).children].map((node) => ({ id: node.dataset.id }));
|
||||
const added = $(`#${name}-new`)
|
||||
.value.split(/\r?\n/)
|
||||
.map((value) => value.trim())
|
||||
.filter(Boolean)
|
||||
.map((value) => ({ value }));
|
||||
return kept.concat(added);
|
||||
}
|
||||
|
||||
const numberValue = (selector) => Number($(selector).value);
|
||||
|
||||
function fillConfig(value) {
|
||||
if (!value) return;
|
||||
$("#c-listen").value = value.listen;
|
||||
$("#c-prefer").value = value.prefer;
|
||||
$("#c-web-listen").value = value.webui.listen;
|
||||
$("#c-session").value = value.webui.session_ttl_minutes;
|
||||
$("#c-web-enabled").checked = value.webui.enabled;
|
||||
$("#c-anonymous").checked = !!value.anonymous;
|
||||
$("#c-proxyfile").value = value.proxyfile;
|
||||
$("#c-up-zen").value = value.upstream.zen;
|
||||
$("#c-up-go").value = value.upstream.go;
|
||||
$("#c-attempts").value = value.retry.max_attempts;
|
||||
$("#c-timeout").value = value.retry.timeout_seconds;
|
||||
$("#c-refresh").value = value.models.refresh_seconds;
|
||||
$("#c-protocols").value = JSON.stringify(value.models.protocols || {}, null, 2);
|
||||
$("#c-free-only").checked = !!value.models.free_only;
|
||||
const reasoning = value.reasoning || {};
|
||||
$("#c-reasoning-effort").value = reasoning.effort || "";
|
||||
$("#c-reasoning-by-model").value = JSON.stringify(reasoning.effort_by_model || {}, null, 2);
|
||||
$("#c-idle").value = value.performance.max_idle_conns;
|
||||
$("#c-idle-host").value = value.performance.max_idle_conns_per_host;
|
||||
$("#c-max-host").value = value.performance.max_conns_per_host;
|
||||
$("#c-idle-timeout").value = value.performance.idle_conn_timeout_seconds;
|
||||
$("#c-connect").value = value.performance.connect_timeout_seconds;
|
||||
$("#c-cooldown").value = value.performance.failure_cooldown_seconds;
|
||||
$("#c-attempt-timeout").value = value.performance.attempt_timeout_seconds;
|
||||
$("#c-first-event-timeout").value = value.performance.first_event_timeout_seconds || 0;
|
||||
$("#c-level").value = value.logging.level;
|
||||
$("#c-ring").value = value.logging.ring_size;
|
||||
$("#c-dump-bodies").checked = !!value.logging.dump_request_bodies;
|
||||
["server_keys", "zen_keys", "go_keys", "proxies"].forEach(renderChips);
|
||||
const notice = $("#restart-notice");
|
||||
if (value.restart_required_fields?.length) {
|
||||
notice.textContent = `已保存但尚未生效:${value.restart_required_fields.join(", ")}。当前 API ${value.effective.listen}、WebUI ${value.effective.webui_listen}。请重启进程。`;
|
||||
notice.classList.remove("hidden");
|
||||
} else {
|
||||
notice.classList.add("hidden");
|
||||
}
|
||||
}
|
||||
|
||||
async function save(event) {
|
||||
event.preventDefault();
|
||||
const current = store.get("config");
|
||||
if (!current) return;
|
||||
try {
|
||||
const update = {
|
||||
listen: $("#c-listen").value,
|
||||
server_keys: secretInputs("server_keys"),
|
||||
zen_keys: secretInputs("zen_keys"),
|
||||
go_keys: secretInputs("go_keys"),
|
||||
anonymous: $("#c-anonymous").checked,
|
||||
proxies: secretInputs("proxies"),
|
||||
proxyfile: $("#c-proxyfile").value,
|
||||
prefer: $("#c-prefer").value,
|
||||
upstream: { zen: $("#c-up-zen").value, go: $("#c-up-go").value },
|
||||
retry: { max_attempts: numberValue("#c-attempts"), timeout_seconds: numberValue("#c-timeout") },
|
||||
models: {
|
||||
refresh_seconds: numberValue("#c-refresh"),
|
||||
protocols: JSON.parse($("#c-protocols").value || "{}"),
|
||||
free_only: $("#c-free-only").checked,
|
||||
},
|
||||
reasoning: {
|
||||
effort: $("#c-reasoning-effort").value,
|
||||
effort_by_model: JSON.parse($("#c-reasoning-by-model").value || "{}"),
|
||||
},
|
||||
performance: {
|
||||
max_idle_conns: numberValue("#c-idle"),
|
||||
max_idle_conns_per_host: numberValue("#c-idle-host"),
|
||||
max_conns_per_host: numberValue("#c-max-host"),
|
||||
idle_conn_timeout_seconds: numberValue("#c-idle-timeout"),
|
||||
connect_timeout_seconds: numberValue("#c-connect"),
|
||||
failure_cooldown_seconds: numberValue("#c-cooldown"),
|
||||
attempt_timeout_seconds: numberValue("#c-attempt-timeout"),
|
||||
first_event_timeout_seconds: numberValue("#c-first-event-timeout"),
|
||||
},
|
||||
logging: {
|
||||
level: $("#c-level").value,
|
||||
ring_size: numberValue("#c-ring"),
|
||||
dump_request_bodies: $("#c-dump-bodies").checked,
|
||||
},
|
||||
webui: {
|
||||
enabled: $("#c-web-enabled").checked,
|
||||
listen: $("#c-web-listen").value,
|
||||
username: current.webui.username,
|
||||
session_ttl_minutes: numberValue("#c-session"),
|
||||
},
|
||||
};
|
||||
const result = await api("/api/config", { method: "PUT", body: JSON.stringify(update) });
|
||||
store.set("config", result.config);
|
||||
["server_keys", "zen_keys", "go_keys", "proxies"].forEach(
|
||||
(name) => ($(`#${name}-new`).value = ""),
|
||||
);
|
||||
await loadDebugModels();
|
||||
toast(
|
||||
result.result.restart_required
|
||||
? `已应用;${result.result.restart_fields.join(", ")} 需重启`
|
||||
: "配置已保存并立即应用",
|
||||
);
|
||||
} catch (error) {
|
||||
toast(error.message, true);
|
||||
}
|
||||
}
|
||||
|
||||
async function reload() {
|
||||
try {
|
||||
const result = await api("/api/config/reload", { method: "POST", body: "{}" });
|
||||
await loadConfig();
|
||||
await loadDebugModels();
|
||||
toast(result.restart_required ? "磁盘配置已重载,监听字段需重启" : "磁盘配置已重载");
|
||||
} catch (error) {
|
||||
toast(error.message, true);
|
||||
}
|
||||
}
|
||||
|
||||
function reveal() {
|
||||
const input = el("input", { type: "password", autocomplete: "current-password" });
|
||||
const submit = async (close) => {
|
||||
try {
|
||||
const values = await api("/api/config/reveal", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ password: input.value }),
|
||||
});
|
||||
close();
|
||||
openDialog({
|
||||
title: "敏感配置",
|
||||
size: "dialog-lg",
|
||||
body: el("pre", { text: JSON.stringify(values, null, 2) }),
|
||||
actions: [{ label: "关闭" }],
|
||||
});
|
||||
} catch (error) {
|
||||
toast(error.message, true);
|
||||
}
|
||||
};
|
||||
const dialog = openDialog({
|
||||
title: "查看敏感配置",
|
||||
body: el("div", { class: "field" }, [el("label", { text: "请再次输入管理密码" }), input]),
|
||||
actions: [
|
||||
{ label: "取消" },
|
||||
{ label: "查看", kind: "btn-primary", onClick: submit },
|
||||
],
|
||||
});
|
||||
input.addEventListener("keydown", (event) => {
|
||||
if (event.key === "Enter") {
|
||||
event.preventDefault();
|
||||
submit(dialog.close);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export default {
|
||||
id: "config",
|
||||
title: "配置中心",
|
||||
sub: "验证后原子保存,并热应用可变字段。",
|
||||
init() {
|
||||
store.on("config", fillConfig);
|
||||
bindTabs($("#page-config"));
|
||||
$("#config-form").addEventListener("submit", save);
|
||||
$("#reload-config").addEventListener("click", reload);
|
||||
$("#reveal").addEventListener("click", reveal);
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,320 @@
|
||||
// Page: 诊断 — request testing, routing, ledgers and the live event stream.
|
||||
import { api } from "../api.js";
|
||||
import { loadDebugModels } from "../data.js";
|
||||
import * as logstream from "../logstream.js";
|
||||
import * as store from "../store.js";
|
||||
import {
|
||||
$,
|
||||
bindTabs,
|
||||
copyText,
|
||||
el,
|
||||
emptyRow,
|
||||
formatNumber,
|
||||
renderFacts,
|
||||
timeOnly,
|
||||
toast,
|
||||
} from "../ui.js";
|
||||
|
||||
const keyTestLabels = {
|
||||
usable: "Key 可用",
|
||||
rejected: "Key 被拒绝",
|
||||
rate_limited: "Key 已被接受但受到限流",
|
||||
upstream_error: "上游异常,无法判定 Key",
|
||||
transport_error: "网络或代理异常,无法判定 Key",
|
||||
unavailable: "Key 或运行时不可用",
|
||||
request_error: "请求未成功",
|
||||
};
|
||||
|
||||
function playgroundTemplate() {
|
||||
const protocol = $("#play-protocol").value;
|
||||
const model = $("#play-model").value || "YOUR_MODEL";
|
||||
if (protocol === "responses") return { model, input: "用一句话说明这个模型的能力。" };
|
||||
if (protocol === "anthropic")
|
||||
return {
|
||||
model,
|
||||
max_tokens: 512,
|
||||
messages: [{ role: "user", content: "用一句话说明这个模型的能力。" }],
|
||||
};
|
||||
return { model, messages: [{ role: "user", content: "用一句话说明这个模型的能力。" }] };
|
||||
}
|
||||
|
||||
function resetTemplate() {
|
||||
$("#play-request").value = JSON.stringify(playgroundTemplate(), null, 2);
|
||||
}
|
||||
|
||||
function renderKeys() {
|
||||
const select = $("#play-key");
|
||||
const selected = select.value;
|
||||
select.replaceChildren();
|
||||
select.append(el("option", { value: "auto", text: "自动路由(匿名 / Tier 回退 / Key 轮询)" }));
|
||||
const keys = store.get("debug")?.keys || {};
|
||||
for (const [tier, label] of [
|
||||
["zen", "Zen Keys"],
|
||||
["go", "Go Keys"],
|
||||
]) {
|
||||
const items = keys[tier] || [];
|
||||
if (!items.length) continue;
|
||||
const group = el("optgroup", { label });
|
||||
for (const item of items) {
|
||||
const cooling = item.cooldown_until
|
||||
? ` · 冷却至 ${new Date(item.cooldown_until).toLocaleTimeString("zh-CN", { hour12: false })}`
|
||||
: "";
|
||||
group.append(
|
||||
el("option", {
|
||||
value: `${tier}:${item.id}`,
|
||||
text: `${tier.toUpperCase()} · ${item.display} · ${item.id}${cooling}`,
|
||||
}),
|
||||
);
|
||||
}
|
||||
select.append(group);
|
||||
}
|
||||
if (selected && [...select.options].some((option) => option.value === selected)) select.value = selected;
|
||||
else select.value = "auto";
|
||||
}
|
||||
|
||||
function renderModels() {
|
||||
const select = $("#play-model");
|
||||
const selected = select.value;
|
||||
select.replaceChildren();
|
||||
(store.get("debug")?.models || []).forEach((item) => {
|
||||
select.append(el("option", { value: item.model, text: item.model }));
|
||||
});
|
||||
if (selected && [...select.options].some((option) => option.value === selected)) select.value = selected;
|
||||
if (!$("#play-request").value.trim()) resetTemplate();
|
||||
renderKeys();
|
||||
}
|
||||
|
||||
function showResult(result) {
|
||||
const keyTest = result.key_test ? keyTestLabels[result.key_test] || result.key_test : "";
|
||||
const state = $("#play-state");
|
||||
state.textContent = result.ok
|
||||
? `请求成功 · HTTP ${result.http_status}`
|
||||
: `请求失败 · HTTP ${result.http_status}`;
|
||||
state.className = `section-caption ${result.ok ? "ok" : "bad"}`;
|
||||
const route = result.route || {};
|
||||
const eligibility = route.anonymous_eligibility || {};
|
||||
const selected = result.selected_key;
|
||||
const routeLabel = route.tier
|
||||
? `${route.tier} / ${route.anonymous ? "anonymous" : route.key_id || "key"}`
|
||||
: "未路由";
|
||||
renderFacts($("#play-facts"), [
|
||||
["HTTP 状态", result.http_status, result.ok ? "ok" : "bad"],
|
||||
["耗时", `${result.duration_ms} ms`],
|
||||
["Request ID", result.request_id || "—"],
|
||||
["测试模式", selected ? `指定 ${selected.tier.toUpperCase()} Key` : "自动路由"],
|
||||
["测试 Key", selected ? `${selected.display} · ${selected.id}` : "—"],
|
||||
[
|
||||
"Key 判断",
|
||||
keyTest || "自动路由未单独判定",
|
||||
result.key_test === "usable" ? "ok" : result.key_test ? "bad" : "",
|
||||
],
|
||||
["实际路由", routeLabel],
|
||||
["原生协议", route.native_protocol || "—"],
|
||||
[
|
||||
"匿名判断",
|
||||
`${eligibility.allowed ? "允许" : "拒绝"} · ${eligibility.source || "—"}`,
|
||||
eligibility.allowed ? "ok" : "warn",
|
||||
],
|
||||
]);
|
||||
$("#play-output").textContent = JSON.stringify(result.response, null, 2);
|
||||
}
|
||||
|
||||
async function run(event) {
|
||||
event.preventDefault();
|
||||
let request;
|
||||
try {
|
||||
request = JSON.parse($("#play-request").value);
|
||||
} catch (error) {
|
||||
toast(`请求 JSON 无效:${error.message}`, true);
|
||||
return;
|
||||
}
|
||||
const keyValue = $("#play-key").value;
|
||||
const key =
|
||||
keyValue === "auto"
|
||||
? { mode: "auto" }
|
||||
: { mode: "selected", tier: keyValue.split(":")[0], id: keyValue.split(":").slice(1).join(":") };
|
||||
$("#play-run").disabled = true;
|
||||
$("#play-state").textContent =
|
||||
key.mode === "selected" ? "指定 Key 测试进行中…" : "Gateway 请求进行中…";
|
||||
try {
|
||||
store.set(
|
||||
"lastPlayground",
|
||||
await api("/api/debug/inference", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ protocol: $("#play-protocol").value, key, request }),
|
||||
}),
|
||||
);
|
||||
} catch (error) {
|
||||
toast(error.message, true);
|
||||
$("#play-state").textContent = "诊断入口请求失败";
|
||||
} finally {
|
||||
$("#play-run").disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
function renderRequests() {
|
||||
const host = $("#upstream-requests");
|
||||
host.replaceChildren();
|
||||
(store.get("monitor")?.upstream?.requests || [])
|
||||
.slice(-100)
|
||||
.reverse()
|
||||
.forEach((request) => {
|
||||
const terminal = { stream_error: "流式响应失败", client_canceled: "客户端已取消" };
|
||||
const result = terminal[request.outcome]
|
||||
? `HTTP ${request.status} · ${terminal[request.outcome]}`
|
||||
: request.status || request.outcome;
|
||||
host.append(
|
||||
el("tr", {}, [
|
||||
el("td", { class: "mono", text: timeOnly(request.time) }),
|
||||
el("td", { class: "mono", text: request.request_id }),
|
||||
el("td", { text: request.model }),
|
||||
el("td", { text: request.tier || "—" }),
|
||||
el("td", { text: request.channel }),
|
||||
el("td", { text: request.key_id || "—" }),
|
||||
el("td", { class: "num", text: request.attempts }),
|
||||
el("td", { class: request.success ? "ok" : "bad", text: result }),
|
||||
el("td", { class: "num", text: `${request.duration_ms} ms` }),
|
||||
]),
|
||||
);
|
||||
});
|
||||
if (!host.children.length) emptyRow(host, 9, "尚无请求路由");
|
||||
}
|
||||
|
||||
function renderAttempts() {
|
||||
const host = $("#upstream-attempts");
|
||||
host.replaceChildren();
|
||||
(store.get("monitor")?.upstream?.recent || [])
|
||||
.slice(-100)
|
||||
.reverse()
|
||||
.forEach((attempt) => {
|
||||
host.append(
|
||||
el("tr", {}, [
|
||||
el("td", { class: "mono", text: timeOnly(attempt.time) }),
|
||||
el("td", { class: "mono", text: attempt.request_id }),
|
||||
el("td", { text: attempt.model }),
|
||||
el("td", { text: `${attempt.tier} / ${attempt.channel}` }),
|
||||
el("td", { text: attempt.key_id }),
|
||||
el("td", { text: attempt.proxy_node }),
|
||||
el("td", { class: attempt.success ? "ok" : "bad", text: attempt.status || attempt.outcome }),
|
||||
el("td", { class: "num", text: `${attempt.duration_ms} ms` }),
|
||||
]),
|
||||
);
|
||||
});
|
||||
if (!host.children.length) emptyRow(host, 8, "尚无上游尝试");
|
||||
}
|
||||
|
||||
function renderMetadata() {
|
||||
const monitor = store.get("monitor");
|
||||
const debug = store.get("debug");
|
||||
const metadata = debug?.metadata || monitor?.resources?.metadata || {};
|
||||
renderFacts($("#metadata-facts"), [
|
||||
["就绪", metadata.ready ? "是" : "否", metadata.ready ? "ok" : "warn"],
|
||||
["模型数", formatNumber(metadata.models)],
|
||||
["更新时间", metadata.updated_at ? new Date(metadata.updated_at).toLocaleString("zh-CN", { hour12: false }) : "尚未更新"],
|
||||
["是否过期", metadata.stale ? "是" : "否", metadata.stale ? "warn" : "ok"],
|
||||
["下次刷新", metadata.next_refresh ? new Date(metadata.next_refresh).toLocaleString("zh-CN", { hour12: false }) : "—"],
|
||||
["最近错误", metadata.last_error || "无", metadata.last_error ? "bad" : "ok"],
|
||||
]);
|
||||
}
|
||||
|
||||
function renderRouteModels() {
|
||||
const debug = store.get("debug");
|
||||
const host = $("#diagnostic-models");
|
||||
if (!host || !debug) return;
|
||||
const query = $("#diagnostic-model-search").value.trim().toLowerCase();
|
||||
host.replaceChildren();
|
||||
(debug.models || [])
|
||||
.filter((item) => !query || item.model.toLowerCase().includes(query))
|
||||
.forEach((item) => {
|
||||
const eligibility = item.anonymous_eligibility || {};
|
||||
const plan = [...(item.anonymous ? ["anonymous"] : []), ...(item.key_tiers || [])];
|
||||
host.append(
|
||||
el("tr", {}, [
|
||||
el("td", { class: "mono", text: item.model }),
|
||||
el("td", { text: `${item.native_protocol} · ${item.protocol_source}` }),
|
||||
el("td", {
|
||||
class: item.route_error ? "bad" : "",
|
||||
text: item.route_error || (plan.length ? plan.join(" → ") : "—"),
|
||||
}),
|
||||
el("td", { class: eligibility.allowed ? "ok" : "warn", text: eligibility.allowed ? "允许" : "拒绝" }),
|
||||
el("td", { text: eligibility.source || "—" }),
|
||||
el("td", {
|
||||
class: "num",
|
||||
text: `${eligibility.input_cost == null ? "?" : eligibility.input_cost} / ${
|
||||
eligibility.output_cost == null ? "?" : eligibility.output_cost
|
||||
}`,
|
||||
}),
|
||||
]),
|
||||
);
|
||||
});
|
||||
if (!host.children.length) emptyRow(host, 6, "没有匹配模型");
|
||||
}
|
||||
|
||||
let activeTab = "playground";
|
||||
|
||||
function renderLedger() {
|
||||
renderRequests();
|
||||
renderAttempts();
|
||||
}
|
||||
|
||||
function renderRoute() {
|
||||
renderMetadata();
|
||||
renderRouteModels();
|
||||
}
|
||||
|
||||
export default {
|
||||
id: "diagnostics",
|
||||
title: "诊断",
|
||||
sub: "请求测试、路由资格与运行流水。",
|
||||
init() {
|
||||
bindTabs($("#page-diagnostics"), (id) => {
|
||||
activeTab = id;
|
||||
logstream.setVisible(id === "logs");
|
||||
if (id === "playground") {
|
||||
if (!store.get("debug")) loadDebugModels();
|
||||
renderModels();
|
||||
}
|
||||
if (id === "ledger") renderLedger();
|
||||
if (id === "route") renderRoute();
|
||||
});
|
||||
logstream.bind();
|
||||
$("#play-protocol").addEventListener("change", resetTemplate);
|
||||
$("#play-model").addEventListener("change", () => {
|
||||
try {
|
||||
const request = JSON.parse($("#play-request").value);
|
||||
request.model = $("#play-model").value;
|
||||
$("#play-request").value = JSON.stringify(request, null, 2);
|
||||
} catch {
|
||||
resetTemplate();
|
||||
}
|
||||
});
|
||||
$("#play-reset").addEventListener("click", resetTemplate);
|
||||
$("#play-form").addEventListener("submit", run);
|
||||
$("#play-copy").addEventListener("click", () => copyText($("#play-output").textContent, "原始响应已复制"));
|
||||
$("#diagnostic-model-search").addEventListener("input", renderRouteModels);
|
||||
store.on("debug", () => {
|
||||
renderModels();
|
||||
renderRoute();
|
||||
});
|
||||
store.on("monitor", () => {
|
||||
renderLedger();
|
||||
renderMetadata();
|
||||
});
|
||||
store.on("lastPlayground", (value) => {
|
||||
if (value) showResult(value);
|
||||
});
|
||||
},
|
||||
show() {
|
||||
if (!store.get("debug")) loadDebugModels();
|
||||
renderModels();
|
||||
renderLedger();
|
||||
renderRoute();
|
||||
if (activeTab === "logs") logstream.setVisible(true);
|
||||
},
|
||||
hide() {
|
||||
logstream.setVisible(false);
|
||||
},
|
||||
refresh() {
|
||||
if (activeTab === "logs") logstream.render();
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,226 @@
|
||||
// Page: 模型与额度 — Go quota windows and free model availability.
|
||||
import { api, hasSession } from "../api.js";
|
||||
import { loadDebugModels } from "../data.js";
|
||||
import { $, bindTabs, copyText, el, emptyRow, localTime } from "../ui.js";
|
||||
|
||||
const windows = [
|
||||
["rolling", "5 小时窗口"],
|
||||
["weekly", "每周窗口"],
|
||||
["monthly", "每月窗口"],
|
||||
];
|
||||
|
||||
let data = null;
|
||||
let timer = null;
|
||||
let loading = false;
|
||||
let activeTab = "quota";
|
||||
|
||||
async function load() {
|
||||
if (loading) return;
|
||||
loading = true;
|
||||
$("#quota-refresh").disabled = true;
|
||||
$("#quota-refresh").textContent = "读取中…";
|
||||
try {
|
||||
const value = await api("/api/model-quotas");
|
||||
if (!hasSession()) return;
|
||||
data = value;
|
||||
const select = $("#quota-account");
|
||||
const selected = select.value;
|
||||
select.replaceChildren();
|
||||
for (const account of value.accounts || []) {
|
||||
select.append(el("option", { value: account.id, text: `Go Key ${account.display}` }));
|
||||
}
|
||||
if ([...select.options].some((option) => option.value === selected)) select.value = selected;
|
||||
if (!select.options.length) select.append(el("option", { value: "", text: "尚未配置 Go Key" }));
|
||||
render();
|
||||
} catch (error) {
|
||||
$("#quota-status").textContent = `查询失败:${error.message}。已有显示仅为上次查询结果。`;
|
||||
} finally {
|
||||
loading = false;
|
||||
$("#quota-refresh").disabled = false;
|
||||
$("#quota-refresh").textContent = "刷新额度";
|
||||
}
|
||||
}
|
||||
|
||||
function render() {
|
||||
if (!data) return;
|
||||
const account = (data.accounts || []).find((item) => item.id === $("#quota-account").value);
|
||||
const stale = account?.status === "stale";
|
||||
const cards = $("#quota-cards");
|
||||
cards.replaceChildren();
|
||||
$("#quota-status").textContent = !account
|
||||
? "请先在配置中心添加 OpenCode Go Key。"
|
||||
: account.error
|
||||
? `${account.error}${stale ? ";下方显示上次成功数据,当前额度未知。" : ";当前额度未知。"}`
|
||||
: "已连接 OpenCode · 共享套餐额度。多个 Key 的额度不相加。";
|
||||
$("#quota-updated").textContent = account?.fetched_at
|
||||
? `${stale ? "上次成功查询" : "额度更新时间"}:${localTime(account.fetched_at)} · 缓存 60 秒 · 来源:OpenCode Go /v1/usage`
|
||||
: "";
|
||||
for (const [id, label] of windows) {
|
||||
const item = account?.windows?.[id];
|
||||
const progress = el("progress", { max: 100, "aria-label": `${label}剩余额度` });
|
||||
progress.value = item ? item.remaining_percent : 0;
|
||||
cards.append(
|
||||
el("div", { class: `quota-card${item?.remaining_percent < 20 ? " quota-low" : ""}` }, [
|
||||
el("h3", { text: label }),
|
||||
el("div", { class: "quota-value", text: item ? `≈ ${item.remaining_percent}%` : "未知" }),
|
||||
progress,
|
||||
el("div", {
|
||||
class: "quota-reset",
|
||||
text: item
|
||||
? `${stale ? "历史剩余" : "剩余"} · ${item.status === "rate-limited" ? "已限额 · " : ""}重置于 ${localTime(item.resets_at)}`
|
||||
: "等待上游额度数据",
|
||||
}),
|
||||
]),
|
||||
);
|
||||
}
|
||||
const query = $("#quota-model-search").value.trim().toLowerCase();
|
||||
const allModels = data.models || [];
|
||||
const models = allModels.filter((model) => model.id.toLowerCase().includes(query));
|
||||
$("#quota-model-count").textContent = `${models.length} / ${allModels.length}`;
|
||||
const catalog = data.catalog;
|
||||
const catalogUpdated =
|
||||
catalog?.updated_at && !catalog.updated_at.startsWith("0001-")
|
||||
? localTime(catalog.updated_at)
|
||||
: "尚未就绪";
|
||||
$("#quota-catalog-status").textContent = `${catalog?.stale ? "模型目录暂未更新,显示缓存 · " : ""}目录更新时间:${catalogUpdated}`;
|
||||
const host = $("#quota-models");
|
||||
host.replaceChildren();
|
||||
for (const model of models) {
|
||||
const copy = el("button", { class: "btn btn-sm btn-ghost", text: "复制名称" });
|
||||
copy.addEventListener("click", () => copyText(model.id));
|
||||
const row = el("tr", {}, [
|
||||
el("td", { class: "mono", text: model.id }),
|
||||
el("td", {
|
||||
text:
|
||||
{ chat: "Chat Completions", responses: "Responses", anthropic: "Messages" }[model.protocol] ||
|
||||
model.protocol,
|
||||
}),
|
||||
]);
|
||||
for (const [id] of windows) {
|
||||
const item = account?.windows?.[id];
|
||||
row.append(
|
||||
el("td", {
|
||||
class: "num",
|
||||
text: item ? `≈ ${item.remaining_percent}%${stale ? "(历史)" : ""}` : "未知",
|
||||
}),
|
||||
);
|
||||
}
|
||||
row.append(el("td", {}, [copy]));
|
||||
host.append(row);
|
||||
}
|
||||
if (!models.length)
|
||||
emptyRow(host, 6, allModels.length ? "没有匹配的模型" : "模型目录尚未就绪,请稍后刷新");
|
||||
}
|
||||
|
||||
const date = (value) => (value && !value.startsWith("0001-") ? localTime(value) : "待探测");
|
||||
|
||||
async function loadAvailability() {
|
||||
try {
|
||||
const value = await api("/api/models/availability");
|
||||
$("#availability-error").textContent = "";
|
||||
const host = $("#availability-models");
|
||||
host.replaceChildren();
|
||||
for (const item of value.models) {
|
||||
const restore = el("button", {
|
||||
type: "button",
|
||||
class: "btn btn-sm btn-ghost",
|
||||
text: "恢复启用",
|
||||
disabled: !item.disabled,
|
||||
});
|
||||
const toggle = el("button", {
|
||||
type: "button",
|
||||
class: "btn btn-sm btn-ghost",
|
||||
text: item.manual ? "切回自动" : "切为手动",
|
||||
});
|
||||
const run = async (path, body) => {
|
||||
restore.disabled = true;
|
||||
toggle.disabled = true;
|
||||
try {
|
||||
await api(path, { method: "POST", body: JSON.stringify(body) });
|
||||
await loadAvailability();
|
||||
await loadDebugModels();
|
||||
} catch (error) {
|
||||
$("#availability-error").textContent = error.message;
|
||||
restore.disabled = !item.disabled;
|
||||
toggle.disabled = false;
|
||||
}
|
||||
};
|
||||
restore.addEventListener("click", () => run("/api/models/restore", { model: item.model }));
|
||||
toggle.addEventListener("click", () =>
|
||||
run("/api/models/manual", { model: item.model, manual: !item.manual }),
|
||||
);
|
||||
host.append(
|
||||
el("tr", {}, [
|
||||
el("td", { class: "mono", text: item.model }),
|
||||
el("td", { class: item.disabled ? "warn" : "ok", text: item.disabled ? "已禁用" : "已启用" }),
|
||||
el("td", { text: [item.channel, item.reason].filter(Boolean).join(" / ") || "待探测" }),
|
||||
el("td", { text: item.manual ? "手动" : "自动" }),
|
||||
el("td", {
|
||||
text: item.auto_effort?.effort
|
||||
? `${item.auto_effort.effort}(${date(item.effort_checked_at)})`
|
||||
: "未验证",
|
||||
}),
|
||||
el("td", { class: "mono", text: date(item.checked_at) }),
|
||||
el("td", {
|
||||
class: "mono",
|
||||
text: item.manual ? "手动控制,不自动探测" : date(item.next_check),
|
||||
}),
|
||||
el("td", {}, [el("div", { class: "key-actions" }, [restore, toggle])]),
|
||||
]),
|
||||
);
|
||||
}
|
||||
if (!value.models.length)
|
||||
$("#availability-error").textContent = "当前模型目录中没有符合免费资格的模型。";
|
||||
} catch (error) {
|
||||
$("#availability-error").textContent = error.message;
|
||||
}
|
||||
}
|
||||
|
||||
function startPolling() {
|
||||
clearInterval(timer);
|
||||
timer = setInterval(() => {
|
||||
if (!document.hidden) load();
|
||||
}, 60000);
|
||||
}
|
||||
|
||||
function stopPolling() {
|
||||
clearInterval(timer);
|
||||
timer = null;
|
||||
}
|
||||
|
||||
export default {
|
||||
id: "model-quotas",
|
||||
title: "模型与额度",
|
||||
sub: "共享套餐额度与免费模型探测状态。",
|
||||
init() {
|
||||
bindTabs($("#page-model-quotas"), (id) => {
|
||||
activeTab = id;
|
||||
if (id === "quota") {
|
||||
load();
|
||||
startPolling();
|
||||
} else {
|
||||
stopPolling();
|
||||
loadAvailability();
|
||||
}
|
||||
});
|
||||
$("#quota-refresh").addEventListener("click", load);
|
||||
$("#quota-account").addEventListener("change", render);
|
||||
$("#quota-model-search").addEventListener("input", render);
|
||||
$("#availability-refresh").addEventListener("click", loadAvailability);
|
||||
},
|
||||
show() {
|
||||
if (activeTab === "quota") {
|
||||
load();
|
||||
startPolling();
|
||||
} else {
|
||||
loadAvailability();
|
||||
}
|
||||
},
|
||||
hide() {
|
||||
stopPolling();
|
||||
},
|
||||
refresh() {
|
||||
if (activeTab === "quota") load();
|
||||
else loadAvailability();
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,207 @@
|
||||
// Page: 概览 — readiness checklist, metrics, resources and token usage.
|
||||
import * as store from "../store.js";
|
||||
import { $, bindTabs, el, emptyRow, formatNumber, timeOnly } from "../ui.js";
|
||||
|
||||
function renderChecklist() {
|
||||
const config = store.get("config");
|
||||
const monitor = store.get("monitor");
|
||||
if (!config || !monitor) return;
|
||||
const resources = monitor.resources;
|
||||
const models = resources.models || {};
|
||||
const modelDescription = models.stale
|
||||
? "目录来自" + (models.cache_source || "磁盘") + "快取,等待后台刷新。"
|
||||
: "上游目录已完成首次刷新且有可暴露模型。";
|
||||
const checks = [
|
||||
["配置本地 Key", "客户端使用 Server Key 访问 Gateway。", (config.server_keys || []).length > 0],
|
||||
[
|
||||
"选择上游通道",
|
||||
"至少有 Zen / Go Key,或启用匿名通道。",
|
||||
(config.zen_keys || []).length + (config.go_keys || []).length > 0 || config.anonymous,
|
||||
],
|
||||
["检查 Proxy", "至少一个代理节点健康。", (resources.proxies || []).some((proxy) => proxy.healthy)],
|
||||
["等待模型目录", modelDescription, models.exposed > 0 && !!models.updated_at],
|
||||
];
|
||||
const card = $("#overview-checklist");
|
||||
const ready = checks.every(([, , done]) => done);
|
||||
card.classList.toggle("hidden", ready);
|
||||
if (ready) return;
|
||||
const host = $("#guide-steps");
|
||||
host.replaceChildren();
|
||||
checks.forEach(([title, description, done]) => {
|
||||
host.append(
|
||||
el("article", { class: "guide-step" }, [
|
||||
el("h3", { text: title }),
|
||||
el("p", { text: description }),
|
||||
el("div", { class: `step-state ${done ? "ok" : "warn"}`, text: done ? "✓ 已就绪" : "○ 待处理" }),
|
||||
]),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function renderResources(resources) {
|
||||
const proxies = $("#proxy-table");
|
||||
proxies.replaceChildren();
|
||||
(resources.proxies || []).forEach((proxy) => {
|
||||
proxies.append(
|
||||
el("tr", {}, [
|
||||
el("td", { text: proxy.address }),
|
||||
el("td", {
|
||||
class: `status ${proxy.healthy ? "ok" : "bad"}`,
|
||||
text: proxy.healthy ? "正常" : "不可用",
|
||||
}),
|
||||
el("td", {
|
||||
text: `Z ${proxy.zen_keys} · G ${proxy.go_keys} · A ${proxy.anonymous ? "开" : "关"}`,
|
||||
}),
|
||||
]),
|
||||
);
|
||||
});
|
||||
if (!proxies.children.length) emptyRow(proxies, 3);
|
||||
const keys = $("#key-table");
|
||||
keys.replaceChildren();
|
||||
if (resources.anonymous) {
|
||||
keys.append(
|
||||
el("tr", {}, [
|
||||
el("td", { text: "anonymous" }),
|
||||
el("td", { text: "zen" }),
|
||||
el("td", { class: "status ok", text: "已启用" }),
|
||||
]),
|
||||
);
|
||||
}
|
||||
(resources.keys || []).forEach((key) => {
|
||||
keys.append(
|
||||
el("tr", {}, [
|
||||
el("td", { text: key.id }),
|
||||
el("td", { text: key.tier }),
|
||||
el("td", {
|
||||
class: `status ${key.cooldown_until ? "warn" : "ok"}`,
|
||||
text: key.cooldown_until ? "冷却中" : "可用",
|
||||
}),
|
||||
]),
|
||||
);
|
||||
});
|
||||
if (!keys.children.length) emptyRow(keys, 3);
|
||||
}
|
||||
|
||||
function renderBreakdowns(metrics) {
|
||||
const host = $("#breakdowns");
|
||||
host.replaceChildren();
|
||||
[
|
||||
["端点", metrics.endpoints],
|
||||
["状态码", metrics.statuses],
|
||||
["模型", metrics.models],
|
||||
["Tier", metrics.tiers],
|
||||
].forEach(([title, data]) => {
|
||||
const body = el("tbody");
|
||||
Object.entries(data || {})
|
||||
.sort((a, b) => b[1] - a[1])
|
||||
.slice(0, 10)
|
||||
.forEach(([key, value]) => {
|
||||
body.append(el("tr", {}, [el("td", { text: key }), el("td", { class: "num", text: value })]));
|
||||
});
|
||||
if (!body.children.length) emptyRow(body, 2, "暂无请求");
|
||||
host.append(
|
||||
el("div", { class: "breakdown" }, [
|
||||
el("h3", { text: title }),
|
||||
el("div", { class: "table-wrap" }, [el("table", { class: "table" }, [body])]),
|
||||
]),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function renderSummary(monitor) {
|
||||
const metrics = monitor.metrics;
|
||||
$("#m-total").textContent = formatNumber(metrics.last_hour.total);
|
||||
$("#m-rate").textContent = `${((metrics.last_hour.success_rate || 0) * 100).toFixed(1)}%`;
|
||||
$("#m-p95").textContent = `${metrics.last_hour.p95_ms || 0} ms`;
|
||||
$("#m-active").textContent = `${metrics.active_requests || 0} / ${metrics.active_streams || 0}`;
|
||||
renderResources(monitor.resources);
|
||||
renderBreakdowns(metrics);
|
||||
}
|
||||
|
||||
function renderTrend(metrics) {
|
||||
const trend = $("#usage-trend");
|
||||
const series = metrics?.series || [];
|
||||
const maximum = Math.max(1, ...series.map((point) => point.total_tokens || 0));
|
||||
trend.replaceChildren();
|
||||
series.forEach((point) => {
|
||||
const bar = el("div", { class: "trend-bar" });
|
||||
bar.style.height = `${Math.max(2, Math.round(((point.total_tokens || 0) / maximum) * 100))}%`;
|
||||
bar.title = `${timeOnly(point.minute)} · input ${formatNumber(point.input_tokens)} · output ${formatNumber(point.output_tokens)} · total ${formatNumber(point.total_tokens)}`;
|
||||
trend.append(bar);
|
||||
});
|
||||
$("#usage-trend-meta").textContent = series.length
|
||||
? `峰值 ${formatNumber(maximum)} tokens / 分钟 · 近 ${series.length} 分钟`
|
||||
: "尚无趋势数据";
|
||||
}
|
||||
|
||||
function renderUsageModels(usage) {
|
||||
const host = $("#usage-models");
|
||||
host.replaceChildren();
|
||||
Object.entries(usage.models || {})
|
||||
.sort((a, b) => (b[1].total_tokens || 0) - (a[1].total_tokens || 0))
|
||||
.slice(0, 15)
|
||||
.forEach(([model, value]) => {
|
||||
host.append(
|
||||
el("tr", {}, [
|
||||
el("td", { class: "mono", text: model }),
|
||||
el("td", { class: "num", text: formatNumber(value.input_tokens) }),
|
||||
el("td", { class: "num", text: formatNumber(value.output_tokens) }),
|
||||
el("td", { class: "num", text: formatNumber(value.total_tokens) }),
|
||||
]),
|
||||
);
|
||||
});
|
||||
if (!host.children.length) emptyRow(host, 4, "尚无 Token 用量");
|
||||
}
|
||||
|
||||
function renderTiers(usage) {
|
||||
const host = $("#usage-tiers");
|
||||
const entries = Object.entries(usage.tiers || {}).sort(
|
||||
(a, b) => (b[1].total_tokens || 0) - (a[1].total_tokens || 0),
|
||||
);
|
||||
const total = Math.max(1, ...entries.map(([, value]) => value.total_tokens || 0));
|
||||
host.replaceChildren();
|
||||
entries.forEach(([tier, value]) => {
|
||||
const fill = el("div", { class: "tier-fill" });
|
||||
fill.style.width = `${Math.round(((value.total_tokens || 0) / total) * 100)}%`;
|
||||
host.append(
|
||||
el("div", { class: "tier-row" }, [
|
||||
el("strong", { text: tier }),
|
||||
el("div", { class: "tier-track" }, [fill]),
|
||||
el("span", { class: "tier-value", text: formatNumber(value.total_tokens) }),
|
||||
]),
|
||||
);
|
||||
});
|
||||
if (!entries.length) host.append(el("div", { class: "empty", text: "尚无 Tier 用量" }));
|
||||
}
|
||||
|
||||
function renderUsage(monitor) {
|
||||
const usage = monitor.usage?.last_hour || {};
|
||||
const tokens = usage.tokens || {};
|
||||
$("#u-coverage").textContent = `${((usage.coverage || 0) * 100).toFixed(1)}%`;
|
||||
$("#u-total").textContent = formatNumber(tokens.total_tokens);
|
||||
$("#u-cached").textContent = formatNumber(tokens.cached_tokens);
|
||||
$("#u-reasoning").textContent = formatNumber(tokens.reasoning_tokens);
|
||||
renderTrend(monitor.metrics);
|
||||
renderUsageModels(usage);
|
||||
renderTiers(usage);
|
||||
}
|
||||
|
||||
function render() {
|
||||
renderChecklist();
|
||||
const monitor = store.get("monitor");
|
||||
if (!monitor) return;
|
||||
renderSummary(monitor);
|
||||
renderUsage(monitor);
|
||||
}
|
||||
|
||||
export default {
|
||||
id: "overview",
|
||||
title: "概览",
|
||||
sub: "运行指标、Token 用量与资源状态。",
|
||||
init() {
|
||||
bindTabs($("#page-overview"));
|
||||
store.on("monitor", render);
|
||||
store.on("config", renderChecklist);
|
||||
},
|
||||
show: render,
|
||||
};
|
||||
@@ -0,0 +1,224 @@
|
||||
// Page: 模型轮转 — sota/sweet alias groups, ordering, manual switch and attempts.
|
||||
import { api, hasSession } from "../api.js";
|
||||
import { $, el, emptyRow, localTime, toast } from "../ui.js";
|
||||
|
||||
const reasons = {
|
||||
success: "成功",
|
||||
client_canceled: "调用方取消",
|
||||
quota_or_rate_limit: "额度不足 / 限流",
|
||||
transport_error: "连接错误",
|
||||
first_output_timeout: "首个输出超时",
|
||||
stream_error: "输出中断",
|
||||
response_read_error: "读取响应失败",
|
||||
response_conversion_error: "响应解析或转换失败",
|
||||
request_conversion_error: "请求转换失败",
|
||||
upstream_error: "上游错误",
|
||||
};
|
||||
|
||||
let data = null;
|
||||
let dirty = false;
|
||||
|
||||
// The persisted rotation state serializes nil maps and slices as JSON null;
|
||||
// normalize them before anything renders against them.
|
||||
function normalize(value) {
|
||||
for (const group of value.groups || []) {
|
||||
group.order = group.order || [];
|
||||
group.available = group.available || {};
|
||||
group.paused = group.paused || {};
|
||||
group.switches = group.switches || [];
|
||||
}
|
||||
value.attempts = value.attempts || [];
|
||||
return value;
|
||||
}
|
||||
|
||||
async function load() {
|
||||
try {
|
||||
const value = await api("/api/rotation");
|
||||
if (!hasSession()) return;
|
||||
data = normalize(value);
|
||||
dirty = false;
|
||||
render();
|
||||
} catch (error) {
|
||||
toast(error.message, true);
|
||||
}
|
||||
}
|
||||
|
||||
function renderGroup(group) {
|
||||
const aliasInput = el("input", {
|
||||
id: `rotation-alias-${group.id}`,
|
||||
value: group.alias,
|
||||
required: true,
|
||||
maxlength: 64,
|
||||
});
|
||||
aliasInput.addEventListener("input", () => {
|
||||
group.alias = aliasInput.value;
|
||||
dirty = true;
|
||||
});
|
||||
const table = el("table", { class: "table" }, [
|
||||
el("thead", {}, [
|
||||
el("tr", {}, ["顺序", "模型", "状态 / 恢复时间", "操作"].map((text) => el("th", { text }))),
|
||||
]),
|
||||
]);
|
||||
const body = el("tbody");
|
||||
table.append(body);
|
||||
group.order.forEach((model, index) => {
|
||||
const row = el("tr", {}, [
|
||||
el("td", { class: "num", text: String(index + 1) }),
|
||||
el("td", { class: "mono", text: model }),
|
||||
]);
|
||||
const until = group.paused[model];
|
||||
const paused = until && new Date(until) > new Date();
|
||||
row.append(
|
||||
el("td", {
|
||||
text: !group.available[model]
|
||||
? "已下架 / 暂不可用"
|
||||
: paused
|
||||
? `暂停至 ${localTime(until)}`
|
||||
: model === group.current
|
||||
? "当前使用"
|
||||
: "可用",
|
||||
}),
|
||||
);
|
||||
const actions = el("div", { class: "rotation-actions" });
|
||||
for (const [text, delta] of [
|
||||
["上移", -1],
|
||||
["下移", 1],
|
||||
]) {
|
||||
const button = el("button", {
|
||||
type: "button",
|
||||
class: "btn btn-sm btn-ghost",
|
||||
text,
|
||||
"aria-label": `${model} ${text}`,
|
||||
disabled: index + delta < 0 || index + delta >= group.order.length,
|
||||
});
|
||||
button.addEventListener("click", () => {
|
||||
[group.order[index], group.order[index + delta]] = [
|
||||
group.order[index + delta],
|
||||
group.order[index],
|
||||
];
|
||||
data.first_output_seconds = Number($("#rotation-timeout").value);
|
||||
dirty = true;
|
||||
render();
|
||||
});
|
||||
actions.append(button);
|
||||
}
|
||||
const select = el("button", {
|
||||
type: "button",
|
||||
class: "btn btn-sm btn-ghost",
|
||||
text: "设为当前",
|
||||
"aria-label": `使用 ${model}`,
|
||||
disabled: !group.available[model],
|
||||
});
|
||||
select.addEventListener("click", async () => {
|
||||
select.disabled = true;
|
||||
try {
|
||||
const result = normalize(
|
||||
await api("/api/rotation/current", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ group: group.id, model }),
|
||||
}),
|
||||
);
|
||||
// Keep unsaved alias/order edits while refreshing operational state.
|
||||
for (const item of data.groups) {
|
||||
const live = result.groups.find((entry) => entry.id === item.id);
|
||||
Object.assign(item, { current: live.current, paused: live.paused, switches: live.switches });
|
||||
}
|
||||
data.persistence_error = result.persistence_error;
|
||||
render();
|
||||
toast("当前模型已切换");
|
||||
} catch (error) {
|
||||
select.disabled = false;
|
||||
toast(error.message, true);
|
||||
}
|
||||
});
|
||||
actions.append(select);
|
||||
row.append(el("td", {}, [actions]));
|
||||
body.append(row);
|
||||
});
|
||||
if (!group.order.length) emptyRow(body, 4, "等待 Go 模型目录");
|
||||
const recent = el("div", { class: "rotation-switches" }, [el("h3", { text: "最近切换" })]);
|
||||
for (const item of (group.switches || []).slice(-5).reverse()) {
|
||||
recent.append(
|
||||
el("p", {
|
||||
text: `${localTime(item.time)} · ${item.from} → ${item.to} · ${reasons[item.reason] || item.reason}`,
|
||||
}),
|
||||
);
|
||||
}
|
||||
if (!group.switches?.length) recent.append(el("p", { text: "尚无切换记录" }));
|
||||
return el("section", { class: "section rotation-group" }, [
|
||||
el("h2", { class: "section-title", text: group.id === "sota" ? "SOTA" : "甜点" }),
|
||||
el("div", { class: "field" }, [
|
||||
el("label", { for: `rotation-alias-${group.id}`, text: "调用别名" }),
|
||||
aliasInput,
|
||||
]),
|
||||
el("p", {
|
||||
class: "rotation-current",
|
||||
text: `当前模型:${group.current || "等待可用模型"}`,
|
||||
}),
|
||||
el("div", { class: "table-wrap" }, [table]),
|
||||
recent,
|
||||
]);
|
||||
}
|
||||
|
||||
function render() {
|
||||
$("#rotation-status").textContent =
|
||||
data.persistence_error || "状态已更新 · 两组独立轮转,所有调用方共享当前位置。";
|
||||
$("#rotation-timeout").value = data.first_output_seconds;
|
||||
const host = $("#rotation-groups");
|
||||
host.replaceChildren();
|
||||
for (const group of data.groups) host.append(renderGroup(group));
|
||||
const attempts = $("#rotation-attempts");
|
||||
attempts.replaceChildren();
|
||||
for (const item of (data.attempts || []).slice().reverse()) {
|
||||
attempts.append(
|
||||
el("tr", {}, [
|
||||
el("td", { class: "mono", text: localTime(item.time) }),
|
||||
el("td", { class: "mono", text: item.request }),
|
||||
el("td", { text: item.alias }),
|
||||
el("td", { class: "mono", text: item.model }),
|
||||
el("td", { class: "num", text: String(item.number) }),
|
||||
el("td", { text: reasons[item.outcome] || item.outcome }),
|
||||
]),
|
||||
);
|
||||
}
|
||||
if (!data.attempts?.length) emptyRow(attempts, 6, "调用分组别名后显示最近 100 次尝试");
|
||||
}
|
||||
|
||||
async function save(event) {
|
||||
event.preventDefault();
|
||||
if (!data) return;
|
||||
const button = $("#rotation-save");
|
||||
button.disabled = true;
|
||||
try {
|
||||
const body = { first_output_seconds: Number($("#rotation-timeout").value) };
|
||||
for (const group of data.groups) body[group.id] = { alias: group.alias.trim(), order: group.order };
|
||||
data = normalize(await api("/api/rotation", { method: "PUT", body: JSON.stringify(body) }));
|
||||
dirty = false;
|
||||
render();
|
||||
toast("模型轮转配置已保存并生效");
|
||||
} catch (error) {
|
||||
toast(error.message, true);
|
||||
} finally {
|
||||
button.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
id: "rotation",
|
||||
title: "模型轮转",
|
||||
sub: "共享当前模型、故障切换与尝试记录。",
|
||||
init() {
|
||||
$("#rotation-refresh").addEventListener("click", () => {
|
||||
if (dirty) {
|
||||
toast("有未保存的修改,请先保存后刷新", true);
|
||||
return;
|
||||
}
|
||||
load();
|
||||
});
|
||||
$("#rotation-timeout").addEventListener("input", () => {
|
||||
dirty = true;
|
||||
});
|
||||
$("#rotation-form").addEventListener("submit", save);
|
||||
},
|
||||
show: load,
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
// Shared console state with a minimal change subscription so page modules
|
||||
// re-render independently.
|
||||
const state = {
|
||||
config: null,
|
||||
monitor: null,
|
||||
debug: null,
|
||||
lastPlayground: null,
|
||||
};
|
||||
|
||||
const listeners = new Map();
|
||||
|
||||
export function get(key) {
|
||||
return state[key];
|
||||
}
|
||||
|
||||
export function set(key, value) {
|
||||
state[key] = value;
|
||||
const subscribers = listeners.get(key);
|
||||
if (!subscribers) return;
|
||||
for (const handler of [...subscribers]) handler(value);
|
||||
}
|
||||
|
||||
export function on(key, handler) {
|
||||
let subscribers = listeners.get(key);
|
||||
if (!subscribers) listeners.set(key, (subscribers = new Set()));
|
||||
subscribers.add(handler);
|
||||
return () => subscribers.delete(handler);
|
||||
}
|
||||
+197
@@ -0,0 +1,197 @@
|
||||
// DOM helpers, formatters, clipboard, toast and in-page dialogs.
|
||||
export const $ = (selector, root = document) => root.querySelector(selector);
|
||||
export const $$ = (selector, root = document) => [...root.querySelectorAll(selector)];
|
||||
|
||||
export function el(tag, props = {}, children = []) {
|
||||
const node = document.createElement(tag);
|
||||
for (const [key, value] of Object.entries(props)) {
|
||||
if (value == null || value === false) continue;
|
||||
if (key === "class") node.className = value;
|
||||
else if (key === "text") node.textContent = value;
|
||||
else if (key === "dataset") Object.assign(node.dataset, value);
|
||||
else if (key.startsWith("on") && typeof value === "function")
|
||||
node.addEventListener(key.slice(2), value);
|
||||
else if (value === true) node.setAttribute(key, "");
|
||||
else node.setAttribute(key, String(value));
|
||||
}
|
||||
for (const child of Array.isArray(children) ? children : [children]) {
|
||||
if (child == null || child === false) continue;
|
||||
node.append(child instanceof Node ? child : document.createTextNode(String(child)));
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
export const formatNumber = (value) => Number(value || 0).toLocaleString();
|
||||
|
||||
export function localTime(value) {
|
||||
return value ? new Date(value).toLocaleString("zh-CN", { hour12: false }) : "—";
|
||||
}
|
||||
|
||||
export function timeOnly(value) {
|
||||
return value ? new Date(value).toLocaleTimeString("zh-CN", { hour12: false }) : "—";
|
||||
}
|
||||
|
||||
let toastTimer = null;
|
||||
|
||||
export function toast(message, bad = false) {
|
||||
const node = $("#toast");
|
||||
node.textContent = message;
|
||||
node.classList.toggle("bad-toast", bad);
|
||||
node.classList.remove("hidden");
|
||||
clearTimeout(toastTimer);
|
||||
toastTimer = setTimeout(() => node.classList.add("hidden"), 3600);
|
||||
}
|
||||
|
||||
export async function copyText(text, okMessage = "已复制") {
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
toast(okMessage);
|
||||
return true;
|
||||
} catch {
|
||||
toast("浏览器不允许剪贴板访问,请手动选中复制", true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function emptyRow(host, columns, message = "暂无数据") {
|
||||
host.append(el("tr", {}, [el("td", { class: "empty", colspan: columns, text: message })]));
|
||||
}
|
||||
|
||||
export function renderFacts(host, entries) {
|
||||
host.replaceChildren();
|
||||
for (const [label, value, tone] of entries) {
|
||||
host.append(
|
||||
el("div", { class: "fact" }, [
|
||||
el("div", { class: "fact-label", text: label }),
|
||||
el("div", { class: `fact-value ${tone || ""}`.trim(), text: value ?? "—" }),
|
||||
]),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Generic dialog host; onClose fires on every close path so promise-based
|
||||
// dialogs settle exactly once.
|
||||
export function openDialog({ title, body = null, size = "", actions = [], onClose }) {
|
||||
const previous = document.activeElement;
|
||||
const titleId = `dialog-title-${Math.random().toString(36).slice(2, 8)}`;
|
||||
const overlay = el("div", { class: "dialog-overlay" });
|
||||
const dialog = el("div", {
|
||||
class: `dialog ${size}`.trim(),
|
||||
role: "dialog",
|
||||
"aria-modal": "true",
|
||||
"aria-labelledby": titleId,
|
||||
});
|
||||
dialog.append(el("h2", { id: titleId, class: "dialog-title", text: title }));
|
||||
if (body) dialog.append(body);
|
||||
let closed = false;
|
||||
const close = () => {
|
||||
if (closed) return;
|
||||
closed = true;
|
||||
overlay.remove();
|
||||
document.removeEventListener("keydown", onKey, true);
|
||||
if (previous instanceof HTMLElement && previous.isConnected) previous.focus();
|
||||
onClose?.();
|
||||
};
|
||||
const onKey = (event) => {
|
||||
if (event.key === "Escape") {
|
||||
event.stopPropagation();
|
||||
close();
|
||||
}
|
||||
};
|
||||
if (actions.length) {
|
||||
const row = el("div", { class: "dialog-actions" });
|
||||
for (const action of actions) {
|
||||
row.append(
|
||||
el("button", {
|
||||
type: "button",
|
||||
class: `btn btn-sm ${action.kind || "btn-ghost"}`,
|
||||
text: action.label,
|
||||
onclick: () => (action.onClick ? action.onClick(close) : close()),
|
||||
}),
|
||||
);
|
||||
}
|
||||
dialog.append(row);
|
||||
}
|
||||
overlay.append(dialog);
|
||||
overlay.addEventListener("mousedown", (event) => {
|
||||
if (event.target === overlay) close();
|
||||
});
|
||||
document.addEventListener("keydown", onKey, true);
|
||||
$("#dialog-host").append(overlay);
|
||||
const target = dialog.querySelector("input, select, textarea") || dialog.querySelector(".dialog-actions .btn");
|
||||
target?.focus();
|
||||
return { close, dialog };
|
||||
}
|
||||
|
||||
export function confirmDialog({ title, message = "", confirmLabel = "确定", danger = false }) {
|
||||
return new Promise((resolve) => {
|
||||
let settled = false;
|
||||
const finish = (value, close) => {
|
||||
if (!settled) {
|
||||
settled = true;
|
||||
resolve(value);
|
||||
}
|
||||
close?.();
|
||||
};
|
||||
openDialog({
|
||||
title,
|
||||
body: message ? el("p", { class: "dialog-text", text: message }) : null,
|
||||
onClose: () => finish(false),
|
||||
actions: [
|
||||
{ label: "取消", onClick: (close) => finish(false, close) },
|
||||
{
|
||||
label: confirmLabel,
|
||||
kind: danger ? "btn-danger" : "btn-primary",
|
||||
onClick: (close) => finish(true, close),
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function promptDialog({ title, label, value = "", placeholder = "", confirmLabel = "确定" }) {
|
||||
return new Promise((resolve) => {
|
||||
let settled = false;
|
||||
const input = el("input", { value, placeholder, maxlength: 80 });
|
||||
const finish = (result, close) => {
|
||||
if (!settled) {
|
||||
settled = true;
|
||||
resolve(result);
|
||||
}
|
||||
close?.();
|
||||
};
|
||||
input.addEventListener("keydown", (event) => {
|
||||
if (event.key === "Enter") {
|
||||
event.preventDefault();
|
||||
finish(input.value, dialog.close);
|
||||
}
|
||||
});
|
||||
const dialog = openDialog({
|
||||
title,
|
||||
body: el("div", { class: "field" }, [el("label", { text: label }), input]),
|
||||
onClose: () => finish(null),
|
||||
actions: [
|
||||
{ label: "取消", onClick: (close) => finish(null, close) },
|
||||
{ label: confirmLabel, kind: "btn-primary", onClick: (close) => finish(input.value, close) },
|
||||
],
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Tab strip wiring: [data-tab] buttons toggle [data-panel] panels and report
|
||||
// the active id.
|
||||
export function bindTabs(page, onSwitch) {
|
||||
const buttons = $$(".tabs .tab", page);
|
||||
const panels = $$("[data-panel]", page);
|
||||
const activate = (id) => {
|
||||
for (const button of buttons) {
|
||||
const active = button.dataset.tab === id;
|
||||
button.classList.toggle("active", active);
|
||||
button.setAttribute("aria-selected", active ? "true" : "false");
|
||||
}
|
||||
for (const panel of panels) panel.classList.toggle("hidden", panel.dataset.panel !== id);
|
||||
onSwitch?.(id);
|
||||
};
|
||||
for (const button of buttons) button.addEventListener("click", () => activate(button.dataset.tab));
|
||||
return { activate };
|
||||
}
|
||||
@@ -1,926 +0,0 @@
|
||||
#diagnostic-model-search {
|
||||
max-width: 260px;
|
||||
}
|
||||
|
||||
#account-form {
|
||||
max-width: 660px;
|
||||
}
|
||||
|
||||
:root {
|
||||
color-scheme: light;
|
||||
--paper: #f2efe5;
|
||||
--paper2: #e8e2d4;
|
||||
--ink: #17231f;
|
||||
--muted: #68716c;
|
||||
--forest: #153c34;
|
||||
--forest2: #204d43;
|
||||
--orange: #ed5a2a;
|
||||
--yellow: #e7b94f;
|
||||
--line: #c9c3b5;
|
||||
--white: #fffdf7;
|
||||
--bad: #b6382f;
|
||||
--ok: #237056;
|
||||
--shadow: 0 12px 35px #17231f16;
|
||||
}
|
||||
.quota-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 18px;
|
||||
margin: 20px 0;
|
||||
}
|
||||
.quota-card {
|
||||
padding: 22px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 8px;
|
||||
background: var(--white);
|
||||
}
|
||||
.quota-card h3 {
|
||||
margin: 0 0 12px;
|
||||
font-size: 14px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.quota-card .quota-value {
|
||||
font-size: 36px;
|
||||
font-weight: 750;
|
||||
letter-spacing: -1px;
|
||||
}
|
||||
.quota-card progress {
|
||||
width: 100%;
|
||||
height: 9px;
|
||||
accent-color: var(--forest);
|
||||
margin: 14px 0 8px;
|
||||
}
|
||||
.quota-card.quota-low progress {
|
||||
accent-color: var(--orange);
|
||||
}
|
||||
.quota-card .quota-reset {
|
||||
font-size: 12px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.quota-status {
|
||||
padding: 10px 14px;
|
||||
background: var(--paper2);
|
||||
border-radius: 6px;
|
||||
}
|
||||
.key-actions {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.key-actions button {
|
||||
padding: 5px 9px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.key-env {
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
padding: 18px;
|
||||
background: var(--forest);
|
||||
color: var(--white);
|
||||
border-radius: 6px;
|
||||
}
|
||||
#quota-model-search {
|
||||
max-width: 250px;
|
||||
}
|
||||
#quota-account {
|
||||
max-width: 360px;
|
||||
}
|
||||
#api-key-created {
|
||||
border-color: var(--ok);
|
||||
}
|
||||
@media (max-width: 760px) {
|
||||
.quota-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
html {
|
||||
scroll-behavior: smooth;
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
background: var(--paper);
|
||||
color: var(--ink);
|
||||
font:
|
||||
14px/1.55 ui-sans-serif,
|
||||
system-ui,
|
||||
-apple-system,
|
||||
"Segoe UI",
|
||||
sans-serif;
|
||||
}
|
||||
button,
|
||||
input,
|
||||
textarea,
|
||||
select {
|
||||
font: inherit;
|
||||
}
|
||||
button {
|
||||
cursor: pointer;
|
||||
}
|
||||
.hidden {
|
||||
display: none !important;
|
||||
}
|
||||
.mono,
|
||||
code,
|
||||
pre,
|
||||
.eyebrow,
|
||||
.nav-no,
|
||||
.metric,
|
||||
.table th,
|
||||
.log {
|
||||
font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
|
||||
}
|
||||
.login {
|
||||
min-height: 100vh;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(280px, 1fr) minmax(360px, 520px);
|
||||
background: var(--forest);
|
||||
}
|
||||
.login-intro {
|
||||
padding: 9vw 7vw;
|
||||
color: #f8f2e4;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
background-image:
|
||||
linear-gradient(#ffffff0d 1px, transparent 1px),
|
||||
linear-gradient(90deg, #ffffff0d 1px, transparent 1px);
|
||||
background-size: 36px 36px;
|
||||
}
|
||||
.manual-mark {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
font-weight: 800;
|
||||
letter-spacing: 0.03em;
|
||||
}
|
||||
.manual-mark i {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 38px;
|
||||
height: 38px;
|
||||
background: var(--orange);
|
||||
color: white;
|
||||
font:
|
||||
normal 900 17px ui-monospace,
|
||||
monospace;
|
||||
}
|
||||
.login-intro h1 {
|
||||
font:
|
||||
500 clamp(42px, 7vw, 84px)/0.95 Georgia,
|
||||
serif;
|
||||
letter-spacing: -0.055em;
|
||||
margin: 60px 0 18px;
|
||||
max-width: 700px;
|
||||
}
|
||||
.login-intro p {
|
||||
max-width: 560px;
|
||||
color: #d4ddd8;
|
||||
font-size: 16px;
|
||||
}
|
||||
.login-panel {
|
||||
background: var(--paper);
|
||||
display: grid;
|
||||
place-items: center;
|
||||
padding: 32px;
|
||||
}
|
||||
.login-card {
|
||||
width: min(390px, 100%);
|
||||
}
|
||||
.login-card h2 {
|
||||
font:
|
||||
500 34px/1.1 Georgia,
|
||||
serif;
|
||||
margin: 10px 0;
|
||||
}
|
||||
.login-card .rule {
|
||||
height: 4px;
|
||||
width: 54px;
|
||||
background: var(--orange);
|
||||
margin: 20px 0 28px;
|
||||
}
|
||||
.layout {
|
||||
display: grid;
|
||||
grid-template-columns: 274px minmax(0, 1fr);
|
||||
min-height: 100vh;
|
||||
}
|
||||
.sidebar {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
height: 100vh;
|
||||
color: #f8f2e4;
|
||||
background: var(--forest);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 24px 18px 20px;
|
||||
border-right: 6px solid var(--orange);
|
||||
overflow-y: auto;
|
||||
}
|
||||
.sidebar-head {
|
||||
padding: 4px 10px 25px;
|
||||
border-bottom: 1px solid #ffffff24;
|
||||
}
|
||||
.sidebar-kicker {
|
||||
font:
|
||||
11px ui-monospace,
|
||||
monospace;
|
||||
color: #9fb7ae;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.18em;
|
||||
}
|
||||
.sidebar-title {
|
||||
font:
|
||||
500 25px Georgia,
|
||||
serif;
|
||||
margin-top: 5px;
|
||||
}
|
||||
.nav {
|
||||
display: grid;
|
||||
margin-top: 18px;
|
||||
gap: 3px;
|
||||
}
|
||||
.nav button {
|
||||
display: grid;
|
||||
grid-template-columns: 30px 1fr;
|
||||
align-items: center;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: #b9cbc4;
|
||||
text-align: left;
|
||||
padding: 10px 11px;
|
||||
border-left: 3px solid transparent;
|
||||
}
|
||||
.nav button:hover,
|
||||
.nav button.active {
|
||||
color: white;
|
||||
background: #ffffff0c;
|
||||
border-left-color: var(--orange);
|
||||
}
|
||||
.nav-no {
|
||||
font-size: 10px;
|
||||
color: #76958a;
|
||||
}
|
||||
.nav button.active .nav-no {
|
||||
color: #ff926e;
|
||||
}
|
||||
.sidebar-foot {
|
||||
margin-top: auto;
|
||||
padding: 18px 10px 0;
|
||||
border-top: 1px solid #ffffff24;
|
||||
color: #9fb7ae;
|
||||
font-size: 12px;
|
||||
}
|
||||
.live-line {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 7px;
|
||||
}
|
||||
.live-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
background: #5dd6a6;
|
||||
border-radius: 50%;
|
||||
box-shadow: 0 0 0 4px #5dd6a619;
|
||||
}
|
||||
.main {
|
||||
min-width: 0;
|
||||
padding: 30px clamp(20px, 4vw, 56px) 72px;
|
||||
}
|
||||
.topbar {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 20px;
|
||||
padding-bottom: 22px;
|
||||
border-bottom: 1px solid var(--line);
|
||||
margin-bottom: 26px;
|
||||
}
|
||||
.eyebrow {
|
||||
font-size: 10px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.19em;
|
||||
color: var(--orange);
|
||||
font-weight: 800;
|
||||
}
|
||||
.topbar h1 {
|
||||
font:
|
||||
500 clamp(30px, 4vw, 48px)/1 Georgia,
|
||||
serif;
|
||||
margin: 7px 0;
|
||||
}
|
||||
.subtitle {
|
||||
color: var(--muted);
|
||||
max-width: 680px;
|
||||
}
|
||||
.toolbar {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
}
|
||||
.primary,
|
||||
.ghost,
|
||||
.danger,
|
||||
.copy {
|
||||
border: 1px solid var(--ink);
|
||||
padding: 9px 14px;
|
||||
font-weight: 750;
|
||||
background: transparent;
|
||||
color: var(--ink);
|
||||
}
|
||||
.primary {
|
||||
background: var(--ink);
|
||||
color: var(--white);
|
||||
}
|
||||
.primary:hover {
|
||||
background: var(--orange);
|
||||
border-color: var(--orange);
|
||||
}
|
||||
.ghost:hover,
|
||||
.copy:hover {
|
||||
background: var(--paper2);
|
||||
}
|
||||
.danger {
|
||||
color: var(--bad);
|
||||
border-color: var(--bad);
|
||||
}
|
||||
.wide {
|
||||
width: 100%;
|
||||
}
|
||||
.notice {
|
||||
border-left: 5px solid var(--yellow);
|
||||
background: #f8eac4;
|
||||
padding: 12px 15px;
|
||||
margin: -8px 0 20px;
|
||||
}
|
||||
.metric-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 1px;
|
||||
background: var(--line);
|
||||
border: 1px solid var(--line);
|
||||
}
|
||||
.metric-card {
|
||||
background: var(--white);
|
||||
padding: 21px;
|
||||
min-height: 132px;
|
||||
}
|
||||
.label {
|
||||
font:
|
||||
700 10px ui-monospace,
|
||||
monospace;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.12em;
|
||||
color: var(--muted);
|
||||
}
|
||||
.metric {
|
||||
font-size: 31px;
|
||||
font-weight: 800;
|
||||
margin-top: 19px;
|
||||
letter-spacing: -0.06em;
|
||||
}
|
||||
.metric-note {
|
||||
color: var(--muted);
|
||||
font-size: 11px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
.section {
|
||||
background: var(--white);
|
||||
border: 1px solid var(--line);
|
||||
padding: 22px;
|
||||
margin-top: 18px;
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
.section-head {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: start;
|
||||
gap: 16px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.section h2,
|
||||
.section h3 {
|
||||
font:
|
||||
600 20px/1.2 Georgia,
|
||||
serif;
|
||||
margin: 0;
|
||||
}
|
||||
.section-caption {
|
||||
color: var(--muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
.split {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 18px;
|
||||
}
|
||||
.table-wrap {
|
||||
overflow: auto;
|
||||
}
|
||||
.table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
.table th,
|
||||
.table td {
|
||||
text-align: left;
|
||||
padding: 10px 8px;
|
||||
border-bottom: 1px solid #ded9cd;
|
||||
vertical-align: top;
|
||||
}
|
||||
.table th {
|
||||
font-size: 9px;
|
||||
letter-spacing: 0.12em;
|
||||
text-transform: uppercase;
|
||||
color: var(--muted);
|
||||
}
|
||||
.table tr:last-child td {
|
||||
border-bottom: 0;
|
||||
}
|
||||
.status {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.status:before {
|
||||
content: "";
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
border-radius: 50%;
|
||||
background: currentColor;
|
||||
}
|
||||
.ok {
|
||||
color: var(--ok);
|
||||
}
|
||||
.bad {
|
||||
color: var(--bad);
|
||||
}
|
||||
.warn {
|
||||
color: #9b6810;
|
||||
}
|
||||
.guide {
|
||||
counter-reset: steps;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 1px;
|
||||
background: var(--line);
|
||||
border: 1px solid var(--line);
|
||||
}
|
||||
.guide-step {
|
||||
counter-increment: steps;
|
||||
background: var(--white);
|
||||
padding: 22px;
|
||||
min-height: 150px;
|
||||
position: relative;
|
||||
}
|
||||
.guide-step:before {
|
||||
content: "0" counter(steps);
|
||||
font:
|
||||
800 11px ui-monospace,
|
||||
monospace;
|
||||
color: var(--orange);
|
||||
letter-spacing: 0.12em;
|
||||
}
|
||||
.guide-step h3 {
|
||||
font:
|
||||
600 18px Georgia,
|
||||
serif;
|
||||
margin: 14px 0 7px;
|
||||
}
|
||||
.guide-step p {
|
||||
color: var(--muted);
|
||||
margin: 0 0 14px;
|
||||
}
|
||||
.step-state {
|
||||
font:
|
||||
700 11px ui-monospace,
|
||||
monospace;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.access-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 220px minmax(0, 1fr);
|
||||
gap: 18px;
|
||||
}
|
||||
.toc {
|
||||
position: sticky;
|
||||
top: 20px;
|
||||
align-self: start;
|
||||
border-top: 4px solid var(--ink);
|
||||
padding-top: 10px;
|
||||
}
|
||||
.toc button {
|
||||
display: block;
|
||||
width: 100%;
|
||||
border: 0;
|
||||
border-bottom: 1px solid var(--line);
|
||||
background: transparent;
|
||||
padding: 9px 4px;
|
||||
text-align: left;
|
||||
color: var(--muted);
|
||||
}
|
||||
.toc button:hover {
|
||||
color: var(--orange);
|
||||
}
|
||||
.code-card {
|
||||
margin: 14px 0;
|
||||
border: 1px solid var(--line);
|
||||
background: #17231f;
|
||||
color: #dce6df;
|
||||
}
|
||||
.code-head {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 8px 12px;
|
||||
border-bottom: 1px solid #ffffff1f;
|
||||
color: #a9bcb4;
|
||||
font:
|
||||
10px ui-monospace,
|
||||
monospace;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.11em;
|
||||
}
|
||||
.code-card pre {
|
||||
margin: 0;
|
||||
padding: 16px;
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
font-size: 12px;
|
||||
color: #edf3ef;
|
||||
}
|
||||
.copy {
|
||||
color: #e8efe9;
|
||||
border-color: #788d84;
|
||||
padding: 5px 9px;
|
||||
font-size: 10px;
|
||||
}
|
||||
.field {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
margin: 13px 0;
|
||||
}
|
||||
.field label {
|
||||
font:
|
||||
700 10px ui-monospace,
|
||||
monospace;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.1em;
|
||||
color: #56635e;
|
||||
}
|
||||
.input,
|
||||
input,
|
||||
textarea,
|
||||
select {
|
||||
width: 100%;
|
||||
border: 1px solid #a9a397;
|
||||
background: #fffef9;
|
||||
color: var(--ink);
|
||||
padding: 10px 11px;
|
||||
border-radius: 0;
|
||||
outline: none;
|
||||
}
|
||||
.input:focus,
|
||||
input:focus,
|
||||
textarea:focus,
|
||||
select:focus {
|
||||
border-color: var(--orange);
|
||||
box-shadow: 0 0 0 2px #ed5a2a20;
|
||||
}
|
||||
textarea {
|
||||
resize: vertical;
|
||||
min-height: 92px;
|
||||
}
|
||||
.check-label {
|
||||
display: flex !important;
|
||||
align-items: center;
|
||||
gap: 9px;
|
||||
text-transform: none !important;
|
||||
letter-spacing: 0 !important;
|
||||
font-family: inherit !important;
|
||||
}
|
||||
.check-label input {
|
||||
width: auto;
|
||||
}
|
||||
.form-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 0 18px;
|
||||
}
|
||||
.full {
|
||||
grid-column: 1/-1;
|
||||
}
|
||||
.chips {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
flex-wrap: wrap;
|
||||
margin: 4px 0 8px;
|
||||
}
|
||||
.chip {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
background: var(--paper2);
|
||||
border: 1px solid var(--line);
|
||||
padding: 5px 7px;
|
||||
font:
|
||||
11px ui-monospace,
|
||||
monospace;
|
||||
}
|
||||
.chip button {
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: var(--bad);
|
||||
font-weight: 900;
|
||||
padding: 0;
|
||||
}
|
||||
.actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 9px;
|
||||
margin-top: 18px;
|
||||
}
|
||||
.filters {
|
||||
display: grid;
|
||||
grid-template-columns: 140px 160px minmax(180px, 1fr) auto;
|
||||
gap: 8px;
|
||||
margin-bottom: 11px;
|
||||
}
|
||||
.logs {
|
||||
height: 62vh;
|
||||
overflow: auto;
|
||||
background: #13201c;
|
||||
color: #d7e2dc;
|
||||
border: 1px solid #13201c;
|
||||
}
|
||||
.log {
|
||||
display: grid;
|
||||
grid-template-columns: 86px 55px 105px minmax(170px, 1fr);
|
||||
gap: 10px;
|
||||
padding: 8px 10px;
|
||||
border-bottom: 1px solid #ffffff12;
|
||||
font-size: 11px;
|
||||
}
|
||||
.log:hover {
|
||||
background: #ffffff08;
|
||||
}
|
||||
.log-time,
|
||||
.log-component,
|
||||
.log-fields {
|
||||
color: #89a097;
|
||||
}
|
||||
.log-fields {
|
||||
grid-column: 4;
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.empty {
|
||||
color: var(--muted);
|
||||
padding: 14px 8px;
|
||||
}
|
||||
.error {
|
||||
color: var(--bad);
|
||||
min-height: 22px;
|
||||
}
|
||||
.modal {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: #17231fcc;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
padding: 20px;
|
||||
z-index: 10;
|
||||
}
|
||||
.modal-card {
|
||||
width: min(720px, 100%);
|
||||
max-height: 82vh;
|
||||
overflow: auto;
|
||||
background: var(--paper);
|
||||
border-top: 7px solid var(--orange);
|
||||
padding: 24px;
|
||||
box-shadow: 0 30px 80px #0007;
|
||||
}
|
||||
.modal-card pre {
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.toast {
|
||||
position: fixed;
|
||||
right: 22px;
|
||||
bottom: 22px;
|
||||
z-index: 20;
|
||||
background: var(--forest);
|
||||
color: white;
|
||||
border-left: 5px solid #5dd6a6;
|
||||
padding: 12px 16px;
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
.toast.bad-toast {
|
||||
border-left-color: #ff7062;
|
||||
}
|
||||
.tiny {
|
||||
font-size: 11px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.trend-chart {
|
||||
height: 230px;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
gap: 3px;
|
||||
padding: 18px 4px 0;
|
||||
border-bottom: 1px solid var(--line);
|
||||
overflow: hidden;
|
||||
}
|
||||
.trend-bar {
|
||||
flex: 1;
|
||||
min-width: 2px;
|
||||
background: var(--forest2);
|
||||
border-top: 3px solid var(--orange);
|
||||
position: relative;
|
||||
}
|
||||
.trend-bar:hover {
|
||||
background: var(--orange);
|
||||
}
|
||||
.tier-row {
|
||||
display: grid;
|
||||
grid-template-columns: 70px minmax(0, 1fr) 90px;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin: 14px 0;
|
||||
}
|
||||
.tier-track {
|
||||
height: 12px;
|
||||
background: var(--paper2);
|
||||
}
|
||||
.tier-fill {
|
||||
height: 100%;
|
||||
background: var(--orange);
|
||||
}
|
||||
.play-grid {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(360px, 0.9fr) minmax(400px, 1.1fr);
|
||||
gap: 18px;
|
||||
}
|
||||
.json-editor {
|
||||
min-height: 430px;
|
||||
background: #17231f;
|
||||
color: #e7efe9;
|
||||
border-color: #17231f;
|
||||
font:
|
||||
12px/1.55 ui-monospace,
|
||||
monospace;
|
||||
}
|
||||
.fact-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 1px;
|
||||
background: var(--line);
|
||||
border: 1px solid var(--line);
|
||||
}
|
||||
.fact {
|
||||
background: var(--white);
|
||||
padding: 12px;
|
||||
}
|
||||
.fact dt {
|
||||
font:
|
||||
700 9px ui-monospace,
|
||||
monospace;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.1em;
|
||||
color: var(--muted);
|
||||
}
|
||||
.fact dd {
|
||||
margin: 5px 0 0;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.pill {
|
||||
display: inline-block;
|
||||
padding: 2px 6px;
|
||||
border: 1px solid currentColor;
|
||||
font:
|
||||
10px ui-monospace,
|
||||
monospace;
|
||||
}
|
||||
.cost {
|
||||
font:
|
||||
11px ui-monospace,
|
||||
monospace;
|
||||
white-space: nowrap;
|
||||
}
|
||||
@media (max-width: 1100px) {
|
||||
.play-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
@media (max-width: 980px) {
|
||||
.layout {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
.sidebar {
|
||||
position: relative;
|
||||
height: auto;
|
||||
border-right: 0;
|
||||
border-bottom: 5px solid var(--orange);
|
||||
padding: 15px;
|
||||
}
|
||||
.sidebar-head {
|
||||
display: flex;
|
||||
align-items: end;
|
||||
justify-content: space-between;
|
||||
padding: 0 5px 12px;
|
||||
}
|
||||
.nav {
|
||||
display: flex;
|
||||
overflow: auto;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.nav button {
|
||||
min-width: max-content;
|
||||
grid-template-columns: 24px 1fr;
|
||||
}
|
||||
.sidebar-foot {
|
||||
display: none;
|
||||
}
|
||||
.main {
|
||||
padding-top: 22px;
|
||||
}
|
||||
.metric-grid {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
.login {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.login-intro {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
@media (max-width: 680px) {
|
||||
.topbar {
|
||||
flex-direction: column;
|
||||
}
|
||||
.metric-grid,
|
||||
.split,
|
||||
.guide,
|
||||
.form-grid,
|
||||
.fact-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.full {
|
||||
grid-column: auto;
|
||||
}
|
||||
.access-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.toc {
|
||||
position: static;
|
||||
}
|
||||
.filters {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
.log {
|
||||
grid-template-columns: 72px 48px minmax(0, 1fr);
|
||||
}
|
||||
.log-component {
|
||||
display: none;
|
||||
}
|
||||
.log-fields {
|
||||
grid-column: 1/-1;
|
||||
}
|
||||
.toolbar {
|
||||
width: 100%;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.play-grid {
|
||||
display: block;
|
||||
}
|
||||
.json-editor {
|
||||
min-height: 320px;
|
||||
}
|
||||
.section-head {
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
|
||||
.rotation-actions {
|
||||
min-width: 215px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.rotation-actions button {
|
||||
margin: 3px;
|
||||
}
|
||||
.rotation-switches {
|
||||
margin-top: 22px;
|
||||
color: var(--muted);
|
||||
font-size: 13px;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
#rotation-groups .field {
|
||||
max-width: 360px;
|
||||
}
|
||||
#rotation-attempts td {
|
||||
max-width: 270px;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
Reference in new issue
Block a user