Spaces:
Paused
Paused
Update templates/index.html
Browse files- templates/index.html +21 -4
templates/index.html
CHANGED
|
@@ -26,6 +26,7 @@
|
|
| 26 |
background-color: #1e1e1e;
|
| 27 |
color: #ffffff;
|
| 28 |
font-family: 'Courier New', Courier, monospace;
|
|
|
|
| 29 |
}
|
| 30 |
#input {
|
| 31 |
width: calc(100% - 22px);
|
|
@@ -35,6 +36,7 @@
|
|
| 35 |
background-color: #1e1e1e;
|
| 36 |
color: #ffffff;
|
| 37 |
font-family: 'Courier New', Courier, monospace;
|
|
|
|
| 38 |
}
|
| 39 |
button {
|
| 40 |
padding: 10px 15px;
|
|
@@ -43,6 +45,7 @@
|
|
| 43 |
border: none;
|
| 44 |
cursor: pointer;
|
| 45 |
margin-left: 5px;
|
|
|
|
| 46 |
}
|
| 47 |
button:hover {
|
| 48 |
background-color: #555;
|
|
@@ -53,6 +56,7 @@
|
|
| 53 |
color: #ffffff;
|
| 54 |
padding: 20px;
|
| 55 |
margin-top: 20px;
|
|
|
|
| 56 |
}
|
| 57 |
.dropzone .dz-message {
|
| 58 |
color: #ffffff;
|
|
@@ -73,7 +77,9 @@
|
|
| 73 |
<button onclick="sendInput()">Send</button>
|
| 74 |
|
| 75 |
<h1>File Upload</h1>
|
| 76 |
-
<form action="/upload" class="dropzone" id="my-dropzone"
|
|
|
|
|
|
|
| 77 |
|
| 78 |
<h1>File Manager</h1>
|
| 79 |
<p><a href="/files">Go to File Manager</a></p>
|
|
@@ -83,17 +89,28 @@
|
|
| 83 |
var socket = io();
|
| 84 |
|
| 85 |
socket.on('output', function(data) {
|
| 86 |
-
|
|
|
|
| 87 |
var outputDiv = document.getElementById('output');
|
| 88 |
outputDiv.scrollTop = outputDiv.scrollHeight; // 自动滚动到最新输出
|
| 89 |
});
|
| 90 |
|
| 91 |
function sendInput() {
|
| 92 |
var input = document.getElementById('input').value;
|
| 93 |
-
|
| 94 |
-
|
|
|
|
|
|
|
| 95 |
}
|
| 96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
// Dropzone configuration
|
| 98 |
Dropzone.options.myDropzone = {
|
| 99 |
paramName: "file", // The name that will be used to transfer the file
|
|
|
|
| 26 |
background-color: #1e1e1e;
|
| 27 |
color: #ffffff;
|
| 28 |
font-family: 'Courier New', Courier, monospace;
|
| 29 |
+
white-space: pre-wrap; /* 保留空格和换行 */
|
| 30 |
}
|
| 31 |
#input {
|
| 32 |
width: calc(100% - 22px);
|
|
|
|
| 36 |
background-color: #1e1e1e;
|
| 37 |
color: #ffffff;
|
| 38 |
font-family: 'Courier New', Courier, monospace;
|
| 39 |
+
border-radius: 4px;
|
| 40 |
}
|
| 41 |
button {
|
| 42 |
padding: 10px 15px;
|
|
|
|
| 45 |
border: none;
|
| 46 |
cursor: pointer;
|
| 47 |
margin-left: 5px;
|
| 48 |
+
border-radius: 4px;
|
| 49 |
}
|
| 50 |
button:hover {
|
| 51 |
background-color: #555;
|
|
|
|
| 56 |
color: #ffffff;
|
| 57 |
padding: 20px;
|
| 58 |
margin-top: 20px;
|
| 59 |
+
border-radius: 4px;
|
| 60 |
}
|
| 61 |
.dropzone .dz-message {
|
| 62 |
color: #ffffff;
|
|
|
|
| 77 |
<button onclick="sendInput()">Send</button>
|
| 78 |
|
| 79 |
<h1>File Upload</h1>
|
| 80 |
+
<form action="/upload" class="dropzone" id="my-dropzone">
|
| 81 |
+
<div class="dz-message">Drop files here or click to upload.</div>
|
| 82 |
+
</form>
|
| 83 |
|
| 84 |
<h1>File Manager</h1>
|
| 85 |
<p><a href="/files">Go to File Manager</a></p>
|
|
|
|
| 89 |
var socket = io();
|
| 90 |
|
| 91 |
socket.on('output', function(data) {
|
| 92 |
+
// 使用 <pre> 标签来保留格式
|
| 93 |
+
document.getElementById('output').innerHTML += data + '\n';
|
| 94 |
var outputDiv = document.getElementById('output');
|
| 95 |
outputDiv.scrollTop = outputDiv.scrollHeight; // 自动滚动到最新输出
|
| 96 |
});
|
| 97 |
|
| 98 |
function sendInput() {
|
| 99 |
var input = document.getElementById('input').value;
|
| 100 |
+
if (input.trim() !== '') { // 确保输入不为空
|
| 101 |
+
socket.emit('input', input);
|
| 102 |
+
document.getElementById('input').value = '';
|
| 103 |
+
}
|
| 104 |
}
|
| 105 |
|
| 106 |
+
// 监听输入框的键盘事件
|
| 107 |
+
document.getElementById('input').addEventListener('keydown', function(event) {
|
| 108 |
+
if (event.key === 'Enter') {
|
| 109 |
+
sendInput(); // 按下回车时执行命令
|
| 110 |
+
event.preventDefault(); // 防止表单提交
|
| 111 |
+
}
|
| 112 |
+
});
|
| 113 |
+
|
| 114 |
// Dropzone configuration
|
| 115 |
Dropzone.options.myDropzone = {
|
| 116 |
paramName: "file", // The name that will be used to transfer the file
|