mirror of
https://github.com/ZeroCatDev/ClassworksKV.git
synced 2025-08-31 20:39:22 +00:00
简化首页
This commit is contained in:
parent
15691b7333
commit
f250deb2bb
@ -20,37 +20,6 @@
|
|||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
.form-section {
|
|
||||||
background-color: #f0f8ff;
|
|
||||||
padding: 20px;
|
|
||||||
border-radius: 5px;
|
|
||||||
margin-top: 30px;
|
|
||||||
}
|
|
||||||
textarea {
|
|
||||||
width: 100%;
|
|
||||||
height: 200px;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
font-family: monospace;
|
|
||||||
}
|
|
||||||
button {
|
|
||||||
padding: 10px 15px;
|
|
||||||
background-color: #4CAF50;
|
|
||||||
color: white;
|
|
||||||
border: none;
|
|
||||||
border-radius: 4px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
button:hover {
|
|
||||||
background-color: #45a049;
|
|
||||||
}
|
|
||||||
#response {
|
|
||||||
white-space: pre-wrap;
|
|
||||||
background-color: #f5f5f5;
|
|
||||||
padding: 15px;
|
|
||||||
border-radius: 5px;
|
|
||||||
margin-top: 20px;
|
|
||||||
font-family: monospace;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
@ -62,70 +31,6 @@
|
|||||||
<div class="readme-content">
|
<div class="readme-content">
|
||||||
<pre><%= readmeValue.readme %></pre>
|
<pre><%= readmeValue.readme %></pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-section">
|
|
||||||
<h2>批量数据导入测试</h2>
|
|
||||||
<form id="batchImportForm">
|
|
||||||
<div>
|
|
||||||
<label for="namespace">命名空间:</label>
|
|
||||||
<input type="text" id="namespace" name="namespace" placeholder="输入命名空间" required>
|
|
||||||
<button type="button" id="generateUUID">生成UUID</button>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label for="data">JSON数据 (格式: {"key":{}, "key2":{}})</label>
|
|
||||||
<textarea id="data" name="data" placeholder='{"key1": {"value": "test1"}, "key2": {"value": "test2"}}' required></textarea>
|
|
||||||
</div>
|
|
||||||
<button type="submit">导入数据</button>
|
|
||||||
</form>
|
|
||||||
<div>
|
|
||||||
<h3>响应结果:</h3>
|
|
||||||
<pre id="response"></pre>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
document.getElementById('generateUUID').addEventListener('click', async function() {
|
|
||||||
try {
|
|
||||||
const response = await fetch('/_uuid', {
|
|
||||||
method: 'GET'
|
|
||||||
});
|
|
||||||
const data = await response.json();
|
|
||||||
document.getElementById('namespace').value = data.namespace;
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error:', error);
|
|
||||||
document.getElementById('response').textContent = '获取UUID失败: ' + error.message;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
document.getElementById('batchImportForm').addEventListener('submit', async function(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
const namespace = document.getElementById('namespace').value;
|
|
||||||
let jsonData;
|
|
||||||
|
|
||||||
try {
|
|
||||||
jsonData = JSON.parse(document.getElementById('data').value);
|
|
||||||
} catch (error) {
|
|
||||||
document.getElementById('response').textContent = 'JSON解析错误: ' + error.message;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await fetch(`/${namespace}/_batchimport`, {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
},
|
|
||||||
body: JSON.stringify(jsonData)
|
|
||||||
});
|
|
||||||
|
|
||||||
const result = await response.json();
|
|
||||||
document.getElementById('response').textContent = JSON.stringify(result, null, 2);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error:', error);
|
|
||||||
document.getElementById('response').textContent = '请求失败: ' + error.message;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
Loading…
x
Reference in New Issue
Block a user