> ## Documentation Index
> Fetch the complete documentation index at: https://docs.akria.net/llms.txt
> Use this file to discover all available pages before exploring further.

# 第10组：GitOps 安全 | GitOps & Security

> 测试你对 Git, Webhook, Auth 等工具的理解

<a href="quiz" className="text-emerald-600 hover:underline text-sm">← 返回选单</a>

## 📝 词汇测验

export const QuizRunner = () => {
  const questions = [
    {
        "q": "'Repository' 意为：",
        "o": [
            "垃圾桶",
            "仓库/代码库",
            "工厂",
            "商店"
        ],
        "a": "仓库/代码库",
        "h": "存储代码的地方。"
    },
    {
        "q": "'Branch' 指：",
        "o": [
            "主线",
            "分支",
            "树叶",
            "根部"
        ],
        "a": "分支",
        "h": "并行的开发线条。"
    },
    {
        "q": "'Merge' 意为：",
        "o": [
            "拆分",
            "合并",
            "重写",
            "删除"
        ],
        "a": "合并",
        "h": "将分支代码整合。"
    },
    {
        "q": "'Conflict' 意为：",
        "o": [
            "合作",
            "冲突",
            "和平",
            "交流"
        ],
        "a": "冲突",
        "h": "不同人修改了同一处代码。"
    },
    {
        "q": "'Webhook' 意为：",
        "o": [
            "钩子/回调地址",
            "木马",
            "浏览器",
            "插件"
        ],
        "a": "钩子/回调地址",
        "h": "由事件触发的 HTTP 回调。"
    },
    {
        "q": "'Auth' 常作为什么的简写？",
        "o": [
            "Author",
            "Authentication/认证",
            "Automatic",
            "Authority"
        ],
        "a": "Authentication/认证",
        "h": "验证身份。"
    },
    {
        "q": "'Encryption' 意为：",
        "o": [
            "公开",
            "加密",
            "解压",
            "分发"
        ],
        "a": "加密",
        "h": "保护数据不被阅读。"
    },
    {
        "q": "'Proxy' 意为：",
        "o": [
            "直连",
            "代理",
            "断连",
            "攻击"
        ],
        "a": "代理",
        "h": "代表客户端或服务端发请求。"
    },
    {
        "q": "'Firewall' 意为：",
        "o": [
            "灭火器",
            "防火墙",
            "安全门",
            "警报器"
        ],
        "a": "防火墙",
        "h": "网络访问控制安全屏障。"
    },
    {
        "q": "'Version' 意为：",
        "o": [
            "旧款",
            "版本",
            "书籍",
            "报纸"
        ],
        "a": "版本",
        "h": "软件演进的状态标识。"
    }
];

  const [idx, setIdx] = React.useState(0);
  const [scr, setScr] = React.useState(0);
  const [fin, setFin] = React.useState(false);
  const [sel, setSel] = React.useState(null);
  const [ok, setOk] = React.useState(null);
  const [ready, setReady] = React.useState(false);
  const [sq, setSq] = React.useState([]);

  React.useEffect(() => {
    setReady(true);
    setSq(questions.map(q => ({ ...q, o: [...q.o].sort(() => Math.random() - 0.5) })));
  }, []);

  const onAnswer = (o) => {
    if (sel) return;
    setSel(o);
    const isOk = o === questions[idx].a;
    setOk(isOk);
    if (isOk) setScr(scr + 1);
    setTimeout(() => {
      if (idx + 1 < questions.length) {
        setIdx(idx + 1);
        setSel(null);
        setOk(null);
      } else {
        setFin(true);
      }
    }, 1500);
  };

  if (!ready) return <div className="p-10 text-center opacity-50">Loading...</div>;

  if (fin) {
    return (
      <div className="p-10 rounded-2xl bg-white dark:bg-gray-900 border text-center shadow-xl">
        <div className="text-2xl font-bold text-emerald-600 mb-4">测试完成！</div>
        <div className="text-lg mb-8">得分: {scr} / {questions.length}</div>
        <div className="flex gap-4 justify-center">
            <button className="bg-emerald-600 hover:bg-emerald-700 text-white px-8 py-3 rounded-lg font-bold transition-all" onClick={() => {setIdx(0);setScr(0);setFin(false);setSel(null);setOk(null);}}>重新开始</button>
            <a href="quiz" className="bg-gray-100 hover:bg-gray-200 text-gray-700 px-8 py-3 rounded-lg font-bold transition-all no-underline">返回选单</a>
        </div>
      </div>
    );
  }

  const curr = sq[idx];
  if (!curr) return null;

  return (
    <div className="p-6 rounded-2xl bg-white dark:bg-gray-900 border shadow-lg">
      <div className="mb-4 text-xs opacity-50 font-mono text-right">进度: {idx + 1} / {questions.length}</div>
      
      <div className="h-1 bg-gray-100 rounded-full mb-6 overflow-hidden">
        <div className="h-full bg-emerald-500 transition-all duration-300" style={{width: ((idx + 1) / questions.length * 100) + '%'}}></div>
      </div>

      <div className="text-xl font-bold mb-8 text-gray-900 dark:text-gray-100">{curr.q}</div>
      
      <div className="space-y-3">
        {curr.o.map((o, i) => (
          <button 
            key={i} 
            className={"w-full text-left p-4 rounded-xl border-2 transition-all font-medium " + (sel === o ? (ok ? "bg-emerald-50 dark:bg-emerald-900/20 border-emerald-500 text-emerald-700 dark:text-emerald-400" : "bg-red-50 dark:bg-red-900/20 border-red-500 text-red-700 dark:text-red-400") : (sel && o === curr.a ? "bg-emerald-50 dark:bg-emerald-900/20 border-emerald-500 text-emerald-700 dark:text-emerald-400 opacity-80" : "bg-gray-50 dark:bg-gray-800 border-gray-100 dark:border-gray-700 hover:border-emerald-500 hover:shadow-md text-gray-700 dark:text-gray-300"))}
            onClick={() => onAnswer(o)}
          >
            {o}
          </button>
        ))}
      </div>
      
      {sel && (
        <div className={"mt-6 p-4 rounded-lg border-l-4 " + (ok ? "bg-emerald-50 dark:bg-emerald-900/20 border-emerald-500 text-emerald-800 dark:text-emerald-300" : "bg-red-50 dark:bg-red-900/20 border-red-500 text-red-800 dark:text-red-300")}>
          <div className="font-bold flex items-center gap-2">
            {ok ? "✅ 正确!" : "❌ 错误"}
            <span className="font-normal opacity-70 text-sm ml-auto">正确答案: {curr.a}</span>
          </div>
          <div className="text-sm opacity-80 mt-2">💡 提示: {curr.h}</div>
        </div>
      )}
    </div>
  );
};

<QuizRunner />
