feat(i18n): add AI history components internationalization support

- Add useI18n composable and ai-history locale files
- Refactor 10 AI history Vue components to support i18n (GPTEvolutionDemo, AIErasComparisonDemo, AiEvolutionDemo, etc.)
- Add English version of AI history appendix article
- Add English translations for stage-1 appendix-articles:
  - vibe-coding-tools-snake-game-tutorial.md
  - vibe-coding-tools-build-website-with-ai-coding-and-design-agents.md
- Use relative paths to reference Chinese version images
- Update appendix sidebar config to use English AI history link
This commit is contained in:
sanbuphy
2026-02-26 09:33:06 +08:00
parent d2809706e5
commit de86489421
17 changed files with 1451 additions and 140 deletions
@@ -2,13 +2,13 @@
<div class="demo-card">
<div class="perceptron-layout">
<div class="inputs-col">
<div v-for="inp in inputs" :key="inp.label" class="input-node">
<div v-for="(inp, i) in inputs" :key="i" class="input-node">
<span class="node-circle">{{ inp.val }}</span>
<span class="node-label">{{ inp.label }}</span>
<span class="node-label">{{ featureLabels[i] }}</span>
</div>
</div>
<div class="weights-col">
<div v-for="inp in inputs" :key="inp.label" class="weight-arrow">
<div v-for="(inp, i) in inputs" :key="i" class="weight-arrow">
<span class="arrow"></span>
<span class="w-tag">×{{ inp.weight }}</span>
</div>
@@ -18,7 +18,7 @@
<div class="n-sym">Σ</div>
<div class="n-val">{{ sum }}</div>
</div>
<span class="bias-tag">偏置 {{ bias }}</span>
<span class="bias-tag">{{ t('perceptron.biasLabel') }} {{ bias }}</span>
</div>
<div class="act-col">
<span class="arrow big"></span>
@@ -28,19 +28,23 @@
<div class="output-col">
<div class="output-node" :class="{ on: output === 1 }">
<span class="out-val">{{ output }}</span>
<span class="out-lbl">{{ output ? '激活' : '静默' }}</span>
<span class="out-lbl">{{ output ? t('perceptron.activated') : t('perceptron.silent') }}</span>
</div>
</div>
</div>
<div class="caption">
输入特征&emsp; 乘以权重重要性&emsp; 求和 + 偏置&emsp; 超过阈值就激活输出 1否则输出 0
</div>
<div class="caption">{{ t('perceptron.caption') }}</div>
</div>
</template>
<script setup>
import { computed } from 'vue'
const inputs = [{ label: '特征 x₁', val: 1, weight: 0.6 }, { label: '特征 x₂', val: 0, weight: 0.4 }]
import { useI18n } from '../../../composables/useI18n.js'
import { aiHistoryLocale } from '../../../locales/ai-history/index.js'
const { t, messages } = useI18n(aiHistoryLocale)
const featureLabels = computed(() => messages.value.perceptron?.features ?? [])
const inputs = [{ val: 1, weight: 0.6 }, { val: 0, weight: 0.4 }]
const bias = -0.3
const sum = computed(() => Number((inputs.reduce((s, i) => s + i.val * i.weight, 0) + bias).toFixed(2)))
const output = computed(() => sum.value > 0 ? 1 : 0)