Initial import of weiyuan frontend
This commit is contained in:
@@ -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>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user