This commit is contained in:
2026-03-16 17:01:33 +08:00
parent 970d6d9538
commit 53541f8b46
3 changed files with 36 additions and 15 deletions

View File

@@ -6,14 +6,12 @@
import React from "react"; import React from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { Spin, Tag, Space, message } from "antd"; import { Spin, Tag, Space, message } from "antd";
import { Button, Empty } from "@lobehub/ui"; import { Button, Empty, MaterialFileTypeIcon } from "@lobehub/ui";
import { import {
LayoutGrid, LayoutGrid,
Download, Download,
History, History,
Code, Code,
FileCode,
FileText,
Monitor, Monitor,
Smartphone, Smartphone,
ArrowLeft, ArrowLeft,
@@ -142,6 +140,10 @@ const useStyles = createStyles(({ token, css }) => ({
display: flex; display: flex;
flex-direction: column; flex-direction: column;
`, `,
fileSize: css`
min-width: 30px;
text-align: right;
`,
})); }));
const AppDetail: React.FC = () => { const AppDetail: React.FC = () => {
@@ -332,13 +334,32 @@ const AppDetail: React.FC = () => {
} }
}; };
// Icon for file type: FileCode for JS, FileText for CSS // Icon for file type using MaterialFileTypeIcon
const getFileTypeIcon = (type: "js" | "css") => { const getFileTypeIcon = (type: "js" | "css", filename: string) => {
return type === "js" ? ( return <MaterialFileTypeIcon type='file' filename={`test.${type}`} size={16} />;
<FileCode size={16} style={{ color: "#f7df1e" }} /> };
) : (
<FileText size={16} style={{ color: "#264de4" }} /> // Format file size to human readable
); const formatFileSize = (size: string | number | undefined): string => {
if (!size) return "-";
const num = typeof size === "string" ? parseInt(size, 10) : size;
if (isNaN(num)) return "-";
if (num < 1024) return `${num} B`;
if (num < 1024 * 1024) return `${(num / 1024).toFixed(1)} KB`;
return `${(num / (1024 * 1024)).toFixed(1)} MB`;
};
// Get file metadata from FILE type resource
const getFileMeta = (
file: FileConfigResponse,
): { contentType: string; size: string } | null => {
if (isFileResource(file) && file.file) {
return {
contentType: file.file.contentType || "-",
size: file.file.size || "-",
};
}
return null;
}; };
const renderFileList = ( const renderFileList = (
@@ -362,6 +383,7 @@ const AppDetail: React.FC = () => {
const fileKey = getFileKey(file); const fileKey = getFileKey(file);
const canView = isFileResource(file); const canView = isFileResource(file);
const isDownloading = fileKey === downloadingKey; const isDownloading = fileKey === downloadingKey;
const fileMeta = getFileMeta(file);
return ( return (
<div <div
@@ -374,11 +396,14 @@ const AppDetail: React.FC = () => {
}} }}
> >
<div className={styles.fileInfo}> <div className={styles.fileInfo}>
<span className={styles.fileIcon}>{getFileTypeIcon(type)}</span> <span className={styles.fileIcon}>{getFileTypeIcon(type, fileName)}</span>
<span className={styles.fileName}>{fileName}</span> <span className={styles.fileName}>{fileName}</span>
</div> </div>
{canView && ( {canView && (
<Space> <Space>
{fileMeta && (
<span className={styles.fileSize}>{formatFileSize(fileMeta.size)}</span>
)}
<Button <Button
type="text" type="text"
size="small" size="small"

View File

@@ -10,12 +10,10 @@ import { Button } from "@lobehub/ui";
import { import {
Inbox, Inbox,
Trash2, Trash2,
FileText,
File, File,
Code, Code,
} from "lucide-react"; } from "lucide-react";
import { createStyles } from "antd-style"; import { createStyles } from "antd-style";
import type { UploadFile, UploadProps } from "antd";
import type { DeployFile } from "@shared/types/ipc"; import type { DeployFile } from "@shared/types/ipc";
const { Dragger } = Upload; const { Dragger } = Upload;

View File

@@ -20,7 +20,6 @@ import {
Download, Download,
Trash2, Trash2,
Undo2, Undo2,
Tag,
Code, Code,
FileText, FileText,
} from "lucide-react"; } from "lucide-react";
@@ -268,7 +267,6 @@ const VersionHistory: React.FC = () => {
{version.tags.map((tag, i) => ( {version.tags.map((tag, i) => (
<Tag <Tag
key={i} key={i}
icon={<Tag size={14} />}
color="processing" color="processing"
> >
{tag} {tag}