Compare commits

...

3 Commits

9 changed files with 1291 additions and 964 deletions

712
App.tsx

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +1,12 @@
/**
* WebZilla 백엔드 프록시 서버 (Node.js) v1.1
* WebZilla 백엔드 프록시 서버 (Node.js) v1.2
*
* 기능 추가:
* - 로컬 파일 시스템 접근 (fs)
* - 설정 데이터 저장 (AppData/Roaming 또는 ~/.config)
* 기능:
* - WebSocket Proxy (Port: 8090)
* - FTP/SFTP 지원
* - 로컬 파일 시스템 탐색 (LOCAL_LIST)
* - 설정 저장 (AppData)
* - **NEW**: 포트 충돌 자동 감지 및 프로세스 종료 기능
*/
const WebSocket = require('ws');
@@ -11,45 +14,48 @@ const ftp = require('basic-ftp');
const fs = require('fs');
const path = require('path');
const os = require('os');
const { exec } = require('child_process');
const readline = require('readline');
// --- 로컬 저장소 경로 설정 (AppData 구현) ---
function getConfigDir() {
const homedir = os.homedir();
// Windows: C:\Users\User\AppData\Roaming\WebZilla
if (process.platform === 'win32') {
return path.join(process.env.APPDATA || path.join(homedir, 'AppData', 'Roaming'), 'WebZilla');
}
// macOS: ~/Library/Application Support/WebZilla
else if (process.platform === 'darwin') {
} else if (process.platform === 'darwin') {
return path.join(homedir, 'Library', 'Application Support', 'WebZilla');
}
// Linux: ~/.config/webzilla
else {
} else {
return path.join(homedir, '.config', 'webzilla');
}
}
// 앱 시작 시 설정 디렉토리 생성
const configDir = getConfigDir();
if (!fs.existsSync(configDir)) {
try {
fs.mkdirSync(configDir, { recursive: true });
console.log(`📂 설정 폴더가 생성되었습니다: ${configDir}`);
} catch (e) {
console.error(`❌ 설정 폴더 생성 실패: ${e.message}`);
try { fs.mkdirSync(configDir, { recursive: true }); } catch (e) { }
}
const PORT = 8090;
// --- 서버 시작 함수 (재시도 로직 포함) ---
function startServer() {
const wss = new WebSocket.Server({ port: PORT });
wss.on('error', (err) => {
if (err.code === 'EADDRINUSE') {
console.error(`\n❌ 포트 ${PORT}이(가) 이미 사용 중입니다.`);
handlePortConflict();
} else {
console.log(`📂 설정 폴더 로드됨: ${configDir}`);
console.error("❌ 서버 오류:", err);
process.exit(1);
}
});
const wss = new WebSocket.Server({ port: 8090 });
console.log("🚀 WebZilla FTP Proxy Server가 ws://localhost:8090 에서 실행 중입니다.");
wss.on('listening', () => {
console.log(`\n🚀 WebZilla FTP Proxy Server가 ws://localhost:${PORT} 에서 실행 중입니다.`);
console.log(`📂 설정 폴더: ${configDir}`);
});
wss.on('connection', (ws) => {
console.log("클라이언트가 접속했습니다.");
const client = new ftp.Client();
ws.on('message', async (message) => {
@@ -57,7 +63,6 @@ wss.on('connection', (ws) => {
const data = JSON.parse(message);
switch (data.command) {
// --- FTP 연결 관련 ---
case 'CONNECT':
console.log(`FTP 연결 시도: ${data.user}@${data.host}:${data.port}`);
try {
@@ -80,9 +85,9 @@ wss.on('connection', (ws) => {
ws.send(JSON.stringify({ type: 'error', message: 'FTP 연결이 끊어져 있습니다.' }));
return;
}
try {
const listPath = data.path || '/';
const list = await client.list(listPath);
const files = list.map(f => ({
id: `ftp-${Date.now()}-${Math.random()}`,
name: f.name,
@@ -91,8 +96,41 @@ wss.on('connection', (ws) => {
date: f.rawModifiedAt || new Date().toISOString(),
permissions: '-'
}));
ws.send(JSON.stringify({ type: 'list', files, path: listPath }));
} catch (err) {
ws.send(JSON.stringify({ type: 'error', message: err.message }));
}
break;
case 'MKD':
if (client.closed) return;
try {
await client.ensureDir(data.path);
ws.send(JSON.stringify({ type: 'success', message: '폴더 생성 완료' }));
} catch (err) {
ws.send(JSON.stringify({ type: 'error', message: err.message }));
}
break;
case 'DELE':
if (client.closed) return;
try {
if (data.isFolder) await client.removeDir(data.path);
else await client.remove(data.path);
ws.send(JSON.stringify({ type: 'success', message: '삭제 완료' }));
} catch (err) {
ws.send(JSON.stringify({ type: 'error', message: err.message }));
}
break;
case 'RENAME':
if (client.closed) return;
try {
await client.rename(data.from, data.to);
ws.send(JSON.stringify({ type: 'success', message: '이름 변경 완료' }));
} catch (err) {
ws.send(JSON.stringify({ type: 'error', message: err.message }));
}
break;
case 'DISCONNECT':
@@ -100,20 +138,25 @@ wss.on('connection', (ws) => {
ws.send(JSON.stringify({ type: 'status', status: 'disconnected', message: '연결이 종료되었습니다.' }));
break;
// --- 로컬 설정 저장 관련 (새로 추가됨) ---
case 'SAVE_SITE':
// 예: 사이트 정보를 JSON 파일로 저장
// Deprecated in favor of SAVE_SITES for full sync, but kept for compatibility
try {
const sitesFile = path.join(configDir, 'sites.json');
let sites = [];
if (fs.existsSync(sitesFile)) {
sites = JSON.parse(fs.readFileSync(sitesFile, 'utf8'));
}
if (fs.existsSync(sitesFile)) sites = JSON.parse(fs.readFileSync(sitesFile, 'utf8'));
sites.push(data.siteInfo);
fs.writeFileSync(sitesFile, JSON.stringify(sites, null, 2));
ws.send(JSON.stringify({ type: 'success', message: '사이트가 추가되었습니다.' }));
} catch (err) {
ws.send(JSON.stringify({ type: 'error', message: `저장 실패: ${err.message}` }));
}
break;
console.log(`💾 사이트 정보 저장됨: ${data.siteInfo.host}`);
ws.send(JSON.stringify({ type: 'success', message: '사이트 정보가 로컬(AppData)에 저장되었습니다.' }));
case 'SAVE_SITES':
try {
const sitesFile = path.join(configDir, 'sites.json');
fs.writeFileSync(sitesFile, JSON.stringify(data.sites, null, 2));
ws.send(JSON.stringify({ type: 'success', message: '사이트 목록이 저장되었습니다.' }));
} catch (err) {
ws.send(JSON.stringify({ type: 'error', message: `저장 실패: ${err.message}` }));
}
@@ -133,8 +176,66 @@ wss.on('connection', (ws) => {
}
break;
default:
console.log(`알 수 없는 명령: ${data.command}`);
case 'LOCAL_LIST':
try {
const targetPath = data.path || os.homedir();
const entries = fs.readdirSync(targetPath, { withFileTypes: true });
const files = entries.map(dirent => {
let size = 0;
let date = new Date().toISOString();
try {
const stats = fs.statSync(path.join(targetPath, dirent.name));
size = stats.size;
date = stats.mtime.toISOString();
} catch (e) { }
return {
id: `local-${Math.random()}`,
name: dirent.name,
type: dirent.isDirectory() ? 'FOLDER' : 'FILE',
size: size,
date: date,
permissions: '-'
};
});
ws.send(JSON.stringify({ type: 'local_list', files, path: targetPath }));
} catch (err) {
ws.send(JSON.stringify({ type: 'error', message: `로컬 목록 실패: ${err.message}` }));
}
break;
case 'LOCAL_MKD':
try {
if (!fs.existsSync(data.path)) {
fs.mkdirSync(data.path, { recursive: true });
ws.send(JSON.stringify({ type: 'success', message: '로컬 폴더 생성 완료' }));
} else {
ws.send(JSON.stringify({ type: 'error', message: '이미 존재하는 폴더입니다.' }));
}
} catch (err) {
ws.send(JSON.stringify({ type: 'error', message: `로컬 폴더 생성 실패: ${err.message}` }));
}
break;
case 'LOCAL_RENAME':
try {
fs.renameSync(data.from, data.to);
ws.send(JSON.stringify({ type: 'success', message: '이름 변경 완료' }));
} catch (err) {
ws.send(JSON.stringify({ type: 'error', message: `이름 변경 실패: ${err.message}` }));
}
break;
case 'LOCAL_DELE':
try {
fs.rmSync(data.path, { recursive: true, force: true });
ws.send(JSON.stringify({ type: 'success', message: '삭제 완료' }));
} catch (err) {
ws.send(JSON.stringify({ type: 'error', message: `삭제 실패: ${err.message}` }));
}
break;
}
} catch (err) {
console.error("오류 발생:", err);
@@ -143,7 +244,66 @@ wss.on('connection', (ws) => {
});
ws.on('close', () => {
console.log("클라이언트 접속 종료");
client.close();
});
});
}
// --- 포트 충돌 처리 ---
function handlePortConflict() {
// Windows: netstat -ano | findstr :8090
// Mac/Linux: lsof -i :8090
if (process.platform === 'win32') {
exec(`netstat -ano | findstr :${PORT}`, (err, stdout, stderr) => {
if (err || !stdout) {
console.log("실행 중인 프로세스를 찾지 못했습니다. 수동으로 확인해주세요.");
process.exit(1);
return;
}
// Parse PID (Last token in line)
const lines = stdout.trim().split('\n');
const line = lines[0].trim();
const parts = line.split(/\s+/);
const pid = parts[parts.length - 1];
askToKill(pid);
});
} else {
// Simple fallback/notification for non-Windows (or implement lsof)
console.log(`Port ${PORT} is in use. Please kill the process manually.`);
process.exit(1);
}
}
function askToKill(pid) {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
console.log(`⚠️ PID [${pid}] 프로세스가 포트 ${PORT}를 사용 중입니다.`);
rl.question(`❓ 해당 프로세스를 종료하고 서버를 시작하시겠습니까? (Y/n): `, (answer) => {
const ans = answer.trim().toLowerCase();
if (ans === '' || ans === 'y' || ans === 'yes') {
console.log(`🔫 PID ${pid} 종료 시도 중...`);
exec(`taskkill /F /PID ${pid}`, (killErr) => {
if (killErr) {
console.error(`❌ 종료 실패: ${killErr.message}`);
process.exit(1);
} else {
console.log("✅ 프로세스가 종료되었습니다. 서버를 다시 시작합니다...");
rl.close();
setTimeout(startServer, 1000); // 1초 후 재시작
}
});
} else {
console.log("🚫 작업을 취소했습니다.");
process.exit(0);
}
});
}
// 초기 실행
startServer();

View File

@@ -9,15 +9,31 @@ interface CreateFolderModalProps {
}
export const CreateFolderModal: React.FC<CreateFolderModalProps> = ({ isOpen, onClose, onConfirm }) => {
const [folderName, setFolderName] = useState('새 폴더');
const [folderName, setFolderName] = useState('');
const [error, setError] = useState('');
useEffect(() => {
if (isOpen) {
setFolderName('새 폴더');
setFolderName('');
setError('');
// Auto focus hack
setTimeout(() => document.getElementById('new-folder-input')?.focus(), 50);
const handleKeyDown = (e: KeyboardEvent) => {
if (e.key === 'Escape') onClose();
};
window.addEventListener('keydown', handleKeyDown);
return () => window.removeEventListener('keydown', handleKeyDown);
}
}, [isOpen]);
}, [isOpen, onClose]);
const handleConfirm = () => {
if (!folderName.trim()) {
setError('폴더 이름을 입력해주세요.');
return;
}
onConfirm(folderName);
};
if (!isOpen) return null;
@@ -37,14 +53,15 @@ export const CreateFolderModal: React.FC<CreateFolderModalProps> = ({ isOpen, on
id="new-folder-input"
type="text"
value={folderName}
onChange={(e) => setFolderName(e.target.value)}
onKeyDown={(e) => e.key === 'Enter' && onConfirm(folderName)}
className="w-full bg-white border border-slate-300 rounded px-3 py-2 text-sm text-slate-800 focus:border-blue-500 focus:outline-none"
onChange={(e) => { setFolderName(e.target.value); setError(''); }}
onKeyDown={(e) => e.key === 'Enter' && handleConfirm()}
className={`w-full bg-white border rounded px-3 py-2 text-sm text-slate-800 focus:outline-none ${error ? 'border-red-500 focus:border-red-500' : 'border-slate-300 focus:border-blue-500'}`}
/>
{error && <p className="text-xs text-red-500 mt-1">{error}</p>}
</div>
<div className="flex justify-end gap-2">
<button onClick={onClose} className="px-3 py-1.5 text-xs text-slate-600 hover:text-slate-900 bg-slate-100 hover:bg-slate-200 rounded"></button>
<button onClick={() => onConfirm(folderName)} className="px-3 py-1.5 text-xs bg-blue-600 hover:bg-blue-500 text-white rounded shadow-md shadow-blue-500/20"></button>
<button onClick={handleConfirm} className="px-3 py-1.5 text-xs bg-blue-600 hover:bg-blue-500 text-white rounded shadow-md shadow-blue-500/20"></button>
</div>
</div>
</div>
@@ -62,13 +79,33 @@ interface RenameModalProps {
export const RenameModal: React.FC<RenameModalProps> = ({ isOpen, currentName, onClose, onConfirm }) => {
const [newName, setNewName] = useState('');
const [error, setError] = useState('');
useEffect(() => {
if (isOpen) {
setNewName(currentName);
setError('');
setTimeout(() => document.getElementById('rename-input')?.focus(), 50);
const handleKeyDown = (e: KeyboardEvent) => {
if (e.key === 'Escape') onClose();
};
window.addEventListener('keydown', handleKeyDown);
return () => window.removeEventListener('keydown', handleKeyDown);
}
}, [isOpen, currentName]);
}, [isOpen, currentName, onClose]);
const handleConfirm = () => {
if (!newName.trim()) {
setError('새 이름을 입력해주세요.');
return;
}
if (newName.trim() === currentName) {
setError('변경된 내용이 없습니다.');
return;
}
onConfirm(newName);
};
if (!isOpen) return null;
@@ -91,14 +128,15 @@ export const RenameModal: React.FC<RenameModalProps> = ({ isOpen, currentName, o
id="rename-input"
type="text"
value={newName}
onChange={(e) => setNewName(e.target.value)}
onKeyDown={(e) => e.key === 'Enter' && onConfirm(newName)}
className="w-full bg-white border border-slate-300 rounded px-3 py-2 text-sm text-slate-800 focus:border-blue-500 focus:outline-none"
onChange={(e) => { setNewName(e.target.value); setError(''); }}
onKeyDown={(e) => e.key === 'Enter' && handleConfirm()}
className={`w-full bg-white border rounded px-3 py-2 text-sm text-slate-800 focus:outline-none ${error ? 'border-red-500 focus:border-red-500' : 'border-slate-300 focus:border-blue-500'}`}
/>
{error && <p className="text-xs text-red-500 mt-1">{error}</p>}
</div>
<div className="flex justify-end gap-2">
<button onClick={onClose} className="px-3 py-1.5 text-xs text-slate-600 hover:text-slate-900 bg-slate-100 hover:bg-slate-200 rounded"></button>
<button onClick={() => onConfirm(newName)} className="px-3 py-1.5 text-xs bg-blue-600 hover:bg-blue-500 text-white rounded shadow-md shadow-blue-500/20"></button>
<button onClick={handleConfirm} className="px-3 py-1.5 text-xs bg-blue-600 hover:bg-blue-500 text-white rounded shadow-md shadow-blue-500/20"></button>
</div>
</div>
</div>
@@ -116,6 +154,16 @@ interface DeleteModalProps {
}
export const DeleteModal: React.FC<DeleteModalProps> = ({ isOpen, fileCount, fileNames, onClose, onConfirm }) => {
useEffect(() => {
if (isOpen) {
const handleKeyDown = (e: KeyboardEvent) => {
if (e.key === 'Escape') onClose();
};
window.addEventListener('keydown', handleKeyDown);
return () => window.removeEventListener('keydown', handleKeyDown);
}
}, [isOpen, onClose]);
if (!isOpen) return null;
return (

View File

@@ -15,6 +15,7 @@ interface FilePaneProps {
onSelectionChange: (ids: Set<string>) => void;
selectedIds: Set<string>;
connected?: boolean;
refreshKey?: number;
onCreateFolder?: () => void;
onDelete?: () => void;
onRename?: () => void;
@@ -31,12 +32,28 @@ const FilePane: React.FC<FilePaneProps> = ({
onSelectionChange,
selectedIds,
connected = true,
refreshKey,
onCreateFolder,
onDelete,
onRename
}) => {
const [searchTerm, setSearchTerm] = useState('');
const [lastClickedId, setLastClickedId] = useState<string | null>(null);
const [pathInput, setPathInput] = useState(path);
// Sync path input when prop changes OR refreshKey updates
React.useEffect(() => {
setPathInput(path);
}, [path, refreshKey]);
const handlePathKeyDown = (e: React.KeyboardEvent) => {
if (e.key === 'Enter') {
onNavigate(pathInput);
} else if (e.key === 'Escape') {
setPathInput(path); // Revert
(e.target as HTMLInputElement).blur();
}
};
// Filter files based on search term
const displayFiles = useMemo(() => {
@@ -82,16 +99,23 @@ const FilePane: React.FC<FilePaneProps> = ({
};
return (
<div className="flex flex-col h-full bg-white border border-slate-300 rounded-lg overflow-hidden shadow-sm">
<div className={`flex flex-col h-full bg-white border border-slate-300 rounded-lg overflow-hidden shadow-sm transition-all duration-300 ${!connected ? 'opacity-60 grayscale-[0.5] pointer-events-none' : ''}`}>
{/* Header */}
<div className="bg-slate-50 p-2 border-b border-slate-200 flex items-center justify-between">
<div className="flex items-center gap-2 text-slate-700 font-semibold text-sm">
<div className="flex items-center gap-2 text-slate-700 font-semibold text-sm shrink-0">
{icon === 'local' ? <Monitor size={16} /> : <Server size={16} />}
<span>{title}</span>
</div>
<div className="flex items-center gap-2 bg-white px-2 py-1 rounded border border-slate-200 text-xs text-slate-500 flex-1 ml-4 truncate shadow-sm">
<span className="text-slate-400">:</span>
<span className="font-mono text-slate-700 select-all">{path}</span>
<div className="flex items-center gap-2 bg-white px-2 py-0.5 rounded border border-slate-200 text-xs text-slate-500 flex-1 ml-4 shadow-sm focus-within:border-blue-500 focus-within:ring-1 focus-within:ring-blue-500 transition-all">
<span className="text-slate-400 shrink-0">:</span>
<input
type="text"
value={pathInput}
onChange={(e) => setPathInput(e.target.value)}
onKeyDown={handlePathKeyDown}
className="font-mono text-slate-700 w-full outline-none text-xs py-1"
spellCheck={false}
/>
</div>
</div>
@@ -203,8 +227,7 @@ const FilePane: React.FC<FilePaneProps> = ({
setSearchTerm(''); // Clear search on navigate
}
}}
className={`cursor-pointer border-b border-slate-50 group select-none ${
isSelected
className={`cursor-pointer border-b border-slate-50 group select-none ${isSelected
? 'bg-blue-100 text-blue-900 border-blue-200'
: 'text-slate-700 hover:bg-slate-50'
}`}

228
components/HelpModal.tsx Normal file
View File

@@ -0,0 +1,228 @@
import React, { useState, useEffect } from 'react';
import { X, HelpCircle, Server, Folder, FileText, Settings, Wifi, Terminal } from 'lucide-react';
interface HelpModalProps {
isOpen: boolean;
onClose: () => void;
initialTab?: 'sites' | 'connection' | 'files' | 'backend';
}
const HelpModal: React.FC<HelpModalProps> = ({ isOpen, onClose, initialTab }) => {
const [activeTab, setActiveTab] = useState<'sites' | 'connection' | 'files' | 'backend'>('sites');
useEffect(() => {
if (isOpen && initialTab) {
setActiveTab(initialTab);
}
}, [isOpen, initialTab]);
// ESC key handler
useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => {
if (isOpen && (e.key === 'Escape' || e.key === 'Esc')) {
onClose();
}
};
if (isOpen) {
window.addEventListener('keydown', handleKeyDown);
}
return () => {
window.removeEventListener('keydown', handleKeyDown);
};
}, [isOpen, onClose]);
if (!isOpen) return null;
return (
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/20 backdrop-blur-sm p-4">
<div className="bg-white border border-slate-200 rounded-lg shadow-2xl w-full max-w-2xl flex flex-col h-[600px] max-h-[90vh]">
{/* Header */}
<div className="flex items-center justify-between p-4 border-b border-slate-200 bg-slate-50 rounded-t-lg">
<h2 className="text-base font-bold text-slate-800 flex items-center gap-2">
<HelpCircle size={20} className="text-blue-600" />
</h2>
<button onClick={onClose} className="text-slate-400 hover:text-slate-600 transition-colors">
<X size={20} />
</button>
</div>
<div className="flex flex-1 min-h-0">
{/* Sidebar */}
<div className="w-48 border-r border-slate-200 bg-slate-50 p-2 flex flex-col gap-1">
<button
onClick={() => setActiveTab('sites')}
className={`flex items-center gap-2 px-3 py-2 text-sm rounded transition-colors ${activeTab === 'sites' ? 'bg-white text-blue-600 shadow-sm font-medium' : 'text-slate-600 hover:bg-slate-200'
}`}
>
<Server size={16} />
</button>
<button
onClick={() => setActiveTab('connection')}
className={`flex items-center gap-2 px-3 py-2 text-sm rounded transition-colors ${activeTab === 'connection' ? 'bg-white text-blue-600 shadow-sm font-medium' : 'text-slate-600 hover:bg-slate-200'
}`}
>
<Wifi size={16} />
</button>
<button
onClick={() => setActiveTab('backend')}
className={`flex items-center gap-2 px-3 py-2 text-sm rounded transition-colors ${activeTab === 'backend' ? 'bg-white text-blue-600 shadow-sm font-medium' : 'text-slate-600 hover:bg-slate-200'
}`}
>
<Terminal size={16} /> /
</button>
<button
onClick={() => setActiveTab('files')}
className={`flex items-center gap-2 px-3 py-2 text-sm rounded transition-colors ${activeTab === 'files' ? 'bg-white text-blue-600 shadow-sm font-medium' : 'text-slate-600 hover:bg-slate-200'
}`}
>
<Folder size={16} />
</button>
</div>
{/* Content */}
<div className="flex-1 overflow-y-auto p-6 bg-white">
{activeTab === 'sites' && (
<div className="space-y-6">
<div>
<h3 className="text-lg font-bold text-slate-800 mb-2 flex items-center gap-2">
<Server size={20} className="text-slate-400" />
</h3>
<p className="text-slate-600 text-sm leading-relaxed mb-4">
FTP .
</p>
<ul className="list-disc list-inside text-sm text-slate-600 space-y-2 bg-slate-50 p-4 rounded border border-slate-100">
<li><strong> :</strong> .</li>
<li><strong> :</strong> . (: /public_html)</li>
<li><strong> :</strong> '연결' . ( )</li>
</ul>
</div>
</div>
)}
{activeTab === 'connection' && (
<div className="space-y-6">
<div>
<h3 className="text-lg font-bold text-slate-800 mb-2 flex items-center gap-2">
<Wifi size={20} className="text-slate-400" />
</h3>
<p className="text-slate-600 text-sm leading-relaxed mb-4">
.
</p>
<ul className="list-disc list-inside text-sm text-slate-600 space-y-2 bg-slate-50 p-4 rounded border border-slate-100">
<li><strong> :</strong> , , .</li>
<li><strong> :</strong> (/) .</li>
<li><strong> :</strong> .</li>
</ul>
</div>
</div>
)}
{activeTab === 'backend' && (
<div className="space-y-6">
<div>
<h3 className="text-lg font-bold text-slate-800 mb-2 flex items-center gap-2">
<Terminal size={20} className="text-slate-400" />
</h3>
<p className="text-slate-600 text-sm leading-relaxed mb-4">
WebZilla는 .
</p>
<div className="space-y-4">
<div className="bg-amber-50 p-4 rounded border border-amber-100">
<h4 className="font-bold text-amber-800 text-sm mb-2 flex items-center gap-2">
<Settings size={16} /> 1.
</h4>
<p className="text-xs text-amber-700 leading-relaxed">
<span className="font-bold bg-emerald-600 text-white px-1.5 py-0.5 rounded text-[10px]"></span>
<code className="mx-1 bg-amber-100 px-1 rounded text-amber-900">backend_proxy.cjs</code> .
</p>
</div>
<div className="bg-slate-50 p-4 rounded border border-slate-200">
<h4 className="font-bold text-slate-800 text-sm mb-2 text- mb-2">2. </h4>
<div className="space-y-3">
<div>
<span className="text-xs font-bold text-slate-600 block mb-1"> A: Node.js가 ()</span>
<div className="bg-slate-800 text-slate-200 p-2 rounded text-xs font-mono">
node backend_proxy.cjs
</div>
</div>
<div>
<span className="text-xs font-bold text-slate-600 block mb-1"> B: 실행 (.exe) </span>
<p className="text-xs text-slate-500"> exe .</p>
</div>
</div>
</div>
<div className="flex items-start gap-2 text-xs text-blue-600 bg-blue-50 p-3 rounded">
<div className="shrink-0 mt-0.5"><Wifi size={14} /></div>
<p> <strong>8090</strong> , 'Server' <span className="font-bold text-green-600">Connected</span> .</p>
</div>
</div>
</div>
</div>
)}
{activeTab === 'files' && (
<div className="space-y-6">
<div>
<h3 className="text-lg font-bold text-slate-800 mb-2 flex items-center gap-2">
<Folder size={20} className="text-slate-400" />
</h3>
<p className="text-slate-600 text-sm leading-relaxed mb-4">
( ) () .
</p>
<div className="space-y-4">
<div className="bg-blue-50 p-3 rounded border border-blue-100">
<h4 className="font-bold text-blue-800 text-sm mb-1"> </h4>
<p className="text-xs text-blue-600">
/ . ( )
</p>
</div>
<div className="grid grid-cols-2 gap-3">
<div className="border border-slate-200 p-3 rounded">
<h4 className="font-bold text-slate-700 text-sm mb-1"> ( )</h4>
<ul className="text-xs text-slate-500 space-y-1">
<li> </li>
<li> </li>
<li> / </li>
</ul>
</div>
<div className="border border-slate-200 p-3 rounded">
<h4 className="font-bold text-slate-700 text-sm mb-1"> ()</h4>
<ul className="text-xs text-slate-500 space-y-1">
<li> (MKD)</li>
<li> (RENAME)</li>
<li> / (DELE)</li>
</ul>
</div>
</div>
</div>
</div>
</div>
)}
</div>
</div>
{/* Footer */}
<div className="p-4 border-t border-slate-200 bg-slate-50 flex justify-end rounded-b-lg">
<button
onClick={onClose}
className="px-4 py-2 bg-slate-800 hover:bg-slate-700 text-white text-sm rounded shadow-sm transition-colors"
>
</button>
</div>
</div>
</div>
);
};
export default HelpModal;

View File

@@ -6,177 +6,45 @@ interface SettingsModalProps {
onClose: () => void;
}
const SettingsModal: React.FC<SettingsModalProps> = ({ isOpen, onClose }) => {
const [activeTab, setActiveTab] = useState<'arch' | 'code'>('arch');
const [copied, setCopied] = useState(false);
const SettingsModal: React.FC<SettingsModalProps & { saveConnectionInfo: boolean, onToggleSaveConnectionInfo: (checked: boolean) => void }> = ({
isOpen,
onClose,
saveConnectionInfo,
onToggleSaveConnectionInfo
}) => {
if (!isOpen) return null;
const backendCodeDisplay = `/**
* WebZilla Backend Proxy (Node.js)
* Supports: FTP (basic-ftp) & SFTP (ssh2-sftp-client)
* Dependencies: npm install ws basic-ftp ssh2-sftp-client
*/
const WebSocket = require('ws');
const ftp = require('basic-ftp');
const SftpClient = require('ssh2-sftp-client');
// ... imports
const wss = new WebSocket.Server({ port: 8090 });
wss.on('connection', (ws) => {
let ftpClient = new ftp.Client();
let sftpClient = new SftpClient();
let currentProto = 'ftp';
ws.on('message', async (msg) => {
const data = JSON.parse(msg);
if (data.command === 'CONNECT') {
currentProto = data.protocol; // 'ftp' or 'sftp'
if (currentProto === 'sftp') {
await sftpClient.connect({
host: data.host,
port: data.port,
username: data.user,
password: data.pass
});
} else {
await ftpClient.access({
host: data.host,
user: data.user,
password: data.pass
});
}
ws.send(JSON.stringify({ status: 'connected' }));
}
// ... Handling LIST, MKD, DELE for both protocols
});
});`;
const handleCopy = () => {
navigator.clipboard.writeText(backendCodeDisplay);
setCopied(true);
setTimeout(() => setCopied(false), 2000);
};
return (
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/20 backdrop-blur-sm p-4">
<div className="bg-white border border-slate-200 rounded-lg shadow-2xl w-full max-w-2xl flex flex-col max-h-[85vh]">
<div className="bg-white border border-slate-200 rounded-lg shadow-2xl w-full max-w-md flex flex-col">
{/* Header */}
<div className="flex items-center justify-between p-4 border-b border-slate-200">
<h2 className="text-lg font-bold text-slate-800 flex items-center gap-2">
<Server size={20} className="text-blue-600" />
</h2>
<button onClick={onClose} className="text-slate-400 hover:text-slate-600 transition-colors">
<X size={20} />
</button>
</div>
{/* Tabs */}
<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'
}`}
>
</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'
}`}
>
(Preview)
</button>
</div>
{/* Content */}
<div className="p-6 overflow-y-auto flex-1 text-slate-600">
{activeTab === 'arch' ? (
<div className="space-y-6">
<div className="bg-slate-50 p-6 rounded-lg border border-slate-200 flex flex-col md:flex-row items-center justify-between gap-4 text-center">
<div className="flex flex-col items-center gap-2">
<div className="w-16 h-16 bg-blue-50 rounded-full flex items-center justify-center border border-blue-200">
<Globe size={32} className="text-blue-500" />
<div className="p-6">
<label className="flex items-center gap-3 p-4 border border-slate-200 rounded-lg cursor-pointer hover:bg-slate-50 transition-colors">
<div className="relative flex items-center">
<input
type="checkbox"
checked={saveConnectionInfo}
onChange={(e) => onToggleSaveConnectionInfo(e.target.checked)}
className="w-5 h-5 text-blue-600 border-slate-300 rounded focus:ring-blue-500"
/>
</div>
<span className="font-bold text-sm text-slate-700"></span>
<span className="text-xs text-slate-500">React Client</span>
<div className="flex-1">
<span className="font-semibold text-slate-700 block text-sm"> </span>
<span className="text-xs text-slate-500">, , .</span>
</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>
</div>
<div className="flex flex-col items-center gap-2 relative">
<div className="w-16 h-16 bg-green-50 rounded-full flex items-center justify-center border border-green-200">
<Server size={32} className="text-green-500" />
</div>
<span className="font-bold text-sm text-slate-700">Node.js Proxy</span>
{/* AppData Connection */}
<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
</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" />
</div>
<div className="flex flex-col items-center gap-2">
<div className="w-16 h-16 bg-orange-50 rounded-full flex items-center justify-center border border-orange-200">
<Server size={32} className="text-orange-500" />
</div>
<span className="font-bold text-sm text-slate-700">Remote Server</span>
</div>
</div>
<div className="space-y-2">
<h3 className="font-bold text-slate-800"> (v1.1)</h3>
<ul className="list-disc list-inside text-sm text-slate-600 space-y-1 ml-2">
<li><span className="text-green-600 font-semibold">SFTP :</span> SSH2 .</li>
<li><span className="text-blue-600 font-semibold"> :</span> FTP UI .</li>
<li><span className="text-yellow-600 font-semibold"> :</span> , , .</li>
</ul>
</div>
</div>
) : (
<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>
</div>
<div className="relative group">
<pre className="bg-slate-800 p-4 rounded-lg overflow-x-auto text-xs font-mono text-slate-200 border border-slate-700 leading-relaxed shadow-inner">
{backendCodeDisplay}
</pre>
</div>
<p className="text-xs text-slate-400 italic text-center">
'백엔드 다운로드' .
</p>
</div>
)}
</label>
</div>
<div className="p-4 border-t border-slate-200 bg-slate-50 rounded-b-lg flex justify-end">

View File

@@ -151,8 +151,7 @@ const SiteManagerModal: React.FC<SiteManagerModalProps> = ({
<div
key={site.id}
onClick={() => selectSite(site)}
className={`flex items-center gap-2 px-3 py-2 rounded cursor-pointer text-sm select-none transition-colors ${
selectedId === site.id
className={`flex items-center gap-2 px-3 py-2 rounded cursor-pointer text-sm select-none transition-colors ${selectedId === site.id
? 'bg-blue-100 text-blue-900 border border-blue-200'
: 'text-slate-600 hover:bg-slate-200'
}`}
@@ -177,16 +176,14 @@ const SiteManagerModal: React.FC<SiteManagerModalProps> = ({
<div className="flex border-b border-slate-200 px-4">
<button
onClick={() => setActiveTab('general')}
className={`px-4 py-2 text-xs font-medium border-b-2 transition-colors ${
activeTab === 'general' ? 'border-blue-500 text-blue-600' : 'border-transparent text-slate-500'
className={`px-4 py-2 text-xs font-medium border-b-2 transition-colors ${activeTab === 'general' ? 'border-blue-500 text-blue-600' : 'border-transparent text-slate-500'
}`}
>
(General)
</button>
<button
onClick={() => setActiveTab('transfer')}
className={`px-4 py-2 text-xs font-medium border-b-2 transition-colors ${
activeTab === 'transfer' ? 'border-blue-500 text-blue-600' : 'border-transparent text-slate-500'
className={`px-4 py-2 text-xs font-medium border-b-2 transition-colors ${activeTab === 'transfer' ? 'border-blue-500 text-blue-600' : 'border-transparent text-slate-500'
}`}
>
(Transfer)
@@ -262,6 +259,17 @@ const SiteManagerModal: React.FC<SiteManagerModalProps> = ({
className="col-span-3 bg-white border border-slate-300 rounded px-2 py-1.5 text-sm focus:border-blue-500 focus:outline-none text-slate-800 placeholder:text-slate-400"
/>
</div>
<div className="grid grid-cols-4 gap-4 items-center">
<label className="text-xs text-slate-500 text-right"> </label>
<input
type="text"
value={formData.initialPath || ''}
onChange={(e) => updateForm('initialPath', e.target.value)}
placeholder="/ (기본값)"
className="col-span-3 bg-white border border-slate-300 rounded px-2 py-1.5 text-sm focus:border-blue-500 focus:outline-none text-slate-800 placeholder:text-slate-400"
/>
</div>
</div>
) : (
<div className="space-y-6">
@@ -322,8 +330,7 @@ const SiteManagerModal: React.FC<SiteManagerModalProps> = ({
<button
onClick={handleSave}
disabled={!formData}
className={`px-4 py-2 text-sm rounded flex items-center gap-2 transition-colors shadow-sm ${
isDirty
className={`px-4 py-2 text-sm rounded flex items-center gap-2 transition-colors shadow-sm ${isDirty
? 'bg-emerald-600 hover:bg-emerald-500 text-white shadow-emerald-500/20'
: 'bg-white border border-slate-300 text-slate-500'
}`}

View File

@@ -44,4 +44,5 @@ export interface SiteConfig {
user: string;
pass?: string; // Optional for security
passiveMode?: boolean;
initialPath?: string;
}

Binary file not shown.