fix(ui): 修复登录和并发请求并统一页面展示

调整登录流程和请求处理,统一各中心的表格交互、主题样式和页面展示。
This commit is contained in:
zhanjunhao
2026-11-19 18:58:46 +08:00
parent 9b6eb1c7c4
commit 7908ed53a3
128 changed files with 4672 additions and 5391 deletions
+126
View File
@@ -0,0 +1,126 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import { colord, extend } from 'colord';
import a11yPlugin from 'colord/plugins/a11y';
import mixPlugin from 'colord/plugins/mix';
extend([a11yPlugin, mixPlugin]);
export const PROTOTYPE_LIGHT_PRIMARY = '#b96508';
export const PROTOTYPE_DARK_PRIMARY = '#d1963a';
export const PROTOTYPE_DARK_SEED = '#f2ad41';
const clamp = (value, low, high) => Math.min(high, Math.max(low, value));
function toneAtContrast(color, surface, minimum, lighter) {
const { h: hue, s: saturation } = color.toHsl();
const tone = (lightness) => colord({ h: hue, s: saturation, l: lightness });
let low = 0;
let high = 100;
for (let step = 0; step < 12; step++) {
const middle = (low + high) / 2;
if (tone(middle).contrast(surface) >= minimum === lighter) high = middle;
else low = middle;
}
return tone(lighter ? high : low);
}
const readable = (color, surface, dark) =>
color.contrast(surface) >= 4.7
? color
: toneAtContrast(color, surface, 4.7, dark);
export function resolveBrandPalette(configured, dark, surface) {
const prototype = dark ? PROTOTYPE_DARK_PRIMARY : PROTOTYPE_LIGHT_PRIMARY;
const parsed = colord(configured);
const input = parsed.isValid() ? parsed.alpha(1) : colord(prototype);
const isPrototype = input.toHex() === prototype;
const hsl = input.toHsl();
const seed = isPrototype
? input
: colord({ ...hsl, s: Math.min(hsl.s, 68), l: clamp(hsl.l, 28, 70) });
const onSolid = dark ? '#11151c' : '#ffffff';
let normal;
let hover;
let active;
if (dark) {
const base = seed.contrast(onSolid);
const target = clamp(base, 5.3, isPrototype ? 7.2 : 6.45);
const fill = (ratio) => toneAtContrast(seed, onSolid, ratio, true);
normal = base === target ? seed : fill(target);
hover = fill(target + 0.5);
active = fill(target - 0.55);
} else {
normal = readable(seed, onSolid, false);
hover = normal.darken(0.035);
active = normal.darken(0.07);
}
const backdrop = colord(surface);
const tint = backdrop.mix(normal, dark ? 0.14 : 0.085);
const tintHover = backdrop.mix(normal, dark ? 0.2 : 0.135);
const ink = readable(normal, tintHover, dark).toHex();
return {
isPrototype,
onSolid,
normal: normal.toHex(),
hover: hover.toHex(),
active: active.toHex(),
accent: isPrototype ? (dark ? PROTOTYPE_DARK_SEED : prototype) : ink,
selectionBg: isPrototype ? (dark ? '#382b1b' : '#fff3df') : tint.toHex(),
selectionText: isPrototype ? (dark ? PROTOTYPE_DARK_SEED : '#a45a07') : ink,
tint: tint.toHex(),
tintHover: tintHover.toHex(),
};
}
export function resolveGradientLabel(stops, surface) {
const backdrop = colord(surface);
const base = backdrop.toRgb();
const colors = stops.map((stop) => {
const parsed = colord(stop);
return parsed.isValid() ? parsed.toRgb() : base;
});
const composite = (channel, from, to, progress) =>
from[channel] * from.a * (1 - progress) +
to[channel] * to.a * progress +
base[channel] * (1 - from.a * (1 - progress) - to.a * progress);
const samples = colors.flatMap((from, index) => {
const to = colors[index + 1] ?? from;
return [0, 0.25, 0.5, 0.75].map((progress) =>
colord({
r: composite('r', from, to, progress),
g: composite('g', from, to, progress),
b: composite('b', from, to, progress),
}),
);
});
const inks = ['#ffffff', '#11151c'];
const minimum = (ink) =>
Math.min(...samples.map((sample) => sample.contrast(ink)));
const chosen = minimum(inks[0]) >= minimum(inks[1]) ? inks[0] : inks[1];
if (samples.length > 0 && minimum(chosen) >= 4.5) return { color: chosen };
return {
color:
backdrop.contrast(inks[0]) >= backdrop.contrast(inks[1])
? inks[0]
: inks[1],
background: backdrop.toHex(),
};
}