优化cms
This commit is contained in:
1 parent
f56a63d4ce
commit
1f7603923e
9 files changed
+183
-42
No files matched your search
@@ -10,6 +10,8 @@
|
||||
|
||||
初始化完成后,在 **Configuration → Features** 启用 `ElectionSystem.Cms.PublicContent`。该模块的数据迁移会自动创建下列固定公开栏目和公共元数据字段;停用模块不会删除已有公开内容。
|
||||
|
||||
启用后请刷新后台(或重新登录)。左侧 **Content → Information Disclosure** 会出现八个固定栏目入口,每个入口直接打开对应内容类型的筛选列表并可新建内容。若入口不可见,确认当前角色已拥有 Orchard Core 的 **List Content** 权限;站点管理员默认具备该权限。
|
||||
|
||||
## 公开前台接入
|
||||
|
||||
选举主程序的 Razor Pages 通过 CMS 主机的只读 `GET /api/public-content` 接口读取内容,绝不直连 CMS 数据库。该接口只允许固定公开内容类型,并且只返回已发布版本的标题、正文、发布时间和公开元数据;草稿、历史版本、选民资料、投票状态、线下计票和内部审计记录均不会返回。
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"launchUrl": "",
|
||||
"applicationUrl": "http://localhost:5037",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
@@ -23,7 +23,7 @@
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"launchUrl": "",
|
||||
"applicationUrl": "https://localhost:7053;http://localhost:5037",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using OrchardCore.Contents;
|
||||
using OrchardCore.Navigation;
|
||||
using OrchardCore.Security.Permissions;
|
||||
|
||||
namespace ElectionSystem.Cms.PublicContent;
|
||||
|
||||
/// <summary>
|
||||
/// Makes the fixed election disclosure sections visible in the CMS administration menu.
|
||||
/// </summary>
|
||||
public sealed class AdminMenu(IStringLocalizer<AdminMenu> stringLocalizer) : AdminNavigationProvider
|
||||
{
|
||||
private readonly IStringLocalizer _stringLocalizer = stringLocalizer;
|
||||
|
||||
protected override ValueTask BuildAsync(NavigationBuilder builder)
|
||||
{
|
||||
builder.Add(_stringLocalizer["Content"], content => content
|
||||
.Add(_stringLocalizer["Information Disclosure"], "10", disclosure => disclosure
|
||||
.AddClass("election-public-content")
|
||||
.Id("election-public-content")
|
||||
.LinkToFirstChild(true)
|
||||
.Add(_stringLocalizer["Election Notices"], "1", item => AddContentList(item, "ElectionNotice"))
|
||||
.Add(_stringLocalizer["Rules and Policies"], "2", item => AddContentList(item, "PolicyDocument"))
|
||||
.Add(_stringLocalizer["Candidate Disclosures"], "3", item => AddContentList(item, "CandidateDisclosure"))
|
||||
.Add(_stringLocalizer["Voter Guides"], "4", item => AddContentList(item, "VoterGuide"))
|
||||
.Add(_stringLocalizer["Result Announcements"], "5", item => AddContentList(item, "ResultAnnouncement"))
|
||||
.Add(_stringLocalizer["Frequently Asked Questions"], "6", item => AddContentList(item, "PublicFaq"))
|
||||
.Add(_stringLocalizer["Downloads"], "7", item => AddContentList(item, "DownloadAsset"))
|
||||
.Add(_stringLocalizer["Archives"], "8", item => AddContentList(item, "ArchiveRecord"))));
|
||||
|
||||
return ValueTask.CompletedTask;
|
||||
}
|
||||
|
||||
private static NavigationItemBuilder AddContentList(NavigationItemBuilder item, string contentType) => item
|
||||
.Action("List", "Admin", new RouteValueDictionary
|
||||
{
|
||||
["area"] = "OrchardCore.Contents",
|
||||
["contentTypeId"] = contentType
|
||||
})
|
||||
.Permission(CommonPermissions.ListContent)
|
||||
.LocalNav();
|
||||
}
|
||||
Loaded 3 of 9 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user