升级并完成 Razor Pages + Blazor Web App 骨架。

- 项目现为 net10.0,使用本机 .NET SDK 10.0.400 / runtime 10.0.11。
- MySQL 驱动当前最新兼容版本是 Pomelo 9.0,因此 EF Core 保持在 9.0.11;迁移已可正常读取。
- Razor Pages 静态 SSR:
  - [公开首页](E:\\election system\\src\\ElectionSystem.Api\\Pages\\Index.cshtml)
  - [公开公告示例](E:\\election system\\src\\ElectionSystem.Api\\Pages\\Content\\Notice.cshtml)
- Blazor Interactive Server:
  - [投票交互预览](E:\\election system\\src\\ElectionSystem.Api\\Components\\Pages\\BallotPreview.razor),仅演示交互,不提交或保存选票。
- 已加入 Blazor 所需的反伪造中间件,架构说明同步更新:[architecture.md](E:\\election system\\docs\\architecture.md)。
This commit is contained in:
biss committed 2026-08-29 11:31:28 +08:00
1 parent ab935480b0
commit 2eddb1217e
17 files changed
+251 -9

No files matched your search

@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="组织内部选举与投票信息系统" />
<base href="/" />
<link rel="stylesheet" href="@Assets["css/site.css"]" />
<HeadOutlet />
</head>
<body>
<Routes />
<script src="@Assets["_framework/blazor.web.js"]"></script>
</body>
</html>
@@ -0,0 +1,12 @@
@inherits LayoutComponentBase
<header class="site-header">
<a class="brand" href="/">选举与投票信息系统</a>
<nav aria-label="主导航">
<a href="/content/notice">公开公告</a>
<a href="/ballot-preview">投票交互预览</a>
<a href="/api/system/info">API</a>
</nav>
</header>
@Body
<footer class="site-footer">所有时间和结果以活动正式公告为准。</footer>
@@ -0,0 +1,47 @@
@page "/ballot-preview"
@rendermode InteractiveServer
<PageTitle>投票交互预览</PageTitle>
<main class="container">
<p class="eyebrow">INTERACTIVE SERVER</p>
<h1>投票交互预览</h1>
<p>此页面用于验证嵌入式 Blazor Server 交互能力,不连接选举数据,也不会提交或记录任何选票。</p>
<section class="panel" aria-labelledby="selection-title">
<h2 id="selection-title">模拟选择</h2>
@foreach (var candidate in candidates)
{
<label class="option">
<input type="checkbox" checked="@selected.Contains(candidate)" @onchange="() => Toggle(candidate)" />
@candidate
</label>
}
<p aria-live="polite">当前已选:@selected.Count 人(本活动最多可选 2 人)。</p>
@if (selectionError is not null)
{
<p class="error" role="alert">@selectionError</p>
}
</section>
</main>
@code {
private readonly string[] candidates = ["候选人甲", "候选人乙", "候选人丙"];
private readonly HashSet<string> selected = [];
private string? selectionError;
private void Toggle(string candidate)
{
selectionError = null;
if (!selected.Add(candidate))
{
selected.Remove(candidate);
return;
}
if (selected.Count > 2)
{
selected.Remove(candidate);
selectionError = "最多只能选择 2 人。";
}
}
}
Loaded 3 of 17 files, more files were not shown because too many files have changed in this diff. Show more