{"id":14973147,"url":"https://github.com/ldqk/masuit.myblogs","last_synced_at":"2025-05-14T18:07:16.524Z","repository":{"id":37706257,"uuid":"140912912","full_name":"ldqk/Masuit.MyBlogs","owner":"ldqk","description":"基于C#/.NET8的 masuit.org个人博客站项目源码，https://masuit.org ，供参考、学习、引用、非商业性质的部署。","archived":false,"fork":false,"pushed_at":"2025-04-24T03:29:12.000Z","size":521005,"stargazers_count":1106,"open_issues_count":1,"forks_count":296,"subscribers_count":36,"default_branch":"master","last_synced_at":"2025-04-24T04:26:18.917Z","etag":null,"topics":["angularjs","blog","cms","hangfire","ip2region-maxmind","lucene","masuit","mvc","myblogs","net6","redis"],"latest_commit_sha":null,"homepage":"https://masuit.org","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ldqk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-07-14T03:30:37.000Z","updated_at":"2025-04-24T03:29:18.000Z","dependencies_parsed_at":"2024-01-12T12:04:45.192Z","dependency_job_id":"a8bd28a3-6c33-4d38-8263-601418f676e5","html_url":"https://github.com/ldqk/Masuit.MyBlogs","commit_stats":{"total_commits":1153,"total_committers":5,"mean_commits":230.6,"dds":0.005203816131829964,"last_synced_commit":"a1aaf8195a28fb27b36ff1eb66123af14251237a"},"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ldqk%2FMasuit.MyBlogs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ldqk%2FMasuit.MyBlogs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ldqk%2FMasuit.MyBlogs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ldqk%2FMasuit.MyBlogs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ldqk","download_url":"https://codeload.github.com/ldqk/Masuit.MyBlogs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254198515,"owners_count":22030966,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angularjs","blog","cms","hangfire","ip2region-maxmind","lucene","masuit","mvc","myblogs","net6","redis"],"created_at":"2024-09-24T13:48:13.115Z","updated_at":"2025-05-14T18:07:11.508Z","avatar_url":"https://github.com/ldqk.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"### Masuit.MyBlogs\n\u003ca href=\"https://gitee.com/masuit/Masuit.MyBlogs\"\u003e\u003cimg src=\"https://gitee.com/static/images/logo-black.svg\" height=\"32\"\u003e\u003c/a\u003e \u003ca href=\"https://github.com/ldqk/Masuit.MyBlogs\"\u003e\u003cimg src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/9/95/Font_Awesome_5_brands_github.svg/54px-Font_Awesome_5_brands_github.svg.png\" height=\"32\"\u003e\u003cimg src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/2/29/GitHub_logo_2013.svg/128px-GitHub_logo_2013.svg.png\" height=\"32\"\u003e\u003c/a\u003e  \n\n个人博客站项目源码，高性能高安全性低占用的博客系统，这也许是我写过的性能最高的web项目了。**仅3MB的代码量！** 目前日均处理请求数80-600w次，同时在线活跃用户数60-600人，**数据量累计已达到数百万条**，数据库+Redis+网站主程序同时运行在一台4核8GB的机器上，浏览器页面请求秒级响应，CPU平均使用率控制在10%左右，内存占用控制在400MB左右。\n![任务管理器](https://img11.360buyimg.com/ddimg/jfs/t1/170269/23/18655/93697/6076eb8fE82d545e7/78f0815f7311cd49.png)\n![image](https://user-images.githubusercontent.com/20254980/206615289-fa975ddc-4534-47f8-9d80-d8ab637b0157.png)\n\n![image](https://user-images.githubusercontent.com/20254980/129124476-88a324ac-cfd2-4e9b-8fb9-e84e12d04051.png)\n\n### 演示站点\n测试站点1：[https://masuit.org](https://masuit.org)，测试站点2：[https://masuit.com](https://masuit.com)，测试站点3：[https://ldqk.xyz](https://ldqk.xyz)\n\n[![LICENSE](https://img.shields.io/badge/license-Anti%20996-blue.svg)](https://github.com/996icu/996.ICU/blob/master/LICENSE) ![codeSize](https://img.shields.io/github/languages/code-size/ldqk/Masuit.MyBlogs.svg) ![language](https://img.shields.io/github/languages/top/ldqk/Masuit.MyBlogs.svg)\n\n### 请注意：\n一旦使用本开源项目以及引用了本项目或包含本项目代码的公司因为违反劳动法（包括但不限定非法裁员、超时用工、雇佣童工等）在任何法律诉讼中败诉的，一经发现，本项目作者有权利追讨本项目的使用费（**公司工商注册信息认缴金额的2-5倍作为本项目的授权费**），或者直接不允许使用任何包含本项目的源代码！任何性质的`外包公司`或`996公司`需要使用本类库，请联系作者进行商业授权！其他企业或个人可随意使用不受限。996那叫用人，也是废人。8小时工作制才可以让你有时间自我提升，将来有竞争力。反对996，人人有责！\n\n## Star趋势  \n\u003cimg src=\"https://starchart.cc/ldqk/Masuit.MyBlogs.svg\"\u003e    \n\n### 前端请求支援\n目前网站前端页面的代码比较零乱，到处都是，大家想吐槽的尽管吐槽吧，也想找个人帮忙设计下整体的前端页面，有兴趣愿意贡献代码的的小伙伴，欢迎Pull Request吧！😂😂\n### 项目主要技术栈\n.NET8  \nASP.NET Core MVC  \nBlazor  \nEntity Framework Core  \nMasuit.Tools  \nMasuit.LuceneEFCore.SearchEngine  \nHangfire  \n### 开发环境\n操作系统：Windows 11 23h2  \nIDE：Visual Studio 2022 v17.8  \n数据库：PostgreSQL 16.x  \nRedis：redis-server-windows 7.x  \n运行时：必须是.NET 8 \n### 当前运行环境\n操作系统：Windows Server 2019  \n数据库：PostgreSQL 16.x  \nRedis：redis-server-windows 7.x  \n运行时：.NET 8  \n服务器配置：4核+8GB+6Gbps  \n承载流量：单日请求量平均600w左右，单日带宽1TB左右  \n`请勿使用阿里云、百度云等活动超卖机运行本程序，否则卡出翔！！！`  \n`如何判断服务器商是否有超卖：给你的服务器跑个分，如果跑分接近于网络上该处理器公布的分数，则不是超卖的机器，计算公式：总分/核心数进行比较，由于是虚拟机，如果单独比较单核跑分，没有参考意义`\n### 基础设施要求\n||最低配置|推荐配置|豪华配置|至尊配置|\n| --------   | -----:   | :----: | :----: | :----: |\n|CPU|1核|2核|2核|4核|\n|内存|1GB|2GB|4GB|8GB|\n|带宽|1Mbps|1Mbps|5Mbps|1000Mbps+|\n|数据库|pgsql 9|pgsql 14|pgsql 15+|pgsql 16+|\n|缓存组件|Redis 3.2+|Redis 5.0+|Redis 5.0+|Redis 7.0+|\n|备注|玩玩而已|几个人同时访问|几百个人同时访问，单日请求量600w以下|单日请求量600w以上|\n### 主要功能\n#### 服务器性能监控\n可直接在线实时监控服务器的运行状态，包括CPU、网络带宽、磁盘使用率、内存占用等情况，百分位统计和图表统计，可记录最近一天的服务器健康状态，通过websocket进行数据的推送，仅支持Windows，且需要Windows安装最新的更新。\n![image](https://user-images.githubusercontent.com/20254980/127088294-89c63e04-399c-45a1-ae47-5b55ea86a05d.png)\n\n#### 文章管理\n- 包含文章审核、文章合并、文章列表的增删查改、分类管理、专题管理；\n- 文章审核：当用户在前台页进行投稿后，会进入审核状态，审核通过后，才会在前台页的文章列表中展示出来。\n- 文章合并：当用户在前台页进行了文章的编辑后，会创建出文章的合并请求，当后台管理进行相应的合并操作后，前台用户的修改才会正式生效，可以直接合并、编辑并合并和拒绝合并，拒绝时，修改人会收到相应的邮件通知。\n- 文章操作：可对文章进行修改、新增、置顶、临时删除(下架)、还原、永久删除、禁止评论等操作，编辑后的文章会生成历史版本。文章支持模板变量。\n- 分类管理：对文章的分类进行增删查改和文章的移动等操作，与文章的关系：一对多。\n- 专题管理：对文章的专题进行管理，与文章的关系：多对多。\n- 快速分享：首页快速分享栏目的管理。\n![image](https://user-images.githubusercontent.com/20254980/127089680-c8f57334-2b7e-4ca2-a2a2-01a50d58e61b.png)\n![image](https://user-images.githubusercontent.com/20254980/127088470-15fabe44-c45f-4801-b2fb-8fc034a593dd.png)\n![image](https://user-images.githubusercontent.com/20254980/127089714-d85a3f8b-bb8e-4a0a-b6c1-0e4aead194e2.png)\n![image](https://user-images.githubusercontent.com/20254980/127089725-25a5fa87-2c70-49bd-ada9-e65a8c71797d.png)\n![image](https://user-images.githubusercontent.com/20254980/127089745-70ec7ac2-b80f-4059-abae-7ba362f02b60.png)\n![image](https://user-images.githubusercontent.com/20254980/127089763-57457c59-cfdf-4b7d-a31b-8123dc944c88.png)\n\n#### 评论和留言管理\n对前台用户提交的留言和评论进行审核，当前台用户提交的内容可能包含有敏感词时，会进入人工审核，审核成功才会在前台页中展示。\n#### 消息通知\n站内消息包含评论、留言、投稿、文章合并等通知。\n#### 公告管理\n对网站的公告进行增删查改管理。支持定时上下架发布。\n![image](https://user-images.githubusercontent.com/20254980/127088599-9d9d6b8b-9253-4f3d-8b9a-80965c002422.png)\n\n#### 杂项页管理\n一些通用的页面管理，可自由灵活的创建静态页面。\n![image](https://user-images.githubusercontent.com/20254980/127088620-3ea1e808-7ce2-4ede-9a62-765609cfda94.png)\n\n#### 系统设置\n- 包含系统的全局设置、防火墙管理、网站运行日志记录、友链管理、邮件模板的管理。\n- 全局设置：网站的一些基本配置和SEO相关操作等；\n- 防火墙：对网站的所有请求进行全局流量的拦截，让规则内的请求阻止掉，支持黑名单、白名单、IP地址段、国家或地区、关键词审查等规则；\n- 模板变量：针对文章内容的通用内容生成，变量只能添加不能删除。\n![image](https://user-images.githubusercontent.com/20254980/127088748-13d56e4a-f5e0-4c59-9135-0af935d70976.png)\n![image](https://user-images.githubusercontent.com/20254980/127088776-b95f8e8d-5f07-4937-8a9f-6a975ed29e31.png)\n![image](https://user-images.githubusercontent.com/20254980/127089076-2599c484-9323-4d1a-82e5-61ef833ed4e3.png)\n![image](https://user-images.githubusercontent.com/20254980/127089090-5b0dedcb-6be7-46ce-82e7-b4fcb50ea032.png)\n![image](https://user-images.githubusercontent.com/20254980/127089200-cca28f8a-87bb-4a8b-b581-91c0572714c9.png)\n\n#### 广告管理\n主动式的广告投放管理，支持竞价排名，支持在banner、边栏、页内、列表内的广告展示，竞价或权重的高低决定广告出现的概率。支持按地区进行投放。\n![image](https://user-images.githubusercontent.com/20254980/127089325-27b5bf4d-49ea-41ea-aae6-8829924bcc92.png)\n![image](https://user-images.githubusercontent.com/20254980/127089358-7bab075c-5bb7-41ea-8900-29a2eecb71de.png)\n\n#### 赞助管理\n对网站打赏进行增删查改操作，自动掩码。\n![image](https://user-images.githubusercontent.com/20254980/127089429-beb5baf0-c1d3-4880-85c0-9f897fb0de75.png)\n\n#### 搜索统计\n当前台用户每Session周期内的关键词搜索，不重复的关键词将会被记录，用于热词统计，仅记录最近一个月内的所有搜索关键词，用于统计当月、7天以及当天的搜索热词。\n![image](https://user-images.githubusercontent.com/20254980/127089504-2c32288d-aa0d-4331-a3a2-90e97ba9f7a2.png)\n\n#### 任务管理\nhangfire的可视化管理页面\n#### 文件管理\n服务器文件的在线管理，支持浏览、预览、压缩、解压缩、创建文件夹、上传、下载、打包下载等文件的基本操作。\n![image](https://user-images.githubusercontent.com/20254980/127089568-5d3bcef6-5ad7-4f44-b30d-b7253be2d3fb.png)\n\n### 项目架构\n- 项目采用单体架构，方便部署和配置，传统的MVC模式，ASP.NET Core MVC+EF Core的简单架构。  \n- Controller→Service→Repository→DbContext  \n![image](https://git.imweb.io/ldqk/imgbed/raw/master/5ccbcc714c3db.jpg)  \n### 项目文件夹定义：\nApp_Data：存放网站的一些常规数据，以文本的形式存在，这类数据不需要频繁更新的。  \n┠─cert文件夹：存放https证书  \n┠─ban.txt：敏感词库  \n┠─CustomKeywords.txt：搜索分词词库  \n┠─denyip.txt：IP地址黑名单  \n┠─DenyIPRange.txt：IP地址段黑名单  \n┠─GeoLite2-City.mmdb：MaxMind地址库  \n┠─ip2region.db：ip2region地址库  \n┠─mod.txt：审查词库  \n┠─whitelist.txt：IP地址白名单  \nCommon：之前老项目的Common项目；  \nConfigs：项目的一些配置对象  \nControllers：控制器  \nExtensions：一些扩展类或一些项目的扩展功能，比如hangfire、ueditor、中间件、拦截器等；  \nInfrastructure：数据访问基础设施，包含Repository和Services，相当于老项目的DAL和BLL；  \nMigrations：数据库CodeFirst模式的迁移文件；  \nModels：存放一些实体类或DTO；  \nViews：razor视图  \nwwwroot：项目的所有静态资源；  \n### 核心功能点技术实现\n#### 后端技术栈：\n依赖注入容器：.NET Core自带的+Autofac，autofac主要负责批量注入和属性注入；  \n实体映射框架：automapper 9.0；  \n缓存框架：CacheManager统一管理网站的热数据，如Session、内存缓存，EFCoreSecondLevelCacheInterceptor负责管理EF Core的二级缓存；  \n定时任务：hangfire统一管理定时任务，包含友链回链检查、文章定时发布、访客统计、搜索热词统计、Lucene库刷新等任务；  \nWebsocket：Blazor进行流推送实现服务器硬件健康状态的实时监控；  \n硬件检测：Masuit.Tools封装的硬件检测功能；  \n全文检索：Masuit.LuceneEFCore.SearchEngine基于Lucene.Net 4.8实现的全文检索中间件；  \n中文分词：结巴分词结合本地词库实现中文分词；  \n断点下载：Masuit.Tools封装的断点续传功能；  \nRedis：CSRedis负责Redis的读写操作；  \n文件压缩：Masuit.Tools封装的zip文件压缩功能；  \nHtml字符串操作：htmldiff.net-core实现文章版本的内容对比，HtmlAgilityPack实现html字符串的“DOM”操作，主要是用于提取img标签，HtmlSanitizer实现表单的html代码的仿XSS处理；  \n图床：支持多个图床的上传：gitee、github、gitlab；  \n拦截器：授权拦截器、请求拦截器负责网站全局流量的拦截和清洗、防火墙拦截器负责拦截网站自带防火墙规则的请求流量、异常拦截器、url重定向重写拦截器，主要用于将http的请求重定向到https；  \n请求IP来源检查：maxmind+IP2Region+本地数据库实现请求IP的来源检查；  \nRSS：WilderMinds.RssSyndication实现网站的RSS源；  \nEF扩展功能：zzzproject相关nuget包  \nWord文档转换：OpenXml实现浏览器端上传Word文档转换为html字符串。  \n在线文件管理：angular-filemanager+文件管理代码实现服务器文件的在线管理  \n\n#### 前端技术栈\n##### 前台页面：\n基于bootstrap3布局  \nueditor+layedit富文本编辑器  \nnotie提示栏+sweetyalert弹窗+layui组件  \nangularjs  \n\n##### 后台管理页：\n- angularjs单一页面应用程序  \n- material布局风格  \n- echart图表组件  \n- ng-table表格插件  \n- material风格angular-filemanager文件管理器  \n#### 性能和安全相关\n- hangfire实现分布式任务调度；\n- Z.EntityFramework.Plus实现数据访问层的高性能数据库批量操作；\n- Lucene.NET实现高性能站内检索；\n- 通过url的敏感词检查过滤恶意流量；\n- 限制客户端的请求频次；\n- 表单的AntiForgeryToken防止恶意提交；\n- ip2region+MaxMind地址库实现请求来源审查；\n- 用户信息采用端到端RSA非对称加密进行数据传输；\n### 项目部署\n以Windows系统为例，Linux系统请自行折腾。\n#### 1.安装基础设施：\n1. 安装.net6运行时：[https://dotnet.microsoft.com/zh-cn/download](https://dotnet.microsoft.com/zh-cn/download)\n2. 安装mysql：[mysql 8 绿色版](https://masuit.org/1567),或pgsql：[pgsql 14 绿色版](https://masuit.org/2160)\n3. 安装redis：[redis for windows绿色版](https://masuit.org/130)\n#### 2.生成网站应用\n#### 方式一：编译源代码：\n编译需要将[Masuit.Tools](https://github.com/ldqk/Masuit.Tools)项目和[Masuit.LuceneEFCore.SearchEngine](https://github.com/ldqk/Masuit.LuceneEFCore.SearchEngine)项目也一起clone下来，和本项目平级目录存放，才能正常编译，否则，将[Masuit.Tools](https://github.com/ldqk/Masuit.Tools)项目和[Masuit.LuceneEFCore.SearchEngine](https://github.com/ldqk/Masuit.LuceneEFCore.SearchEngine)项目移除，通过nuget安装也是可以的。  \n![](https://git.imweb.io/ldqk/imgbed/raw/master/20191019/6370710386639200004363431.png)  \n#### 方式二：下载编译好的现成的二进制文件\n前往[Release](https://github.com/ldqk/Masuit.MyBlogs/releases)下载最新的压缩包解压即可。\n#### 3.还原数据库脚本\n创建数据库，名称随意，如：myblogs，然后前往[Release](https://github.com/ldqk/Masuit.MyBlogs/releases)或[https://github.com/ldqk/Masuit.MyBlogs/tree/master/database/mysql](https://github.com/ldqk/Masuit.MyBlogs/tree/master/database/mysql)下载最新的数据库文件,还原到新建的数据库。   \n如果没有你目标数据库类型的还原文件，你可以先还原到mysql或pgsql中，然后使用[Full Convert](https://masuit.org/2163)转换成你需要的目标数据库类型即可。\n#### 4.修改配置文件：\n主要需要配置的是以下内容，其他配置均为可选项，不配置则表示不启用；\n![image](https://user-images.githubusercontent.com/20254980/169738528-ba0cc1a4-cb19-4e9d-b6cd-2f146a633c35.png)  \n同时，BaiduAK参与了数据库的加密，如果你没有BaiduAK，自行到百度地图开放平台申请，`免费的`。  \n如果你使用了CDN，需要配置TrueClientIPHeader选项为真实IP请求转发头，如cloudflare的叫CF-Connecting-IP。\n如果Redis不在本机，需要在配置文件中的Redis节下配置，固定为Redis，值的格式：127.0.0.1:6379,allowadmin=true，若未正确配置，将按默认值“127.0.0.1:6379,allowadmin=true,abortConnect=false”。  \n其他配置请参考appsettings.json的注释按需配置即可。  \n#### 5.启动网站\n配置好环境和配置文件后，可直接通过dotnet Masuit.MyBlogs.Core.dll命令或直接双击Masuit.MyBlogs.Core.exe运行，也可以通过nssm挂在为Windows服务运行，或者你也可以尝试在Linux下部署。  \n#### 其他方式部署\nIIS：部署时必须将应用程序池的标识设置为LocalSystem，否则无法监控服务器硬件，同时需要安装.NET Core Hosting运行时环境，IIS程序池改为无托管代码。  \n![](https://git.imweb.io/ldqk/imgbed/raw/master/5ccbf30b6a083.jpg)  \ndocker/Linux：自行爬文。  \n#### 有偿代部署服务\n请联系：admin@masuit.com\n\n### 后台管理：\nhttps://127.0.0.1:5001/dashboard\n- 初始用户名：masuit  \n- 初始密码：123abc@#$\n`若密码不对，可在debug模式下进入后台【用户管理】下重置密码`\n\n### 推荐项目\n基于EntityFrameworkCore和Lucene.NET实现的全文检索搜索引擎：[Masuit.LuceneEFCore.SearchEngine](https://github.com/ldqk/Masuit.LuceneEFCore.SearchEngine \"Masuit.LuceneEFCore.SearchEngine\")\n\n.NET万能框架工具库：[Masuit.Tools](https://github.com/ldqk/Masuit.Tools)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fldqk%2Fmasuit.myblogs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fldqk%2Fmasuit.myblogs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fldqk%2Fmasuit.myblogs/lists"}