Implement Executable File Detection & Terminal Integration + i18n Improvements #252

Merged
ZacharyZcR merged 63 commits from main into main 2025-09-18 02:58:14 +00:00
2 changed files with 23 additions and 23 deletions
Showing only changes of commit f4f5e47e48 - Show all commits
@@ -150,7 +150,7 @@ export function DraggableWindow({
<div <div
ref={windowRef} ref={windowRef}
className={cn( className={cn(
"absolute bg-white border border-gray-300 rounded-lg shadow-2xl", "absolute bg-card border border-border rounded-lg shadow-2xl",
"select-none overflow-hidden", "select-none overflow-hidden",
isMaximized ? "inset-0" : "" isMaximized ? "inset-0" : ""
)} )}
@@ -168,8 +168,8 @@ export function DraggableWindow({
ref={titleBarRef} ref={titleBarRef}
className={cn( className={cn(
"flex items-center justify-between px-3 py-2", "flex items-center justify-between px-3 py-2",
"bg-gradient-to-r from-blue-500 to-blue-600 text-white", "bg-muted/50 text-foreground border-b border-border",
"border-b border-gray-300 cursor-grab active:cursor-grabbing" "cursor-grab active:cursor-grabbing"
)} )}
onMouseDown={handleMouseDown} onMouseDown={handleMouseDown}
onDoubleClick={handleTitleDoubleClick} onDoubleClick={handleTitleDoubleClick}
@@ -181,7 +181,7 @@ export function DraggableWindow({
<div className="flex items-center gap-1"> <div className="flex items-center gap-1">
{onMinimize && ( {onMinimize && (
<button <button
className="w-8 h-6 flex items-center justify-center rounded hover:bg-white/20 transition-colors" className="w-8 h-6 flex items-center justify-center rounded hover:bg-accent transition-colors"
onClick={(e) => { onClick={(e) => {
e.stopPropagation(); e.stopPropagation();
onMinimize(); onMinimize();
@@ -194,7 +194,7 @@ export function DraggableWindow({
{onMaximize && ( {onMaximize && (
<button <button
className="w-8 h-6 flex items-center justify-center rounded hover:bg-white/20 transition-colors" className="w-8 h-6 flex items-center justify-center rounded hover:bg-accent transition-colors"
onClick={(e) => { onClick={(e) => {
e.stopPropagation(); e.stopPropagation();
onMaximize(); onMaximize();
@@ -210,7 +210,7 @@ export function DraggableWindow({
)} )}
<button <button
className="w-8 h-6 flex items-center justify-center rounded hover:bg-red-500 transition-colors" className="w-8 h-6 flex items-center justify-center rounded hover:bg-destructive hover:text-destructive-foreground transition-colors"
onClick={(e) => { onClick={(e) => {
e.stopPropagation(); e.stopPropagation();
onClose(); onClose();
@@ -146,20 +146,20 @@ export function FileViewer({
} }
return ( return (
<div className="h-full flex flex-col bg-gray-50"> <div className="h-full flex flex-col bg-background">
{/* 文件信息头部 */} {/* 文件信息头部 */}
<div className="flex-shrink-0 bg-white border-b border-gray-200 p-4"> <div className="flex-shrink-0 bg-card border-b border-border p-4">
<div className="flex items-center justify-between"> <div className="flex items-center justify-between">
<div className="flex items-center gap-3"> <div className="flex items-center gap-3">
<div className={cn("p-2 rounded-lg bg-gray-100", fileTypeInfo.color)}> <div className={cn("p-2 rounded-lg bg-muted", fileTypeInfo.color)}>
{fileTypeInfo.icon} {fileTypeInfo.icon}
</div> </div>
<div> <div>
<h3 className="font-medium text-gray-900">{file.name}</h3> <h3 className="font-medium text-foreground">{file.name}</h3>
<div className="flex items-center gap-4 text-sm text-gray-500"> <div className="flex items-center gap-4 text-sm text-muted-foreground">
<span>{formatFileSize(file.size)}</span> <span>{formatFileSize(file.size)}</span>
{file.modified && <span>Modified: {file.modified}</span>} {file.modified && <span>Modified: {file.modified}</span>}
<span className={cn("px-2 py-1 rounded-full text-xs", fileTypeInfo.color, "bg-gray-100")}> <span className={cn("px-2 py-1 rounded-full text-xs", fileTypeInfo.color, "bg-muted")}>
{fileTypeInfo.type.toUpperCase()} {fileTypeInfo.type.toUpperCase()}
</span> </span>
</div> </div>
@@ -197,13 +197,13 @@ export function FileViewer({
<div className="flex-1 overflow-auto"> <div className="flex-1 overflow-auto">
{/* 大文件警告对话框 */} {/* 大文件警告对话框 */}
{showLargeFileWarning && ( {showLargeFileWarning && (
<div className="h-full flex items-center justify-center bg-gray-50"> <div className="h-full flex items-center justify-center bg-background">
<div className="bg-white border border-orange-200 rounded-lg p-6 max-w-md mx-4 shadow-lg"> <div className="bg-card border border-orange-200 rounded-lg p-6 max-w-md mx-4 shadow-lg">
<div className="flex items-start gap-3 mb-4"> <div className="flex items-start gap-3 mb-4">
<AlertCircle className="w-6 h-6 text-orange-500 flex-shrink-0 mt-0.5" /> <AlertCircle className="w-6 h-6 text-orange-500 flex-shrink-0 mt-0.5" />
<div> <div>
<h3 className="font-medium text-gray-900 mb-2">Large File Warning</h3> <h3 className="font-medium text-foreground mb-2">Large File Warning</h3>
<p className="text-sm text-gray-600 mb-3"> <p className="text-sm text-muted-foreground mb-3">
This file is {formatFileSize(file.size)} in size, which may cause performance issues when opened as text. This file is {formatFileSize(file.size)} in size, which may cause performance issues when opened as text.
</p> </p>
{isTooLarge ? ( {isTooLarge ? (
@@ -213,7 +213,7 @@ export function FileViewer({
</p> </p>
</div> </div>
) : ( ) : (
<p className="text-sm text-gray-600 mb-4"> <p className="text-sm text-muted-foreground mb-4">
Do you want to continue opening this file as text? This may slow down your browser. Do you want to continue opening this file as text? This may slow down your browser.
</p> </p>
)} )}
@@ -277,8 +277,8 @@ export function FileViewer({
onChange={(e) => handleContentChange(e.target.value)} onChange={(e) => handleContentChange(e.target.value)}
className={cn( className={cn(
"w-full h-full p-4 border-none resize-none outline-none", "w-full h-full p-4 border-none resize-none outline-none",
"font-mono text-sm bg-white", "font-mono text-sm bg-background text-foreground",
fileTypeInfo.type === 'code' && "bg-gray-900 text-gray-100" fileTypeInfo.type === 'code' && "bg-muted text-foreground"
)} )}
placeholder="Start typing..." placeholder="Start typing..."
spellCheck={false} spellCheck={false}
@@ -286,7 +286,7 @@ export function FileViewer({
) : ( ) : (
<div className={cn( <div className={cn(
"h-full p-4 font-mono text-sm whitespace-pre-wrap", "h-full p-4 font-mono text-sm whitespace-pre-wrap",
fileTypeInfo.type === 'code' ? "bg-gray-900 text-gray-100" : "bg-white text-gray-900" fileTypeInfo.type === 'code' ? "bg-muted text-foreground" : "bg-background text-foreground"
)}> )}>
{content || 'File is empty'} {content || 'File is empty'}
</div> </div>
@@ -328,8 +328,8 @@ export function FileViewer({
{/* 未知文件类型 - 只在不能显示为文本且没有警告时显示 */} {/* 未知文件类型 - 只在不能显示为文本且没有警告时显示 */}
{fileTypeInfo.type === 'unknown' && !shouldShowAsText && !showLargeFileWarning && ( {fileTypeInfo.type === 'unknown' && !shouldShowAsText && !showLargeFileWarning && (
<div className="h-full flex items-center justify-center"> <div className="h-full flex items-center justify-center">
<div className="text-center text-gray-500"> <div className="text-center text-muted-foreground">
<AlertCircle className="w-16 h-16 mx-auto mb-4 text-gray-300" /> <AlertCircle className="w-16 h-16 mx-auto mb-4 text-muted-foreground/50" />
<h3 className="text-lg font-medium mb-2">Cannot preview this file type</h3> <h3 className="text-lg font-medium mb-2">Cannot preview this file type</h3>
<p className="text-sm mb-4"> <p className="text-sm mb-4">
This file type is not supported for preview. You can download it to view in an external application. This file type is not supported for preview. You can download it to view in an external application.
@@ -350,7 +350,7 @@ export function FileViewer({
</div> </div>
{/* 底部状态栏 */} {/* 底部状态栏 */}
<div className="flex-shrink-0 bg-gray-100 border-t border-gray-200 px-4 py-2 text-xs text-gray-600"> <div className="flex-shrink-0 bg-muted/50 border-t border-border px-4 py-2 text-xs text-muted-foreground">
<div className="flex justify-between items-center"> <div className="flex justify-between items-center">
<span>{file.path}</span> <span>{file.path}</span>
{hasChanges && ( {hasChanges && (