mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-03 07:06:36 +08:00
feat: 更新嵌入式文件系统逻辑,支持路径清理和静态资源请求处理,增强前端主题切换能力
This commit is contained in:
@@ -27,7 +27,7 @@ export function AppCard({
|
||||
{(title || description || action) && (
|
||||
<header className='flex flex-col gap-3 border-b border-[var(--border-default)] px-6 py-5 md:flex-row md:items-start md:justify-between'>
|
||||
<div className='space-y-1'>
|
||||
{title ? <h2 className='text-lg font-semibold text-white'>{title}</h2> : null}
|
||||
{title ? <h2 className='text-lg font-semibold text-[var(--foreground-primary)]'>{title}</h2> : null}
|
||||
{description ? (
|
||||
<p className='text-sm leading-6 text-[var(--foreground-secondary)]'>{description}</p>
|
||||
) : null}
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
import { cn } from '@/lib/utils/cn';
|
||||
|
||||
const variantClasses = {
|
||||
success: 'border-emerald-400/25 bg-emerald-500/15 text-emerald-200',
|
||||
warning: 'border-amber-400/25 bg-amber-500/15 text-amber-200',
|
||||
danger: 'border-rose-400/25 bg-rose-500/15 text-rose-200',
|
||||
info: 'border-sky-400/25 bg-sky-500/15 text-sky-200',
|
||||
success:
|
||||
'border-[var(--status-success-border)] bg-[var(--status-success-soft)] text-[var(--status-success-foreground)]',
|
||||
warning:
|
||||
'border-[var(--status-warning-border)] bg-[var(--status-warning-soft)] text-[var(--status-warning-foreground)]',
|
||||
danger:
|
||||
'border-[var(--status-danger-border)] bg-[var(--status-danger-soft)] text-[var(--status-danger-foreground)]',
|
||||
info:
|
||||
'border-[var(--status-info-border)] bg-[var(--status-info-soft)] text-[var(--status-info-foreground)]',
|
||||
} as const;
|
||||
|
||||
interface StatusBadgeProps {
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
'use client';
|
||||
|
||||
import { cn } from '@/lib/utils/cn';
|
||||
import type { ThemeMode } from '@/lib/theme/theme';
|
||||
import { useTheme } from '@/components/providers/theme-provider';
|
||||
|
||||
const themeOptions: Array<{ value: ThemeMode; label: string }> = [
|
||||
{ value: 'light', label: '浅色' },
|
||||
{ value: 'system', label: '跟随系统' },
|
||||
{ value: 'dark', label: '深色' },
|
||||
];
|
||||
|
||||
interface ThemeToggleProps {
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function ThemeToggle({ className }: ThemeToggleProps) {
|
||||
const { themeMode, resolvedTheme, setThemeMode } = useTheme();
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
'inline-flex items-center gap-1 rounded-full border border-[var(--border-default)] bg-[var(--control-background)] p-1 text-xs text-[var(--foreground-secondary)]',
|
||||
className,
|
||||
)}
|
||||
aria-label='主题切换'
|
||||
>
|
||||
{themeOptions.map((option) => {
|
||||
const active = themeMode === option.value;
|
||||
|
||||
return (
|
||||
<button
|
||||
key={option.value}
|
||||
type='button'
|
||||
onClick={() => setThemeMode(option.value)}
|
||||
className={cn(
|
||||
'rounded-full px-3 py-1.5 transition-colors',
|
||||
active
|
||||
? 'bg-[var(--accent-soft)] text-[var(--foreground-primary)]'
|
||||
: 'hover:bg-[var(--control-background-hover)] hover:text-[var(--foreground-primary)]',
|
||||
)}
|
||||
aria-pressed={active}
|
||||
title={
|
||||
option.value === 'system'
|
||||
? `当前跟随系统(${resolvedTheme === 'dark' ? '深色' : '浅色'})`
|
||||
: `切换到${option.label}`
|
||||
}
|
||||
>
|
||||
{option.label}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user