第 0 阶段:教材项目 2 任务 1 在网页中原样运行

- runtime:仿真 WinForms 子集(Form、Button、Label、TextBox、ComboBox、
  GroupBox、Timer、MessageBox、界面线程消息循环、跨线程检查)、
  教材设备类库(DeviceCtrlHelper、LED 控件)、运行器(常驻编译服务 + 运行模式)
- server:Bun + Hono,WebSocket 会话,每次运行一个进程,消息转发
- web:Vue + Naive UI,WinForms 风格窗体渲染、MessageBox、实训台 LED 屏
- 端到端测试与 100 个程序并发的压力测试
- 教材逐任务摘要(docs/教材摘要)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
xuyueandClaude Opus 5.5 committed 2026-10-22 10:15:14 +08:00
commit 98be8331bc
71 files changed
+7919

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
import { readdir } from 'node:fs/promises'
import { join, relative, resolve } from 'node:path'
import type { SourceFile } from '@iot/shared'
const SAMPLES_DIR = resolve(import.meta.dir, '../../samples')
export interface SampleInfo {
id: string
title: string
}
/** 示例工程:samples/ 下每个子目录是一个工程,meta.json 里写标题 */
export async function listSamples(): Promise<SampleInfo[]> {
const entries = await readdir(SAMPLES_DIR, { withFileTypes: true })
const samples: SampleInfo[] = []
for (const entry of entries) {
if (!entry.isDirectory()) continue
const meta = await Bun.file(join(SAMPLES_DIR, entry.name, 'meta.json')).json()
samples.push({ id: entry.name, title: meta.title })
}
return samples.sort((a, b) => a.id.localeCompare(b.id))
}
export async function loadSample(id: string): Promise<SourceFile[] | null> {
const dir = resolve(SAMPLES_DIR, id)
if (!dir.startsWith(`${SAMPLES_DIR}/`)) return null
const files: SourceFile[] = []
const glob = new Bun.Glob('**/*.cs')
for await (const path of glob.scan({ cwd: dir })) {
files.push({ path: relative(dir, join(dir, path)), content: await Bun.file(join(dir, path)).text() })
}
return files.length > 0 ? files.sort((a, b) => a.path.localeCompare(b.path)) : null
}