feat: API说明增加一键复制按钮
This commit is contained in:
@@ -13,9 +13,14 @@
|
|||||||
<button class="btn btn-outline-secondary btn-sm dropdown-toggle" type="button" data-bs-toggle="dropdown">
|
<button class="btn btn-outline-secondary btn-sm dropdown-toggle" type="button" data-bs-toggle="dropdown">
|
||||||
<i class="bi bi-cloud-arrow-up me-1"></i>API上传
|
<i class="bi bi-cloud-arrow-up me-1"></i>API上传
|
||||||
</button>
|
</button>
|
||||||
<ul class="dropdown-menu dropdown-menu-end p-3" style="min-width: 350px;">
|
<ul class="dropdown-menu dropdown-menu-end p-3" style="min-width: 400px;">
|
||||||
<li>
|
<li>
|
||||||
<h6 class="dropdown-header">临时文件上传 API</h6>
|
<div class="d-flex justify-content-between align-items-center mb-2">
|
||||||
|
<h6 class="dropdown-header mb-0">临时文件上传 API</h6>
|
||||||
|
<button class="btn btn-sm btn-outline-primary" onclick="copyApiDocs()">
|
||||||
|
<i class="bi bi-clipboard me-1"></i>复制
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
<p class="small text-muted mb-2">端点: <code>POST /api/v1/temp-upload/</code></p>
|
<p class="small text-muted mb-2">端点: <code>POST /api/v1/temp-upload/</code></p>
|
||||||
<hr>
|
<hr>
|
||||||
<p class="small mb-1"><strong>参数:</strong></p>
|
<p class="small mb-1"><strong>参数:</strong></p>
|
||||||
@@ -25,10 +30,20 @@
|
|||||||
<li><code>expire_type</code> - expire_1h / expire_1d / expire_7d</li>
|
<li><code>expire_type</code> - expire_1h / expire_1d / expire_7d</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p class="small mb-1"><strong>cURL示例:</strong></p>
|
<p class="small mb-1"><strong>cURL示例:</strong></p>
|
||||||
<pre class="small bg-dark text-white p-2 rounded"><code>curl -X POST -F "file=@f.pdf" -F "title=文件" -F "expire_type=expire_1d" /api/v1/temp-upload/</code></pre>
|
<pre class="small bg-dark text-white p-2 rounded" id="curlExample"><code>curl -X POST -F "file=@f.pdf" -F "title=文件" -F "expire_type=expire_1d" /api/v1/temp-upload/</code></pre>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
<script>
|
||||||
|
function copyApiDocs() {
|
||||||
|
const curlCode = document.getElementById('curlExample').textContent;
|
||||||
|
navigator.clipboard.writeText(curlCode).then(function() {
|
||||||
|
alert('已复制到剪贴板!');
|
||||||
|
}).catch(function(err) {
|
||||||
|
console.error('复制失败:', err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
<a href="{% url 'add_public_content' %}" class="btn btn-primary">
|
<a href="{% url 'add_public_content' %}" class="btn btn-primary">
|
||||||
<i class="bi bi-plus-lg me-1"></i>添加内容
|
<i class="bi bi-plus-lg me-1"></i>添加内容
|
||||||
|
|||||||
Reference in New Issue
Block a user