增加添加文件和新建文件夹功能
Browse files- index.html +125 -4
index.html
CHANGED
|
@@ -53,8 +53,11 @@
|
|
| 53 |
<button class="block w-full text-left px-4 py-1 hover:bg-blue-100">New Disk</button>
|
| 54 |
<button class="block w-full text-left px-4 py-1 hover:bg-blue-100">Open Disk</button>
|
| 55 |
<button class="block w-full text-left px-4 py-1 hover:bg-blue-100">Sign Out</button>
|
|
|
|
|
|
|
|
|
|
| 56 |
</div>
|
| 57 |
-
|
| 58 |
<div class="text-sm font-medium">Welcome, Admin</div>
|
| 59 |
</div>
|
| 60 |
</div>
|
|
@@ -199,15 +202,124 @@
|
|
| 199 |
|
| 200 |
<!-- Status Bar -->
|
| 201 |
<div class="bg-gray-200 p-1 border-t border-gray-300 text-xs flex justify-between px-2">
|
| 202 |
-
|
| 203 |
-
|
| 204 |
</div>
|
| 205 |
</div>
|
| 206 |
</div>
|
| 207 |
<script>
|
| 208 |
feather.replace();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
// Simulate disk selection
|
| 210 |
-
|
| 211 |
item.addEventListener('click', function() {
|
| 212 |
// Remove active class from all
|
| 213 |
document.querySelectorAll('div.px-2.py-1').forEach(i => {
|
|
@@ -241,6 +353,15 @@ document.querySelector('.address-bar').textContent = `This PC > ${diskName}`;
|
|
| 241 |
document.getElementById('detail-modified').textContent = now.toLocaleString();
|
| 242 |
});
|
| 243 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 244 |
</script>
|
| 245 |
</body>
|
| 246 |
</html>
|
|
|
|
| 53 |
<button class="block w-full text-left px-4 py-1 hover:bg-blue-100">New Disk</button>
|
| 54 |
<button class="block w-full text-left px-4 py-1 hover:bg-blue-100">Open Disk</button>
|
| 55 |
<button class="block w-full text-left px-4 py-1 hover:bg-blue-100">Sign Out</button>
|
| 56 |
+
<div class="border-t border-gray-200 my-1"></div>
|
| 57 |
+
<button id="newFolderBtn" class="block w-full text-left px-4 py-1 hover:bg-blue-100">New Folder</button>
|
| 58 |
+
<button id="newFileBtn" class="block w-full text-left px-4 py-1 hover:bg-blue-100">New File</button>
|
| 59 |
</div>
|
| 60 |
+
</div>
|
| 61 |
<div class="text-sm font-medium">Welcome, Admin</div>
|
| 62 |
</div>
|
| 63 |
</div>
|
|
|
|
| 202 |
|
| 203 |
<!-- Status Bar -->
|
| 204 |
<div class="bg-gray-200 p-1 border-t border-gray-300 text-xs flex justify-between px-2">
|
| 205 |
+
<div id="itemCount">12 items</div>
|
| 206 |
+
<div>4.2 GB free of 120 GB</div>
|
| 207 |
</div>
|
| 208 |
</div>
|
| 209 |
</div>
|
| 210 |
<script>
|
| 211 |
feather.replace();
|
| 212 |
+
|
| 213 |
+
// New Folder Dialog
|
| 214 |
+
const newFolderDialog = `
|
| 215 |
+
<div id="newFolderDialog" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
|
| 216 |
+
<div class="bg-white p-4 rounded shadow-lg w-80">
|
| 217 |
+
<h3 class="font-semibold mb-4">Create New Folder</h3>
|
| 218 |
+
<input type="text" id="folderName" placeholder="Folder name" class="w-full p-2 border rounded mb-4">
|
| 219 |
+
<div class="flex justify-end space-x-2">
|
| 220 |
+
<button id="cancelFolderBtn" class="px-4 py-2 bg-gray-200 rounded hover:bg-gray-300">Cancel</button>
|
| 221 |
+
<button id="createFolderBtn" class="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600">Create</button>
|
| 222 |
+
</div>
|
| 223 |
+
</div>
|
| 224 |
+
</div>
|
| 225 |
+
`;
|
| 226 |
+
|
| 227 |
+
// New File Dialog
|
| 228 |
+
const newFileDialog = `
|
| 229 |
+
<div id="newFileDialog" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
|
| 230 |
+
<div class="bg-white p-4 rounded shadow-lg w-80">
|
| 231 |
+
<h3 class="font-semibold mb-4">Create New File</h3>
|
| 232 |
+
<input type="text" id="fileName" placeholder="File name" class="w-full p-2 border rounded mb-2">
|
| 233 |
+
<select id="fileType" class="w-full p-2 border rounded mb-4">
|
| 234 |
+
<option value="text">Text File</option>
|
| 235 |
+
<option value="image">Image</option>
|
| 236 |
+
<option value="document">Document</option>
|
| 237 |
+
</select>
|
| 238 |
+
<div class="flex justify-end space-x-2">
|
| 239 |
+
<button id="cancelFileBtn" class="px-4 py-2 bg-gray-200 rounded hover:bg-gray-300">Cancel</button>
|
| 240 |
+
<button id="createFileBtn" class="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600">Create</button>
|
| 241 |
+
</div>
|
| 242 |
+
</div>
|
| 243 |
+
</div>
|
| 244 |
+
`;
|
| 245 |
+
|
| 246 |
+
document.body.insertAdjacentHTML('beforeend', newFolderDialog);
|
| 247 |
+
document.body.insertAdjacentHTML('beforeend', newFileDialog);
|
| 248 |
+
|
| 249 |
+
// Handle new folder creation
|
| 250 |
+
document.getElementById('newFolderBtn').addEventListener('click', () => {
|
| 251 |
+
document.getElementById('newFolderDialog').classList.remove('hidden');
|
| 252 |
+
});
|
| 253 |
+
|
| 254 |
+
document.getElementById('cancelFolderBtn').addEventListener('click', () => {
|
| 255 |
+
document.getElementById('newFolderDialog').classList.add('hidden');
|
| 256 |
+
});
|
| 257 |
+
|
| 258 |
+
document.getElementById('createFolderBtn').addEventListener('click', () => {
|
| 259 |
+
const folderName = document.getElementById('folderName').value.trim();
|
| 260 |
+
if (folderName) {
|
| 261 |
+
const fileGrid = document.querySelector('.grid');
|
| 262 |
+
const newFolder = `
|
| 263 |
+
<div class="flex flex-col items-center p-2 hover:bg-blue-50 rounded cursor-pointer">
|
| 264 |
+
<i data-feather="folder" class="folder-icon w-12 h-12"></i>
|
| 265 |
+
<span class="text-sm mt-1 text-center">${folderName}</span>
|
| 266 |
+
</div>
|
| 267 |
+
`;
|
| 268 |
+
fileGrid.insertAdjacentHTML('beforeend', newFolder);
|
| 269 |
+
feather.replace();
|
| 270 |
+
document.getElementById('newFolderDialog').classList.add('hidden');
|
| 271 |
+
document.getElementById('folderName').value = '';
|
| 272 |
+
}
|
| 273 |
+
});
|
| 274 |
+
|
| 275 |
+
// Handle new file creation
|
| 276 |
+
document.getElementById('newFileBtn').addEventListener('click', () => {
|
| 277 |
+
document.getElementById('newFileDialog').classList.remove('hidden');
|
| 278 |
+
});
|
| 279 |
+
|
| 280 |
+
document.getElementById('cancelFileBtn').addEventListener('click', () => {
|
| 281 |
+
document.getElementById('newFileDialog').classList.add('hidden');
|
| 282 |
+
});
|
| 283 |
+
|
| 284 |
+
document.getElementById('createFileBtn').addEventListener('click', () => {
|
| 285 |
+
const fileName = document.getElementById('fileName').value.trim();
|
| 286 |
+
const fileType = document.getElementById('fileType').value;
|
| 287 |
+
|
| 288 |
+
if (fileName) {
|
| 289 |
+
const fileGrid = document.querySelector('.grid');
|
| 290 |
+
let iconClass = 'file-icon';
|
| 291 |
+
let iconName = 'file';
|
| 292 |
+
|
| 293 |
+
switch(fileType) {
|
| 294 |
+
case 'text':
|
| 295 |
+
iconClass = 'doc-icon';
|
| 296 |
+
iconName = 'file-text';
|
| 297 |
+
break;
|
| 298 |
+
case 'image':
|
| 299 |
+
iconClass = 'img-icon';
|
| 300 |
+
iconName = 'image';
|
| 301 |
+
break;
|
| 302 |
+
case 'document':
|
| 303 |
+
iconClass = 'doc-icon';
|
| 304 |
+
iconName = 'file-text';
|
| 305 |
+
break;
|
| 306 |
+
}
|
| 307 |
+
|
| 308 |
+
const newFile = `
|
| 309 |
+
<div class="flex flex-col items-center p-2 hover:bg-blue-50 rounded cursor-pointer">
|
| 310 |
+
<i data-feather="${iconName}" class="${iconClass} w-12 h-12"></i>
|
| 311 |
+
<span class="text-sm mt-1 text-center">${fileName}</span>
|
| 312 |
+
</div>
|
| 313 |
+
`;
|
| 314 |
+
fileGrid.insertAdjacentHTML('beforeend', newFile);
|
| 315 |
+
feather.replace();
|
| 316 |
+
document.getElementById('newFileDialog').classList.add('hidden');
|
| 317 |
+
document.getElementById('fileName').value = '';
|
| 318 |
+
}
|
| 319 |
+
});
|
| 320 |
+
|
| 321 |
// Simulate disk selection
|
| 322 |
+
document.querySelectorAll('div.px-2.py-1').forEach(item => {
|
| 323 |
item.addEventListener('click', function() {
|
| 324 |
// Remove active class from all
|
| 325 |
document.querySelectorAll('div.px-2.py-1').forEach(i => {
|
|
|
|
| 353 |
document.getElementById('detail-modified').textContent = now.toLocaleString();
|
| 354 |
});
|
| 355 |
});
|
| 356 |
+
|
| 357 |
+
// Update item count
|
| 358 |
+
function updateItemCount() {
|
| 359 |
+
const count = document.querySelectorAll('.flex.flex-col.items-center').length;
|
| 360 |
+
document.getElementById('itemCount').textContent = `${count} items`;
|
| 361 |
+
}
|
| 362 |
+
|
| 363 |
+
// Initialize
|
| 364 |
+
updateItemCount();
|
| 365 |
</script>
|
| 366 |
</body>
|
| 367 |
</html>
|