feat(v3): add task progress state and curl copy helper

This commit is contained in:
likingcode
2026-03-09 02:04:16 +08:00
parent e766fa427f
commit 3c208651b9
2 changed files with 28 additions and 0 deletions

View File

@@ -65,6 +65,7 @@
<div class="tipbox"> <div class="tipbox">
<h4>🧪 实验任务卡(高级模块)</h4> <h4>🧪 实验任务卡(高级模块)</h4>
<label style="display:block;margin-bottom:8px;"><input id="advancedTaskDone" type="checkbox" onchange="toggleAdvancedTaskDone(this)"> 本任务我已经完成</label>
<ul style="padding-left:20px;line-height:1.8;"> <ul style="padding-left:20px;line-height:1.8;">
<li>目标:比较 learn/advanced profile 下可用能力差异</li> <li>目标:比较 learn/advanced profile 下可用能力差异</li>
<li>步骤1先查看“系统配置”和“认证方案对比”</li> <li>步骤1先查看“系统配置”和“认证方案对比”</li>
@@ -141,6 +142,18 @@
</div> </div>
<script> <script>
const ADV_TASK_KEY = 'task.advanced.done';
function toggleAdvancedTaskDone(el) {
localStorage.setItem(ADV_TASK_KEY, el.checked ? '1' : '0');
}
function initAdvancedTaskState() {
const done = localStorage.getItem(ADV_TASK_KEY) === '1';
const checkbox = document.getElementById('advancedTaskDone');
if (checkbox) checkbox.checked = done;
}
async function loadConfig() { async function loadConfig() {
const result = document.getElementById('configResult'); const result = document.getElementById('configResult');
result.textContent = '加载中...'; result.textContent = '加载中...';
@@ -239,6 +252,7 @@
} }
loadConfig(); loadConfig();
initAdvancedTaskState();
</script> </script>
</body> </body>
</html> </html>

View File

@@ -50,6 +50,7 @@
.json-input { width: 100%; min-height: 100px; padding: 10px; border: 1px solid #ddd; border-radius: 5px; font-family: monospace; font-size: 0.9em; } .json-input { width: 100%; min-height: 100px; padding: 10px; border: 1px solid #ddd; border-radius: 5px; font-family: monospace; font-size: 0.9em; }
.profile-banner { background:#fff7e6;border-left:4px solid #fa8c16;padding:12px 14px;border-radius:8px;margin-bottom:18px; color:#874d00; } .profile-banner { background:#fff7e6;border-left:4px solid #fa8c16;padding:12px 14px;border-radius:8px;margin-bottom:18px; color:#874d00; }
.tools { margin: 10px 0 16px; }
</style> </style>
</head> </head>
<body> <body>
@@ -70,6 +71,9 @@
</div> </div>
<div id="profileBanner" class="profile-banner">正在读取 profile...</div> <div id="profileBanner" class="profile-banner">正在读取 profile...</div>
<div class="tools">
<button class="btn btn-primary" onclick="copyCurl()">复制当前示例 cURLGET /api/users</button>
</div>
<div class="tabs"> <div class="tabs">
<div class="tab active" onclick="switchTab('user')">👥 用户 API</div> <div class="tab active" onclick="switchTab('user')">👥 用户 API</div>
@@ -262,6 +266,16 @@
} }
} }
async function copyCurl() {
const curl = `curl -X GET "${window.location.origin}/api/users"`;
try {
await navigator.clipboard.writeText(curl);
alert('已复制: ' + curl);
} catch (e) {
alert('复制失败,请手动复制: ' + curl);
}
}
async function testApi(method, url, body, resultId) { async function testApi(method, url, body, resultId) {
const resultDiv = document.getElementById(resultId); const resultDiv = document.getElementById(resultId);
resultDiv.classList.add('show'); resultDiv.classList.add('show');