Upgrade Alias-Agent to 0.2.0 (#51)

Upgrade Alias-Agent to 0.2.0

---------

Co-authored-by: ZiTao-Li <zitao.l@alibaba-inc.com>
Co-authored-by: xieyxclack <yuexiang.xyx@alibaba-inc.com>
Co-authored-by: Zexi Li <tomleeze@qq.com>
Co-authored-by: SSSuperDan <dlaura2218@gmail.com>
Co-authored-by: lalaliat <78087788+lalaliat@users.noreply.github.com>
Co-authored-by: jinli.yl <jinli.yl@alibaba-inc.com>
Co-authored-by: Dengjiaji <dengjiaji.djj@alibaba-inc.com>
Co-authored-by: 于南 <zengtianjing.ztj@alibaba-inc.com>
Co-authored-by: JustinDing <166603159+sleepy-bird-world@users.noreply.github.com>
Co-authored-by: y1y5 <269557841@qq.com>
Co-authored-by: 柳佚 <yly287738@alibaba-inc.com>
Co-authored-by: LiangguiWeng <347185100@qq.com>
Co-authored-by: 潜星 <zhijian.mzj@alibaba-inc.com>
Co-authored-by: StCarmen <1106135234@qq.com>
Co-authored-by: LuYi <yilu_2000@outlook.com>
Co-authored-by: 刺葳 <ciwei.cy@alibaba-inc.com>
This commit is contained in:
Yue Cui
2025-12-03 20:58:25 +08:00
committed by GitHub
parent 8af2dc6477
commit cb87558efe
430 changed files with 49058 additions and 3471 deletions

View File

@@ -0,0 +1,81 @@
import React from "react";
import { getFileType, languageMap } from "./utils";
import { HtmlViewer } from "./HtmlViewer";
import { MarkdownViewer } from "./MarkdownViewer";
import { CodeViewer } from "./CodeViewer";
import { CSVViewer } from "./CSVViewer";
import { ChartViewer } from "./ChartViewer";
import { DiffViewer } from "./DiffViewer";
import { ViewerStyle } from "./types";
interface UniversalViewerProps {
content: string;
fileName?: string;
style?: ViewerStyle;
}
export const UniversalViewer: React.FC<UniversalViewerProps> = ({
content,
fileName = "",
style = {},
}) => {
const getViewer = () => {
const defaultStyles = {
width: "100%",
height: "100%",
overflow: "auto",
...style,
};
const fileType = fileName?.split(".").pop()?.toLowerCase() || "";
const type = getFileType(fileType);
switch (type) {
case "html":
return <HtmlViewer content={content} style={defaultStyles} />;
case "markdown":
return <MarkdownViewer content={content} style={defaultStyles} />;
case "csv":
return <CSVViewer content={content} style={defaultStyles} />;
// case 'pdf':
// return <PDFViewer content={content} style={defaultStyles} />;
// case 'image':
// return <ImageViewer content={content} style={defaultStyles} />;
case "chart":
return <ChartViewer content={content} style={defaultStyles} />;
case "diff":
return <DiffViewer content={content} style={defaultStyles} />;
default:
const language = languageMap[fileType] || "text";
return (
<CodeViewer
content={content}
language={language}
style={defaultStyles}
/>
);
}
};
return (
<div
style={{
display: "flex",
flex: 1,
// maxHeight: '500px',
position: "relative",
// overflow: 'auto',
// border: '1px solid #ddd',
borderRadius: "4px",
}}
>
{getViewer()}
</div>
);
};