Initial import of weiyuan frontend
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
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 React, { Suspense, lazy, useContext } from 'react';
|
||||
import { StatusContext } from '../../../context/Status';
|
||||
|
||||
/**
|
||||
* 登录/注册页背景动画 —— 主题注册表
|
||||
*
|
||||
* 主题由后端 option「AuthBackgroundTheme」控制,经 /api/status 的
|
||||
* auth_background_theme 字段下发。未配置 / 配置非法时兜底 ocean,
|
||||
* 保证老部署行为不变。每个主题懒加载,未选中的不进首屏 bundle。
|
||||
*/
|
||||
const THEMES = {
|
||||
ocean: lazy(() => import('../OceanBackground')),
|
||||
'token-factory': lazy(() => import('./themes/TokenFactory')),
|
||||
'token-factory-cinematic': lazy(
|
||||
() => import('./themes/CinematicTokenFactory'),
|
||||
),
|
||||
};
|
||||
|
||||
// status 尚未拉取完成时,用 localStorage 缓存的上一次 status 兜底,
|
||||
// 避免回头客先黑屏再闪入动画。
|
||||
const readCachedTheme = () => {
|
||||
try {
|
||||
const s = JSON.parse(localStorage.getItem('status') || '{}');
|
||||
return s?.auth_background_theme;
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
|
||||
const AuthBackground = () => {
|
||||
const [statusState] = useContext(StatusContext);
|
||||
const theme =
|
||||
statusState?.status?.auth_background_theme ?? readCachedTheme() ?? 'ocean';
|
||||
|
||||
if (theme === 'none') return null;
|
||||
// hasOwnProperty 守卫:防止 "constructor" 之类的原型链键名取出非组件值导致渲染崩溃
|
||||
const ThemeComponent = Object.prototype.hasOwnProperty.call(THEMES, theme)
|
||||
? THEMES[theme]
|
||||
: THEMES.ocean;
|
||||
|
||||
return (
|
||||
<Suspense fallback={null}>
|
||||
<ThemeComponent />
|
||||
</Suspense>
|
||||
);
|
||||
};
|
||||
|
||||
export default AuthBackground;
|
||||
@@ -0,0 +1,246 @@
|
||||
/* Cinematic image layer and lightweight motion effects. */
|
||||
.token-factory-scene {
|
||||
--factory-parallax-x: 0px;
|
||||
--factory-parallax-y: 0px;
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: -1;
|
||||
overflow: hidden;
|
||||
pointer-events: none;
|
||||
background: #020611;
|
||||
isolation: isolate;
|
||||
}
|
||||
|
||||
.token-factory-scene__image {
|
||||
position: absolute;
|
||||
inset: -3.5%;
|
||||
background-image: url('/assets/token-factory-cinematic-v2-web.webp');
|
||||
background-position: center center;
|
||||
background-size: cover;
|
||||
filter: saturate(1.08) contrast(1.08) brightness(0.88);
|
||||
transform: translate3d(
|
||||
var(--factory-parallax-x),
|
||||
var(--factory-parallax-y),
|
||||
0
|
||||
)
|
||||
scale(1.055);
|
||||
animation: factory-camera-breathe 18s ease-in-out infinite alternate;
|
||||
will-change: transform;
|
||||
}
|
||||
|
||||
.token-factory-scene__grade {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background:
|
||||
radial-gradient(
|
||||
ellipse 28% 62% at 50% 49%,
|
||||
rgba(0, 4, 12, 0.62) 0%,
|
||||
rgba(1, 7, 18, 0.36) 48%,
|
||||
transparent 100%
|
||||
),
|
||||
linear-gradient(
|
||||
90deg,
|
||||
rgba(1, 5, 13, 0.06),
|
||||
transparent 30%,
|
||||
transparent 68%,
|
||||
rgba(0, 4, 12, 0.18)
|
||||
),
|
||||
linear-gradient(
|
||||
180deg,
|
||||
rgba(1, 5, 14, 0.2),
|
||||
transparent 38%,
|
||||
rgba(0, 3, 10, 0.4)
|
||||
);
|
||||
mix-blend-mode: multiply;
|
||||
}
|
||||
|
||||
.token-factory-scene__beam {
|
||||
position: absolute;
|
||||
width: 52vw;
|
||||
height: 9vh;
|
||||
top: 59%;
|
||||
left: -18vw;
|
||||
opacity: 0.42;
|
||||
filter: blur(16px);
|
||||
transform: rotate(-3deg);
|
||||
animation: factory-energy-sweep 8.5s cubic-bezier(0.42, 0, 0.2, 1) infinite;
|
||||
background: linear-gradient(
|
||||
90deg,
|
||||
transparent,
|
||||
rgba(255, 184, 78, 0.8),
|
||||
rgba(255, 238, 191, 0.92),
|
||||
transparent
|
||||
);
|
||||
mix-blend-mode: screen;
|
||||
}
|
||||
|
||||
.token-factory-scene__beam--cool {
|
||||
top: 66%;
|
||||
left: -32vw;
|
||||
width: 68vw;
|
||||
height: 7vh;
|
||||
opacity: 0.38;
|
||||
animation-delay: -4.2s;
|
||||
animation-duration: 10.5s;
|
||||
background: linear-gradient(
|
||||
90deg,
|
||||
transparent,
|
||||
rgba(28, 178, 255, 0.8),
|
||||
rgba(124, 239, 255, 0.92),
|
||||
transparent
|
||||
);
|
||||
}
|
||||
|
||||
.token-factory-scene__haze {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background:
|
||||
radial-gradient(
|
||||
circle at 50% 46%,
|
||||
rgba(63, 196, 255, 0.15),
|
||||
transparent 20%
|
||||
),
|
||||
radial-gradient(
|
||||
circle at 12% 48%,
|
||||
rgba(255, 181, 78, 0.1),
|
||||
transparent 26%
|
||||
),
|
||||
linear-gradient(
|
||||
112deg,
|
||||
transparent 42%,
|
||||
rgba(93, 211, 255, 0.06) 51%,
|
||||
transparent 59%
|
||||
);
|
||||
animation: factory-haze-pulse 7s ease-in-out infinite alternate;
|
||||
mix-blend-mode: screen;
|
||||
}
|
||||
|
||||
.token-factory-scene__particles {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
mix-blend-mode: screen;
|
||||
}
|
||||
|
||||
.token-factory-scene__vignette {
|
||||
position: absolute;
|
||||
inset: -1px;
|
||||
box-shadow:
|
||||
inset 0 0 17vw 3vw rgba(0, 2, 8, 0.72),
|
||||
inset 0 -16vh 18vh rgba(0, 3, 10, 0.52);
|
||||
}
|
||||
|
||||
.token-factory-scene__grain {
|
||||
position: absolute;
|
||||
inset: -50%;
|
||||
opacity: 0.055;
|
||||
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.85'/%3E%3C/svg%3E");
|
||||
animation: factory-film-grain 0.35s steps(2) infinite;
|
||||
mix-blend-mode: soft-light;
|
||||
}
|
||||
|
||||
@keyframes factory-camera-breathe {
|
||||
from {
|
||||
transform: translate3d(
|
||||
var(--factory-parallax-x),
|
||||
var(--factory-parallax-y),
|
||||
0
|
||||
)
|
||||
scale(1.055);
|
||||
}
|
||||
to {
|
||||
transform: translate3d(
|
||||
var(--factory-parallax-x),
|
||||
var(--factory-parallax-y),
|
||||
0
|
||||
)
|
||||
scale(1.075);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes factory-energy-sweep {
|
||||
0% {
|
||||
transform: translate3d(-8vw, 0, 0) rotate(-3deg) scaleX(0.7);
|
||||
opacity: 0;
|
||||
}
|
||||
18% {
|
||||
opacity: 0.42;
|
||||
}
|
||||
72% {
|
||||
opacity: 0.3;
|
||||
}
|
||||
100% {
|
||||
transform: translate3d(148vw, -3vh, 0) rotate(-3deg) scaleX(1.1);
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes factory-haze-pulse {
|
||||
from {
|
||||
opacity: 0.62;
|
||||
transform: scale(1);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: scale(1.035);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes factory-film-grain {
|
||||
0% {
|
||||
transform: translate3d(-2%, 1%, 0);
|
||||
}
|
||||
25% {
|
||||
transform: translate3d(1%, -2%, 0);
|
||||
}
|
||||
50% {
|
||||
transform: translate3d(2%, 2%, 0);
|
||||
}
|
||||
75% {
|
||||
transform: translate3d(-1%, -1%, 0);
|
||||
}
|
||||
100% {
|
||||
transform: translate3d(0, 2%, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.token-factory-scene__image {
|
||||
inset: -2%;
|
||||
background-position: 51% center;
|
||||
transform: scale(1.04);
|
||||
animation: none;
|
||||
}
|
||||
|
||||
.token-factory-scene__grade {
|
||||
background:
|
||||
radial-gradient(
|
||||
ellipse 72% 50% at 50% 48%,
|
||||
rgba(1, 5, 14, 0.58),
|
||||
transparent 100%
|
||||
),
|
||||
linear-gradient(
|
||||
180deg,
|
||||
rgba(1, 5, 14, 0.24),
|
||||
transparent 35%,
|
||||
rgba(0, 3, 10, 0.5)
|
||||
);
|
||||
}
|
||||
|
||||
.token-factory-scene__beam {
|
||||
opacity: 0.25;
|
||||
}
|
||||
.token-factory-scene__grain {
|
||||
opacity: 0.035;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.token-factory-scene__image,
|
||||
.token-factory-scene__beam,
|
||||
.token-factory-scene__haze,
|
||||
.token-factory-scene__grain {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,234 @@
|
||||
/*
|
||||
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 React, { useEffect, useRef } from 'react';
|
||||
import './CinematicTokenFactory.css';
|
||||
|
||||
const mulberry32 = (seed) => {
|
||||
let value = seed >>> 0;
|
||||
return () => {
|
||||
value += 0x6d2b79f5;
|
||||
let result = value;
|
||||
result = Math.imul(result ^ (result >>> 15), result | 1);
|
||||
result ^= result + Math.imul(result ^ (result >>> 7), result | 61);
|
||||
return ((result ^ (result >>> 14)) >>> 0) / 4294967296;
|
||||
};
|
||||
};
|
||||
|
||||
const CinematicTokenFactory = () => {
|
||||
const sceneRef = useRef(null);
|
||||
const canvasRef = useRef(null);
|
||||
|
||||
useEffect(() => {
|
||||
const scene = sceneRef.current;
|
||||
const canvas = canvasRef.current;
|
||||
if (!scene || !canvas) return undefined;
|
||||
|
||||
const context = canvas.getContext('2d');
|
||||
const motionQuery = window.matchMedia('(prefers-reduced-motion: reduce)');
|
||||
let reducedMotion = motionQuery.matches;
|
||||
const random = mulberry32(0x746f6b65);
|
||||
const particles = Array.from({ length: 48 }, (_, index) => ({
|
||||
x: random(),
|
||||
y: random(),
|
||||
depth: 0.35 + random() * 0.9,
|
||||
radius: index % 8 === 0 ? 3 + random() * 2.4 : 0.6 + random() * 1.5,
|
||||
speed: 0.000018 + random() * 0.000035,
|
||||
phase: random() * Math.PI * 2,
|
||||
token: index % 8 === 0,
|
||||
}));
|
||||
|
||||
let width = 0;
|
||||
let height = 0;
|
||||
let dpr = 1;
|
||||
let frameId = 0;
|
||||
let visible = !document.hidden;
|
||||
let pointerX = 0;
|
||||
let pointerY = 0;
|
||||
let smoothX = 0;
|
||||
let smoothY = 0;
|
||||
let lastFrameTime = 0;
|
||||
|
||||
const resize = () => {
|
||||
width = window.innerWidth;
|
||||
height = window.innerHeight;
|
||||
dpr = Math.min(window.devicePixelRatio || 1, 1.5);
|
||||
canvas.width = Math.round(width * dpr);
|
||||
canvas.height = Math.round(height * dpr);
|
||||
canvas.style.width = `${width}px`;
|
||||
canvas.style.height = `${height}px`;
|
||||
context.setTransform(dpr, 0, 0, dpr, 0, 0);
|
||||
};
|
||||
|
||||
const onPointerMove = (event) => {
|
||||
pointerX = event.clientX / Math.max(width, 1) - 0.5;
|
||||
pointerY = event.clientY / Math.max(height, 1) - 0.5;
|
||||
};
|
||||
|
||||
const drawEnergyStream = (time, y, color, speed, amplitude) => {
|
||||
context.save();
|
||||
context.globalCompositeOperation = 'screen';
|
||||
context.lineWidth = 1.15;
|
||||
context.strokeStyle = color;
|
||||
context.shadowColor = color;
|
||||
context.shadowBlur = 10;
|
||||
context.beginPath();
|
||||
for (let x = -40; x <= width + 40; x += 18) {
|
||||
const progress = x / Math.max(width, 1);
|
||||
const wave = Math.sin(progress * 8 + time * speed) * amplitude;
|
||||
const perspective = (progress - 0.52) ** 2 * height * 0.08;
|
||||
const py = height * y + wave + perspective;
|
||||
if (x === -40) context.moveTo(x, py);
|
||||
else context.lineTo(x, py);
|
||||
}
|
||||
context.stroke();
|
||||
|
||||
for (let i = 0; i < 6; i += 1) {
|
||||
const progress = (time * speed * 0.13 + i / 6) % 1;
|
||||
const x = progress * width;
|
||||
const wave = Math.sin(progress * 8 + time * speed) * amplitude;
|
||||
const py = height * y + wave + (progress - 0.52) ** 2 * height * 0.08;
|
||||
const glow = context.createRadialGradient(x, py, 0, x, py, 13);
|
||||
glow.addColorStop(0, 'rgba(255,255,255,.95)');
|
||||
glow.addColorStop(0.25, color);
|
||||
glow.addColorStop(1, 'rgba(0,0,0,0)');
|
||||
context.fillStyle = glow;
|
||||
context.beginPath();
|
||||
context.arc(x, py, 13, 0, Math.PI * 2);
|
||||
context.fill();
|
||||
}
|
||||
context.restore();
|
||||
};
|
||||
|
||||
const drawParticle = (particle, time, deltaMs) => {
|
||||
if (!reducedMotion) {
|
||||
particle.x += particle.speed * particle.depth * deltaMs;
|
||||
particle.y +=
|
||||
Math.sin(time * 0.00045 + particle.phase) *
|
||||
0.000025 *
|
||||
(deltaMs / 16.67);
|
||||
if (particle.x > 1.08) particle.x = -0.08;
|
||||
}
|
||||
|
||||
const x = particle.x * width + smoothX * 24 * particle.depth;
|
||||
const y = particle.y * height + smoothY * 14 * particle.depth;
|
||||
const pulse = 0.65 + Math.sin(time * 0.0012 + particle.phase) * 0.35;
|
||||
context.save();
|
||||
context.globalCompositeOperation = 'screen';
|
||||
|
||||
if (particle.token) {
|
||||
const radius = particle.radius * (0.85 + pulse * 0.2);
|
||||
context.translate(x, y);
|
||||
context.rotate(Math.sin(time * 0.00035 + particle.phase) * 0.35);
|
||||
context.shadowColor = '#ffc861';
|
||||
context.shadowBlur = 14;
|
||||
context.strokeStyle = `rgba(255, 202, 98, ${0.45 + pulse * 0.4})`;
|
||||
context.lineWidth = 1.1;
|
||||
context.beginPath();
|
||||
context.arc(0, 0, radius * 1.65, 0, Math.PI * 2);
|
||||
context.stroke();
|
||||
context.beginPath();
|
||||
context.moveTo(-radius * 0.65, -radius * 0.15);
|
||||
context.lineTo(radius * 0.65, -radius * 0.15);
|
||||
context.moveTo(-radius * 0.65, radius * 0.35);
|
||||
context.lineTo(radius * 0.65, radius * 0.35);
|
||||
context.stroke();
|
||||
} else {
|
||||
context.shadowColor = '#72e8ff';
|
||||
context.shadowBlur = 9;
|
||||
context.fillStyle = `rgba(125, 231, 255, ${0.18 + pulse * 0.5})`;
|
||||
context.beginPath();
|
||||
context.arc(x, y, particle.radius * pulse, 0, Math.PI * 2);
|
||||
context.fill();
|
||||
}
|
||||
context.restore();
|
||||
};
|
||||
|
||||
const render = (time = 0) => {
|
||||
const deltaMs = lastFrameTime
|
||||
? Math.min(Math.max(time - lastFrameTime, 0), 50)
|
||||
: 16.67;
|
||||
lastFrameTime = time;
|
||||
context.clearRect(0, 0, width, height);
|
||||
smoothX += (pointerX - smoothX) * 0.035;
|
||||
smoothY += (pointerY - smoothY) * 0.035;
|
||||
scene.style.setProperty('--factory-parallax-x', `${smoothX * -18}px`);
|
||||
scene.style.setProperty('--factory-parallax-y', `${smoothY * -10}px`);
|
||||
|
||||
drawEnergyStream(time * 0.001, 0.68, 'rgba(255, 181, 73, .58)', 1.2, 4);
|
||||
drawEnergyStream(time * 0.001, 0.73, 'rgba(47, 211, 255, .62)', 1.65, 6);
|
||||
particles.forEach((particle) => drawParticle(particle, time, deltaMs));
|
||||
|
||||
if (!reducedMotion && visible) frameId = requestAnimationFrame(render);
|
||||
};
|
||||
|
||||
const onVisibilityChange = () => {
|
||||
visible = !document.hidden;
|
||||
if (visible && !reducedMotion) {
|
||||
cancelAnimationFrame(frameId);
|
||||
lastFrameTime = 0;
|
||||
frameId = requestAnimationFrame(render);
|
||||
}
|
||||
};
|
||||
|
||||
const onResize = () => {
|
||||
resize();
|
||||
if (reducedMotion) {
|
||||
lastFrameTime = 0;
|
||||
render(performance.now());
|
||||
}
|
||||
};
|
||||
|
||||
const onMotionPreferenceChange = (event) => {
|
||||
reducedMotion = event.matches;
|
||||
cancelAnimationFrame(frameId);
|
||||
lastFrameTime = 0;
|
||||
render(performance.now());
|
||||
};
|
||||
|
||||
resize();
|
||||
render();
|
||||
window.addEventListener('resize', onResize);
|
||||
window.addEventListener('pointermove', onPointerMove, { passive: true });
|
||||
document.addEventListener('visibilitychange', onVisibilityChange);
|
||||
motionQuery.addEventListener('change', onMotionPreferenceChange);
|
||||
|
||||
return () => {
|
||||
cancelAnimationFrame(frameId);
|
||||
window.removeEventListener('resize', onResize);
|
||||
window.removeEventListener('pointermove', onPointerMove);
|
||||
document.removeEventListener('visibilitychange', onVisibilityChange);
|
||||
motionQuery.removeEventListener('change', onMotionPreferenceChange);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div ref={sceneRef} className='token-factory-scene' aria-hidden='true'>
|
||||
<div className='token-factory-scene__image' />
|
||||
<div className='token-factory-scene__grade' />
|
||||
<div className='token-factory-scene__beam token-factory-scene__beam--warm' />
|
||||
<div className='token-factory-scene__beam token-factory-scene__beam--cool' />
|
||||
<div className='token-factory-scene__haze' />
|
||||
<canvas ref={canvasRef} className='token-factory-scene__particles' />
|
||||
<div className='token-factory-scene__vignette' />
|
||||
<div className='token-factory-scene__grain' />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default CinematicTokenFactory;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
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 React from 'react';
|
||||
import Loading from './ui/Loading';
|
||||
import {
|
||||
isChunkLoadError,
|
||||
reloadForChunkError,
|
||||
} from '../../helpers/chunkReload';
|
||||
|
||||
class ChunkErrorBoundary extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = { error: null, reloading: false };
|
||||
}
|
||||
|
||||
static getDerivedStateFromError(error) {
|
||||
return { error, reloading: false };
|
||||
}
|
||||
|
||||
componentDidCatch(error) {
|
||||
if (reloadForChunkError(error)) {
|
||||
this.setState({ reloading: true });
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const { error } = this.state;
|
||||
|
||||
if (!error) {
|
||||
return this.props.children;
|
||||
}
|
||||
|
||||
const chunkLoadError = isChunkLoadError(error);
|
||||
|
||||
if (chunkLoadError && this.state.reloading) {
|
||||
return <Loading />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
minHeight: '100vh',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
padding: 24,
|
||||
textAlign: 'center',
|
||||
}}
|
||||
>
|
||||
<div>
|
||||
<h2 style={{ marginBottom: 12 }}>
|
||||
{chunkLoadError ? 'Page update required' : 'Something went wrong'}
|
||||
</h2>
|
||||
<p style={{ marginBottom: 16 }}>
|
||||
{chunkLoadError
|
||||
? 'The app was updated while this page was open. Refresh to load the latest files.'
|
||||
: 'Please refresh the page and try again.'}
|
||||
</p>
|
||||
<button type='button' onClick={() => window.location.reload()}>
|
||||
Refresh
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default ChunkErrorBoundary;
|
||||
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
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 React, { useState, useCallback } from 'react';
|
||||
import { Modal } from '@douyinfe/semi-ui';
|
||||
import { X, Shield, Scale, ScrollText, ExternalLink } from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import DocumentRenderer from './index';
|
||||
import { useIsMobile } from '../../../hooks/common/useIsMobile';
|
||||
|
||||
const getIconByType = (type) => {
|
||||
if (type === 'privacy') return Shield;
|
||||
if (type === 'agreement') return Scale;
|
||||
return ScrollText;
|
||||
};
|
||||
|
||||
const AGREEMENT_CONFIGS = {
|
||||
agreement: {
|
||||
apiEndpoint: '/api/user-agreement',
|
||||
cacheKey: 'user_agreement',
|
||||
fullPagePath: '/user-agreement',
|
||||
titleKey: '服务协议',
|
||||
emptyKey: '加载服务协议内容失败...',
|
||||
},
|
||||
privacy: {
|
||||
apiEndpoint: '/api/privacy-policy',
|
||||
cacheKey: 'privacy_policy',
|
||||
fullPagePath: '/privacy-policy',
|
||||
titleKey: '隐私政策',
|
||||
emptyKey: '加载隐私政策内容失败...',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* 协议预览弹窗(用于登录/注册页内嵌预览)
|
||||
* @param {boolean} visible
|
||||
* @param {'agreement'|'privacy'} type
|
||||
* @param {function} onClose
|
||||
*/
|
||||
const AgreementModal = ({ visible, type, onClose }) => {
|
||||
const { t } = useTranslation();
|
||||
const isMobile = useIsMobile();
|
||||
const [progress, setProgress] = useState(0);
|
||||
|
||||
const handleProgressChange = useCallback((p) => setProgress(p), []);
|
||||
|
||||
const config = type ? AGREEMENT_CONFIGS[type] : null;
|
||||
if (!config) return null;
|
||||
|
||||
const IconComponent = getIconByType(type);
|
||||
const title = t(config.titleKey);
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={null}
|
||||
header={null}
|
||||
footer={null}
|
||||
visible={visible}
|
||||
onCancel={onClose}
|
||||
closeIcon={null}
|
||||
maskClosable={true}
|
||||
centered
|
||||
width={isMobile ? '94%' : 720}
|
||||
bodyStyle={{
|
||||
padding: 0,
|
||||
borderRadius: 16,
|
||||
overflow: 'hidden',
|
||||
}}
|
||||
className='agreement-preview-modal'
|
||||
maskStyle={{
|
||||
backgroundColor: 'rgba(15, 18, 28, 0.55)',
|
||||
backdropFilter: 'blur(8px)',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className='flex flex-col bg-white dark:bg-gray-900 ring-1 ring-gray-200/60 dark:ring-gray-800/60 rounded-2xl overflow-hidden'
|
||||
style={{ height: isMobile ? '85vh' : '78vh' }}
|
||||
>
|
||||
{/* 阅读进度条 */}
|
||||
<div
|
||||
className='h-[2px] bg-gradient-to-r from-brand-from via-brand to-brand-to origin-left transition-transform duration-150 ease-out'
|
||||
style={{ transform: `scaleX(${progress / 100})` }}
|
||||
aria-hidden
|
||||
/>
|
||||
|
||||
{/* 头部 */}
|
||||
<div className='relative flex items-center justify-between px-5 sm:px-6 h-14 border-b border-gray-200/80 dark:border-gray-800/80 flex-shrink-0 bg-white/95 dark:bg-gray-900/95 backdrop-blur-md'>
|
||||
{/* 头部环境光 */}
|
||||
<div className='pointer-events-none absolute inset-0 overflow-hidden' aria-hidden>
|
||||
<div className='absolute -top-12 left-8 w-48 h-24 bg-gradient-to-br from-brand-from/15 to-brand-to/10 dark:from-brand-from/15 dark:to-brand-to/10 blur-3xl rounded-full' />
|
||||
</div>
|
||||
|
||||
<div className='relative flex items-center gap-2.5'>
|
||||
<div className='relative'>
|
||||
<div className='absolute inset-0 bg-gradient-to-br from-brand-from to-brand-to blur-md opacity-50 dark:opacity-40 rounded-lg' />
|
||||
<div className='relative w-7 h-7 rounded-lg bg-gradient-to-br from-brand-from to-brand-to flex items-center justify-center shadow-sm'>
|
||||
<IconComponent size={14} className='text-white' />
|
||||
</div>
|
||||
</div>
|
||||
<h2 className='text-sm font-semibold text-gray-900 dark:text-gray-50 tracking-tight'>
|
||||
{title}
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
<div className='relative flex items-center gap-1'>
|
||||
<a
|
||||
href={config.fullPagePath}
|
||||
target='_blank'
|
||||
rel='noopener noreferrer'
|
||||
className='group inline-flex items-center gap-1 px-2 py-1.5 text-xs font-medium text-gray-500 dark:text-gray-400 hover:text-brand-deep dark:hover:text-brand-from hover:bg-gray-100/80 dark:hover:bg-gray-800/80 rounded-md transition-colors'
|
||||
title={t('在新标签页打开')}
|
||||
>
|
||||
<ExternalLink size={12} className='transition-transform group-hover:translate-x-0.5 group-hover:-translate-y-0.5' />
|
||||
<span className='hidden sm:inline'>{t('完整页面')}</span>
|
||||
</a>
|
||||
<button
|
||||
onClick={onClose}
|
||||
className='p-1.5 rounded-md text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 hover:bg-gray-100/80 dark:hover:bg-gray-800/80 transition-colors'
|
||||
aria-label={t('关闭')}
|
||||
>
|
||||
<X size={16} />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 内容区 */}
|
||||
<div className='flex-1 min-h-0 bg-gray-50/30 dark:bg-gray-950/20'>
|
||||
<DocumentRenderer
|
||||
apiEndpoint={config.apiEndpoint}
|
||||
title={title}
|
||||
cacheKey={config.cacheKey}
|
||||
emptyMessage={t(config.emptyKey)}
|
||||
mode='embedded'
|
||||
docType={type}
|
||||
onProgressChange={handleProgressChange}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default AgreementModal;
|
||||
@@ -0,0 +1,637 @@
|
||||
/*
|
||||
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 React, { useEffect, useState, useCallback, useRef } from 'react';
|
||||
import { API, showError } from '../../../helpers';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import MarkdownRenderer from '../markdown/MarkdownRenderer';
|
||||
import {
|
||||
Shield,
|
||||
ScrollText,
|
||||
ExternalLink,
|
||||
ChevronUp,
|
||||
ArrowLeft,
|
||||
BookOpen,
|
||||
Scale,
|
||||
Printer,
|
||||
} from 'lucide-react';
|
||||
import { useNavigate, useLocation } from 'react-router-dom';
|
||||
|
||||
// 检查是否为 URL
|
||||
const isUrl = (content) => {
|
||||
try {
|
||||
new URL(content.trim());
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
// 检查是否为 HTML 内容
|
||||
const isHtmlContent = (content) => {
|
||||
if (!content || typeof content !== 'string') return false;
|
||||
const htmlTagRegex = /<\/?[a-z][\s\S]*>/i;
|
||||
return htmlTagRegex.test(content);
|
||||
};
|
||||
|
||||
/**
|
||||
* 抽取 HTML body 内容与 style 标签。
|
||||
* 注意:此函数 NOT 是真正的 XSS 消毒,仅做结构整理;
|
||||
* 信任来源:内容由后台管理员设置(需登录管理后台),如需在不受信场景使用应替换为 DOMPurify。
|
||||
*/
|
||||
const extractHtml = (html) => {
|
||||
const tempDiv = document.createElement('div');
|
||||
tempDiv.innerHTML = html;
|
||||
const styles = Array.from(tempDiv.querySelectorAll('style'))
|
||||
.map((style) => style.innerHTML)
|
||||
.join('\n');
|
||||
// 主动剔除 script 标签,降低风险
|
||||
tempDiv.querySelectorAll('script').forEach((el) => el.remove());
|
||||
const bodyContent = tempDiv.querySelector('body');
|
||||
const content = bodyContent ? bodyContent.innerHTML : tempDiv.innerHTML;
|
||||
return { content, styles };
|
||||
};
|
||||
|
||||
// 根据 type / 标题获取对应的图标
|
||||
const getIcon = ({ type, title }) => {
|
||||
if (type === 'privacy') return Shield;
|
||||
if (type === 'agreement') return Scale;
|
||||
// 兜底(i18n 友好度有限):按标题关键字推断
|
||||
if (title?.includes('隐私') || title?.toLowerCase().includes('privacy')) {
|
||||
return Shield;
|
||||
}
|
||||
if (
|
||||
title?.includes('服务') ||
|
||||
title?.includes('用户') ||
|
||||
title?.toLowerCase().includes('terms') ||
|
||||
title?.toLowerCase().includes('service')
|
||||
) {
|
||||
return Scale;
|
||||
}
|
||||
return ScrollText;
|
||||
};
|
||||
|
||||
/**
|
||||
* 智能返回:
|
||||
* 1) 有真实历史(length>1)→ navigate(-1)
|
||||
* 2) 尝试 window.close()(脚本打开的标签页会成功,否则被忽略)
|
||||
* 3) 兜底跳首页
|
||||
*
|
||||
* 说明:因 LoginForm 的协议链接使用了 rel="noopener noreferrer",
|
||||
* 新标签里的 window.opener 为 null、document.referrer 为空,无法用 referrer 判同源。
|
||||
*/
|
||||
const useSmartBack = () => {
|
||||
const navigate = useNavigate();
|
||||
return useCallback(() => {
|
||||
if (window.history.length > 1) {
|
||||
navigate(-1);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
window.close();
|
||||
} catch (e) {
|
||||
// 浏览器拒绝则继续走兜底
|
||||
}
|
||||
// 短延时给 close() 一个机会
|
||||
setTimeout(() => {
|
||||
if (!window.closed) navigate('/');
|
||||
}, 50);
|
||||
}, [navigate]);
|
||||
};
|
||||
|
||||
/**
|
||||
* 通用文档渲染组件
|
||||
* @param {string} apiEndpoint API 接口地址
|
||||
* @param {string} title 文档标题
|
||||
* @param {string} cacheKey 本地存储缓存键
|
||||
* @param {string} emptyMessage 空内容时的提示消息
|
||||
* @param {'page'|'embedded'} mode page=独立页面(默认),embedded=嵌入式(无背景/头部)
|
||||
* @param {'agreement'|'privacy'} [docType] 文档类型(用于图标识别,比标题更可靠)
|
||||
* @param {function} [onProgressChange] 进度变化回调(嵌入模式用于宿主显示进度条)
|
||||
*/
|
||||
const DocumentRenderer = ({
|
||||
apiEndpoint,
|
||||
title,
|
||||
cacheKey,
|
||||
emptyMessage,
|
||||
mode = 'page',
|
||||
docType,
|
||||
onProgressChange,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const smartBack = useSmartBack();
|
||||
const location = useLocation();
|
||||
const [content, setContent] = useState('');
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [htmlStyles, setHtmlStyles] = useState('');
|
||||
const [processedHtmlContent, setProcessedHtmlContent] = useState('');
|
||||
const [showBackToTop, setShowBackToTop] = useState(false);
|
||||
const [readProgress, setReadProgress] = useState(0);
|
||||
const scrollContainerRef = useRef(null);
|
||||
const rootRef = useRef(null);
|
||||
const isMountedRef = useRef(true);
|
||||
const abortControllerRef = useRef(null);
|
||||
|
||||
const isEmbedded = mode === 'embedded';
|
||||
const IconComponent = getIcon({ type: docType, title });
|
||||
|
||||
const processContent = useCallback((rawContent) => {
|
||||
if (isHtmlContent(rawContent)) {
|
||||
const { content: htmlContent, styles } = extractHtml(rawContent);
|
||||
setProcessedHtmlContent(htmlContent);
|
||||
setHtmlStyles(styles);
|
||||
} else {
|
||||
setProcessedHtmlContent('');
|
||||
setHtmlStyles('');
|
||||
}
|
||||
}, []);
|
||||
|
||||
// 加载内容(含取消保护,避免在卸载后 setState)
|
||||
useEffect(() => {
|
||||
isMountedRef.current = true;
|
||||
const controller = new AbortController();
|
||||
abortControllerRef.current = controller;
|
||||
|
||||
const load = async () => {
|
||||
const cachedContent = localStorage.getItem(cacheKey) || '';
|
||||
if (cachedContent) {
|
||||
setContent(cachedContent);
|
||||
processContent(cachedContent);
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await API.get(apiEndpoint, { signal: controller.signal });
|
||||
if (!isMountedRef.current) return;
|
||||
const { success, message, data } = res.data;
|
||||
if (success && data) {
|
||||
setContent(data);
|
||||
processContent(data);
|
||||
localStorage.setItem(cacheKey, data);
|
||||
} else if (!cachedContent) {
|
||||
showError(message || emptyMessage);
|
||||
setContent('');
|
||||
}
|
||||
} catch (error) {
|
||||
if (controller.signal.aborted) return; // 用户离开页面
|
||||
if (!isMountedRef.current) return;
|
||||
const cached = localStorage.getItem(cacheKey) || '';
|
||||
if (!cached) {
|
||||
showError(emptyMessage);
|
||||
setContent('');
|
||||
}
|
||||
} finally {
|
||||
if (isMountedRef.current) setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
load();
|
||||
|
||||
return () => {
|
||||
isMountedRef.current = false;
|
||||
controller.abort();
|
||||
};
|
||||
}, [apiEndpoint, cacheKey, emptyMessage, processContent]);
|
||||
|
||||
// 滚动监听 + 阅读进度计算(page 模式监听 window,embedded 模式监听容器)
|
||||
const handleScroll = useCallback(
|
||||
(e) => {
|
||||
let scrollTop;
|
||||
let scrollHeight;
|
||||
let clientHeight;
|
||||
|
||||
if (
|
||||
e?.target &&
|
||||
e.target !== window &&
|
||||
e.target.scrollHeight !== undefined
|
||||
) {
|
||||
scrollTop = e.target.scrollTop;
|
||||
scrollHeight = e.target.scrollHeight;
|
||||
clientHeight = e.target.clientHeight;
|
||||
} else {
|
||||
scrollTop = window.scrollY;
|
||||
scrollHeight = document.documentElement.scrollHeight;
|
||||
clientHeight = window.innerHeight;
|
||||
}
|
||||
|
||||
setShowBackToTop(scrollTop > 300);
|
||||
|
||||
const denom = scrollHeight - clientHeight;
|
||||
const progress =
|
||||
denom > 0 ? Math.min(100, Math.max(0, (scrollTop / denom) * 100)) : 0;
|
||||
setReadProgress(progress);
|
||||
if (isEmbedded && onProgressChange) {
|
||||
onProgressChange(progress);
|
||||
}
|
||||
},
|
||||
[isEmbedded, onProgressChange],
|
||||
);
|
||||
|
||||
const scrollToTop = () => {
|
||||
const target =
|
||||
(isEmbedded && scrollContainerRef.current) || pageScrollElRef.current;
|
||||
if (target) {
|
||||
target.scrollTo({ top: 0, behavior: 'smooth' });
|
||||
} else {
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||
}
|
||||
};
|
||||
|
||||
// page 模式的实际滚动容器不是 window:PageLayout 外层是 height:100vh + overflow:hidden,
|
||||
// 真正滚动的是内层 Semi Layout(一个普通 div)。元素的 scroll 事件不冒泡到 window,
|
||||
// 所以原来只监听 window 时 showBackToTop 永远为 false、阅读进度条恒为 0。
|
||||
// 这里向上找到真正可滚动的祖先来监听;找不到再回退 window(独立页/未来结构变化)。
|
||||
const pageScrollElRef = useRef(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (isEmbedded) return;
|
||||
|
||||
const findScrollParent = (node) => {
|
||||
let el = node?.parentElement;
|
||||
while (el && el !== document.body) {
|
||||
const overflowY = window.getComputedStyle(el).overflowY;
|
||||
if (
|
||||
(overflowY === 'auto' || overflowY === 'scroll') &&
|
||||
el.scrollHeight > el.clientHeight
|
||||
) {
|
||||
return el;
|
||||
}
|
||||
el = el.parentElement;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const target = findScrollParent(rootRef.current) || window;
|
||||
pageScrollElRef.current = target === window ? null : target;
|
||||
|
||||
const onScroll = (e) => {
|
||||
if (target === window) {
|
||||
handleScroll();
|
||||
return;
|
||||
}
|
||||
handleScroll({ target });
|
||||
};
|
||||
|
||||
target.addEventListener('scroll', onScroll, { passive: true });
|
||||
return () => target.removeEventListener('scroll', onScroll);
|
||||
}, [isEmbedded, handleScroll]);
|
||||
|
||||
// 处理 HTML 样式注入
|
||||
useEffect(() => {
|
||||
const styleId = `document-renderer-styles-${cacheKey}-${mode}`;
|
||||
|
||||
if (htmlStyles) {
|
||||
let styleEl = document.getElementById(styleId);
|
||||
if (!styleEl) {
|
||||
styleEl = document.createElement('style');
|
||||
styleEl.id = styleId;
|
||||
styleEl.type = 'text/css';
|
||||
document.head.appendChild(styleEl);
|
||||
}
|
||||
styleEl.innerHTML = htmlStyles;
|
||||
} else {
|
||||
const el = document.getElementById(styleId);
|
||||
if (el) el.remove();
|
||||
}
|
||||
|
||||
return () => {
|
||||
const el = document.getElementById(styleId);
|
||||
if (el) el.remove();
|
||||
};
|
||||
}, [htmlStyles, cacheKey, mode]);
|
||||
|
||||
// URL hash 自动滚动到对应 h2/h3 anchor(仅 page 模式 + 内容加载完成后)
|
||||
useEffect(() => {
|
||||
if (isEmbedded || loading || !content || !location.hash) return;
|
||||
const id = decodeURIComponent(location.hash.slice(1));
|
||||
if (!id) return;
|
||||
const t = setTimeout(() => {
|
||||
const el = document.getElementById(id);
|
||||
if (el) el.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
}, 200);
|
||||
return () => clearTimeout(t);
|
||||
}, [isEmbedded, loading, content, location.hash]);
|
||||
|
||||
// 为 h2/h3 注入 id + 锚点链接(page 模式 + Markdown 已渲染 DOM 后)
|
||||
const contentRef = useRef(null);
|
||||
useEffect(() => {
|
||||
if (isEmbedded || loading || !contentRef.current) return;
|
||||
const root = contentRef.current;
|
||||
const slugify = (text) =>
|
||||
String(text || '')
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.replace(/\s+/g, '-')
|
||||
.replace(/[^\w\-一-龥]+/g, '')
|
||||
.slice(0, 80);
|
||||
|
||||
const seen = new Map();
|
||||
const headings = root.querySelectorAll('h2, h3');
|
||||
headings.forEach((h) => {
|
||||
if (h.querySelector('.doc-anchor')) return; // 已处理
|
||||
let base = h.id || slugify(h.textContent);
|
||||
if (!base) return;
|
||||
let id = base;
|
||||
const n = seen.get(base) || 0;
|
||||
if (n > 0) id = `${base}-${n}`;
|
||||
seen.set(base, n + 1);
|
||||
h.id = id;
|
||||
|
||||
const a = document.createElement('a');
|
||||
a.href = `#${id}`;
|
||||
a.className = 'doc-anchor';
|
||||
a.setAttribute('aria-label', '复制段落链接');
|
||||
a.textContent = '#';
|
||||
a.addEventListener('click', (e) => {
|
||||
e.preventDefault();
|
||||
const url = `${window.location.origin}${window.location.pathname}#${id}`;
|
||||
if (navigator.clipboard) {
|
||||
navigator.clipboard.writeText(url).catch(() => {});
|
||||
}
|
||||
history.replaceState(null, '', `#${id}`);
|
||||
});
|
||||
h.prepend(a);
|
||||
});
|
||||
}, [isEmbedded, loading, content, processedHtmlContent]);
|
||||
|
||||
// 文档内容样式(prose)—— 同时兼顾浅色与深色
|
||||
const proseClass = `prose prose-base dark:prose-invert max-w-none
|
||||
prose-headings:font-semibold prose-headings:text-gray-900 dark:prose-headings:text-gray-50 prose-headings:scroll-mt-24 prose-headings:tracking-tight
|
||||
prose-h1:text-2xl prose-h1:mb-4 prose-h1:mt-0
|
||||
prose-h2:text-lg prose-h2:mt-8 prose-h2:mb-3 prose-h2:pb-2 prose-h2:border-b prose-h2:border-gray-200 dark:prose-h2:border-gray-800
|
||||
prose-h3:text-base prose-h3:mt-5 prose-h3:mb-2
|
||||
prose-p:text-gray-700 dark:prose-p:text-gray-300 prose-p:leading-[1.75] prose-p:my-3
|
||||
prose-a:text-brand-deep dark:prose-a:text-brand-from prose-a:no-underline prose-a:font-medium hover:prose-a:underline hover:prose-a:underline-offset-4
|
||||
prose-strong:text-gray-900 dark:prose-strong:text-white prose-strong:font-semibold
|
||||
prose-code:bg-brand/10 dark:prose-code:bg-brand/15 prose-code:text-brand-deep dark:prose-code:text-brand-from prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded prose-code:text-[0.875em] prose-code:font-mono prose-code:before:content-none prose-code:after:content-none prose-code:border prose-code:border-brand/15 dark:prose-code:border-brand/20
|
||||
prose-pre:bg-gray-50 dark:prose-pre:bg-gray-900/60 prose-pre:border prose-pre:border-gray-200 dark:prose-pre:border-gray-800 prose-pre:rounded-lg
|
||||
prose-ul:my-3 prose-ol:my-3 prose-ul:space-y-1 prose-ol:space-y-1
|
||||
prose-li:text-gray-700 dark:prose-li:text-gray-300 prose-li:my-0.5 prose-li:marker:text-brand
|
||||
prose-blockquote:border-l-4 prose-blockquote:border-brand prose-blockquote:bg-brand/5 dark:prose-blockquote:bg-brand/10 prose-blockquote:py-2 prose-blockquote:px-4 prose-blockquote:rounded-r prose-blockquote:not-italic prose-blockquote:text-gray-700 dark:prose-blockquote:text-gray-300
|
||||
prose-hr:border-gray-200 dark:prose-hr:border-gray-800 prose-hr:my-6
|
||||
prose-table:rounded-lg prose-table:overflow-hidden
|
||||
prose-th:bg-gray-50 dark:prose-th:bg-gray-800/50 prose-th:text-gray-900 dark:prose-th:text-gray-100
|
||||
prose-td:border-gray-200 dark:prose-td:border-gray-800
|
||||
prose-img:rounded-lg prose-img:border prose-img:border-gray-200 dark:prose-img:border-gray-800`;
|
||||
|
||||
// ============ Skeleton(短暂加载也更稳) ============
|
||||
const renderLoading = () => (
|
||||
<div className='doc-fade-in' aria-busy='true' aria-live='polite'>
|
||||
<div className='space-y-3 max-w-2xl'>
|
||||
<div className='h-7 w-2/3 rounded-md bg-gray-200/70 dark:bg-gray-800/70 animate-pulse' />
|
||||
<div className='h-4 w-1/3 rounded-md bg-gray-200/60 dark:bg-gray-800/60 animate-pulse' />
|
||||
<div className='h-px bg-gray-200 dark:bg-gray-800 my-5' />
|
||||
<div className='space-y-2.5'>
|
||||
<div className='h-4 w-full rounded bg-gray-200/60 dark:bg-gray-800/60 animate-pulse' />
|
||||
<div className='h-4 w-[92%] rounded bg-gray-200/60 dark:bg-gray-800/60 animate-pulse' />
|
||||
<div className='h-4 w-[85%] rounded bg-gray-200/60 dark:bg-gray-800/60 animate-pulse' />
|
||||
</div>
|
||||
<div className='h-6 w-1/2 rounded bg-gray-200/70 dark:bg-gray-800/70 animate-pulse mt-6' />
|
||||
<div className='space-y-2.5'>
|
||||
<div className='h-4 w-full rounded bg-gray-200/60 dark:bg-gray-800/60 animate-pulse' />
|
||||
<div className='h-4 w-[88%] rounded bg-gray-200/60 dark:bg-gray-800/60 animate-pulse' />
|
||||
</div>
|
||||
</div>
|
||||
<span className='sr-only'>{t('加载中...')}</span>
|
||||
</div>
|
||||
);
|
||||
|
||||
// ============ 空状态 ============
|
||||
const renderEmpty = () => (
|
||||
<div className='flex flex-col items-center justify-center py-20 px-6 text-center doc-fade-in'>
|
||||
<div className='relative mb-5'>
|
||||
<div className='absolute inset-0 bg-gradient-to-br from-brand-from/20 to-brand-to/20 dark:from-brand-from/10 dark:to-brand-to/10 blur-2xl rounded-full' />
|
||||
<div className='relative w-16 h-16 bg-gray-100 dark:bg-gray-800/80 border border-gray-200 dark:border-gray-700/60 rounded-2xl flex items-center justify-center'>
|
||||
<IconComponent
|
||||
size={28}
|
||||
className='text-gray-400 dark:text-gray-500'
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<h3 className='text-base font-semibold text-gray-800 dark:text-gray-100 mb-1.5'>
|
||||
{t('内容正在准备中')}
|
||||
</h3>
|
||||
<p className='text-sm text-gray-500 dark:text-gray-400'>
|
||||
{t('管理员尚未设置') + title + t('内容')}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
|
||||
// ============ URL 卡片 ============
|
||||
const renderUrlCard = () => (
|
||||
<div className='flex flex-col items-center justify-center py-16 px-6 text-center doc-fade-in'>
|
||||
<div className='relative mb-5'>
|
||||
<div className='absolute -inset-4 bg-gradient-to-br from-brand-from/30 to-brand-to/30 dark:from-brand-from/20 dark:to-brand-to/20 blur-2xl rounded-full' />
|
||||
<div className='relative w-16 h-16 bg-gradient-to-br from-brand-from to-brand-to rounded-2xl flex items-center justify-center shadow-lg shadow-brand/30 dark:shadow-brand/20'>
|
||||
<IconComponent size={28} className='text-white' />
|
||||
</div>
|
||||
</div>
|
||||
<h3 className='text-lg font-semibold text-gray-900 dark:text-white mb-2'>
|
||||
{title}
|
||||
</h3>
|
||||
<p className='text-sm text-gray-500 dark:text-gray-400 mb-6 max-w-md'>
|
||||
{t('管理员设置了外部链接,点击下方按钮访问完整文档')}
|
||||
</p>
|
||||
<a
|
||||
href={content.trim()}
|
||||
target='_blank'
|
||||
rel='noopener noreferrer'
|
||||
title={content.trim()}
|
||||
className='group inline-flex items-center gap-2 px-6 py-2.5 bg-gradient-to-r from-brand-from to-brand-to hover:shadow-lg hover:shadow-brand/30 dark:hover:shadow-brand/20 text-white text-sm font-medium rounded-lg shadow-sm transition-all hover:-translate-y-0.5'
|
||||
>
|
||||
<BookOpen size={16} />
|
||||
{t('访问') + title}
|
||||
<ExternalLink
|
||||
size={14}
|
||||
className='transition-transform group-hover:translate-x-0.5'
|
||||
/>
|
||||
</a>
|
||||
</div>
|
||||
);
|
||||
|
||||
// ============ HTML / Markdown 主体 ============
|
||||
const renderDocumentBody = () => {
|
||||
if (isHtmlContent(content)) {
|
||||
return (
|
||||
<div
|
||||
ref={contentRef}
|
||||
className={`${proseClass} doc-content`}
|
||||
dangerouslySetInnerHTML={{ __html: processedHtmlContent }}
|
||||
/>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<div ref={contentRef} className={`${proseClass} doc-content`}>
|
||||
<MarkdownRenderer content={content} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
// ============ 主体决策 ============
|
||||
const renderBody = () => {
|
||||
if (loading) return renderLoading();
|
||||
if (!content || content.trim() === '') return renderEmpty();
|
||||
if (isUrl(content)) return renderUrlCard();
|
||||
return renderDocumentBody();
|
||||
};
|
||||
|
||||
// ============ 嵌入模式 ============
|
||||
if (isEmbedded) {
|
||||
return (
|
||||
<div
|
||||
ref={scrollContainerRef}
|
||||
onScroll={handleScroll}
|
||||
className='relative h-full overflow-y-auto px-5 sm:px-8 py-6 doc-fade-in scroll-smooth doc-scrollbar'
|
||||
>
|
||||
{renderBody()}
|
||||
|
||||
<button
|
||||
onClick={scrollToTop}
|
||||
className={`sticky bottom-3 ml-auto block p-2 bg-white/95 dark:bg-gray-800/95 backdrop-blur-md rounded-full shadow-lg border border-gray-200 dark:border-gray-700 hover:shadow-xl hover:-translate-y-0.5 hover:bg-white dark:hover:bg-gray-800 transition-all duration-200 ${
|
||||
showBackToTop ? 'opacity-100' : 'opacity-0 pointer-events-none'
|
||||
}`}
|
||||
aria-label={t('返回顶部')}
|
||||
>
|
||||
<ChevronUp size={16} className='text-gray-600 dark:text-gray-300' />
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ============ 页面模式 ============
|
||||
const hasRealContent =
|
||||
!loading && content && content.trim() !== '' && !isUrl(content);
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={rootRef}
|
||||
className='relative min-h-screen bg-gray-50 dark:bg-gray-950 doc-fade-in doc-page-root'
|
||||
>
|
||||
{/* 阅读进度条 */}
|
||||
<div
|
||||
className='fixed top-0 left-0 right-0 z-50 h-[2px] bg-gradient-to-r from-brand-from via-brand to-brand-to origin-left transition-transform duration-150 ease-out doc-no-print'
|
||||
style={{ transform: `scaleX(${readProgress / 100})` }}
|
||||
aria-hidden
|
||||
/>
|
||||
|
||||
{/* 顶部环境光 */}
|
||||
<div
|
||||
className='pointer-events-none absolute inset-x-0 top-0 h-[420px] overflow-hidden doc-no-print'
|
||||
aria-hidden
|
||||
>
|
||||
<div className='absolute -top-40 left-1/2 -translate-x-1/2 w-[900px] h-[500px] bg-gradient-to-b from-brand-from/[0.08] via-brand-via/[0.04] to-transparent dark:from-brand-from/[0.12] dark:via-brand-via/[0.06] blur-3xl rounded-full' />
|
||||
</div>
|
||||
|
||||
{/* Sticky Header */}
|
||||
<header className='sticky top-0 z-40 bg-white/85 dark:bg-gray-950/85 backdrop-blur-xl border-b border-gray-200/70 dark:border-gray-800/70 doc-no-print'>
|
||||
<div className='max-w-3xl mx-auto px-4 sm:px-6 h-14 flex items-center justify-between gap-2'>
|
||||
<button
|
||||
onClick={smartBack}
|
||||
className='group inline-flex items-center gap-1.5 px-2.5 py-1.5 -ml-2 text-sm font-medium text-gray-600 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-gray-800/80 rounded-md transition-colors shrink-0'
|
||||
>
|
||||
<ArrowLeft
|
||||
size={15}
|
||||
className='transition-transform group-hover:-translate-x-0.5'
|
||||
/>
|
||||
<span>{t('返回')}</span>
|
||||
</button>
|
||||
|
||||
<div className='flex items-center gap-2 text-gray-700 dark:text-gray-200 min-w-0'>
|
||||
<div className='w-6 h-6 rounded-md bg-brand/10 dark:bg-brand/20 flex items-center justify-center shrink-0'>
|
||||
<IconComponent
|
||||
size={13}
|
||||
className='text-brand-deep dark:text-brand-from'
|
||||
/>
|
||||
</div>
|
||||
<span className='text-sm font-semibold tracking-tight truncate'>
|
||||
{title}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* 打印按钮 */}
|
||||
<button
|
||||
onClick={() => window.print()}
|
||||
className='inline-flex items-center justify-center w-8 h-8 text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-gray-800/80 rounded-md transition-colors shrink-0'
|
||||
aria-label={t('打印')}
|
||||
title={t('打印')}
|
||||
>
|
||||
<Printer size={15} />
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{/* 文档主体 */}
|
||||
<main className='relative max-w-3xl mx-auto px-4 sm:px-6 py-8 sm:py-12'>
|
||||
{/* 文档标题区 */}
|
||||
{hasRealContent && (
|
||||
<div className='mb-6 doc-slide-up'>
|
||||
<div className='flex items-center gap-2 mb-3 doc-no-print'>
|
||||
<div className='w-1 h-5 bg-gradient-to-b from-brand-from to-brand-to rounded-full' />
|
||||
<span className='text-xs font-medium text-brand-deep dark:text-brand-from uppercase tracking-wider'>
|
||||
{t('法律文档')}
|
||||
</span>
|
||||
</div>
|
||||
<h1 className='text-2xl sm:text-3xl font-bold text-gray-900 dark:text-white mb-2 tracking-tight'>
|
||||
{title}
|
||||
</h1>
|
||||
<p className='text-xs text-gray-500 dark:text-gray-400'>
|
||||
{t('最后更新')}:{new Date().toLocaleDateString()}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 文档卡片 */}
|
||||
<article className='doc-card relative bg-white dark:bg-gray-900 rounded-xl border border-gray-200/80 dark:border-gray-800/80 shadow-[0_1px_2px_rgba(0,0,0,0.04),0_4px_24px_-12px_rgba(0,0,0,0.08)] dark:shadow-[0_1px_2px_rgba(0,0,0,0.3),0_8px_32px_-12px_rgba(0,0,0,0.4)] p-6 sm:p-10 doc-slide-up'>
|
||||
{renderBody()}
|
||||
</article>
|
||||
|
||||
{/* 底部返回入口 */}
|
||||
{!loading && (
|
||||
<div className='mt-8 flex justify-center doc-no-print'>
|
||||
<button
|
||||
onClick={smartBack}
|
||||
className='group inline-flex items-center gap-2 px-5 py-2 text-sm bg-white dark:bg-gray-900 hover:bg-gray-50 dark:hover:bg-gray-800/80 border border-gray-200 dark:border-gray-800 hover:border-gray-300 dark:hover:border-gray-700 rounded-lg text-gray-700 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white shadow-sm transition-all'
|
||||
>
|
||||
<ArrowLeft
|
||||
size={14}
|
||||
className='transition-transform group-hover:-translate-x-0.5'
|
||||
/>
|
||||
{t('返回')}
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</main>
|
||||
|
||||
{/* 返回顶部 FAB */}
|
||||
<button
|
||||
onClick={scrollToTop}
|
||||
className={`fixed bottom-6 right-6 z-50 p-2.5 bg-white/95 dark:bg-gray-800/95 backdrop-blur-md rounded-full shadow-lg border border-gray-200 dark:border-gray-700 hover:shadow-xl hover:-translate-y-0.5 hover:bg-white dark:hover:bg-gray-800 transition-all duration-200 doc-no-print ${
|
||||
showBackToTop
|
||||
? 'opacity-100 translate-y-0'
|
||||
: 'opacity-0 translate-y-2 pointer-events-none'
|
||||
}`}
|
||||
aria-label={t('返回顶部')}
|
||||
>
|
||||
<ChevronUp size={18} className='text-gray-600 dark:text-gray-300' />
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default DocumentRenderer;
|
||||
@@ -0,0 +1,282 @@
|
||||
/*
|
||||
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 React, { useEffect, useRef } from 'react';
|
||||
|
||||
const MapleBackground = () => {
|
||||
const canvasRef = useRef(null);
|
||||
|
||||
useEffect(() => {
|
||||
const canvas = canvasRef.current;
|
||||
const ctx = canvas.getContext('2d');
|
||||
let animationFrameId;
|
||||
let width, height;
|
||||
|
||||
// Realistic Maple Leaf Path Data (SVG path)
|
||||
const leafPathData =
|
||||
'M150.6,90.8c-5.8,1.6-11.3-1.6-14.9-5.3c-3.6-3.7-5.5-8.5-4.8-13.6c-0.6-2.6-1.5-5.1-2.9-7.4c-3.2-5.4-8.8-8.8-14.8-9.5 c-3.8-0.5-7.6,0.3-11.1,2.1c-0.8,0.4-1.6,0.9-2.5,1.5c-0.1-0.1-0.2-0.3-0.3-0.4c-3-5.2-7.8-9.1-13.4-10.9c-2.3-0.7-4.7-1.1-7-1.1 c-0.8,0-1.6,0-2.3,0.1c0.1-1.3,0.1-2.7-0.1-4c-0.4-3.4-1.7-6.5-3.6-9.1c-4.3-5.7-11.2-8.5-18.1-7.4c-6.8,1.1-12.2,6-14.3,12.7 c-0.6,1.9-0.8,3.9-0.7,5.9c-2.6-0.3-5.3-0.2-7.8,0.5c-6.2,1.5-11.2,6.1-13.6,12.1c-0.7,1.8-1.2,3.7-1.3,5.6c-0.8-0.6-1.7-1.1-2.6-1.6 c-3.5-1.8-7.3-2.6-11.1-2.1c-6.1,0.7-11.6,4.1-14.8,9.5c-1.4,2.3-2.3,4.8-2.9,7.4c0.7,5.1-1.2,9.9-4.8,13.6 c-3.6,3.7-9.1,6.9-14.9,5.3c-2.6-0.7-5.1-1.9-7.2-3.5c-1.3-1-2.3-2.3-3.1-3.7c-0.6,3.1-0.1,6.4,1.4,9.2c2.6,4.9,7.6,8.2,13,8.7 c3.5,0.3,6.9-0.5,9.9-2.1c0.4,2.5,1.2,4.8,2.5,6.9c2.6,4.3,6.8,7.3,11.6,8.4c0.8,0.2,1.6,0.3,2.4,0.3c0.7,0,1.3-0.1,2-0.2 c-0.1,1.1-0.1,2.3,0,3.4c0.6,5,3.6,9.2,8.1,11.5c4.5,2.3,9.8,2.3,14.3,0c1.7-0.9,3.2-2.1,4.4-3.5c0.8,3.1,2.6,5.8,5.1,7.8 c4.4,3.4,10.2,4.3,15.3,2.4c1.1-0.4,2.2-0.9,3.2-1.6l0.5,21.7c0.1,2.5,2.2,4.5,4.7,4.4c2.5-0.1,4.5-2.2,4.4-4.7l-0.5-22.6 c1.1,0.5,2.2,0.9,3.4,1.2c1.7,0.4,3.4,0.6,5.1,0.6c3.9,0,7.6-1.2,10.7-3.6c2.5-1.9,4.4-4.6,5.2-7.6c1.3,1.4,2.8,2.6,4.5,3.5 c4.5,2.3,9.8,2.3,14.3,0c4.5-2.3,7.5-6.5,8.1-11.5c0.1-1.1,0.1-2.3,0-3.4c0.7,0.1,1.3,0.2,2,0.2c0.8,0,1.6-0.1,2.4-0.3 c4.8-1.1,9-4.1,11.6-8.4c1.2-2.1,2.1-4.4,2.5-6.9c3.1,1.7,6.4,2.4,9.9,2.1c5.5-0.5,10.4-3.8,13-8.7c1.5-2.8,2-6.1,1.4-9.2 C157.9,87,156.9,88.3,155.6,89.3C153.5,90.9,153.2,90.1,150.6,90.8z';
|
||||
|
||||
const leafPath = new Path2D(leafPathData);
|
||||
|
||||
// 检测是否为移动设备
|
||||
const isMobile =
|
||||
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
|
||||
navigator.userAgent,
|
||||
);
|
||||
|
||||
// 简化的云朵类(性能优化版)
|
||||
class Cloud {
|
||||
constructor() {
|
||||
this.reset();
|
||||
this.x = Math.random() * width; // 随机初始位置
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.x = -150;
|
||||
this.y = Math.random() * (height * 0.3); // 屏幕上方 30%
|
||||
this.speed = Math.random() * 0.15 + 0.08;
|
||||
this.scale = Math.random() * 0.4 + 0.4;
|
||||
this.opacity = Math.random() * 0.2 + 0.3;
|
||||
}
|
||||
|
||||
update() {
|
||||
this.x += this.speed;
|
||||
if (this.x > width + 150) {
|
||||
this.reset();
|
||||
}
|
||||
}
|
||||
|
||||
draw(ctx) {
|
||||
ctx.save();
|
||||
ctx.translate(this.x, this.y);
|
||||
ctx.scale(this.scale, this.scale);
|
||||
ctx.globalAlpha = this.opacity;
|
||||
ctx.fillStyle = '#FFFFFF';
|
||||
|
||||
// 简化云朵:只用 3 个圆形(原版 4 个)
|
||||
ctx.beginPath();
|
||||
ctx.arc(0, 0, 25, 0, Math.PI * 2);
|
||||
ctx.arc(30, -8, 30, 0, Math.PI * 2);
|
||||
ctx.arc(55, 0, 25, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
|
||||
ctx.restore();
|
||||
}
|
||||
}
|
||||
|
||||
class Leaf {
|
||||
constructor() {
|
||||
this.init(true);
|
||||
}
|
||||
|
||||
init(randomY = false) {
|
||||
this.x = Math.random() * width;
|
||||
this.y = randomY ? Math.random() * height : -50;
|
||||
this.size = (Math.random() * 0.5 + 0.3) * 0.4; // Scaled down for the path size
|
||||
this.speed = Math.random() * 1.5 + 0.5;
|
||||
this.sway = Math.random() * 0.02 + 0.005;
|
||||
this.swayOffset = Math.random() * Math.PI * 2;
|
||||
this.rotation = Math.random() * Math.PI * 2;
|
||||
this.rotationSpeed = (Math.random() - 0.5) * 0.02;
|
||||
|
||||
// Realistic Autumn Colors
|
||||
const colors = [
|
||||
'#C0392B', // Dark Red
|
||||
'#E74C3C', // Red
|
||||
'#D35400', // Pumpkin
|
||||
'#E67E22', // Carrot
|
||||
'#F39C12', // Orange
|
||||
'#F1C40F', // Yellow
|
||||
'#A0522D', // Sienna (Brown)
|
||||
'#8B4513', // SaddleBrown
|
||||
];
|
||||
this.color = colors[Math.floor(Math.random() * colors.length)];
|
||||
}
|
||||
|
||||
update() {
|
||||
this.y += this.speed;
|
||||
this.x += Math.sin(this.swayOffset) * 0.8; // More gentle sway
|
||||
this.swayOffset += this.sway;
|
||||
this.rotation += this.rotationSpeed;
|
||||
|
||||
if (this.y > height + 50) {
|
||||
this.init();
|
||||
}
|
||||
}
|
||||
|
||||
draw(ctx) {
|
||||
ctx.save();
|
||||
ctx.translate(this.x, this.y);
|
||||
ctx.rotate(this.rotation);
|
||||
ctx.scale(this.size, this.size);
|
||||
|
||||
// Offset to center the path rotation
|
||||
ctx.translate(-75, -75);
|
||||
|
||||
// 添加轻微阴影以保留立体感(性能影响小)
|
||||
ctx.shadowColor = 'rgba(0,0,0,0.15)';
|
||||
ctx.shadowBlur = 3;
|
||||
ctx.shadowOffsetX = 1;
|
||||
ctx.shadowOffsetY = 1;
|
||||
|
||||
ctx.fillStyle = this.color;
|
||||
ctx.fill(leafPath);
|
||||
|
||||
// 移除阴影以避免影响叶脉
|
||||
ctx.shadowColor = 'transparent';
|
||||
|
||||
// 只在桌面端绘制叶脉,移动端跳过以提升性能
|
||||
if (!isMobile) {
|
||||
ctx.strokeStyle = 'rgba(0, 0, 0, 0.2)';
|
||||
ctx.lineWidth = 1.5;
|
||||
ctx.lineCap = 'round';
|
||||
|
||||
// 简化叶脉:绘制主脉和 2 条侧脉
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(78, 115);
|
||||
ctx.lineTo(78, 20);
|
||||
ctx.stroke();
|
||||
|
||||
// 上侧脉
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(78, 100);
|
||||
ctx.quadraticCurveTo(60, 80, 30, 45);
|
||||
ctx.stroke();
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(78, 100);
|
||||
ctx.quadraticCurveTo(96, 80, 125, 45);
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
ctx.restore();
|
||||
}
|
||||
}
|
||||
|
||||
let leaves = [];
|
||||
let clouds = [];
|
||||
// 根据设备性能自适应调整元素数量
|
||||
const LEAF_COUNT = isMobile ? 10 : 20;
|
||||
const CLOUD_COUNT = isMobile ? 2 : 3; // 简化版:移动端 2 朵,桌面端 3 朵
|
||||
|
||||
const initElements = () => {
|
||||
leaves = [];
|
||||
clouds = [];
|
||||
for (let i = 0; i < LEAF_COUNT; i++) {
|
||||
leaves.push(new Leaf());
|
||||
}
|
||||
for (let i = 0; i < CLOUD_COUNT; i++) {
|
||||
clouds.push(new Cloud());
|
||||
}
|
||||
};
|
||||
|
||||
const drawSkyAndField = () => {
|
||||
// 保留天空渐变(性能影响小,视觉提升大)
|
||||
const skyGrad = ctx.createLinearGradient(0, 0, 0, height);
|
||||
skyGrad.addColorStop(0, '#5CACEE');
|
||||
skyGrad.addColorStop(0.6, '#B0E0E6');
|
||||
skyGrad.addColorStop(1, '#E0F7FA');
|
||||
ctx.fillStyle = skyGrad;
|
||||
ctx.fillRect(0, 0, width, height);
|
||||
|
||||
// 绘制云朵(在山丘后面)
|
||||
clouds.forEach((cloud) => {
|
||||
cloud.update();
|
||||
cloud.draw(ctx);
|
||||
});
|
||||
|
||||
// 简化山丘:只保留 2 层以保持层次感
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(0, height * 0.85);
|
||||
ctx.bezierCurveTo(
|
||||
width * 0.4,
|
||||
height * 0.75,
|
||||
width * 0.6,
|
||||
height * 0.9,
|
||||
width,
|
||||
height * 0.82,
|
||||
);
|
||||
ctx.lineTo(width, height);
|
||||
ctx.lineTo(0, height);
|
||||
ctx.fillStyle = '#8FBC8F';
|
||||
ctx.fill();
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(0, height);
|
||||
ctx.lineTo(0, height * 0.95);
|
||||
ctx.bezierCurveTo(
|
||||
width * 0.5,
|
||||
height * 1.05,
|
||||
width * 0.8,
|
||||
height * 0.92,
|
||||
width,
|
||||
height * 0.96,
|
||||
);
|
||||
ctx.lineTo(width, height);
|
||||
ctx.fillStyle = '#556B2F';
|
||||
ctx.fill();
|
||||
};
|
||||
|
||||
const animate = () => {
|
||||
ctx.clearRect(0, 0, width, height);
|
||||
|
||||
drawSkyAndField();
|
||||
|
||||
leaves.forEach((leaf) => {
|
||||
leaf.update();
|
||||
leaf.draw(ctx);
|
||||
});
|
||||
|
||||
animationFrameId = requestAnimationFrame(animate);
|
||||
};
|
||||
|
||||
const resize = () => {
|
||||
width = window.innerWidth;
|
||||
height = window.innerHeight;
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
};
|
||||
|
||||
window.addEventListener('resize', resize);
|
||||
resize();
|
||||
initElements();
|
||||
animate();
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('resize', resize);
|
||||
cancelAnimationFrame(animationFrameId);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<canvas
|
||||
ref={canvasRef}
|
||||
style={{
|
||||
position: 'fixed',
|
||||
top: 0,
|
||||
left: 0,
|
||||
zIndex: -1,
|
||||
width: '100vw',
|
||||
height: '100vh',
|
||||
pointerEvents: 'none',
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default MapleBackground;
|
||||
@@ -0,0 +1,181 @@
|
||||
/*
|
||||
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 React, { useEffect, useRef } from 'react';
|
||||
import {
|
||||
Select,
|
||||
Spin,
|
||||
Typography,
|
||||
Empty,
|
||||
Tag,
|
||||
Tooltip,
|
||||
} from '@douyinfe/semi-ui';
|
||||
import { Lock } from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useModelSelector } from '../../hooks/models/useModelSelector';
|
||||
import { MODEL_CATEGORY_NAMES } from '../../constants';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
/**
|
||||
* 模型选择器组件
|
||||
* @param {string} category - 模型分类(可选)
|
||||
* @param {string} value - 当前选中的模型ID或名称
|
||||
* @param {function} onChange - 模型变化回调
|
||||
* @param {string} placeholder - 占位文本
|
||||
* @param {boolean} disabled - 是否禁用
|
||||
* @param {string} size - 尺寸
|
||||
*/
|
||||
const ModelSelector = ({
|
||||
category = null,
|
||||
value,
|
||||
onChange,
|
||||
placeholder,
|
||||
disabled = false,
|
||||
size = 'default',
|
||||
showCategoryLabel = false,
|
||||
// 加载完成后向父组件回传模型列表(用于父组件按 name 反查 model 对象,避免重复 fetch)
|
||||
onModelsLoaded,
|
||||
// 是否在初次加载完成后自动选中第一个模型(外部需要"先回填再生成"时可关闭)
|
||||
autoSelectFirst = true,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { models, loading, selectedModel, setSelectedModel } =
|
||||
useModelSelector(category);
|
||||
const isInitializedRef = useRef(false);
|
||||
|
||||
// 当模型加载完成时,自动选择第一个「可调用」模型(避免默认选中锁定模型)
|
||||
useEffect(() => {
|
||||
if (!loading && models.length > 0 && !isInitializedRef.current) {
|
||||
if (autoSelectFirst) {
|
||||
const firstModel = models.find((m) => !m.level_locked);
|
||||
setSelectedModel(firstModel || null);
|
||||
if (firstModel && onChange) {
|
||||
onChange(firstModel);
|
||||
}
|
||||
}
|
||||
isInitializedRef.current = true;
|
||||
}
|
||||
}, [loading, models, setSelectedModel, onChange, autoSelectFirst]);
|
||||
|
||||
// 把加载好的模型列表传给父组件
|
||||
useEffect(() => {
|
||||
if (!onModelsLoaded) return;
|
||||
if (loading) return;
|
||||
onModelsLoaded(models);
|
||||
}, [models, loading, onModelsLoaded]);
|
||||
|
||||
// 处理模型选择:锁定(仅可见)模型不可选中
|
||||
const handleChange = (selectedValue) => {
|
||||
const model = models.find(
|
||||
(m) => m.id === selectedValue || m.model_name === selectedValue,
|
||||
);
|
||||
if (model && !model.level_locked) {
|
||||
setSelectedModel(model);
|
||||
if (onChange) {
|
||||
onChange(model);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 渲染模型选项:level_state=visible 展示锁态并禁用
|
||||
const renderOption = (model) => {
|
||||
const locked = model.level_locked;
|
||||
return (
|
||||
<Select.Option
|
||||
key={model.id}
|
||||
value={model.id}
|
||||
disabled={locked}
|
||||
showTick={!locked}
|
||||
>
|
||||
<div style={{ display: 'flex', alignItems: 'center' }}>
|
||||
<Text strong type={locked ? 'tertiary' : undefined}>
|
||||
{model.model_name}
|
||||
</Text>
|
||||
{model.vendor && (
|
||||
<Text type='secondary' size='small' style={{ marginLeft: '8px' }}>
|
||||
({model.vendor})
|
||||
</Text>
|
||||
)}
|
||||
{locked && (
|
||||
<Tooltip content={t('当前等级无权调用此模型,升级等级后可用')}>
|
||||
<Tag
|
||||
size='small'
|
||||
color='grey'
|
||||
prefixIcon={<Lock size={12} />}
|
||||
style={{ marginLeft: '8px' }}
|
||||
>
|
||||
{t('仅可见')}
|
||||
</Tag>
|
||||
</Tooltip>
|
||||
)}
|
||||
</div>
|
||||
</Select.Option>
|
||||
);
|
||||
};
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div style={{ textAlign: 'center', padding: '20px' }}>
|
||||
<Spin />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (models.length === 0) {
|
||||
return (
|
||||
<Empty
|
||||
title={t('暂无可用模型')}
|
||||
description={
|
||||
category
|
||||
? `${MODEL_CATEGORY_NAMES[category]}类模型暂无可用`
|
||||
: t('请先添加模型')
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{showCategoryLabel && category && (
|
||||
<Text
|
||||
type='secondary'
|
||||
size='small'
|
||||
style={{ display: 'block', marginBottom: '4px' }}
|
||||
>
|
||||
{MODEL_CATEGORY_NAMES[category]}
|
||||
</Text>
|
||||
)}
|
||||
<Select
|
||||
value={value || selectedModel?.id}
|
||||
onChange={handleChange}
|
||||
placeholder={placeholder || t('请选择模型')}
|
||||
disabled={disabled}
|
||||
size={size}
|
||||
style={{ width: '100%' }}
|
||||
filter
|
||||
showClear
|
||||
>
|
||||
{models.map(renderOption)}
|
||||
</Select>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ModelSelector;
|
||||
@@ -0,0 +1,532 @@
|
||||
/*
|
||||
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 React, { useEffect, useRef } from 'react';
|
||||
|
||||
/**
|
||||
* 深海八爪 · 幽光 —— 登录页背景动画
|
||||
*
|
||||
* 七层景深(由后到前):
|
||||
* 1. 景深渐变背景(浅→深,带 vignette)
|
||||
* 2. 顶部光柱(brand-primary,缓 breathing)
|
||||
* 3. 中层浮游粒子(brand-primary 微辉光)
|
||||
* 4. 触手剪影 + 吸盘 Mexican wave 发光(右下角)
|
||||
* 5. 上升气泡(白色,正弦摆动)
|
||||
* 6. 前景闪烁粒子(brand-gradient-to,快移视差)
|
||||
* 7. 生命脉冲(每 6-10s 一次环形扩散)
|
||||
*
|
||||
* 立体感来源:
|
||||
* - 鼠标视差(各层不同步移动,后层慢、前层快)
|
||||
* - 触手 sucker 波浪式呼吸(像 Mexican wave)
|
||||
* - 偶发生命脉冲(节奏惊喜)
|
||||
*
|
||||
* 主题适配:
|
||||
* - 所有发光层用 --brand-primary / --brand-gradient-to(CSS 变量实时读取)
|
||||
* - 暗色模式背景换为午夜蓝→墨黑
|
||||
* - prefers-reduced-motion:关闭脉冲 / breathing / 视差,只留缓慢气泡
|
||||
*
|
||||
* 性能:
|
||||
* - 单 canvas + 单 rAF 循环
|
||||
* - 设备自适应粒子数(移动端减半)
|
||||
* - 主题色每 500ms 读一次(不是每帧)
|
||||
*/
|
||||
|
||||
// ─── 工具函数 ─────────────────────────────────────────────────
|
||||
const hexToRgb = (hex) => {
|
||||
if (!hex) return { r: 99, g: 102, b: 241 }; // brand-primary 兜底
|
||||
let h = hex.replace('#', '').trim();
|
||||
if (h.length === 3) h = h.split('').map((c) => c + c).join('');
|
||||
if (h.length === 8) h = h.slice(0, 6); // 忽略 alpha
|
||||
if (!/^[0-9a-fA-F]{6}$/.test(h)) return { r: 99, g: 102, b: 241 };
|
||||
const num = parseInt(h, 16);
|
||||
return { r: (num >> 16) & 255, g: (num >> 8) & 255, b: num & 255 };
|
||||
};
|
||||
const rgba = (c, a) => `rgba(${c.r}, ${c.g}, ${c.b}, ${a})`;
|
||||
const lerp = (a, b, t) => a + (b - a) * t;
|
||||
const easeOutCubic = (t) => 1 - Math.pow(1 - t, 3);
|
||||
// 三阶 Bezier 求 t 处坐标(给触手沿曲线放置吸盘用)
|
||||
const bezierPoint = (p0, p1, p2, p3, t) => {
|
||||
const mt = 1 - t;
|
||||
return mt * mt * mt * p0 + 3 * mt * mt * t * p1 + 3 * mt * t * t * p2 + t * t * t * p3;
|
||||
};
|
||||
|
||||
// ─── 粒子类 ──────────────────────────────────────────────────
|
||||
class Plankton {
|
||||
constructor(width, height) {
|
||||
this.w = width;
|
||||
this.h = height;
|
||||
this.reset(true);
|
||||
}
|
||||
reset(randomY = false) {
|
||||
this.x = Math.random() * this.w;
|
||||
this.y = randomY ? Math.random() * this.h : Math.random() < 0.5 ? -10 : this.h + 10;
|
||||
this.size = Math.random() * 1.5 + 0.5;
|
||||
this.vx = (Math.random() - 0.5) * 0.2;
|
||||
this.vy = (Math.random() - 0.5) * 0.15;
|
||||
this.alpha = Math.random() * 0.35 + 0.2;
|
||||
this.phase = Math.random() * Math.PI * 2;
|
||||
}
|
||||
update() {
|
||||
this.x += this.vx;
|
||||
this.y += this.vy + Math.sin(this.phase) * 0.15;
|
||||
this.phase += 0.015;
|
||||
if (this.x < -20 || this.x > this.w + 20 || this.y < -20 || this.y > this.h + 20) this.reset();
|
||||
}
|
||||
resize(w, h) {
|
||||
this.w = w;
|
||||
this.h = h;
|
||||
}
|
||||
draw(ctx, ox, oy, color) {
|
||||
const x = this.x + ox;
|
||||
const y = this.y + oy;
|
||||
const r = this.size * 4;
|
||||
const grad = ctx.createRadialGradient(x, y, 0, x, y, r);
|
||||
grad.addColorStop(0, rgba(color, this.alpha));
|
||||
grad.addColorStop(1, rgba(color, 0));
|
||||
ctx.fillStyle = grad;
|
||||
ctx.beginPath();
|
||||
ctx.arc(x, y, r, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
ctx.fillStyle = `rgba(255, 255, 255, ${this.alpha * 0.5})`;
|
||||
ctx.beginPath();
|
||||
ctx.arc(x, y, this.size, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
|
||||
class Sparkle extends Plankton {
|
||||
reset(randomY = false) {
|
||||
super.reset(randomY);
|
||||
this.size = Math.random() * 2.2 + 0.8;
|
||||
this.vx *= 2.5;
|
||||
this.vy *= 2.5;
|
||||
this.alpha = Math.random() * 0.5 + 0.35;
|
||||
}
|
||||
}
|
||||
|
||||
class Bubble {
|
||||
constructor(width, height) {
|
||||
this.w = width;
|
||||
this.h = height;
|
||||
this.reset(true);
|
||||
}
|
||||
reset(randomY = false) {
|
||||
this.x = Math.random() * this.w;
|
||||
this.y = randomY ? Math.random() * this.h : this.h + 30;
|
||||
this.size = Math.random() * 8 + 3;
|
||||
this.vy = -(Math.random() * 0.7 + 0.3);
|
||||
this.swayPhase = Math.random() * Math.PI * 2;
|
||||
this.alpha = Math.random() * 0.4 + 0.3;
|
||||
}
|
||||
update() {
|
||||
this.y += this.vy;
|
||||
this.x += Math.sin(this.swayPhase) * 0.5;
|
||||
this.swayPhase += 0.03;
|
||||
if (this.y < -30) this.reset(false);
|
||||
}
|
||||
resize(w, h) {
|
||||
this.w = w;
|
||||
this.h = h;
|
||||
}
|
||||
draw(ctx, ox, oy) {
|
||||
const x = this.x + ox;
|
||||
const y = this.y + oy;
|
||||
ctx.strokeStyle = `rgba(255, 255, 255, ${this.alpha * 0.6})`;
|
||||
ctx.lineWidth = 1;
|
||||
ctx.beginPath();
|
||||
ctx.arc(x, y, this.size, 0, Math.PI * 2);
|
||||
ctx.stroke();
|
||||
ctx.fillStyle = `rgba(255, 255, 255, ${this.alpha * 0.5})`;
|
||||
ctx.beginPath();
|
||||
ctx.arc(x - this.size * 0.3, y - this.size * 0.3, this.size * 0.28, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
|
||||
class LightPillar {
|
||||
constructor(width, index, total) {
|
||||
this.idx = index;
|
||||
this.total = total;
|
||||
// 这些参数只在构造时随机一次,resize 时不能重抽,
|
||||
// 否则窗口拖拽时光柱会"跳"位置和宽度。
|
||||
this.offset = (Math.random() - 0.5) * 80;
|
||||
this.width = 120 + Math.random() * 100;
|
||||
this.angle = -0.18 + Math.random() * 0.36;
|
||||
this.intensity = 0.05 + Math.random() * 0.05;
|
||||
this.breathPhase = Math.random() * Math.PI * 2;
|
||||
this.resize(width);
|
||||
}
|
||||
resize(width) {
|
||||
// 只更新跟 width 相关的 baseX 基准,固定 offset 保持不变
|
||||
this.baseX = ((this.idx + 0.5) / this.total) * width + this.offset;
|
||||
}
|
||||
update(breathOn) {
|
||||
if (breathOn) this.breathPhase += 0.003;
|
||||
}
|
||||
draw(ctx, ox, height, color) {
|
||||
const breath = 0.6 + Math.sin(this.breathPhase) * 0.4;
|
||||
const x = this.baseX + ox * 0.3;
|
||||
ctx.save();
|
||||
ctx.translate(x, 0);
|
||||
ctx.rotate(this.angle);
|
||||
const grad = ctx.createLinearGradient(0, 0, 0, height * 1.3);
|
||||
grad.addColorStop(0, rgba(color, this.intensity * breath));
|
||||
grad.addColorStop(1, rgba(color, 0));
|
||||
ctx.fillStyle = grad;
|
||||
ctx.fillRect(-this.width / 2, -50, this.width, height * 1.4);
|
||||
ctx.restore();
|
||||
}
|
||||
}
|
||||
|
||||
class Tentacle {
|
||||
constructor(width, height, suckerCount) {
|
||||
this.w = width;
|
||||
this.h = height;
|
||||
this.suckerCount = suckerCount;
|
||||
this.suckerPhases = Array.from({ length: suckerCount }, (_, i) => i * 0.6);
|
||||
this.swayPhase = 0;
|
||||
}
|
||||
resize(w, h) {
|
||||
this.w = w;
|
||||
this.h = h;
|
||||
}
|
||||
update() {
|
||||
this.swayPhase += 0.004;
|
||||
for (let i = 0; i < this.suckerCount; i++) this.suckerPhases[i] += 0.045;
|
||||
}
|
||||
draw(ctx, ox, oy, color, isDark) {
|
||||
const baseX = this.w;
|
||||
const baseY = this.h;
|
||||
const length = Math.min(this.w, this.h) * 0.7;
|
||||
const sway = Math.sin(this.swayPhase) * 40;
|
||||
// tip 跟随鼠标视差;base 锚定在角落
|
||||
const endX = baseX - length * 0.5 + sway + ox;
|
||||
const endY = baseY - length * 0.7 + oy;
|
||||
const c2X = baseX - length * 0.4 + sway * 1.4 + ox * 0.7;
|
||||
const c2Y = baseY - length * 0.55 + oy * 0.7;
|
||||
const c1X = baseX - length * 0.1 + ox * 0.3;
|
||||
const c1Y = baseY - length * 0.3 + oy * 0.3;
|
||||
|
||||
// 分段绘制以做出尖端渐细的效果
|
||||
const segs = 32;
|
||||
const taperFrom = 38;
|
||||
const taperTo = 8;
|
||||
ctx.strokeStyle = isDark ? 'rgba(0, 5, 15, 0.55)' : 'rgba(0, 25, 40, 0.45)';
|
||||
ctx.lineCap = 'round';
|
||||
let prevX = baseX;
|
||||
let prevY = baseY;
|
||||
for (let i = 1; i <= segs; i++) {
|
||||
const t = i / segs;
|
||||
const x = bezierPoint(baseX, c1X, c2X, endX, t);
|
||||
const y = bezierPoint(baseY, c1Y, c2Y, endY, t);
|
||||
ctx.lineWidth = lerp(taperFrom, taperTo, t);
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(prevX, prevY);
|
||||
ctx.lineTo(x, y);
|
||||
ctx.stroke();
|
||||
prevX = x;
|
||||
prevY = y;
|
||||
}
|
||||
|
||||
// 吸盘:沿曲线均匀分布,各自相位错开形成 Mexican wave
|
||||
for (let i = 0; i < this.suckerCount; i++) {
|
||||
const t = 0.18 + (i / (this.suckerCount - 1)) * 0.78;
|
||||
const x = bezierPoint(baseX, c1X, c2X, endX, t);
|
||||
const y = bezierPoint(baseY, c1Y, c2Y, endY, t);
|
||||
const breath = 0.5 + Math.sin(this.suckerPhases[i]) * 0.5;
|
||||
const glow = 5 + breath * 8;
|
||||
// 外层光晕
|
||||
const grad = ctx.createRadialGradient(x, y, 0, x, y, glow * 3);
|
||||
grad.addColorStop(0, rgba(color, 0.6 + breath * 0.3));
|
||||
grad.addColorStop(0.4, rgba(color, 0.3 + breath * 0.2));
|
||||
grad.addColorStop(1, rgba(color, 0));
|
||||
ctx.fillStyle = grad;
|
||||
ctx.beginPath();
|
||||
ctx.arc(x, y, glow * 3, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
// 内核亮点
|
||||
ctx.fillStyle = `rgba(255, 255, 255, ${0.7 + breath * 0.3})`;
|
||||
ctx.beginPath();
|
||||
ctx.arc(x, y, glow * 0.45, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class LifePulse {
|
||||
constructor(width, height) {
|
||||
this.w = width;
|
||||
this.h = height;
|
||||
this.active = false;
|
||||
this.startT = 0;
|
||||
this.nextT = performance.now() + 4000 + Math.random() * 3000;
|
||||
this.duration = 3200;
|
||||
}
|
||||
resize(w, h) {
|
||||
this.w = w;
|
||||
this.h = h;
|
||||
}
|
||||
update(now, enabled) {
|
||||
if (!enabled) return;
|
||||
if (!this.active && now >= this.nextT) {
|
||||
// 从屏幕外随机一侧触发
|
||||
const side = Math.floor(Math.random() * 4);
|
||||
const m = 100;
|
||||
if (side === 0) { this.ox = Math.random() * this.w; this.oy = -m; }
|
||||
else if (side === 1) { this.ox = this.w + m; this.oy = Math.random() * this.h; }
|
||||
else if (side === 2) { this.ox = Math.random() * this.w; this.oy = this.h + m; }
|
||||
else { this.ox = -m; this.oy = Math.random() * this.h; }
|
||||
this.active = true;
|
||||
this.startT = now;
|
||||
this.maxR = Math.hypot(this.w, this.h) * 0.7;
|
||||
}
|
||||
if (this.active && now - this.startT >= this.duration) {
|
||||
this.active = false;
|
||||
this.nextT = now + 6000 + Math.random() * 4000;
|
||||
}
|
||||
}
|
||||
draw(ctx, now, color) {
|
||||
if (!this.active) return;
|
||||
const p = (now - this.startT) / this.duration;
|
||||
const radius = this.maxR * easeOutCubic(p);
|
||||
const alpha = p < 0.5 ? p * 2 * 0.35 : (1 - p) * 2 * 0.35;
|
||||
const inner = Math.max(0, radius - 50);
|
||||
const outer = radius + 50;
|
||||
const grad = ctx.createRadialGradient(this.ox, this.oy, inner, this.ox, this.oy, outer);
|
||||
grad.addColorStop(0, rgba(color, 0));
|
||||
grad.addColorStop(0.5, rgba(color, alpha));
|
||||
grad.addColorStop(1, rgba(color, 0));
|
||||
ctx.fillStyle = grad;
|
||||
ctx.fillRect(0, 0, this.w, this.h);
|
||||
}
|
||||
}
|
||||
|
||||
// ─── 主题 / 模式读取 ────────────────────────────────────────
|
||||
const readTheme = () => {
|
||||
const cs = getComputedStyle(document.documentElement);
|
||||
const get = (k, fallback) => {
|
||||
const v = cs.getPropertyValue(k).trim();
|
||||
return v || fallback;
|
||||
};
|
||||
return {
|
||||
primary: hexToRgb(get('--brand-primary', '#1668dc')),
|
||||
accent: hexToRgb(get('--brand-gradient-to', '#0958d9')),
|
||||
};
|
||||
};
|
||||
const detectDark = () => {
|
||||
if (document.documentElement.classList.contains('dark')) return true;
|
||||
if (document.body && document.body.getAttribute('theme-mode') === 'dark') return true;
|
||||
// ThemeContext 在浅色模式会移除上面两个标记,此时必须先看用户显式选择,
|
||||
// 否则"强制浅色 + 系统深色"会被 prefers-color-scheme 兜底误判成暗色
|
||||
try {
|
||||
const stored = localStorage.getItem('theme-mode');
|
||||
if (stored === 'dark') return true;
|
||||
if (stored === 'light') return false;
|
||||
} catch {
|
||||
// localStorage 不可用(隐私模式等)时继续走系统偏好
|
||||
}
|
||||
return window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||
};
|
||||
|
||||
// ─── 组件 ─────────────────────────────────────────────────
|
||||
const OceanBackground = () => {
|
||||
const canvasRef = useRef(null);
|
||||
|
||||
useEffect(() => {
|
||||
const canvas = canvasRef.current;
|
||||
if (!canvas) return;
|
||||
const ctx = canvas.getContext('2d');
|
||||
let frameId = 0;
|
||||
let themeTickId = 0;
|
||||
|
||||
let width = window.innerWidth;
|
||||
let height = window.innerHeight;
|
||||
const dpr = Math.min(window.devicePixelRatio || 1, 1.5); // 上限避免移动端开销
|
||||
|
||||
// 设备 / 偏好检测
|
||||
const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
|
||||
navigator.userAgent,
|
||||
);
|
||||
const reducedMotion =
|
||||
window.matchMedia &&
|
||||
window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||
|
||||
// 元素数量自适应。宽矩形光柱左右边缘无法自然羽化,会形成明显条带,统一关闭。
|
||||
const COUNT = reducedMotion
|
||||
? { plankton: 25, sparkle: 0, bubble: 6, pillar: 0 }
|
||||
: isMobile
|
||||
? { plankton: 40, sparkle: 12, bubble: 10, pillar: 0 }
|
||||
: { plankton: 80, sparkle: 28, bubble: 16, pillar: 0 };
|
||||
|
||||
// 主题色 + 暗色,500ms 一更新(getComputedStyle 不算贵,但没必要每帧)
|
||||
let theme = readTheme();
|
||||
let isDark = detectDark();
|
||||
themeTickId = setInterval(() => {
|
||||
theme = readTheme();
|
||||
isDark = detectDark();
|
||||
}, 500);
|
||||
|
||||
// 鼠标视差状态
|
||||
let mouseTargetX = 0;
|
||||
let mouseTargetY = 0;
|
||||
let mouseX = 0;
|
||||
let mouseY = 0;
|
||||
const onMouseMove = (e) => {
|
||||
if (reducedMotion) return;
|
||||
mouseTargetX = (e.clientX / width - 0.5) * 2;
|
||||
mouseTargetY = (e.clientY / height - 0.5) * 2;
|
||||
};
|
||||
|
||||
// 实例化
|
||||
const plankton = Array.from({ length: COUNT.plankton }, () => new Plankton(width, height));
|
||||
const sparkles = Array.from({ length: COUNT.sparkle }, () => new Sparkle(width, height));
|
||||
const bubbles = Array.from({ length: COUNT.bubble }, () => new Bubble(width, height));
|
||||
const pillars = Array.from(
|
||||
{ length: COUNT.pillar },
|
||||
(_, i) => new LightPillar(width, i, COUNT.pillar || 1),
|
||||
);
|
||||
const tentacle = reducedMotion
|
||||
? null
|
||||
: new Tentacle(width, height, isMobile ? 6 : 8);
|
||||
const pulse = new LifePulse(width, height);
|
||||
|
||||
// ─ resize ─────────────────────────
|
||||
const resize = () => {
|
||||
width = window.innerWidth;
|
||||
height = window.innerHeight;
|
||||
canvas.width = width * dpr;
|
||||
canvas.height = height * dpr;
|
||||
canvas.style.width = width + 'px';
|
||||
canvas.style.height = height + 'px';
|
||||
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
||||
plankton.forEach((p) => p.resize(width, height));
|
||||
sparkles.forEach((p) => p.resize(width, height));
|
||||
bubbles.forEach((b) => b.resize(width, height));
|
||||
pillars.forEach((p) => p.resize(width));
|
||||
if (tentacle) tentacle.resize(width, height);
|
||||
pulse.resize(width, height);
|
||||
};
|
||||
|
||||
// ─ 景深渐变背景 ───────────────────────
|
||||
const drawBackground = () => {
|
||||
// 主渐变:浅色 = 水青→深 teal,暗色 = 午夜蓝→墨黑
|
||||
const grad = ctx.createLinearGradient(0, 0, 0, height);
|
||||
if (isDark) {
|
||||
grad.addColorStop(0, '#0d1f33');
|
||||
grad.addColorStop(0.5, '#0a1525');
|
||||
grad.addColorStop(1, '#02060d');
|
||||
} else {
|
||||
grad.addColorStop(0, '#b8e0e8');
|
||||
grad.addColorStop(0.45, '#4a8fa8');
|
||||
grad.addColorStop(1, '#0d3854');
|
||||
}
|
||||
ctx.fillStyle = grad;
|
||||
ctx.fillRect(0, 0, width, height);
|
||||
|
||||
// 四角 vignette,加强深度感
|
||||
const cx = width / 2;
|
||||
const cy = height / 2;
|
||||
const r0 = Math.min(width, height) * 0.35;
|
||||
const r1 = Math.max(width, height) * 0.75;
|
||||
const vig = ctx.createRadialGradient(cx, cy, r0, cx, cy, r1);
|
||||
vig.addColorStop(0, 'rgba(0, 0, 0, 0)');
|
||||
vig.addColorStop(1, isDark ? 'rgba(0, 0, 0, 0.55)' : 'rgba(0, 10, 25, 0.35)');
|
||||
ctx.fillStyle = vig;
|
||||
ctx.fillRect(0, 0, width, height);
|
||||
};
|
||||
|
||||
// ─ 主循环 ────────────────────────────
|
||||
const animate = () => {
|
||||
const now = performance.now();
|
||||
|
||||
// 鼠标视差 lerp(reducedMotion 时跳过)
|
||||
if (!reducedMotion) {
|
||||
mouseX = lerp(mouseX, mouseTargetX, 0.05);
|
||||
mouseY = lerp(mouseY, mouseTargetY, 0.05);
|
||||
}
|
||||
|
||||
drawBackground();
|
||||
|
||||
// Layer 2: 光柱(后景,视差最少)
|
||||
pillars.forEach((p) => {
|
||||
p.update(!reducedMotion);
|
||||
p.draw(ctx, mouseX * 10, height, theme.primary);
|
||||
});
|
||||
|
||||
// Layer 3: 中层浮游(视差中等)
|
||||
plankton.forEach((p) => {
|
||||
p.update();
|
||||
p.draw(ctx, mouseX * 18, mouseY * 12, theme.primary);
|
||||
});
|
||||
|
||||
// Layer 4: 触手(视差中前)
|
||||
if (tentacle) {
|
||||
tentacle.update();
|
||||
tentacle.draw(ctx, mouseX * 25, mouseY * 18, theme.primary, isDark);
|
||||
}
|
||||
|
||||
// Layer 5: 气泡(视差中前)
|
||||
bubbles.forEach((b) => {
|
||||
b.update();
|
||||
b.draw(ctx, mouseX * 30, mouseY * 20);
|
||||
});
|
||||
|
||||
// Layer 6: 前景闪烁粒子(视差最大,给"动感")
|
||||
sparkles.forEach((s) => {
|
||||
s.update();
|
||||
s.draw(ctx, mouseX * 40, mouseY * 28, theme.accent);
|
||||
});
|
||||
|
||||
// Layer 7: 生命脉冲(reducedMotion 时不启用)
|
||||
pulse.update(now, !reducedMotion);
|
||||
pulse.draw(ctx, now, theme.primary);
|
||||
|
||||
frameId = requestAnimationFrame(animate);
|
||||
};
|
||||
|
||||
window.addEventListener('resize', resize);
|
||||
window.addEventListener('mousemove', onMouseMove);
|
||||
resize();
|
||||
animate();
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('resize', resize);
|
||||
window.removeEventListener('mousemove', onMouseMove);
|
||||
cancelAnimationFrame(frameId);
|
||||
clearInterval(themeTickId);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<canvas
|
||||
ref={canvasRef}
|
||||
style={{
|
||||
position: 'fixed',
|
||||
top: 0,
|
||||
left: 0,
|
||||
zIndex: -1,
|
||||
width: '100vw',
|
||||
height: '100vh',
|
||||
pointerEvents: 'none',
|
||||
}}
|
||||
aria-hidden='true'
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default OceanBackground;
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
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 React from 'react';
|
||||
|
||||
/**
|
||||
* 统一页面背景层 —— 所有路由级页面 shell 的唯一背景来源。
|
||||
*
|
||||
* 设计目标(详见 docs/11-前端与体验中心/03-主题色配置化改造方案.md):
|
||||
* 1. 可管理:颜色全部走 bg-glow-* CSS 变量,管理员在
|
||||
* 系统设置 → 主题设置 → 背景晕染 调一处,全场所有页面同步生效。
|
||||
* 2. 单层:每个可视页面只有一层背景。父 shell 渲染本组件,
|
||||
* 嵌套子页面用 embedded 开关跳过自身背景,避免双层叠加。
|
||||
* 3. 一致:from/to 两 stop,强度统一刻度。
|
||||
*
|
||||
* 两种强度:
|
||||
* subtle(默认)—— 后台 / 管理 / 列表类页面:2 个角落光斑 blur-3xl,克制。
|
||||
* rich —— 沉浸式页面(对话 / 生成):3 个大光球 blur-[100px],更强。
|
||||
*
|
||||
* 暗色无需 dark: 前缀切换颜色 —— bg-glow-*-rgb 变量本身随浅/暗级联,
|
||||
* 仅在需要"暗色更克制"时用 dark: 降低 alpha。
|
||||
*
|
||||
* 用法:放在一个 `relative` 容器内作为第一个子元素,内容用 `relative z-10` 叠其上。
|
||||
* <div className='relative ...'>
|
||||
* <PageBackground grid animate />
|
||||
* <div className='relative z-10'>{children}</div>
|
||||
* </div>
|
||||
*/
|
||||
export default function PageBackground({
|
||||
variant = 'subtle',
|
||||
grid = false,
|
||||
animate = false,
|
||||
className = '',
|
||||
}) {
|
||||
const pulse = animate ? 'animate-pulse motion-reduce:animate-none' : '';
|
||||
return (
|
||||
<div
|
||||
className={`absolute inset-0 overflow-hidden pointer-events-none ${className}`}
|
||||
aria-hidden='true'
|
||||
>
|
||||
{variant === 'rich' ? (
|
||||
<>
|
||||
{/* 基础渐变 —— 顶部→底部晕染(顶起色、底止色、中段通透) */}
|
||||
<div className='absolute inset-0 bg-gradient-to-b from-bg-glow-from/15 via-transparent to-bg-glow-to/20 dark:from-bg-glow-from/10 dark:via-transparent dark:to-bg-glow-to/15' />
|
||||
{/* 3 个沉浸式大光球 */}
|
||||
<div
|
||||
className={`absolute top-[5%] right-[10%] w-[400px] h-[400px] rounded-full bg-gradient-to-br from-bg-glow-from/15 to-bg-glow-to/15 dark:from-bg-glow-from/10 dark:to-bg-glow-to/10 blur-[100px] ${pulse}`}
|
||||
/>
|
||||
<div
|
||||
className={`absolute bottom-[10%] left-[5%] w-[350px] h-[350px] rounded-full bg-gradient-to-br from-bg-glow-from/15 to-bg-glow-to/15 dark:from-bg-glow-from/10 dark:to-bg-glow-to/10 blur-[100px] ${pulse}`}
|
||||
style={animate ? { animationDelay: '1.5s' } : undefined}
|
||||
/>
|
||||
<div
|
||||
className={`absolute top-[40%] left-[35%] w-[250px] h-[250px] rounded-full bg-gradient-to-br from-bg-glow-from/10 to-bg-glow-to/10 dark:from-bg-glow-from/5 dark:to-bg-glow-to/5 blur-[80px] ${pulse}`}
|
||||
style={animate ? { animationDelay: '3s' } : undefined}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
{/* 基础渐变 —— 顶部→底部晕染(顶起色、底止色、中段通透) */}
|
||||
<div className='absolute inset-0 bg-gradient-to-b from-bg-glow-from/10 via-transparent to-bg-glow-to/20 dark:from-bg-glow-from/10 dark:via-transparent dark:to-bg-glow-to/15' />
|
||||
{/* 2 个角落光斑 */}
|
||||
<div
|
||||
className={`absolute top-20 right-20 w-64 h-64 rounded-full bg-bg-glow-from/10 blur-3xl ${pulse}`}
|
||||
/>
|
||||
<div
|
||||
className={`absolute bottom-20 left-20 w-80 h-80 rounded-full bg-bg-glow-to/10 blur-3xl ${pulse}`}
|
||||
style={animate ? { animationDelay: '1s' } : undefined}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
{grid && (
|
||||
<div
|
||||
className='absolute inset-0 opacity-[0.02] dark:opacity-[0.04]'
|
||||
style={{
|
||||
backgroundImage:
|
||||
'radial-gradient(circle at 1px 1px, currentColor 1px, transparent 0)',
|
||||
backgroundSize: '32px 32px',
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,356 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
|
||||
/*
|
||||
* PageGuide —— 企业控制台页面级「使用指引」三层体系的可复用实现。
|
||||
*
|
||||
* 三层结构(详见 docs 设计提案「页面功能指引」):
|
||||
* 1. 常驻入口 <PageGuideTrigger>:放在页面 hero 动作区,随时唤起抽屉;
|
||||
* 2. 进度胶囊 <PageGuidePill>:有上手流程的页面放在 hero 下方,
|
||||
* 展示数据驱动的完成度与「下一步」,全部完成后自动隐藏;
|
||||
* 3. 侧滑抽屉 <PageGuideDrawer>:承载定位一句话、分步操作、FAQ 与直达 CTA,
|
||||
* 首次访问自动展开一次(localStorage 按 guideKey 记忆)。
|
||||
*
|
||||
* 页面只需 usePageGuide({...配置}) 后把三个组件放到对应位置;
|
||||
* steps[].done 传布尔值即启用进度跟踪,不传则渲染为纯阅读步骤。
|
||||
*/
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { Button, SideSheet } from '@douyinfe/semi-ui';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
BookOpenText,
|
||||
CheckCircle2,
|
||||
ChevronDown,
|
||||
Compass,
|
||||
Loader2,
|
||||
} from 'lucide-react';
|
||||
import './page-guide.css';
|
||||
|
||||
const seenKey = (guideKey) => `page-guide-seen-${guideKey}`;
|
||||
|
||||
// localStorage 在隐私模式/配额耗尽时会抛异常(知识页 verified-key 处已有同款
|
||||
// 防御)。指引记忆是增强功能,绝不能反过来弄坏「使用指引」入口:写失败静默
|
||||
// 放弃;读失败按「已看过」处理,避免每次进页都重复自动弹出。
|
||||
// sessionSeen 兜"读正常、写抛异常"(配额耗尽)的场景:持久化失败时至少
|
||||
// 本会话内不重复自动弹出——否则每次路由进页都会弹一次,比不弹更糟。
|
||||
const sessionSeen = new Set();
|
||||
const readSeen = (guideKey) => {
|
||||
if (sessionSeen.has(guideKey)) return true;
|
||||
try {
|
||||
return window.localStorage.getItem(seenKey(guideKey)) === '1';
|
||||
} catch {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
const markSeen = (guideKey) => {
|
||||
sessionSeen.add(guideKey);
|
||||
try {
|
||||
window.localStorage.setItem(seenKey(guideKey), '1');
|
||||
} catch {
|
||||
// 忽略:仅损失跨会话记忆(本会话由 sessionSeen 兜底)
|
||||
}
|
||||
};
|
||||
|
||||
const prefersReducedMotion = () =>
|
||||
window.matchMedia?.('(prefers-reduced-motion: reduce)')?.matches ?? false;
|
||||
|
||||
// 指引 CTA 通用落点:滚动到目标区块并短暂高亮。延迟一拍等抽屉先关闭——
|
||||
// SideSheet 关闭动画约 300ms,早于它执行 scrollIntoView 会被遮罩滚动锁吞掉。
|
||||
export const flashGuideTarget = (selector, focusSelector) => {
|
||||
window.setTimeout(() => {
|
||||
const node = document.querySelector(selector);
|
||||
if (!node) return;
|
||||
node.scrollIntoView({
|
||||
behavior: prefersReducedMotion() ? 'auto' : 'smooth',
|
||||
block: 'center',
|
||||
});
|
||||
node.classList.add('page-guide-flash');
|
||||
window.setTimeout(() => node.classList.remove('page-guide-flash'), 1700);
|
||||
if (focusSelector) {
|
||||
window.setTimeout(
|
||||
() =>
|
||||
document.querySelector(focusSelector)?.focus({ preventScroll: true }),
|
||||
450,
|
||||
);
|
||||
}
|
||||
}, 350);
|
||||
};
|
||||
|
||||
export const usePageGuide = ({
|
||||
guideKey,
|
||||
title,
|
||||
intro,
|
||||
steps = [],
|
||||
faq = [],
|
||||
footer,
|
||||
autoOpen = true,
|
||||
// ready=false 时进度胶囊不渲染:页面数据未就绪前 done 全为 false,
|
||||
// 会对老用户闪现一个错误的「0/N」胶囊。
|
||||
ready = true,
|
||||
}) => {
|
||||
const [visible, setVisible] = useState(false);
|
||||
// focusStep:从胶囊进入时定位展开的步骤;null 表示按「下一步」默认展开。
|
||||
const [focusStep, setFocusStep] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!autoOpen || !guideKey) return undefined;
|
||||
if (readSeen(guideKey)) return undefined;
|
||||
// 延迟一拍再展开,等页面首屏渲染完成,避免抽屉与骨架屏同时抢焦点。
|
||||
const timer = window.setTimeout(() => {
|
||||
// 二次核对:800ms 窗口内用户手动打开过(open() 已 markSeen)就不再
|
||||
// 重弹——否则"快速开又关"后抽屉会自行复活一次。
|
||||
if (readSeen(guideKey)) return;
|
||||
markSeen(guideKey);
|
||||
setVisible(true);
|
||||
}, 800);
|
||||
return () => window.clearTimeout(timer);
|
||||
}, [autoOpen, guideKey]);
|
||||
|
||||
const progress = useMemo(() => {
|
||||
const trackable = steps.some((step) => typeof step.done === 'boolean');
|
||||
const doneCount = steps.filter((step) => step.done).length;
|
||||
const nextIndex = trackable ? steps.findIndex((step) => !step.done) : -1;
|
||||
return {
|
||||
trackable,
|
||||
doneCount,
|
||||
total: steps.length,
|
||||
nextIndex,
|
||||
allDone: trackable && nextIndex === -1,
|
||||
};
|
||||
}, [steps]);
|
||||
|
||||
const open = useCallback(
|
||||
(stepIndex = null) => {
|
||||
if (guideKey) markSeen(guideKey);
|
||||
setFocusStep(stepIndex);
|
||||
setVisible(true);
|
||||
},
|
||||
[guideKey],
|
||||
);
|
||||
const close = useCallback(() => setVisible(false), []);
|
||||
|
||||
return {
|
||||
visible,
|
||||
open,
|
||||
close,
|
||||
focusStep,
|
||||
progress,
|
||||
ready,
|
||||
config: { guideKey, title, intro, steps, faq, footer },
|
||||
};
|
||||
};
|
||||
|
||||
export const PageGuideTrigger = ({ guide, className = '' }) => {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Button
|
||||
theme='borderless'
|
||||
className={`page-guide-trigger ${className}`}
|
||||
icon={<BookOpenText size={16} />}
|
||||
onClick={() => guide.open()}
|
||||
>
|
||||
{t('使用指引')}
|
||||
</Button>
|
||||
);
|
||||
};
|
||||
|
||||
export const PageGuidePill = ({ guide, className = '' }) => {
|
||||
const { t } = useTranslation();
|
||||
const { progress, config } = guide;
|
||||
if (!guide.ready || !progress.trackable || progress.allDone) return null;
|
||||
const nextStep = config.steps[progress.nextIndex];
|
||||
return (
|
||||
<button
|
||||
type='button'
|
||||
className={`page-guide-pill ${className}`}
|
||||
onClick={() => guide.open(progress.nextIndex)}
|
||||
>
|
||||
<Compass size={14} className='page-guide-pill-icon' />
|
||||
<span className='page-guide-pill-dots' aria-hidden='true'>
|
||||
{config.steps.map((step, index) => (
|
||||
<i
|
||||
key={step.title}
|
||||
className={
|
||||
step.done
|
||||
? 'is-done'
|
||||
: index === progress.nextIndex
|
||||
? 'is-next'
|
||||
: ''
|
||||
}
|
||||
/>
|
||||
))}
|
||||
</span>
|
||||
<span className='page-guide-pill-text'>
|
||||
{t('快速上手')} {progress.doneCount}/{progress.total}
|
||||
{' · '}
|
||||
<strong>
|
||||
{t('下一步')}
|
||||
{t(':')}
|
||||
{nextStep?.working ? t('进行中') : nextStep?.title}
|
||||
</strong>
|
||||
</span>
|
||||
<span className='page-guide-pill-go'>{t('继续')} →</span>
|
||||
</button>
|
||||
);
|
||||
};
|
||||
|
||||
const StepIcon = ({ step, index, isNext }) => {
|
||||
if (step.done) return <CheckCircle2 size={14} />;
|
||||
if (!step.done && step.working)
|
||||
return <Loader2 size={13} className='page-guide-spin' />;
|
||||
return <span className={isNext ? 'is-next' : ''}>{index + 1}</span>;
|
||||
};
|
||||
|
||||
export const PageGuideDrawer = ({ guide }) => {
|
||||
const { t } = useTranslation();
|
||||
const { config, progress, visible, focusStep } = guide;
|
||||
// 展开哪一步:胶囊点进来的目标步 > 数据驱动的下一步 > 第一步。
|
||||
const defaultExpanded =
|
||||
focusStep ?? (progress.nextIndex >= 0 ? progress.nextIndex : 0);
|
||||
const [expanded, setExpanded] = useState(defaultExpanded);
|
||||
useEffect(() => {
|
||||
if (visible) setExpanded(defaultExpanded);
|
||||
// 抽屉每次打开时重新对齐展开项;关闭期间不响应数据变化。
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [visible, focusStep]);
|
||||
|
||||
const runAction = (step) => {
|
||||
guide.close();
|
||||
if (typeof step.onAction === 'function') step.onAction();
|
||||
};
|
||||
|
||||
return (
|
||||
<SideSheet
|
||||
className='page-guide-drawer'
|
||||
closeOnEsc
|
||||
title={
|
||||
<div className='page-guide-head'>
|
||||
<strong>{config.title}</strong>
|
||||
{config.intro && <span>{config.intro}</span>}
|
||||
</div>
|
||||
}
|
||||
visible={visible}
|
||||
onCancel={guide.close}
|
||||
width={420}
|
||||
footer={
|
||||
<div className='page-guide-foot'>
|
||||
{config.footer || t('可随时从页面右上角「使用指引」再次打开')}
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div className='page-guide-body'>
|
||||
{progress.trackable && (
|
||||
<p className='page-guide-progress'>
|
||||
{t('上手进度')}{' '}
|
||||
<b>
|
||||
{progress.doneCount}/{progress.total}
|
||||
</b>
|
||||
{' · '}
|
||||
{progress.allDone
|
||||
? t('已完成全部入门步骤')
|
||||
: t('完成态由页面真实数据驱动,无需手动勾选')}
|
||||
</p>
|
||||
)}
|
||||
<ol className='page-guide-steps'>
|
||||
{config.steps.map((step, index) => {
|
||||
const isNext = index === progress.nextIndex;
|
||||
const isOpen = index === expanded;
|
||||
const detailId = `page-guide-step-${config.guideKey}-${index}`;
|
||||
const stateClass = step.done
|
||||
? 'is-done'
|
||||
: step.working
|
||||
? 'is-working'
|
||||
: isNext
|
||||
? 'is-next'
|
||||
: '';
|
||||
return (
|
||||
<li
|
||||
key={step.title}
|
||||
className={`page-guide-step ${stateClass} ${isOpen ? 'is-open' : ''}`}
|
||||
>
|
||||
<button
|
||||
type='button'
|
||||
className='page-guide-step-head'
|
||||
aria-expanded={isOpen}
|
||||
aria-controls={isOpen ? detailId : undefined}
|
||||
onClick={() => setExpanded(isOpen ? -1 : index)}
|
||||
>
|
||||
<span className='page-guide-step-ic'>
|
||||
<StepIcon step={step} index={index} isNext={isNext} />
|
||||
</span>
|
||||
<span className='page-guide-step-copy'>
|
||||
<strong>
|
||||
{step.title}
|
||||
{step.done && (
|
||||
<em className='page-guide-badge is-done'>
|
||||
{t('已完成')}
|
||||
</em>
|
||||
)}
|
||||
{!step.done && step.working && (
|
||||
<em className='page-guide-badge is-working'>
|
||||
{t('进行中')}
|
||||
</em>
|
||||
)}
|
||||
{!step.done && !step.working && isNext && (
|
||||
<em className='page-guide-badge'>{t('下一步')}</em>
|
||||
)}
|
||||
</strong>
|
||||
{step.detail && <small>{step.detail}</small>}
|
||||
</span>
|
||||
<ChevronDown size={15} className='page-guide-step-arrow' />
|
||||
</button>
|
||||
{isOpen && (
|
||||
<div className='page-guide-step-detail' id={detailId}>
|
||||
{Array.isArray(step.points) && step.points.length > 0 && (
|
||||
<ul>
|
||||
{step.points.map((point) => (
|
||||
<li key={point}>{point}</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
{step.cta && step.onAction && (
|
||||
<button
|
||||
type='button'
|
||||
className='page-guide-step-cta'
|
||||
onClick={() => runAction(step)}
|
||||
>
|
||||
{step.cta} →
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ol>
|
||||
{guide.config.faq.length > 0 && (
|
||||
<>
|
||||
<p className='page-guide-section-title'>{t('常见问题')}</p>
|
||||
{config.faq.map((item) => (
|
||||
<div className='page-guide-faq' key={item.q}>
|
||||
<b>{item.q}</b>
|
||||
<span>{item.a}</span>
|
||||
</div>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</SideSheet>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,396 @@
|
||||
/* PageGuide —— 页面级使用指引(触发按钮 / 进度胶囊 / 侧滑抽屉)
|
||||
* 配色全部从主题 token 派生,随亮暗色与品牌预设自动适配。 */
|
||||
|
||||
.page-guide-pill,
|
||||
.page-guide-drawer {
|
||||
--pg-ink: var(--text-primary);
|
||||
--pg-muted: var(--text-secondary);
|
||||
--pg-line: var(--border-subtle);
|
||||
--pg-accent: var(--semi-color-primary);
|
||||
--pg-accent-deep: var(--semi-color-primary-active, var(--semi-color-primary));
|
||||
--pg-tint: color-mix(in srgb, var(--semi-color-primary) 8%, transparent);
|
||||
--pg-tint-strong: color-mix(
|
||||
in srgb,
|
||||
var(--semi-color-primary) 14%,
|
||||
transparent
|
||||
);
|
||||
--pg-tint-line: color-mix(
|
||||
in srgb,
|
||||
var(--semi-color-primary) 28%,
|
||||
transparent
|
||||
);
|
||||
--pg-ok: var(--semi-color-success);
|
||||
--pg-ok-tint: color-mix(in srgb, var(--semi-color-success) 14%, transparent);
|
||||
}
|
||||
|
||||
/* ===== 进度胶囊 ===== */
|
||||
.page-guide-pill {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
max-width: 100%;
|
||||
padding: 6px 8px 6px 14px;
|
||||
border: 1px solid var(--pg-tint-line);
|
||||
border-radius: 999px;
|
||||
background: color-mix(
|
||||
in srgb,
|
||||
var(--semi-color-primary) 4%,
|
||||
var(--surface-card)
|
||||
);
|
||||
color: var(--pg-ink);
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
cursor: pointer;
|
||||
transition:
|
||||
border-color 0.15s ease,
|
||||
box-shadow 0.15s ease;
|
||||
}
|
||||
|
||||
.page-guide-pill:hover {
|
||||
border-color: var(--pg-accent);
|
||||
box-shadow: 0 2px 10px var(--pg-tint);
|
||||
}
|
||||
|
||||
.page-guide-pill:focus-visible,
|
||||
.page-guide-trigger:focus-visible,
|
||||
.page-guide-step-head:focus-visible,
|
||||
.page-guide-step-cta:focus-visible {
|
||||
outline: 2px solid
|
||||
color-mix(in srgb, var(--semi-color-primary) 55%, transparent);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.page-guide-pill-icon {
|
||||
flex: none;
|
||||
color: var(--pg-accent);
|
||||
}
|
||||
|
||||
.page-guide-pill-dots {
|
||||
display: inline-flex;
|
||||
gap: 4px;
|
||||
flex: none;
|
||||
}
|
||||
|
||||
.page-guide-pill-dots i {
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
border-radius: 50%;
|
||||
background: var(--pg-line);
|
||||
}
|
||||
|
||||
.page-guide-pill-dots i.is-done {
|
||||
background: var(--pg-ok);
|
||||
}
|
||||
|
||||
.page-guide-pill-dots i.is-next {
|
||||
background: var(--pg-accent);
|
||||
}
|
||||
|
||||
.page-guide-pill-text {
|
||||
color: var(--pg-muted);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.page-guide-pill-text strong {
|
||||
color: var(--pg-accent);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.page-guide-pill-go {
|
||||
flex: none;
|
||||
padding: 2px 10px;
|
||||
border-radius: 999px;
|
||||
background: var(--pg-tint);
|
||||
color: var(--pg-accent);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* ===== 抽屉 ===== */
|
||||
.page-guide-drawer .semi-sidesheet-inner {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.page-guide-drawer .semi-sidesheet-body {
|
||||
padding: 14px 22px 20px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
/* 抽屉滚动条:复用品牌滚动条 token(同 app-scrollbar 的取色来源) */
|
||||
.page-guide-drawer .semi-sidesheet-body::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
.page-guide-drawer .semi-sidesheet-body::-webkit-scrollbar-thumb {
|
||||
border-radius: 999px;
|
||||
background: var(--brand-scroll);
|
||||
}
|
||||
|
||||
.page-guide-drawer .semi-sidesheet-body::-webkit-scrollbar-thumb:hover {
|
||||
background: var(--brand-scroll-hover);
|
||||
}
|
||||
|
||||
.page-guide-head {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.page-guide-head strong {
|
||||
font-size: 16px;
|
||||
color: var(--pg-ink);
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
|
||||
.page-guide-head span {
|
||||
font-size: 12.5px;
|
||||
font-weight: 400;
|
||||
color: var(--pg-muted);
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.page-guide-progress {
|
||||
margin: 0 0 12px;
|
||||
font-size: 12px;
|
||||
color: var(--pg-muted);
|
||||
}
|
||||
|
||||
.page-guide-progress b {
|
||||
color: var(--pg-ok);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
/* ===== 步骤 ===== */
|
||||
.page-guide-steps {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.page-guide-step {
|
||||
border: 1px solid var(--pg-line);
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
background: var(--surface-card);
|
||||
}
|
||||
|
||||
.page-guide-step.is-next {
|
||||
border-color: var(--pg-tint-line);
|
||||
background: color-mix(
|
||||
in srgb,
|
||||
var(--semi-color-primary) 5%,
|
||||
var(--surface-card)
|
||||
);
|
||||
}
|
||||
|
||||
.page-guide-step-head {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 10px;
|
||||
width: 100%;
|
||||
padding: 12px 14px;
|
||||
border: 0;
|
||||
background: none;
|
||||
color: inherit;
|
||||
font: inherit;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.page-guide-step-ic {
|
||||
flex: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
margin-top: 1px;
|
||||
border: 1px solid var(--pg-line);
|
||||
border-radius: 50%;
|
||||
font-size: 12px;
|
||||
color: var(--pg-muted);
|
||||
}
|
||||
|
||||
.page-guide-step.is-done .page-guide-step-ic {
|
||||
border-color: transparent;
|
||||
background: var(--pg-ok-tint);
|
||||
color: var(--pg-ok);
|
||||
}
|
||||
|
||||
.page-guide-step.is-next .page-guide-step-ic {
|
||||
border-color: transparent;
|
||||
background: var(--pg-accent);
|
||||
color: var(--semi-color-white, var(--surface-card));
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.page-guide-step.is-working .page-guide-step-ic {
|
||||
border-color: var(--pg-tint-line);
|
||||
color: var(--pg-accent);
|
||||
}
|
||||
|
||||
.page-guide-step-copy {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.page-guide-step-copy strong {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
font-size: 13.5px;
|
||||
color: var(--pg-ink);
|
||||
}
|
||||
|
||||
.page-guide-step-copy small {
|
||||
display: block;
|
||||
margin-top: 2px;
|
||||
font-size: 12.5px;
|
||||
line-height: 1.6;
|
||||
color: var(--pg-muted);
|
||||
}
|
||||
|
||||
.page-guide-badge {
|
||||
flex: none;
|
||||
padding: 1px 8px;
|
||||
border: 1px solid var(--pg-tint-line);
|
||||
border-radius: 999px;
|
||||
background: var(--surface-card);
|
||||
color: var(--pg-accent);
|
||||
font-size: 11px;
|
||||
font-style: normal;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.page-guide-badge.is-done {
|
||||
border-color: transparent;
|
||||
background: var(--pg-ok-tint);
|
||||
color: var(--pg-ok);
|
||||
}
|
||||
|
||||
.page-guide-badge.is-working {
|
||||
border-color: transparent;
|
||||
background: var(--pg-tint);
|
||||
}
|
||||
|
||||
.page-guide-step-arrow {
|
||||
flex: none;
|
||||
margin-top: 3px;
|
||||
color: var(--pg-muted);
|
||||
transition: transform 0.15s ease;
|
||||
}
|
||||
|
||||
.page-guide-step.is-open .page-guide-step-arrow {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
.page-guide-step-detail {
|
||||
padding: 0 14px 12px 46px;
|
||||
}
|
||||
|
||||
.page-guide-step-detail ul {
|
||||
margin: 0;
|
||||
padding-left: 16px;
|
||||
font-size: 12.5px;
|
||||
line-height: 1.7;
|
||||
color: var(--pg-muted);
|
||||
}
|
||||
|
||||
.page-guide-step-detail li + li {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.page-guide-step-cta {
|
||||
margin-top: 10px;
|
||||
padding: 5px 12px;
|
||||
border: 1px solid var(--pg-tint-line);
|
||||
border-radius: 8px;
|
||||
background: var(--surface-card);
|
||||
color: var(--pg-accent);
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: background 0.15s ease;
|
||||
}
|
||||
|
||||
.page-guide-step-cta:hover {
|
||||
background: var(--pg-tint);
|
||||
}
|
||||
|
||||
/* ===== FAQ ===== */
|
||||
.page-guide-section-title {
|
||||
margin: 20px 0 10px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.08em;
|
||||
color: var(--pg-muted);
|
||||
}
|
||||
|
||||
.page-guide-faq {
|
||||
margin-bottom: 10px;
|
||||
padding-left: 12px;
|
||||
border-left: 2px solid var(--pg-tint-line);
|
||||
font-size: 12.5px;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.page-guide-faq b {
|
||||
display: block;
|
||||
color: var(--pg-ink);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.page-guide-faq span {
|
||||
color: var(--pg-muted);
|
||||
}
|
||||
|
||||
.page-guide-foot {
|
||||
font-size: 12px;
|
||||
color: var(--pg-muted);
|
||||
}
|
||||
|
||||
/* 指引 CTA 落点的短暂高亮(flashGuideTarget) */
|
||||
.page-guide-flash {
|
||||
animation: page-guide-flash-pulse 1.6s ease;
|
||||
}
|
||||
|
||||
@keyframes page-guide-flash-pulse {
|
||||
0%,
|
||||
100% {
|
||||
box-shadow: none;
|
||||
}
|
||||
30% {
|
||||
box-shadow: 0 0 0 4px
|
||||
color-mix(in srgb, var(--semi-color-primary) 45%, transparent);
|
||||
}
|
||||
}
|
||||
|
||||
.page-guide-spin {
|
||||
animation: page-guide-spin 1s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes page-guide-spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.page-guide-pill,
|
||||
.page-guide-step-arrow,
|
||||
.page-guide-step-cta {
|
||||
transition: none;
|
||||
}
|
||||
|
||||
.page-guide-spin,
|
||||
.page-guide-flash {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
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 React, { useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Button, Modal } from '@douyinfe/semi-ui';
|
||||
import { useSecureVerification } from '../../../hooks/common/useSecureVerification';
|
||||
import { createApiCalls } from '../../../services/secureVerification';
|
||||
import SecureVerificationModal from '../modals/SecureVerificationModal';
|
||||
import ChannelKeyDisplay from '../ui/ChannelKeyDisplay';
|
||||
|
||||
/**
|
||||
* 渠道密钥查看组件使用示例
|
||||
* 展示如何使用通用安全验证系统
|
||||
*/
|
||||
const ChannelKeyViewExample = ({ channelId }) => {
|
||||
const { t } = useTranslation();
|
||||
const [keyData, setKeyData] = useState('');
|
||||
const [showKeyModal, setShowKeyModal] = useState(false);
|
||||
|
||||
// 使用通用安全验证 Hook
|
||||
const {
|
||||
isModalVisible,
|
||||
verificationMethods,
|
||||
verificationState,
|
||||
startVerification,
|
||||
executeVerification,
|
||||
cancelVerification,
|
||||
setVerificationCode,
|
||||
switchVerificationMethod,
|
||||
} = useSecureVerification({
|
||||
onSuccess: (result) => {
|
||||
// 验证成功后处理结果
|
||||
if (result.success && result.data?.key) {
|
||||
setKeyData(result.data.key);
|
||||
setShowKeyModal(true);
|
||||
}
|
||||
},
|
||||
successMessage: t('密钥获取成功'),
|
||||
});
|
||||
|
||||
// 开始查看密钥流程
|
||||
const handleViewKey = async () => {
|
||||
const apiCall = createApiCalls.viewChannelKey(channelId);
|
||||
|
||||
await startVerification(apiCall, {
|
||||
title: t('查看渠道密钥'),
|
||||
description: t('为了保护账户安全,请验证您的身份。'),
|
||||
preferredMethod: 'passkey', // 可以指定首选验证方式
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* 查看密钥按钮 */}
|
||||
<Button type='primary' theme='outline' onClick={handleViewKey}>
|
||||
{t('查看密钥')}
|
||||
</Button>
|
||||
|
||||
{/* 安全验证模态框 */}
|
||||
<SecureVerificationModal
|
||||
visible={isModalVisible}
|
||||
verificationMethods={verificationMethods}
|
||||
verificationState={verificationState}
|
||||
onVerify={executeVerification}
|
||||
onCancel={cancelVerification}
|
||||
onCodeChange={setVerificationCode}
|
||||
onMethodSwitch={switchVerificationMethod}
|
||||
title={verificationState.title}
|
||||
description={verificationState.description}
|
||||
/>
|
||||
|
||||
{/* 密钥显示模态框 */}
|
||||
<Modal
|
||||
title={t('渠道密钥信息')}
|
||||
visible={showKeyModal}
|
||||
onCancel={() => setShowKeyModal(false)}
|
||||
footer={
|
||||
<Button type='primary' onClick={() => setShowKeyModal(false)}>
|
||||
{t('完成')}
|
||||
</Button>
|
||||
}
|
||||
width={700}
|
||||
style={{ maxWidth: '90vw' }}
|
||||
>
|
||||
<ChannelKeyDisplay
|
||||
keyData={keyData}
|
||||
showSuccessIcon={true}
|
||||
successText={t('密钥获取成功')}
|
||||
showWarning={true}
|
||||
/>
|
||||
</Modal>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default ChannelKeyViewExample;
|
||||
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
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 React from 'react';
|
||||
|
||||
// 微信图标 (已经存在于 WeChatIcon.jsx,但为了统一导入,这里也提供)
|
||||
export const WechatBrandIcon = ({
|
||||
size = 24,
|
||||
color = '#07C160',
|
||||
className = '',
|
||||
...props
|
||||
}) => (
|
||||
<svg
|
||||
viewBox='0 0 24 24'
|
||||
width={size}
|
||||
height={size}
|
||||
fill={color}
|
||||
className={className}
|
||||
{...props}
|
||||
>
|
||||
<path d='M8.691 2.188C3.891 2.188 0 5.476 0 9.53c0 2.212 1.17 4.203 3.002 5.55a.59.59 0 0 1 .213.665l-.39 1.48c-.019.07-.048.141-.048.213 0 .163.13.295.29.295a.326.326 0 0 0 .167-.054l1.903-1.114a.864.864 0 0 1 .717-.098 10.16 10.16 0 0 0 2.837.403c.276 0 .543-.027.811-.05-.857-2.578.157-4.972 1.932-6.446 1.703-1.415 3.882-1.98 5.853-1.838-.576-3.583-4.196-6.348-8.596-6.348zM5.785 5.991c.642 0 1.162.529 1.162 1.18a1.17 1.17 0 0 1-1.162 1.178A1.17 1.17 0 0 1 4.623 7.17c0-.651.52-1.18 1.162-1.18zm5.813 0c.642 0 1.162.529 1.162 1.18a1.17 1.17 0 0 1-1.162 1.178 1.17 1.17 0 0 1-1.162-1.178c0-.651.52-1.18 1.162-1.18zm5.34 2.867c-1.797-.052-3.746.512-5.28 1.786-1.72 1.428-2.687 3.72-1.78 6.22.942 2.453 3.666 4.229 6.884 4.229.826 0 1.622-.12 2.361-.336a.722.722 0 0 1 .598.082l1.584.926a.272.272 0 0 0 .14.047c.134 0 .24-.111.24-.247 0-.06-.023-.12-.038-.177l-.327-1.233a.582.582 0 0 1 .123-.51c1.531-1.186 2.498-2.913 2.498-4.879 0-3.583-3.256-6.468-7.11-6.468l.107-.44zm-2.68 2.58c.535 0 .969.44.969.982a.976.976 0 0 1-.969.983.976.976 0 0 1-.969-.983c0-.542.434-.982.969-.982zm4.844 0c.535 0 .969.44.969.982a.976.976 0 0 1-.969.983.976.976 0 0 1-.969-.983c0-.542.434-.982.969-.982z' />
|
||||
</svg>
|
||||
);
|
||||
|
||||
// 支付宝图标
|
||||
export const AlipayBrandIcon = ({
|
||||
size = 24,
|
||||
color = '#1677FF',
|
||||
className = '',
|
||||
...props
|
||||
}) => (
|
||||
<svg
|
||||
viewBox='0 0 24 24'
|
||||
width={size}
|
||||
height={size}
|
||||
fill={color}
|
||||
className={className}
|
||||
{...props}
|
||||
>
|
||||
<path d='M18.423 8.467c-.012-.02-4.54-8.467-4.54-8.467h-13.883l8 14.889-8 9.111h5l2.973-3.378s1.522 1.378 3.527 1.378c3 0 6.5-2.5 6.5-6.5 0-2.653-1.714-4.941-4.119-5.755zm-8.423 9.533l-4-7.432 4-4.568zm8.5 1c-1.93 0-3.5-1.57-3.5-3.5s1.57-3.5 3.5-3.5 3.5 1.57 3.5 3.5-1.57 3.5-3.5 3.5z' />
|
||||
</svg>
|
||||
);
|
||||
|
||||
// Stripe 图标
|
||||
export const StripeBrandIcon = ({
|
||||
size = 24,
|
||||
color = '#635BFF',
|
||||
className = '',
|
||||
...props
|
||||
}) => (
|
||||
<svg
|
||||
viewBox='0 0 24 24'
|
||||
width={size}
|
||||
height={size}
|
||||
fill={color}
|
||||
className={className}
|
||||
{...props}
|
||||
>
|
||||
<path d='M13.976 9.15c-2.172-.806-3.356-1.426-3.356-2.409 0-.831.683-1.305 1.901-1.305 2.227 0 4.515.858 6.09 1.631l.89-5.494C18.252.975 15.697 0 12.165 0 9.667 0 7.589.654 6.104 1.872 4.56 3.147 3.757 4.992 3.757 7.218c0 4.039 2.467 5.76 6.476 7.219 2.585.92 3.445 1.574 3.445 2.583 0 .98-.84 1.545-2.354 1.545-1.875 0-4.965-.921-6.99-2.109l-.9 5.555C5.175 22.99 8.385 24 11.714 24c2.641 0 4.843-.624 6.328-1.813 1.664-1.305 2.525-3.236 2.525-5.732 0-4.128-2.524-5.851-6.591-7.305z' />
|
||||
</svg>
|
||||
);
|
||||
|
||||
// PayPal brand mark
|
||||
export const PayPalBrandIcon = ({
|
||||
size = 24,
|
||||
color = '#0070BA',
|
||||
className = '',
|
||||
...props
|
||||
}) => (
|
||||
<svg
|
||||
viewBox='0 0 24 24'
|
||||
width={size}
|
||||
height={size}
|
||||
fill={color}
|
||||
className={className}
|
||||
{...props}
|
||||
>
|
||||
<path d='M7.08 20.5H3.5a.75.75 0 0 1-.74-.87L5.74 1.1A1.3 1.3 0 0 1 7.02 0h6.53c4.15 0 6.58 2.2 6.11 5.76-.54 4.08-3.37 6.34-7.4 6.34H10.4a1.3 1.3 0 0 0-1.28 1.1L8.3 18.36A1.3 1.3 0 0 1 7.08 20.5Zm3.65-15.93-.55 3.47h1.57c1.72 0 2.8-.78 3.02-2.16.18-1.13-.64-1.31-2.05-1.31h-1.99Z' />
|
||||
<path
|
||||
d='M19.63 7.04c-.63 4.75-4.08 7.68-8.94 7.68h-.64l-.7 4.46-.2 1.27A1.3 1.3 0 0 0 10.44 22h3.1a1.3 1.3 0 0 0 1.28-1.1l.5-3.17a1.3 1.3 0 0 1 1.28-1.1h.81c3.57 0 6.02-2.08 6.48-5.52.33-2.48-.8-4.16-2.75-4.89-.45-.17-.94-.3-1.47-.38 0 .4-.01.8-.04 1.2Z'
|
||||
fill='#003087'
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
|
||||
// Telegram 图标
|
||||
export const TelegramBrandIcon = ({
|
||||
size = 24,
|
||||
color = '#26A5E4',
|
||||
className = '',
|
||||
...props
|
||||
}) => (
|
||||
<svg
|
||||
viewBox='0 0 24 24'
|
||||
width={size}
|
||||
height={size}
|
||||
fill={color}
|
||||
className={className}
|
||||
{...props}
|
||||
>
|
||||
<path d='M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.48.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z' />
|
||||
</svg>
|
||||
);
|
||||
|
||||
// Discord 图标
|
||||
export const DiscordBrandIcon = ({
|
||||
size = 24,
|
||||
color = '#5865F2',
|
||||
className = '',
|
||||
...props
|
||||
}) => (
|
||||
<svg
|
||||
viewBox='0 0 24 24'
|
||||
width={size}
|
||||
height={size}
|
||||
fill={color}
|
||||
className={className}
|
||||
{...props}
|
||||
>
|
||||
<path d='M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z' />
|
||||
</svg>
|
||||
);
|
||||
|
||||
// Linux 图标 (用于 LinuxDO)
|
||||
export const LinuxBrandIcon = ({
|
||||
size = 24,
|
||||
color = '#FCC624',
|
||||
className = '',
|
||||
...props
|
||||
}) => (
|
||||
<svg
|
||||
viewBox='0 0 24 24'
|
||||
width={size}
|
||||
height={size}
|
||||
fill={color}
|
||||
className={className}
|
||||
{...props}
|
||||
>
|
||||
<path d='M12.504 0c-.155 0-.315.008-.48.021-4.226.333-3.105 4.807-3.17 6.298-.076 1.092-.3 1.953-1.05 3.02-.885 1.051-2.127 2.75-2.716 4.521-.278.832-.41 1.684-.287 2.489a.424.424 0 00-.011.078c0 .072.011.142.033.21.179-.78.46-1.474.846-2.078l.53.07c-.145.49-.194.977-.148 1.449.04.42.15.82.43 1.131.711.77 1.89 1.032 2.902 1.032 1.02 0 1.902-.26 2.61-1.03.28-.31.39-.71.43-1.13.046-.473-.003-.96-.148-1.45l.53-.07c.386.605.668 1.299.847 2.078.022-.068.033-.139.033-.21a.424.424 0 00-.011-.078c.123-.805-.009-1.657-.287-2.489-.59-1.77-1.831-3.47-2.716-4.52-.75-1.068-.974-1.929-1.05-3.021-.066-1.491 1.055-5.965-3.17-6.298-.165-.013-.325-.021-.48-.021zm-.751 4.143c.357 0 .646.287.646.643a.645.645 0 01-.646.644.645.645 0 01-.645-.644c0-.356.288-.643.645-.643zm-5.116.641c.356 0 .645.287.645.644a.645.645 0 01-.645.643.645.645 0 01-.644-.643c0-.357.288-.644.644-.644zM12 8.941c.528 0 .956.428.956.955 0 .527-.428.955-.956.955-.527 0-.955-.428-.955-.955 0-.527.428-.955.955-.955zM4.668 11.19c.42 0 .76.34.76.76 0 .42-.34.76-.76.76a.76.76 0 01-.76-.76c0-.42.34-.76.76-.76zm14.664 0c.42 0 .76.34.76.76 0 .42-.34.76-.76.76a.76.76 0 01-.76-.76c0-.42.34-.76.76-.76z' />
|
||||
</svg>
|
||||
);
|
||||
|
||||
// Shuffle 图标 (用于替换 FaRandom)
|
||||
export const ShuffleBrandIcon = ({
|
||||
size = 16,
|
||||
color = 'currentColor',
|
||||
className = '',
|
||||
...props
|
||||
}) => (
|
||||
<svg
|
||||
viewBox='0 0 24 24'
|
||||
width={size}
|
||||
height={size}
|
||||
fill='none'
|
||||
stroke={color}
|
||||
strokeWidth='2'
|
||||
strokeLinecap='round'
|
||||
strokeLinejoin='round'
|
||||
className={className}
|
||||
{...props}
|
||||
>
|
||||
<polyline points='16 3 21 3 21 8'></polyline>
|
||||
<line x1='4' y1='20' x2='21' y2='3'></line>
|
||||
<polyline points='21 16 21 21 16 21'></polyline>
|
||||
<line x1='15' y1='15' x2='21' y2='21'></line>
|
||||
<line x1='4' y1='4' x2='9' y2='9'></line>
|
||||
</svg>
|
||||
);
|
||||
@@ -0,0 +1,953 @@
|
||||
/*
|
||||
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 React from 'react';
|
||||
|
||||
// ========== 无结果插图 ==========
|
||||
export const IllustrationNoResult = ({ style = {} }) => (
|
||||
<svg
|
||||
viewBox='0 0 200 200'
|
||||
fill='none'
|
||||
xmlns='http://www.w3.org/2000/svg'
|
||||
style={{ width: 150, height: 150, ...style }}
|
||||
>
|
||||
<defs>
|
||||
<linearGradient id='noResultGrad1' x1='0%' y1='0%' x2='100%' y2='100%'>
|
||||
<stop offset='0%' stopColor='var(--brand-primary)' />
|
||||
<stop offset='100%' stopColor='var(--brand-gradient-via)' />
|
||||
</linearGradient>
|
||||
<linearGradient id='noResultGrad2' x1='0%' y1='0%' x2='100%' y2='100%'>
|
||||
<stop offset='0%' stopColor='color-mix(in srgb, var(--brand-primary) 12%, #fff)' />
|
||||
<stop offset='100%' stopColor='color-mix(in srgb, var(--brand-primary) 20%, #fff)' />
|
||||
</linearGradient>
|
||||
<filter id='noResultShadow' x='-20%' y='-20%' width='140%' height='140%'>
|
||||
<feDropShadow
|
||||
dx='0'
|
||||
dy='4'
|
||||
stdDeviation='8'
|
||||
floodColor='var(--brand-primary)'
|
||||
floodOpacity='0.15'
|
||||
/>
|
||||
</filter>
|
||||
</defs>
|
||||
{/* 背景装饰圆 */}
|
||||
<circle cx='100' cy='100' r='80' fill='url(#noResultGrad2)' opacity='0.3' />
|
||||
<circle cx='100' cy='100' r='60' fill='url(#noResultGrad2)' opacity='0.5' />
|
||||
{/* 搜索放大镜 */}
|
||||
<g filter='url(#noResultShadow)'>
|
||||
<circle
|
||||
cx='90'
|
||||
cy='85'
|
||||
r='35'
|
||||
stroke='url(#noResultGrad1)'
|
||||
strokeWidth='6'
|
||||
fill='white'
|
||||
/>
|
||||
<line
|
||||
x1='115'
|
||||
y1='110'
|
||||
x2='140'
|
||||
y2='135'
|
||||
stroke='url(#noResultGrad1)'
|
||||
strokeWidth='8'
|
||||
strokeLinecap='round'
|
||||
/>
|
||||
</g>
|
||||
{/* X 标记 */}
|
||||
<g opacity='0.8'>
|
||||
<line
|
||||
x1='75'
|
||||
y1='70'
|
||||
x2='105'
|
||||
y2='100'
|
||||
stroke='var(--semi-color-danger)'
|
||||
strokeWidth='4'
|
||||
strokeLinecap='round'
|
||||
/>
|
||||
<line
|
||||
x1='105'
|
||||
y1='70'
|
||||
x2='75'
|
||||
y2='100'
|
||||
stroke='var(--semi-color-danger)'
|
||||
strokeWidth='4'
|
||||
strokeLinecap='round'
|
||||
/>
|
||||
</g>
|
||||
{/* 装饰点 */}
|
||||
<circle cx='45' cy='60' r='4' fill='var(--brand-primary)' opacity='0.4'>
|
||||
<animate
|
||||
attributeName='opacity'
|
||||
values='0.4;0.8;0.4'
|
||||
dur='2s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</circle>
|
||||
<circle cx='160' cy='50' r='3' fill='var(--brand-gradient-via)' opacity='0.5'>
|
||||
<animate
|
||||
attributeName='opacity'
|
||||
values='0.5;1;0.5'
|
||||
dur='2.5s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</circle>
|
||||
<circle cx='155' cy='140' r='5' fill='var(--brand-gradient-to)' opacity='0.3'>
|
||||
<animate
|
||||
attributeName='opacity'
|
||||
values='0.3;0.7;0.3'
|
||||
dur='3s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</circle>
|
||||
</svg>
|
||||
);
|
||||
|
||||
export const IllustrationNoResultDark = ({ style = {} }) => (
|
||||
<svg
|
||||
viewBox='0 0 200 200'
|
||||
fill='none'
|
||||
xmlns='http://www.w3.org/2000/svg'
|
||||
style={{ width: 150, height: 150, ...style }}
|
||||
>
|
||||
<defs>
|
||||
<linearGradient
|
||||
id='noResultGradDark1'
|
||||
x1='0%'
|
||||
y1='0%'
|
||||
x2='100%'
|
||||
y2='100%'
|
||||
>
|
||||
<stop offset='0%' stopColor='var(--brand-gradient-from)' />
|
||||
<stop offset='100%' stopColor='var(--brand-gradient-to)' />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id='noResultGradDark2'
|
||||
x1='0%'
|
||||
y1='0%'
|
||||
x2='100%'
|
||||
y2='100%'
|
||||
>
|
||||
<stop offset='0%' stopColor='color-mix(in srgb, var(--brand-primary) 25%, #000)' />
|
||||
<stop offset='100%' stopColor='color-mix(in srgb, var(--brand-gradient-via) 25%, #000)' />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<circle
|
||||
cx='100'
|
||||
cy='100'
|
||||
r='80'
|
||||
fill='url(#noResultGradDark2)'
|
||||
opacity='0.3'
|
||||
/>
|
||||
<circle
|
||||
cx='100'
|
||||
cy='100'
|
||||
r='60'
|
||||
fill='url(#noResultGradDark2)'
|
||||
opacity='0.5'
|
||||
/>
|
||||
<g>
|
||||
<circle
|
||||
cx='90'
|
||||
cy='85'
|
||||
r='35'
|
||||
stroke='url(#noResultGradDark1)'
|
||||
strokeWidth='6'
|
||||
fill='color-mix(in srgb, var(--brand-primary) 15%, #000)'
|
||||
/>
|
||||
<line
|
||||
x1='115'
|
||||
y1='110'
|
||||
x2='140'
|
||||
y2='135'
|
||||
stroke='url(#noResultGradDark1)'
|
||||
strokeWidth='8'
|
||||
strokeLinecap='round'
|
||||
/>
|
||||
</g>
|
||||
<g opacity='0.8'>
|
||||
<line
|
||||
x1='75'
|
||||
y1='70'
|
||||
x2='105'
|
||||
y2='100'
|
||||
stroke='var(--semi-color-danger)'
|
||||
strokeWidth='4'
|
||||
strokeLinecap='round'
|
||||
/>
|
||||
<line
|
||||
x1='105'
|
||||
y1='70'
|
||||
x2='75'
|
||||
y2='100'
|
||||
stroke='var(--semi-color-danger)'
|
||||
strokeWidth='4'
|
||||
strokeLinecap='round'
|
||||
/>
|
||||
</g>
|
||||
<circle cx='45' cy='60' r='4' fill='var(--brand-gradient-from)' opacity='0.5'>
|
||||
<animate
|
||||
attributeName='opacity'
|
||||
values='0.5;1;0.5'
|
||||
dur='2s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</circle>
|
||||
<circle cx='160' cy='50' r='3' fill='var(--brand-gradient-to)' opacity='0.6'>
|
||||
<animate
|
||||
attributeName='opacity'
|
||||
values='0.6;1;0.6'
|
||||
dur='2.5s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</circle>
|
||||
<circle cx='155' cy='140' r='5' fill='var(--brand-primary-hover)' opacity='0.4'>
|
||||
<animate
|
||||
attributeName='opacity'
|
||||
values='0.4;0.8;0.4'
|
||||
dur='3s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</circle>
|
||||
</svg>
|
||||
);
|
||||
|
||||
// ========== 页面未找到插图 ==========
|
||||
export const IllustrationNotFound = ({ style = {} }) => (
|
||||
<svg
|
||||
viewBox='0 0 200 200'
|
||||
fill='none'
|
||||
xmlns='http://www.w3.org/2000/svg'
|
||||
style={{ width: 150, height: 150, ...style }}
|
||||
>
|
||||
<defs>
|
||||
<linearGradient id='notFoundGrad1' x1='0%' y1='0%' x2='100%' y2='100%'>
|
||||
<stop offset='0%' stopColor='var(--semi-color-warning)' />
|
||||
<stop offset='100%' stopColor='var(--semi-color-danger)' />
|
||||
</linearGradient>
|
||||
<linearGradient id='notFoundGrad2' x1='0%' y1='0%' x2='100%' y2='100%'>
|
||||
<stop offset='0%' stopColor='color-mix(in srgb, var(--semi-color-warning) 15%, #fff)' />
|
||||
<stop offset='100%' stopColor='color-mix(in srgb, var(--semi-color-danger) 25%, #fff)' />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
{/* 背景 */}
|
||||
<circle cx='100' cy='100' r='75' fill='url(#notFoundGrad2)' opacity='0.4' />
|
||||
{/* 404 文字 */}
|
||||
<text
|
||||
x='100'
|
||||
y='90'
|
||||
textAnchor='middle'
|
||||
fontSize='48'
|
||||
fontWeight='bold'
|
||||
fill='url(#notFoundGrad1)'
|
||||
>
|
||||
404
|
||||
</text>
|
||||
{/* 底部线条 */}
|
||||
<path
|
||||
d='M50 120 Q100 140 150 120'
|
||||
stroke='url(#notFoundGrad1)'
|
||||
strokeWidth='3'
|
||||
fill='none'
|
||||
strokeLinecap='round'
|
||||
/>
|
||||
{/* 问号 */}
|
||||
<text
|
||||
x='100'
|
||||
y='160'
|
||||
textAnchor='middle'
|
||||
fontSize='24'
|
||||
fill='url(#notFoundGrad1)'
|
||||
opacity='0.6'
|
||||
>
|
||||
?
|
||||
</text>
|
||||
{/* 装饰星星 */}
|
||||
<path
|
||||
d='M40 40 L42 48 L50 50 L42 52 L40 60 L38 52 L30 50 L38 48 Z'
|
||||
fill='var(--semi-color-warning)'
|
||||
opacity='0.6'
|
||||
>
|
||||
<animate
|
||||
attributeName='opacity'
|
||||
values='0.6;1;0.6'
|
||||
dur='1.5s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</path>
|
||||
<path
|
||||
d='M160 60 L161.5 66 L168 68 L161.5 70 L160 76 L158.5 70 L152 68 L158.5 66 Z'
|
||||
fill='var(--semi-color-danger)'
|
||||
opacity='0.5'
|
||||
>
|
||||
<animate
|
||||
attributeName='opacity'
|
||||
values='0.5;0.9;0.5'
|
||||
dur='2s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</path>
|
||||
</svg>
|
||||
);
|
||||
|
||||
export const IllustrationNotFoundDark = ({ style = {} }) => (
|
||||
<svg
|
||||
viewBox='0 0 200 200'
|
||||
fill='none'
|
||||
xmlns='http://www.w3.org/2000/svg'
|
||||
style={{ width: 150, height: 150, ...style }}
|
||||
>
|
||||
<defs>
|
||||
<linearGradient
|
||||
id='notFoundGradDark1'
|
||||
x1='0%'
|
||||
y1='0%'
|
||||
x2='100%'
|
||||
y2='100%'
|
||||
>
|
||||
<stop offset='0%' stopColor='var(--semi-color-warning)' />
|
||||
<stop offset='100%' stopColor='var(--semi-color-danger)' />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id='notFoundGradDark2'
|
||||
x1='0%'
|
||||
y1='0%'
|
||||
x2='100%'
|
||||
y2='100%'
|
||||
>
|
||||
<stop offset='0%' stopColor='color-mix(in srgb, var(--semi-color-warning) 30%, #000)' />
|
||||
<stop offset='100%' stopColor='color-mix(in srgb, var(--semi-color-danger) 30%, #000)' />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<circle
|
||||
cx='100'
|
||||
cy='100'
|
||||
r='75'
|
||||
fill='url(#notFoundGradDark2)'
|
||||
opacity='0.4'
|
||||
/>
|
||||
<text
|
||||
x='100'
|
||||
y='90'
|
||||
textAnchor='middle'
|
||||
fontSize='48'
|
||||
fontWeight='bold'
|
||||
fill='url(#notFoundGradDark1)'
|
||||
>
|
||||
404
|
||||
</text>
|
||||
<path
|
||||
d='M50 120 Q100 140 150 120'
|
||||
stroke='url(#notFoundGradDark1)'
|
||||
strokeWidth='3'
|
||||
fill='none'
|
||||
strokeLinecap='round'
|
||||
/>
|
||||
<text
|
||||
x='100'
|
||||
y='160'
|
||||
textAnchor='middle'
|
||||
fontSize='24'
|
||||
fill='url(#notFoundGradDark1)'
|
||||
opacity='0.6'
|
||||
>
|
||||
?
|
||||
</text>
|
||||
<path
|
||||
d='M40 40 L42 48 L50 50 L42 52 L40 60 L38 52 L30 50 L38 48 Z'
|
||||
fill='var(--semi-color-warning)'
|
||||
opacity='0.7'
|
||||
>
|
||||
<animate
|
||||
attributeName='opacity'
|
||||
values='0.7;1;0.7'
|
||||
dur='1.5s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</path>
|
||||
<path
|
||||
d='M160 60 L161.5 66 L168 68 L161.5 70 L160 76 L158.5 70 L152 68 L158.5 66 Z'
|
||||
fill='var(--semi-color-danger)'
|
||||
opacity='0.6'
|
||||
>
|
||||
<animate
|
||||
attributeName='opacity'
|
||||
values='0.6;1;0.6'
|
||||
dur='2s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</path>
|
||||
</svg>
|
||||
);
|
||||
|
||||
// ========== 无权限插图 ==========
|
||||
export const IllustrationNoAccess = ({ style = {} }) => (
|
||||
<svg
|
||||
viewBox='0 0 200 200'
|
||||
fill='none'
|
||||
xmlns='http://www.w3.org/2000/svg'
|
||||
style={{ width: 150, height: 150, ...style }}
|
||||
>
|
||||
<defs>
|
||||
<linearGradient id='noAccessGrad1' x1='0%' y1='0%' x2='100%' y2='100%'>
|
||||
<stop offset='0%' stopColor='var(--semi-color-danger)' />
|
||||
<stop offset='100%' stopColor='var(--brand-gradient-via)' />
|
||||
</linearGradient>
|
||||
<linearGradient id='noAccessGrad2' x1='0%' y1='0%' x2='100%' y2='100%'>
|
||||
<stop offset='0%' stopColor='#fce7f3' />
|
||||
<stop offset='100%' stopColor='color-mix(in srgb, var(--brand-gradient-via) 10%, #fff)' />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
{/* 背景 */}
|
||||
<circle cx='100' cy='100' r='75' fill='url(#noAccessGrad2)' opacity='0.5' />
|
||||
{/* 锁身 */}
|
||||
<rect
|
||||
x='65'
|
||||
y='90'
|
||||
width='70'
|
||||
height='55'
|
||||
rx='8'
|
||||
fill='url(#noAccessGrad1)'
|
||||
/>
|
||||
{/* 锁孔 */}
|
||||
<circle cx='100' cy='112' r='8' fill='white' />
|
||||
<rect x='96' y='112' width='8' height='18' rx='2' fill='white' />
|
||||
{/* 锁钩 */}
|
||||
<path
|
||||
d='M75 90 V70 C75 55 85 45 100 45 C115 45 125 55 125 70 V90'
|
||||
stroke='url(#noAccessGrad1)'
|
||||
strokeWidth='8'
|
||||
fill='none'
|
||||
strokeLinecap='round'
|
||||
/>
|
||||
{/* 装饰 */}
|
||||
<circle cx='45' cy='70' r='4' fill='var(--semi-color-danger)' opacity='0.4'>
|
||||
<animate
|
||||
attributeName='r'
|
||||
values='4;6;4'
|
||||
dur='2s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</circle>
|
||||
<circle cx='160' cy='130' r='5' fill='var(--brand-gradient-via)' opacity='0.4'>
|
||||
<animate
|
||||
attributeName='r'
|
||||
values='5;7;5'
|
||||
dur='2.5s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</circle>
|
||||
</svg>
|
||||
);
|
||||
|
||||
export const IllustrationNoAccessDark = ({ style = {} }) => (
|
||||
<svg
|
||||
viewBox='0 0 200 200'
|
||||
fill='none'
|
||||
xmlns='http://www.w3.org/2000/svg'
|
||||
style={{ width: 150, height: 150, ...style }}
|
||||
>
|
||||
<defs>
|
||||
<linearGradient
|
||||
id='noAccessGradDark1'
|
||||
x1='0%'
|
||||
y1='0%'
|
||||
x2='100%'
|
||||
y2='100%'
|
||||
>
|
||||
<stop offset='0%' stopColor='var(--semi-color-danger)' />
|
||||
<stop offset='100%' stopColor='var(--brand-gradient-to)' />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id='noAccessGradDark2'
|
||||
x1='0%'
|
||||
y1='0%'
|
||||
x2='100%'
|
||||
y2='100%'
|
||||
>
|
||||
<stop offset='0%' stopColor='color-mix(in srgb, var(--semi-color-danger) 30%, #000)' />
|
||||
<stop offset='100%' stopColor='color-mix(in srgb, var(--brand-gradient-via) 25%, #000)' />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<circle
|
||||
cx='100'
|
||||
cy='100'
|
||||
r='75'
|
||||
fill='url(#noAccessGradDark2)'
|
||||
opacity='0.4'
|
||||
/>
|
||||
<rect
|
||||
x='65'
|
||||
y='90'
|
||||
width='70'
|
||||
height='55'
|
||||
rx='8'
|
||||
fill='url(#noAccessGradDark1)'
|
||||
/>
|
||||
<circle cx='100' cy='112' r='8' fill='color-mix(in srgb, var(--brand-primary) 15%, #000)' />
|
||||
<rect x='96' y='112' width='8' height='18' rx='2' fill='color-mix(in srgb, var(--brand-primary) 15%, #000)' />
|
||||
<path
|
||||
d='M75 90 V70 C75 55 85 45 100 45 C115 45 125 55 125 70 V90'
|
||||
stroke='url(#noAccessGradDark1)'
|
||||
strokeWidth='8'
|
||||
fill='none'
|
||||
strokeLinecap='round'
|
||||
/>
|
||||
<circle cx='45' cy='70' r='4' fill='var(--semi-color-danger)' opacity='0.5'>
|
||||
<animate
|
||||
attributeName='r'
|
||||
values='4;6;4'
|
||||
dur='2s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</circle>
|
||||
<circle cx='160' cy='130' r='5' fill='var(--brand-gradient-to)' opacity='0.5'>
|
||||
<animate
|
||||
attributeName='r'
|
||||
values='5;7;5'
|
||||
dur='2.5s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</circle>
|
||||
</svg>
|
||||
);
|
||||
|
||||
// ========== 建设中插图 ==========
|
||||
export const IllustrationConstruction = ({ style = {} }) => (
|
||||
<svg
|
||||
viewBox='0 0 200 200'
|
||||
fill='none'
|
||||
xmlns='http://www.w3.org/2000/svg'
|
||||
style={{ width: 150, height: 150, ...style }}
|
||||
>
|
||||
<defs>
|
||||
<linearGradient id='constructGrad1' x1='0%' y1='0%' x2='100%' y2='100%'>
|
||||
<stop offset='0%' stopColor='var(--semi-color-success)' />
|
||||
<stop offset='100%' stopColor='var(--accent-teal)' />
|
||||
</linearGradient>
|
||||
<linearGradient id='constructGrad2' x1='0%' y1='0%' x2='100%' y2='100%'>
|
||||
<stop offset='0%' stopColor='color-mix(in srgb, var(--semi-color-success) 15%, #fff)' />
|
||||
<stop offset='100%' stopColor='color-mix(in srgb, var(--accent-teal) 15%, #fff)' />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
{/* 背景 */}
|
||||
<circle
|
||||
cx='100'
|
||||
cy='100'
|
||||
r='75'
|
||||
fill='url(#constructGrad2)'
|
||||
opacity='0.4'
|
||||
/>
|
||||
{/* 齿轮1 */}
|
||||
<g transform='translate(70, 80)'>
|
||||
<circle
|
||||
cx='20'
|
||||
cy='20'
|
||||
r='15'
|
||||
stroke='url(#constructGrad1)'
|
||||
strokeWidth='4'
|
||||
fill='white'
|
||||
/>
|
||||
<circle cx='20' cy='20' r='6' fill='url(#constructGrad1)' />
|
||||
{[0, 45, 90, 135, 180, 225, 270, 315].map((angle, i) => (
|
||||
<rect
|
||||
key={i}
|
||||
x='17'
|
||||
y='0'
|
||||
width='6'
|
||||
height='8'
|
||||
rx='2'
|
||||
fill='url(#constructGrad1)'
|
||||
transform={`rotate(${angle} 20 20)`}
|
||||
/>
|
||||
))}
|
||||
<animateTransform
|
||||
attributeName='transform'
|
||||
type='rotate'
|
||||
from='0 90 100'
|
||||
to='360 90 100'
|
||||
dur='8s'
|
||||
repeatCount='indefinite'
|
||||
additive='sum'
|
||||
/>
|
||||
</g>
|
||||
{/* 齿轮2 */}
|
||||
<g transform='translate(105, 95)'>
|
||||
<circle
|
||||
cx='15'
|
||||
cy='15'
|
||||
r='12'
|
||||
stroke='url(#constructGrad1)'
|
||||
strokeWidth='3'
|
||||
fill='white'
|
||||
/>
|
||||
<circle cx='15' cy='15' r='5' fill='url(#constructGrad1)' />
|
||||
{[0, 60, 120, 180, 240, 300].map((angle, i) => (
|
||||
<rect
|
||||
key={i}
|
||||
x='13'
|
||||
y='0'
|
||||
width='4'
|
||||
height='6'
|
||||
rx='1'
|
||||
fill='url(#constructGrad1)'
|
||||
transform={`rotate(${angle} 15 15)`}
|
||||
/>
|
||||
))}
|
||||
<animateTransform
|
||||
attributeName='transform'
|
||||
type='rotate'
|
||||
from='360 120 110'
|
||||
to='0 120 110'
|
||||
dur='6s'
|
||||
repeatCount='indefinite'
|
||||
additive='sum'
|
||||
/>
|
||||
</g>
|
||||
{/* 扳手 */}
|
||||
<path
|
||||
d='M55 55 L65 65 L60 70 L50 60 Z'
|
||||
fill='url(#constructGrad1)'
|
||||
opacity='0.7'
|
||||
/>
|
||||
{/* 装饰 */}
|
||||
<circle cx='150' cy='50' r='4' fill='var(--semi-color-success)' opacity='0.5'>
|
||||
<animate
|
||||
attributeName='opacity'
|
||||
values='0.5;1;0.5'
|
||||
dur='2s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</circle>
|
||||
<circle cx='50' cy='150' r='3' fill='var(--accent-teal)' opacity='0.4'>
|
||||
<animate
|
||||
attributeName='opacity'
|
||||
values='0.4;0.8;0.4'
|
||||
dur='2.5s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</circle>
|
||||
</svg>
|
||||
);
|
||||
|
||||
export const IllustrationConstructionDark = ({ style = {} }) => (
|
||||
<svg
|
||||
viewBox='0 0 200 200'
|
||||
fill='none'
|
||||
xmlns='http://www.w3.org/2000/svg'
|
||||
style={{ width: 150, height: 150, ...style }}
|
||||
>
|
||||
<defs>
|
||||
<linearGradient
|
||||
id='constructGradDark1'
|
||||
x1='0%'
|
||||
y1='0%'
|
||||
x2='100%'
|
||||
y2='100%'
|
||||
>
|
||||
<stop offset='0%' stopColor='var(--semi-color-success)' />
|
||||
<stop offset='100%' stopColor='var(--accent-teal)' />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id='constructGradDark2'
|
||||
x1='0%'
|
||||
y1='0%'
|
||||
x2='100%'
|
||||
y2='100%'
|
||||
>
|
||||
<stop offset='0%' stopColor='color-mix(in srgb, var(--semi-color-success) 25%, #000)' />
|
||||
<stop offset='100%' stopColor='color-mix(in srgb, var(--accent-teal) 25%, #000)' />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<circle
|
||||
cx='100'
|
||||
cy='100'
|
||||
r='75'
|
||||
fill='url(#constructGradDark2)'
|
||||
opacity='0.4'
|
||||
/>
|
||||
<g transform='translate(70, 80)'>
|
||||
<circle
|
||||
cx='20'
|
||||
cy='20'
|
||||
r='15'
|
||||
stroke='url(#constructGradDark1)'
|
||||
strokeWidth='4'
|
||||
fill='#0f172a'
|
||||
/>
|
||||
<circle cx='20' cy='20' r='6' fill='url(#constructGradDark1)' />
|
||||
{[0, 45, 90, 135, 180, 225, 270, 315].map((angle, i) => (
|
||||
<rect
|
||||
key={i}
|
||||
x='17'
|
||||
y='0'
|
||||
width='6'
|
||||
height='8'
|
||||
rx='2'
|
||||
fill='url(#constructGradDark1)'
|
||||
transform={`rotate(${angle} 20 20)`}
|
||||
/>
|
||||
))}
|
||||
<animateTransform
|
||||
attributeName='transform'
|
||||
type='rotate'
|
||||
from='0 90 100'
|
||||
to='360 90 100'
|
||||
dur='8s'
|
||||
repeatCount='indefinite'
|
||||
additive='sum'
|
||||
/>
|
||||
</g>
|
||||
<g transform='translate(105, 95)'>
|
||||
<circle
|
||||
cx='15'
|
||||
cy='15'
|
||||
r='12'
|
||||
stroke='url(#constructGradDark1)'
|
||||
strokeWidth='3'
|
||||
fill='#0f172a'
|
||||
/>
|
||||
<circle cx='15' cy='15' r='5' fill='url(#constructGradDark1)' />
|
||||
{[0, 60, 120, 180, 240, 300].map((angle, i) => (
|
||||
<rect
|
||||
key={i}
|
||||
x='13'
|
||||
y='0'
|
||||
width='4'
|
||||
height='6'
|
||||
rx='1'
|
||||
fill='url(#constructGradDark1)'
|
||||
transform={`rotate(${angle} 15 15)`}
|
||||
/>
|
||||
))}
|
||||
<animateTransform
|
||||
attributeName='transform'
|
||||
type='rotate'
|
||||
from='360 120 110'
|
||||
to='0 120 110'
|
||||
dur='6s'
|
||||
repeatCount='indefinite'
|
||||
additive='sum'
|
||||
/>
|
||||
</g>
|
||||
<path
|
||||
d='M55 55 L65 65 L60 70 L50 60 Z'
|
||||
fill='url(#constructGradDark1)'
|
||||
opacity='0.7'
|
||||
/>
|
||||
<circle cx='150' cy='50' r='4' fill='var(--semi-color-success)' opacity='0.6'>
|
||||
<animate
|
||||
attributeName='opacity'
|
||||
values='0.6;1;0.6'
|
||||
dur='2s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</circle>
|
||||
<circle cx='50' cy='150' r='3' fill='var(--accent-teal)' opacity='0.5'>
|
||||
<animate
|
||||
attributeName='opacity'
|
||||
values='0.5;0.9;0.5'
|
||||
dur='2.5s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</circle>
|
||||
</svg>
|
||||
);
|
||||
|
||||
// ========== 无内容插图 ==========
|
||||
export const IllustrationNoContent = ({ style = {} }) => (
|
||||
<svg
|
||||
viewBox='0 0 200 200'
|
||||
fill='none'
|
||||
xmlns='http://www.w3.org/2000/svg'
|
||||
style={{ width: 150, height: 150, ...style }}
|
||||
>
|
||||
<defs>
|
||||
<linearGradient id='noContentGrad1' x1='0%' y1='0%' x2='100%' y2='100%'>
|
||||
<stop offset='0%' stopColor='var(--accent-blue)' />
|
||||
<stop offset='100%' stopColor='var(--brand-gradient-via)' />
|
||||
</linearGradient>
|
||||
<linearGradient id='noContentGrad2' x1='0%' y1='0%' x2='100%' y2='100%'>
|
||||
<stop offset='0%' stopColor='color-mix(in srgb, var(--accent-blue) 12%, #fff)' />
|
||||
<stop offset='100%' stopColor='color-mix(in srgb, var(--brand-gradient-via) 10%, #fff)' />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
{/* 背景 */}
|
||||
<circle
|
||||
cx='100'
|
||||
cy='100'
|
||||
r='75'
|
||||
fill='url(#noContentGrad2)'
|
||||
opacity='0.4'
|
||||
/>
|
||||
{/* 文件夹 */}
|
||||
<path
|
||||
d='M50 70 L50 140 C50 145 55 150 60 150 L140 150 C145 150 150 145 150 140 L150 85 C150 80 145 75 140 75 L100 75 L90 65 L60 65 C55 65 50 70 50 75 Z'
|
||||
fill='url(#noContentGrad1)'
|
||||
opacity='0.9'
|
||||
/>
|
||||
<path
|
||||
d='M50 85 L150 85 L150 140 C150 145 145 150 140 150 L60 150 C55 150 50 145 50 140 Z'
|
||||
fill='white'
|
||||
opacity='0.9'
|
||||
/>
|
||||
{/* 虚线 */}
|
||||
<line
|
||||
x1='70'
|
||||
y1='105'
|
||||
x2='130'
|
||||
y2='105'
|
||||
stroke='url(#noContentGrad1)'
|
||||
strokeWidth='3'
|
||||
strokeDasharray='8,4'
|
||||
opacity='0.5'
|
||||
/>
|
||||
<line
|
||||
x1='70'
|
||||
y1='120'
|
||||
x2='110'
|
||||
y2='120'
|
||||
stroke='url(#noContentGrad1)'
|
||||
strokeWidth='3'
|
||||
strokeDasharray='8,4'
|
||||
opacity='0.3'
|
||||
/>
|
||||
<line
|
||||
x1='70'
|
||||
y1='135'
|
||||
x2='90'
|
||||
y2='135'
|
||||
stroke='url(#noContentGrad1)'
|
||||
strokeWidth='3'
|
||||
strokeDasharray='8,4'
|
||||
opacity='0.2'
|
||||
/>
|
||||
{/* 装饰 */}
|
||||
<circle cx='160' cy='55' r='4' fill='var(--accent-blue)' opacity='0.5'>
|
||||
<animate
|
||||
attributeName='opacity'
|
||||
values='0.5;1;0.5'
|
||||
dur='2s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</circle>
|
||||
<circle cx='40' cy='145' r='3' fill='var(--brand-gradient-via)' opacity='0.4'>
|
||||
<animate
|
||||
attributeName='opacity'
|
||||
values='0.4;0.8;0.4'
|
||||
dur='2.5s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</circle>
|
||||
</svg>
|
||||
);
|
||||
|
||||
export const IllustrationNoContentDark = ({ style = {} }) => (
|
||||
<svg
|
||||
viewBox='0 0 200 200'
|
||||
fill='none'
|
||||
xmlns='http://www.w3.org/2000/svg'
|
||||
style={{ width: 150, height: 150, ...style }}
|
||||
>
|
||||
<defs>
|
||||
<linearGradient
|
||||
id='noContentGradDark1'
|
||||
x1='0%'
|
||||
y1='0%'
|
||||
x2='100%'
|
||||
y2='100%'
|
||||
>
|
||||
<stop offset='0%' stopColor='var(--accent-blue)' />
|
||||
<stop offset='100%' stopColor='var(--brand-gradient-to)' />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id='noContentGradDark2'
|
||||
x1='0%'
|
||||
y1='0%'
|
||||
x2='100%'
|
||||
y2='100%'
|
||||
>
|
||||
<stop offset='0%' stopColor='color-mix(in srgb, var(--accent-blue) 25%, #000)' />
|
||||
<stop offset='100%' stopColor='color-mix(in srgb, var(--brand-gradient-via) 25%, #000)' />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<circle
|
||||
cx='100'
|
||||
cy='100'
|
||||
r='75'
|
||||
fill='url(#noContentGradDark2)'
|
||||
opacity='0.3'
|
||||
/>
|
||||
<path
|
||||
d='M50 70 L50 140 C50 145 55 150 60 150 L140 150 C145 150 150 145 150 140 L150 85 C150 80 145 75 140 75 L100 75 L90 65 L60 65 C55 65 50 70 50 75 Z'
|
||||
fill='url(#noContentGradDark1)'
|
||||
opacity='0.9'
|
||||
/>
|
||||
<path
|
||||
d='M50 85 L150 85 L150 140 C150 145 145 150 140 150 L60 150 C55 150 50 145 50 140 Z'
|
||||
fill='color-mix(in srgb, var(--brand-primary) 15%, #000)'
|
||||
opacity='0.9'
|
||||
/>
|
||||
<line
|
||||
x1='70'
|
||||
y1='105'
|
||||
x2='130'
|
||||
y2='105'
|
||||
stroke='url(#noContentGradDark1)'
|
||||
strokeWidth='3'
|
||||
strokeDasharray='8,4'
|
||||
opacity='0.5'
|
||||
/>
|
||||
<line
|
||||
x1='70'
|
||||
y1='120'
|
||||
x2='110'
|
||||
y2='120'
|
||||
stroke='url(#noContentGradDark1)'
|
||||
strokeWidth='3'
|
||||
strokeDasharray='8,4'
|
||||
opacity='0.3'
|
||||
/>
|
||||
<line
|
||||
x1='70'
|
||||
y1='135'
|
||||
x2='90'
|
||||
y2='135'
|
||||
stroke='url(#noContentGradDark1)'
|
||||
strokeWidth='3'
|
||||
strokeDasharray='8,4'
|
||||
opacity='0.2'
|
||||
/>
|
||||
<circle cx='160' cy='55' r='4' fill='var(--accent-blue)' opacity='0.6'>
|
||||
<animate
|
||||
attributeName='opacity'
|
||||
values='0.6;1;0.6'
|
||||
dur='2s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</circle>
|
||||
<circle cx='40' cy='145' r='3' fill='var(--brand-gradient-to)' opacity='0.5'>
|
||||
<animate
|
||||
attributeName='opacity'
|
||||
values='0.5;0.9;0.5'
|
||||
dur='2.5s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</circle>
|
||||
</svg>
|
||||
);
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
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 React from 'react';
|
||||
|
||||
const DiscordIcon = ({ style = {}, ...props }) => {
|
||||
return (
|
||||
<svg
|
||||
viewBox='0 0 24 24'
|
||||
fill='currentColor'
|
||||
style={{ width: '20px', height: '20px', ...style }}
|
||||
{...props}
|
||||
>
|
||||
<path d='M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z' />
|
||||
</svg>
|
||||
);
|
||||
};
|
||||
|
||||
export default DiscordIcon;
|
||||
@@ -0,0 +1,169 @@
|
||||
/* Dolphin Logo Styles - 海豚图标动画样式 */
|
||||
|
||||
.dolphin-logo {
|
||||
display: inline-block;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
/* 整体游泳动画 */
|
||||
.dolphin-animated .dolphin-body {
|
||||
animation: dolphinSwim 3s ease-in-out infinite;
|
||||
transform-origin: center center;
|
||||
}
|
||||
|
||||
@keyframes dolphinSwim {
|
||||
0%,
|
||||
100% {
|
||||
transform: translateY(0) rotate(0deg);
|
||||
}
|
||||
25% {
|
||||
transform: translateY(-3px) rotate(-2deg);
|
||||
}
|
||||
50% {
|
||||
transform: translateY(0) rotate(0deg);
|
||||
}
|
||||
75% {
|
||||
transform: translateY(2px) rotate(2deg);
|
||||
}
|
||||
}
|
||||
|
||||
/* 尾巴摆动 */
|
||||
.dolphin-animated .dolphin-tail {
|
||||
animation: tailWag 0.8s ease-in-out infinite;
|
||||
transform-origin: 20px 48px;
|
||||
}
|
||||
|
||||
@keyframes tailWag {
|
||||
0%,
|
||||
100% {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
50% {
|
||||
transform: rotate(-8deg);
|
||||
}
|
||||
}
|
||||
|
||||
/* 背鳍微动 */
|
||||
.dolphin-animated .dolphin-fin {
|
||||
animation: finMove 2s ease-in-out infinite;
|
||||
transform-origin: 45px 25px;
|
||||
}
|
||||
|
||||
@keyframes finMove {
|
||||
0%,
|
||||
100% {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
50% {
|
||||
transform: rotate(-3deg);
|
||||
}
|
||||
}
|
||||
|
||||
/* 胸鳍划水 */
|
||||
.dolphin-animated .dolphin-pectoral {
|
||||
animation: pectoralMove 1.5s ease-in-out infinite;
|
||||
transform-origin: 38px 55px;
|
||||
}
|
||||
|
||||
@keyframes pectoralMove {
|
||||
0%,
|
||||
100% {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
50% {
|
||||
transform: rotate(5deg);
|
||||
}
|
||||
}
|
||||
|
||||
/* 眼睛眨眼 */
|
||||
.dolphin-animated .dolphin-eye {
|
||||
animation: blink 4s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes blink {
|
||||
0%,
|
||||
45%,
|
||||
55%,
|
||||
100% {
|
||||
transform: scaleY(1);
|
||||
}
|
||||
50% {
|
||||
transform: scaleY(0.1);
|
||||
}
|
||||
}
|
||||
|
||||
/* 眼睛高光闪烁 */
|
||||
.dolphin-animated .dolphin-eye-highlight {
|
||||
animation: eyeSparkle 2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes eyeSparkle {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
50% {
|
||||
opacity: 0.6;
|
||||
}
|
||||
}
|
||||
|
||||
/* 光泽流动 */
|
||||
.dolphin-animated .dolphin-shine {
|
||||
animation: shineMove 3s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes shineMove {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 0.8;
|
||||
transform: translateX(0);
|
||||
}
|
||||
50% {
|
||||
opacity: 0.4;
|
||||
transform: translateX(2px);
|
||||
}
|
||||
}
|
||||
|
||||
/* 气泡上浮已在 SVG 中定义 */
|
||||
|
||||
/* 悬停效果 */
|
||||
.dolphin-logo:hover .dolphin-body {
|
||||
animation: dolphinJump 0.6s ease-out;
|
||||
}
|
||||
|
||||
@keyframes dolphinJump {
|
||||
0% {
|
||||
transform: translateY(0) rotate(0deg);
|
||||
}
|
||||
30% {
|
||||
transform: translateY(-8px) rotate(-5deg);
|
||||
}
|
||||
60% {
|
||||
transform: translateY(-4px) rotate(3deg);
|
||||
}
|
||||
100% {
|
||||
transform: translateY(0) rotate(0deg);
|
||||
}
|
||||
}
|
||||
|
||||
/* 暗色模式适配 */
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.dolphin-logo {
|
||||
filter: brightness(1.1);
|
||||
}
|
||||
}
|
||||
|
||||
/* 禁用动画时的静态样式 */
|
||||
.dolphin-logo:not(.dolphin-animated) .dolphin-body,
|
||||
.dolphin-logo:not(.dolphin-animated) .dolphin-tail,
|
||||
.dolphin-logo:not(.dolphin-animated) .dolphin-fin,
|
||||
.dolphin-logo:not(.dolphin-animated) .dolphin-pectoral,
|
||||
.dolphin-logo:not(.dolphin-animated) .dolphin-eye,
|
||||
.dolphin-logo:not(.dolphin-animated) .dolphin-eye-highlight,
|
||||
.dolphin-logo:not(.dolphin-animated) .dolphin-shine {
|
||||
animation: none;
|
||||
}
|
||||
|
||||
.dolphin-logo:not(.dolphin-animated) .bubbles {
|
||||
display: none;
|
||||
}
|
||||
@@ -0,0 +1,327 @@
|
||||
/*
|
||||
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 React from 'react';
|
||||
import './DolphinLogo.css';
|
||||
|
||||
/**
|
||||
* Dolphin Logo Component - 海豚动画图标
|
||||
* @param {number} size - Logo 大小(像素),默认 32
|
||||
* @param {string} className - 额外的 CSS 类名
|
||||
* @param {boolean} animated - 是否启用动画,默认 true
|
||||
*/
|
||||
const DolphinLogo = ({ size = 32, className = '', animated = true }) => {
|
||||
return (
|
||||
<svg
|
||||
viewBox='0 0 100 100'
|
||||
xmlns='http://www.w3.org/2000/svg'
|
||||
width={size}
|
||||
height={size}
|
||||
className={`dolphin-logo ${animated ? 'dolphin-animated' : ''} ${className}`}
|
||||
>
|
||||
<defs>
|
||||
{/* 主渐变 - 海洋蓝 */}
|
||||
<linearGradient
|
||||
id='dolphinGradient'
|
||||
x1='0%'
|
||||
y1='0%'
|
||||
x2='100%'
|
||||
y2='100%'
|
||||
>
|
||||
<stop offset='0%' stopColor='#4facfe'>
|
||||
<animate
|
||||
attributeName='stop-color'
|
||||
values='#4facfe;#00f2fe;#38bdf8;#4facfe'
|
||||
dur='4s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</stop>
|
||||
<stop offset='50%' stopColor='#00c6fb'>
|
||||
<animate
|
||||
attributeName='stop-color'
|
||||
values='#00c6fb;#4facfe;#00f2fe;#00c6fb'
|
||||
dur='4s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</stop>
|
||||
<stop offset='100%' stopColor='#005bea'>
|
||||
<animate
|
||||
attributeName='stop-color'
|
||||
values='#005bea;#0083b0;#4facfe;#005bea'
|
||||
dur='4s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</stop>
|
||||
</linearGradient>
|
||||
|
||||
{/* 腹部渐变 - 浅色 */}
|
||||
<linearGradient id='bellyGradient' x1='0%' y1='0%' x2='0%' y2='100%'>
|
||||
<stop offset='0%' stopColor='#e0f7ff' />
|
||||
<stop offset='100%' stopColor='#b8e8fc' />
|
||||
</linearGradient>
|
||||
|
||||
{/* 光泽效果 */}
|
||||
<linearGradient id='shineGradient' x1='0%' y1='0%' x2='100%' y2='100%'>
|
||||
<stop offset='0%' stopColor='#ffffff' stopOpacity='0.6' />
|
||||
<stop offset='50%' stopColor='#ffffff' stopOpacity='0.2' />
|
||||
<stop offset='100%' stopColor='#ffffff' stopOpacity='0' />
|
||||
</linearGradient>
|
||||
|
||||
{/* 阴影滤镜 */}
|
||||
<filter id='dolphinShadow' x='-20%' y='-20%' width='140%' height='140%'>
|
||||
<feDropShadow
|
||||
dx='0'
|
||||
dy='2'
|
||||
stdDeviation='2'
|
||||
floodColor='#0066cc'
|
||||
floodOpacity='0.3'
|
||||
/>
|
||||
</filter>
|
||||
|
||||
{/* 水波纹效果 */}
|
||||
<filter id='waterRipple'>
|
||||
<feTurbulence
|
||||
type='fractalNoise'
|
||||
baseFrequency='0.02'
|
||||
numOctaves='2'
|
||||
result='turbulence'
|
||||
>
|
||||
<animate
|
||||
attributeName='baseFrequency'
|
||||
values='0.02;0.025;0.02'
|
||||
dur='3s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</feTurbulence>
|
||||
<feDisplacementMap
|
||||
in='SourceGraphic'
|
||||
in2='turbulence'
|
||||
scale='1'
|
||||
xChannelSelector='R'
|
||||
yChannelSelector='G'
|
||||
/>
|
||||
</filter>
|
||||
</defs>
|
||||
|
||||
{/* 海豚主体 */}
|
||||
<g className='dolphin-body' filter='url(#dolphinShadow)'>
|
||||
{/* 身体 */}
|
||||
<path
|
||||
className='dolphin-main'
|
||||
d='M 75 45
|
||||
C 80 35, 78 25, 70 22
|
||||
C 62 19, 50 20, 42 25
|
||||
C 34 30, 25 38, 20 48
|
||||
C 15 58, 18 68, 28 72
|
||||
C 38 76, 55 74, 68 65
|
||||
C 78 58, 82 50, 75 45
|
||||
Z'
|
||||
fill='url(#dolphinGradient)'
|
||||
/>
|
||||
|
||||
{/* 腹部 */}
|
||||
<path
|
||||
className='dolphin-belly'
|
||||
d='M 68 52
|
||||
C 65 58, 55 65, 42 66
|
||||
C 32 67, 25 63, 24 56
|
||||
C 23 50, 28 44, 38 42
|
||||
C 50 40, 62 44, 68 52
|
||||
Z'
|
||||
fill='url(#bellyGradient)'
|
||||
opacity='0.9'
|
||||
/>
|
||||
|
||||
{/* 嘴巴/吻部 */}
|
||||
<path
|
||||
className='dolphin-snout'
|
||||
d='M 70 22
|
||||
C 75 20, 82 22, 88 28
|
||||
C 85 30, 78 30, 72 28
|
||||
C 70 26, 70 24, 70 22
|
||||
Z'
|
||||
fill='url(#dolphinGradient)'
|
||||
/>
|
||||
|
||||
{/* 背鳍 */}
|
||||
<path
|
||||
className='dolphin-fin'
|
||||
d='M 45 25
|
||||
C 48 18, 52 12, 50 8
|
||||
C 48 12, 44 18, 42 25
|
||||
Z'
|
||||
fill='url(#dolphinGradient)'
|
||||
/>
|
||||
|
||||
{/* 胸鳍 */}
|
||||
<path
|
||||
className='dolphin-pectoral'
|
||||
d='M 38 55
|
||||
C 32 58, 25 65, 20 70
|
||||
C 22 68, 28 62, 35 58
|
||||
C 36 56, 37 55, 38 55
|
||||
Z'
|
||||
fill='url(#dolphinGradient)'
|
||||
/>
|
||||
|
||||
{/* 尾鳍 */}
|
||||
<path
|
||||
className='dolphin-tail'
|
||||
d='M 20 48
|
||||
C 14 42, 8 38, 5 42
|
||||
C 8 45, 12 48, 15 52
|
||||
M 20 48
|
||||
C 14 54, 8 58, 5 54
|
||||
C 8 52, 12 50, 15 48
|
||||
Z'
|
||||
fill='url(#dolphinGradient)'
|
||||
/>
|
||||
|
||||
{/* 眼睛 */}
|
||||
<ellipse
|
||||
className='dolphin-eye'
|
||||
cx='62'
|
||||
cy='32'
|
||||
rx='3'
|
||||
ry='3.5'
|
||||
fill='#1a365d'
|
||||
/>
|
||||
|
||||
{/* 眼睛高光 */}
|
||||
<ellipse
|
||||
className='dolphin-eye-highlight'
|
||||
cx='63'
|
||||
cy='31'
|
||||
rx='1'
|
||||
ry='1.2'
|
||||
fill='#ffffff'
|
||||
/>
|
||||
|
||||
{/* 身体光泽 */}
|
||||
<path
|
||||
className='dolphin-shine'
|
||||
d='M 55 28
|
||||
C 60 26, 65 28, 68 32
|
||||
C 65 30, 58 28, 52 30
|
||||
C 50 31, 52 29, 55 28
|
||||
Z'
|
||||
fill='url(#shineGradient)'
|
||||
/>
|
||||
|
||||
{/* 微笑线条 */}
|
||||
<path
|
||||
className='dolphin-smile'
|
||||
d='M 75 28 Q 80 30, 84 28'
|
||||
fill='none'
|
||||
stroke='#1a365d'
|
||||
strokeWidth='1'
|
||||
strokeLinecap='round'
|
||||
opacity='0.5'
|
||||
/>
|
||||
</g>
|
||||
|
||||
{/* 水花气泡 */}
|
||||
<g className='bubbles'>
|
||||
<circle
|
||||
className='bubble bubble-1'
|
||||
cx='15'
|
||||
cy='75'
|
||||
r='2'
|
||||
fill='#4facfe'
|
||||
opacity='0.6'
|
||||
>
|
||||
<animate
|
||||
attributeName='cy'
|
||||
values='75;65;55'
|
||||
dur='2s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
<animate
|
||||
attributeName='opacity'
|
||||
values='0.6;0.3;0'
|
||||
dur='2s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
<animate
|
||||
attributeName='r'
|
||||
values='2;3;2'
|
||||
dur='2s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</circle>
|
||||
<circle
|
||||
className='bubble bubble-2'
|
||||
cx='22'
|
||||
cy='80'
|
||||
r='1.5'
|
||||
fill='#00c6fb'
|
||||
opacity='0.5'
|
||||
>
|
||||
<animate
|
||||
attributeName='cy'
|
||||
values='80;68;56'
|
||||
dur='2.5s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
<animate
|
||||
attributeName='opacity'
|
||||
values='0.5;0.2;0'
|
||||
dur='2.5s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
<animate
|
||||
attributeName='r'
|
||||
values='1.5;2.5;1.5'
|
||||
dur='2.5s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</circle>
|
||||
<circle
|
||||
className='bubble bubble-3'
|
||||
cx='10'
|
||||
cy='82'
|
||||
r='1'
|
||||
fill='#38bdf8'
|
||||
opacity='0.4'
|
||||
>
|
||||
<animate
|
||||
attributeName='cy'
|
||||
values='82;72;62'
|
||||
dur='3s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
<animate
|
||||
attributeName='opacity'
|
||||
values='0.4;0.2;0'
|
||||
dur='3s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
<animate
|
||||
attributeName='r'
|
||||
values='1;2;1'
|
||||
dur='3s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</circle>
|
||||
</g>
|
||||
</svg>
|
||||
);
|
||||
};
|
||||
|
||||
export default DolphinLogo;
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
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 React from 'react';
|
||||
import { Icon } from '@douyinfe/semi-ui';
|
||||
|
||||
const LinuxDoIcon = (props) => {
|
||||
function CustomIcon() {
|
||||
return (
|
||||
<svg
|
||||
className='icon'
|
||||
viewBox='0 0 16 16'
|
||||
version='1.1'
|
||||
xmlns='http://www.w3.org/2000/svg'
|
||||
width='1em'
|
||||
height='1em'
|
||||
{...props}
|
||||
>
|
||||
<g id='linuxdo_icon' data-name='linuxdo_icon'>
|
||||
<path
|
||||
d='m7.44,0s.09,0,.13,0c.09,0,.19,0,.28,0,.14,0,.29,0,.43,0,.09,0,.18,0,.27,0q.12,0,.25,0t.26.08c.15.03.29.06.44.08,1.97.38,3.78,1.47,4.95,3.11.04.06.09.12.13.18.67.96,1.15,2.11,1.3,3.28q0,.19.09.26c0,.15,0,.29,0,.44,0,.04,0,.09,0,.13,0,.09,0,.19,0,.28,0,.14,0,.29,0,.43,0,.09,0,.18,0,.27,0,.08,0,.17,0,.25q0,.19-.08.26c-.03.15-.06.29-.08.44-.38,1.97-1.47,3.78-3.11,4.95-.06.04-.12.09-.18.13-.96.67-2.11,1.15-3.28,1.3q-.19,0-.26.09c-.15,0-.29,0-.44,0-.04,0-.09,0-.13,0-.09,0-.19,0-.28,0-.14,0-.29,0-.43,0-.09,0-.18,0-.27,0-.08,0-.17,0-.25,0q-.19,0-.26-.08c-.15-.03-.29-.06-.44-.08-1.97-.38-3.78-1.47-4.95-3.11q-.07-.09-.13-.18c-.67-.96-1.15-2.11-1.3-3.28q0-.19-.09-.26c0-.15,0-.29,0-.44,0-.04,0-.09,0-.13,0-.09,0-.19,0-.28,0-.14,0-.29,0-.43,0-.09,0-.18,0-.27,0-.08,0-.17,0-.25q0-.19.08-.26c.03-.15.06-.29.08-.44.38-1.97,1.47-3.78,3.11-4.95.06-.04.12-.09.18-.13C4.42.73,5.57.26,6.74.1,7,.07,7.15,0,7.44,0Z'
|
||||
fill='#EFEFEF'
|
||||
/>
|
||||
<path
|
||||
d='m1.27,11.33h13.45c-.94,1.89-2.51,3.21-4.51,3.88-1.99.59-3.96.37-5.8-.57-1.25-.7-2.67-1.9-3.14-3.3Z'
|
||||
fill='#FEB005'
|
||||
/>
|
||||
<path
|
||||
d='m12.54,1.99c.87.7,1.82,1.59,2.18,2.68H1.27c.87-1.74,2.33-3.13,4.2-3.78,2.44-.79,5-.47,7.07,1.1Z'
|
||||
fill='#1D1D1F'
|
||||
/>
|
||||
</g>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
return <Icon svg={<CustomIcon />} />;
|
||||
};
|
||||
|
||||
export default LinuxDoIcon;
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
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 React from 'react';
|
||||
import { Icon } from '@douyinfe/semi-ui';
|
||||
|
||||
const OIDCIcon = (props) => {
|
||||
function CustomIcon() {
|
||||
return (
|
||||
<svg
|
||||
t='1723135116886'
|
||||
className='icon'
|
||||
viewBox='0 0 1024 1024'
|
||||
version='1.1'
|
||||
xmlns='http://www.w3.org/2000/svg'
|
||||
p-id='10969'
|
||||
width='20'
|
||||
height='20'
|
||||
>
|
||||
<path
|
||||
d='M512 960C265 960 64 759 64 512S265 64 512 64s448 201 448 448-201 448-448 448z m0-882.6c-239.7 0-434.6 195-434.6 434.6s195 434.6 434.6 434.6 434.6-195 434.6-434.6S751.7 77.4 512 77.4z'
|
||||
p-id='10970'
|
||||
fill='#2c2c2c'
|
||||
stroke='#2c2c2c'
|
||||
stroke-width='60'
|
||||
></path>
|
||||
<path
|
||||
d='M197.7 512c0-78.3 31.6-98.8 87.2-98.8 56.2 0 87.2 20.5 87.2 98.8s-31 98.8-87.2 98.8c-55.7 0-87.2-20.5-87.2-98.8z m130.4 0c0-46.8-7.8-64.5-43.2-64.5-35.2 0-42.9 17.7-42.9 64.5 0 47.1 7.8 63.7 42.9 63.7 35.4 0 43.2-16.6 43.2-63.7zM409.7 415.9h42.1V608h-42.1V415.9zM653.9 512c0 74.2-37.1 96.1-93.6 96.1h-65.9V415.9h65.9c56.5 0 93.6 16.1 93.6 96.1z m-43.5 0c0-49.3-17.7-60.6-52.3-60.6h-21.6v120.7h21.6c35.4 0 52.3-13.3 52.3-60.1zM686.5 512c0-74.2 36.3-98.8 92.7-98.8 18.3 0 33.2 2.2 44.8 6.4v36.3c-11.9-4.2-26-6.6-42.1-6.6-34.6 0-49.8 15.5-49.8 62.6 0 50.1 15.2 62.6 49.3 62.6 15.8 0 30.2-2.2 44.8-7.5v36c-11.3 4.7-28.5 8-46.8 8-56.1-0.2-92.9-18.7-92.9-99z'
|
||||
p-id='10971'
|
||||
fill='#2c2c2c'
|
||||
stroke='#2c2c2c'
|
||||
stroke-width='20'
|
||||
></path>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
return <Icon svg={<CustomIcon />} />;
|
||||
};
|
||||
|
||||
export default OIDCIcon;
|
||||
@@ -0,0 +1,246 @@
|
||||
# WeeLogo 组件使用说明
|
||||
|
||||
## 简介
|
||||
|
||||
WeeLogo 是一个基于 SVG 的动画 Logo 组件,提供 4 种不同的视觉风格。这个组件从原始的 HTML logo 文件中提取并转换为 React 组件。
|
||||
|
||||
## 可用风格
|
||||
|
||||
1. **minimalist** - 极简线条风格(默认)
|
||||
- 简洁的线条设计
|
||||
- 柔和的渐变动画
|
||||
- 适合现代简约的界面
|
||||
|
||||
2. **modern** - 现代圆润风格
|
||||
- 圆润的形状设计
|
||||
- 浮动动画效果
|
||||
- 适合友好、亲和的界面
|
||||
|
||||
3. **tech** - 科技未来风格
|
||||
- 科技感强烈的发光效果
|
||||
- 扫描线动画
|
||||
- 适合科技、创新主题
|
||||
|
||||
4. **wave** - 波浪流动风格
|
||||
- 流畅的波浪效果
|
||||
- 液态动画
|
||||
- 适合创意、动态的界面
|
||||
|
||||
## 基本使用
|
||||
|
||||
### 导入组件
|
||||
|
||||
```jsx
|
||||
import WeeLogo from '../../components/common/logo/WeeLogo';
|
||||
```
|
||||
|
||||
### 使用示例
|
||||
|
||||
#### 1. 默认使用(极简风格,32px)
|
||||
|
||||
```jsx
|
||||
<WeeLogo />
|
||||
```
|
||||
|
||||
#### 2. 指定风格
|
||||
|
||||
```jsx
|
||||
<WeeLogo style="modern" />
|
||||
<WeeLogo style="tech" />
|
||||
<WeeLogo style="wave" />
|
||||
```
|
||||
|
||||
#### 3. 自定义大小
|
||||
|
||||
```jsx
|
||||
{
|
||||
/* 64px 高度 */
|
||||
}
|
||||
<WeeLogo size={64} />;
|
||||
|
||||
{
|
||||
/* 48px 高度 */
|
||||
}
|
||||
<WeeLogo style='tech' size={48} />;
|
||||
```
|
||||
|
||||
#### 4. 添加自定义样式
|
||||
|
||||
```jsx
|
||||
<WeeLogo style='modern' size={40} className='my-custom-class' />
|
||||
```
|
||||
|
||||
## 在 HeaderLogo 中使用
|
||||
|
||||
HeaderLogo 组件已经集成了 WeeLogo 支持:
|
||||
|
||||
```jsx
|
||||
<HeaderLogo
|
||||
useSvgLogo={true} // 启用 SVG logo
|
||||
logoStyle='minimalist' // 选择风格
|
||||
// ... 其他 props
|
||||
/>
|
||||
```
|
||||
|
||||
### 完整示例
|
||||
|
||||
```jsx
|
||||
import React from 'react';
|
||||
import HeaderLogo from './components/layout/headerbar/HeaderLogo';
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<HeaderLogo
|
||||
isMobile={false}
|
||||
isConsoleRoute={false}
|
||||
logo='/path/to/fallback-logo.png'
|
||||
logoLoaded={true}
|
||||
isLoading={false}
|
||||
systemName='My System'
|
||||
isSelfUseMode={false}
|
||||
isDemoSiteMode={false}
|
||||
t={(key) => key}
|
||||
useSvgLogo={true} // 使用 SVG logo
|
||||
logoStyle='tech' // 科技风格
|
||||
/>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
## Props 说明
|
||||
|
||||
### WeeLogo
|
||||
|
||||
| Prop | 类型 | 默认值 | 说明 |
|
||||
| --------- | ------ | ------------ | ------------------------------------------------------- |
|
||||
| style | string | 'minimalist' | Logo 风格: 'minimalist' \| 'modern' \| 'tech' \| 'wave' |
|
||||
| size | number | 32 | Logo 高度(像素),宽度自动按 2:1 比例计算 |
|
||||
| className | string | '' | 自定义 CSS 类名 |
|
||||
|
||||
### HeaderLogo (新增 Props)
|
||||
|
||||
| Prop | 类型 | 默认值 | 说明 |
|
||||
| ---------- | ------- | ------------ | -------------------------- |
|
||||
| useSvgLogo | boolean | false | 是否使用 SVG logo 而非图片 |
|
||||
| logoStyle | string | 'minimalist' | SVG logo 风格 |
|
||||
|
||||
## 样式自定义
|
||||
|
||||
可以通过 CSS 覆盖默认样式:
|
||||
|
||||
```css
|
||||
/* 修改动画速度 */
|
||||
.wee-logo-minimalist .letter {
|
||||
animation-duration: 5s !important;
|
||||
}
|
||||
|
||||
/* 修改颜色(需要修改 SVG gradient) */
|
||||
.my-custom-logo {
|
||||
filter: hue-rotate(45deg);
|
||||
}
|
||||
|
||||
/* 修改大小(也可以用 size prop) */
|
||||
.wee-logo {
|
||||
transform: scale(1.5);
|
||||
}
|
||||
```
|
||||
|
||||
## 注意事项
|
||||
|
||||
1. **性能**: SVG 动画比图片稍微占用更多 CPU,但在现代浏览器中性能表现良好
|
||||
2. **兼容性**: 所有现代浏览器都支持 SVG 动画,包括移动端
|
||||
3. **尺寸**: Logo 的宽高比固定为 2:1,只需设置高度即可
|
||||
4. **主题**: Logo 动画颜色是硬编码的,如需适配深色/浅色主题,可能需要添加额外的 CSS
|
||||
|
||||
## 迁移指南
|
||||
|
||||
### 从图片 Logo 迁移到 SVG Logo
|
||||
|
||||
**之前:**
|
||||
|
||||
```jsx
|
||||
<HeaderLogo
|
||||
logo='/logo.png'
|
||||
logoLoaded={true}
|
||||
// ...
|
||||
/>
|
||||
```
|
||||
|
||||
**之后:**
|
||||
|
||||
```jsx
|
||||
<HeaderLogo
|
||||
logo='/logo.png' // 保留作为后备
|
||||
logoLoaded={true}
|
||||
useSvgLogo={true} // 启用 SVG
|
||||
logoStyle='minimalist' // 选择风格
|
||||
// ...
|
||||
/>
|
||||
```
|
||||
|
||||
## 文件位置
|
||||
|
||||
- 组件: `web/src/components/common/logo/WeeLogo.jsx`
|
||||
- 样式: `web/src/components/common/logo/WeeLogo.css`
|
||||
- 原始设计: `web/src/components/common/logo/wee-logo-style*.html`
|
||||
|
||||
## 示例页面
|
||||
|
||||
可以创建一个专门的页面来展示所有 Logo 风格:
|
||||
|
||||
```jsx
|
||||
import React from 'react';
|
||||
import WeeLogo from './components/common/logo/WeeLogo';
|
||||
|
||||
function LogoShowcase() {
|
||||
const styles = ['minimalist', 'modern', 'tech', 'wave'];
|
||||
|
||||
return (
|
||||
<div style={{ padding: '40px' }}>
|
||||
<h1>WeeLogo 风格展示</h1>
|
||||
<div
|
||||
style={{
|
||||
display: 'grid',
|
||||
gridTemplateColumns: 'repeat(2, 1fr)',
|
||||
gap: '40px',
|
||||
}}
|
||||
>
|
||||
{styles.map((style) => (
|
||||
<div
|
||||
key={style}
|
||||
style={{
|
||||
padding: '20px',
|
||||
background: style === 'tech' ? '#0a0e27' : '#f5f5f5',
|
||||
borderRadius: '10px',
|
||||
textAlign: 'center',
|
||||
}}
|
||||
>
|
||||
<h3>{style}</h3>
|
||||
<WeeLogo style={style} size={48} />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default LogoShowcase;
|
||||
```
|
||||
|
||||
## 故障排除
|
||||
|
||||
### Logo 不显示
|
||||
|
||||
- 检查 WeeLogo.css 是否正确导入
|
||||
- 检查浏览器控制台是否有错误
|
||||
- 确认 style prop 的值是有效的
|
||||
|
||||
### 动画不流畅
|
||||
|
||||
- 检查是否同时显示了太多动画元素
|
||||
- 考虑在移动设备上禁用复杂动画
|
||||
|
||||
### 大小不正确
|
||||
|
||||
- 确认 size prop 是数字类型,不是字符串
|
||||
- 检查父容器是否有限制大小的样式
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
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 React from 'react';
|
||||
import { Icon } from '@douyinfe/semi-ui';
|
||||
|
||||
const WeChatIcon = () => {
|
||||
function CustomIcon() {
|
||||
return (
|
||||
<svg
|
||||
t='1709714447384'
|
||||
className='icon'
|
||||
viewBox='0 0 1024 1024'
|
||||
version='1.1'
|
||||
xmlns='http://www.w3.org/2000/svg'
|
||||
p-id='5091'
|
||||
width='20'
|
||||
height='20'
|
||||
>
|
||||
<path
|
||||
d='M690.1 377.4c5.9 0 11.8 0.2 17.6 0.5-24.4-128.7-158.3-227.1-319.9-227.1C209 150.8 64 271.4 64 420.2c0 81.1 43.6 154.2 111.9 203.6 5.5 3.9 9.1 10.3 9.1 17.6 0 2.4-0.5 4.6-1.1 6.9-5.5 20.3-14.2 52.8-14.6 54.3-0.7 2.6-1.7 5.2-1.7 7.9 0 5.9 4.8 10.8 10.8 10.8 2.3 0 4.2-0.9 6.2-2l70.9-40.9c5.3-3.1 11-5 17.2-5 3.2 0 6.4 0.5 9.5 1.4 33.1 9.5 68.8 14.8 105.7 14.8 6 0 11.9-0.1 17.8-0.4-7.1-21-10.9-43.1-10.9-66 0-135.8 132.2-245.8 295.3-245.8z m-194.3-86.5c23.8 0 43.2 19.3 43.2 43.1s-19.3 43.1-43.2 43.1c-23.8 0-43.2-19.3-43.2-43.1s19.4-43.1 43.2-43.1z m-215.9 86.2c-23.8 0-43.2-19.3-43.2-43.1s19.3-43.1 43.2-43.1 43.2 19.3 43.2 43.1-19.4 43.1-43.2 43.1z'
|
||||
p-id='5092'
|
||||
></path>
|
||||
<path
|
||||
d='M866.7 792.7c56.9-41.2 93.2-102 93.2-169.7 0-124-120.8-224.5-269.9-224.5-149 0-269.9 100.5-269.9 224.5S540.9 847.5 690 847.5c30.8 0 60.6-4.4 88.1-12.3 2.6-0.8 5.2-1.2 7.9-1.2 5.2 0 9.9 1.6 14.3 4.1l59.1 34c1.7 1 3.3 1.7 5.2 1.7 2.4 0 4.7-0.9 6.4-2.6 1.7-1.7 2.6-4 2.6-6.4 0-2.2-0.9-4.4-1.4-6.6-0.3-1.2-7.6-28.3-12.2-45.3-0.5-1.9-0.9-3.8-0.9-5.7 0.1-5.9 3.1-11.2 7.6-14.5zM600.2 587.2c-19.9 0-36-16.1-36-35.9 0-19.8 16.1-35.9 36-35.9s36 16.1 36 35.9c0 19.8-16.2 35.9-36 35.9z m179.9 0c-19.9 0-36-16.1-36-35.9 0-19.8 16.1-35.9 36-35.9s36 16.1 36 35.9c-0.1 19.8-16.2 35.9-36 35.9z'
|
||||
p-id='5093'
|
||||
></path>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Icon svg={<CustomIcon />} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default WeChatIcon;
|
||||
@@ -0,0 +1,144 @@
|
||||
/* Wee Logo Styles */
|
||||
|
||||
.wee-logo {
|
||||
display: inline-block;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
/* Minimalist Style */
|
||||
.wee-logo-minimalist .letter {
|
||||
animation: pulse 3s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.wee-logo-minimalist .w1 {
|
||||
animation-delay: 0s;
|
||||
}
|
||||
|
||||
.wee-logo-minimalist .e1 {
|
||||
animation-delay: 0.3s;
|
||||
}
|
||||
|
||||
.wee-logo-minimalist .e2 {
|
||||
animation-delay: 0.6s;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
50% {
|
||||
opacity: 0.7;
|
||||
}
|
||||
}
|
||||
|
||||
/* Modern Style */
|
||||
.wee-logo-modern .w-letter,
|
||||
.wee-logo-modern .e1-letter,
|
||||
.wee-logo-modern .e2-letter {
|
||||
animation: float 2s ease-in-out infinite;
|
||||
transform-origin: center;
|
||||
}
|
||||
|
||||
.wee-logo-modern .e1-letter {
|
||||
animation-delay: 0.2s;
|
||||
}
|
||||
|
||||
.wee-logo-modern .e2-letter {
|
||||
animation-delay: 0.4s;
|
||||
}
|
||||
|
||||
@keyframes float {
|
||||
0%,
|
||||
100% {
|
||||
transform: translateY(0px);
|
||||
}
|
||||
50% {
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
}
|
||||
|
||||
/* Tech Style */
|
||||
.wee-logo-tech .letter-group {
|
||||
animation: glow 2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.wee-logo-tech .w-tech {
|
||||
animation-delay: 0s;
|
||||
}
|
||||
|
||||
.wee-logo-tech .e1-tech {
|
||||
animation-delay: 0.3s;
|
||||
}
|
||||
|
||||
.wee-logo-tech .e2-tech {
|
||||
animation-delay: 0.6s;
|
||||
}
|
||||
|
||||
.wee-logo-tech .scan-line {
|
||||
animation: scan 3s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes glow {
|
||||
0%,
|
||||
100% {
|
||||
filter: drop-shadow(0 0 2px rgba(74, 144, 226, 0.4))
|
||||
drop-shadow(0 0 4px rgba(74, 144, 226, 0.3));
|
||||
}
|
||||
50% {
|
||||
filter: drop-shadow(0 0 4px rgba(74, 144, 226, 0.6))
|
||||
drop-shadow(0 0 8px rgba(74, 144, 226, 0.4));
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes scan {
|
||||
0% {
|
||||
transform: translateX(-100%);
|
||||
opacity: 0;
|
||||
}
|
||||
50% {
|
||||
opacity: 1;
|
||||
}
|
||||
100% {
|
||||
transform: translateX(500%);
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Wave Style */
|
||||
.wee-logo-wave .liquid-bg {
|
||||
animation: liquidMove 8s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.wee-logo-wave .flow-w,
|
||||
.wee-logo-wave .flow-e1,
|
||||
.wee-logo-wave .flow-e2 {
|
||||
animation: flowText 2s ease-in-out infinite alternate;
|
||||
}
|
||||
|
||||
.wee-logo-wave .flow-e1 {
|
||||
animation-delay: 0.2s;
|
||||
}
|
||||
|
||||
.wee-logo-wave .flow-e2 {
|
||||
animation-delay: 0.4s;
|
||||
}
|
||||
|
||||
@keyframes liquidMove {
|
||||
0%,
|
||||
100% {
|
||||
transform: translateY(0) scale(1);
|
||||
}
|
||||
50% {
|
||||
transform: translateY(-2px) scale(1.01);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes flowText {
|
||||
0% {
|
||||
transform: translateX(0);
|
||||
}
|
||||
100% {
|
||||
transform: translateX(2px);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,502 @@
|
||||
/*
|
||||
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 React from 'react';
|
||||
import './WeeLogo.css';
|
||||
|
||||
/**
|
||||
* Wee Logo Component
|
||||
* @param {string} style - Logo style: 'minimalist' | 'modern' | 'tech' | 'wave' (default: 'minimalist')
|
||||
* @param {number} size - Logo size in pixels (default: 32)
|
||||
* @param {string} className - Additional CSS classes
|
||||
*/
|
||||
const WeeLogo = ({ style = 'minimalist', size = 32, className = '' }) => {
|
||||
const aspectRatio = 2; // width/height ratio
|
||||
const width = size * aspectRatio;
|
||||
const height = size;
|
||||
|
||||
// Style 1: Minimalist Lines
|
||||
const MinimalistLogo = () => (
|
||||
<svg
|
||||
viewBox='0 0 400 200'
|
||||
xmlns='http://www.w3.org/2000/svg'
|
||||
width={width}
|
||||
height={height}
|
||||
className={`wee-logo wee-logo-minimalist ${className}`}
|
||||
>
|
||||
<defs>
|
||||
<linearGradient id='blueGradient' x1='0%' y1='0%' x2='100%' y2='100%'>
|
||||
<stop offset='0%' style={{ stopColor: '#4A90E2', stopOpacity: 1 }}>
|
||||
<animate
|
||||
attributeName='stop-color'
|
||||
values='#4A90E2;#2E5C8A;#4A90E2'
|
||||
dur='4s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</stop>
|
||||
<stop offset='100%' style={{ stopColor: '#1E3A5F', stopOpacity: 1 }}>
|
||||
<animate
|
||||
attributeName='stop-color'
|
||||
values='#1E3A5F;#4A90E2;#1E3A5F'
|
||||
dur='4s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</stop>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
|
||||
{/* W */}
|
||||
<path
|
||||
className='letter w1'
|
||||
d='M 20 60 L 40 140 L 60 100 L 80 140 L 100 60'
|
||||
strokeWidth='8'
|
||||
strokeLinecap='round'
|
||||
strokeLinejoin='round'
|
||||
fill='none'
|
||||
stroke='url(#blueGradient)'
|
||||
/>
|
||||
|
||||
{/* E */}
|
||||
<path
|
||||
className='letter e1'
|
||||
d='M 150 60 L 150 140 M 150 60 L 230 60 M 150 100 L 210 100 M 150 140 L 230 140'
|
||||
strokeWidth='8'
|
||||
strokeLinecap='round'
|
||||
strokeLinejoin='round'
|
||||
fill='none'
|
||||
stroke='url(#blueGradient)'
|
||||
/>
|
||||
|
||||
{/* E */}
|
||||
<path
|
||||
className='letter e2'
|
||||
d='M 270 60 L 270 140 M 270 60 L 350 60 M 270 100 L 330 100 M 270 140 L 350 140'
|
||||
strokeWidth='8'
|
||||
strokeLinecap='round'
|
||||
strokeLinejoin='round'
|
||||
fill='none'
|
||||
stroke='url(#blueGradient)'
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
|
||||
// Style 2: Modern Rounded
|
||||
const ModernLogo = () => (
|
||||
<svg
|
||||
viewBox='0 0 420 200'
|
||||
xmlns='http://www.w3.org/2000/svg'
|
||||
width={width}
|
||||
height={height}
|
||||
className={`wee-logo wee-logo-modern ${className}`}
|
||||
>
|
||||
<defs>
|
||||
<linearGradient id='blueGradient2' x1='0%' y1='0%' x2='100%' y2='100%'>
|
||||
<stop offset='0%' style={{ stopColor: '#5DADE2', stopOpacity: 1 }}>
|
||||
<animate
|
||||
attributeName='stop-color'
|
||||
values='#5DADE2;#3498DB;#2E86C1;#5DADE2'
|
||||
dur='3s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</stop>
|
||||
<stop offset='50%' style={{ stopColor: '#3498DB', stopOpacity: 1 }}>
|
||||
<animate
|
||||
attributeName='stop-color'
|
||||
values='#3498DB;#2E86C1;#5DADE2;#3498DB'
|
||||
dur='3s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</stop>
|
||||
<stop offset='100%' style={{ stopColor: '#2874A6', stopOpacity: 1 }}>
|
||||
<animate
|
||||
attributeName='stop-color'
|
||||
values='#2874A6;#5DADE2;#3498DB;#2874A6'
|
||||
dur='3s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</stop>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
|
||||
{/* W */}
|
||||
<g className='w-letter'>
|
||||
<path
|
||||
className='letter'
|
||||
fill='url(#blueGradient2)'
|
||||
d='M 10,50 Q 20,40 30,50 L 35,120 Q 37,130 45,130 Q 53,130 55,120 L 60,80 Q 62,70 70,70 Q 78,70 80,80 L 85,120 Q 87,130 95,130 Q 103,130 105,120 L 110,50 Q 120,40 130,50 L 135,60 L 115,130 Q 110,145 95,145 Q 85,145 80,135 L 70,105 L 60,135 Q 55,145 45,145 Q 30,145 25,130 L 5,60 Z'
|
||||
/>
|
||||
</g>
|
||||
|
||||
{/* First E */}
|
||||
<g className='e1-letter'>
|
||||
<path
|
||||
className='letter'
|
||||
fill='url(#blueGradient2)'
|
||||
d='M 170,50 Q 180,40 200,45 L 240,50 Q 250,52 248,62 Q 246,72 236,70 L 200,65 L 200,90 L 225,92 Q 235,93 233,103 Q 231,113 221,112 L 200,110 L 200,130 L 240,135 Q 250,136 248,146 Q 246,156 236,155 L 200,150 Q 180,148 170,138 Z'
|
||||
/>
|
||||
</g>
|
||||
|
||||
{/* Second E */}
|
||||
<g className='e2-letter'>
|
||||
<path
|
||||
className='letter'
|
||||
fill='url(#blueGradient2)'
|
||||
d='M 280,50 Q 290,40 310,45 L 350,50 Q 360,52 358,62 Q 356,72 346,70 L 310,65 L 310,90 L 335,92 Q 345,93 343,103 Q 341,113 331,112 L 310,110 L 310,130 L 350,135 Q 360,136 358,146 Q 356,156 346,155 L 310,150 Q 290,148 280,138 Z'
|
||||
/>
|
||||
</g>
|
||||
</svg>
|
||||
);
|
||||
|
||||
// Style 3: Tech Futuristic
|
||||
const TechLogo = () => (
|
||||
<svg
|
||||
viewBox='0 0 400 200'
|
||||
xmlns='http://www.w3.org/2000/svg'
|
||||
width={width}
|
||||
height={height}
|
||||
className={`wee-logo wee-logo-tech ${className}`}
|
||||
>
|
||||
<defs>
|
||||
<linearGradient id='techGradient' x1='0%' y1='0%' x2='100%' y2='100%'>
|
||||
<stop offset='0%' style={{ stopColor: '#00D9FF', stopOpacity: 1 }}>
|
||||
<animate
|
||||
attributeName='stop-color'
|
||||
values='#00D9FF;#0099FF;#0066FF;#00D9FF'
|
||||
dur='2s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</stop>
|
||||
<stop offset='100%' style={{ stopColor: '#0066FF', stopOpacity: 1 }}>
|
||||
<animate
|
||||
attributeName='stop-color'
|
||||
values='#0066FF;#00D9FF;#0099FF;#0066FF'
|
||||
dur='2s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</stop>
|
||||
</linearGradient>
|
||||
|
||||
<linearGradient id='glowGradient' x1='0%' y1='0%' x2='100%' y2='0%'>
|
||||
<stop
|
||||
offset='0%'
|
||||
style={{ stopColor: '#4A90E2', stopOpacity: 0.5 }}
|
||||
/>
|
||||
<stop offset='50%' style={{ stopColor: '#00D9FF', stopOpacity: 1 }}>
|
||||
<animate
|
||||
attributeName='offset'
|
||||
values='0;1;0'
|
||||
dur='2s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</stop>
|
||||
<stop
|
||||
offset='100%'
|
||||
style={{ stopColor: '#4A90E2', stopOpacity: 0.5 }}
|
||||
/>
|
||||
</linearGradient>
|
||||
|
||||
<filter id='glow'>
|
||||
<feGaussianBlur stdDeviation='3' result='coloredBlur' />
|
||||
<feMerge>
|
||||
<feMergeNode in='coloredBlur' />
|
||||
<feMergeNode in='SourceGraphic' />
|
||||
</feMerge>
|
||||
</filter>
|
||||
</defs>
|
||||
|
||||
{/* Scan line effect */}
|
||||
<rect
|
||||
className='scan-line'
|
||||
x='0'
|
||||
y='0'
|
||||
width='20'
|
||||
height='200'
|
||||
fill='url(#glowGradient)'
|
||||
opacity='0.3'
|
||||
/>
|
||||
|
||||
{/* W */}
|
||||
<g className='letter-group w-tech'>
|
||||
<text
|
||||
className='letter'
|
||||
x='10'
|
||||
y='140'
|
||||
fontFamily="'Arial Black', sans-serif"
|
||||
fontSize='120'
|
||||
fontWeight='900'
|
||||
fill='url(#techGradient)'
|
||||
stroke='url(#glowGradient)'
|
||||
strokeWidth='2'
|
||||
filter='url(#glow)'
|
||||
>
|
||||
W
|
||||
</text>
|
||||
</g>
|
||||
|
||||
{/* E */}
|
||||
<g className='letter-group e1-tech'>
|
||||
<text
|
||||
className='letter'
|
||||
x='140'
|
||||
y='140'
|
||||
fontFamily="'Arial Black', sans-serif"
|
||||
fontSize='120'
|
||||
fontWeight='900'
|
||||
fill='url(#techGradient)'
|
||||
stroke='url(#glowGradient)'
|
||||
strokeWidth='2'
|
||||
filter='url(#glow)'
|
||||
>
|
||||
E
|
||||
</text>
|
||||
</g>
|
||||
|
||||
{/* E */}
|
||||
<g className='letter-group e2-tech'>
|
||||
<text
|
||||
className='letter'
|
||||
x='260'
|
||||
y='140'
|
||||
fontFamily="'Arial Black', sans-serif"
|
||||
fontSize='120'
|
||||
fontWeight='900'
|
||||
fill='url(#techGradient)'
|
||||
stroke='url(#glowGradient)'
|
||||
strokeWidth='2'
|
||||
filter='url(#glow)'
|
||||
>
|
||||
E
|
||||
</text>
|
||||
</g>
|
||||
|
||||
{/* Grid lines for tech effect */}
|
||||
<line
|
||||
x1='0'
|
||||
y1='180'
|
||||
x2='400'
|
||||
y2='180'
|
||||
stroke='#0099FF'
|
||||
strokeWidth='0.5'
|
||||
opacity='0.3'
|
||||
>
|
||||
<animate
|
||||
attributeName='opacity'
|
||||
values='0.3;0.6;0.3'
|
||||
dur='2s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</line>
|
||||
<line
|
||||
x1='0'
|
||||
y1='190'
|
||||
x2='400'
|
||||
y2='190'
|
||||
stroke='#00D9FF'
|
||||
strokeWidth='0.5'
|
||||
opacity='0.2'
|
||||
>
|
||||
<animate
|
||||
attributeName='opacity'
|
||||
values='0.2;0.5;0.2'
|
||||
dur='2s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</line>
|
||||
</svg>
|
||||
);
|
||||
|
||||
// Style 4: Wave Flow
|
||||
const WaveLogo = () => (
|
||||
<svg
|
||||
viewBox='0 0 500 220'
|
||||
xmlns='http://www.w3.org/2000/svg'
|
||||
width={width}
|
||||
height={height}
|
||||
className={`wee-logo wee-logo-wave ${className}`}
|
||||
>
|
||||
<defs>
|
||||
<linearGradient id='waveGradient' x1='0%' y1='0%' x2='100%' y2='100%'>
|
||||
<stop offset='0%' style={{ stopColor: '#2193b0', stopOpacity: 1 }}>
|
||||
<animate
|
||||
attributeName='stop-color'
|
||||
values='#2193b0;#6dd5ed;#4facfe;#2193b0'
|
||||
dur='4s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</stop>
|
||||
<stop offset='50%' style={{ stopColor: '#4facfe', stopOpacity: 1 }}>
|
||||
<animate
|
||||
attributeName='stop-color'
|
||||
values='#4facfe;#00f2fe;#2193b0;#4facfe'
|
||||
dur='4s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</stop>
|
||||
<stop offset='100%' style={{ stopColor: '#00f2fe', stopOpacity: 1 }}>
|
||||
<animate
|
||||
attributeName='stop-color'
|
||||
values='#00f2fe;#4facfe;#6dd5ed;#00f2fe'
|
||||
dur='4s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</stop>
|
||||
</linearGradient>
|
||||
|
||||
<filter id='liquid'>
|
||||
<feTurbulence
|
||||
type='fractalNoise'
|
||||
baseFrequency='0.01'
|
||||
numOctaves='3'
|
||||
result='turbulence'
|
||||
>
|
||||
<animate
|
||||
attributeName='baseFrequency'
|
||||
values='0.01;0.02;0.01'
|
||||
dur='10s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</feTurbulence>
|
||||
<feDisplacementMap
|
||||
in='SourceGraphic'
|
||||
in2='turbulence'
|
||||
scale='5'
|
||||
xChannelSelector='R'
|
||||
yChannelSelector='G'
|
||||
/>
|
||||
</filter>
|
||||
</defs>
|
||||
|
||||
{/* Background liquid shapes */}
|
||||
<ellipse
|
||||
className='liquid-bg'
|
||||
cx='100'
|
||||
cy='150'
|
||||
rx='80'
|
||||
ry='60'
|
||||
fill='url(#waveGradient)'
|
||||
opacity='0.1'
|
||||
filter='url(#liquid)'
|
||||
/>
|
||||
<ellipse
|
||||
className='liquid-bg'
|
||||
cx='250'
|
||||
cy='140'
|
||||
rx='90'
|
||||
ry='70'
|
||||
fill='url(#waveGradient)'
|
||||
opacity='0.1'
|
||||
filter='url(#liquid)'
|
||||
style={{ animationDelay: '1s' }}
|
||||
/>
|
||||
<ellipse
|
||||
className='liquid-bg'
|
||||
cx='400'
|
||||
cy='145'
|
||||
rx='85'
|
||||
ry='65'
|
||||
fill='url(#waveGradient)'
|
||||
opacity='0.1'
|
||||
filter='url(#liquid)'
|
||||
style={{ animationDelay: '2s' }}
|
||||
/>
|
||||
|
||||
{/* Wave path for baseline */}
|
||||
<path id='wavePath' d='M 0,140 Q 125,120 250,140 T 500,140' fill='none' />
|
||||
|
||||
{/* Text on wave path */}
|
||||
<text
|
||||
className='wave-text'
|
||||
fontSize='120'
|
||||
fontWeight='900'
|
||||
fill='url(#waveGradient)'
|
||||
fontFamily="'Arial Rounded MT Bold', 'Helvetica Rounded', Arial, sans-serif"
|
||||
>
|
||||
<textPath href='#wavePath' startOffset='8%'>
|
||||
<tspan className='flow-w'>w</tspan>
|
||||
<tspan className='flow-e1'>e</tspan>
|
||||
<tspan className='flow-e2'>e</tspan>
|
||||
<animate
|
||||
attributeName='startOffset'
|
||||
values='8%;10%;8%'
|
||||
dur='3s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</textPath>
|
||||
</text>
|
||||
|
||||
{/* Decorative dots */}
|
||||
<circle cx='50' cy='100' r='3' fill='#4facfe' opacity='0.6'>
|
||||
<animate
|
||||
attributeName='cy'
|
||||
values='100;95;100'
|
||||
dur='2s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
<animate
|
||||
attributeName='opacity'
|
||||
values='0.6;1;0.6'
|
||||
dur='2s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</circle>
|
||||
<circle cx='450' cy='110' r='3' fill='#2193b0' opacity='0.6'>
|
||||
<animate
|
||||
attributeName='cy'
|
||||
values='110;105;110'
|
||||
dur='2.5s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
<animate
|
||||
attributeName='opacity'
|
||||
values='0.6;1;0.6'
|
||||
dur='2.5s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</circle>
|
||||
<circle cx='250' cy='95' r='3' fill='#00f2fe' opacity='0.6'>
|
||||
<animate
|
||||
attributeName='cy'
|
||||
values='95;90;95'
|
||||
dur='2.2s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
<animate
|
||||
attributeName='opacity'
|
||||
values='0.6;1;0.6'
|
||||
dur='2.2s'
|
||||
repeatCount='indefinite'
|
||||
/>
|
||||
</circle>
|
||||
</svg>
|
||||
);
|
||||
|
||||
// Select logo style
|
||||
const logos = {
|
||||
minimalist: MinimalistLogo,
|
||||
modern: ModernLogo,
|
||||
tech: TechLogo,
|
||||
wave: WaveLogo,
|
||||
};
|
||||
|
||||
const LogoComponent = logos[style] || MinimalistLogo;
|
||||
|
||||
return <LogoComponent />;
|
||||
};
|
||||
|
||||
export default WeeLogo;
|
||||
@@ -0,0 +1,160 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Wee Logo - Style 1: Minimalist Lines</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
background: #f5f5f5;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
||||
}
|
||||
|
||||
.container {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.logo-container {
|
||||
background: white;
|
||||
padding: 60px;
|
||||
border-radius: 20px;
|
||||
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
svg {
|
||||
width: 400px;
|
||||
height: 200px;
|
||||
}
|
||||
|
||||
.letter {
|
||||
fill: url(#blueGradient);
|
||||
stroke-width: 0;
|
||||
}
|
||||
|
||||
.w1 {
|
||||
animation: slideIn 1s ease-out forwards;
|
||||
}
|
||||
.e1 {
|
||||
animation: slideIn 1s ease-out 0.2s forwards;
|
||||
}
|
||||
.e2 {
|
||||
animation: slideIn 1s ease-out 0.4s forwards;
|
||||
}
|
||||
|
||||
@keyframes slideIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(-20px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
.letter {
|
||||
animation: pulse 3s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.w1 {
|
||||
animation-delay: 0s;
|
||||
}
|
||||
.e1 {
|
||||
animation-delay: 0.3s;
|
||||
}
|
||||
.e2 {
|
||||
animation-delay: 0.6s;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
50% {
|
||||
opacity: 0.7;
|
||||
}
|
||||
}
|
||||
|
||||
h2 {
|
||||
color: #333;
|
||||
margin-top: 20px;
|
||||
font-weight: 300;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="logo-container">
|
||||
<svg viewBox="0 0 400 200" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<linearGradient
|
||||
id="blueGradient"
|
||||
x1="0%"
|
||||
y1="0%"
|
||||
x2="100%"
|
||||
y2="100%"
|
||||
>
|
||||
<stop offset="0%" style="stop-color: #4a90e2; stop-opacity: 1">
|
||||
<animate
|
||||
attributeName="stop-color"
|
||||
values="#4A90E2;#2E5C8A;#4A90E2"
|
||||
dur="4s"
|
||||
repeatCount="indefinite"
|
||||
/>
|
||||
</stop>
|
||||
<stop offset="100%" style="stop-color: #1e3a5f; stop-opacity: 1">
|
||||
<animate
|
||||
attributeName="stop-color"
|
||||
values="#1E3A5F;#4A90E2;#1E3A5F"
|
||||
dur="4s"
|
||||
repeatCount="indefinite"
|
||||
/>
|
||||
</stop>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
|
||||
<!-- W -->
|
||||
<path
|
||||
class="letter w1"
|
||||
d="M 20 60 L 40 140 L 60 100 L 80 140 L 100 60"
|
||||
stroke-width="8"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
fill="none"
|
||||
stroke="url(#blueGradient)"
|
||||
/>
|
||||
|
||||
<!-- E -->
|
||||
<path
|
||||
class="letter e1"
|
||||
d="M 150 60 L 150 140 M 150 60 L 230 60 M 150 100 L 210 100 M 150 140 L 230 140"
|
||||
stroke-width="8"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
fill="none"
|
||||
stroke="url(#blueGradient)"
|
||||
/>
|
||||
|
||||
<!-- E -->
|
||||
<path
|
||||
class="letter e2"
|
||||
d="M 270 60 L 270 140 M 270 60 L 350 60 M 270 100 L 330 100 M 270 140 L 350 140"
|
||||
stroke-width="8"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
fill="none"
|
||||
stroke="url(#blueGradient)"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<h2>Style 1: Minimalist Lines</h2>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,149 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Wee Logo - Style 2: Modern Rounded</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
background: #f5f5f5;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
||||
}
|
||||
|
||||
.container {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.logo-container {
|
||||
background: white;
|
||||
padding: 60px;
|
||||
border-radius: 20px;
|
||||
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
svg {
|
||||
width: 400px;
|
||||
height: 200px;
|
||||
}
|
||||
|
||||
.letter {
|
||||
fill: url(#blueGradient2);
|
||||
}
|
||||
|
||||
@keyframes float {
|
||||
0%,
|
||||
100% {
|
||||
transform: translateY(0px);
|
||||
}
|
||||
50% {
|
||||
transform: translateY(-10px);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes rotate {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
.w-letter {
|
||||
animation: float 2s ease-in-out infinite;
|
||||
transform-origin: center;
|
||||
}
|
||||
|
||||
.e1-letter {
|
||||
animation: float 2s ease-in-out infinite;
|
||||
animation-delay: 0.2s;
|
||||
transform-origin: center;
|
||||
}
|
||||
|
||||
.e2-letter {
|
||||
animation: float 2s ease-in-out infinite;
|
||||
animation-delay: 0.4s;
|
||||
transform-origin: center;
|
||||
}
|
||||
|
||||
h2 {
|
||||
color: #333;
|
||||
margin-top: 20px;
|
||||
font-weight: 300;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="logo-container">
|
||||
<svg viewBox="0 0 420 200" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<linearGradient
|
||||
id="blueGradient2"
|
||||
x1="0%"
|
||||
y1="0%"
|
||||
x2="100%"
|
||||
y2="100%"
|
||||
>
|
||||
<stop offset="0%" style="stop-color: #5dade2; stop-opacity: 1">
|
||||
<animate
|
||||
attributeName="stop-color"
|
||||
values="#5DADE2;#3498DB;#2E86C1;#5DADE2"
|
||||
dur="3s"
|
||||
repeatCount="indefinite"
|
||||
/>
|
||||
</stop>
|
||||
<stop offset="50%" style="stop-color: #3498db; stop-opacity: 1">
|
||||
<animate
|
||||
attributeName="stop-color"
|
||||
values="#3498DB;#2E86C1;#5DADE2;#3498DB"
|
||||
dur="3s"
|
||||
repeatCount="indefinite"
|
||||
/>
|
||||
</stop>
|
||||
<stop offset="100%" style="stop-color: #2874a6; stop-opacity: 1">
|
||||
<animate
|
||||
attributeName="stop-color"
|
||||
values="#2874A6;#5DADE2;#3498DB;#2874A6"
|
||||
dur="3s"
|
||||
repeatCount="indefinite"
|
||||
/>
|
||||
</stop>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
|
||||
<!-- W -->
|
||||
<g class="w-letter">
|
||||
<path
|
||||
class="letter"
|
||||
d="M 10,50 Q 20,40 30,50 L 35,120 Q 37,130 45,130 Q 53,130 55,120 L 60,80 Q 62,70 70,70 Q 78,70 80,80 L 85,120 Q 87,130 95,130 Q 103,130 105,120 L 110,50 Q 120,40 130,50 L 135,60 L 115,130 Q 110,145 95,145 Q 85,145 80,135 L 70,105 L 60,135 Q 55,145 45,145 Q 30,145 25,130 L 5,60 Z"
|
||||
/>
|
||||
</g>
|
||||
|
||||
<!-- First E -->
|
||||
<g class="e1-letter">
|
||||
<path
|
||||
class="letter"
|
||||
d="M 170,50 Q 180,40 200,45 L 240,50 Q 250,52 248,62 Q 246,72 236,70 L 200,65 L 200,90 L 225,92 Q 235,93 233,103 Q 231,113 221,112 L 200,110 L 200,130 L 240,135 Q 250,136 248,146 Q 246,156 236,155 L 200,150 Q 180,148 170,138 Z"
|
||||
/>
|
||||
</g>
|
||||
|
||||
<!-- Second E -->
|
||||
<g class="e2-letter">
|
||||
<path
|
||||
class="letter"
|
||||
d="M 280,50 Q 290,40 310,45 L 350,50 Q 360,52 358,62 Q 356,72 346,70 L 310,65 L 310,90 L 335,92 Q 345,93 343,103 Q 341,113 331,112 L 310,110 L 310,130 L 350,135 Q 360,136 358,146 Q 356,156 346,155 L 310,150 Q 290,148 280,138 Z"
|
||||
/>
|
||||
</g>
|
||||
</svg>
|
||||
</div>
|
||||
<h2>Style 2: Modern Rounded</h2>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,293 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Wee Logo - Style 3: Tech Futuristic</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
background: #0a0e27;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
||||
}
|
||||
|
||||
.container {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.logo-container {
|
||||
background: linear-gradient(135deg, #1a1f3a 0%, #0f1229 100%);
|
||||
padding: 60px;
|
||||
border-radius: 20px;
|
||||
box-shadow:
|
||||
0 10px 40px rgba(0, 0, 0, 0.5),
|
||||
0 0 60px rgba(74, 144, 226, 0.3);
|
||||
}
|
||||
|
||||
svg {
|
||||
width: 400px;
|
||||
height: 200px;
|
||||
filter: drop-shadow(0 0 20px rgba(74, 144, 226, 0.5));
|
||||
}
|
||||
|
||||
.letter {
|
||||
fill: url(#techGradient);
|
||||
stroke: url(#glowGradient);
|
||||
stroke-width: 2;
|
||||
}
|
||||
|
||||
@keyframes glow {
|
||||
0%,
|
||||
100% {
|
||||
filter: drop-shadow(0 0 5px rgba(74, 144, 226, 0.8))
|
||||
drop-shadow(0 0 10px rgba(74, 144, 226, 0.6))
|
||||
drop-shadow(0 0 15px rgba(74, 144, 226, 0.4));
|
||||
}
|
||||
50% {
|
||||
filter: drop-shadow(0 0 10px rgba(74, 144, 226, 1))
|
||||
drop-shadow(0 0 20px rgba(74, 144, 226, 0.8))
|
||||
drop-shadow(0 0 30px rgba(74, 144, 226, 0.6));
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes scan {
|
||||
0% {
|
||||
transform: translateX(-100%);
|
||||
opacity: 0;
|
||||
}
|
||||
50% {
|
||||
opacity: 1;
|
||||
}
|
||||
100% {
|
||||
transform: translateX(500%);
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.scan-line {
|
||||
animation: scan 3s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.letter-group {
|
||||
animation: glow 2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.w-tech {
|
||||
animation-delay: 0s;
|
||||
}
|
||||
.e1-tech {
|
||||
animation-delay: 0.3s;
|
||||
}
|
||||
.e2-tech {
|
||||
animation-delay: 0.6s;
|
||||
}
|
||||
|
||||
@keyframes flicker {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
50% {
|
||||
opacity: 0.95;
|
||||
}
|
||||
75% {
|
||||
opacity: 0.98;
|
||||
}
|
||||
}
|
||||
|
||||
h2 {
|
||||
color: #5dade2;
|
||||
margin-top: 20px;
|
||||
font-weight: 300;
|
||||
text-shadow: 0 0 10px rgba(93, 173, 226, 0.5);
|
||||
}
|
||||
|
||||
.particles {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.particle {
|
||||
position: absolute;
|
||||
width: 2px;
|
||||
height: 2px;
|
||||
background: #5dade2;
|
||||
border-radius: 50%;
|
||||
animation: particle-float 4s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes particle-float {
|
||||
0%,
|
||||
100% {
|
||||
transform: translateY(0) translateX(0);
|
||||
opacity: 0;
|
||||
}
|
||||
50% {
|
||||
opacity: 1;
|
||||
}
|
||||
100% {
|
||||
transform: translateY(-100px) translateX(20px);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="logo-container">
|
||||
<svg viewBox="0 0 400 200" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<linearGradient
|
||||
id="techGradient"
|
||||
x1="0%"
|
||||
y1="0%"
|
||||
x2="100%"
|
||||
y2="100%"
|
||||
>
|
||||
<stop offset="0%" style="stop-color: #00d9ff; stop-opacity: 1">
|
||||
<animate
|
||||
attributeName="stop-color"
|
||||
values="#00D9FF;#0099FF;#0066FF;#00D9FF"
|
||||
dur="2s"
|
||||
repeatCount="indefinite"
|
||||
/>
|
||||
</stop>
|
||||
<stop offset="100%" style="stop-color: #0066ff; stop-opacity: 1">
|
||||
<animate
|
||||
attributeName="stop-color"
|
||||
values="#0066FF;#00D9FF;#0099FF;#0066FF"
|
||||
dur="2s"
|
||||
repeatCount="indefinite"
|
||||
/>
|
||||
</stop>
|
||||
</linearGradient>
|
||||
|
||||
<linearGradient id="glowGradient" x1="0%" y1="0%" x2="100%" y2="0%">
|
||||
<stop
|
||||
offset="0%"
|
||||
style="stop-color: #4a90e2; stop-opacity: 0.5"
|
||||
/>
|
||||
<stop offset="50%" style="stop-color: #00d9ff; stop-opacity: 1">
|
||||
<animate
|
||||
attributeName="offset"
|
||||
values="0;1;0"
|
||||
dur="2s"
|
||||
repeatCount="indefinite"
|
||||
/>
|
||||
</stop>
|
||||
<stop
|
||||
offset="100%"
|
||||
style="stop-color: #4a90e2; stop-opacity: 0.5"
|
||||
/>
|
||||
</linearGradient>
|
||||
|
||||
<filter id="glow">
|
||||
<feGaussianBlur stdDeviation="3" result="coloredBlur" />
|
||||
<feMerge>
|
||||
<feMergeNode in="coloredBlur" />
|
||||
<feMergeNode in="SourceGraphic" />
|
||||
</feMerge>
|
||||
</filter>
|
||||
</defs>
|
||||
|
||||
<!-- Scan line effect -->
|
||||
<rect
|
||||
class="scan-line"
|
||||
x="0"
|
||||
y="0"
|
||||
width="20"
|
||||
height="200"
|
||||
fill="url(#glowGradient)"
|
||||
opacity="0.3"
|
||||
/>
|
||||
|
||||
<!-- W -->
|
||||
<g class="letter-group w-tech">
|
||||
<text
|
||||
class="letter"
|
||||
x="10"
|
||||
y="140"
|
||||
font-family="'Arial Black', sans-serif"
|
||||
font-size="120"
|
||||
font-weight="900"
|
||||
filter="url(#glow)"
|
||||
>
|
||||
W
|
||||
</text>
|
||||
</g>
|
||||
|
||||
<!-- E -->
|
||||
<g class="letter-group e1-tech">
|
||||
<text
|
||||
class="letter"
|
||||
x="140"
|
||||
y="140"
|
||||
font-family="'Arial Black', sans-serif"
|
||||
font-size="120"
|
||||
font-weight="900"
|
||||
filter="url(#glow)"
|
||||
>
|
||||
E
|
||||
</text>
|
||||
</g>
|
||||
|
||||
<!-- E -->
|
||||
<g class="letter-group e2-tech">
|
||||
<text
|
||||
class="letter"
|
||||
x="260"
|
||||
y="140"
|
||||
font-family="'Arial Black', sans-serif"
|
||||
font-size="120"
|
||||
font-weight="900"
|
||||
filter="url(#glow)"
|
||||
>
|
||||
E
|
||||
</text>
|
||||
</g>
|
||||
|
||||
<!-- Grid lines for tech effect -->
|
||||
<line
|
||||
x1="0"
|
||||
y1="180"
|
||||
x2="400"
|
||||
y2="180"
|
||||
stroke="#0099FF"
|
||||
stroke-width="0.5"
|
||||
opacity="0.3"
|
||||
>
|
||||
<animate
|
||||
attributeName="opacity"
|
||||
values="0.3;0.6;0.3"
|
||||
dur="2s"
|
||||
repeatCount="indefinite"
|
||||
/>
|
||||
</line>
|
||||
<line
|
||||
x1="0"
|
||||
y1="190"
|
||||
x2="400"
|
||||
y2="190"
|
||||
stroke="#00D9FF"
|
||||
stroke-width="0.5"
|
||||
opacity="0.2"
|
||||
>
|
||||
<animate
|
||||
attributeName="opacity"
|
||||
values="0.2;0.5;0.2"
|
||||
dur="2s"
|
||||
repeatCount="indefinite"
|
||||
/>
|
||||
</line>
|
||||
</svg>
|
||||
</div>
|
||||
<h2>Style 3: Tech Futuristic</h2>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,293 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Wee Logo - Style 4: Wave Flow</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
||||
}
|
||||
|
||||
.container {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.logo-container {
|
||||
background: rgba(255, 255, 255, 0.95);
|
||||
padding: 60px;
|
||||
border-radius: 30px;
|
||||
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
|
||||
backdrop-filter: blur(10px);
|
||||
}
|
||||
|
||||
svg {
|
||||
width: 500px;
|
||||
height: 200px;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.wave-text {
|
||||
fill: url(#waveGradient);
|
||||
font-family:
|
||||
'Arial Rounded MT Bold', 'Helvetica Rounded', Arial, sans-serif;
|
||||
font-size: 140px;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
@keyframes wave {
|
||||
0%,
|
||||
100% {
|
||||
d: path('M0,100 Q25,80 50,100 T100,100');
|
||||
}
|
||||
50% {
|
||||
d: path('M0,100 Q25,120 50,100 T100,100');
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes morphW {
|
||||
0%,
|
||||
100% {
|
||||
d: path(
|
||||
'M 20,60 L 35,130 Q 37,140 45,140 Q 53,140 55,130 L 65,85 L 75,130 Q 77,140 85,140 Q 93,140 95,130 L 110,60'
|
||||
);
|
||||
}
|
||||
50% {
|
||||
d: path(
|
||||
'M 20,65 L 35,125 Q 37,135 45,135 Q 53,135 55,125 L 65,90 L 75,125 Q 77,135 85,135 Q 93,135 95,125 L 110,65'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
.liquid-bg {
|
||||
animation: liquidMove 8s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes liquidMove {
|
||||
0%,
|
||||
100% {
|
||||
transform: translateY(0) scale(1);
|
||||
}
|
||||
50% {
|
||||
transform: translateY(-5px) scale(1.02);
|
||||
}
|
||||
}
|
||||
|
||||
h2 {
|
||||
color: #fff;
|
||||
margin-top: 20px;
|
||||
font-weight: 300;
|
||||
text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
@keyframes flowText {
|
||||
0% {
|
||||
transform: translateX(0);
|
||||
}
|
||||
100% {
|
||||
transform: translateX(5px);
|
||||
}
|
||||
}
|
||||
|
||||
.flow-w {
|
||||
animation: flowText 2s ease-in-out infinite alternate;
|
||||
}
|
||||
|
||||
.flow-e1 {
|
||||
animation: flowText 2s ease-in-out infinite alternate;
|
||||
animation-delay: 0.2s;
|
||||
}
|
||||
|
||||
.flow-e2 {
|
||||
animation: flowText 2s ease-in-out infinite alternate;
|
||||
animation-delay: 0.4s;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="logo-container">
|
||||
<svg viewBox="0 0 500 220" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<linearGradient
|
||||
id="waveGradient"
|
||||
x1="0%"
|
||||
y1="0%"
|
||||
x2="100%"
|
||||
y2="100%"
|
||||
>
|
||||
<stop offset="0%" style="stop-color: #2193b0; stop-opacity: 1">
|
||||
<animate
|
||||
attributeName="stop-color"
|
||||
values="#2193b0;#6dd5ed;#4facfe;#2193b0"
|
||||
dur="4s"
|
||||
repeatCount="indefinite"
|
||||
/>
|
||||
</stop>
|
||||
<stop offset="50%" style="stop-color: #4facfe; stop-opacity: 1">
|
||||
<animate
|
||||
attributeName="stop-color"
|
||||
values="#4facfe;#00f2fe;#2193b0;#4facfe"
|
||||
dur="4s"
|
||||
repeatCount="indefinite"
|
||||
/>
|
||||
</stop>
|
||||
<stop offset="100%" style="stop-color: #00f2fe; stop-opacity: 1">
|
||||
<animate
|
||||
attributeName="stop-color"
|
||||
values="#00f2fe;#4facfe;#6dd5ed;#00f2fe"
|
||||
dur="4s"
|
||||
repeatCount="indefinite"
|
||||
/>
|
||||
</stop>
|
||||
</linearGradient>
|
||||
|
||||
<filter id="wave-blur">
|
||||
<feGaussianBlur in="SourceGraphic" stdDeviation="1" />
|
||||
</filter>
|
||||
|
||||
<filter id="liquid">
|
||||
<feTurbulence
|
||||
type="fractalNoise"
|
||||
baseFrequency="0.01"
|
||||
numOctaves="3"
|
||||
result="turbulence"
|
||||
>
|
||||
<animate
|
||||
attributeName="baseFrequency"
|
||||
values="0.01;0.02;0.01"
|
||||
dur="10s"
|
||||
repeatCount="indefinite"
|
||||
/>
|
||||
</feTurbulence>
|
||||
<feDisplacementMap
|
||||
in="SourceGraphic"
|
||||
in2="turbulence"
|
||||
scale="5"
|
||||
xChannelSelector="R"
|
||||
yChannelSelector="G"
|
||||
/>
|
||||
</filter>
|
||||
</defs>
|
||||
|
||||
<!-- Background liquid shapes -->
|
||||
<ellipse
|
||||
class="liquid-bg"
|
||||
cx="100"
|
||||
cy="150"
|
||||
rx="80"
|
||||
ry="60"
|
||||
fill="url(#waveGradient)"
|
||||
opacity="0.1"
|
||||
filter="url(#liquid)"
|
||||
/>
|
||||
<ellipse
|
||||
class="liquid-bg"
|
||||
cx="250"
|
||||
cy="140"
|
||||
rx="90"
|
||||
ry="70"
|
||||
fill="url(#waveGradient)"
|
||||
opacity="0.1"
|
||||
filter="url(#liquid)"
|
||||
style="animation-delay: 1s"
|
||||
/>
|
||||
<ellipse
|
||||
class="liquid-bg"
|
||||
cx="400"
|
||||
cy="145"
|
||||
rx="85"
|
||||
ry="65"
|
||||
fill="url(#waveGradient)"
|
||||
opacity="0.1"
|
||||
filter="url(#liquid)"
|
||||
style="animation-delay: 2s"
|
||||
/>
|
||||
|
||||
<!-- Wave path for baseline -->
|
||||
<path
|
||||
id="wavePath"
|
||||
d="M 0,140 Q 125,120 250,140 T 500,140"
|
||||
fill="none"
|
||||
/>
|
||||
|
||||
<!-- Text on wave path -->
|
||||
<text class="wave-text" font-size="120" font-weight="900">
|
||||
<textPath href="#wavePath" startOffset="8%">
|
||||
<tspan class="flow-w">w</tspan>
|
||||
<tspan class="flow-e1">e</tspan>
|
||||
<tspan class="flow-e2">e</tspan>
|
||||
<animate
|
||||
attributeName="startOffset"
|
||||
values="8%;10%;8%"
|
||||
dur="3s"
|
||||
repeatCount="indefinite"
|
||||
/>
|
||||
</textPath>
|
||||
</text>
|
||||
|
||||
<!-- Animated wave path -->
|
||||
<animateTransform
|
||||
attributeName="transform"
|
||||
type="translate"
|
||||
values="0,0; 0,-3; 0,0"
|
||||
dur="3s"
|
||||
repeatCount="indefinite"
|
||||
/>
|
||||
|
||||
<!-- Decorative dots -->
|
||||
<circle cx="50" cy="100" r="3" fill="#4facfe" opacity="0.6">
|
||||
<animate
|
||||
attributeName="cy"
|
||||
values="100;95;100"
|
||||
dur="2s"
|
||||
repeatCount="indefinite"
|
||||
/>
|
||||
<animate
|
||||
attributeName="opacity"
|
||||
values="0.6;1;0.6"
|
||||
dur="2s"
|
||||
repeatCount="indefinite"
|
||||
/>
|
||||
</circle>
|
||||
<circle cx="450" cy="110" r="3" fill="#2193b0" opacity="0.6">
|
||||
<animate
|
||||
attributeName="cy"
|
||||
values="110;105;110"
|
||||
dur="2.5s"
|
||||
repeatCount="indefinite"
|
||||
/>
|
||||
<animate
|
||||
attributeName="opacity"
|
||||
values="0.6;1;0.6"
|
||||
dur="2.5s"
|
||||
repeatCount="indefinite"
|
||||
/>
|
||||
</circle>
|
||||
<circle cx="250" cy="95" r="3" fill="#00f2fe" opacity="0.6">
|
||||
<animate
|
||||
attributeName="cy"
|
||||
values="95;90;95"
|
||||
dur="2.2s"
|
||||
repeatCount="indefinite"
|
||||
/>
|
||||
<animate
|
||||
attributeName="opacity"
|
||||
values="0.6;1;0.6"
|
||||
dur="2.2s"
|
||||
repeatCount="indefinite"
|
||||
/>
|
||||
</circle>
|
||||
</svg>
|
||||
</div>
|
||||
<h2>Style 4: Wave Flow</h2>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,770 @@
|
||||
/*
|
||||
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 ReactMarkdown from 'react-markdown';
|
||||
import 'katex/dist/katex.min.css';
|
||||
import 'highlight.js/styles/github.css';
|
||||
import './markdown.css';
|
||||
import RemarkMath from 'remark-math';
|
||||
import RemarkBreaks from 'remark-breaks';
|
||||
import RehypeKatex from 'rehype-katex';
|
||||
import RemarkGfm from 'remark-gfm';
|
||||
import RehypeHighlight from 'rehype-highlight';
|
||||
import {
|
||||
useRef,
|
||||
useState,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useId,
|
||||
} from 'react';
|
||||
import React from 'react';
|
||||
import { useDebouncedCallback } from 'use-debounce';
|
||||
import clsx from 'clsx';
|
||||
import { Button, Tooltip, Toast } from '@douyinfe/semi-ui';
|
||||
import { copy, rehypeSplitWordsIntoSpans } from '../../../helpers';
|
||||
import { IconCopy } from '@douyinfe/semi-icons';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import ImagePreviewModal from '../../playground/ImagePreviewModal';
|
||||
|
||||
// 懒加载 mermaid 库 - 只在需要时才加载这个大型依赖
|
||||
let mermaidInstance = null;
|
||||
let mermaidLoading = null;
|
||||
|
||||
const loadMermaid = async () => {
|
||||
if (mermaidInstance) return mermaidInstance;
|
||||
if (mermaidLoading) return mermaidLoading;
|
||||
|
||||
mermaidLoading = import('mermaid').then((module) => {
|
||||
mermaidInstance = module.default;
|
||||
mermaidInstance.initialize({
|
||||
startOnLoad: false,
|
||||
theme: 'default',
|
||||
securityLevel: 'loose',
|
||||
});
|
||||
return mermaidInstance;
|
||||
});
|
||||
|
||||
return mermaidLoading;
|
||||
};
|
||||
|
||||
export function Mermaid(props) {
|
||||
// svgRef 指向一个「React 视角里永远为空」的子节点,我们用 innerHTML 手动塞 SVG。
|
||||
// 关键:绝不能让 mermaid 去改写 React 正在管理子节点的元素 —— 之前用
|
||||
// mermaid.run({nodes:[ref.current]}) 直接抹掉了容器里 React 渲染的 loading/文本节点,
|
||||
// 等 setIsLoading(false) 触发重渲染时,React 找不到那些被 mermaid 删掉的节点,
|
||||
// 就抛 removeChild "NotFoundError"。改用 mermaid.render() 拿 svg 字符串后写进 svgRef,
|
||||
// React 始终认为 svgRef 这个 div 是空的,便不会与 mermaid 的 DOM 改动冲突。
|
||||
const svgRef = useRef(null);
|
||||
const [hasError, setHasError] = useState(false);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const rawId = useId();
|
||||
// useId 产出形如 ":r0:",含非法字符;清洗后作为 mermaid.render 的 id 基底(会进 querySelector)
|
||||
const idBase = `mermaid-${rawId.replace(/[^a-zA-Z0-9_-]/g, '')}`;
|
||||
// 每次 render 取递增后缀,确保 id 唯一。关键:StrictMode 开发模式下 mount effect 会跑两次,
|
||||
// 若两次用同一 id 并发调用 mermaid.render,会因其内部临时节点 #d{id} 冲突而报错/画不出图。
|
||||
const renderSeqRef = useRef(0);
|
||||
|
||||
useEffect(() => {
|
||||
if (!props.code) return;
|
||||
let cancelled = false;
|
||||
const renderId = `${idBase}-${renderSeqRef.current++}`;
|
||||
setIsLoading(true);
|
||||
setHasError(false);
|
||||
loadMermaid()
|
||||
.then((mermaid) => mermaid.render(renderId, props.code))
|
||||
.then(({ svg, bindFunctions }) => {
|
||||
if (cancelled || !svgRef.current) return;
|
||||
svgRef.current.innerHTML = svg;
|
||||
// 交互式图表(点击/tooltip)需要 mermaid 绑定事件;静态图表则是空操作
|
||||
if (typeof bindFunctions === 'function') {
|
||||
bindFunctions(svgRef.current);
|
||||
}
|
||||
setIsLoading(false);
|
||||
})
|
||||
.catch((e) => {
|
||||
if (cancelled) return;
|
||||
setHasError(true);
|
||||
setIsLoading(false);
|
||||
console.error('[Mermaid] ', e.message);
|
||||
});
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [props.code, idBase]);
|
||||
|
||||
function viewSvgInNewWindow() {
|
||||
const svg = svgRef.current?.querySelector('svg');
|
||||
if (!svg) return;
|
||||
const text = new XMLSerializer().serializeToString(svg);
|
||||
const blob = new Blob([text], { type: 'image/svg+xml' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
window.open(url, '_blank');
|
||||
}
|
||||
|
||||
// 解析失败(含流式中途语法不完整)时整体隐藏,不渲染半截图表。
|
||||
// 调用方是 <Mermaid key={mermaidCode}/>:代码一变即全新实例重挂载并重画,
|
||||
// 不依赖同实例内重试,所以这里直接卸载是安全的。
|
||||
if (hasError) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className={clsx('mermaid-container')}
|
||||
style={{
|
||||
cursor: 'pointer',
|
||||
overflow: 'auto',
|
||||
padding: '12px',
|
||||
border: '1px solid var(--semi-color-border)',
|
||||
borderRadius: '8px',
|
||||
backgroundColor: 'var(--semi-color-bg-1)',
|
||||
margin: '12px 0',
|
||||
position: 'relative',
|
||||
minHeight: isLoading ? '100px' : 'auto',
|
||||
}}
|
||||
onClick={() => viewSvgInNewWindow()}
|
||||
>
|
||||
{isLoading && (
|
||||
<div
|
||||
style={{
|
||||
position: 'absolute',
|
||||
top: '50%',
|
||||
left: '50%',
|
||||
transform: 'translate(-50%, -50%)',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: '8px',
|
||||
color: 'var(--semi-color-text-2)',
|
||||
fontSize: '12px',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
width: '14px',
|
||||
height: '14px',
|
||||
border: '2px solid var(--semi-color-border)',
|
||||
borderTop: '2px solid var(--semi-color-primary)',
|
||||
borderRadius: '50%',
|
||||
animation: 'spin 1s linear infinite',
|
||||
}}
|
||||
/>
|
||||
加载图表中...
|
||||
</div>
|
||||
)}
|
||||
{/* React 视角下这个 div 恒为空,SVG 由 effect 通过 innerHTML 注入,互不干涉 */}
|
||||
<div ref={svgRef} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function PreCode(props) {
|
||||
const ref = useRef(null);
|
||||
const [mermaidCode, setMermaidCode] = useState('');
|
||||
const [htmlCode, setHtmlCode] = useState('');
|
||||
const { t } = useTranslation();
|
||||
|
||||
const renderArtifacts = useDebouncedCallback(() => {
|
||||
if (!ref.current) return;
|
||||
const mermaidDom = ref.current.querySelector('code.language-mermaid');
|
||||
if (mermaidDom) {
|
||||
setMermaidCode(mermaidDom.innerText);
|
||||
}
|
||||
const htmlDom = ref.current.querySelector('code.language-html');
|
||||
const refText = ref.current.querySelector('code')?.innerText;
|
||||
if (htmlDom) {
|
||||
setHtmlCode(htmlDom.innerText);
|
||||
} else if (
|
||||
refText?.startsWith('<!DOCTYPE') ||
|
||||
refText?.startsWith('<svg') ||
|
||||
refText?.startsWith('<?xml')
|
||||
) {
|
||||
setHtmlCode(refText);
|
||||
}
|
||||
}, 600);
|
||||
|
||||
// 处理代码块的换行
|
||||
useEffect(() => {
|
||||
if (ref.current) {
|
||||
const codeElements = ref.current.querySelectorAll('code');
|
||||
const wrapLanguages = [
|
||||
'',
|
||||
'md',
|
||||
'markdown',
|
||||
'text',
|
||||
'txt',
|
||||
'plaintext',
|
||||
'tex',
|
||||
'latex',
|
||||
];
|
||||
codeElements.forEach((codeElement) => {
|
||||
let languageClass = codeElement.className.match(/language-(\w+)/);
|
||||
let name = languageClass ? languageClass[1] : '';
|
||||
if (wrapLanguages.includes(name)) {
|
||||
codeElement.style.whiteSpace = 'pre-wrap';
|
||||
}
|
||||
});
|
||||
setTimeout(renderArtifacts, 1);
|
||||
}
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<pre
|
||||
ref={ref}
|
||||
style={{
|
||||
position: 'relative',
|
||||
backgroundColor: 'var(--semi-color-fill-0)',
|
||||
border: '1px solid var(--semi-color-border)',
|
||||
borderRadius: '6px',
|
||||
padding: '12px',
|
||||
margin: '12px 0',
|
||||
overflow: 'auto',
|
||||
fontSize: '14px',
|
||||
lineHeight: '1.4',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className='copy-code-button'
|
||||
style={{
|
||||
position: 'absolute',
|
||||
top: '8px',
|
||||
right: '8px',
|
||||
display: 'flex',
|
||||
gap: '4px',
|
||||
zIndex: 10,
|
||||
opacity: 0,
|
||||
transition: 'opacity 0.2s ease',
|
||||
}}
|
||||
>
|
||||
<Tooltip content={t('复制代码')}>
|
||||
<Button
|
||||
size='small'
|
||||
theme='borderless'
|
||||
icon={<IconCopy />}
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
if (ref.current) {
|
||||
const codeElement = ref.current.querySelector('code');
|
||||
const code = codeElement?.textContent ?? '';
|
||||
copy(code).then((success) => {
|
||||
if (success) {
|
||||
Toast.success(t('代码已复制到剪贴板'));
|
||||
} else {
|
||||
Toast.error(t('复制失败,请手动复制'));
|
||||
}
|
||||
});
|
||||
}
|
||||
}}
|
||||
style={{
|
||||
padding: '4px',
|
||||
backgroundColor: 'var(--semi-color-bg-2)',
|
||||
borderRadius: '4px',
|
||||
cursor: 'pointer',
|
||||
border: '1px solid var(--semi-color-border)',
|
||||
boxShadow: '0 1px 2px rgba(0, 0, 0, 0.1)',
|
||||
}}
|
||||
/>
|
||||
</Tooltip>
|
||||
</div>
|
||||
{props.children}
|
||||
</pre>
|
||||
{mermaidCode.length > 0 && (
|
||||
<Mermaid code={mermaidCode} key={mermaidCode} />
|
||||
)}
|
||||
{htmlCode.length > 0 && (
|
||||
<div
|
||||
style={{
|
||||
border: '1px solid var(--semi-color-border)',
|
||||
borderRadius: '8px',
|
||||
padding: '16px',
|
||||
margin: '12px 0',
|
||||
backgroundColor: 'var(--semi-color-bg-1)',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
marginBottom: '8px',
|
||||
fontSize: '12px',
|
||||
color: 'var(--semi-color-text-2)',
|
||||
}}
|
||||
>
|
||||
HTML预览:
|
||||
</div>
|
||||
<div dangerouslySetInnerHTML={{ __html: htmlCode }} />
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function CustomCode(props) {
|
||||
const ref = useRef(null);
|
||||
const [collapsed, setCollapsed] = useState(true);
|
||||
const [showToggle, setShowToggle] = useState(false);
|
||||
const { t } = useTranslation();
|
||||
|
||||
const className = props?.className || '';
|
||||
// 行内代码 vs 代码块判定:带 language-* 类、或内容含换行 = 代码块;否则按行内代码渲染。
|
||||
// 关键:行内代码必须渲染成纯 <code>,绝不能套 <div>。行内代码位于 <p> 内,块级 <div>
|
||||
// 会被浏览器从 <p> 中提升出来、把段落拆开,导致 React 虚拟树与真实 DOM 错位;流式追加
|
||||
// 文本触发 reconcile 时就会报 removeChild "NotFoundError"。
|
||||
const isBlock =
|
||||
/language-(\w+)/.test(className) ||
|
||||
(typeof props.children === 'string' && props.children.includes('\n')) ||
|
||||
(Array.isArray(props.children) &&
|
||||
props.children.some((c) => typeof c === 'string' && c.includes('\n')));
|
||||
|
||||
useEffect(() => {
|
||||
if (ref.current) {
|
||||
const codeHeight = ref.current.scrollHeight;
|
||||
setShowToggle(codeHeight > 400);
|
||||
ref.current.scrollTop = ref.current.scrollHeight;
|
||||
}
|
||||
}, [props.children]);
|
||||
|
||||
const toggleCollapsed = () => {
|
||||
setCollapsed((collapsed) => !collapsed);
|
||||
};
|
||||
|
||||
const renderShowMoreButton = () => {
|
||||
if (showToggle && collapsed) {
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
position: 'absolute',
|
||||
bottom: '8px',
|
||||
right: '8px',
|
||||
left: '8px',
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
}}
|
||||
>
|
||||
<Button size='small' onClick={toggleCollapsed} theme='solid'>
|
||||
{t('显示更多')}
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
// 行内代码:纯 <code>,不包裹任何块级元素,避免 <p> 内嵌 <div> 的非法嵌套
|
||||
if (!isBlock) {
|
||||
return <code className={clsx(className)}>{props.children}</code>;
|
||||
}
|
||||
|
||||
return (
|
||||
<div style={{ position: 'relative' }}>
|
||||
<code
|
||||
className={clsx(className)}
|
||||
ref={ref}
|
||||
style={{
|
||||
maxHeight: collapsed ? '400px' : 'none',
|
||||
overflowY: 'hidden',
|
||||
display: 'block',
|
||||
padding: '8px 12px',
|
||||
backgroundColor: 'var(--semi-color-fill-0)',
|
||||
borderRadius: '4px',
|
||||
fontSize: '13px',
|
||||
lineHeight: '1.4',
|
||||
}}
|
||||
>
|
||||
{props.children}
|
||||
</code>
|
||||
{renderShowMoreButton()}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function escapeBrackets(text) {
|
||||
const pattern =
|
||||
/(```[\s\S]*?```|`.*?`)|\\\[([\s\S]*?[^\\])\\\]|\\\((.*?)\\\)/g;
|
||||
return text.replace(
|
||||
pattern,
|
||||
(match, codeBlock, squareBracket, roundBracket) => {
|
||||
if (codeBlock) {
|
||||
return codeBlock;
|
||||
} else if (squareBracket) {
|
||||
return `$$${squareBracket}$$`;
|
||||
} else if (roundBracket) {
|
||||
return `$${roundBracket}$`;
|
||||
}
|
||||
return match;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
function tryWrapHtmlCode(text) {
|
||||
// 尝试包装HTML代码
|
||||
if (text.includes('```')) {
|
||||
return text;
|
||||
}
|
||||
return text
|
||||
.replace(
|
||||
/([`]*?)(\w*?)([\n\r]*?)(<!DOCTYPE html>)/g,
|
||||
(match, quoteStart, lang, newLine, doctype) => {
|
||||
return !quoteStart ? '\n```html\n' + doctype : match;
|
||||
},
|
||||
)
|
||||
.replace(
|
||||
/(<\/body>)([\r\n\s]*?)(<\/html>)([\n\r]*)([`]*)([\n\r]*?)/g,
|
||||
(match, bodyEnd, space, htmlEnd, newLine, quoteEnd) => {
|
||||
return !quoteEnd ? bodyEnd + space + htmlEnd + '\n```\n' : match;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
function MarkdownContentImpl(props) {
|
||||
const {
|
||||
content,
|
||||
className,
|
||||
animated = false,
|
||||
previousContentLength = 0,
|
||||
} = props;
|
||||
|
||||
const [previewImageUrl, setPreviewImageUrl] = useState(null);
|
||||
|
||||
const escapedContent = useMemo(() => {
|
||||
return tryWrapHtmlCode(escapeBrackets(content));
|
||||
}, [content]);
|
||||
|
||||
// 判断是否为用户消息
|
||||
const isUserMessage = className && className.includes('user-message');
|
||||
|
||||
const rehypePluginsBase = useMemo(() => {
|
||||
const base = [
|
||||
RehypeKatex,
|
||||
[
|
||||
RehypeHighlight,
|
||||
{
|
||||
detect: false,
|
||||
ignoreMissing: true,
|
||||
},
|
||||
],
|
||||
];
|
||||
if (animated) {
|
||||
base.push([rehypeSplitWordsIntoSpans, { previousContentLength }]);
|
||||
}
|
||||
return base;
|
||||
}, [animated, previousContentLength]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<ReactMarkdown
|
||||
remarkPlugins={[RemarkMath, RemarkGfm, RemarkBreaks]}
|
||||
rehypePlugins={rehypePluginsBase}
|
||||
components={{
|
||||
pre: PreCode,
|
||||
code: CustomCode,
|
||||
p: (pProps) => (
|
||||
<p
|
||||
{...pProps}
|
||||
dir='auto'
|
||||
style={{
|
||||
lineHeight: '1.6',
|
||||
color: isUserMessage ? 'white' : 'inherit',
|
||||
}}
|
||||
/>
|
||||
),
|
||||
a: (aProps) => {
|
||||
const href = aProps.href || '';
|
||||
if (/\.(aac|mp3|opus|wav)$/.test(href)) {
|
||||
return (
|
||||
<figure style={{ margin: '12px 0' }}>
|
||||
<audio controls src={href} style={{ width: '100%' }}></audio>
|
||||
</figure>
|
||||
);
|
||||
}
|
||||
if (/\.(3gp|3g2|webm|ogv|mpeg|mp4|avi)$/.test(href)) {
|
||||
return (
|
||||
<video
|
||||
controls
|
||||
style={{ width: '100%', maxWidth: '100%', margin: '12px 0' }}
|
||||
>
|
||||
<source src={href} />
|
||||
</video>
|
||||
);
|
||||
}
|
||||
const isInternal = /^\/#/i.test(href);
|
||||
const target = isInternal ? '_self' : (aProps.target ?? '_blank');
|
||||
return (
|
||||
<a
|
||||
{...aProps}
|
||||
target={target}
|
||||
style={{
|
||||
color: isUserMessage
|
||||
? '#87CEEB'
|
||||
: 'var(--semi-color-primary)',
|
||||
textDecoration: 'none',
|
||||
}}
|
||||
onMouseEnter={(e) => {
|
||||
e.target.style.textDecoration = 'underline';
|
||||
}}
|
||||
onMouseLeave={(e) => {
|
||||
e.target.style.textDecoration = 'none';
|
||||
}}
|
||||
/>
|
||||
);
|
||||
},
|
||||
h1: (props) => (
|
||||
<h1
|
||||
{...props}
|
||||
style={{
|
||||
fontSize: '24px',
|
||||
fontWeight: 'bold',
|
||||
margin: '20px 0 12px 0',
|
||||
color: isUserMessage ? 'white' : 'var(--semi-color-text-0)',
|
||||
}}
|
||||
/>
|
||||
),
|
||||
h2: (props) => (
|
||||
<h2
|
||||
{...props}
|
||||
style={{
|
||||
fontSize: '20px',
|
||||
fontWeight: 'bold',
|
||||
margin: '18px 0 10px 0',
|
||||
color: isUserMessage ? 'white' : 'var(--semi-color-text-0)',
|
||||
}}
|
||||
/>
|
||||
),
|
||||
h3: (props) => (
|
||||
<h3
|
||||
{...props}
|
||||
style={{
|
||||
fontSize: '18px',
|
||||
fontWeight: 'bold',
|
||||
margin: '16px 0 8px 0',
|
||||
color: isUserMessage ? 'white' : 'var(--semi-color-text-0)',
|
||||
}}
|
||||
/>
|
||||
),
|
||||
h4: (props) => (
|
||||
<h4
|
||||
{...props}
|
||||
style={{
|
||||
fontSize: '16px',
|
||||
fontWeight: 'bold',
|
||||
margin: '14px 0 6px 0',
|
||||
color: isUserMessage ? 'white' : 'var(--semi-color-text-0)',
|
||||
}}
|
||||
/>
|
||||
),
|
||||
h5: (props) => (
|
||||
<h5
|
||||
{...props}
|
||||
style={{
|
||||
fontSize: '14px',
|
||||
fontWeight: 'bold',
|
||||
margin: '12px 0 4px 0',
|
||||
color: isUserMessage ? 'white' : 'var(--semi-color-text-0)',
|
||||
}}
|
||||
/>
|
||||
),
|
||||
h6: (props) => (
|
||||
<h6
|
||||
{...props}
|
||||
style={{
|
||||
fontSize: '13px',
|
||||
fontWeight: 'bold',
|
||||
margin: '10px 0 4px 0',
|
||||
color: isUserMessage ? 'white' : 'var(--semi-color-text-0)',
|
||||
}}
|
||||
/>
|
||||
),
|
||||
blockquote: (props) => (
|
||||
<blockquote
|
||||
{...props}
|
||||
style={{
|
||||
borderLeft: isUserMessage
|
||||
? '4px solid rgba(255, 255, 255, 0.5)'
|
||||
: '4px solid var(--semi-color-primary)',
|
||||
paddingLeft: '16px',
|
||||
margin: '12px 0',
|
||||
backgroundColor: isUserMessage
|
||||
? 'rgba(255, 255, 255, 0.1)'
|
||||
: 'var(--semi-color-fill-0)',
|
||||
padding: '8px 16px',
|
||||
borderRadius: '0 4px 4px 0',
|
||||
fontStyle: 'italic',
|
||||
color: isUserMessage ? 'white' : 'inherit',
|
||||
}}
|
||||
/>
|
||||
),
|
||||
ul: (props) => (
|
||||
<ul
|
||||
{...props}
|
||||
style={{
|
||||
margin: '8px 0',
|
||||
paddingLeft: '20px',
|
||||
color: isUserMessage ? 'white' : 'inherit',
|
||||
}}
|
||||
/>
|
||||
),
|
||||
ol: (props) => (
|
||||
<ol
|
||||
{...props}
|
||||
style={{
|
||||
margin: '8px 0',
|
||||
paddingLeft: '20px',
|
||||
color: isUserMessage ? 'white' : 'inherit',
|
||||
}}
|
||||
/>
|
||||
),
|
||||
li: (props) => (
|
||||
<li
|
||||
{...props}
|
||||
style={{
|
||||
margin: '4px 0',
|
||||
lineHeight: '1.6',
|
||||
color: isUserMessage ? 'white' : 'inherit',
|
||||
}}
|
||||
/>
|
||||
),
|
||||
table: (props) => (
|
||||
<div style={{ overflow: 'auto', margin: '12px 0' }}>
|
||||
<table
|
||||
{...props}
|
||||
style={{
|
||||
width: '100%',
|
||||
borderCollapse: 'collapse',
|
||||
border: isUserMessage
|
||||
? '1px solid rgba(255, 255, 255, 0.3)'
|
||||
: '1px solid var(--semi-color-border)',
|
||||
borderRadius: '6px',
|
||||
overflow: 'hidden',
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
),
|
||||
th: (props) => (
|
||||
<th
|
||||
{...props}
|
||||
style={{
|
||||
padding: '8px 12px',
|
||||
backgroundColor: isUserMessage
|
||||
? 'rgba(255, 255, 255, 0.2)'
|
||||
: 'var(--semi-color-fill-1)',
|
||||
border: isUserMessage
|
||||
? '1px solid rgba(255, 255, 255, 0.3)'
|
||||
: '1px solid var(--semi-color-border)',
|
||||
fontWeight: 'bold',
|
||||
textAlign: 'left',
|
||||
color: isUserMessage ? 'white' : 'inherit',
|
||||
}}
|
||||
/>
|
||||
),
|
||||
td: (props) => (
|
||||
<td
|
||||
{...props}
|
||||
style={{
|
||||
padding: '8px 12px',
|
||||
border: isUserMessage
|
||||
? '1px solid rgba(255, 255, 255, 0.3)'
|
||||
: '1px solid var(--semi-color-border)',
|
||||
color: isUserMessage ? 'white' : 'inherit',
|
||||
}}
|
||||
/>
|
||||
),
|
||||
img: (imgProps) => (
|
||||
<img
|
||||
{...imgProps}
|
||||
className='rounded-lg max-w-full h-auto shadow-sm border border-gray-200/60 dark:border-neutral-700/60 cursor-pointer hover:opacity-90 transition-opacity'
|
||||
style={{ maxHeight: '400px', margin: '8px 0' }}
|
||||
onClick={() => setPreviewImageUrl(imgProps.src)}
|
||||
/>
|
||||
),
|
||||
}}
|
||||
>
|
||||
{escapedContent}
|
||||
</ReactMarkdown>
|
||||
|
||||
<ImagePreviewModal
|
||||
visible={!!previewImageUrl}
|
||||
imageUrl={previewImageUrl}
|
||||
onClose={() => setPreviewImageUrl(null)}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export const MarkdownContent = React.memo(MarkdownContentImpl);
|
||||
|
||||
export function MarkdownRenderer(props) {
|
||||
const {
|
||||
content,
|
||||
loading,
|
||||
fontSize = 14,
|
||||
fontFamily = 'inherit',
|
||||
className,
|
||||
style,
|
||||
animated = false,
|
||||
previousContentLength = 0,
|
||||
...otherProps
|
||||
} = props;
|
||||
|
||||
return (
|
||||
<div
|
||||
className={clsx('markdown-body', className)}
|
||||
style={{
|
||||
fontSize: `${fontSize}px`,
|
||||
fontFamily: fontFamily,
|
||||
lineHeight: '1.6',
|
||||
color: 'var(--semi-color-text-0)',
|
||||
...style,
|
||||
}}
|
||||
dir='auto'
|
||||
{...otherProps}
|
||||
>
|
||||
{loading ? (
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: '8px',
|
||||
padding: '16px',
|
||||
color: 'var(--semi-color-text-2)',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
width: '16px',
|
||||
height: '16px',
|
||||
border: '2px solid var(--semi-color-border)',
|
||||
borderTop: '2px solid var(--semi-color-primary)',
|
||||
borderRadius: '50%',
|
||||
animation: 'spin 1s linear infinite',
|
||||
}}
|
||||
/>
|
||||
正在渲染...
|
||||
</div>
|
||||
) : (
|
||||
<MarkdownContent
|
||||
content={content}
|
||||
className={className}
|
||||
animated={animated}
|
||||
previousContentLength={previousContentLength}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default MarkdownRenderer;
|
||||
@@ -0,0 +1,607 @@
|
||||
/* 基础markdown样式 */
|
||||
.markdown-body {
|
||||
font-family: inherit;
|
||||
line-height: 1.6;
|
||||
color: var(--semi-color-text-0);
|
||||
overflow-wrap: break-word;
|
||||
word-wrap: break-word;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
/* 用户消息样式 - 白色字体适配蓝色背景 */
|
||||
.user-message {
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
.user-message .markdown-body {
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
.user-message h1,
|
||||
.user-message h2,
|
||||
.user-message h3,
|
||||
.user-message h4,
|
||||
.user-message h5,
|
||||
.user-message h6 {
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
.user-message p {
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
.user-message span {
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
.user-message div {
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
.user-message li {
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
.user-message td,
|
||||
.user-message th {
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
.user-message blockquote {
|
||||
color: white !important;
|
||||
border-left-color: rgba(255, 255, 255, 0.5) !important;
|
||||
background-color: rgba(255, 255, 255, 0.1) !important;
|
||||
}
|
||||
|
||||
.user-message code:not(pre code) {
|
||||
color: #000 !important;
|
||||
background-color: rgba(255, 255, 255, 0.9) !important;
|
||||
}
|
||||
|
||||
.user-message a {
|
||||
color: #87ceeb !important;
|
||||
/* 浅蓝色链接 */
|
||||
}
|
||||
|
||||
.user-message a:hover {
|
||||
color: #b0e0e6 !important;
|
||||
/* hover时更浅的蓝色 */
|
||||
}
|
||||
|
||||
/* 表格在用户消息中的样式 */
|
||||
.user-message table {
|
||||
border-color: rgba(255, 255, 255, 0.3) !important;
|
||||
}
|
||||
|
||||
.user-message th {
|
||||
background-color: rgba(255, 255, 255, 0.2) !important;
|
||||
border-color: rgba(255, 255, 255, 0.3) !important;
|
||||
}
|
||||
|
||||
.user-message td {
|
||||
border-color: rgba(255, 255, 255, 0.3) !important;
|
||||
}
|
||||
|
||||
/* 加载动画 */
|
||||
@keyframes spin {
|
||||
0% {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
/* 代码高亮主题 - 适配Semi Design */
|
||||
.hljs {
|
||||
display: block;
|
||||
overflow-x: auto;
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
color: var(--semi-color-text-0);
|
||||
}
|
||||
|
||||
.hljs-comment,
|
||||
.hljs-quote {
|
||||
color: var(--semi-color-text-2);
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.hljs-keyword,
|
||||
.hljs-selector-tag,
|
||||
.hljs-subst {
|
||||
color: var(--semi-color-primary);
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.hljs-number,
|
||||
.hljs-literal,
|
||||
.hljs-variable,
|
||||
.hljs-template-variable,
|
||||
.hljs-tag .hljs-attr {
|
||||
color: var(--semi-color-warning);
|
||||
}
|
||||
|
||||
.hljs-string,
|
||||
.hljs-doctag {
|
||||
color: var(--semi-color-success);
|
||||
}
|
||||
|
||||
.hljs-title,
|
||||
.hljs-section,
|
||||
.hljs-selector-id {
|
||||
color: var(--semi-color-primary);
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.hljs-subst {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.hljs-type,
|
||||
.hljs-class .hljs-title {
|
||||
color: var(--semi-color-info);
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.hljs-tag,
|
||||
.hljs-name,
|
||||
.hljs-attribute {
|
||||
color: var(--semi-color-primary);
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.hljs-regexp,
|
||||
.hljs-link {
|
||||
color: var(--semi-color-tertiary);
|
||||
}
|
||||
|
||||
.hljs-symbol,
|
||||
.hljs-bullet {
|
||||
color: var(--semi-color-warning);
|
||||
}
|
||||
|
||||
.hljs-built_in,
|
||||
.hljs-builtin-name {
|
||||
color: var(--semi-color-info);
|
||||
}
|
||||
|
||||
.hljs-meta {
|
||||
color: var(--semi-color-text-2);
|
||||
}
|
||||
|
||||
.hljs-deletion {
|
||||
background: var(--semi-color-danger-light-default);
|
||||
}
|
||||
|
||||
.hljs-addition {
|
||||
background: var(--semi-color-success-light-default);
|
||||
}
|
||||
|
||||
.hljs-emphasis {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.hljs-strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* Mermaid容器样式 */
|
||||
.mermaid-container {
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.mermaid-container:hover {
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
/* 代码块样式增强 */
|
||||
pre {
|
||||
position: relative;
|
||||
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
pre:hover {
|
||||
border-color: var(--semi-color-primary) !important;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
pre:hover .copy-code-button {
|
||||
opacity: 1 !important;
|
||||
}
|
||||
|
||||
.copy-code-button {
|
||||
opacity: 0;
|
||||
transition: opacity 0.2s ease;
|
||||
z-index: 10;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.copy-code-button:hover {
|
||||
opacity: 1 !important;
|
||||
}
|
||||
|
||||
.copy-code-button button {
|
||||
pointer-events: auto !important;
|
||||
cursor: pointer !important;
|
||||
}
|
||||
|
||||
/* 确保按钮可点击 */
|
||||
.copy-code-button .semi-button {
|
||||
pointer-events: auto !important;
|
||||
cursor: pointer !important;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.copy-code-button .semi-button:hover {
|
||||
background-color: var(--semi-color-fill-1) !important;
|
||||
border-color: var(--semi-color-primary) !important;
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
/* ===== 服务大盘描述区域表格增强样式 ===== */
|
||||
.service-dashboard-description .markdown-body table {
|
||||
border-collapse: separate;
|
||||
border-spacing: 0;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
width: 100%;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
|
||||
.service-dashboard-description .markdown-body thead tr {
|
||||
background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 50%, #f0fdfa 100%);
|
||||
}
|
||||
|
||||
.service-dashboard-description .markdown-body th {
|
||||
padding: 12px 20px !important;
|
||||
font-weight: 600 !important;
|
||||
font-size: 13px;
|
||||
color: #065f46 !important;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
border-bottom: 2px solid #a7f3d0 !important;
|
||||
border-right: 1px solid #d1fae5 !important;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.service-dashboard-description .markdown-body th:last-child {
|
||||
border-right: none !important;
|
||||
}
|
||||
|
||||
.service-dashboard-description .markdown-body td {
|
||||
padding: 10px 20px !important;
|
||||
font-size: 14px;
|
||||
color: #374151 !important;
|
||||
border-bottom: 1px solid #f3f4f6 !important;
|
||||
border-right: 1px solid #f3f4f6 !important;
|
||||
transition: background-color 0.15s ease;
|
||||
}
|
||||
|
||||
.service-dashboard-description .markdown-body td:last-child {
|
||||
border-right: none !important;
|
||||
}
|
||||
|
||||
.service-dashboard-description .markdown-body tbody tr:last-child td {
|
||||
border-bottom: none !important;
|
||||
}
|
||||
|
||||
.service-dashboard-description .markdown-body tbody tr:hover {
|
||||
background-color: #f0fdf4;
|
||||
}
|
||||
|
||||
.service-dashboard-description .markdown-body tbody tr:nth-child(even) {
|
||||
background-color: #fafafa;
|
||||
}
|
||||
|
||||
.service-dashboard-description .markdown-body tbody tr:nth-child(even):hover {
|
||||
background-color: #f0fdf4;
|
||||
}
|
||||
|
||||
/* 服务大盘描述区域标题样式增强 */
|
||||
.service-dashboard-description .markdown-body h3,
|
||||
.service-dashboard-description .markdown-body h4 {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
color: #1f2937 !important;
|
||||
margin-top: 24px !important;
|
||||
margin-bottom: 12px !important;
|
||||
padding-bottom: 8px;
|
||||
border-bottom: 2px solid #ecfdf5;
|
||||
}
|
||||
|
||||
.service-dashboard-description .markdown-body h3:first-child,
|
||||
.service-dashboard-description .markdown-body h4:first-child {
|
||||
margin-top: 0 !important;
|
||||
}
|
||||
|
||||
/* 暗色模式适配 */
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.service-dashboard-description .markdown-body table {
|
||||
border-color: #374151;
|
||||
}
|
||||
|
||||
.service-dashboard-description .markdown-body thead tr {
|
||||
background: linear-gradient(135deg, #064e3b33 0%, #065f4633 100%);
|
||||
}
|
||||
|
||||
.service-dashboard-description .markdown-body th {
|
||||
color: #6ee7b7 !important;
|
||||
border-bottom-color: #065f46 !important;
|
||||
border-right-color: #1f2937 !important;
|
||||
}
|
||||
|
||||
.service-dashboard-description .markdown-body td {
|
||||
color: #d1d5db !important;
|
||||
border-bottom-color: #1f2937 !important;
|
||||
border-right-color: #1f2937 !important;
|
||||
}
|
||||
|
||||
.service-dashboard-description .markdown-body tbody tr:hover {
|
||||
background-color: #064e3b22;
|
||||
}
|
||||
|
||||
.service-dashboard-description .markdown-body tbody tr:nth-child(even) {
|
||||
background-color: #11182722;
|
||||
}
|
||||
|
||||
.service-dashboard-description .markdown-body h3,
|
||||
.service-dashboard-description .markdown-body h4 {
|
||||
color: #f3f4f6 !important;
|
||||
border-bottom-color: #1f2937;
|
||||
}
|
||||
}
|
||||
|
||||
/* dark class 模式适配 (tailwind dark mode) */
|
||||
.dark .service-dashboard-description .markdown-body table {
|
||||
border-color: #374151;
|
||||
}
|
||||
|
||||
.dark .service-dashboard-description .markdown-body thead tr {
|
||||
background: linear-gradient(135deg, #064e3b33 0%, #065f4633 100%);
|
||||
}
|
||||
|
||||
.dark .service-dashboard-description .markdown-body th {
|
||||
color: #6ee7b7 !important;
|
||||
border-bottom-color: #065f46 !important;
|
||||
border-right-color: #1f2937 !important;
|
||||
}
|
||||
|
||||
.dark .service-dashboard-description .markdown-body td {
|
||||
color: #d1d5db !important;
|
||||
border-bottom-color: #1f2937 !important;
|
||||
border-right-color: #1f2937 !important;
|
||||
}
|
||||
|
||||
.dark .service-dashboard-description .markdown-body tbody tr:hover {
|
||||
background-color: #064e3b22;
|
||||
}
|
||||
|
||||
.dark .service-dashboard-description .markdown-body tbody tr:nth-child(even) {
|
||||
background-color: #11182722;
|
||||
}
|
||||
|
||||
.dark .service-dashboard-description .markdown-body h3,
|
||||
.dark .service-dashboard-description .markdown-body h4 {
|
||||
color: #f3f4f6 !important;
|
||||
border-bottom-color: #1f2937;
|
||||
}
|
||||
|
||||
/* 表格响应式 */
|
||||
@media (max-width: 768px) {
|
||||
.markdown-body table {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.markdown-body th,
|
||||
.markdown-body td {
|
||||
padding: 6px 8px;
|
||||
}
|
||||
|
||||
.service-dashboard-description .markdown-body th {
|
||||
padding: 8px 12px !important;
|
||||
}
|
||||
|
||||
.service-dashboard-description .markdown-body td {
|
||||
padding: 8px 12px !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* 数学公式样式 */
|
||||
.katex {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
.katex-display {
|
||||
margin: 1em 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* 链接hover效果 */
|
||||
.markdown-body a {
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
/* 引用块样式增强 */
|
||||
.markdown-body blockquote {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.markdown-body blockquote::before {
|
||||
content: '"';
|
||||
position: absolute;
|
||||
left: -8px;
|
||||
top: -8px;
|
||||
font-size: 24px;
|
||||
color: var(--semi-color-primary);
|
||||
opacity: 0.3;
|
||||
}
|
||||
|
||||
/* 列表样式增强 */
|
||||
.markdown-body ul li::marker {
|
||||
color: var(--semi-color-primary);
|
||||
}
|
||||
|
||||
.markdown-body ol li::marker {
|
||||
color: var(--semi-color-primary);
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* 分隔线样式 */
|
||||
.markdown-body hr {
|
||||
border: none;
|
||||
height: 1px;
|
||||
background: linear-gradient(
|
||||
to right,
|
||||
transparent,
|
||||
var(--semi-color-border),
|
||||
transparent
|
||||
);
|
||||
margin: 24px 0;
|
||||
}
|
||||
|
||||
/* 图片样式 */
|
||||
.markdown-body img {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||
margin: 12px 0;
|
||||
}
|
||||
|
||||
/* 内联代码样式 */
|
||||
.markdown-body code:not(pre code) {
|
||||
background-color: var(--semi-color-fill-1);
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
font-size: 0.9em;
|
||||
color: var(--semi-color-primary);
|
||||
border: 1px solid var(--semi-color-border);
|
||||
}
|
||||
|
||||
/* 标题锚点样式 */
|
||||
.markdown-body h1:hover,
|
||||
.markdown-body h2:hover,
|
||||
.markdown-body h3:hover,
|
||||
.markdown-body h4:hover,
|
||||
.markdown-body h5:hover,
|
||||
.markdown-body h6:hover {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* 任务列表样式 */
|
||||
.markdown-body input[type='checkbox'] {
|
||||
margin-right: 8px;
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
.markdown-body li.task-list-item {
|
||||
list-style: none;
|
||||
margin-left: -20px;
|
||||
}
|
||||
|
||||
/* 键盘按键样式 */
|
||||
.markdown-body kbd {
|
||||
background-color: var(--semi-color-fill-0);
|
||||
border: 1px solid var(--semi-color-border);
|
||||
border-radius: 3px;
|
||||
box-shadow: 0 1px 0 var(--semi-color-border);
|
||||
color: var(--semi-color-text-0);
|
||||
display: inline-block;
|
||||
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
|
||||
font-size: 0.85em;
|
||||
font-weight: 700;
|
||||
line-height: 1;
|
||||
padding: 2px 4px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* 详情折叠样式 */
|
||||
.markdown-body details {
|
||||
border: 1px solid var(--semi-color-border);
|
||||
border-radius: 6px;
|
||||
padding: 12px;
|
||||
margin: 12px 0;
|
||||
}
|
||||
|
||||
.markdown-body summary {
|
||||
cursor: pointer;
|
||||
font-weight: bold;
|
||||
color: var(--semi-color-primary);
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.markdown-body summary:hover {
|
||||
color: var(--semi-color-primary-hover);
|
||||
}
|
||||
|
||||
/* 脚注样式 */
|
||||
.markdown-body .footnote-ref {
|
||||
color: var(--semi-color-primary);
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.markdown-body .footnote-ref:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/* 警告块样式 */
|
||||
.markdown-body .warning {
|
||||
background-color: var(--semi-color-warning-light-default);
|
||||
border-left: 4px solid var(--semi-color-warning);
|
||||
padding: 12px 16px;
|
||||
margin: 12px 0;
|
||||
border-radius: 0 6px 6px 0;
|
||||
}
|
||||
|
||||
.markdown-body .info {
|
||||
background-color: var(--semi-color-info-light-default);
|
||||
border-left: 4px solid var(--semi-color-info);
|
||||
padding: 12px 16px;
|
||||
margin: 12px 0;
|
||||
border-radius: 0 6px 6px 0;
|
||||
}
|
||||
|
||||
.markdown-body .success {
|
||||
background-color: var(--semi-color-success-light-default);
|
||||
border-left: 4px solid var(--semi-color-success);
|
||||
padding: 12px 16px;
|
||||
margin: 12px 0;
|
||||
border-radius: 0 6px 6px 0;
|
||||
}
|
||||
|
||||
.markdown-body .danger {
|
||||
background-color: var(--semi-color-danger-light-default);
|
||||
border-left: 4px solid var(--semi-color-danger);
|
||||
padding: 12px 16px;
|
||||
margin: 12px 0;
|
||||
border-radius: 0 6px 6px 0;
|
||||
}
|
||||
|
||||
@keyframes fade-in {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(6px) scale(0.98);
|
||||
filter: blur(3px);
|
||||
}
|
||||
60% {
|
||||
opacity: 0.85;
|
||||
filter: blur(0.5px);
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0) scale(1);
|
||||
filter: blur(0);
|
||||
}
|
||||
}
|
||||
|
||||
.animate-fade-in {
|
||||
animation: fade-in 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
|
||||
will-change: opacity, transform;
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
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 React from 'react';
|
||||
import { Modal, Button, Typography } from '@douyinfe/semi-ui';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
Gift,
|
||||
ArrowRight,
|
||||
Sparkles,
|
||||
X,
|
||||
Wallet,
|
||||
KeyRound,
|
||||
Star,
|
||||
} from 'lucide-react';
|
||||
import { renderQuota } from '../../../helpers';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
const FEATURES = [
|
||||
{
|
||||
icon: Sparkles,
|
||||
title: '顶尖模型随心调',
|
||||
desc: '可调用 claude、codex 等全球顶尖大模型',
|
||||
},
|
||||
{
|
||||
icon: KeyRound,
|
||||
title: '一个 Key 接入一切',
|
||||
desc: '生成 API Key,直接对接 openclaw、opencode 等工具',
|
||||
},
|
||||
];
|
||||
|
||||
const NewUserGiftModal = ({ visible, onClose, quota }) => {
|
||||
const { t } = useTranslation();
|
||||
const quotaDisplay = renderQuota(quota || 0);
|
||||
|
||||
return (
|
||||
<Modal
|
||||
visible={visible}
|
||||
closable={false}
|
||||
maskClosable={true}
|
||||
onCancel={onClose}
|
||||
footer={null}
|
||||
width={440}
|
||||
className='new-user-gift-modal'
|
||||
bodyStyle={{ padding: 0 }}
|
||||
centered
|
||||
>
|
||||
<div className='relative overflow-hidden bg-white dark:bg-gray-900'>
|
||||
{/* 关闭按钮 */}
|
||||
<button
|
||||
onClick={onClose}
|
||||
className='absolute top-3.5 right-3.5 z-20 w-7 h-7 rounded-full bg-white/20 hover:bg-white/35 flex items-center justify-center transition-colors duration-150'
|
||||
aria-label={t('关闭')}
|
||||
>
|
||||
<X size={14} className='text-white' />
|
||||
</button>
|
||||
|
||||
{/* 头部 */}
|
||||
<div className='relative bg-gradient-to-br from-amber-400 via-orange-400 to-yellow-500 px-8 pt-8 pb-12 text-center overflow-hidden'>
|
||||
{/* 装饰圆 */}
|
||||
<div className='absolute -top-12 -right-12 w-48 h-48 bg-white/10 rounded-full' />
|
||||
<div className='absolute -bottom-8 -left-8 w-32 h-32 bg-white/10 rounded-full' />
|
||||
<div className='absolute top-6 left-8 w-1.5 h-1.5 bg-white/60 rounded-full' />
|
||||
<div className='absolute top-10 right-16 w-2 h-2 bg-white/40 rounded-full' />
|
||||
<div className='absolute bottom-10 right-10 w-1.5 h-1.5 bg-white/55 rounded-full' />
|
||||
<div className='absolute top-16 left-20 w-1 h-1 bg-white/45 rounded-full' />
|
||||
|
||||
{/* 星形装饰 */}
|
||||
<div className='absolute top-5 right-8 opacity-30'>
|
||||
<Star size={10} className='text-white fill-white' />
|
||||
</div>
|
||||
<div className='absolute bottom-14 left-12 opacity-25'>
|
||||
<Star size={8} className='text-white fill-white' />
|
||||
</div>
|
||||
|
||||
{/* 礼物图标 */}
|
||||
<div className='relative mx-auto mb-4 w-16 h-16 bg-white/25 backdrop-blur-sm rounded-2xl flex items-center justify-center shadow-2xl ring-2 ring-white/30 rotate-3'>
|
||||
<Gift size={30} className='text-white -rotate-3' />
|
||||
<div className='absolute -top-2 -right-2 w-6 h-6 bg-white rounded-full flex items-center justify-center shadow-lg'>
|
||||
<Sparkles size={12} className='text-amber-500' />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2 className='text-white text-lg font-bold mb-1 leading-snug drop-shadow-sm'>
|
||||
{t('恭喜!新人礼包已到账')}
|
||||
</h2>
|
||||
<p className='text-amber-100 text-xs'>
|
||||
{t('专属体验额度已自动充入您的账户')}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* 额度卡片 — 叠加在头部下边缘 */}
|
||||
<div className='relative -mt-7 mx-5 z-10'>
|
||||
<div className='bg-white dark:bg-gray-800 rounded-2xl shadow-xl shadow-amber-400/20 border border-amber-100 dark:border-amber-900/40 px-5 py-4 text-center'>
|
||||
<div className='flex items-center justify-center gap-1.5 mb-1.5'>
|
||||
<Wallet
|
||||
size={13}
|
||||
className='text-amber-500 dark:text-amber-400'
|
||||
/>
|
||||
<Text className='!text-amber-600 dark:!text-amber-400 text-xs font-medium'>
|
||||
{t('免费体验额度')}
|
||||
</Text>
|
||||
</div>
|
||||
<div className='text-4xl font-extrabold bg-gradient-to-r from-amber-500 to-orange-500 bg-clip-text text-transparent leading-tight tracking-tight'>
|
||||
{quotaDisplay}
|
||||
</div>
|
||||
<Text className='!text-gray-400 dark:!text-gray-400 text-xs mt-1.5 block'>
|
||||
{t('已存入账户 · 无需任何操作 · 用完可随时充值')}
|
||||
</Text>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 权益列表 */}
|
||||
<div className='px-5 pt-3.5 pb-3 space-y-2'>
|
||||
{FEATURES.map(({ icon: Icon, title, desc }) => (
|
||||
<div
|
||||
key={title}
|
||||
className='flex items-start gap-3 p-3 rounded-xl bg-amber-50/60 dark:bg-gray-800/50 hover:bg-amber-50 dark:hover:bg-amber-900/20 border border-amber-100/80 dark:border-amber-900/30 transition-colors duration-150'
|
||||
>
|
||||
<div className='w-8 h-8 bg-gradient-to-br from-amber-400 to-orange-400 rounded-lg flex items-center justify-center flex-shrink-0 shadow-sm shadow-amber-300/40'>
|
||||
<Icon size={14} className='text-white' />
|
||||
</div>
|
||||
<div className='min-w-0'>
|
||||
<p className='text-gray-800 dark:text-gray-200 text-sm font-semibold leading-snug'>
|
||||
{t(title)}
|
||||
</p>
|
||||
<p className='text-gray-500 dark:text-gray-400 text-xs mt-0.5 leading-relaxed'>
|
||||
{t(desc)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* 底部按钮 */}
|
||||
<div className='px-5 pb-5 pt-1.5'>
|
||||
<Button
|
||||
theme='solid'
|
||||
size='large'
|
||||
onClick={onClose}
|
||||
className='w-full !bg-gradient-to-r !from-amber-400 !to-orange-500 hover:!from-amber-500 hover:!to-orange-600 !border-0 !rounded-xl !h-11 !font-semibold !shadow-lg !shadow-amber-400/30 transition-all duration-200 hover:!shadow-xl hover:!shadow-amber-400/40 active:!scale-[0.98]'
|
||||
>
|
||||
<span className='flex items-center justify-center gap-2 text-white'>
|
||||
{t('马上试一试')}
|
||||
<ArrowRight size={16} />
|
||||
</span>
|
||||
</Button>
|
||||
<p className='text-gray-400 dark:text-gray-500 text-xs text-center mt-2.5 leading-relaxed'>
|
||||
{t('在「用户中心」可随时查看余额和使用记录')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style jsx='true'>{`
|
||||
.new-user-gift-modal .semi-modal-content {
|
||||
border-radius: 20px;
|
||||
overflow: hidden;
|
||||
padding: 0;
|
||||
}
|
||||
.new-user-gift-modal .semi-modal-body {
|
||||
padding: 0;
|
||||
}
|
||||
`}</style>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default NewUserGiftModal;
|
||||
@@ -0,0 +1,320 @@
|
||||
/*
|
||||
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 React, { useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
Modal,
|
||||
Button,
|
||||
Input,
|
||||
Typography,
|
||||
Tabs,
|
||||
TabPane,
|
||||
} from '@douyinfe/semi-ui';
|
||||
|
||||
/**
|
||||
* 通用安全验证模态框组件
|
||||
* 配合 useSecureVerification Hook 使用
|
||||
* @param {Object} props
|
||||
* @param {boolean} props.visible - 是否显示模态框
|
||||
* @param {Object} props.verificationMethods - 可用的验证方式
|
||||
* @param {Object} props.verificationState - 当前验证状态
|
||||
* @param {Function} props.onVerify - 验证回调
|
||||
* @param {Function} props.onCancel - 取消回调
|
||||
* @param {Function} props.onCodeChange - 验证码变化回调
|
||||
* @param {Function} props.onMethodSwitch - 验证方式切换回调
|
||||
* @param {string} props.title - 模态框标题
|
||||
* @param {string} props.description - 验证描述文本
|
||||
*/
|
||||
const SecureVerificationModal = ({
|
||||
visible,
|
||||
verificationMethods,
|
||||
verificationState,
|
||||
onVerify,
|
||||
onCancel,
|
||||
onCodeChange,
|
||||
onMethodSwitch,
|
||||
title,
|
||||
description,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [, setIsAnimating] = useState(false);
|
||||
const [, setVerifySuccess] = useState(false);
|
||||
|
||||
const { has2FA, hasPasskey, passkeySupported } = verificationMethods;
|
||||
const { method, loading, code } = verificationState;
|
||||
|
||||
useEffect(() => {
|
||||
if (visible) {
|
||||
setIsAnimating(true);
|
||||
setVerifySuccess(false);
|
||||
} else {
|
||||
setIsAnimating(false);
|
||||
}
|
||||
}, [visible]);
|
||||
|
||||
const handleKeyDown = (e) => {
|
||||
if (e.key === 'Enter' && code.trim() && !loading && method === '2fa') {
|
||||
onVerify(method, code);
|
||||
}
|
||||
if (e.key === 'Escape' && !loading) {
|
||||
onCancel();
|
||||
}
|
||||
};
|
||||
|
||||
// 如果用户没有启用任何验证方式
|
||||
if (visible && !has2FA && !hasPasskey) {
|
||||
return (
|
||||
<Modal
|
||||
title={title || t('安全验证')}
|
||||
visible={visible}
|
||||
onCancel={onCancel}
|
||||
footer={<Button onClick={onCancel}>{t('确定')}</Button>}
|
||||
width={500}
|
||||
style={{ maxWidth: '90vw' }}
|
||||
>
|
||||
<div className='text-center py-6'>
|
||||
<div className='mb-4'>
|
||||
<svg
|
||||
className='w-16 h-16 text-yellow-500 mx-auto mb-4'
|
||||
fill='currentColor'
|
||||
viewBox='0 0 20 20'
|
||||
>
|
||||
<path
|
||||
fillRule='evenodd'
|
||||
d='M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z'
|
||||
clipRule='evenodd'
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<Typography.Title heading={4} className='mb-2'>
|
||||
{t('需要安全验证')}
|
||||
</Typography.Title>
|
||||
<Typography.Text type='tertiary'>
|
||||
{t('您需要先启用两步验证或 Passkey 才能查看敏感信息。')}
|
||||
</Typography.Text>
|
||||
<br />
|
||||
<Typography.Text type='tertiary'>
|
||||
{t('请前往个人设置 → 安全设置进行配置。')}
|
||||
</Typography.Text>
|
||||
</div>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={title || t('安全验证')}
|
||||
visible={visible}
|
||||
onCancel={loading ? undefined : onCancel}
|
||||
closeOnEsc={!loading}
|
||||
footer={null}
|
||||
width={460}
|
||||
centered
|
||||
style={{
|
||||
maxWidth: 'calc(100vw - 32px)',
|
||||
}}
|
||||
bodyStyle={{
|
||||
padding: '20px 24px',
|
||||
}}
|
||||
>
|
||||
<div style={{ width: '100%' }}>
|
||||
{/* 描述信息 */}
|
||||
{description && (
|
||||
<Typography.Paragraph
|
||||
type='tertiary'
|
||||
style={{
|
||||
margin: '0 0 20px 0',
|
||||
fontSize: '14px',
|
||||
lineHeight: '1.6',
|
||||
}}
|
||||
>
|
||||
{description}
|
||||
</Typography.Paragraph>
|
||||
)}
|
||||
|
||||
{/* 验证方式选择 */}
|
||||
<Tabs
|
||||
activeKey={method}
|
||||
onChange={onMethodSwitch}
|
||||
type='line'
|
||||
size='default'
|
||||
style={{ margin: 0 }}
|
||||
>
|
||||
{has2FA && (
|
||||
<TabPane tab={t('两步验证')} itemKey='2fa'>
|
||||
<div style={{ paddingTop: '20px' }}>
|
||||
<div style={{ marginBottom: '12px' }}>
|
||||
<Input
|
||||
placeholder={t('请输入6位验证码或8位备用码')}
|
||||
value={code}
|
||||
onChange={onCodeChange}
|
||||
size='large'
|
||||
maxLength={8}
|
||||
onKeyDown={handleKeyDown}
|
||||
autoFocus={method === '2fa'}
|
||||
disabled={loading}
|
||||
prefix={
|
||||
<svg
|
||||
style={{
|
||||
width: 16,
|
||||
height: 16,
|
||||
marginRight: 8,
|
||||
flexShrink: 0,
|
||||
}}
|
||||
fill='currentColor'
|
||||
viewBox='0 0 20 20'
|
||||
>
|
||||
<path
|
||||
fillRule='evenodd'
|
||||
d='M18 8a6 6 0 01-7.743 5.743L10 14l-1 1-1 1H6v2H2v-4l4.257-4.257A6 6 0 1118 8zm-6-4a1 1 0 100 2 2 2 0 012 2 1 1 0 102 0 4 4 0 00-4-4z'
|
||||
clipRule='evenodd'
|
||||
/>
|
||||
</svg>
|
||||
}
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Typography.Text
|
||||
type='tertiary'
|
||||
size='small'
|
||||
style={{
|
||||
display: 'block',
|
||||
marginBottom: '20px',
|
||||
fontSize: '13px',
|
||||
lineHeight: '1.5',
|
||||
}}
|
||||
>
|
||||
{t('从认证器应用中获取验证码,或使用备用码')}
|
||||
</Typography.Text>
|
||||
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
justifyContent: 'flex-end',
|
||||
gap: '8px',
|
||||
flexWrap: 'wrap',
|
||||
}}
|
||||
>
|
||||
<Button onClick={onCancel} disabled={loading}>
|
||||
{t('取消')}
|
||||
</Button>
|
||||
<Button
|
||||
theme='solid'
|
||||
type='primary'
|
||||
loading={loading}
|
||||
disabled={!code.trim() || loading}
|
||||
onClick={() => onVerify(method, code)}
|
||||
>
|
||||
{t('验证')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</TabPane>
|
||||
)}
|
||||
|
||||
{hasPasskey && passkeySupported && (
|
||||
<TabPane tab={t('Passkey')} itemKey='passkey'>
|
||||
<div style={{ paddingTop: '20px' }}>
|
||||
<div
|
||||
style={{
|
||||
textAlign: 'center',
|
||||
padding: '24px 16px',
|
||||
marginBottom: '20px',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
width: 56,
|
||||
height: 56,
|
||||
margin: '0 auto 16px',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
borderRadius: '50%',
|
||||
background: 'var(--semi-color-primary-light-default)',
|
||||
}}
|
||||
>
|
||||
<svg
|
||||
style={{
|
||||
width: 28,
|
||||
height: 28,
|
||||
color: 'var(--semi-color-primary)',
|
||||
}}
|
||||
fill='currentColor'
|
||||
viewBox='0 0 20 20'
|
||||
>
|
||||
<path
|
||||
fillRule='evenodd'
|
||||
d='M18 8a6 6 0 01-7.743 5.743L10 14l-1 1-1 1H6v2H2v-4l4.257-4.257A6 6 0 1118 8zm-6-4a1 1 0 100 2 2 2 0 012 2 1 1 0 102 0 4 4 0 00-4-4z'
|
||||
clipRule='evenodd'
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<Typography.Title
|
||||
heading={5}
|
||||
style={{ margin: '0 0 8px', fontSize: '16px' }}
|
||||
>
|
||||
{t('使用 Passkey 验证')}
|
||||
</Typography.Title>
|
||||
<Typography.Text
|
||||
type='tertiary'
|
||||
style={{
|
||||
display: 'block',
|
||||
margin: 0,
|
||||
fontSize: '13px',
|
||||
lineHeight: '1.5',
|
||||
}}
|
||||
>
|
||||
{t('点击验证按钮,使用您的生物特征或安全密钥')}
|
||||
</Typography.Text>
|
||||
</div>
|
||||
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
justifyContent: 'flex-end',
|
||||
gap: '8px',
|
||||
flexWrap: 'wrap',
|
||||
}}
|
||||
>
|
||||
<Button onClick={onCancel} disabled={loading}>
|
||||
{t('取消')}
|
||||
</Button>
|
||||
<Button
|
||||
theme='solid'
|
||||
type='primary'
|
||||
loading={loading}
|
||||
disabled={loading}
|
||||
onClick={() => onVerify(method)}
|
||||
>
|
||||
{t('验证 Passkey')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</TabPane>
|
||||
)}
|
||||
</Tabs>
|
||||
</div>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default SecureVerificationModal;
|
||||
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
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 React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Modal, Button, Input, Typography } from '@douyinfe/semi-ui';
|
||||
|
||||
/**
|
||||
* 可复用的两步验证模态框组件
|
||||
* @param {Object} props
|
||||
* @param {boolean} props.visible - 是否显示模态框
|
||||
* @param {string} props.code - 验证码值
|
||||
* @param {boolean} props.loading - 是否正在验证
|
||||
* @param {Function} props.onCodeChange - 验证码变化回调
|
||||
* @param {Function} props.onVerify - 验证回调
|
||||
* @param {Function} props.onCancel - 取消回调
|
||||
* @param {string} props.title - 模态框标题
|
||||
* @param {string} props.description - 验证描述文本
|
||||
* @param {string} props.placeholder - 输入框占位文本
|
||||
*/
|
||||
const TwoFactorAuthModal = ({
|
||||
visible,
|
||||
code,
|
||||
loading,
|
||||
onCodeChange,
|
||||
onVerify,
|
||||
onCancel,
|
||||
title,
|
||||
description,
|
||||
placeholder,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const handleKeyDown = (e) => {
|
||||
if (e.key === 'Enter' && code && !loading) {
|
||||
onVerify();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={
|
||||
<div className='flex items-center'>
|
||||
<div className='w-8 h-8 rounded-full bg-blue-100 dark:bg-blue-900 flex items-center justify-center mr-3'>
|
||||
<svg
|
||||
className='w-4 h-4 text-blue-600 dark:text-blue-400'
|
||||
fill='currentColor'
|
||||
viewBox='0 0 20 20'
|
||||
>
|
||||
<path
|
||||
fillRule='evenodd'
|
||||
d='M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z'
|
||||
clipRule='evenodd'
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
{title || t('安全验证')}
|
||||
</div>
|
||||
}
|
||||
visible={visible}
|
||||
onCancel={onCancel}
|
||||
footer={
|
||||
<>
|
||||
<Button onClick={onCancel}>{t('取消')}</Button>
|
||||
<Button
|
||||
type='primary'
|
||||
loading={loading}
|
||||
disabled={!code || loading}
|
||||
onClick={onVerify}
|
||||
>
|
||||
{t('验证')}
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
width={500}
|
||||
style={{ maxWidth: '90vw' }}
|
||||
>
|
||||
<div className='space-y-6'>
|
||||
{/* 安全提示 */}
|
||||
<div className='bg-blue-50 dark:bg-blue-900 rounded-lg p-4'>
|
||||
<div className='flex items-start'>
|
||||
<svg
|
||||
className='w-5 h-5 text-blue-600 dark:text-blue-400 mt-0.5 mr-3 flex-shrink-0'
|
||||
fill='currentColor'
|
||||
viewBox='0 0 20 20'
|
||||
>
|
||||
<path
|
||||
fillRule='evenodd'
|
||||
d='M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z'
|
||||
clipRule='evenodd'
|
||||
/>
|
||||
</svg>
|
||||
<div>
|
||||
<Typography.Text
|
||||
strong
|
||||
className='text-blue-800 dark:text-blue-200'
|
||||
>
|
||||
{t('安全验证')}
|
||||
</Typography.Text>
|
||||
<Typography.Text className='block text-blue-700 dark:text-blue-300 text-sm mt-1'>
|
||||
{description || t('为了保护账户安全,请验证您的两步验证码。')}
|
||||
</Typography.Text>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 验证码输入 */}
|
||||
<div>
|
||||
<Typography.Text strong className='block mb-2'>
|
||||
{t('验证身份')}
|
||||
</Typography.Text>
|
||||
<Input
|
||||
placeholder={placeholder || t('请输入认证器验证码或备用码')}
|
||||
value={code}
|
||||
onChange={onCodeChange}
|
||||
size='large'
|
||||
maxLength={8}
|
||||
onKeyDown={handleKeyDown}
|
||||
autoFocus
|
||||
/>
|
||||
<Typography.Text type='tertiary' size='small' className='mt-2 block'>
|
||||
{t(
|
||||
'支持6位TOTP验证码或8位备用码,可到`个人设置-安全设置-两步验证设置`配置或查看。',
|
||||
)}
|
||||
</Typography.Text>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default TwoFactorAuthModal;
|
||||
@@ -0,0 +1,403 @@
|
||||
/*
|
||||
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 React, { useState, useEffect, useContext } from 'react';
|
||||
import {
|
||||
Modal,
|
||||
RadioGroup,
|
||||
Radio,
|
||||
Button,
|
||||
Typography,
|
||||
} from '@douyinfe/semi-ui';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import {
|
||||
API,
|
||||
clearUserData,
|
||||
showSuccess,
|
||||
showError,
|
||||
showWarning,
|
||||
} from '../../../helpers';
|
||||
import {
|
||||
Sparkles,
|
||||
Briefcase,
|
||||
Cpu,
|
||||
ChevronRight,
|
||||
UserCircle,
|
||||
X,
|
||||
LogOut,
|
||||
} from 'lucide-react';
|
||||
import { UserContext } from '../../../context/User';
|
||||
|
||||
const { Title, Text } = Typography;
|
||||
|
||||
const UserSurveyModal = ({ visible, onClose, onSuccess }) => {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
const [, userDispatch] = useContext(UserContext);
|
||||
const [jobType, setJobType] = useState(null);
|
||||
const [aiToolUsage, setAIToolUsage] = useState(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [showExitConfirm, setShowExitConfirm] = useState(false);
|
||||
|
||||
// 弹窗显示时重置状态
|
||||
useEffect(() => {
|
||||
if (visible) {
|
||||
setJobType(null);
|
||||
setAIToolUsage(null);
|
||||
setLoading(false);
|
||||
setShowExitConfirm(false);
|
||||
}
|
||||
}, [visible]);
|
||||
|
||||
// 处理关闭按钮点击 - 显示确认提示
|
||||
const handleCloseClick = () => {
|
||||
setShowExitConfirm(true);
|
||||
};
|
||||
|
||||
// 确认退出 - 执行退出登录
|
||||
const handleConfirmExit = async () => {
|
||||
try {
|
||||
await API.get('/api/user/logout');
|
||||
showWarning(t('您已退出登录,填写问卷后方可使用平台'));
|
||||
userDispatch({ type: 'logout' });
|
||||
clearUserData();
|
||||
onClose?.();
|
||||
navigate('/org/login');
|
||||
} catch (error) {
|
||||
console.error('Logout failed:', error);
|
||||
// 即使请求失败也清除本地状态
|
||||
userDispatch({ type: 'logout' });
|
||||
clearUserData();
|
||||
onClose?.();
|
||||
navigate('/org/login');
|
||||
}
|
||||
};
|
||||
|
||||
// 取消退出 - 返回填写问卷
|
||||
const handleCancelExit = () => {
|
||||
setShowExitConfirm(false);
|
||||
};
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (!jobType) {
|
||||
showError(t('请选择您的职业类型'));
|
||||
return;
|
||||
}
|
||||
if (!aiToolUsage) {
|
||||
showError(t('请选择您的AI工具使用情况'));
|
||||
return;
|
||||
}
|
||||
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await API.post('/api/user/survey', {
|
||||
job_type: jobType,
|
||||
ai_tool_usage: aiToolUsage,
|
||||
});
|
||||
|
||||
const { success, message } = res.data;
|
||||
if (success) {
|
||||
showSuccess(message || t('提交成功,感谢您的反馈!'));
|
||||
onSuccess?.();
|
||||
onClose?.();
|
||||
} else {
|
||||
showError(message || t('提交失败'));
|
||||
}
|
||||
} catch (error) {
|
||||
showError(t('提交失败,请稍后重试'));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const jobTypeOptions = [
|
||||
{ value: 1, label: t('是,开发/测试/运维等技术岗位'), icon: '💻' },
|
||||
{ value: 2, label: t('是,产品/设计/运营等技术周边岗位'), icon: '🎨' },
|
||||
{ value: 3, label: t('否,其他行业'), icon: '🏢' },
|
||||
];
|
||||
|
||||
const aiToolOptions = [
|
||||
{ value: 1, label: t('是,正在使用'), icon: '🚀' },
|
||||
{ value: 2, label: t('是,了解或尝试过'), icon: '🔍' },
|
||||
{ value: 3, label: t('否,但有兴趣尝试'), icon: '✨' },
|
||||
{ value: 4, label: t('否,暂不需要'), icon: '💤' },
|
||||
];
|
||||
|
||||
return (
|
||||
<Modal
|
||||
visible={visible}
|
||||
closable={false}
|
||||
maskClosable={false}
|
||||
footer={null}
|
||||
width={520}
|
||||
className='user-survey-modal'
|
||||
bodyStyle={{ padding: 0 }}
|
||||
>
|
||||
<div className='relative overflow-hidden'>
|
||||
{/* 关闭按钮 */}
|
||||
<button
|
||||
onClick={handleCloseClick}
|
||||
className='absolute top-4 right-4 z-10 p-2 rounded-full bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600 transition-colors duration-200 group'
|
||||
title={t('暂不填写')}
|
||||
>
|
||||
<X
|
||||
size={18}
|
||||
className='text-gray-500 dark:text-gray-400 group-hover:text-gray-700 dark:group-hover:text-gray-200'
|
||||
/>
|
||||
</button>
|
||||
|
||||
{/* 背景装饰 */}
|
||||
<div className='absolute inset-0 pointer-events-none overflow-hidden'>
|
||||
<div className='absolute -top-20 -right-20 w-40 h-40 bg-gradient-to-br from-brand-from/20 to-brand-to/20 rounded-full blur-3xl' />
|
||||
<div className='absolute -bottom-20 -left-20 w-40 h-40 bg-gradient-to-br from-pink-500/15 to-rose-500/15 rounded-full blur-3xl' />
|
||||
</div>
|
||||
|
||||
{/* 确认退出弹层 */}
|
||||
{showExitConfirm && (
|
||||
<div className='absolute inset-0 z-20 bg-white/95 dark:bg-gray-900/95 backdrop-blur-sm flex flex-col items-center justify-center px-8'>
|
||||
<div className='p-4 bg-gradient-to-br from-amber-100 to-orange-100 dark:from-amber-900/30 dark:to-orange-900/30 rounded-full mb-6'>
|
||||
<LogOut
|
||||
size={32}
|
||||
className='text-amber-600 dark:text-amber-400'
|
||||
/>
|
||||
</div>
|
||||
<h3 className='text-xl font-semibold text-gray-900 dark:text-white mb-3'>
|
||||
{t('确认退出?')}
|
||||
</h3>
|
||||
<p className='text-gray-600 dark:text-gray-400 text-center mb-6 max-w-sm'>
|
||||
{t('不填写问卷将无法使用平台功能,系统将自动退出登录。')}
|
||||
</p>
|
||||
<div className='flex gap-3 w-full max-w-xs'>
|
||||
<Button
|
||||
theme='light'
|
||||
size='large'
|
||||
onClick={handleCancelExit}
|
||||
className='flex-1 !rounded-xl !h-11'
|
||||
>
|
||||
{t('继续填写')}
|
||||
</Button>
|
||||
<Button
|
||||
theme='solid'
|
||||
type='danger'
|
||||
size='large'
|
||||
onClick={handleConfirmExit}
|
||||
className='flex-1 !rounded-xl !h-11'
|
||||
>
|
||||
{t('确认退出')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 头部 */}
|
||||
<div className='relative px-8 pt-8 pb-6'>
|
||||
<div className='flex items-center gap-4 mb-4'>
|
||||
<div className='relative'>
|
||||
<div className='p-3.5 bg-gradient-to-br from-brand-from to-brand-to rounded-2xl shadow-lg shadow-brand/30'>
|
||||
<UserCircle size={28} className='text-white' />
|
||||
</div>
|
||||
<div className='absolute -top-1 -right-1 w-5 h-5 bg-gradient-to-r from-amber-400 to-orange-500 rounded-full flex items-center justify-center shadow-lg'>
|
||||
<Sparkles size={12} className='text-white' />
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<Title
|
||||
heading={4}
|
||||
className='!mb-1 !text-gray-900 dark:!text-white'
|
||||
>
|
||||
{t('欢迎加入!')}
|
||||
</Title>
|
||||
<Text className='!text-gray-500 dark:!text-gray-400 text-sm'>
|
||||
{t('帮助我们更好地了解您')}
|
||||
</Text>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className='p-3 bg-gradient-to-r from-brand-from/5 to-brand-to/5 dark:from-brand-from/20 dark:to-brand-to/20 rounded-xl border border-brand/10 dark:border-brand-deep/50'>
|
||||
<Text className='!text-brand-deep dark:!text-brand-from text-sm'>
|
||||
💡 {t('回答两个小问题,让我们为您提供更适合的服务体验')}
|
||||
</Text>
|
||||
</div>
|
||||
<div className='mt-3 flex items-center gap-2 text-xs text-gray-400 dark:text-gray-500'>
|
||||
<span>✓</span>
|
||||
<span>{t('仅需填写一次,之后不会再弹出')}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 问题区域 */}
|
||||
<div className='relative px-8 pb-6 space-y-6'>
|
||||
{/* 问题1 */}
|
||||
<div className='space-y-3'>
|
||||
<div className='flex items-center gap-2'>
|
||||
<div className='w-6 h-6 rounded-full bg-brand/10 dark:bg-brand-deep/50 flex items-center justify-center'>
|
||||
<Briefcase
|
||||
size={14}
|
||||
className='text-brand-deep dark:text-brand-from'
|
||||
/>
|
||||
</div>
|
||||
<Text strong className='!text-gray-800 dark:!text-gray-200'>
|
||||
{t('您是IT相关从业者吗?')}
|
||||
</Text>
|
||||
</div>
|
||||
<RadioGroup
|
||||
value={jobType}
|
||||
onChange={(e) => setJobType(e.target.value)}
|
||||
direction='vertical'
|
||||
className='survey-radio-group'
|
||||
>
|
||||
{jobTypeOptions.map((option) => (
|
||||
<Radio
|
||||
key={option.value}
|
||||
value={option.value}
|
||||
className={`survey-radio-item ${jobType === option.value ? 'selected' : ''}`}
|
||||
>
|
||||
<div className='flex items-center gap-2'>
|
||||
<span className='text-lg'>{option.icon}</span>
|
||||
<span className='text-gray-700 dark:text-gray-300'>
|
||||
{option.label}
|
||||
</span>
|
||||
</div>
|
||||
</Radio>
|
||||
))}
|
||||
</RadioGroup>
|
||||
</div>
|
||||
|
||||
{/* 问题2 */}
|
||||
<div className='space-y-3'>
|
||||
<div className='flex items-center gap-2'>
|
||||
<div className='w-6 h-6 rounded-full bg-brand/10 dark:bg-brand-deep/50 flex items-center justify-center'>
|
||||
<Cpu
|
||||
size={14}
|
||||
className='text-brand-deep dark:text-brand-from'
|
||||
/>
|
||||
</div>
|
||||
<Text strong className='!text-gray-800 dark:!text-gray-200'>
|
||||
{t('您使用过AI编程工具吗?')}
|
||||
</Text>
|
||||
<Text className='!text-gray-400 dark:!text-gray-500 text-xs'>
|
||||
{t('(如Cursor/Claude/Copilot等)')}
|
||||
</Text>
|
||||
</div>
|
||||
<RadioGroup
|
||||
value={aiToolUsage}
|
||||
onChange={(e) => setAIToolUsage(e.target.value)}
|
||||
direction='vertical'
|
||||
className='survey-radio-group'
|
||||
>
|
||||
{aiToolOptions.map((option) => (
|
||||
<Radio
|
||||
key={option.value}
|
||||
value={option.value}
|
||||
className={`survey-radio-item ${aiToolUsage === option.value ? 'selected' : ''}`}
|
||||
>
|
||||
<div className='flex items-center gap-2'>
|
||||
<span className='text-lg'>{option.icon}</span>
|
||||
<span className='text-gray-700 dark:text-gray-300'>
|
||||
{option.label}
|
||||
</span>
|
||||
</div>
|
||||
</Radio>
|
||||
))}
|
||||
</RadioGroup>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 底部按钮 */}
|
||||
<div className='relative px-8 py-5 border-t border-gray-100 dark:border-gray-800 bg-gray-50/50 dark:bg-gray-900/50'>
|
||||
<Button
|
||||
theme='solid'
|
||||
type='primary'
|
||||
size='large'
|
||||
loading={loading}
|
||||
onClick={handleSubmit}
|
||||
disabled={!jobType || !aiToolUsage}
|
||||
className='w-full !bg-gradient-to-r !from-brand-from !to-brand-to hover:!from-brand-from hover:!to-brand-to !border-0 !rounded-xl !h-12 !font-medium !shadow-lg !shadow-brand/25 transition-all duration-200 hover:!shadow-xl hover:!shadow-brand/30 disabled:!opacity-50 disabled:!cursor-not-allowed'
|
||||
>
|
||||
<span className='flex items-center justify-center gap-2'>
|
||||
{t('开始使用')}
|
||||
<ChevronRight size={18} />
|
||||
</span>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style jsx='true'>{`
|
||||
.user-survey-modal .semi-modal-content {
|
||||
border-radius: 20px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.survey-radio-group .semi-radio {
|
||||
margin-bottom: 8px;
|
||||
padding: 12px 16px;
|
||||
border-radius: 12px;
|
||||
border: 2px solid transparent;
|
||||
background: rgba(249, 250, 251, 0.8);
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.dark .survey-radio-group .semi-radio {
|
||||
background: rgba(31, 41, 55, 0.5);
|
||||
}
|
||||
|
||||
.survey-radio-group .semi-radio:hover {
|
||||
background: rgba(243, 244, 246, 1);
|
||||
border-color: color-mix(in srgb, var(--brand-primary) 30%, transparent);
|
||||
}
|
||||
|
||||
.dark .survey-radio-group .semi-radio:hover {
|
||||
background: rgba(55, 65, 81, 0.8);
|
||||
border-color: color-mix(in srgb, var(--brand-primary) 40%, transparent);
|
||||
}
|
||||
|
||||
.survey-radio-group .semi-radio.semi-radio-checked {
|
||||
background: linear-gradient(
|
||||
135deg,
|
||||
color-mix(in srgb, var(--brand-primary) 10%, transparent) 0%,
|
||||
color-mix(in srgb, var(--brand-gradient-via) 10%, transparent) 100%
|
||||
);
|
||||
border-color: color-mix(in srgb, var(--brand-primary) 50%, transparent);
|
||||
}
|
||||
|
||||
.dark .survey-radio-group .semi-radio.semi-radio-checked {
|
||||
background: linear-gradient(
|
||||
135deg,
|
||||
color-mix(in srgb, var(--brand-primary) 20%, transparent) 0%,
|
||||
color-mix(in srgb, var(--brand-gradient-via) 20%, transparent) 100%
|
||||
);
|
||||
border-color: color-mix(in srgb, var(--brand-primary) 60%, transparent);
|
||||
}
|
||||
|
||||
.survey-radio-group .semi-radio .semi-radio-inner-display {
|
||||
border-color: #d1d5db;
|
||||
}
|
||||
|
||||
.survey-radio-group
|
||||
.semi-radio.semi-radio-checked
|
||||
.semi-radio-inner-display {
|
||||
border-color: var(--brand-primary);
|
||||
background: var(--brand-primary);
|
||||
}
|
||||
`}</style>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default UserSurveyModal;
|
||||
@@ -0,0 +1,198 @@
|
||||
/*
|
||||
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 React, { useState } from 'react';
|
||||
import { Card, Divider, Button } from '@douyinfe/semi-ui';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useIsMobile } from '../../../hooks/common/useIsMobile';
|
||||
import { IconEyeOpened, IconEyeClosed } from '@douyinfe/semi-icons';
|
||||
|
||||
/**
|
||||
* CardPro 高级卡片组件
|
||||
*
|
||||
* 布局分为6个区域:
|
||||
* 1. 统计信息区域 (statsArea)
|
||||
* 2. 描述信息区域 (descriptionArea)
|
||||
* 3. 类型切换/标签区域 (tabsArea)
|
||||
* 4. 操作按钮区域 (actionsArea)
|
||||
* 5. 搜索表单区域 (searchArea)
|
||||
* 6. 分页区域 (paginationArea) - 固定在卡片底部
|
||||
*
|
||||
* 支持三种布局类型:
|
||||
* - type1: 操作型 (如TokensTable) - 描述信息 + 操作按钮 + 搜索表单
|
||||
* - type2: 查询型 (如LogsTable) - 统计信息 + 搜索表单
|
||||
* - type3: 复杂型 (如ChannelsTable) - 描述信息 + 类型切换 + 操作按钮 + 搜索表单
|
||||
*/
|
||||
const CardPro = ({
|
||||
type = 'type1',
|
||||
className = '',
|
||||
children,
|
||||
// 各个区域的内容
|
||||
statsArea,
|
||||
descriptionArea,
|
||||
tabsArea,
|
||||
actionsArea,
|
||||
searchArea,
|
||||
paginationArea, // 新增分页区域
|
||||
// 卡片属性
|
||||
shadows = '',
|
||||
bordered = true,
|
||||
// 自定义样式
|
||||
style,
|
||||
// 国际化函数
|
||||
t = (key) => key,
|
||||
...props
|
||||
}) => {
|
||||
const isMobile = useIsMobile();
|
||||
const [showMobileActions, setShowMobileActions] = useState(false);
|
||||
|
||||
const toggleMobileActions = () => {
|
||||
setShowMobileActions(!showMobileActions);
|
||||
};
|
||||
|
||||
const hasMobileHideableContent = actionsArea || searchArea;
|
||||
|
||||
const renderHeader = () => {
|
||||
const hasContent =
|
||||
statsArea || descriptionArea || tabsArea || actionsArea || searchArea;
|
||||
if (!hasContent) return null;
|
||||
|
||||
return (
|
||||
<div className='flex flex-col w-full'>
|
||||
{/* 统计信息区域 - 用于type2 */}
|
||||
{type === 'type2' && statsArea && <>{statsArea}</>}
|
||||
|
||||
{/* 描述信息区域 - 用于type1和type3 */}
|
||||
{(type === 'type1' || type === 'type3') && descriptionArea && (
|
||||
<>{descriptionArea}</>
|
||||
)}
|
||||
|
||||
{/* 第一个分隔线 - 在描述信息或统计信息后面 */}
|
||||
{((type === 'type1' || type === 'type3') && descriptionArea) ||
|
||||
(type === 'type2' && statsArea) ? (
|
||||
<Divider margin='12px' />
|
||||
) : null}
|
||||
|
||||
{/* 类型切换/标签区域 - 主要用于type3 */}
|
||||
{type === 'type3' && tabsArea && <>{tabsArea}</>}
|
||||
|
||||
{/* 移动端操作切换按钮 */}
|
||||
{isMobile && hasMobileHideableContent && (
|
||||
<>
|
||||
<div className='w-full mb-2'>
|
||||
<Button
|
||||
onClick={toggleMobileActions}
|
||||
icon={showMobileActions ? <IconEyeClosed /> : <IconEyeOpened />}
|
||||
type='tertiary'
|
||||
size='small'
|
||||
theme='outline'
|
||||
block
|
||||
>
|
||||
{showMobileActions ? t('隐藏操作项') : t('显示操作项')}
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* 操作按钮和搜索表单的容器 */}
|
||||
<div
|
||||
className={`flex flex-col gap-2 ${isMobile && !showMobileActions ? 'hidden' : ''}`}
|
||||
>
|
||||
{/* 操作按钮区域 - 用于type1和type3 */}
|
||||
{(type === 'type1' || type === 'type3') &&
|
||||
actionsArea &&
|
||||
(Array.isArray(actionsArea) ? (
|
||||
actionsArea.map((area, idx) => (
|
||||
<React.Fragment key={idx}>
|
||||
{idx !== 0 && <Divider />}
|
||||
<div className='w-full'>{area}</div>
|
||||
</React.Fragment>
|
||||
))
|
||||
) : (
|
||||
<div className='w-full'>{actionsArea}</div>
|
||||
))}
|
||||
|
||||
{/* 当同时存在操作区和搜索区时,插入分隔线 */}
|
||||
{actionsArea && searchArea && <Divider />}
|
||||
|
||||
{/* 搜索表单区域 - 所有类型都可能有 */}
|
||||
{searchArea && <div className='w-full'>{searchArea}</div>}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const headerContent = renderHeader();
|
||||
|
||||
// 渲染分页区域
|
||||
const renderFooter = () => {
|
||||
if (!paginationArea) return null;
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`flex w-full pt-4 border-t ${isMobile ? 'justify-center' : 'justify-between items-center'}`}
|
||||
style={{ borderColor: 'var(--semi-color-border)' }}
|
||||
>
|
||||
{paginationArea}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const footerContent = renderFooter();
|
||||
|
||||
return (
|
||||
<Card
|
||||
className={`table-scroll-card !rounded-2xl ${className}`}
|
||||
title={headerContent}
|
||||
footer={footerContent}
|
||||
shadows={shadows}
|
||||
bordered={bordered}
|
||||
style={style}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
|
||||
CardPro.propTypes = {
|
||||
// 布局类型
|
||||
type: PropTypes.oneOf(['type1', 'type2', 'type3']),
|
||||
// 样式相关
|
||||
className: PropTypes.string,
|
||||
style: PropTypes.object,
|
||||
shadows: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
||||
bordered: PropTypes.bool,
|
||||
// 内容区域
|
||||
statsArea: PropTypes.node,
|
||||
descriptionArea: PropTypes.node,
|
||||
tabsArea: PropTypes.node,
|
||||
actionsArea: PropTypes.oneOfType([
|
||||
PropTypes.node,
|
||||
PropTypes.arrayOf(PropTypes.node),
|
||||
]),
|
||||
searchArea: PropTypes.node,
|
||||
paginationArea: PropTypes.node,
|
||||
// 表格内容
|
||||
children: PropTypes.node,
|
||||
// 国际化函数
|
||||
t: PropTypes.func,
|
||||
};
|
||||
|
||||
export default CardPro;
|
||||
@@ -0,0 +1,331 @@
|
||||
/*
|
||||
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 React, { useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
Table,
|
||||
Card,
|
||||
Checkbox,
|
||||
Skeleton,
|
||||
Pagination,
|
||||
Empty,
|
||||
Button,
|
||||
Collapsible,
|
||||
} from '@douyinfe/semi-ui';
|
||||
import { IconChevronDown, IconChevronUp } from '@douyinfe/semi-icons';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useIsMobile } from '../../../hooks/common/useIsMobile';
|
||||
import { useMinimumLoadingTime } from '../../../hooks/common/useMinimumLoadingTime';
|
||||
|
||||
/**
|
||||
* CardTable 响应式表格组件
|
||||
*
|
||||
* 在桌面端渲染 Semi-UI 的 Table 组件,在移动端则将每一行数据渲染成 Card 形式。
|
||||
* 该组件与 Table 组件的大部分 API 保持一致,只需将原 Table 换成 CardTable 即可。
|
||||
*/
|
||||
const CardTable = ({
|
||||
columns = [],
|
||||
dataSource = [],
|
||||
loading = false,
|
||||
rowKey = 'key',
|
||||
hidePagination = false,
|
||||
...tableProps
|
||||
}) => {
|
||||
const isMobile = useIsMobile();
|
||||
const { t } = useTranslation();
|
||||
|
||||
const showSkeleton = useMinimumLoadingTime(loading);
|
||||
|
||||
const getRowKey = (record, index) => {
|
||||
if (typeof rowKey === 'function') return rowKey(record);
|
||||
return record[rowKey] !== undefined ? record[rowKey] : index;
|
||||
};
|
||||
|
||||
// ===== 移动端多选支持 =====
|
||||
// 移动端卡片分支此前完全没有消费 rowSelection,导致调用方的 selectedKeys 永远是空数组,
|
||||
// 令牌/兑换码/渠道/模型/管理员令牌五个页面的批量操作在手机上全是死按钮
|
||||
// (点了只提示「请至少选择一个」,渠道页甚至会对空集合弹出删除确认)。
|
||||
// 这里补上:兼容 Semi 的受控(传 selectedRowKeys)与非受控(只传 onChange)两种用法。
|
||||
const rowSelection =
|
||||
tableProps.rowSelection && typeof tableProps.rowSelection === 'object'
|
||||
? tableProps.rowSelection
|
||||
: null;
|
||||
const selectionEnabled = Boolean(tableProps.rowSelection);
|
||||
const [internalSelectedKeys, setInternalSelectedKeys] = useState([]);
|
||||
const selectedKeys = rowSelection?.selectedRowKeys ?? internalSelectedKeys;
|
||||
|
||||
const isRowSelectable = (record, index) => {
|
||||
const props = rowSelection?.getCheckboxProps?.(record, index);
|
||||
return !props?.disabled;
|
||||
};
|
||||
|
||||
const emitSelection = (nextKeys) => {
|
||||
if (rowSelection?.selectedRowKeys === undefined) {
|
||||
setInternalSelectedKeys(nextKeys);
|
||||
}
|
||||
const keySet = new Set(nextKeys);
|
||||
const nextRows = dataSource.filter((record, index) =>
|
||||
keySet.has(getRowKey(record, index)),
|
||||
);
|
||||
rowSelection?.onChange?.(nextKeys, nextRows);
|
||||
};
|
||||
|
||||
const toggleRowSelected = (key, checked) => {
|
||||
const nextKeys = checked
|
||||
? [...selectedKeys.filter((k) => k !== key), key]
|
||||
: selectedKeys.filter((k) => k !== key);
|
||||
emitSelection(nextKeys);
|
||||
};
|
||||
|
||||
const selectableKeys = dataSource
|
||||
.map((record, index) =>
|
||||
isRowSelectable(record, index) ? getRowKey(record, index) : null,
|
||||
)
|
||||
.filter((key) => key !== null);
|
||||
const allSelected =
|
||||
selectableKeys.length > 0 &&
|
||||
selectableKeys.every((key) => selectedKeys.includes(key));
|
||||
|
||||
if (!isMobile) {
|
||||
const finalTableProps = hidePagination
|
||||
? { ...tableProps, pagination: false }
|
||||
: tableProps;
|
||||
|
||||
return (
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={dataSource}
|
||||
loading={loading}
|
||||
rowKey={rowKey}
|
||||
{...finalTableProps}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (showSkeleton) {
|
||||
const visibleCols = columns.filter((col) => {
|
||||
if (tableProps?.visibleColumns && col.key) {
|
||||
return tableProps.visibleColumns[col.key];
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
const renderSkeletonCard = (key) => {
|
||||
const placeholder = (
|
||||
<div className='p-2'>
|
||||
{visibleCols.map((col, idx) => {
|
||||
if (!col.title) {
|
||||
return (
|
||||
<div key={idx} className='mt-2 flex justify-end'>
|
||||
<Skeleton.Title active style={{ width: 100, height: 24 }} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
key={idx}
|
||||
className='flex justify-between items-center py-1 border-b last:border-b-0 border-dashed'
|
||||
style={{ borderColor: 'var(--semi-color-border)' }}
|
||||
>
|
||||
<Skeleton.Title active style={{ width: 80, height: 14 }} />
|
||||
<Skeleton.Title
|
||||
active
|
||||
style={{
|
||||
width: `${50 + (idx % 3) * 10}%`,
|
||||
maxWidth: 180,
|
||||
height: 14,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<Card key={key} className='!rounded-2xl shadow-sm'>
|
||||
<Skeleton loading={true} active placeholder={placeholder}></Skeleton>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className='flex flex-col gap-2'>
|
||||
{[1, 2, 3].map((i) => renderSkeletonCard(i))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const isEmpty = !showSkeleton && (!dataSource || dataSource.length === 0);
|
||||
|
||||
const MobileRowCard = ({ record, index }) => {
|
||||
const [showDetails, setShowDetails] = useState(false);
|
||||
const rowKeyVal = getRowKey(record, index);
|
||||
|
||||
const hasDetails =
|
||||
tableProps.expandedRowRender &&
|
||||
(!tableProps.rowExpandable || tableProps.rowExpandable(record));
|
||||
|
||||
// onRow 同样此前被丢弃:调用方用它给禁用/已删除记录着色、绑定行点击,
|
||||
// 移动端一并透传到卡片上,保持与桌面行为一致。
|
||||
const rowProps = tableProps.onRow?.(record, index) || {};
|
||||
const selectable = isRowSelectable(record, index);
|
||||
|
||||
return (
|
||||
<Card
|
||||
key={rowKeyVal}
|
||||
{...rowProps}
|
||||
className={`!rounded-2xl shadow-sm ${rowProps.className || ''}`}
|
||||
>
|
||||
{selectionEnabled && (
|
||||
<div
|
||||
className='flex items-center pb-1 mb-1 border-b border-dashed'
|
||||
style={{ borderColor: 'var(--semi-color-border)' }}
|
||||
>
|
||||
<Checkbox
|
||||
checked={selectedKeys.includes(rowKeyVal)}
|
||||
disabled={!selectable}
|
||||
onChange={(e) => {
|
||||
toggleRowSelected(rowKeyVal, e.target.checked);
|
||||
}}
|
||||
// 阻止冒泡,避免同时触发 onRow 的行点击
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<span className='text-xs text-gray-500'>{t('选择')}</span>
|
||||
</Checkbox>
|
||||
</div>
|
||||
)}
|
||||
{columns.map((col, colIdx) => {
|
||||
if (
|
||||
tableProps?.visibleColumns &&
|
||||
!tableProps.visibleColumns[col.key]
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const title = col.title;
|
||||
const cellContent = col.render
|
||||
? col.render(record[col.dataIndex], record, index)
|
||||
: record[col.dataIndex];
|
||||
|
||||
if (!title) {
|
||||
return (
|
||||
<div key={col.key || colIdx} className='mt-2 flex justify-end'>
|
||||
{cellContent}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
key={col.key || colIdx}
|
||||
className='flex justify-between items-start py-1 border-b last:border-b-0 border-dashed'
|
||||
style={{ borderColor: 'var(--semi-color-border)' }}
|
||||
>
|
||||
<span className='font-medium text-gray-600 mr-2 whitespace-nowrap select-none'>
|
||||
{title}
|
||||
</span>
|
||||
<div className='flex-1 break-all flex justify-end items-center gap-1'>
|
||||
{cellContent !== undefined && cellContent !== null
|
||||
? cellContent
|
||||
: '-'}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
|
||||
{hasDetails && (
|
||||
<>
|
||||
<Button
|
||||
theme='borderless'
|
||||
size='small'
|
||||
className='w-full flex justify-center mt-2'
|
||||
icon={showDetails ? <IconChevronUp /> : <IconChevronDown />}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
setShowDetails(!showDetails);
|
||||
}}
|
||||
>
|
||||
{showDetails ? t('收起') : t('详情')}
|
||||
</Button>
|
||||
<Collapsible isOpen={showDetails} keepDOM>
|
||||
<div className='pt-2'>
|
||||
{tableProps.expandedRowRender(record, index)}
|
||||
</div>
|
||||
</Collapsible>
|
||||
</>
|
||||
)}
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
|
||||
if (isEmpty) {
|
||||
if (tableProps.empty) return tableProps.empty;
|
||||
return (
|
||||
<div className='flex justify-center p-4'>
|
||||
<Empty description='No Data' />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='flex flex-col gap-2'>
|
||||
{selectionEnabled && selectableKeys.length > 0 && (
|
||||
<div className='flex items-center justify-between px-3 py-2 rounded-xl bg-semi-color-fill-0'>
|
||||
<Checkbox
|
||||
checked={allSelected}
|
||||
indeterminate={!allSelected && selectedKeys.length > 0}
|
||||
onChange={(e) => {
|
||||
emitSelection(e.target.checked ? selectableKeys : []);
|
||||
}}
|
||||
>
|
||||
<span className='text-xs'>{t('全选')}</span>
|
||||
</Checkbox>
|
||||
<span className='text-xs text-gray-500'>
|
||||
{t('已选 {{count}} 项', { count: selectedKeys.length })}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
{dataSource.map((record, index) => (
|
||||
<MobileRowCard
|
||||
key={getRowKey(record, index)}
|
||||
record={record}
|
||||
index={index}
|
||||
/>
|
||||
))}
|
||||
{!hidePagination && tableProps.pagination && dataSource.length > 0 && (
|
||||
<div className='mt-2 flex justify-center'>
|
||||
<Pagination {...tableProps.pagination} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
CardTable.propTypes = {
|
||||
columns: PropTypes.array.isRequired,
|
||||
dataSource: PropTypes.array,
|
||||
loading: PropTypes.bool,
|
||||
rowKey: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
||||
hidePagination: PropTypes.bool,
|
||||
};
|
||||
|
||||
export default CardTable;
|
||||
@@ -0,0 +1,280 @@
|
||||
/*
|
||||
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 React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Card, Button, Typography, Tag } from '@douyinfe/semi-ui';
|
||||
import { copy, showSuccess } from '../../../helpers';
|
||||
|
||||
/**
|
||||
* 解析密钥数据,支持多种格式
|
||||
* @param {string} keyData - 密钥数据
|
||||
* @param {Function} t - 翻译函数
|
||||
* @returns {Array} 解析后的密钥数组
|
||||
*/
|
||||
const parseChannelKeys = (keyData, t) => {
|
||||
if (!keyData) return [];
|
||||
|
||||
const trimmed = keyData.trim();
|
||||
|
||||
// 检查是否是JSON数组格式(如Vertex AI)
|
||||
if (trimmed.startsWith('[')) {
|
||||
try {
|
||||
const parsed = JSON.parse(trimmed);
|
||||
if (Array.isArray(parsed)) {
|
||||
return parsed.map((item, index) => ({
|
||||
id: index,
|
||||
content:
|
||||
typeof item === 'string' ? item : JSON.stringify(item, null, 2),
|
||||
type: typeof item === 'string' ? 'text' : 'json',
|
||||
label: `${t('密钥')} ${index + 1}`,
|
||||
}));
|
||||
}
|
||||
} catch (e) {
|
||||
// 如果解析失败,按普通文本处理
|
||||
console.warn('Failed to parse JSON keys:', e);
|
||||
}
|
||||
}
|
||||
|
||||
// 检查是否是多行密钥(按换行符分割)
|
||||
const lines = trimmed.split('\n').filter((line) => line.trim());
|
||||
if (lines.length > 1) {
|
||||
return lines.map((line, index) => ({
|
||||
id: index,
|
||||
content: line.trim(),
|
||||
type: 'text',
|
||||
label: `${t('密钥')} ${index + 1}`,
|
||||
}));
|
||||
}
|
||||
|
||||
// 单个密钥
|
||||
return [
|
||||
{
|
||||
id: 0,
|
||||
content: trimmed,
|
||||
type: trimmed.startsWith('{') ? 'json' : 'text',
|
||||
label: t('密钥'),
|
||||
},
|
||||
];
|
||||
};
|
||||
|
||||
/**
|
||||
* 可复用的密钥显示组件
|
||||
* @param {Object} props
|
||||
* @param {string} props.keyData - 密钥数据
|
||||
* @param {boolean} props.showSuccessIcon - 是否显示成功图标
|
||||
* @param {string} props.successText - 成功文本
|
||||
* @param {boolean} props.showWarning - 是否显示安全警告
|
||||
* @param {string} props.warningText - 警告文本
|
||||
*/
|
||||
const ChannelKeyDisplay = ({
|
||||
keyData,
|
||||
showSuccessIcon = true,
|
||||
successText,
|
||||
showWarning = true,
|
||||
warningText,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const parsedKeys = parseChannelKeys(keyData, t);
|
||||
const isMultipleKeys = parsedKeys.length > 1;
|
||||
|
||||
const handleCopyAll = () => {
|
||||
copy(keyData);
|
||||
showSuccess(t('所有密钥已复制到剪贴板'));
|
||||
};
|
||||
|
||||
const handleCopyKey = (content) => {
|
||||
copy(content);
|
||||
showSuccess(t('密钥已复制到剪贴板'));
|
||||
};
|
||||
|
||||
return (
|
||||
<div className='space-y-4'>
|
||||
{/* 成功状态 */}
|
||||
{showSuccessIcon && (
|
||||
<div className='flex items-center gap-2'>
|
||||
<svg
|
||||
className='w-5 h-5 text-green-600'
|
||||
fill='currentColor'
|
||||
viewBox='0 0 20 20'
|
||||
>
|
||||
<path
|
||||
fillRule='evenodd'
|
||||
d='M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z'
|
||||
clipRule='evenodd'
|
||||
/>
|
||||
</svg>
|
||||
<Typography.Text strong className='text-green-700'>
|
||||
{successText || t('验证成功')}
|
||||
</Typography.Text>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 密钥内容 */}
|
||||
<div className='space-y-3'>
|
||||
<div className='flex items-center justify-between'>
|
||||
<Typography.Text strong>
|
||||
{isMultipleKeys ? t('渠道密钥列表') : t('渠道密钥')}
|
||||
</Typography.Text>
|
||||
{isMultipleKeys && (
|
||||
<div className='flex items-center gap-2'>
|
||||
<Typography.Text type='tertiary' size='small'>
|
||||
{t('共 {{count}} 个密钥', { count: parsedKeys.length })}
|
||||
</Typography.Text>
|
||||
<Button
|
||||
size='small'
|
||||
type='primary'
|
||||
theme='outline'
|
||||
onClick={handleCopyAll}
|
||||
>
|
||||
{t('复制全部')}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className='space-y-3 max-h-80 overflow-auto'>
|
||||
{parsedKeys.map((keyItem) => (
|
||||
<Card
|
||||
key={keyItem.id}
|
||||
className='!rounded-lg !border !border-gray-200 dark:!border-gray-700'
|
||||
>
|
||||
<div className='space-y-2'>
|
||||
<div className='flex items-center justify-between'>
|
||||
<Typography.Text
|
||||
strong
|
||||
size='small'
|
||||
className='text-gray-700 dark:text-gray-300'
|
||||
>
|
||||
{keyItem.label}
|
||||
</Typography.Text>
|
||||
<div className='flex items-center gap-2'>
|
||||
{keyItem.type === 'json' && (
|
||||
<Tag size='small' color='blue'>
|
||||
{t('JSON')}
|
||||
</Tag>
|
||||
)}
|
||||
<Button
|
||||
size='small'
|
||||
type='primary'
|
||||
theme='outline'
|
||||
icon={
|
||||
<svg
|
||||
className='w-3 h-3'
|
||||
fill='currentColor'
|
||||
viewBox='0 0 20 20'
|
||||
>
|
||||
<path d='M8 3a1 1 0 011-1h2a1 1 0 110 2H9a1 1 0 01-1-1z' />
|
||||
<path d='M6 3a2 2 0 00-2 2v11a2 2 0 002 2h8a2 2 0 002-2V5a2 2 0 00-2-2 3 3 0 01-3 3H9a3 3 0 01-3-3z' />
|
||||
</svg>
|
||||
}
|
||||
onClick={() => handleCopyKey(keyItem.content)}
|
||||
>
|
||||
{t('复制')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className='bg-gray-50 dark:bg-gray-800 rounded-lg p-3 max-h-40 overflow-auto'>
|
||||
<Typography.Text
|
||||
code
|
||||
className='text-xs font-mono break-all whitespace-pre-wrap text-gray-800 dark:text-gray-200'
|
||||
>
|
||||
{keyItem.content}
|
||||
</Typography.Text>
|
||||
</div>
|
||||
|
||||
{keyItem.type === 'json' && (
|
||||
<Typography.Text
|
||||
type='tertiary'
|
||||
size='small'
|
||||
className='block'
|
||||
>
|
||||
{t('JSON格式密钥,请确保格式正确')}
|
||||
</Typography.Text>
|
||||
)}
|
||||
</div>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{isMultipleKeys && (
|
||||
<div className='bg-blue-50 dark:bg-blue-900 rounded-lg p-3'>
|
||||
<Typography.Text
|
||||
type='tertiary'
|
||||
size='small'
|
||||
className='text-blue-700 dark:text-blue-300'
|
||||
>
|
||||
<svg
|
||||
className='w-4 h-4 inline mr-1'
|
||||
fill='currentColor'
|
||||
viewBox='0 0 20 20'
|
||||
>
|
||||
<path
|
||||
fillRule='evenodd'
|
||||
d='M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z'
|
||||
clipRule='evenodd'
|
||||
/>
|
||||
</svg>
|
||||
{t(
|
||||
'检测到多个密钥,您可以单独复制每个密钥,或点击复制全部获取完整内容。',
|
||||
)}
|
||||
</Typography.Text>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 安全警告 */}
|
||||
{showWarning && (
|
||||
<div className='bg-yellow-50 dark:bg-yellow-900 rounded-lg p-4'>
|
||||
<div className='flex items-start'>
|
||||
<svg
|
||||
className='w-5 h-5 text-yellow-600 dark:text-yellow-400 mt-0.5 mr-3 flex-shrink-0'
|
||||
fill='currentColor'
|
||||
viewBox='0 0 20 20'
|
||||
>
|
||||
<path
|
||||
fillRule='evenodd'
|
||||
d='M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z'
|
||||
clipRule='evenodd'
|
||||
/>
|
||||
</svg>
|
||||
<div>
|
||||
<Typography.Text
|
||||
strong
|
||||
className='text-yellow-800 dark:text-yellow-200'
|
||||
>
|
||||
{t('安全提醒')}
|
||||
</Typography.Text>
|
||||
<Typography.Text className='block text-yellow-700 dark:text-yellow-300 text-sm mt-1'>
|
||||
{warningText ||
|
||||
t(
|
||||
'请妥善保管密钥信息,不要泄露给他人。如有安全疑虑,请及时更换密钥。',
|
||||
)}
|
||||
</Typography.Text>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ChannelKeyDisplay;
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
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 React from 'react';
|
||||
import { Button } from '@douyinfe/semi-ui';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useIsMobile } from '../../../hooks/common/useIsMobile';
|
||||
|
||||
/**
|
||||
* 紧凑模式切换按钮组件
|
||||
* 用于在自适应列表和紧凑列表之间切换
|
||||
* 在移动端时自动隐藏,因为移动端使用"显示操作项"按钮来控制内容显示
|
||||
*/
|
||||
const CompactModeToggle = ({
|
||||
compactMode,
|
||||
setCompactMode,
|
||||
t,
|
||||
size = 'small',
|
||||
type = 'tertiary',
|
||||
className = '',
|
||||
...props
|
||||
}) => {
|
||||
const isMobile = useIsMobile();
|
||||
|
||||
// 在移动端隐藏紧凑列表切换按钮
|
||||
if (isMobile) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Button
|
||||
type={type}
|
||||
size={size}
|
||||
className={`w-full md:w-auto ${className}`}
|
||||
onClick={() => setCompactMode(!compactMode)}
|
||||
{...props}
|
||||
>
|
||||
{compactMode ? t('自适应列表') : t('紧凑列表')}
|
||||
</Button>
|
||||
);
|
||||
};
|
||||
|
||||
CompactModeToggle.propTypes = {
|
||||
compactMode: PropTypes.bool.isRequired,
|
||||
setCompactMode: PropTypes.func.isRequired,
|
||||
t: PropTypes.func.isRequired,
|
||||
size: PropTypes.string,
|
||||
type: PropTypes.string,
|
||||
className: PropTypes.string,
|
||||
};
|
||||
|
||||
export default CompactModeToggle;
|
||||
@@ -0,0 +1,716 @@
|
||||
/*
|
||||
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 React, { useState, useEffect, useCallback, useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
Button,
|
||||
Form,
|
||||
Typography,
|
||||
Banner,
|
||||
Tabs,
|
||||
TabPane,
|
||||
Card,
|
||||
Input,
|
||||
InputNumber,
|
||||
Switch,
|
||||
TextArea,
|
||||
Row,
|
||||
Col,
|
||||
Divider,
|
||||
Tooltip,
|
||||
} from '@douyinfe/semi-ui';
|
||||
import { IconPlus, IconDelete, IconAlertTriangle } from '@douyinfe/semi-icons';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
// 唯一 ID 生成器,确保在组件生命周期内稳定且递增
|
||||
const generateUniqueId = (() => {
|
||||
let counter = 0;
|
||||
return () => `kv_${counter++}`;
|
||||
})();
|
||||
|
||||
const JSONEditor = ({
|
||||
value = '',
|
||||
onChange,
|
||||
field,
|
||||
label,
|
||||
placeholder,
|
||||
extraText,
|
||||
extraFooter,
|
||||
showClear = true,
|
||||
template,
|
||||
templateLabel,
|
||||
editorType = 'keyValue',
|
||||
rules = [],
|
||||
formApi = null,
|
||||
...props
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
// 将对象转换为键值对数组(包含唯一ID)
|
||||
const objectToKeyValueArray = useCallback((obj, prevPairs = []) => {
|
||||
if (!obj || typeof obj !== 'object') return [];
|
||||
|
||||
const entries = Object.entries(obj);
|
||||
return entries.map(([key, value], index) => {
|
||||
// 如果上一次转换后同位置的键一致,则沿用其 id,保持 React key 稳定
|
||||
const prev = prevPairs[index];
|
||||
const shouldReuseId = prev && prev.key === key;
|
||||
return {
|
||||
id: shouldReuseId ? prev.id : generateUniqueId(),
|
||||
key,
|
||||
value,
|
||||
};
|
||||
});
|
||||
}, []);
|
||||
|
||||
// 将键值对数组转换为对象(重复键时后面的会覆盖前面的)
|
||||
const keyValueArrayToObject = useCallback((arr) => {
|
||||
const result = {};
|
||||
arr.forEach((item) => {
|
||||
if (item.key) {
|
||||
result[item.key] = item.value;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}, []);
|
||||
|
||||
// 初始化键值对数组
|
||||
const [keyValuePairs, setKeyValuePairs] = useState(() => {
|
||||
if (typeof value === 'string' && value.trim()) {
|
||||
try {
|
||||
const parsed = JSON.parse(value);
|
||||
return objectToKeyValueArray(parsed);
|
||||
} catch (error) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
if (typeof value === 'object' && value !== null) {
|
||||
return objectToKeyValueArray(value);
|
||||
}
|
||||
return [];
|
||||
});
|
||||
|
||||
// 手动模式下的本地文本缓冲
|
||||
const [manualText, setManualText] = useState(() => {
|
||||
if (typeof value === 'string') return value;
|
||||
if (value && typeof value === 'object')
|
||||
return JSON.stringify(value, null, 2);
|
||||
return '';
|
||||
});
|
||||
|
||||
// 根据键数量决定默认编辑模式
|
||||
const [editMode, setEditMode] = useState(() => {
|
||||
if (typeof value === 'string' && value.trim()) {
|
||||
try {
|
||||
const parsed = JSON.parse(value);
|
||||
const keyCount = Object.keys(parsed).length;
|
||||
return keyCount > 10 ? 'manual' : 'visual';
|
||||
} catch (error) {
|
||||
return 'manual';
|
||||
}
|
||||
}
|
||||
return 'visual';
|
||||
});
|
||||
|
||||
const [jsonError, setJsonError] = useState('');
|
||||
|
||||
// 计算重复的键
|
||||
const duplicateKeys = useMemo(() => {
|
||||
const keyCount = {};
|
||||
const duplicates = new Set();
|
||||
|
||||
keyValuePairs.forEach((pair) => {
|
||||
if (pair.key) {
|
||||
keyCount[pair.key] = (keyCount[pair.key] || 0) + 1;
|
||||
if (keyCount[pair.key] > 1) {
|
||||
duplicates.add(pair.key);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return duplicates;
|
||||
}, [keyValuePairs]);
|
||||
|
||||
// 数据同步 - 当value变化时更新键值对数组
|
||||
useEffect(() => {
|
||||
try {
|
||||
let parsed = {};
|
||||
if (typeof value === 'string' && value.trim()) {
|
||||
parsed = JSON.parse(value);
|
||||
} else if (typeof value === 'object' && value !== null) {
|
||||
parsed = value;
|
||||
}
|
||||
|
||||
// 只在外部值真正改变时更新,避免循环更新
|
||||
const currentObj = keyValueArrayToObject(keyValuePairs);
|
||||
if (JSON.stringify(parsed) !== JSON.stringify(currentObj)) {
|
||||
setKeyValuePairs(objectToKeyValueArray(parsed, keyValuePairs));
|
||||
}
|
||||
setJsonError('');
|
||||
} catch (error) {
|
||||
console.log('JSON解析失败:', error.message);
|
||||
setJsonError(error.message);
|
||||
}
|
||||
}, [value]);
|
||||
|
||||
// 外部 value 变化时,若不在手动模式,则同步手动文本
|
||||
useEffect(() => {
|
||||
if (editMode !== 'manual') {
|
||||
if (typeof value === 'string') setManualText(value);
|
||||
else if (value && typeof value === 'object')
|
||||
setManualText(JSON.stringify(value, null, 2));
|
||||
else setManualText('');
|
||||
}
|
||||
}, [value, editMode]);
|
||||
|
||||
// 处理可视化编辑的数据变化
|
||||
const handleVisualChange = useCallback(
|
||||
(newPairs) => {
|
||||
setKeyValuePairs(newPairs);
|
||||
const jsonObject = keyValueArrayToObject(newPairs);
|
||||
const jsonString =
|
||||
Object.keys(jsonObject).length === 0
|
||||
? ''
|
||||
: JSON.stringify(jsonObject, null, 2);
|
||||
|
||||
setJsonError('');
|
||||
|
||||
// 通过formApi设置值
|
||||
if (formApi && field) {
|
||||
formApi.setValue(field, jsonString);
|
||||
}
|
||||
|
||||
onChange?.(jsonString);
|
||||
},
|
||||
[onChange, formApi, field, keyValueArrayToObject],
|
||||
);
|
||||
|
||||
// 处理手动编辑的数据变化
|
||||
const handleManualChange = useCallback(
|
||||
(newValue) => {
|
||||
setManualText(newValue);
|
||||
if (newValue && newValue.trim()) {
|
||||
try {
|
||||
const parsed = JSON.parse(newValue);
|
||||
setKeyValuePairs(objectToKeyValueArray(parsed, keyValuePairs));
|
||||
setJsonError('');
|
||||
onChange?.(newValue);
|
||||
} catch (error) {
|
||||
setJsonError(error.message);
|
||||
}
|
||||
} else {
|
||||
setKeyValuePairs([]);
|
||||
setJsonError('');
|
||||
onChange?.('');
|
||||
}
|
||||
},
|
||||
[onChange, objectToKeyValueArray, keyValuePairs],
|
||||
);
|
||||
|
||||
// 切换编辑模式
|
||||
const toggleEditMode = useCallback(() => {
|
||||
if (editMode === 'visual') {
|
||||
const jsonObject = keyValueArrayToObject(keyValuePairs);
|
||||
setManualText(
|
||||
Object.keys(jsonObject).length === 0
|
||||
? ''
|
||||
: JSON.stringify(jsonObject, null, 2),
|
||||
);
|
||||
setEditMode('manual');
|
||||
} else {
|
||||
try {
|
||||
let parsed = {};
|
||||
if (manualText && manualText.trim()) {
|
||||
parsed = JSON.parse(manualText);
|
||||
} else if (typeof value === 'string' && value.trim()) {
|
||||
parsed = JSON.parse(value);
|
||||
} else if (typeof value === 'object' && value !== null) {
|
||||
parsed = value;
|
||||
}
|
||||
setKeyValuePairs(objectToKeyValueArray(parsed, keyValuePairs));
|
||||
setJsonError('');
|
||||
setEditMode('visual');
|
||||
} catch (error) {
|
||||
setJsonError(error.message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}, [
|
||||
editMode,
|
||||
value,
|
||||
manualText,
|
||||
keyValuePairs,
|
||||
keyValueArrayToObject,
|
||||
objectToKeyValueArray,
|
||||
]);
|
||||
|
||||
// 添加键值对
|
||||
const addKeyValue = useCallback(() => {
|
||||
const newPairs = [...keyValuePairs];
|
||||
const existingKeys = newPairs.map((p) => p.key);
|
||||
let counter = 1;
|
||||
let newKey = `field_${counter}`;
|
||||
while (existingKeys.includes(newKey)) {
|
||||
counter += 1;
|
||||
newKey = `field_${counter}`;
|
||||
}
|
||||
newPairs.push({
|
||||
id: generateUniqueId(),
|
||||
key: newKey,
|
||||
value: '',
|
||||
});
|
||||
handleVisualChange(newPairs);
|
||||
}, [keyValuePairs, handleVisualChange]);
|
||||
|
||||
// 删除键值对
|
||||
const removeKeyValue = useCallback(
|
||||
(id) => {
|
||||
const newPairs = keyValuePairs.filter((pair) => pair.id !== id);
|
||||
handleVisualChange(newPairs);
|
||||
},
|
||||
[keyValuePairs, handleVisualChange],
|
||||
);
|
||||
|
||||
// 更新键名
|
||||
const updateKey = useCallback(
|
||||
(id, newKey) => {
|
||||
const newPairs = keyValuePairs.map((pair) =>
|
||||
pair.id === id ? { ...pair, key: newKey } : pair,
|
||||
);
|
||||
handleVisualChange(newPairs);
|
||||
},
|
||||
[keyValuePairs, handleVisualChange],
|
||||
);
|
||||
|
||||
// 更新值
|
||||
const updateValue = useCallback(
|
||||
(id, newValue) => {
|
||||
const newPairs = keyValuePairs.map((pair) =>
|
||||
pair.id === id ? { ...pair, value: newValue } : pair,
|
||||
);
|
||||
handleVisualChange(newPairs);
|
||||
},
|
||||
[keyValuePairs, handleVisualChange],
|
||||
);
|
||||
|
||||
// 填入模板
|
||||
const fillTemplate = useCallback(() => {
|
||||
if (template) {
|
||||
const templateString = JSON.stringify(template, null, 2);
|
||||
|
||||
if (formApi && field) {
|
||||
formApi.setValue(field, templateString);
|
||||
}
|
||||
|
||||
setManualText(templateString);
|
||||
setKeyValuePairs(objectToKeyValueArray(template, keyValuePairs));
|
||||
onChange?.(templateString);
|
||||
setJsonError('');
|
||||
}
|
||||
}, [
|
||||
template,
|
||||
onChange,
|
||||
formApi,
|
||||
field,
|
||||
objectToKeyValueArray,
|
||||
keyValuePairs,
|
||||
]);
|
||||
|
||||
// 渲染值输入控件(支持嵌套)
|
||||
const renderValueInput = (pairId, value) => {
|
||||
const valueType = typeof value;
|
||||
|
||||
if (valueType === 'boolean') {
|
||||
return (
|
||||
<div className='flex items-center'>
|
||||
<Switch
|
||||
checked={value}
|
||||
onChange={(newValue) => updateValue(pairId, newValue)}
|
||||
/>
|
||||
<Text type='tertiary' className='ml-2'>
|
||||
{value ? t('true') : t('false')}
|
||||
</Text>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (valueType === 'number') {
|
||||
return (
|
||||
<InputNumber
|
||||
value={value}
|
||||
onChange={(newValue) => updateValue(pairId, newValue)}
|
||||
style={{ width: '100%' }}
|
||||
placeholder={t('输入数字')}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (valueType === 'object' && value !== null) {
|
||||
// 简化嵌套对象的处理,使用TextArea
|
||||
return (
|
||||
<TextArea
|
||||
rows={2}
|
||||
value={JSON.stringify(value, null, 2)}
|
||||
onChange={(txt) => {
|
||||
try {
|
||||
const obj = txt.trim() ? JSON.parse(txt) : {};
|
||||
updateValue(pairId, obj);
|
||||
} catch {
|
||||
// 忽略解析错误
|
||||
}
|
||||
}}
|
||||
placeholder={t('输入JSON对象')}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
// 字符串或其他原始类型
|
||||
return (
|
||||
<Input
|
||||
placeholder={t('参数值')}
|
||||
value={String(value)}
|
||||
onChange={(newValue) => {
|
||||
let convertedValue = newValue;
|
||||
if (newValue === 'true') convertedValue = true;
|
||||
else if (newValue === 'false') convertedValue = false;
|
||||
else if (!isNaN(newValue) && newValue !== '') {
|
||||
const num = Number(newValue);
|
||||
// 检查是否为整数
|
||||
if (Number.isInteger(num)) {
|
||||
convertedValue = num;
|
||||
}
|
||||
}
|
||||
updateValue(pairId, convertedValue);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
// 渲染键值对编辑器
|
||||
const renderKeyValueEditor = () => {
|
||||
return (
|
||||
<div className='space-y-1'>
|
||||
{/* 重复键警告 */}
|
||||
{duplicateKeys.size > 0 && (
|
||||
<Banner
|
||||
type='warning'
|
||||
icon={<IconAlertTriangle />}
|
||||
description={
|
||||
<div>
|
||||
<Text strong>{t('存在重复的键名:')}</Text>
|
||||
<Text>{Array.from(duplicateKeys).join(', ')}</Text>
|
||||
<br />
|
||||
<Text type='tertiary' size='small'>
|
||||
{t('注意:JSON中重复的键只会保留最后一个同名键的值')}
|
||||
</Text>
|
||||
</div>
|
||||
}
|
||||
className='mb-3'
|
||||
/>
|
||||
)}
|
||||
|
||||
{keyValuePairs.length === 0 && (
|
||||
<div className='text-center py-6 px-4'>
|
||||
<Text type='tertiary' className='text-gray-500 text-sm'>
|
||||
{t('暂无数据,点击下方按钮添加键值对')}
|
||||
</Text>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{keyValuePairs.map((pair, index) => {
|
||||
const isDuplicate = duplicateKeys.has(pair.key);
|
||||
const isLastDuplicate =
|
||||
isDuplicate &&
|
||||
keyValuePairs.slice(index + 1).every((p) => p.key !== pair.key);
|
||||
|
||||
return (
|
||||
<Row key={pair.id} gutter={8} align='middle'>
|
||||
<Col span={10}>
|
||||
<div className='relative'>
|
||||
<Input
|
||||
placeholder={t('键名')}
|
||||
value={pair.key}
|
||||
onChange={(newKey) => updateKey(pair.id, newKey)}
|
||||
status={isDuplicate ? 'warning' : undefined}
|
||||
/>
|
||||
{isDuplicate && (
|
||||
<Tooltip
|
||||
content={
|
||||
isLastDuplicate
|
||||
? t('这是重复键中的最后一个,其值将被使用')
|
||||
: t('重复的键名,此值将被后面的同名键覆盖')
|
||||
}
|
||||
>
|
||||
<IconAlertTriangle
|
||||
className='absolute right-2 top-1/2 transform -translate-y-1/2'
|
||||
style={{
|
||||
color: isLastDuplicate
|
||||
? 'var(--semi-color-danger)'
|
||||
: 'var(--semi-color-warning)',
|
||||
fontSize: '14px',
|
||||
}}
|
||||
/>
|
||||
</Tooltip>
|
||||
)}
|
||||
</div>
|
||||
</Col>
|
||||
<Col span={12}>{renderValueInput(pair.id, pair.value)}</Col>
|
||||
<Col span={2}>
|
||||
<Button
|
||||
icon={<IconDelete />}
|
||||
type='danger'
|
||||
theme='borderless'
|
||||
onClick={() => removeKeyValue(pair.id)}
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
);
|
||||
})}
|
||||
|
||||
<div className='mt-2 flex justify-center'>
|
||||
<Button
|
||||
icon={<IconPlus />}
|
||||
type='primary'
|
||||
theme='outline'
|
||||
onClick={addKeyValue}
|
||||
>
|
||||
{t('添加键值对')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
// 渲染区域编辑器(特殊格式)- 也需要改造以支持重复键
|
||||
const renderRegionEditor = () => {
|
||||
const defaultPair = keyValuePairs.find((pair) => pair.key === 'default');
|
||||
const modelPairs = keyValuePairs.filter((pair) => pair.key !== 'default');
|
||||
|
||||
return (
|
||||
<div className='space-y-2'>
|
||||
{/* 重复键警告 */}
|
||||
{duplicateKeys.size > 0 && (
|
||||
<Banner
|
||||
type='warning'
|
||||
icon={<IconAlertTriangle />}
|
||||
description={
|
||||
<div>
|
||||
<Text strong>{t('存在重复的键名:')}</Text>
|
||||
<Text>{Array.from(duplicateKeys).join(', ')}</Text>
|
||||
<br />
|
||||
<Text type='tertiary' size='small'>
|
||||
{t('注意:JSON中重复的键只会保留最后一个同名键的值')}
|
||||
</Text>
|
||||
</div>
|
||||
}
|
||||
className='mb-3'
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* 默认区域 */}
|
||||
<Form.Slot label={t('默认区域')}>
|
||||
<Input
|
||||
placeholder={t('默认区域,如: us-central1')}
|
||||
value={defaultPair ? defaultPair.value : ''}
|
||||
onChange={(value) => {
|
||||
if (defaultPair) {
|
||||
updateValue(defaultPair.id, value);
|
||||
} else {
|
||||
const newPairs = [
|
||||
...keyValuePairs,
|
||||
{
|
||||
id: generateUniqueId(),
|
||||
key: 'default',
|
||||
value: value,
|
||||
},
|
||||
];
|
||||
handleVisualChange(newPairs);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</Form.Slot>
|
||||
|
||||
{/* 模型专用区域 */}
|
||||
<Form.Slot label={t('模型专用区域')}>
|
||||
<div>
|
||||
{modelPairs.map((pair) => {
|
||||
const isDuplicate = duplicateKeys.has(pair.key);
|
||||
return (
|
||||
<Row key={pair.id} gutter={8} align='middle' className='mb-2'>
|
||||
<Col span={10}>
|
||||
<div className='relative'>
|
||||
<Input
|
||||
placeholder={t('模型名称')}
|
||||
value={pair.key}
|
||||
onChange={(newKey) => updateKey(pair.id, newKey)}
|
||||
status={isDuplicate ? 'warning' : undefined}
|
||||
/>
|
||||
{isDuplicate && (
|
||||
<Tooltip content={t('重复的键名')}>
|
||||
<IconAlertTriangle
|
||||
className='absolute right-2 top-1/2 transform -translate-y-1/2'
|
||||
style={{ color: 'var(--semi-color-warning)', fontSize: '14px' }}
|
||||
/>
|
||||
</Tooltip>
|
||||
)}
|
||||
</div>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Input
|
||||
placeholder={t('区域')}
|
||||
value={pair.value}
|
||||
onChange={(newValue) => updateValue(pair.id, newValue)}
|
||||
/>
|
||||
</Col>
|
||||
<Col span={2}>
|
||||
<Button
|
||||
icon={<IconDelete />}
|
||||
type='danger'
|
||||
theme='borderless'
|
||||
onClick={() => removeKeyValue(pair.id)}
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
);
|
||||
})}
|
||||
|
||||
<div className='mt-2 flex justify-center'>
|
||||
<Button
|
||||
icon={<IconPlus />}
|
||||
onClick={addKeyValue}
|
||||
type='primary'
|
||||
theme='outline'
|
||||
>
|
||||
{t('添加模型区域')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Form.Slot>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
// 渲染可视化编辑器
|
||||
const renderVisualEditor = () => {
|
||||
switch (editorType) {
|
||||
case 'region':
|
||||
return renderRegionEditor();
|
||||
case 'object':
|
||||
case 'keyValue':
|
||||
default:
|
||||
return renderKeyValueEditor();
|
||||
}
|
||||
};
|
||||
|
||||
const hasJsonError = jsonError && jsonError.trim() !== '';
|
||||
|
||||
return (
|
||||
<Form.Slot label={label}>
|
||||
<Card
|
||||
header={
|
||||
<div className='flex justify-between items-center'>
|
||||
<Tabs
|
||||
type='slash'
|
||||
activeKey={editMode}
|
||||
onChange={(key) => {
|
||||
if (key === 'manual' && editMode === 'visual') {
|
||||
setEditMode('manual');
|
||||
} else if (key === 'visual' && editMode === 'manual') {
|
||||
toggleEditMode();
|
||||
}
|
||||
}}
|
||||
>
|
||||
<TabPane tab={t('可视化')} itemKey='visual' />
|
||||
<TabPane tab={t('手动编辑')} itemKey='manual' />
|
||||
</Tabs>
|
||||
|
||||
{template && templateLabel && (
|
||||
<Button type='tertiary' onClick={fillTemplate} size='small'>
|
||||
{templateLabel}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
}
|
||||
headerStyle={{ padding: '12px 16px' }}
|
||||
bodyStyle={{ padding: '16px' }}
|
||||
className='!rounded-2xl'
|
||||
>
|
||||
{/* JSON错误提示 */}
|
||||
{hasJsonError && (
|
||||
<Banner
|
||||
type='danger'
|
||||
description={`JSON 格式错误: ${jsonError}`}
|
||||
className='mb-3'
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* 编辑器内容 */}
|
||||
{editMode === 'visual' ? (
|
||||
<div>
|
||||
{renderVisualEditor()}
|
||||
{/* 隐藏的Form字段用于验证和数据绑定 */}
|
||||
<Form.Input
|
||||
field={field}
|
||||
value={value}
|
||||
rules={rules}
|
||||
style={{ display: 'none' }}
|
||||
noLabel={true}
|
||||
{...props}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div>
|
||||
<TextArea
|
||||
placeholder={placeholder}
|
||||
value={manualText}
|
||||
onChange={handleManualChange}
|
||||
showClear={showClear}
|
||||
rows={Math.max(8, manualText ? manualText.split('\n').length : 8)}
|
||||
/>
|
||||
{/* 隐藏的Form字段用于验证和数据绑定 */}
|
||||
<Form.Input
|
||||
field={field}
|
||||
value={value}
|
||||
rules={rules}
|
||||
style={{ display: 'none' }}
|
||||
noLabel={true}
|
||||
{...props}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 额外文本显示在卡片底部 */}
|
||||
{extraText && (
|
||||
<Divider margin='12px' align='center'>
|
||||
<Text type='tertiary' size='small'>
|
||||
{extraText}
|
||||
</Text>
|
||||
</Divider>
|
||||
)}
|
||||
{extraFooter && <div className='mt-1'>{extraFooter}</div>}
|
||||
</Card>
|
||||
</Form.Slot>
|
||||
);
|
||||
};
|
||||
|
||||
export default JSONEditor;
|
||||
@@ -0,0 +1,221 @@
|
||||
/*
|
||||
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 React, { useEffect, useMemo, useState } from 'react';
|
||||
|
||||
// 读品牌值:localStorage → window.__WL_BRAND__(index.html 内联脚本写入)→ 空。
|
||||
// 不用 getSystemName/getLogo —— 它们的终极兜底是 'Weelinking' / '/logo.svg'(老品牌),
|
||||
// 这里要严格白牌,宁可让旋转环单独转,也不能露出老标识。
|
||||
// 接 window 一层是为了和首屏 splash 对齐:冷启动 + 用户立刻进了懒路由的窗口期,
|
||||
// localStorage 还没被 /api/status 灌满,但 window 已有后端启动注入的品牌。
|
||||
const readBrand = (key, windowKey) => {
|
||||
try {
|
||||
const v = localStorage.getItem(key);
|
||||
if (v && v !== 'undefined' && v !== 'null') return v;
|
||||
} catch {
|
||||
/* 隐私模式:fall through */
|
||||
}
|
||||
if (typeof window !== 'undefined' && window.__WL_BRAND__) {
|
||||
return window.__WL_BRAND__[windowKey] || '';
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
// 加载文案根据浏览器语言决定,避免 i18n 还没初始化时硬编码中文。
|
||||
const getLoadingText = () => {
|
||||
const lang = ((typeof navigator !== 'undefined' && navigator.language) || 'zh').toLowerCase();
|
||||
return lang.startsWith('zh') ? '加载中...' : 'Loading...';
|
||||
};
|
||||
|
||||
const Loading = () => {
|
||||
const systemName = readBrand('system_name', 'name');
|
||||
const logo = readBrand('logo', 'logo');
|
||||
const [logoFailed, setLogoFailed] = useState(false);
|
||||
// 防御性:同实例内 logo URL 变化(罕见,但 /api/status 在同一 Loading 生命周期内回来时可能发生),
|
||||
// 重置失败标志,避免新 URL 也被错判成"已坏"
|
||||
useEffect(() => {
|
||||
setLogoFailed(false);
|
||||
}, [logo]);
|
||||
|
||||
const loadingText = useMemo(getLoadingText, []);
|
||||
const monogram = useMemo(() => {
|
||||
const s = systemName.trim();
|
||||
return s ? Array.from(s)[0].toUpperCase() : '';
|
||||
}, [systemName]);
|
||||
|
||||
const showImg = logo && !logoFailed;
|
||||
// 没 logo 也没名字:旋转环里留空,避免出现"空着的渐变色方块"
|
||||
const showMono = !showImg && monogram;
|
||||
|
||||
return (
|
||||
<div className='wl-page-loading'>
|
||||
<div className='wl-page-box'>
|
||||
<div className='wl-page-logo-ring'>
|
||||
<span className='wl-page-logo-slot'>
|
||||
{showImg && (
|
||||
<img
|
||||
className='wl-page-logo'
|
||||
src={logo}
|
||||
alt={systemName || 'logo'}
|
||||
onError={() => setLogoFailed(true)}
|
||||
/>
|
||||
)}
|
||||
{showMono && <span className='wl-page-mono'>{monogram}</span>}
|
||||
</span>
|
||||
</div>
|
||||
{systemName && <div className='wl-page-brand'>{systemName}</div>}
|
||||
<div className='wl-page-text'>{loadingText}</div>
|
||||
</div>
|
||||
|
||||
<style>{`
|
||||
.wl-page-loading {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
width: 100%;
|
||||
background: #fafbfc;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||||
user-select: none;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
.wl-page-loading::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
width: 420px;
|
||||
height: 420px;
|
||||
border-radius: 50%;
|
||||
background: radial-gradient(
|
||||
circle,
|
||||
var(--brand-primary-soft, rgba(99, 102, 241, 0.12)),
|
||||
transparent 70%
|
||||
);
|
||||
filter: blur(24px);
|
||||
pointer-events: none;
|
||||
}
|
||||
.wl-page-box {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
animation: wl-page-fade 0.5s ease-out both;
|
||||
}
|
||||
@keyframes wl-page-fade {
|
||||
from { opacity: 0; transform: translateY(12px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
.wl-page-logo-ring {
|
||||
position: relative;
|
||||
width: 84px;
|
||||
height: 84px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-bottom: 22px;
|
||||
}
|
||||
.wl-page-logo-ring::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
border-radius: 50%;
|
||||
border: 3px solid var(--brand-primary-soft, rgba(22, 104, 220, 0.16));
|
||||
border-top-color: var(--brand-primary, #1668dc);
|
||||
animation: wl-page-spin 0.9s linear infinite;
|
||||
}
|
||||
@keyframes wl-page-spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
.wl-page-logo-slot {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
}
|
||||
.wl-page-logo {
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
border-radius: 14px;
|
||||
object-fit: cover;
|
||||
display: block;
|
||||
}
|
||||
.wl-page-mono {
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
border-radius: 14px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 26px;
|
||||
font-weight: 700;
|
||||
color: #fff;
|
||||
background: linear-gradient(
|
||||
135deg,
|
||||
var(--brand-gradient-from, #4096ff),
|
||||
var(--brand-gradient-to, #0958d9)
|
||||
);
|
||||
}
|
||||
.wl-page-brand {
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 1px;
|
||||
color: var(--brand-primary, #1668dc);
|
||||
margin-bottom: 14px;
|
||||
min-height: 24px;
|
||||
}
|
||||
.wl-page-text {
|
||||
font-size: 13px;
|
||||
color: #94a3b8;
|
||||
letter-spacing: 0.5px;
|
||||
animation: wl-page-blink 1.6s ease-in-out infinite;
|
||||
}
|
||||
@keyframes wl-page-blink {
|
||||
0%, 100% { opacity: 0.45; }
|
||||
50% { opacity: 1; }
|
||||
}
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.wl-page-loading { background: #0f1115; }
|
||||
.wl-page-text { color: #64748b; }
|
||||
}
|
||||
html.dark .wl-page-loading,
|
||||
body[theme-mode='dark'] .wl-page-loading { background: #0f1115; }
|
||||
html.dark .wl-page-text,
|
||||
body[theme-mode='dark'] .wl-page-text { color: #64748b; }
|
||||
|
||||
/* 无障碍:尊重系统"减少动效"偏好 */
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.wl-page-logo-ring::before,
|
||||
.wl-page-box,
|
||||
.wl-page-text {
|
||||
animation: none !important;
|
||||
}
|
||||
.wl-page-logo-ring::before {
|
||||
border-color: var(--brand-primary, #1668dc);
|
||||
opacity: 0.6;
|
||||
}
|
||||
.wl-page-text { opacity: 0.75; }
|
||||
}
|
||||
`}</style>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Loading;
|
||||
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
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 React, { useEffect, useRef, useState } from 'react';
|
||||
import { InputNumber, withField } from '@douyinfe/semi-ui';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { getQuotaPerUnit } from '../../../helpers';
|
||||
|
||||
/**
|
||||
* 金额额度输入组件
|
||||
*
|
||||
* 对外的 value/onChange 始终使用系统内部额度单位(token,与后端一致),
|
||||
* UI 上则以人民币金额输入/展示(quotaPerUnit 额度 = ¥1,默认 500000),
|
||||
* 后端无需任何改动。
|
||||
*
|
||||
* quota_display_type = TOKENS 时退化为原始额度输入,行为与旧版一致。
|
||||
*
|
||||
* @param {number|string|null} value 内部额度值(token 单位)
|
||||
* @param {(quota:number|null)=>void} onChange 变更回调,参数为换算后的内部额度值;清空时为 null
|
||||
* @param {number} [minQuota] 最小值(token 单位)
|
||||
* @param {number} [maxQuota] 最大值(token 单位)
|
||||
* @param {string} [placeholder] 占位文案,缺省根据货币模式自动生成
|
||||
* 其余属性透传给 Semi InputNumber(size/style/disabled/prefix 等)
|
||||
*/
|
||||
|
||||
const FALLBACK_QUOTA_PER_UNIT = 500000;
|
||||
const CURRENCY_SYMBOL = '¥';
|
||||
|
||||
function getSafeQuotaPerUnit() {
|
||||
const qpu = getQuotaPerUnit();
|
||||
return Number.isFinite(qpu) && qpu > 0 ? qpu : FALLBACK_QUOTA_PER_UNIT;
|
||||
}
|
||||
|
||||
function isTokensMode() {
|
||||
return (localStorage.getItem('quota_display_type') || 'USD') === 'TOKENS';
|
||||
}
|
||||
|
||||
/** 内部额度 → 显示金额(人民币元),保留 6 位小数避免浮点噪声 */
|
||||
export function quotaToMoney(quota) {
|
||||
const n = typeof quota === 'string' ? parseFloat(quota) : quota;
|
||||
if (n === null || n === undefined || !Number.isFinite(n)) return null;
|
||||
return Number((n / getSafeQuotaPerUnit()).toFixed(6));
|
||||
}
|
||||
|
||||
/** 显示金额(人民币元)→ 内部额度(取整,支持负数) */
|
||||
export function moneyToQuota(money) {
|
||||
const n = typeof money === 'string' ? parseFloat(money) : money;
|
||||
if (n === null || n === undefined || !Number.isFinite(n)) return null;
|
||||
return Math.round(n * getSafeQuotaPerUnit());
|
||||
}
|
||||
|
||||
const QuotaInput = ({
|
||||
value,
|
||||
onChange,
|
||||
minQuota,
|
||||
maxQuota,
|
||||
placeholder,
|
||||
...rest
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const tokensMode = isTokensMode();
|
||||
|
||||
const toDisplay = (q) => {
|
||||
if (q === null || q === undefined || q === '') return null;
|
||||
if (tokensMode) {
|
||||
const n = typeof q === 'string' ? parseFloat(q) : q;
|
||||
return Number.isFinite(n) ? n : null;
|
||||
}
|
||||
return quotaToMoney(q);
|
||||
};
|
||||
|
||||
const [innerValue, setInnerValue] = useState(() => toDisplay(value));
|
||||
// 记录组件自己最近一次上抛的额度值:外部值变化若并非来自本组件输入,
|
||||
// 才回写显示值,避免用户输入"1."之类中间态被换算打断
|
||||
const lastEmittedRef = useRef(
|
||||
value === null || value === undefined || value === ''
|
||||
? null
|
||||
: Number(value),
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const normalized =
|
||||
value === null || value === undefined || value === ''
|
||||
? null
|
||||
: Number(value);
|
||||
if (normalized !== lastEmittedRef.current) {
|
||||
lastEmittedRef.current = normalized;
|
||||
setInnerValue(toDisplay(value));
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [value]);
|
||||
|
||||
const handleChange = (v) => {
|
||||
setInnerValue(v);
|
||||
const n = typeof v === 'string' ? parseFloat(v) : v;
|
||||
let quota;
|
||||
if (n === null || n === undefined || !Number.isFinite(n)) {
|
||||
quota = null;
|
||||
} else {
|
||||
quota = tokensMode ? Math.round(n) : moneyToQuota(n);
|
||||
}
|
||||
lastEmittedRef.current = quota;
|
||||
onChange?.(quota);
|
||||
};
|
||||
|
||||
const min =
|
||||
minQuota === undefined
|
||||
? undefined
|
||||
: tokensMode
|
||||
? minQuota
|
||||
: quotaToMoney(minQuota);
|
||||
const max =
|
||||
maxQuota === undefined
|
||||
? undefined
|
||||
: tokensMode
|
||||
? maxQuota
|
||||
: quotaToMoney(maxQuota);
|
||||
|
||||
return (
|
||||
<InputNumber
|
||||
value={innerValue}
|
||||
onChange={handleChange}
|
||||
min={min}
|
||||
max={max}
|
||||
prefix={tokensMode ? undefined : CURRENCY_SYMBOL}
|
||||
placeholder={
|
||||
placeholder ?? (tokensMode ? t('请输入额度') : t('请输入金额'))
|
||||
}
|
||||
{...rest}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
/** Semi Form 版本:表单值仍为内部额度单位,可直接配合 field/rules 使用 */
|
||||
export const FormQuotaInput = withField(QuotaInput, {
|
||||
valueKey: 'value',
|
||||
onKeyChangeFnName: 'onChange',
|
||||
});
|
||||
|
||||
export default QuotaInput;
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
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 React from 'react';
|
||||
import { Space, Tag, Typography, Popover } from '@douyinfe/semi-ui';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
// 通用渲染函数:限制项目数量显示,支持popover展开
|
||||
export function renderLimitedItems({ items, renderItem, maxDisplay = 3 }) {
|
||||
if (!items || items.length === 0) return '-';
|
||||
const displayItems = items.slice(0, maxDisplay);
|
||||
const remainingItems = items.slice(maxDisplay);
|
||||
return (
|
||||
<Space spacing={1} wrap>
|
||||
{displayItems.map((item, idx) => renderItem(item, idx))}
|
||||
{remainingItems.length > 0 && (
|
||||
<Popover
|
||||
content={
|
||||
<div className='p-2'>
|
||||
<Space spacing={1} wrap>
|
||||
{remainingItems.map((item, idx) => renderItem(item, idx))}
|
||||
</Space>
|
||||
</div>
|
||||
}
|
||||
position='top'
|
||||
>
|
||||
<Tag size='small' shape='circle' color='grey'>
|
||||
+{remainingItems.length}
|
||||
</Tag>
|
||||
</Popover>
|
||||
)}
|
||||
</Space>
|
||||
);
|
||||
}
|
||||
|
||||
// 渲染描述字段,长文本支持tooltip
|
||||
export const renderDescription = (text, maxWidth = 200) => {
|
||||
return (
|
||||
<Text ellipsis={{ showTooltip: true }} style={{ maxWidth }}>
|
||||
{text || '-'}
|
||||
</Text>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,242 @@
|
||||
/*
|
||||
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 React, {
|
||||
useRef,
|
||||
useState,
|
||||
useEffect,
|
||||
useCallback,
|
||||
useMemo,
|
||||
useImperativeHandle,
|
||||
forwardRef,
|
||||
} from 'react';
|
||||
|
||||
/**
|
||||
* ScrollableContainer 可滚动容器组件
|
||||
*
|
||||
* 提供自动检测滚动状态和显示渐变指示器的功能
|
||||
* 当内容超出容器高度且未滚动到底部时,会显示底部渐变指示器
|
||||
*
|
||||
*/
|
||||
const ScrollableContainer = forwardRef(
|
||||
(
|
||||
{
|
||||
children,
|
||||
maxHeight = '24rem',
|
||||
className = '',
|
||||
contentClassName = '',
|
||||
fadeIndicatorClassName = '',
|
||||
checkInterval = 100,
|
||||
scrollThreshold = 5,
|
||||
debounceDelay = 16, // ~60fps
|
||||
onScroll,
|
||||
onScrollStateChange,
|
||||
...props
|
||||
},
|
||||
ref,
|
||||
) => {
|
||||
const scrollRef = useRef(null);
|
||||
const containerRef = useRef(null);
|
||||
const debounceTimerRef = useRef(null);
|
||||
const resizeObserverRef = useRef(null);
|
||||
const onScrollStateChangeRef = useRef(onScrollStateChange);
|
||||
const onScrollRef = useRef(onScroll);
|
||||
|
||||
const [showScrollHint, setShowScrollHint] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
onScrollStateChangeRef.current = onScrollStateChange;
|
||||
}, [onScrollStateChange]);
|
||||
|
||||
useEffect(() => {
|
||||
onScrollRef.current = onScroll;
|
||||
}, [onScroll]);
|
||||
|
||||
const debounce = useCallback((func, delay) => {
|
||||
return (...args) => {
|
||||
if (debounceTimerRef.current) {
|
||||
clearTimeout(debounceTimerRef.current);
|
||||
}
|
||||
debounceTimerRef.current = setTimeout(() => func(...args), delay);
|
||||
};
|
||||
}, []);
|
||||
|
||||
const checkScrollable = useCallback(() => {
|
||||
if (!scrollRef.current) return;
|
||||
|
||||
const element = scrollRef.current;
|
||||
const isScrollable = element.scrollHeight > element.clientHeight;
|
||||
const isAtBottom =
|
||||
element.scrollTop + element.clientHeight >=
|
||||
element.scrollHeight - scrollThreshold;
|
||||
const shouldShowHint = isScrollable && !isAtBottom;
|
||||
|
||||
setShowScrollHint(shouldShowHint);
|
||||
|
||||
if (onScrollStateChangeRef.current) {
|
||||
onScrollStateChangeRef.current({
|
||||
isScrollable,
|
||||
isAtBottom,
|
||||
showScrollHint: shouldShowHint,
|
||||
scrollTop: element.scrollTop,
|
||||
scrollHeight: element.scrollHeight,
|
||||
clientHeight: element.clientHeight,
|
||||
});
|
||||
}
|
||||
}, [scrollThreshold]);
|
||||
|
||||
const debouncedCheckScrollable = useMemo(
|
||||
() => debounce(checkScrollable, debounceDelay),
|
||||
[debounce, checkScrollable, debounceDelay],
|
||||
);
|
||||
|
||||
const handleScroll = useCallback(
|
||||
(e) => {
|
||||
debouncedCheckScrollable();
|
||||
if (onScrollRef.current) {
|
||||
onScrollRef.current(e);
|
||||
}
|
||||
},
|
||||
[debouncedCheckScrollable],
|
||||
);
|
||||
|
||||
useImperativeHandle(
|
||||
ref,
|
||||
() => ({
|
||||
checkScrollable: () => {
|
||||
checkScrollable();
|
||||
},
|
||||
scrollToTop: () => {
|
||||
if (scrollRef.current) {
|
||||
scrollRef.current.scrollTop = 0;
|
||||
}
|
||||
},
|
||||
scrollToBottom: () => {
|
||||
if (scrollRef.current) {
|
||||
scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
|
||||
}
|
||||
},
|
||||
getScrollInfo: () => {
|
||||
if (!scrollRef.current) return null;
|
||||
const element = scrollRef.current;
|
||||
return {
|
||||
scrollTop: element.scrollTop,
|
||||
scrollHeight: element.scrollHeight,
|
||||
clientHeight: element.clientHeight,
|
||||
isScrollable: element.scrollHeight > element.clientHeight,
|
||||
isAtBottom:
|
||||
element.scrollTop + element.clientHeight >=
|
||||
element.scrollHeight - scrollThreshold,
|
||||
};
|
||||
},
|
||||
}),
|
||||
[checkScrollable, scrollThreshold],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const timer = setTimeout(() => {
|
||||
checkScrollable();
|
||||
}, checkInterval);
|
||||
return () => clearTimeout(timer);
|
||||
}, [checkScrollable, checkInterval]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!scrollRef.current) return;
|
||||
|
||||
if (typeof ResizeObserver === 'undefined') {
|
||||
if (typeof MutationObserver !== 'undefined') {
|
||||
const observer = new MutationObserver(() => {
|
||||
debouncedCheckScrollable();
|
||||
});
|
||||
|
||||
observer.observe(scrollRef.current, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
attributes: true,
|
||||
characterData: true,
|
||||
});
|
||||
|
||||
return () => observer.disconnect();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
resizeObserverRef.current = new ResizeObserver((entries) => {
|
||||
for (const _entry of entries) {
|
||||
debouncedCheckScrollable();
|
||||
}
|
||||
});
|
||||
|
||||
resizeObserverRef.current.observe(scrollRef.current);
|
||||
|
||||
return () => {
|
||||
if (resizeObserverRef.current) {
|
||||
resizeObserverRef.current.disconnect();
|
||||
}
|
||||
};
|
||||
}, [debouncedCheckScrollable]);
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
if (debounceTimerRef.current) {
|
||||
clearTimeout(debounceTimerRef.current);
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
|
||||
const containerStyle = useMemo(
|
||||
() => ({
|
||||
maxHeight,
|
||||
}),
|
||||
[maxHeight],
|
||||
);
|
||||
|
||||
const fadeIndicatorStyle = useMemo(
|
||||
() => ({
|
||||
opacity: showScrollHint ? 1 : 0,
|
||||
}),
|
||||
[showScrollHint],
|
||||
);
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={containerRef}
|
||||
className={`card-content-container ${className}`}
|
||||
{...props}
|
||||
>
|
||||
<div
|
||||
ref={scrollRef}
|
||||
className={`overflow-y-auto card-content-scroll ${contentClassName}`}
|
||||
style={containerStyle}
|
||||
onScroll={handleScroll}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
<div
|
||||
className={`card-content-fade-indicator ${fadeIndicatorClassName}`}
|
||||
style={fadeIndicatorStyle}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
ScrollableContainer.displayName = 'ScrollableContainer';
|
||||
|
||||
export default ScrollableContainer;
|
||||
@@ -0,0 +1,310 @@
|
||||
/*
|
||||
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 React, { useState, useRef, useEffect } from 'react';
|
||||
import { useMinimumLoadingTime } from '../../../hooks/common/useMinimumLoadingTime';
|
||||
import { useContainerWidth } from '../../../hooks/common/useContainerWidth';
|
||||
import {
|
||||
Divider,
|
||||
Button,
|
||||
Tag,
|
||||
Row,
|
||||
Col,
|
||||
Collapsible,
|
||||
Checkbox,
|
||||
Skeleton,
|
||||
Tooltip,
|
||||
} from '@douyinfe/semi-ui';
|
||||
import { IconChevronDown, IconChevronUp } from '@douyinfe/semi-icons';
|
||||
|
||||
/**
|
||||
* 通用可选择按钮组组件
|
||||
*
|
||||
* @param {string} title 标题
|
||||
* @param {Array<{value:any,label:string,icon?:React.ReactNode,tagCount?:number}>} items 按钮项
|
||||
* @param {*|Array} activeValue 当前激活的值,可以是单个值或数组(多选)
|
||||
* @param {(value:any)=>void} onChange 选择改变回调
|
||||
* @param {function} t i18n
|
||||
* @param {object} style 额外样式
|
||||
* @param {boolean} collapsible 是否支持折叠,默认true
|
||||
* @param {number} collapseHeight 折叠时的高度,默认200
|
||||
* @param {boolean} withCheckbox 是否启用前缀 Checkbox 来控制激活状态
|
||||
* @param {boolean} loading 是否处于加载状态
|
||||
*/
|
||||
const SelectableButtonGroup = ({
|
||||
title,
|
||||
items = [],
|
||||
activeValue,
|
||||
onChange,
|
||||
t = (v) => v,
|
||||
style = {},
|
||||
collapsible = true,
|
||||
collapseHeight = 200,
|
||||
withCheckbox = false,
|
||||
loading = false,
|
||||
}) => {
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const [skeletonCount] = useState(12);
|
||||
const [containerRef, containerWidth] = useContainerWidth();
|
||||
|
||||
const ConditionalTooltipText = ({ text }) => {
|
||||
const textRef = useRef(null);
|
||||
const [isOverflowing, setIsOverflowing] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const el = textRef.current;
|
||||
if (!el) return;
|
||||
setIsOverflowing(el.scrollWidth > el.clientWidth);
|
||||
}, [text, containerWidth]);
|
||||
|
||||
const textElement = (
|
||||
<span ref={textRef} className='sbg-ellipsis'>
|
||||
{text}
|
||||
</span>
|
||||
);
|
||||
|
||||
return isOverflowing ? (
|
||||
<Tooltip content={text}>{textElement}</Tooltip>
|
||||
) : (
|
||||
textElement
|
||||
);
|
||||
};
|
||||
|
||||
// 基于容器宽度计算响应式列数和标签显示策略
|
||||
const getResponsiveConfig = () => {
|
||||
if (containerWidth <= 280) return { columns: 1, showTags: true }; // 极窄:1列+标签
|
||||
if (containerWidth <= 380) return { columns: 2, showTags: true }; // 窄屏:2列+标签
|
||||
if (containerWidth <= 460) return { columns: 3, showTags: false }; // 中等:3列不加标签
|
||||
return { columns: 3, showTags: true }; // 最宽:3列+标签
|
||||
};
|
||||
|
||||
const { columns: perRow, showTags: shouldShowTags } = getResponsiveConfig();
|
||||
const maxVisibleRows = Math.max(1, Math.floor(collapseHeight / 32)); // Approx row height 32
|
||||
const needCollapse = collapsible && items.length > perRow * maxVisibleRows;
|
||||
const showSkeleton = useMinimumLoadingTime(loading);
|
||||
|
||||
// 统一使用紧凑的网格间距
|
||||
const gutterSize = [4, 4];
|
||||
|
||||
// 计算 Semi UI Col 的 span 值
|
||||
const getColSpan = () => {
|
||||
return Math.floor(24 / perRow);
|
||||
};
|
||||
|
||||
const maskStyle = isOpen
|
||||
? {}
|
||||
: {
|
||||
WebkitMaskImage:
|
||||
'linear-gradient(to bottom, black 0%, rgba(0, 0, 0, 1) 60%, rgba(0, 0, 0, 0.2) 80%, transparent 100%)',
|
||||
};
|
||||
|
||||
const toggle = () => {
|
||||
setIsOpen(!isOpen);
|
||||
};
|
||||
|
||||
const linkStyle = {
|
||||
position: 'absolute',
|
||||
left: 0,
|
||||
right: 0,
|
||||
textAlign: 'center',
|
||||
bottom: -10,
|
||||
fontWeight: 400,
|
||||
cursor: 'pointer',
|
||||
fontSize: '12px',
|
||||
color: 'var(--semi-color-text-2)',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
gap: 4,
|
||||
};
|
||||
|
||||
const renderSkeletonButtons = () => {
|
||||
const placeholder = (
|
||||
<Row gutter={gutterSize} style={{ lineHeight: '32px', ...style }}>
|
||||
{Array.from({ length: skeletonCount }).map((_, index) => (
|
||||
<Col span={getColSpan()} key={index}>
|
||||
<div
|
||||
style={{
|
||||
width: '100%',
|
||||
height: '32px',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'flex-start',
|
||||
border: '1px solid var(--semi-color-border)',
|
||||
borderRadius: 'var(--semi-border-radius-medium)',
|
||||
padding: '0 12px',
|
||||
gap: '6px',
|
||||
}}
|
||||
>
|
||||
{withCheckbox && (
|
||||
<Skeleton.Title active style={{ width: 14, height: 14 }} />
|
||||
)}
|
||||
<Skeleton.Title
|
||||
active
|
||||
style={{
|
||||
width: `${60 + (index % 3) * 20}px`,
|
||||
height: 14,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</Col>
|
||||
))}
|
||||
</Row>
|
||||
);
|
||||
|
||||
return (
|
||||
<Skeleton loading={true} active placeholder={placeholder}></Skeleton>
|
||||
);
|
||||
};
|
||||
|
||||
const contentElement = showSkeleton ? (
|
||||
renderSkeletonButtons()
|
||||
) : (
|
||||
<Row gutter={gutterSize} style={{ lineHeight: '32px', ...style }}>
|
||||
{items.map((item) => {
|
||||
const isDisabled =
|
||||
item.disabled ||
|
||||
(typeof item.tagCount === 'number' && item.tagCount === 0);
|
||||
const isActive = Array.isArray(activeValue)
|
||||
? activeValue.includes(item.value)
|
||||
: activeValue === item.value;
|
||||
|
||||
if (withCheckbox) {
|
||||
return (
|
||||
<Col span={getColSpan()} key={item.value}>
|
||||
<Button
|
||||
onClick={() => {
|
||||
/* disabled */
|
||||
}}
|
||||
theme={isActive ? 'light' : 'outline'}
|
||||
type={isActive ? 'primary' : 'tertiary'}
|
||||
disabled={isDisabled}
|
||||
className='sbg-button'
|
||||
icon={
|
||||
<Checkbox
|
||||
checked={isActive}
|
||||
onChange={() => onChange(item.value)}
|
||||
disabled={isDisabled}
|
||||
style={{ pointerEvents: 'auto' }}
|
||||
/>
|
||||
}
|
||||
style={{ width: '100%', cursor: 'default' }}
|
||||
>
|
||||
<div className='sbg-content'>
|
||||
{item.icon && <span className='sbg-icon'>{item.icon}</span>}
|
||||
<ConditionalTooltipText text={item.label} />
|
||||
{item.tagCount !== undefined && shouldShowTags && (
|
||||
<Tag
|
||||
className='sbg-tag'
|
||||
color='white'
|
||||
shape='circle'
|
||||
size='small'
|
||||
>
|
||||
{item.tagCount}
|
||||
</Tag>
|
||||
)}
|
||||
</div>
|
||||
</Button>
|
||||
</Col>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Col span={getColSpan()} key={item.value}>
|
||||
<Button
|
||||
onClick={() => onChange(item.value)}
|
||||
theme={isActive ? 'light' : 'outline'}
|
||||
type={isActive ? 'primary' : 'tertiary'}
|
||||
disabled={isDisabled}
|
||||
className='sbg-button'
|
||||
style={{ width: '100%' }}
|
||||
>
|
||||
<div className='sbg-content'>
|
||||
{item.icon && <span className='sbg-icon'>{item.icon}</span>}
|
||||
<ConditionalTooltipText text={item.label} />
|
||||
{item.tagCount !== undefined && shouldShowTags && (
|
||||
<Tag
|
||||
className='sbg-tag'
|
||||
color='white'
|
||||
shape='circle'
|
||||
size='small'
|
||||
>
|
||||
{item.tagCount}
|
||||
</Tag>
|
||||
)}
|
||||
</div>
|
||||
</Button>
|
||||
</Col>
|
||||
);
|
||||
})}
|
||||
</Row>
|
||||
);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`mb-8 ${containerWidth <= 400 ? 'sbg-compact' : ''}`}
|
||||
ref={containerRef}
|
||||
>
|
||||
{title && (
|
||||
<Divider margin='12px' align='left'>
|
||||
{showSkeleton ? (
|
||||
<Skeleton.Title active style={{ width: 80, height: 14 }} />
|
||||
) : (
|
||||
title
|
||||
)}
|
||||
</Divider>
|
||||
)}
|
||||
{needCollapse && !showSkeleton ? (
|
||||
<div style={{ position: 'relative' }}>
|
||||
<Collapsible
|
||||
isOpen={isOpen}
|
||||
collapseHeight={collapseHeight}
|
||||
style={{ ...maskStyle }}
|
||||
>
|
||||
{contentElement}
|
||||
</Collapsible>
|
||||
{isOpen ? null : (
|
||||
<div onClick={toggle} style={{ ...linkStyle }}>
|
||||
<IconChevronDown size='small' />
|
||||
<span>{t('展开更多')}</span>
|
||||
</div>
|
||||
)}
|
||||
{isOpen && (
|
||||
<div
|
||||
onClick={toggle}
|
||||
style={{
|
||||
...linkStyle,
|
||||
position: 'static',
|
||||
marginTop: 8,
|
||||
bottom: 'auto',
|
||||
}}
|
||||
>
|
||||
<IconChevronUp size='small' />
|
||||
<span>{t('收起')}</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
contentElement
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default SelectableButtonGroup;
|
||||
Reference in New Issue
Block a user