feat: 新增日志中心、功能优化与代码重构
- 新增 log_datasource.go / log_proxy.go / user_api_token.go 后端控制器 - 新增 log_datasource.go model - 新增 monitor/log-center.ts API 模块 - 新增 LogCenter 前端组件及页面 - 重构 deployment 相关组件 (HPDA/UpdateImageModal/bundle-yaml 等) - 新增 ResetPasswordDialog / code-snippet-block / copy-button 等 UI 组件 - 重构多个 k8s 相关组件 (TopologyView/ResourceVisualEditor/PodFileBrowser 等) - 更新多个 API 和工具函数 (auth.ts/monitor/index.ts/request.ts 等) - 更新静态资源 (index.html + 新 JS/CSS bundle) - 删除废弃静态资源文件
This commit is contained in:
1 parent
5ca0e6d83a
commit
8d46e8f352
197 files changed
+5014
-815
No files matched your search
@@ -0,0 +1,43 @@
|
||||
// code-snippet-block.tsx — 代码片段展示 + 外侧复制按钮 // Logan.Li
|
||||
import { CopyButton } from '@/components/ui/copy-button';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
export interface CodeSnippetBlockProps {
|
||||
label?: string;
|
||||
code: string;
|
||||
copyLabel?: string;
|
||||
className?: string;
|
||||
/** 无密钥等场景禁用复制 // Logan.Li */
|
||||
copyDisabled?: boolean;
|
||||
copyDisabledTitle?: string;
|
||||
}
|
||||
|
||||
export function CodeSnippetBlock({
|
||||
label, code, copyLabel = '已复制', className, copyDisabled, copyDisabledTitle,
|
||||
}: CodeSnippetBlockProps) {
|
||||
return (
|
||||
<div className={cn('space-y-1.5', className)}>
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
{label ? (
|
||||
<p className="text-xs text-[var(--dg-text-muted)]">{label}</p>
|
||||
) : (
|
||||
<span />
|
||||
)}
|
||||
<CopyButton
|
||||
text={code}
|
||||
label={copyLabel}
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="border-[var(--dg-border)] text-[var(--dg-text-secondary)] h-7 px-2"
|
||||
disabled={copyDisabled}
|
||||
title={copyDisabled ? (copyDisabledTitle || '不可复制') : '复制'}
|
||||
>
|
||||
复制
|
||||
</CopyButton>
|
||||
</div>
|
||||
<pre className="text-[11px] font-mono text-[var(--dg-text-secondary)] bg-[var(--dg-bg-secondary)] border border-[var(--dg-border)] rounded-md p-3 overflow-x-auto whitespace-pre-wrap leading-relaxed">
|
||||
{code}
|
||||
</pre>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
// copy-button.tsx — 统一复制按钮(图标 + 文案)// Logan.Li
|
||||
import { useState } from 'react';
|
||||
import { Copy, Check } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { useToast } from '@/hooks/use-toast';
|
||||
import { copyToClipboard } from '@/utils/clipboard';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
export interface CopyButtonProps {
|
||||
text: string;
|
||||
/** 复制成功 toast 标题 */
|
||||
label?: string;
|
||||
/** 按钮展示文案,默认仅图标 */
|
||||
children?: React.ReactNode;
|
||||
className?: string;
|
||||
size?: 'default' | 'sm' | 'lg' | 'icon';
|
||||
variant?: 'default' | 'outline' | 'ghost' | 'secondary';
|
||||
disabled?: boolean;
|
||||
title?: string;
|
||||
}
|
||||
|
||||
export function CopyButton({
|
||||
text,
|
||||
label = '已复制',
|
||||
children,
|
||||
className,
|
||||
size = 'sm',
|
||||
variant = 'outline',
|
||||
disabled,
|
||||
title = '复制',
|
||||
}: CopyButtonProps) {
|
||||
const { toast } = useToast();
|
||||
const [copied, setCopied] = useState(false);
|
||||
|
||||
const handleCopy = async () => {
|
||||
const ok = await copyToClipboard(text);
|
||||
if (ok) {
|
||||
setCopied(true);
|
||||
toast({ title: label });
|
||||
setTimeout(() => setCopied(false), 2000);
|
||||
} else {
|
||||
toast({
|
||||
title: '复制失败',
|
||||
description: '请手动选中内容后复制',
|
||||
variant: 'destructive',
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const isIconOnly = !children && size === 'icon';
|
||||
|
||||
return (
|
||||
<Button
|
||||
type="button"
|
||||
variant={variant}
|
||||
size={size}
|
||||
className={cn(
|
||||
isIconOnly ? 'h-8 w-8 shrink-0' : 'shrink-0',
|
||||
className,
|
||||
)}
|
||||
onClick={handleCopy}
|
||||
disabled={disabled || !text}
|
||||
title={title}
|
||||
aria-label={title}
|
||||
>
|
||||
{copied ? (
|
||||
<Check className={cn('text-emerald-400', children ? 'h-3.5 w-3.5 mr-1' : 'h-3.5 w-3.5')} />
|
||||
) : (
|
||||
<Copy className={cn(children ? 'h-3.5 w-3.5 mr-1' : 'h-3.5 w-3.5')} />
|
||||
)}
|
||||
{children}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user