全部效果加载与反馈

分阶段任务进度

Checkpoint Progress Timeline

任务分阶段排队、进行与完成,并分别呈现每一阶段的进度。

启动分阶段任务,观察各节点状态变化

适用场景

用于展示导出任务的准备、处理和交付。 给每个阶段取一个清楚的名字,流程在某一步花较久时,用户能看出任务走到了哪里。

应用示例

批量字幕导出显示「提取音频」「转录」「打包文件」三站。开始转录时,提取音频保留已完成标记,打包文件仍标为排队中。

AI 提示词

将【任务】做成阶段进度。当前阶段完成后再推进,后续阶段保持排队,保留已完成节点,并只播报阶段切换。

示例代码

保存为 HTML 文件后,用浏览器打开即可运行。代码与页面里的演示一致。

查看 HTML
<!doctype html>
<html lang="zh">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>分阶段任务进度</title>
  <style>
    :root {
      color-scheme: dark;
      --demo-bg: #171629;
      --demo-ink: #f8f5ff;
      --demo-accent: #b9a6ff;
      --demo-muted: #bfbbd3;
      font-family: system-ui, sans-serif;
      color: var(--demo-ink);
      background: var(--demo-bg);
    }

    *, *::before, *::after { box-sizing: border-box; }
    body { margin: 0; min-width: 0; }
    button, input { font: inherit; }

    .demo {
      display: grid;
      place-items: center;
      align-content: center;
      min-height: 100vh;
      padding: 14px;
      overflow: hidden;
      background: radial-gradient(ellipse at 50% 24%, #28233f, var(--demo-bg) 78%);
    }

    .demo-button {
      border: 1px solid #ffffff3d;
      border-radius: 7px;
      background: #ffffff12;
      color: var(--demo-ink);
      padding: 6px 11px;
      font-size: 12px;
      cursor: pointer;
    }

    :focus-visible {
      outline: 2px solid var(--demo-accent);
      outline-offset: 3px;
    }

    .ui { width: min(100%, 238px); display: grid; gap: 8px; position: relative; font-size: 12px; line-height: 1.35; }
    .ui .surface { min-width: 0; border: 1px solid #676591; border-radius: 10px; background: #282744; padding: 8px; }
    .ui .bar { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
    .ui .actions { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 5px; }
    .ui .muted { color: #cecae9; font-size: 11px; }
    .ui .center { text-align: center; }
    .ui .mono { font: 11px ui-monospace, monospace; font-variant-numeric: tabular-nums; }
    .ui p { margin: 0; }
    .ui .button { min-height: 30px; padding: 4px 7px; border-radius: 7px; border: 1px solid #79779f; background: #3d3a60; color: #f9f5ff; font-size: 11px; font-weight: 650; cursor: pointer; }
    .ui .button:hover { background: #4e4976; }
    .ui .primary { background: #c5eeec; border-color: #dafaee; color: #17213b; }
    .ui .primary:hover { background: #e3fff9; }
    .ui .button:disabled { opacity: .6; cursor: default; }
    .ui .field { min-width: 0; width: 100%; border: 1px solid #79779f; border-radius: 6px; background: #1b1a31; color: #faf5ff; padding: 5px 7px; font-size: 12px; }
    .ui .field::placeholder { color: #c2bcdd; }
    .ui input[type="range"] { accent-color: #b8ebe0; width: 100%; min-width: 0; margin: 0; }
    .ui button { font: inherit; }
    .ui [hidden] { display: none !important; }
    .ui progress { accent-color: #b8ebe0; }
    @media (prefers-reduced-motion: reduce) {
      .ui *, .ui *::after, .ui *::before { transition-duration: 0s !important; animation-duration: 0s !important; scroll-behavior: auto !important; }
    }
    .stages{display:grid;gap:4px}.stage{display:flex;align-items:center;gap:6px;font-size:11px}.stage-dot{width:17px;height:17px;display:grid;place-items:center;background:#4f4c72;border-radius:50%;font:10px ui-monospace,monospace}.stage[data-phase=active] .stage-dot{background:#aadbd9;color:#211e34}.stage[data-phase=done] .stage-dot{background:#67b896;color:#202337}.stage label{display:flex;align-items:center;justify-content:space-between;gap:8px;flex:1}.stage progress{width:52%;height:7px}
  </style>
</head>
<body>
  <main class="demo">
    <div class="ui"><div class="surface stages"><div class="stage" data-phase="queued"><span class="stage-dot" aria-hidden="true">1</span><label>准备<progress value="0" max="100"></progress></label></div><div class="stage" data-phase="queued"><span class="stage-dot" aria-hidden="true">2</span><label>转换<progress value="0" max="100"></progress></label></div><div class="stage" data-phase="queued"><span class="stage-dot" aria-hidden="true">3</span><label>交付<progress value="0" max="100"></progress></label></div></div><div class="bar"><span class="muted" role="status">待运行</span><button class="button primary" type="button">运行任务</button></div></div>
  </main>
  <script>
    const stages = [...document.querySelectorAll('.stage')];
    const run = document.querySelector('button');
    const status = document.querySelector('[role=status]');
    run.addEventListener('click', () => {
      let current = 0; run.disabled = true;
      for (const [index, stage] of stages.entries()) { stage.dataset.phase = 'queued'; stage.querySelector('progress').value = 0; stage.firstElementChild.textContent = index + 1; }
      function next() {
        if (current === stages.length) { run.disabled = false; status.textContent = "任务完成"; return; }
        const stage = stages[current]; const bar = stage.querySelector('progress'); stage.dataset.phase = 'active'; status.textContent = bar.parentElement.firstChild.textContent;
        const timer = setInterval(() => { bar.value += 20; if (bar.value === 100) { clearInterval(timer); stage.dataset.phase = 'done'; stage.firstElementChild.textContent = '✓'; current += 1; next(); } }, 100);
      }
      next();
    });
  </script>
</body>
</html>

UI Skills 原创示例

相关参考