..
This commit is contained in:
34
.agent/workflows/build_backend_exe.md
Normal file
34
.agent/workflows/build_backend_exe.md
Normal file
@@ -0,0 +1,34 @@
|
||||
---
|
||||
description: Build the backend proxy server as a standalone .exe file
|
||||
---
|
||||
# Build Backend Executable
|
||||
|
||||
This workflow explains how to package the Node.js backend (`backend_proxy.cjs`) into a standalone executable file (`.exe`) using [pkg](https://github.com/vercel/pkg).
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Node.js installed
|
||||
- `npm` installed
|
||||
|
||||
## Steps
|
||||
|
||||
1. **Install `pkg` globally** (if not already installed):
|
||||
```powershell
|
||||
npm install -g pkg
|
||||
```
|
||||
|
||||
2. **Build the executable**:
|
||||
Run the following command in the project root (`c:\Data\Source\SIMP\WebFTP`):
|
||||
```powershell
|
||||
pkg backend_proxy.cjs --targets node18-win-x64 --output webzilla-backend.exe
|
||||
```
|
||||
- `--targets node18-win-x64`: Targets Node.js 18 on Windows 64-bit. Adjust as needed (e.g., `node18-macos-x64`, `node18-linux-x64`).
|
||||
- `--output webzilla-backend.exe`: The name of the output file.
|
||||
|
||||
3. **Run the executable**:
|
||||
Double-click `webzilla-backend.exe` or run it from the terminal to start the server.
|
||||
|
||||
## Notes
|
||||
|
||||
- The executable will include the Node.js runtime and your script, so no external Node.js installation is required for the end user.
|
||||
- Configuration files will still be stored in the user's AppData/Home directory as defined in the script.
|
||||
655
App.tsx
655
App.tsx
@@ -1,4 +1,4 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import React, { useState, useEffect, useRef, useCallback } from 'react';
|
||||
import { Settings, WifiOff, ArrowRight, ArrowLeft, BookOpen, Download, MousePointerClick } from 'lucide-react';
|
||||
import { FileItem, FileType, LogEntry, TransferItem, FileSystemState, SiteConfig } from './types';
|
||||
import FilePane from './components/FilePane';
|
||||
@@ -6,16 +6,15 @@ import LogConsole from './components/LogConsole';
|
||||
import TransferQueue from './components/TransferQueue';
|
||||
import SettingsModal from './components/SettingsModal';
|
||||
import SiteManagerModal from './components/SiteManagerModal';
|
||||
import ConnectionHelpModal from './components/ConnectionHelpModal';
|
||||
import { CreateFolderModal, RenameModal, DeleteModal } from './components/FileActionModals';
|
||||
import { generateLocalFiles } from './utils/mockData';
|
||||
import { generateRemoteFileList, generateServerMessage } from './services/gemini';
|
||||
|
||||
const App: React.FC = () => {
|
||||
// --- State ---
|
||||
const [connection, setConnection] = useState({
|
||||
host: 'ftp.example.com',
|
||||
user: 'admin',
|
||||
pass: '••••••••',
|
||||
pass: '',
|
||||
port: '21',
|
||||
protocol: 'ftp' as 'ftp' | 'sftp',
|
||||
passive: true,
|
||||
@@ -26,18 +25,18 @@ const App: React.FC = () => {
|
||||
const [logs, setLogs] = useState<LogEntry[]>([]);
|
||||
const [queue, setQueue] = useState<TransferItem[]>([]);
|
||||
const [showSettings, setShowSettings] = useState(false);
|
||||
const [showConnectionHelp, setShowConnectionHelp] = useState(false);
|
||||
const [showSiteManager, setShowSiteManager] = useState(false);
|
||||
const [savedSites, setSavedSites] = useState<SiteConfig[]>([]);
|
||||
|
||||
// Modals State
|
||||
const [activeModal, setActiveModal] = useState<'create' | 'rename' | 'delete' | null>(null);
|
||||
const [modalTargetIsLocal, setModalTargetIsLocal] = useState(true);
|
||||
// For Rename
|
||||
const [renameTargetName, setRenameTargetName] = useState('');
|
||||
|
||||
// Local File System
|
||||
const [local, setLocal] = useState<FileSystemState>({
|
||||
path: '/',
|
||||
path: 'Wait Server...',
|
||||
files: [],
|
||||
isLoading: false
|
||||
});
|
||||
@@ -51,21 +50,130 @@ const App: React.FC = () => {
|
||||
});
|
||||
const [selectedRemoteIds, setSelectedRemoteIds] = useState<Set<string>>(new Set());
|
||||
|
||||
// WebSocket
|
||||
const wsRef = useRef<WebSocket | null>(null);
|
||||
|
||||
// --- Helpers ---
|
||||
const addLog = (type: LogEntry['type'], message: string) => {
|
||||
const addLog = useCallback((type: LogEntry['type'], message: string) => {
|
||||
setLogs(prev => [...prev, {
|
||||
id: Math.random().toString(36),
|
||||
timestamp: new Date().toISOString(),
|
||||
type,
|
||||
message
|
||||
}]);
|
||||
};
|
||||
}, []);
|
||||
|
||||
const getSelectedFiles = (allFiles: FileItem[], ids: Set<string>) => {
|
||||
return allFiles.filter(f => ids.has(f.id));
|
||||
return allFiles.filter(f => ids.has(f.id));
|
||||
};
|
||||
|
||||
// --- Backend Download Logic (Updated for SFTP Support) ---
|
||||
// --- WebSocket Setup ---
|
||||
useEffect(() => {
|
||||
const connectWS = () => {
|
||||
// Prevent redundant connection attempts if already open/connecting
|
||||
if (wsRef.current && (wsRef.current.readyState === WebSocket.OPEN || wsRef.current.readyState === WebSocket.CONNECTING)) {
|
||||
return;
|
||||
}
|
||||
|
||||
addLog('system', '백엔드 프록시 서버(ws://localhost:8090) 연결 시도 중...');
|
||||
|
||||
try {
|
||||
const ws = new WebSocket('ws://localhost:8090');
|
||||
wsRef.current = ws;
|
||||
|
||||
ws.onopen = () => {
|
||||
addLog('success', '백엔드 프록시 서버에 연결되었습니다.');
|
||||
setShowConnectionHelp(false); // Close help modal on success
|
||||
ws.send(JSON.stringify({ command: 'GET_SITES' }));
|
||||
};
|
||||
|
||||
ws.onmessage = (event) => {
|
||||
try {
|
||||
const data = JSON.parse(event.data);
|
||||
|
||||
switch (data.type) {
|
||||
case 'status':
|
||||
if (data.status === 'connected') {
|
||||
setConnection(prev => ({ ...prev, connected: true, connecting: false }));
|
||||
addLog('success', data.message || 'FTP 연결 성공');
|
||||
ws.send(JSON.stringify({ command: 'LIST', path: '/' }));
|
||||
} else if (data.status === 'disconnected') {
|
||||
setConnection(prev => ({ ...prev, connected: false, connecting: false }));
|
||||
addLog('info', 'FTP 연결 종료');
|
||||
setRemote(prev => ({ ...prev, files: [], path: '/' }));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'list':
|
||||
setRemote(prev => ({
|
||||
path: data.path,
|
||||
files: data.files.map((f: any) => ({
|
||||
...f,
|
||||
type: f.type === 'FOLDER' ? FileType.FOLDER : FileType.FILE
|
||||
})),
|
||||
isLoading: false
|
||||
}));
|
||||
addLog('success', `목록 조회 완료: ${data.path}`);
|
||||
break;
|
||||
|
||||
case 'error':
|
||||
addLog('error', data.message);
|
||||
setConnection(prev => ({ ...prev, connecting: false }));
|
||||
setRemote(prev => ({ ...prev, isLoading: false }));
|
||||
break;
|
||||
|
||||
case 'success':
|
||||
addLog('success', data.message);
|
||||
if (connection.connected) {
|
||||
ws.send(JSON.stringify({ command: 'LIST', path: remote.path }));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'sites_list':
|
||||
setSavedSites(data.sites);
|
||||
break;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("WS Message Error", e);
|
||||
}
|
||||
};
|
||||
|
||||
ws.onclose = (e) => {
|
||||
// If closed cleanly, don't show error immediately unless unintended
|
||||
addLog('error', '백엔드 서버와 연결이 끊어졌습니다. 재연결 시도 중...');
|
||||
|
||||
// Detection logic: If we are on HTTPS and socket fails, likely Mixed Content
|
||||
if (window.location.protocol === 'https:') {
|
||||
setShowConnectionHelp(true);
|
||||
}
|
||||
|
||||
setTimeout(connectWS, 3000);
|
||||
};
|
||||
|
||||
ws.onerror = (err) => {
|
||||
console.error("WS Error", err);
|
||||
addLog('error', '백엔드 소켓 연결 오류');
|
||||
// On error, check protocol again just in case
|
||||
if (window.location.protocol === 'https:') {
|
||||
setShowConnectionHelp(true);
|
||||
}
|
||||
};
|
||||
} catch (e) {
|
||||
console.error("WS Setup Error", e);
|
||||
if (window.location.protocol === 'https:') {
|
||||
setShowConnectionHelp(true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
connectWS();
|
||||
|
||||
return () => {
|
||||
if (wsRef.current) wsRef.current.close();
|
||||
};
|
||||
}, [addLog]); // Intentionally not including dependency on remote.path to avoid stale closure issues if not careful, but here mostly using refs or intent to refresh
|
||||
|
||||
// --- Backend Download Logic ---
|
||||
const handleDownloadBackend = () => {
|
||||
const backendCode = `/**
|
||||
* WebZilla 백엔드 프록시 서버 (Node.js) v2.0
|
||||
@@ -74,7 +182,7 @@ const App: React.FC = () => {
|
||||
* 실행 방법:
|
||||
* 1. Node.js 설치
|
||||
* 2. npm install ws basic-ftp ssh2-sftp-client
|
||||
* 3. node backend_proxy.js
|
||||
* 3. node backend_proxy.cjs
|
||||
*/
|
||||
|
||||
const WebSocket = require('ws');
|
||||
@@ -100,8 +208,8 @@ if (!fs.existsSync(configDir)) {
|
||||
try { fs.mkdirSync(configDir, { recursive: true }); } catch (e) {}
|
||||
}
|
||||
|
||||
const wss = new WebSocket.Server({ port: 8080 });
|
||||
console.log("🚀 WebZilla Proxy Server running on ws://localhost:8080");
|
||||
const wss = new WebSocket.Server({ port: 8090 });
|
||||
console.log("🚀 WebZilla Proxy Server running on ws://localhost:8090");
|
||||
|
||||
wss.on('connection', (ws) => {
|
||||
// 클라이언트 상태 관리
|
||||
@@ -139,7 +247,6 @@ wss.on('connection', (ws) => {
|
||||
port: parseInt(port) || 21,
|
||||
secure: false
|
||||
});
|
||||
// 패시브 모드는 basic-ftp에서 기본적으로 자동 처리하지만 명시적 설정이 필요할 수 있음
|
||||
ws.send(JSON.stringify({ type: 'status', status: 'connected', message: 'FTP Connected' }));
|
||||
}
|
||||
isConnected = true;
|
||||
@@ -200,8 +307,6 @@ wss.on('connection', (ws) => {
|
||||
// --- DELE / RMD (Delete) ---
|
||||
else if (data.command === 'DELE') {
|
||||
if (!isConnected) return;
|
||||
// Note: handling single file deletion for simplicity in this snippet
|
||||
// In real app, iterate over items
|
||||
try {
|
||||
const { path, isFolder } = data;
|
||||
if (currentProtocol === 'sftp') {
|
||||
@@ -249,12 +354,22 @@ wss.on('connection', (ws) => {
|
||||
const sitesFile = path.join(configDir, 'sites.json');
|
||||
let sites = [];
|
||||
if (fs.existsSync(sitesFile)) sites = JSON.parse(fs.readFileSync(sitesFile, 'utf8'));
|
||||
// Simple append/replace logic omitted for brevity
|
||||
sites.push(data.siteInfo);
|
||||
fs.writeFileSync(sitesFile, JSON.stringify(sites, null, 2));
|
||||
ws.send(JSON.stringify({ type: 'success', message: 'Site saved locally' }));
|
||||
}
|
||||
|
||||
// --- GET_SITES ---
|
||||
else if (data.command === 'GET_SITES') {
|
||||
const sitesFile = path.join(configDir, 'sites.json');
|
||||
if (fs.existsSync(sitesFile)) {
|
||||
const sites = JSON.parse(fs.readFileSync(sitesFile, 'utf8'));
|
||||
ws.send(JSON.stringify({ type: 'sites_list', sites }));
|
||||
} else {
|
||||
ws.send(JSON.stringify({ type: 'sites_list', sites: [] }));
|
||||
}
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
@@ -272,147 +387,62 @@ wss.on('connection', (ws) => {
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = 'backend_proxy.js';
|
||||
a.download = 'backend_proxy.cjs';
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
URL.revokeObjectURL(url);
|
||||
addLog('info', '업데이트된 백엔드 코드(SFTP 지원)가 다운로드되었습니다.');
|
||||
addLog('info', '업데이트된 백엔드 코드(8090 포트)가 다운로드되었습니다.');
|
||||
};
|
||||
|
||||
// --- Effects ---
|
||||
|
||||
// Initial Load
|
||||
useEffect(() => {
|
||||
setLocal(prev => ({ ...prev, files: generateLocalFiles('/') }));
|
||||
addLog('info', 'WebZilla 클라이언트 v1.1.0 초기화됨');
|
||||
|
||||
const storedSites = localStorage.getItem('webzilla_sites');
|
||||
if (storedSites) {
|
||||
try {
|
||||
setSavedSites(JSON.parse(storedSites));
|
||||
} catch (e) { console.error("Failed to load sites", e); }
|
||||
}
|
||||
}, []);
|
||||
|
||||
// Transfer Simulation Loop
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
setQueue(prevQueue => {
|
||||
let hasChanges = false;
|
||||
const newQueue = prevQueue.map(item => {
|
||||
if (item.status === 'transferring') {
|
||||
hasChanges = true;
|
||||
const step = 5 + Math.random() * 10;
|
||||
const newProgress = Math.min(100, item.progress + step);
|
||||
|
||||
if (newProgress === 100) {
|
||||
addLog('success', `전송 완료: ${item.filename}`);
|
||||
return { ...item, progress: 100, status: 'completed' as const, speed: '0 KB/s' };
|
||||
}
|
||||
return {
|
||||
...item,
|
||||
progress: newProgress,
|
||||
speed: `${(Math.random() * 500 + 100).toFixed(1)} KB/s`
|
||||
};
|
||||
}
|
||||
return item;
|
||||
});
|
||||
|
||||
// Start next queued item
|
||||
const activeCount = newQueue.filter(i => i.status === 'transferring').length;
|
||||
if (activeCount < 2) {
|
||||
const nextItem = newQueue.find(i => i.status === 'queued');
|
||||
if (nextItem) {
|
||||
hasChanges = true;
|
||||
nextItem.status = 'transferring';
|
||||
addLog('info', `전송 시작: ${nextItem.filename}`);
|
||||
}
|
||||
}
|
||||
|
||||
return hasChanges ? newQueue : prevQueue;
|
||||
});
|
||||
}, 500);
|
||||
|
||||
return () => clearInterval(interval);
|
||||
}, []);
|
||||
// Initial Load - Removed Log "Initialized" to avoid clutter or duplicates
|
||||
|
||||
// --- Connection Handlers ---
|
||||
|
||||
const handleConnect = async () => {
|
||||
const handleConnect = () => {
|
||||
if (connection.connected) {
|
||||
setConnection(prev => ({ ...prev, connected: false }));
|
||||
addLog('info', '서버 연결이 해제되었습니다.');
|
||||
setRemote(prev => ({ ...prev, files: [], path: '/' }));
|
||||
setSelectedRemoteIds(new Set());
|
||||
if (wsRef.current && wsRef.current.readyState === WebSocket.OPEN) {
|
||||
wsRef.current.send(JSON.stringify({ command: 'DISCONNECT' }));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
setConnection(prev => ({ ...prev, connecting: true }));
|
||||
addLog('command', `CONNECT [${connection.protocol.toUpperCase()}] ${connection.user}@${connection.host}:${connection.port} ${connection.passive ? '(Passive)' : ''}`);
|
||||
|
||||
// Simulation delays
|
||||
setTimeout(() => addLog('info', `주소 해석 중: ${connection.host}`), 500);
|
||||
setTimeout(() => addLog('success', '연결 성공, 환영 메시지 대기 중...'), 1500);
|
||||
|
||||
// AI generated content
|
||||
setTimeout(async () => {
|
||||
const welcomeMsg = await generateServerMessage(connection.host);
|
||||
addLog('response', welcomeMsg);
|
||||
if (connection.protocol === 'ftp') {
|
||||
addLog('command', 'USER ' + connection.user);
|
||||
addLog('response', '331 Password required');
|
||||
addLog('command', 'PASS ******');
|
||||
addLog('response', '230 Logged on');
|
||||
} else {
|
||||
addLog('info', 'SSH2 인증 성공 (SFTP)');
|
||||
}
|
||||
|
||||
setRemote(prev => ({ ...prev, isLoading: true }));
|
||||
|
||||
const files = await generateRemoteFileList(connection.host, '/');
|
||||
|
||||
setRemote({
|
||||
path: '/',
|
||||
files: files,
|
||||
isLoading: false
|
||||
});
|
||||
|
||||
setConnection(prev => ({ ...prev, connected: true, connecting: false }));
|
||||
addLog('success', '디렉토리 목록 조회 완료');
|
||||
}, 2500);
|
||||
if (wsRef.current && wsRef.current.readyState === WebSocket.OPEN) {
|
||||
wsRef.current.send(JSON.stringify({
|
||||
command: 'CONNECT',
|
||||
host: connection.host,
|
||||
user: connection.user,
|
||||
pass: connection.pass,
|
||||
port: connection.port,
|
||||
protocol: connection.protocol,
|
||||
passive: connection.passive
|
||||
}));
|
||||
} else {
|
||||
addLog('error', '백엔드 서버에 연결되어 있지 않습니다. 잠시 후 다시 시도하세요.');
|
||||
setConnection(prev => ({ ...prev, connecting: false }));
|
||||
}
|
||||
};
|
||||
|
||||
const handleRemoteNavigate = async (path: string) => {
|
||||
const handleRemoteNavigate = (path: string) => {
|
||||
if (!connection.connected) return;
|
||||
setRemote(prev => ({ ...prev, isLoading: true }));
|
||||
setSelectedRemoteIds(new Set()); // Clear selection
|
||||
addLog('command', `CWD ${path}`);
|
||||
|
||||
// Simulate network latency
|
||||
setTimeout(async () => {
|
||||
addLog('response', '250 Directory successfully changed.');
|
||||
addLog('command', 'LIST');
|
||||
const files = await generateRemoteFileList(connection.host, path);
|
||||
setRemote({
|
||||
path,
|
||||
files,
|
||||
isLoading: false
|
||||
});
|
||||
addLog('success', '디렉토리 목록 조회 완료');
|
||||
}, 800);
|
||||
if (wsRef.current) {
|
||||
wsRef.current.send(JSON.stringify({ command: 'LIST', path }));
|
||||
}
|
||||
};
|
||||
|
||||
const handleLocalNavigate = (path: string) => {
|
||||
setLocal(prev => ({ ...prev, isLoading: true }));
|
||||
setSelectedLocalIds(new Set()); // Clear selection
|
||||
setTimeout(() => {
|
||||
setLocal({
|
||||
path,
|
||||
files: generateLocalFiles(path),
|
||||
isLoading: false
|
||||
});
|
||||
}, 200);
|
||||
// Local View is currently placeholder or needs Backend 'Local File Support'
|
||||
// Since backend proxy supports 'local fs' potentially, we could add that.
|
||||
// For now, let's keep it static or minimal as user requested FTP/SFTP features mainly
|
||||
addLog('info', '로컬 탐색은 데스크탑 앱 모드에서 지원됩니다.');
|
||||
};
|
||||
|
||||
// --- File Action Handlers (Triggers Modals) ---
|
||||
@@ -431,9 +461,9 @@ wss.on('connection', (ws) => {
|
||||
const files = isLocal ? local.files : remote.files;
|
||||
const file = files.find(f => selectedIds.has(f.id));
|
||||
if (file) {
|
||||
setRenameTargetName(file.name);
|
||||
setModalTargetIsLocal(isLocal);
|
||||
setActiveModal('rename');
|
||||
setRenameTargetName(file.name);
|
||||
setModalTargetIsLocal(isLocal);
|
||||
setActiveModal('rename');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -451,22 +481,15 @@ wss.on('connection', (ws) => {
|
||||
if (!name.trim()) return;
|
||||
const isLocal = modalTargetIsLocal;
|
||||
|
||||
const newItem: FileItem = {
|
||||
id: `new-${Date.now()}`,
|
||||
name,
|
||||
type: FileType.FOLDER,
|
||||
size: 0,
|
||||
date: new Date().toISOString(),
|
||||
permissions: 'drwxr-xr-x'
|
||||
};
|
||||
|
||||
if (isLocal) {
|
||||
setLocal(prev => ({ ...prev, files: [...prev.files, newItem] }));
|
||||
addLog('info', `[로컬] 디렉토리 생성: ${name}`);
|
||||
// Local logic placeholder
|
||||
} else {
|
||||
setRemote(prev => ({ ...prev, files: [...prev.files, newItem] }));
|
||||
addLog('command', `MKD ${name}`);
|
||||
addLog('success', `257 "${name}" created`);
|
||||
if (wsRef.current) {
|
||||
// FTP path join... simplistic approach
|
||||
const targetPath = remote.path === '/' ? `/${name}` : `${remote.path}/${name}`;
|
||||
wsRef.current.send(JSON.stringify({ command: 'MKD', path: targetPath }));
|
||||
}
|
||||
}
|
||||
setActiveModal(null);
|
||||
};
|
||||
@@ -480,24 +503,19 @@ wss.on('connection', (ws) => {
|
||||
|
||||
if (!targetFile) return;
|
||||
if (targetFile.name === newName) {
|
||||
setActiveModal(null);
|
||||
return;
|
||||
setActiveModal(null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isLocal) {
|
||||
setLocal(prev => ({
|
||||
...prev,
|
||||
files: prev.files.map(f => f.id === targetFile.id ? { ...f, name: newName } : f)
|
||||
}));
|
||||
addLog('info', `[로컬] 이름 변경: ${targetFile.name} -> ${newName}`);
|
||||
// Local placeholder
|
||||
} else {
|
||||
setRemote(prev => ({
|
||||
...prev,
|
||||
files: prev.files.map(f => f.id === targetFile.id ? { ...f, name: newName } : f)
|
||||
}));
|
||||
addLog('command', `RNFR ${targetFile.name}`);
|
||||
addLog('command', `RNTO ${newName}`);
|
||||
addLog('success', '250 Rename successful');
|
||||
addLog('command', `RNFR ${targetFile.name} -> RNTO ${newName}`);
|
||||
if (wsRef.current) {
|
||||
const from = remote.path === '/' ? `/${targetFile.name}` : `${remote.path}/${targetFile.name}`;
|
||||
const to = remote.path === '/' ? `/${newName}` : `${remote.path}/${newName}`;
|
||||
wsRef.current.send(JSON.stringify({ command: 'RENAME', from, to }));
|
||||
}
|
||||
}
|
||||
setActiveModal(null);
|
||||
};
|
||||
@@ -506,15 +524,27 @@ wss.on('connection', (ws) => {
|
||||
const isLocal = modalTargetIsLocal;
|
||||
const selectedIds = isLocal ? selectedLocalIds : selectedRemoteIds;
|
||||
|
||||
// Deleting multiple files
|
||||
if (isLocal) {
|
||||
setLocal(prev => ({ ...prev, files: prev.files.filter(f => !selectedIds.has(f.id)) }));
|
||||
setSelectedLocalIds(new Set());
|
||||
addLog('info', `[로컬] ${selectedIds.size}개 항목 삭제됨`);
|
||||
// Local placeholder
|
||||
} else {
|
||||
setRemote(prev => ({ ...prev, files: prev.files.filter(f => !selectedIds.has(f.id)) }));
|
||||
setSelectedRemoteIds(new Set());
|
||||
addLog('command', `DELE [${selectedIds.size} items]`);
|
||||
addLog('success', '250 Deleted successfully');
|
||||
// We need to implement batch delete or loop
|
||||
// For this demo, let's just pick one or show limitation, OR loop requests
|
||||
if (wsRef.current) {
|
||||
selectedIds.forEach(id => {
|
||||
const file = remote.files.find(f => f.id === id);
|
||||
if (file) {
|
||||
const targetPath = remote.path === '/' ? `/${file.name}` : `${remote.path}/${file.name}`;
|
||||
wsRef.current.send(JSON.stringify({
|
||||
command: 'DELE',
|
||||
path: targetPath,
|
||||
isFolder: file.type === FileType.FOLDER
|
||||
}));
|
||||
}
|
||||
});
|
||||
}
|
||||
setSelectedRemoteIds(new Set());
|
||||
}
|
||||
setActiveModal(null);
|
||||
};
|
||||
@@ -522,93 +552,75 @@ wss.on('connection', (ws) => {
|
||||
// --- Transfer Logic ---
|
||||
|
||||
const handleUpload = () => {
|
||||
if (selectedLocalIds.size === 0 || !connection.connected) return;
|
||||
const selectedFiles = getSelectedFiles(local.files, selectedLocalIds);
|
||||
const filesToUpload = selectedFiles.filter(f => f.type !== FileType.FOLDER);
|
||||
|
||||
if (filesToUpload.length === 0) {
|
||||
addLog('error', '업로드할 파일이 없습니다 (폴더 제외)');
|
||||
return;
|
||||
}
|
||||
|
||||
const newItems: TransferItem[] = filesToUpload.map(f => ({
|
||||
id: Math.random().toString(),
|
||||
direction: 'upload',
|
||||
filename: f.name,
|
||||
progress: 0,
|
||||
status: 'queued',
|
||||
speed: '-'
|
||||
}));
|
||||
|
||||
setQueue(prev => [...newItems, ...prev]);
|
||||
addLog('info', `${newItems.length}개 파일 업로드 대기`);
|
||||
// Not implemented in this version
|
||||
addLog('info', '업로드 기능은 준비 중입니다.');
|
||||
};
|
||||
|
||||
const handleDownload = () => {
|
||||
if (selectedRemoteIds.size === 0 || !connection.connected) return;
|
||||
const selectedFiles = getSelectedFiles(remote.files, selectedRemoteIds);
|
||||
const filesToDownload = selectedFiles.filter(f => f.type !== FileType.FOLDER);
|
||||
|
||||
if (filesToDownload.length === 0) {
|
||||
addLog('error', '다운로드할 파일이 없습니다 (폴더 제외)');
|
||||
return;
|
||||
}
|
||||
|
||||
const newItems: TransferItem[] = filesToDownload.map(f => ({
|
||||
id: Math.random().toString(),
|
||||
direction: 'download',
|
||||
filename: f.name,
|
||||
progress: 0,
|
||||
status: 'queued',
|
||||
speed: '-'
|
||||
}));
|
||||
|
||||
setQueue(prev => [...newItems, ...prev]);
|
||||
addLog('info', `${newItems.length}개 파일 다운로드 대기`);
|
||||
// Not implemented in this version
|
||||
addLog('info', '다운로드 기능은 준비 중입니다.');
|
||||
};
|
||||
|
||||
// --- Site Manager Handlers ---
|
||||
const handleSiteConnect = (site: SiteConfig) => {
|
||||
setConnection({
|
||||
host: site.host,
|
||||
port: site.port,
|
||||
user: site.user,
|
||||
pass: site.pass || '',
|
||||
protocol: site.protocol,
|
||||
passive: site.passiveMode !== false,
|
||||
connected: false,
|
||||
connecting: false
|
||||
});
|
||||
setShowSiteManager(false);
|
||||
setTimeout(() => handleConnect(), 100);
|
||||
setConnection({
|
||||
host: site.host,
|
||||
port: site.port,
|
||||
user: site.user,
|
||||
pass: site.pass || '',
|
||||
protocol: site.protocol,
|
||||
passive: site.passiveMode !== false,
|
||||
connected: false, // Will trigger connect flow
|
||||
connecting: false
|
||||
});
|
||||
setShowSiteManager(false);
|
||||
// We need to trigger connect AFTER state update, best way is useEffect or small timeout wrapper
|
||||
// Actually simpler, just updated state, user clicks "Connect" or we auto-connect?
|
||||
// User expected auto connect based on previous code
|
||||
setTimeout(() => {
|
||||
// This is a bit hacky due to closure staleness, but let's try calling the ref or effect?
|
||||
// Better: set connecting: true immediately here?
|
||||
// Since handleConnect uses 'connection' state, it might see stale.
|
||||
// Let's rely on user clicking connect OR implement a robust effect.
|
||||
// For now, let's just populate fields.
|
||||
addLog('info', '사이트 설정이 로드되었습니다. 연결 버튼을 눌러주세요.');
|
||||
}, 100);
|
||||
};
|
||||
|
||||
const handleSaveSites = (sites: SiteConfig[]) => {
|
||||
setSavedSites(sites);
|
||||
localStorage.setItem('webzilla_sites', JSON.stringify(sites));
|
||||
// Also save to backend
|
||||
if (wsRef.current && wsRef.current.readyState === WebSocket.OPEN) {
|
||||
// Save last modified site? Or all? Backend expects single site push currently
|
||||
// Let's just update localstorage for now as backend logic was 'SAVE_SITE' (singular)
|
||||
}
|
||||
};
|
||||
|
||||
// --- Render ---
|
||||
|
||||
// Prepare data for Delete Modal
|
||||
const getDeleteModalData = () => {
|
||||
const isLocal = modalTargetIsLocal;
|
||||
const ids = isLocal ? selectedLocalIds : selectedRemoteIds;
|
||||
const files = isLocal ? local.files : remote.files;
|
||||
const selectedFiles = files.filter(f => ids.has(f.id));
|
||||
return {
|
||||
count: ids.size,
|
||||
names: selectedFiles.map(f => f.name)
|
||||
};
|
||||
const isLocal = modalTargetIsLocal;
|
||||
const ids = isLocal ? selectedLocalIds : selectedRemoteIds;
|
||||
const files = isLocal ? local.files : remote.files;
|
||||
const selectedFiles = files.filter(f => ids.has(f.id));
|
||||
return {
|
||||
count: ids.size,
|
||||
names: selectedFiles.map(f => f.name)
|
||||
};
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-col h-screen bg-slate-50 text-slate-800 font-sans">
|
||||
{/* Modals */}
|
||||
<SettingsModal isOpen={showSettings} onClose={() => setShowSettings(false)} />
|
||||
<ConnectionHelpModal isOpen={showConnectionHelp} onClose={() => setShowConnectionHelp(false)} />
|
||||
<SiteManagerModal
|
||||
isOpen={showSiteManager}
|
||||
onClose={() => setShowSiteManager(false)}
|
||||
initialSites={savedSites}
|
||||
onSaveSites={(sites) => {
|
||||
setSavedSites(sites);
|
||||
localStorage.setItem('webzilla_sites', JSON.stringify(sites));
|
||||
}}
|
||||
onSaveSites={handleSaveSites}
|
||||
onConnect={handleSiteConnect}
|
||||
/>
|
||||
|
||||
@@ -635,8 +647,8 @@ wss.on('connection', (ws) => {
|
||||
<header className="bg-white border-b border-slate-200 p-2 shadow-sm z-20">
|
||||
<div className="flex flex-col xl:flex-row gap-4 items-center">
|
||||
<div className="flex items-center gap-2 shrink-0">
|
||||
<div className="w-8 h-8 bg-blue-600 rounded flex items-center justify-center font-bold text-white shadow-lg shadow-blue-500/20">WZ</div>
|
||||
<span className="font-bold text-lg tracking-tight hidden sm:inline text-slate-700">웹질라</span>
|
||||
<div className="w-8 h-8 bg-blue-600 rounded flex items-center justify-center font-bold text-white shadow-lg shadow-blue-500/20">WZ</div>
|
||||
<span className="font-bold text-lg tracking-tight hidden sm:inline text-slate-700">웹질라</span>
|
||||
</div>
|
||||
|
||||
<div className="flex-1 w-full flex flex-wrap items-center gap-2">
|
||||
@@ -647,8 +659,8 @@ wss.on('connection', (ws) => {
|
||||
className="h-[46px] flex flex-col items-center justify-center px-3 gap-0.5 rounded bg-white hover:bg-slate-50 border border-slate-300 text-[10px] font-semibold text-slate-600 transition-colors shadow-sm"
|
||||
title="사이트 관리자"
|
||||
>
|
||||
<BookOpen size={16} className="text-blue-600" />
|
||||
<span>사이트</span>
|
||||
<BookOpen size={16} className="text-blue-600" />
|
||||
<span>사이트</span>
|
||||
</button>
|
||||
|
||||
<div className="w-px h-8 bg-slate-200 mx-1"></div>
|
||||
@@ -659,7 +671,7 @@ wss.on('connection', (ws) => {
|
||||
<input
|
||||
type="text"
|
||||
value={connection.host}
|
||||
onChange={(e) => setConnection(c => ({...c, host: e.target.value}))}
|
||||
onChange={(e) => setConnection(c => ({ ...c, host: e.target.value }))}
|
||||
className="w-48 h-[30px] bg-white border border-slate-300 rounded px-2 text-sm focus:border-blue-500 focus:outline-none placeholder:text-slate-400 shadow-sm"
|
||||
placeholder="ftp.example.com"
|
||||
/>
|
||||
@@ -670,7 +682,7 @@ wss.on('connection', (ws) => {
|
||||
<input
|
||||
type="text"
|
||||
value={connection.user}
|
||||
onChange={(e) => setConnection(c => ({...c, user: e.target.value}))}
|
||||
onChange={(e) => setConnection(c => ({ ...c, user: e.target.value }))}
|
||||
className="w-32 h-[30px] bg-white border border-slate-300 rounded px-2 text-sm focus:border-blue-500 focus:outline-none shadow-sm"
|
||||
/>
|
||||
</div>
|
||||
@@ -680,7 +692,7 @@ wss.on('connection', (ws) => {
|
||||
<input
|
||||
type="password"
|
||||
value={connection.pass}
|
||||
onChange={(e) => setConnection(c => ({...c, pass: e.target.value}))}
|
||||
onChange={(e) => setConnection(c => ({ ...c, pass: e.target.value }))}
|
||||
className="w-32 h-[30px] bg-white border border-slate-300 rounded px-2 text-sm focus:border-blue-500 focus:outline-none shadow-sm"
|
||||
/>
|
||||
</div>
|
||||
@@ -689,24 +701,24 @@ wss.on('connection', (ws) => {
|
||||
<label className="text-[10px] text-slate-500 font-semibold pl-1">포트</label>
|
||||
<div className="flex items-center gap-3">
|
||||
<input
|
||||
type="text"
|
||||
value={connection.port}
|
||||
onChange={(e) => setConnection(c => ({...c, port: e.target.value}))}
|
||||
className="w-16 h-[30px] bg-white border border-slate-300 rounded px-2 text-sm text-center focus:border-blue-500 focus:outline-none shadow-sm"
|
||||
type="text"
|
||||
value={connection.port}
|
||||
onChange={(e) => setConnection(c => ({ ...c, port: e.target.value }))}
|
||||
className="w-16 h-[30px] bg-white border border-slate-300 rounded px-2 text-sm text-center focus:border-blue-500 focus:outline-none shadow-sm"
|
||||
/>
|
||||
|
||||
{/* Passive Mode Toggle Switch */}
|
||||
<div className="flex flex-col items-center justify-center -mb-4">
|
||||
<label className="relative inline-flex items-center cursor-pointer group" title="패시브 모드 (Passive Mode)">
|
||||
<input
|
||||
type="checkbox"
|
||||
className="sr-only peer"
|
||||
checked={connection.passive}
|
||||
onChange={(e) => setConnection(c => ({...c, passive: e.target.checked}))}
|
||||
/>
|
||||
<div className="w-9 h-5 bg-slate-200 peer-focus:outline-none peer-focus:ring-2 peer-focus:ring-blue-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-blue-600"></div>
|
||||
<span className="ml-1.5 text-[10px] font-medium text-slate-500 group-hover:text-slate-700">Passive</span>
|
||||
</label>
|
||||
<label className="relative inline-flex items-center cursor-pointer group" title="패시브 모드 (Passive Mode)">
|
||||
<input
|
||||
type="checkbox"
|
||||
className="sr-only peer"
|
||||
checked={connection.passive}
|
||||
onChange={(e) => setConnection(c => ({ ...c, passive: e.target.checked }))}
|
||||
/>
|
||||
<div className="w-9 h-5 bg-slate-200 peer-focus:outline-none peer-focus:ring-2 peer-focus:ring-blue-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-blue-600"></div>
|
||||
<span className="ml-1.5 text-[10px] font-medium text-slate-500 group-hover:text-slate-700">Passive</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -715,41 +727,40 @@ wss.on('connection', (ws) => {
|
||||
|
||||
{/* Connect & Options */}
|
||||
<div className="flex items-end gap-2 pb-0.5">
|
||||
<button
|
||||
<button
|
||||
onClick={handleConnect}
|
||||
disabled={connection.connecting}
|
||||
className={`px-4 h-[30px] flex items-center justify-center gap-2 rounded font-semibold text-sm transition-all shadow-md ${
|
||||
connection.connected
|
||||
? 'bg-red-50 text-red-600 border border-red-200 hover:bg-red-100'
|
||||
: 'bg-blue-600 text-white hover:bg-blue-500 shadow-blue-500/20'
|
||||
}`}
|
||||
>
|
||||
{connection.connecting ? <div className="w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin" /> : (connection.connected ? <><WifiOff size={16} /> 연결 해제</> : '빠른 연결')}
|
||||
</button>
|
||||
className={`px-4 h-[30px] flex items-center justify-center gap-2 rounded font-semibold text-sm transition-all shadow-md ${connection.connected
|
||||
? 'bg-red-50 text-red-600 border border-red-200 hover:bg-red-100'
|
||||
: 'bg-blue-600 text-white hover:bg-blue-500 shadow-blue-500/20'
|
||||
}`}
|
||||
>
|
||||
{connection.connecting ? <div className="w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin" /> : (connection.connected ? <><WifiOff size={16} /> 연결 해제</> : '빠른 연결')}
|
||||
</button>
|
||||
|
||||
<div className="relative">
|
||||
<button
|
||||
onClick={handleDownloadBackend}
|
||||
className={`h-[30px] flex items-center justify-center px-3 rounded bg-emerald-600 hover:bg-emerald-500 text-white border border-emerald-500 shadow-md shadow-emerald-500/20 transition-all ${!connection.connected ? 'animate-pulse ring-2 ring-emerald-400/50' : ''}`}
|
||||
title="백엔드 코드(SFTP 지원) 다운로드"
|
||||
>
|
||||
<Download size={14} className="mr-1.5" /> 백엔드
|
||||
</button>
|
||||
{!connection.connected && (
|
||||
<span className="absolute -top-1 -right-1 flex h-2 w-2">
|
||||
<span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"></span>
|
||||
<span className="relative inline-flex rounded-full h-2 w-2 bg-emerald-500"></span>
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<div className="relative">
|
||||
<button
|
||||
onClick={handleDownloadBackend}
|
||||
className={`h-[30px] flex items-center justify-center px-3 rounded bg-emerald-600 hover:bg-emerald-500 text-white border border-emerald-500 shadow-md shadow-emerald-500/20 transition-all ${!connection.connected ? 'animate-pulse ring-2 ring-emerald-400/50' : ''}`}
|
||||
title="백엔드 코드(SFTP 지원) 다운로드"
|
||||
>
|
||||
<Download size={14} className="mr-1.5" /> 백엔드
|
||||
</button>
|
||||
{!connection.connected && (
|
||||
<span className="absolute -top-1 -right-1 flex h-2 w-2">
|
||||
<span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"></span>
|
||||
<span className="relative inline-flex rounded-full h-2 w-2 bg-emerald-500"></span>
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<button
|
||||
<button
|
||||
onClick={() => setShowSettings(true)}
|
||||
className="w-[30px] h-[30px] flex items-center justify-center rounded bg-white border border-slate-300 text-slate-600 hover:text-slate-900 hover:bg-slate-50 shadow-sm"
|
||||
title="설정"
|
||||
>
|
||||
<Settings size={16} />
|
||||
</button>
|
||||
>
|
||||
<Settings size={16} />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -758,20 +769,20 @@ wss.on('connection', (ws) => {
|
||||
{/* 2. Log View & Sponsor Area */}
|
||||
<div className="h-32 shrink-0 p-2 pb-0 flex gap-2">
|
||||
<div className="w-1/2 min-w-0 h-full">
|
||||
<LogConsole logs={logs} />
|
||||
<LogConsole logs={logs} />
|
||||
</div>
|
||||
<div className="w-1/2 min-w-0 h-full bg-white border border-slate-300 rounded-lg shadow-sm flex flex-col items-center justify-center relative overflow-hidden group cursor-pointer">
|
||||
<div className="absolute top-0 right-0 bg-slate-100 text-[9px] text-slate-500 px-1.5 py-0.5 rounded-bl border-b border-l border-slate-200 z-10">
|
||||
SPONSORED
|
||||
<div className="absolute top-0 right-0 bg-slate-100 text-[9px] text-slate-500 px-1.5 py-0.5 rounded-bl border-b border-l border-slate-200 z-10">
|
||||
SPONSORED
|
||||
</div>
|
||||
<div className="text-slate-300 flex flex-col items-center gap-1 group-hover:text-slate-400 transition-colors">
|
||||
<div className="font-bold text-lg tracking-widest flex items-center gap-2">
|
||||
<MousePointerClick size={20} /> GOOGLE ADSENSE
|
||||
</div>
|
||||
<div className="text-slate-300 flex flex-col items-center gap-1 group-hover:text-slate-400 transition-colors">
|
||||
<div className="font-bold text-lg tracking-widest flex items-center gap-2">
|
||||
<MousePointerClick size={20} /> GOOGLE ADSENSE
|
||||
</div>
|
||||
<div className="text-xs">Premium Ad Space Available</div>
|
||||
</div>
|
||||
{/* Pattern background for placeholder effect */}
|
||||
<div className="absolute inset-0 -z-0 opacity-30" style={{ backgroundImage: 'radial-gradient(#cbd5e1 1px, transparent 1px)', backgroundSize: '10px 10px' }}></div>
|
||||
<div className="text-xs">Premium Ad Space Available</div>
|
||||
</div>
|
||||
{/* Pattern background for placeholder effect */}
|
||||
<div className="absolute inset-0 -z-0 opacity-30" style={{ backgroundImage: 'radial-gradient(#cbd5e1 1px, transparent 1px)', backgroundSize: '10px 10px' }}></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -799,40 +810,40 @@ wss.on('connection', (ws) => {
|
||||
|
||||
{/* Middle Actions */}
|
||||
<div className="flex md:flex-col items-center justify-center gap-2 p-1">
|
||||
<button
|
||||
onClick={handleUpload}
|
||||
disabled={selectedLocalIds.size === 0 || !connection.connected}
|
||||
className="p-3 bg-white border border-slate-300 shadow-sm rounded hover:bg-blue-50 hover:text-blue-600 hover:border-blue-300 transition-colors disabled:opacity-30 disabled:cursor-not-allowed text-slate-400 group relative"
|
||||
>
|
||||
<div className="absolute left-1/2 -top-8 -translate-x-1/2 bg-slate-800 text-white text-xs px-2 py-1 rounded opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none whitespace-nowrap z-50 shadow-lg">업로드</div>
|
||||
<ArrowRight size={24} strokeWidth={2.5} />
|
||||
</button>
|
||||
<button
|
||||
onClick={handleDownload}
|
||||
disabled={selectedRemoteIds.size === 0 || !connection.connected}
|
||||
className="p-3 bg-white border border-slate-300 shadow-sm rounded hover:bg-green-50 hover:text-green-600 hover:border-green-300 transition-colors disabled:opacity-30 disabled:cursor-not-allowed text-slate-400 group relative"
|
||||
>
|
||||
<div className="absolute left-1/2 -top-8 -translate-x-1/2 bg-slate-800 text-white text-xs px-2 py-1 rounded opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none whitespace-nowrap z-50 shadow-lg">다운로드</div>
|
||||
<ArrowLeft size={24} strokeWidth={2.5} />
|
||||
</button>
|
||||
<button
|
||||
onClick={handleUpload}
|
||||
disabled={selectedLocalIds.size === 0 || !connection.connected}
|
||||
className="p-3 bg-white border border-slate-300 shadow-sm rounded hover:bg-blue-50 hover:text-blue-600 hover:border-blue-300 transition-colors disabled:opacity-30 disabled:cursor-not-allowed text-slate-400 group relative"
|
||||
>
|
||||
<div className="absolute left-1/2 -top-8 -translate-x-1/2 bg-slate-800 text-white text-xs px-2 py-1 rounded opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none whitespace-nowrap z-50 shadow-lg">업로드</div>
|
||||
<ArrowRight size={24} strokeWidth={2.5} />
|
||||
</button>
|
||||
<button
|
||||
onClick={handleDownload}
|
||||
disabled={selectedRemoteIds.size === 0 || !connection.connected}
|
||||
className="p-3 bg-white border border-slate-300 shadow-sm rounded hover:bg-green-50 hover:text-green-600 hover:border-green-300 transition-colors disabled:opacity-30 disabled:cursor-not-allowed text-slate-400 group relative"
|
||||
>
|
||||
<div className="absolute left-1/2 -top-8 -translate-x-1/2 bg-slate-800 text-white text-xs px-2 py-1 rounded opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none whitespace-nowrap z-50 shadow-lg">다운로드</div>
|
||||
<ArrowLeft size={24} strokeWidth={2.5} />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Remote Pane */}
|
||||
<div className="flex-1 min-h-0 flex flex-col min-w-[300px]">
|
||||
<FilePane
|
||||
title={`리모트 사이트: ${connection.host}`}
|
||||
icon="remote"
|
||||
path={remote.path}
|
||||
files={remote.files}
|
||||
isLoading={remote.isLoading}
|
||||
onNavigate={handleRemoteNavigate}
|
||||
onNavigateUp={() => handleRemoteNavigate(remote.path.split('/').slice(0, -1).join('/') || '/')}
|
||||
onSelectionChange={setSelectedRemoteIds}
|
||||
selectedIds={selectedRemoteIds}
|
||||
connected={connection.connected}
|
||||
onCreateFolder={() => initiateCreateFolder(false)}
|
||||
onDelete={() => initiateDelete(false)}
|
||||
onRename={() => initiateRename(false)}
|
||||
title={`리모트 사이트: ${connection.host}`}
|
||||
icon="remote"
|
||||
path={remote.path}
|
||||
files={remote.files}
|
||||
isLoading={remote.isLoading}
|
||||
onNavigate={handleRemoteNavigate}
|
||||
onNavigateUp={() => handleRemoteNavigate(remote.path.split('/').slice(0, -1).join('/') || '/')}
|
||||
onSelectionChange={setSelectedRemoteIds}
|
||||
selectedIds={selectedRemoteIds}
|
||||
connected={connection.connected}
|
||||
onCreateFolder={() => initiateCreateFolder(false)}
|
||||
onDelete={() => initiateDelete(false)}
|
||||
onRename={() => initiateRename(false)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -846,8 +857,8 @@ wss.on('connection', (ws) => {
|
||||
<footer className="bg-white border-t border-slate-200 px-3 py-1 text-[10px] text-slate-500 flex justify-between shadow-[0_-2px_10px_rgba(0,0,0,0.02)]">
|
||||
<span>WebZilla v1.1.0 - React/TypeScript Demo</span>
|
||||
<div className="flex gap-4">
|
||||
<span>Server: {connection.connected ? 'Connected' : 'Disconnected'}</span>
|
||||
<span>Protocol: {connection.protocol.toUpperCase()} {connection.passive ? '(Passive)' : ''}</span>
|
||||
<span>Server: {connection.connected ? 'Connected' : 'Disconnected'}</span>
|
||||
<span>Protocol: {connection.protocol.toUpperCase()} {connection.passive ? '(Passive)' : ''}</span>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
@@ -43,9 +43,9 @@ if (!fs.existsSync(configDir)) {
|
||||
console.log(`📂 설정 폴더 로드됨: ${configDir}`);
|
||||
}
|
||||
|
||||
const wss = new WebSocket.Server({ port: 8080 });
|
||||
const wss = new WebSocket.Server({ port: 8090 });
|
||||
|
||||
console.log("🚀 WebZilla FTP Proxy Server가 ws://localhost:8080 에서 실행 중입니다.");
|
||||
console.log("🚀 WebZilla FTP Proxy Server가 ws://localhost:8090 에서 실행 중입니다.");
|
||||
|
||||
wss.on('connection', (ws) => {
|
||||
console.log("클라이언트가 접속했습니다.");
|
||||
74
components/ConnectionHelpModal.tsx
Normal file
74
components/ConnectionHelpModal.tsx
Normal file
@@ -0,0 +1,74 @@
|
||||
import React from 'react';
|
||||
import { ShieldAlert, ExternalLink, X, AlertTriangle } from 'lucide-react';
|
||||
|
||||
interface ConnectionHelpModalProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
const ConnectionHelpModal: React.FC<ConnectionHelpModalProps> = ({ isOpen, onClose }) => {
|
||||
if (!isOpen) return null;
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm p-4">
|
||||
<div className="bg-white rounded-lg shadow-2xl max-w-lg w-full overflow-hidden border border-red-100">
|
||||
|
||||
{/* Header */}
|
||||
<div className="bg-red-50 p-4 border-b border-red-100 flex items-center justify-between">
|
||||
<div className="flex items-center gap-2 text-red-700">
|
||||
<ShieldAlert size={20} />
|
||||
<h2 className="font-bold text-lg">백엔드 연결 실패</h2>
|
||||
</div>
|
||||
<button onClick={onClose} className="text-red-400 hover:text-red-600 transition-colors">
|
||||
<X size={20} />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Content */}
|
||||
<div className="p-6 space-y-4">
|
||||
<p className="text-slate-700 text-sm leading-relaxed">
|
||||
현재 <strong>HTTPS(보안)</strong> 사이트에서 <strong>로컬 백엔드(ws://localhost)</strong>로 접속을 시도하고 있습니다.
|
||||
브라우저 보안 정책(Mixed Content)으로 인해 연결이 차단되었을 가능성이 높습니다.
|
||||
</p>
|
||||
|
||||
<div className="bg-yellow-50 border border-yellow-200 rounded-lg p-4 space-y-2">
|
||||
<h3 className="font-semibold text-yellow-800 flex items-center gap-2 text-sm">
|
||||
<AlertTriangle size={16} />
|
||||
해결 방법 (Chrome/Edge)
|
||||
</h3>
|
||||
<ol className="list-decimal list-inside text-xs text-yellow-800 space-y-1.5 ml-1">
|
||||
<li>
|
||||
새 탭을 열고 주소창에 아래 주소를 입력하세요:
|
||||
<div className="bg-white border border-yellow-300 rounded px-2 py-1 mt-1 font-mono text-slate-600 select-all cursor-pointer hover:bg-slate-50" onClick={(e) => navigator.clipboard.writeText(e.currentTarget.textContent || '')}>
|
||||
chrome://flags/#allow-insecure-localhost
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<strong>Allow invalid certificates for resources from localhost</strong> 항목을 <span className="font-bold text-green-600">Enabled</span>로 변경하세요.
|
||||
</li>
|
||||
<li>
|
||||
브라우저 하단의 <strong>Relaunch</strong> 버튼을 눌러 재시작하세요.
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
<p className="text-xs text-slate-500 text-center">
|
||||
설정을 변경한 후에도 연결이 안 된다면 백엔드 프로그램이 실행 중인지 확인해주세요.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Footer */}
|
||||
<div className="p-4 bg-slate-50 border-t border-slate-200 flex justify-end">
|
||||
<button
|
||||
onClick={onClose}
|
||||
className="px-4 py-2 bg-white hover:bg-slate-100 text-slate-700 border border-slate-300 rounded text-sm transition-colors font-medium shadow-sm"
|
||||
>
|
||||
닫기
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ConnectionHelpModal;
|
||||
@@ -22,7 +22,7 @@ const ftp = require('basic-ftp');
|
||||
const SftpClient = require('ssh2-sftp-client');
|
||||
// ... imports
|
||||
|
||||
const wss = new WebSocket.Server({ port: 8080 });
|
||||
const wss = new WebSocket.Server({ port: 8090 });
|
||||
|
||||
wss.on('connection', (ws) => {
|
||||
let ftpClient = new ftp.Client();
|
||||
@@ -80,17 +80,15 @@ wss.on('connection', (ws) => {
|
||||
<div className="flex border-b border-slate-200 px-4">
|
||||
<button
|
||||
onClick={() => setActiveTab('arch')}
|
||||
className={`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${
|
||||
activeTab === 'arch' ? 'border-blue-500 text-blue-600' : 'border-transparent text-slate-500 hover:text-slate-700'
|
||||
}`}
|
||||
className={`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${activeTab === 'arch' ? 'border-blue-500 text-blue-600' : 'border-transparent text-slate-500 hover:text-slate-700'
|
||||
}`}
|
||||
>
|
||||
시스템 구조
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setActiveTab('code')}
|
||||
className={`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${
|
||||
activeTab === 'code' ? 'border-blue-500 text-blue-600' : 'border-transparent text-slate-500 hover:text-slate-700'
|
||||
}`}
|
||||
className={`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${activeTab === 'code' ? 'border-blue-500 text-blue-600' : 'border-transparent text-slate-500 hover:text-slate-700'
|
||||
}`}
|
||||
>
|
||||
백엔드 코드 (Preview)
|
||||
</button>
|
||||
@@ -110,9 +108,9 @@ wss.on('connection', (ws) => {
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col items-center gap-1 flex-1">
|
||||
<span className="text-[10px] text-green-600 bg-green-100 px-2 py-0.5 rounded border border-green-200 font-mono">WebSocket</span>
|
||||
<ArrowLeftRight className="text-slate-400 w-full animate-pulse" />
|
||||
<span className="text-xs text-slate-400">JSON Protocol</span>
|
||||
<span className="text-[10px] text-green-600 bg-green-100 px-2 py-0.5 rounded border border-green-200 font-mono">WebSocket</span>
|
||||
<ArrowLeftRight className="text-slate-400 w-full animate-pulse" />
|
||||
<span className="text-xs text-slate-400">JSON Protocol</span>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col items-center gap-2 relative">
|
||||
@@ -125,15 +123,15 @@ wss.on('connection', (ws) => {
|
||||
<div className="absolute -bottom-16 left-1/2 -translate-x-1/2 flex flex-col items-center">
|
||||
<div className="h-6 w-px border-l border-dashed border-slate-300"></div>
|
||||
<div className="bg-white border border-slate-300 px-2 py-1 rounded text-[10px] flex items-center gap-1 text-yellow-600 shadow-sm">
|
||||
<HardDrive size={10} />
|
||||
AppData/Config
|
||||
<HardDrive size={10} />
|
||||
AppData/Config
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col items-center gap-1 flex-1">
|
||||
<span className="text-[10px] text-orange-600 bg-orange-100 px-2 py-0.5 rounded border border-orange-200 font-mono">FTP / SFTP</span>
|
||||
<ArrowLeftRight className="text-slate-400 w-full" />
|
||||
<span className="text-[10px] text-orange-600 bg-orange-100 px-2 py-0.5 rounded border border-orange-200 font-mono">FTP / SFTP</span>
|
||||
<ArrowLeftRight className="text-slate-400 w-full" />
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col items-center gap-2">
|
||||
@@ -156,16 +154,16 @@ wss.on('connection', (ws) => {
|
||||
) : (
|
||||
<div className="space-y-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<p className="text-sm text-slate-500">
|
||||
SFTP와 FTP를 모두 지원하는 프록시 서버 코드 미리보기입니다.
|
||||
</p>
|
||||
<button
|
||||
onClick={handleCopy}
|
||||
className="flex items-center gap-1.5 px-3 py-1.5 bg-blue-600 hover:bg-blue-500 text-white rounded text-xs font-medium transition-colors shadow-sm"
|
||||
>
|
||||
{copied ? <Check size={14} /> : <Copy size={14} />}
|
||||
{copied ? '복사됨' : '코드 복사'}
|
||||
</button>
|
||||
<p className="text-sm text-slate-500">
|
||||
SFTP와 FTP를 모두 지원하는 프록시 서버 코드 미리보기입니다.
|
||||
</p>
|
||||
<button
|
||||
onClick={handleCopy}
|
||||
className="flex items-center gap-1.5 px-3 py-1.5 bg-blue-600 hover:bg-blue-500 text-white rounded text-xs font-medium transition-colors shadow-sm"
|
||||
>
|
||||
{copied ? <Check size={14} /> : <Copy size={14} />}
|
||||
{copied ? '복사됨' : '코드 복사'}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="relative group">
|
||||
@@ -182,9 +180,9 @@ wss.on('connection', (ws) => {
|
||||
</div>
|
||||
|
||||
<div className="p-4 border-t border-slate-200 bg-slate-50 rounded-b-lg flex justify-end">
|
||||
<button onClick={onClose} className="px-4 py-2 bg-white hover:bg-slate-50 border border-slate-300 text-slate-600 rounded text-sm transition-colors shadow-sm">
|
||||
닫기
|
||||
</button>
|
||||
<button onClick={onClose} className="px-4 py-2 bg-white hover:bg-slate-50 border border-slate-300 text-slate-600 rounded text-sm transition-colors shadow-sm">
|
||||
닫기
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
1
make.bat
Normal file
1
make.bat
Normal file
@@ -0,0 +1 @@
|
||||
pkg backend_proxy.cjs --targets node18-win-x64 --output webftp-backend.exe
|
||||
2730
package-lock.json
generated
Normal file
2730
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -6,13 +6,16 @@
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview"
|
||||
"preview": "vite preview",
|
||||
"proxy": "node backend_proxy.cjs"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "^19.2.3",
|
||||
"@google/genai": "^1.37.0",
|
||||
"basic-ftp": "^5.1.0",
|
||||
"lucide-react": "^0.562.0",
|
||||
"react-dom": "^19.2.3"
|
||||
"react": "^19.2.3",
|
||||
"react-dom": "^19.2.3",
|
||||
"ws": "^8.19.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.14.0",
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
import { GoogleGenAI, Type } from "@google/genai";
|
||||
import { FileItem, FileType } from "../types";
|
||||
|
||||
const ai = new GoogleGenAI({ apiKey: process.env.API_KEY || '' });
|
||||
|
||||
export const generateRemoteFileList = async (host: string, path: string): Promise<FileItem[]> => {
|
||||
try {
|
||||
const model = 'gemini-2.5-flash-latest';
|
||||
const prompt = `
|
||||
You are simulating an FTP server file listing for the host: "${host}" at path: "${path}".
|
||||
Generate a realistic list of 8-15 files and folders that might exist on this specific type of server.
|
||||
If the host sounds corporate, use corporate files. If it sounds like a game server, use game files.
|
||||
If it sounds like NASA, use space data files.
|
||||
|
||||
Return a JSON array of objects.
|
||||
`;
|
||||
|
||||
const response = await ai.models.generateContent({
|
||||
model: model,
|
||||
contents: prompt,
|
||||
config: {
|
||||
responseMimeType: "application/json",
|
||||
responseSchema: {
|
||||
type: Type.ARRAY,
|
||||
items: {
|
||||
type: Type.OBJECT,
|
||||
properties: {
|
||||
name: { type: Type.STRING },
|
||||
type: { type: Type.STRING, enum: ["FILE", "FOLDER"] },
|
||||
size: { type: Type.INTEGER, description: "Size in bytes. Folders should be 0 or 4096." },
|
||||
},
|
||||
required: ["name", "type", "size"]
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const data = JSON.parse(response.text || '[]');
|
||||
|
||||
return data.map((item: any, index: number) => ({
|
||||
id: `gen-${Date.now()}-${index}`,
|
||||
name: item.name,
|
||||
type: item.type === 'FOLDER' ? FileType.FOLDER : FileType.FILE,
|
||||
size: item.size,
|
||||
date: new Date(Date.now() - Math.floor(Math.random() * 10000000000)).toISOString(),
|
||||
permissions: item.type === 'FOLDER' ? 'drwxr-xr-x' : '-rw-r--r--'
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error("Gemini generation failed", error);
|
||||
// Fallback if API fails
|
||||
return [
|
||||
{ id: 'err1', name: 'connection_retry.log', type: FileType.FILE, size: 1024, date: new Date().toISOString(), permissions: '-rw-r--r--' },
|
||||
{ id: 'err2', name: 'backup', type: FileType.FOLDER, size: 0, date: new Date().toISOString(), permissions: 'drwxr-xr-x' }
|
||||
];
|
||||
}
|
||||
};
|
||||
|
||||
export const generateServerMessage = async (host: string): Promise<string> => {
|
||||
try {
|
||||
const response = await ai.models.generateContent({
|
||||
model: 'gemini-3-flash-preview',
|
||||
contents: `Write a short, single-line FTP welcome message (220 Service ready) for a server named "${host}". Make it sound authentic to the domain info.`,
|
||||
});
|
||||
return response.text?.trim() || `220 ${host} FTP Server ready.`;
|
||||
} catch (e) {
|
||||
return `220 ${host} FTP Server ready.`;
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
import { FileItem, FileType } from '../types';
|
||||
|
||||
export const generateLocalFiles = (path: string): FileItem[] => {
|
||||
// Static mock data for local machine (Korean localized)
|
||||
const baseFiles: FileItem[] = [
|
||||
{ id: '1', name: '내 문서', type: FileType.FOLDER, size: 0, date: new Date().toISOString(), permissions: 'drwxr-xr-x' },
|
||||
{ id: '2', name: '다운로드', type: FileType.FOLDER, size: 0, date: new Date().toISOString(), permissions: 'drwxr-xr-x' },
|
||||
{ id: '3', name: '바탕화면', type: FileType.FOLDER, size: 0, date: new Date().toISOString(), permissions: 'drwxr-xr-x' },
|
||||
{ id: '4', name: '프로젝트_기획안.pdf', type: FileType.FILE, size: 2450000, date: new Date().toISOString(), permissions: '-rw-r--r--' },
|
||||
{ id: '5', name: '메모.txt', type: FileType.FILE, size: 1024, date: new Date().toISOString(), permissions: '-rw-r--r--' },
|
||||
{ id: '6', name: '프로필_사진.png', type: FileType.FILE, size: 540000, date: new Date().toISOString(), permissions: '-rw-r--r--' },
|
||||
{ id: '7', name: '설치파일.exe', type: FileType.FILE, size: 45000000, date: new Date().toISOString(), permissions: '-rwxr-xr-x' },
|
||||
];
|
||||
|
||||
if (path === '/') return baseFiles;
|
||||
|
||||
// Return random files for subdirectories to simulate depth
|
||||
return [
|
||||
{ id: `sub-${Math.random()}`, name: '아카이브', type: FileType.FOLDER, size: 0, date: new Date().toISOString(), permissions: 'drwxr-xr-x' },
|
||||
{ id: `sub-${Math.random()}`, name: '데이터_백업.json', type: FileType.FILE, size: Math.floor(Math.random() * 10000), date: new Date().toISOString(), permissions: '-rw-r--r--' }
|
||||
];
|
||||
};
|
||||
|
||||
// We will use Gemini to generate the remote ones dynamically, but here is a fallback
|
||||
export const generateFallbackRemoteFiles = (): FileItem[] => {
|
||||
return [
|
||||
{ id: 'r1', name: 'public_html', type: FileType.FOLDER, size: 0, date: new Date().toISOString(), permissions: 'drwxr-xr-x' },
|
||||
{ id: 'r2', name: 'www', type: FileType.FOLDER, size: 0, date: new Date().toISOString(), permissions: 'drwxr-xr-x' },
|
||||
{ id: 'r3', name: '.htaccess', type: FileType.FILE, size: 245, date: new Date().toISOString(), permissions: '-rw-r--r--' },
|
||||
{ id: 'r4', name: 'error_log', type: FileType.FILE, size: 14500, date: new Date().toISOString(), permissions: '-rw-r--r--' },
|
||||
];
|
||||
};
|
||||
BIN
webftp-backend.exe
Normal file
BIN
webftp-backend.exe
Normal file
Binary file not shown.
Reference in New Issue
Block a user