mirror of
https://github.com/jung-geun/NFD2NFC.git
synced 2025-12-19 20:14:39 +09:00
141 lines
3.6 KiB
HTML
141 lines
3.6 KiB
HTML
<!-- index.html -->
|
|
<!DOCTYPE html>
|
|
<html lang="ko">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>Directory Watcher App</title>
|
|
<style>
|
|
body {
|
|
font-family: Arial, sans-serif;
|
|
text-align: center;
|
|
padding: 20px;
|
|
}
|
|
|
|
#selected-directories {
|
|
margin-top: 20px;
|
|
text-align: left;
|
|
max-width: 500px;
|
|
margin-left: auto;
|
|
margin-right: auto;
|
|
}
|
|
|
|
.directory-item {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
padding: 8px;
|
|
border-bottom: 1px solid #ccc;
|
|
}
|
|
|
|
.directory-path {
|
|
word-break: break-all;
|
|
}
|
|
|
|
.remove-button {
|
|
background-color: #ff4d4d;
|
|
border: none;
|
|
color: white;
|
|
padding: 5px 10px;
|
|
border-radius: 3px;
|
|
cursor: pointer;
|
|
}
|
|
|
|
#log {
|
|
margin-top: 20px;
|
|
text-align: left;
|
|
white-space: pre-wrap;
|
|
background-color: #f0f0f0;
|
|
padding: 10px;
|
|
border-radius: 5px;
|
|
height: 200px;
|
|
overflow-y: scroll;
|
|
max-width: 500px;
|
|
margin-left: auto;
|
|
margin-right: auto;
|
|
}
|
|
|
|
button {
|
|
padding: 10px 20px;
|
|
font-size: 16px;
|
|
cursor: pointer;
|
|
margin-bottom: 10px;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<h1>디렉토리 감시 애플리케이션</h1>
|
|
<button id="select-directory">디렉토리 선택</button>
|
|
<div id="selected-directories">
|
|
<h2>감시 중인 디렉토리</h2>
|
|
<div id="directories-list">
|
|
<!-- 선택된 디렉토리 목록이 여기에 표시됩니다 -->
|
|
</div>
|
|
</div>
|
|
<div id="log">
|
|
로그가 여기에 표시됩니다.
|
|
</div>
|
|
|
|
<script>
|
|
const selectDirButton = document.getElementById('select-directory');
|
|
const directoriesList = document.getElementById('directories-list');
|
|
const logDiv = document.getElementById('log');
|
|
|
|
// 디렉토리 선택 버튼 클릭 시
|
|
selectDirButton.addEventListener('click', async () => {
|
|
const result = await window.electronAPI.selectDirectories();
|
|
if (!result.canceled) {
|
|
for (const path of result.paths) {
|
|
addDirectoryToList(path);
|
|
}
|
|
}
|
|
});
|
|
|
|
// 디렉토리를 목록에 추가하는 함수
|
|
function addDirectoryToList(dirPath) {
|
|
// 이미 목록에 있는 경우 중복 추가 방지
|
|
if (document.querySelector(`[data-path="${ dirPath }"]`)) {
|
|
return;
|
|
}
|
|
|
|
const directoryItem = document.createElement('div');
|
|
directoryItem.className = 'directory-item';
|
|
directoryItem.setAttribute('data-path', dirPath);
|
|
|
|
const pathSpan = document.createElement('span');
|
|
pathSpan.className = 'directory-path';
|
|
pathSpan.textContent = dirPath;
|
|
|
|
const removeBtn = document.createElement('button');
|
|
removeBtn.className = 'remove-button';
|
|
removeBtn.textContent = '제거';
|
|
removeBtn.addEventListener('click', async () => {
|
|
const response = await window.electronAPI.removeDirectory(dirPath);
|
|
if (response.success) {
|
|
directoriesList.removeChild(directoryItem);
|
|
appendLog(`디렉토리 감시 중지: "${ dirPath }"`);
|
|
} else {
|
|
appendLog(`디렉토리 제거 실패: "${ response.message }"`);
|
|
}
|
|
});
|
|
|
|
directoryItem.appendChild(pathSpan);
|
|
directoryItem.appendChild(removeBtn);
|
|
directoriesList.appendChild(directoryItem);
|
|
}
|
|
|
|
// 로그 메시지를 로그 섹션에 추가하는 함수
|
|
function appendLog(message) {
|
|
logDiv.textContent += `${ message }\n`;
|
|
logDiv.scrollTop = logDiv.scrollHeight; // 자동 스크롤
|
|
}
|
|
|
|
// 로그 메시지 수신 시
|
|
window.electronAPI.onLog((message) => {
|
|
appendLog(message);
|
|
});
|
|
</script>
|
|
</body>
|
|
|
|
</html> |