feat(ai-protocols): add MCP and A2A protocol demos and documentation

docs(ai-protocols): update AI protocols page with visual demos and detailed explanations
style(git-demos): improve responsive design and layout for git visualization components
refactor(ai-history): simplify and clean up demo components
chore: update config to register new AI protocol components
This commit is contained in:
sanbuphy
2026-02-22 18:26:19 +08:00
parent 4b83a4c23e
commit e5a5b9df5b
31 changed files with 5093 additions and 5333 deletions
@@ -2,48 +2,13 @@
<div class="logic-gate-demo">
<div class="demo-header">
<span class="title">逻辑门用开关做运算</span>
<span class="subtitle">切换输入 A / B同屏观察四种门的输出</span>
</div>
<div class="control-panel">
<span class="panel-hint">点按钮切换 0 / 1右侧四个门同步更新</span>
<div class="input-item">
<span class="input-label">输入 A</span>
<button class="input-btn" :class="{ on: inputA }" @click="inputA = !inputA">
{{ inputA ? '1' : '0' }}
</button>
</div>
<div class="input-item">
<span class="input-label">输入 B</span>
<button class="input-btn" :class="{ on: inputB }" @click="inputB = !inputB">
{{ inputB ? '1' : '0' }}
</button>
</div>
<span class="current-state">当前A={{ inputA ? 1 : 0 }}B={{ inputB ? 1 : 0 }}</span>
</div>
<div class="gate-grid">
<div v-for="gate in gates" :key="gate.name" class="gate-card">
<div class="gate-top">
<span class="gate-name">{{ gate.name }}</span>
<span class="gate-formula">{{ gate.formula }}</span>
</div>
<div class="gate-analogy">{{ gate.analogy }}</div>
<div class="gate-output-row">
<span class="output-label">输出</span>
<span
class="output-value"
:class="{ on: gateOutput(gate.name, inputA, inputB) }"
>
{{ gateOutput(gate.name, inputA, inputB) }}
</span>
<span class="output-hint">{{ gateOutput(gate.name, inputA, inputB) ? '(真 / 导通)' : '(假 / 断开)' }}</span>
</div>
</div>
</div>
<p class="intro">
输入 AB 只能是 0 1四种门按不同规则输出一个 0 1下面表格列出所有 4 种输入组合的结果
</p>
<div class="truth-section">
<div class="table-title">四种门真值表对照高亮行 = 当前输入</div>
<table>
<thead>
<tr>
@@ -56,65 +21,37 @@
</tr>
</thead>
<tbody>
<tr
v-for="row in truthRows"
:key="`${row.a}-${row.b}`"
:class="{
highlight:
row.a === (inputA ? 1 : 0) && row.b === (inputB ? 1 : 0)
}"
>
<tr v-for="row in truthRows" :key="`${row.a}-${row.b}`">
<td>{{ row.a }}</td>
<td>{{ row.b }}</td>
<td>{{ gateOutput('AND', !!row.a, !!row.b) }}</td>
<td>{{ gateOutput('OR', !!row.a, !!row.b) }}</td>
<td>{{ gateOutput('NOT', !!row.a, !!row.b) }}</td>
<td>{{ gateOutput('XOR', !!row.a, !!row.b) }}</td>
<td>{{ row.and }}</td>
<td>{{ row.or }}</td>
<td>{{ row.not }}</td>
<td>{{ row.xor }}</td>
</tr>
</tbody>
</table>
<ul class="col-meaning">
<li><strong>AND</strong>两个都是 1 才输出 1像串联都通才通</li>
<li><strong>OR</strong>有一个 1 就输出 1像并联一通就通</li>
<li><strong>NOT(A)</strong> A 取反0110</li>
<li><strong>XOR</strong>两个不同输出 1相同输出 0</li>
</ul>
</div>
<div class="info-box">
<strong>核心思想</strong>逻辑门用晶体管的"开关"组合实现基本运算AND 像串联OR 像并联NOT 取反XOR 判异所有复杂计算都由这四种基础操作构建而来
<strong>核心思想</strong>逻辑门用晶体管的开关组合实现这四种运算复杂计算都由它们组合而成
</div>
</div>
</template>
<script setup>
import { ref } from 'vue'
const inputA = ref(false)
const inputB = ref(false)
const gates = [
{ name: 'AND', formula: 'A && B', analogy: '串联:都为 1 才输出 1' },
{ name: 'OR', formula: 'A || B', analogy: '并联:任一为 1 就输出 1' },
{ name: 'NOT', formula: '!A', analogy: '取反:0→11→0' },
{ name: 'XOR', formula: 'A ⊕ B', analogy: '判异:不同为 1,相同为 0' }
]
const truthRows = [
{ a: 0, b: 0 },
{ a: 0, b: 1 },
{ a: 1, b: 0 },
{ a: 1, b: 1 }
{ a: 0, b: 0, and: 0, or: 0, not: 1, xor: 0 },
{ a: 0, b: 1, and: 0, or: 1, not: 1, xor: 1 },
{ a: 1, b: 0, and: 0, or: 1, not: 0, xor: 1 },
{ a: 1, b: 1, and: 1, or: 1, not: 0, xor: 0 }
]
const gateOutput = (name, a, b) => {
switch (name) {
case 'AND':
return a && b ? 1 : 0
case 'OR':
return a || b ? 1 : 0
case 'NOT':
return a ? 0 : 1
case 'XOR':
return a !== b ? 1 : 0
default:
return 0
}
}
</script>
<style scoped>
@@ -127,11 +64,7 @@ const gateOutput = (name, a, b) => {
}
.demo-header {
display: flex;
align-items: center;
gap: 0.5rem;
margin-bottom: 0.75rem;
flex-wrap: wrap;
margin-bottom: 0.5rem;
}
.demo-header .title {
@@ -139,169 +72,29 @@ const gateOutput = (name, a, b) => {
font-size: 1rem;
}
.demo-header .subtitle {
.intro {
font-size: 0.9rem;
color: var(--vp-c-text-2);
font-size: 0.82rem;
margin-left: 0.5rem;
}
.control-panel {
display: flex;
align-items: center;
gap: 0.6rem;
margin-bottom: 0.75rem;
flex-wrap: wrap;
padding: 0.5rem 0.65rem;
background: var(--vp-c-bg);
border: 1px solid var(--vp-c-divider);
border-radius: 8px;
}
.panel-hint {
font-size: 0.8rem;
color: var(--vp-c-text-2);
}
.current-state {
font-size: 0.8rem;
color: var(--vp-c-text-2);
margin-left: auto;
font-variant-numeric: tabular-nums;
}
.input-item {
display: inline-flex;
align-items: center;
gap: 0.4rem;
background: var(--vp-c-bg-alt);
border: 1px solid var(--vp-c-divider);
border-radius: 999px;
padding: 0.2rem 0.5rem;
font-size: 0.85rem;
}
.input-label {
font-size: 0.82rem;
color: var(--vp-c-text-2);
}
.input-btn {
width: 28px;
height: 28px;
border: 1px solid var(--vp-c-divider);
background: var(--vp-c-bg-alt);
border-radius: 50%;
cursor: pointer;
font-weight: bold;
transition: all 0.2s;
}
.input-btn.on {
background: var(--vp-c-brand);
color: white;
border-color: var(--vp-c-brand);
}
.gate-grid {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 0.5rem;
margin-bottom: 0.75rem;
}
.gate-card {
background: var(--vp-c-bg);
border: 1px solid var(--vp-c-divider);
border-radius: 8px;
padding: 0.55rem;
display: flex;
flex-direction: column;
gap: 0.35rem;
}
.gate-top {
display: flex;
align-items: center;
justify-content: space-between;
}
.gate-name {
font-weight: bold;
font-size: 0.85rem;
color: var(--vp-c-brand-1);
}
.gate-formula {
font-family: monospace;
font-size: 0.72rem;
color: var(--vp-c-text-3);
}
.gate-analogy {
font-size: 0.72rem;
color: var(--vp-c-text-2);
line-height: 1.3;
}
.gate-output-row {
display: flex;
align-items: center;
gap: 0.35rem;
margin-top: 0.1rem;
}
.output-label {
font-size: 0.7rem;
color: var(--vp-c-text-3);
}
.output-hint {
font-size: 0.68rem;
color: var(--vp-c-text-3);
}
.output-value {
width: 24px;
height: 24px;
display: inline-flex;
align-items: center;
justify-content: center;
border: 1px solid var(--vp-c-divider);
border-radius: 4px;
background: var(--vp-c-bg-alt);
font-weight: bold;
font-size: 0.85rem;
flex-shrink: 0;
}
.output-value.on {
background: var(--vp-c-success);
color: white;
border-color: var(--vp-c-success);
margin: 0 0 0.75rem;
line-height: 1.5;
}
.truth-section {
margin-bottom: 0;
}
.table-title {
font-weight: bold;
font-size: 0.82rem;
margin-bottom: 0.4rem;
}
table {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
font-size: 0.8rem;
font-size: 0.88rem;
margin-bottom: 0.75rem;
}
th,
td {
border: 1px solid var(--vp-c-divider);
padding: 0;
height: 2rem;
padding: 0.4rem 0.5rem;
vertical-align: middle;
text-align: center;
font-variant-numeric: tabular-nums;
@@ -312,29 +105,36 @@ th {
font-weight: 600;
}
tr.highlight {
background: var(--vp-c-brand-soft);
.col-meaning {
margin: 0;
padding-left: 1.25rem;
font-size: 0.85rem;
color: var(--vp-c-text-2);
line-height: 1.6;
}
.col-meaning li {
margin-bottom: 0.25rem;
}
.col-meaning strong {
color: var(--vp-c-text-1);
font-variant-numeric: tabular-nums;
}
.info-box {
display: flex;
gap: 0.25rem;
background: var(--vp-c-bg-alt);
padding: 0.75rem;
border-radius: 6px;
font-size: 0.85rem;
color: var(--vp-c-text-2);
margin-top: 0.75rem;
display: flex;
gap: 0.25rem;
}
.info-box strong {
white-space: nowrap;
flex-shrink: 0;
}
@media (max-width: 640px) {
.gate-grid {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
</style>