第一次运行实验时自动建好预置的数据库

- 运行时带上当前实验;实验有 database.sql 而学生还没有其中的库时,先建好这些库
  (已有的库不动,保留学生的数据);建库失败不影响运行
- 教材项目 8 要"附加"现成的 WisdomCampus 库,学生不用先去数据库页面恢复

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
xuyueandClaude Opus 5.5 committed 2026-10-23 15:14:49 +08:00
1 parent 5ae07b851d
commit 10c50265b2
5 files changed
+27 -8

No files matched your search

+4 -1
View File
@@ -409,7 +409,10 @@ function restoreOriginal() {
function run() {
if (running.value) return
session.run(files.value.map((f) => ({ ...f })))
session.run(
files.value.map((f) => ({ ...f })),
props.assignmentId ? assignment.value?.sampleId : sampleId.value,
)
}
</script>
+3 -2
View File
@@ -109,7 +109,8 @@ export function createRunSession() {
socket?.send(JSON.stringify(message))
}
async function run(files: SourceFile[]) {
/** sampleId:当前实验(服务器据此在第一次运行时建好实验预置的数据库) */
async function run(files: SourceFile[], sampleId?: string) {
await connect()
state.diagnostics = []
state.console = ''
@@ -121,7 +122,7 @@ export function createRunSession() {
nodes.clear()
for (const url of images.values()) URL.revokeObjectURL(url)
images.clear()
send({ type: 'run', files })
send({ type: 'run', files, sampleId })
}
/** 调节实训台环境(滑块、传感器开关) */