<?xml version="1.0" encoding="utf-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><title>码栈工坊_源代码分享,技术文章,精品素材,网站模板,网站源码,建站源码,模板下载</title><link>https://www.codepub.top/</link><description>代码分享的平台_开源项目_网站模板_网站源码资源下载</description><item><title>NLog 完全指南：从入门到深度架构</title><link>https://www.codepub.top/post/470.html</link><description>&lt;p&gt;&lt;img class=&quot;ue-image&quot; src=&quot;https://www.codepub.top/zb_users/upload/2026/05/202605311780237901191293.jpg&quot; title=&quot;ScreenShot_2026-05-31_223101_969.jpg&quot; alt=&quot;ScreenShot_2026-05-31_223101_969.jpg&quot;/&gt;&lt;/p&gt;&lt;p style=&quot;margin: 16px 0px;color: rgb(15, 17, 21);font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;&quot; data-pm-slice=&quot;0 0 []&quot; class=&quot;js_darkmode__0 js_darkmode__text__0&quot;&gt;&lt;span class=&quot;js_darkmode__text__1&quot;&gt;&lt;span class=&quot;js_darkmode__text__2&quot;&gt;NLog 是一个为 .NET 平台设计的、强大且灵活的免费开源日志库。它不仅能轻松地帮你把日志记录到文件、数据库或控制台，还通过模块化设计和性能优化，很好地支持了现代 .NET 开发的 AOT（Ahead-Of-Time，预先编译）需求。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;hr style=&quot;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0.1);border-width: medium;border-style: none;border-color: currentcolor;border-image: initial;height: 1px;margin: 32px 0px;display: block;font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;&quot; class=&quot;js_darkmode__1&quot;/&gt;&lt;h2 style=&quot;font: 700 22px / 32px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;margin: 32px 0px 16px;color: rgb(15, 17, 21);letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;&quot; class=&quot;js_darkmode__2 js_darkmode__text__3&quot;&gt;&lt;span class=&quot;js_darkmode__text__4&quot;&gt;&lt;span class=&quot;js_darkmode__text__5&quot;&gt;第一部分：快速上手指南&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h3 style=&quot;font: 700 20px / 30px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;margin: 32px 0px 16px;color: rgb(15, 17, 21);letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;&quot; class=&quot;js_darkmode__3 js_darkmode__text__6&quot;&gt;&lt;span class=&quot;js_darkmode__text__7&quot;&gt;&lt;span class=&quot;js_darkmode__text__8&quot;&gt;1. 安装 &lt;span class=&quot;&quot;&gt;NuGet&lt;/span&gt; 包&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;p&gt;&lt;section style=&quot;text-align: center;&quot;&gt;&lt;img class=&quot;rich_pages wxw-img js_insertlocalimg&quot; data-aistatus=&quot;1&quot; data-imgfileid=&quot;100000657&quot; data-s=&quot;300,640&quot; data-src=&quot;https://mmbiz.qpic.cn/mmbiz_png/Qj7nHlfytbCTt2oeGhibS1DusiagKwcGqYSPyQhefvUUDgNoC2PbiauRRJkRIkg6PTXI3wkjAcxUHEsJA6ubOyyeYPJpfMhMohCOHozsRmYnLo/640?wx_fmt=png&amp;amp;from=appmsg&amp;amp;watermark=1#imgIndex=1&quot; data-type=&quot;png&quot; type=&quot;block&quot; data-original-style=&quot;null&quot; data-index=&quot;1&quot; data-ratio=&quot;0.3604309500489716&quot; data-w=&quot;1021&quot; src=&quot;https://mmbiz.qpic.cn/mmbiz_png/Qj7nHlfytbCTt2oeGhibS1DusiagKwcGqYSPyQhefvUUDgNoC2PbiauRRJkRIkg6PTXI3wkjAcxUHEsJA6ubOyyeYPJpfMhMohCOHozsRmYnLo/640?wx_fmt=png&amp;from=appmsg&amp;wxfrom=13&amp;tp=wxpic&amp;watermark=1#imgIndex=1&quot; _width=&quot;384px&quot; __sec_open_place_holder__=&quot;true&quot; data-sec-load-status=&quot;2&quot; style=&quot;height: auto !important; visibility: visible !important; width: 384px !important;&quot; data-report-img-idx=&quot;1&quot; alt=&quot;图片&quot;/&gt;&lt;/section&gt;&lt;/p&gt;&lt;h3 style=&quot;font: 700 20px / 30px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;margin: 32px 0px 16px;color: rgb(15, 17, 21);letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;&quot; class=&quot;js_darkmode__4 js_darkmode__text__9&quot;&gt;&lt;span class=&quot;js_darkmode__text__10&quot;&gt;&lt;span class=&quot;js_darkmode__text__11&quot;&gt;2. 基础配置 (NLog.config)&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;p style=&quot;margin: 16px 0px;color: rgb(15, 17, 21);font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;&quot; class=&quot;js_darkmode__5 js_darkmode__text__12&quot;&gt;&lt;span class=&quot;js_darkmode__text__13&quot;&gt;&lt;span class=&quot;js_darkmode__text__14&quot;&gt;在项目根目录创建&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;code style=&quot;box-sizing: border-box;font-style: normal;font-variant: normal;font-weight: 400;font-stretch: 100%;line-height: 22px;font-optical-sizing: auto;font-size-adjust: none;font-kerning: auto;font-feature-settings: normal;font-variation-settings: normal;font-language-override: normal;font-family: Menlo, Monaco, Consolas, &amp;quot;Cascadia Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, &amp;quot;DejaVu Sans Mono&amp;quot;, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;JetBrains Mono&amp;quot;, &amp;quot;Fira Code&amp;quot;, Cousine, &amp;quot;Roboto Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, Courier, sans-serif, system-ui;background-color: rgb(235, 238, 242);border-radius: 6px;align-items: center;padding: 0px 5px;display: inline-flex;font-size: 0.875em !important;&quot; class=&quot;js_darkmode__6 js_darkmode__text__15&quot;&gt;&lt;span class=&quot;js_darkmode__text__16&quot;&gt;NLog.config&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;js_darkmode__text__17&quot;&gt;&lt;span class=&quot;js_darkmode__text__18&quot;&gt;&amp;nbsp;文件：&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;section style=&quot;text-align: center;&quot;&gt;&lt;img class=&quot;rich_pages wxw-img js_insertlocalimg&quot; data-aistatus=&quot;1&quot; data-imgfileid=&quot;100000658&quot; data-s=&quot;300,640&quot; data-src=&quot;https://mmbiz.qpic.cn/sz_mmbiz_png/Qj7nHlfytbDiafHYy8KtBxM3I1brlaGPjiaGhDUrLyO0IsoS3jsfTEbp3pbEPiczX06EhDYIicvoky73I4ib60bqT1XgUJPRDNRpPeVkoXOCfLKs/640?wx_fmt=png&amp;amp;from=appmsg&amp;amp;watermark=1#imgIndex=2&quot; data-type=&quot;png&quot; type=&quot;block&quot; data-original-style=&quot;null&quot; data-index=&quot;2&quot; data-ratio=&quot;0.3458498023715415&quot; data-w=&quot;506&quot; src=&quot;https://mmbiz.qpic.cn/sz_mmbiz_png/Qj7nHlfytbDiafHYy8KtBxM3I1brlaGPjiaGhDUrLyO0IsoS3jsfTEbp3pbEPiczX06EhDYIicvoky73I4ib60bqT1XgUJPRDNRpPeVkoXOCfLKs/640?wx_fmt=png&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1&amp;watermark=1#imgIndex=2&quot; _width=&quot;384px&quot; __sec_open_place_holder__=&quot;true&quot; style=&quot;height: auto !important; visibility: visible !important; width: 384px !important;&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780237829355&quot; data-report-img-idx=&quot;2&quot; data-fail=&quot;0&quot;/&gt;&lt;/section&gt;&lt;section style=&quot;text-align: center;&quot;&gt;&lt;img class=&quot;rich_pages wxw-img js_insertlocalimg&quot; data-aistatus=&quot;1&quot; data-imgfileid=&quot;100000662&quot; data-s=&quot;300,640&quot; data-src=&quot;https://mmbiz.qpic.cn/sz_mmbiz_png/Qj7nHlfytbC6vEjFrwHOEB1ibUKK75uYicRPjjKHibTEKoQ6BBJIkuVRAyMnZbZgeRFmLzyPQEbTEnmqrYjo1bnWTwSH2OicNEMialvPiak7kAKok/640?wx_fmt=png&amp;amp;from=appmsg&amp;amp;watermark=1#imgIndex=3&quot; data-type=&quot;png&quot; type=&quot;block&quot; data-original-style=&quot;null&quot; data-index=&quot;3&quot; data-ratio=&quot;0.4720357941834452&quot; data-w=&quot;894&quot; src=&quot;https://mmbiz.qpic.cn/sz_mmbiz_png/Qj7nHlfytbC6vEjFrwHOEB1ibUKK75uYicRPjjKHibTEKoQ6BBJIkuVRAyMnZbZgeRFmLzyPQEbTEnmqrYjo1bnWTwSH2OicNEMialvPiak7kAKok/640?wx_fmt=png&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1&amp;watermark=1#imgIndex=3&quot; _width=&quot;384px&quot; __sec_open_place_holder__=&quot;true&quot; style=&quot;height: auto !important; visibility: visible !important; width: 677px !important;&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780237875936&quot; data-report-img-idx=&quot;3&quot; data-fail=&quot;0&quot;/&gt;&lt;/section&gt;&lt;/p&gt;&lt;h3 style=&quot;font: 700 20px / 30px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;margin: 32px 0px 16px;color: rgb(15, 17, 21);letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;&quot; class=&quot;js_darkmode__7 js_darkmode__text__19&quot;&gt;&lt;span class=&quot;js_darkmode__text__20&quot;&gt;&lt;span class=&quot;js_darkmode__text__21&quot;&gt;3. 在代码中使用&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;p&gt;&lt;section style=&quot;text-align: center;&quot;&gt;&lt;img class=&quot;rich_pages wxw-img js_insertlocalimg&quot; data-aistatus=&quot;1&quot; data-imgfileid=&quot;100000659&quot; data-s=&quot;300,640&quot; data-src=&quot;https://mmbiz.qpic.cn/mmbiz_png/Qj7nHlfytbAk0Z6AFCxNx6iawxAhhL3uwNjBfdyRdwFaHMiaVichExufBtIpc1uoSBtWiaAjiaPsIzCSCxsrAVmclOibbtfjicoziauQtkJnuGnaee8/640?wx_fmt=png&amp;amp;from=appmsg&amp;amp;watermark=1#imgIndex=4&quot; data-type=&quot;png&quot; type=&quot;block&quot; data-original-style=&quot;null&quot; data-index=&quot;4&quot; data-ratio=&quot;0.6165884194053208&quot; data-w=&quot;639&quot; src=&quot;https://mmbiz.qpic.cn/mmbiz_png/Qj7nHlfytbAk0Z6AFCxNx6iawxAhhL3uwNjBfdyRdwFaHMiaVichExufBtIpc1uoSBtWiaAjiaPsIzCSCxsrAVmclOibbtfjicoziauQtkJnuGnaee8/640?wx_fmt=png&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1&amp;watermark=1#imgIndex=4&quot; _width=&quot;384px&quot; __sec_open_place_holder__=&quot;true&quot; style=&quot;height: auto !important; visibility: visible !important; width: 639px !important;&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780237876072&quot; data-report-img-idx=&quot;4&quot; data-fail=&quot;0&quot;/&gt;&lt;/section&gt;&lt;section style=&quot;text-align: center;&quot;&gt;&lt;img class=&quot;rich_pages wxw-img js_insertlocalimg&quot; data-aistatus=&quot;1&quot; data-imgfileid=&quot;100000660&quot; data-s=&quot;300,640&quot; data-src=&quot;https://mmbiz.qpic.cn/mmbiz_png/Qj7nHlfytbAKiarqEqdAV4B6VwYhQ80R5D8zl7icWgbUaibwElxTQXj99Kw2bEfpiaU1D0jpoLMQzIibhiahfOnFxqibUbJ9ZAz0P64UIHKhM8txz8/640?wx_fmt=png&amp;amp;from=appmsg&amp;amp;watermark=1#imgIndex=5&quot; data-type=&quot;png&quot; type=&quot;block&quot; data-original-style=&quot;null&quot; data-index=&quot;5&quot; data-ratio=&quot;0.270687237026648&quot; data-w=&quot;713&quot; src=&quot;https://mmbiz.qpic.cn/mmbiz_png/Qj7nHlfytbAKiarqEqdAV4B6VwYhQ80R5D8zl7icWgbUaibwElxTQXj99Kw2bEfpiaU1D0jpoLMQzIibhiahfOnFxqibUbJ9ZAz0P64UIHKhM8txz8/640?wx_fmt=png&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1&amp;watermark=1#imgIndex=5&quot; _width=&quot;384px&quot; __sec_open_place_holder__=&quot;true&quot; style=&quot;height: auto !important; visibility: visible !important; width: 677px !important;&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780237876737&quot; data-report-img-idx=&quot;5&quot; data-fail=&quot;0&quot;/&gt;&lt;/section&gt;&lt;/p&gt;&lt;hr style=&quot;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0.1);border-width: medium;border-style: none;border-color: currentcolor;border-image: initial;height: 1px;margin: 32px 0px;display: block;font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;&quot; class=&quot;js_darkmode__8&quot;/&gt;&lt;h2 style=&quot;font: 700 22px / 32px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;margin: 32px 0px 16px;color: rgb(15, 17, 21);letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;&quot; class=&quot;js_darkmode__9 js_darkmode__text__22&quot;&gt;&lt;span class=&quot;js_darkmode__text__23&quot;&gt;&lt;span class=&quot;js_darkmode__text__24&quot;&gt;第二部分：核心架构深度解析&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h3 style=&quot;font: 700 20px / 30px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;margin: 32px 0px 16px;color: rgb(15, 17, 21);letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;&quot; class=&quot;js_darkmode__10 js_darkmode__text__25&quot;&gt;&lt;span class=&quot;js_darkmode__text__26&quot;&gt;&lt;span class=&quot;js_darkmode__text__27&quot;&gt;一、架构设计&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;p style=&quot;margin: 16px 0px;color: rgb(15, 17, 21);font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;&quot; class=&quot;js_darkmode__11 js_darkmode__text__28&quot;&gt;&lt;span class=&quot;js_darkmode__text__29&quot;&gt;&lt;span class=&quot;js_darkmode__text__30&quot;&gt;NLog 采用清晰的&lt;/span&gt;&lt;/span&gt;&lt;strong style=&quot;font-weight: 600;&quot; class=&quot;js_darkmode__text__31&quot;&gt;&lt;span class=&quot;js_darkmode__text__32&quot;&gt;&lt;span class=&quot;js_darkmode__text__33&quot;&gt;管道-过滤器架构&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;js_darkmode__text__34&quot;&gt;&lt;span class=&quot;js_darkmode__text__35&quot;&gt;，将日志处理流程分解为四个核心层次：&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;section style=&quot;text-align: center;&quot;&gt;&lt;img class=&quot;rich_pages wxw-img js_insertlocalimg&quot; data-aistatus=&quot;1&quot; data-imgfileid=&quot;100000661&quot; data-s=&quot;300,640&quot; data-src=&quot;https://mmbiz.qpic.cn/mmbiz_png/Qj7nHlfytbDrlFV6eMBSfej2icDYn13q3Y6DxOaG2ibgaqVwpSqTHiaHyaDqaO6icnicpXuLRurlcWZtnsJElvaSIpcSHSiaG8Hg8HMjsdM4b4A8s/640?wx_fmt=png&amp;amp;from=appmsg#imgIndex=6&quot; data-type=&quot;png&quot; type=&quot;block&quot; data-original-style=&quot;null&quot; data-index=&quot;6&quot; data-ratio=&quot;0.065625&quot; data-w=&quot;2560&quot; src=&quot;https://mmbiz.qpic.cn/mmbiz_png/Qj7nHlfytbDrlFV6eMBSfej2icDYn13q3Y6DxOaG2ibgaqVwpSqTHiaHyaDqaO6icnicpXuLRurlcWZtnsJElvaSIpcSHSiaG8Hg8HMjsdM4b4A8s/640?wx_fmt=png&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1#imgIndex=6&quot; _width=&quot;384px&quot; __sec_open_place_holder__=&quot;true&quot; style=&quot;height: auto !important; visibility: visible !important; width: 677px !important;&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780237877253&quot; data-report-img-idx=&quot;6&quot; data-fail=&quot;0&quot;/&gt;&lt;/section&gt;&lt;/p&gt;&lt;h3 style=&quot;font: 700 20px / 30px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;margin: 32px 0px 16px;color: rgb(15, 17, 21);letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;&quot; class=&quot;js_darkmode__12 js_darkmode__text__36&quot;&gt;&lt;span class=&quot;js_darkmode__text__37&quot;&gt;&lt;span class=&quot;js_darkmode__text__38&quot;&gt;二、构建系统与多框架支持&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;p style=&quot;margin: 16px 0px;color: rgb(15, 17, 21);font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;&quot; class=&quot;js_darkmode__13 js_darkmode__text__39&quot;&gt;&lt;span class=&quot;js_darkmode__text__40&quot;&gt;&lt;span class=&quot;js_darkmode__text__41&quot;&gt;NLog 的构建流程体现了其工程严谨性，每个正式版本都经过精心编排：&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;table class=&quot;js_darkmode__text__42&quot; width=&quot;NaN&quot;&gt;&lt;thead class=&quot;js_darkmode__text__43&quot;&gt;&lt;tr class=&quot;js_darkmode__text__44 firstRow&quot;&gt;&lt;th style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.12);font: 500 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;border-top-width: medium;border-top-style: none;border-top-color: currentcolor;padding: 10px 16px 10px 0px;text-align: left;&quot; class=&quot;js_darkmode__14 js_darkmode__text__45&quot;&gt;&lt;span class=&quot;js_darkmode__text__46&quot;&gt;&lt;span class=&quot;js_darkmode__text__47&quot;&gt;阶段&lt;/span&gt;&lt;/span&gt;&lt;/th&gt;&lt;th style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.12);font: 500 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;border-top-width: medium;border-top-style: none;border-top-color: currentcolor;padding: 10px 16px;text-align: left;&quot; class=&quot;js_darkmode__15 js_darkmode__text__48&quot;&gt;&lt;span class=&quot;js_darkmode__text__49&quot;&gt;&lt;span class=&quot;js_darkmode__text__50&quot;&gt;产出物&lt;/span&gt;&lt;/span&gt;&lt;/th&gt;&lt;th style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.12);font: 500 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;border-top-width: medium;border-top-style: none;border-top-color: currentcolor;padding: 10px 16px;text-align: left;&quot; class=&quot;js_darkmode__16 js_darkmode__text__51&quot;&gt;&lt;span class=&quot;js_darkmode__text__52&quot;&gt;&lt;span class=&quot;js_darkmode__text__53&quot;&gt;工具链&lt;/span&gt;&lt;/span&gt;&lt;/th&gt;&lt;th style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.12);font: 500 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;border-top-width: medium;border-top-style: none;border-top-color: currentcolor;padding: 10px 16px;text-align: left;&quot; class=&quot;js_darkmode__17 js_darkmode__text__54&quot;&gt;&lt;span class=&quot;js_darkmode__text__55&quot;&gt;&lt;span class=&quot;js_darkmode__text__56&quot;&gt;说明&lt;/span&gt;&lt;/span&gt;&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody class=&quot;js_darkmode__text__57&quot;&gt;&lt;tr class=&quot;js_darkmode__text__58&quot;&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px 10px 0px;&quot; class=&quot;js_darkmode__18 js_darkmode__text__59&quot;&gt;&lt;strong style=&quot;font-weight: 600;&quot; class=&quot;js_darkmode__text__60&quot;&gt;&lt;span class=&quot;js_darkmode__text__61&quot;&gt;&lt;span class=&quot;js_darkmode__text__62&quot;&gt;编译&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px;&quot; class=&quot;js_darkmode__19 js_darkmode__text__63&quot;&gt;&lt;span class=&quot;js_darkmode__text__64&quot;&gt;&lt;span class=&quot;js_darkmode__text__65&quot;&gt;NLog.dll + XML文档&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px;&quot; class=&quot;js_darkmode__20 js_darkmode__text__66&quot;&gt;&lt;span class=&quot;js_darkmode__text__67&quot;&gt;&lt;span class=&quot;js_darkmode__text__68&quot;&gt;csc.exe + StyleCop&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 0px 10px 16px;&quot; class=&quot;js_darkmode__21 js_darkmode__text__69&quot;&gt;&lt;span class=&quot;js_darkmode__text__70&quot;&gt;&lt;span class=&quot;js_darkmode__text__71&quot;&gt;同时支持8个目标框架&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr class=&quot;js_darkmode__text__72&quot;&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px 10px 0px;&quot; class=&quot;js_darkmode__22 js_darkmode__text__73&quot;&gt;&lt;strong style=&quot;font-weight: 600;&quot; class=&quot;js_darkmode__text__74&quot;&gt;&lt;span class=&quot;js_darkmode__text__75&quot;&gt;&lt;span class=&quot;js_darkmode__text__76&quot;&gt;API提取&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px;&quot; class=&quot;js_darkmode__23 js_darkmode__text__77&quot;&gt;&lt;span class=&quot;js_darkmode__text__78&quot;&gt;&lt;span class=&quot;js_darkmode__text__79&quot;&gt;NLog.api&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px;&quot; class=&quot;js_darkmode__24 js_darkmode__text__80&quot;&gt;&lt;span class=&quot;js_darkmode__text__81&quot;&gt;&lt;span class=&quot;js_darkmode__text__82&quot;&gt;DumpApiXml.exe&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 0px 10px 16px;&quot; class=&quot;js_darkmode__25 js_darkmode__text__83&quot;&gt;&lt;span class=&quot;js_darkmode__text__84&quot;&gt;&lt;span class=&quot;js_darkmode__text__85&quot;&gt;反射分析，提取目标/渲染器信息&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr class=&quot;js_darkmode__text__86&quot;&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px 10px 0px;&quot; class=&quot;js_darkmode__26 js_darkmode__text__87&quot;&gt;&lt;strong style=&quot;font-weight: 600;&quot; class=&quot;js_darkmode__text__88&quot;&gt;&lt;span class=&quot;js_darkmode__text__89&quot;&gt;&lt;span class=&quot;js_darkmode__text__90&quot;&gt;文档生成&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px;&quot; class=&quot;js_darkmode__27 js_darkmode__text__91&quot;&gt;&lt;span class=&quot;js_darkmode__text__92&quot;&gt;&lt;span class=&quot;js_darkmode__text__93&quot;&gt;NLog.chm + 网站&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px;&quot; class=&quot;js_darkmode__28 js_darkmode__text__94&quot;&gt;&lt;span class=&quot;js_darkmode__text__95&quot;&gt;&lt;span class=&quot;js_darkmode__text__96&quot;&gt;SHFB + XSLT&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 0px 10px 16px;&quot; class=&quot;js_darkmode__29 js_darkmode__text__97&quot;&gt;&lt;span class=&quot;js_darkmode__text__98&quot;&gt;&lt;span class=&quot;js_darkmode__text__99&quot;&gt;包含概念文档和API文档&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr class=&quot;js_darkmode__text__100&quot;&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px 10px 0px;&quot; class=&quot;js_darkmode__30 js_darkmode__text__101&quot;&gt;&lt;strong style=&quot;font-weight: 600;&quot; class=&quot;js_darkmode__text__102&quot;&gt;&lt;span class=&quot;js_darkmode__text__103&quot;&gt;&lt;span class=&quot;js_darkmode__text__104&quot;&gt;XSD生成&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px;&quot; class=&quot;js_darkmode__31 js_darkmode__text__105&quot;&gt;&lt;span class=&quot;js_darkmode__text__106&quot;&gt;&lt;span class=&quot;js_darkmode__text__107&quot;&gt;NLog.xsd&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px;&quot; class=&quot;js_darkmode__32 js_darkmode__text__108&quot;&gt;&lt;span class=&quot;js_darkmode__text__109&quot;&gt;&lt;span class=&quot;js_darkmode__text__110&quot;&gt;MakeNLogXsd.exe&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 0px 10px 16px;&quot; class=&quot;js_darkmode__33 js_darkmode__text__111&quot;&gt;&lt;span class=&quot;js_darkmode__text__112&quot;&gt;&lt;span class=&quot;js_darkmode__text__113&quot;&gt;为VS提供智能提示支持&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr class=&quot;js_darkmode__text__114&quot;&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px 10px 0px;&quot; class=&quot;js_darkmode__34 js_darkmode__text__115&quot;&gt;&lt;strong style=&quot;font-weight: 600;&quot; class=&quot;js_darkmode__text__116&quot;&gt;&lt;span class=&quot;js_darkmode__text__117&quot;&gt;&lt;span class=&quot;js_darkmode__text__118&quot;&gt;打包发布&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px;&quot; class=&quot;js_darkmode__35 js_darkmode__text__119&quot;&gt;&lt;span class=&quot;js_darkmode__text__120&quot;&gt;&lt;span class=&quot;js_darkmode__text__121&quot;&gt;NuGet包 + 安装程序&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px;&quot; class=&quot;js_darkmode__36 js_darkmode__text__122&quot;&gt;&lt;span class=&quot;js_darkmode__text__123&quot;&gt;&lt;span class=&quot;js_darkmode__text__124&quot;&gt;WIX&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 0px 10px 16px;&quot; class=&quot;js_darkmode__37 js_darkmode__text__125&quot;&gt;&lt;span class=&quot;js_darkmode__text__126&quot;&gt;&lt;span class=&quot;js_darkmode__text__127&quot;&gt;自动化发布流程&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;h3 style=&quot;font: 700 20px / 30px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;margin: 32px 0px 16px;color: rgb(15, 17, 21);letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255)&quot; class=&quot;js_darkmode__38 js_darkmode__text__128&quot;&gt;三、配置系统的深度工作机制&lt;/h3&gt;&lt;h4 style=&quot;font: 600 16px / 28px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;margin: 16px 0px;color: rgb(15, 17, 21);letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255)&quot; class=&quot;js_darkmode__39 js_darkmode__text__131&quot;&gt;3.1 配置加载与解析流程&lt;/h4&gt;&lt;p style=&quot;margin: 16px 0px;color: rgb(15, 17, 21);font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255)&quot; class=&quot;js_darkmode__40 js_darkmode__text__134&quot;&gt;NLog 的配置系统采用&lt;strong style=&quot;font-weight: 600&quot;&gt;分层加载&lt;/strong&gt;策略：&lt;/p&gt;&lt;p&gt;&lt;section class=&quot;code-snippet__fix code-snippet__js js_darkmode__text__142&quot;&gt;&lt;ul class=&quot;code-snippet__line-index code-snippet__js list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;pre class=&quot;code-snippet__js js_darkmode__text__143&quot; data-lang=&quot;markdown&quot;&gt;启动加载顺序：1.&amp;nbsp;读取&amp;nbsp;app.config&amp;nbsp;/&amp;nbsp;web.config&amp;nbsp;中的&amp;nbsp;nlog&amp;nbsp;section2.&amp;nbsp;加载独立的&amp;nbsp;NLog.config&amp;nbsp;文件3.&amp;nbsp;通过&amp;nbsp;&amp;lt;include&amp;gt;&amp;nbsp;加载扩展配置文件4.&amp;nbsp;应用&amp;nbsp;autoReload=&amp;quot;true&amp;quot;&amp;nbsp;时启动文件监控&lt;/pre&gt;&lt;/section&gt;&lt;/p&gt;&lt;h4 style=&quot;font: 600 16px / 28px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;margin: 16px 0px;color: rgb(15, 17, 21);letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255)&quot; class=&quot;js_darkmode__41 js_darkmode__text__162&quot;&gt;3.2 智能路由机制与 final 规则&lt;/h4&gt;&lt;p style=&quot;margin: 16px 0px;color: rgb(15, 17, 21);font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255)&quot; class=&quot;js_darkmode__42 js_darkmode__text__165&quot;&gt;NLog 的路由引擎在运行时维护一个&lt;strong style=&quot;font-weight: 600&quot;&gt;规则链&lt;/strong&gt;，当&amp;nbsp;&lt;code style=&quot;box-sizing: border-box;font-style: normal;font-variant: normal;font-weight: 400;font-stretch: 100%;line-height: 22px;font-optical-sizing: auto;font-size-adjust: none;font-kerning: auto;font-feature-settings: normal;font-variation-settings: normal;font-language-override: normal;font-family: Menlo, Monaco, Consolas, &amp;#39;Cascadia Mono&amp;#39;, &amp;#39;Ubuntu Mono&amp;#39;, &amp;#39;DejaVu Sans Mono&amp;#39;, &amp;#39;Liberation Mono&amp;#39;, &amp;#39;JetBrains Mono&amp;#39;, &amp;#39;Fira Code&amp;#39;, Cousine, &amp;#39;Roboto Mono&amp;#39;, &amp;#39;Courier New&amp;#39;, Courier, sans-serif, system-ui;background-color: rgb(235, 238, 242);border-radius: 6px;align-items: center;padding: 0px 5px;display: inline-flex;font-size: 0.875em !important&quot; class=&quot;js_darkmode__43 js_darkmode__text__173&quot;&gt;LogEventInfo&lt;/code&gt;&amp;nbsp;产生时：&lt;/p&gt;&lt;ol style=&quot;margin: 16px 0px;padding-left: 18px;color: rgb(15, 17, 21);font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255)&quot; class=&quot;js_darkmode__44 js_darkmode__text__177 list-paddingleft-2&quot; start=&quot;1&quot;&gt;&lt;li&gt;&lt;p style=&quot;margin-top: 0px !important;margin-right: 0px;margin-bottom: 0px;margin-left: 0px&quot;&gt;遍历 rules 集合，按声明顺序匹配&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;margin-top: 0px !important;margin-right: 0px;margin-bottom: 0px;margin-left: 0px&quot;&gt;对每个规则检查 logger name 模式匹配&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;margin-top: 0px !important;margin-right: 0px;margin-bottom: 0px;margin-left: 0px&quot;&gt;验证日志级别是否在 [minlevel, maxlevel] 区间&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;margin-top: 0px !important;margin-right: 0px;margin-bottom: 0px;margin-left: 0px&quot;&gt;通过匹配后，将事件分发到 writeTo 指定的所有目标&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;margin-top: 0px !important;margin-right: 0px;margin-bottom: 0px;margin-left: 0px&quot;&gt;遇到&amp;nbsp;&lt;code style=&quot;box-sizing: border-box;font-style: normal;font-variant: normal;font-weight: 400;font-stretch: 100%;line-height: 22px;font-optical-sizing: auto;font-size-adjust: none;font-kerning: auto;font-feature-settings: normal;font-variation-settings: normal;font-language-override: normal;font-family: Menlo, Monaco, Consolas, &amp;#39;Cascadia Mono&amp;#39;, &amp;#39;Ubuntu Mono&amp;#39;, &amp;#39;DejaVu Sans Mono&amp;#39;, &amp;#39;Liberation Mono&amp;#39;, &amp;#39;JetBrains Mono&amp;#39;, &amp;#39;Fira Code&amp;#39;, Cousine, &amp;#39;Roboto Mono&amp;#39;, &amp;#39;Courier New&amp;#39;, Courier, sans-serif, system-ui;background-color: rgb(235, 238, 242);border-radius: 6px;align-items: center;padding: 0px 5px;display: inline-flex;font-size: 0.875em !important&quot; class=&quot;js_darkmode__45 js_darkmode__text__198&quot;&gt;final=&amp;quot;true&amp;quot;&lt;/code&gt;&amp;nbsp;的规则时停止继续匹配&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p style=&quot;margin: 16px 0px;color: rgb(15, 17, 21);font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255)&quot; class=&quot;js_darkmode__46 js_darkmode__text__202&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;关键配置元素的运行时行为&lt;/strong&gt;：&lt;/p&gt;&lt;p&gt;&lt;section class=&quot;code-snippet__fix code-snippet__js js_darkmode__text__208&quot;&gt;&lt;ul class=&quot;code-snippet__line-index code-snippet__js list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;pre class=&quot;code-snippet__js js_darkmode__text__209&quot; data-lang=&quot;xml&quot;&gt;&lt;code&gt;&lt;span class=&quot;code-snippet__tag js_darkmode__text__212&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;code-snippet__tag js_darkmode__text__213&quot;&gt;&lt;span class=&quot;code-snippet__name js_darkmode__text__214&quot;&gt;rules&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;code-snippet__tag js_darkmode__text__215&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;code-snippet__comment js_darkmode__text__218&quot;&gt;&amp;lt;!-- final=&amp;quot;true&amp;quot;：匹配后终止后续规则，避免日志重复处理 --&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;code-snippet__tag js_darkmode__text__221&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;code-snippet__tag js_darkmode__text__222&quot;&gt;&lt;span class=&quot;code-snippet__name js_darkmode__text__223&quot;&gt;logger&lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;code-snippet__tag js_darkmode__text__224&quot;&gt;&lt;span class=&quot;code-snippet__attr js_darkmode__text__225&quot;&gt;name&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;code-snippet__tag js_darkmode__text__226&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;code-snippet__tag js_darkmode__text__227&quot;&gt;&lt;span class=&quot;code-snippet__string js_darkmode__text__228&quot;&gt;&amp;quot;Microsoft.*&amp;quot;&lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;code-snippet__tag js_darkmode__text__229&quot;&gt;&lt;span class=&quot;code-snippet__attr js_darkmode__text__230&quot;&gt;minlevel&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;code-snippet__tag js_darkmode__text__231&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;code-snippet__tag js_darkmode__text__232&quot;&gt;&lt;span class=&quot;code-snippet__string js_darkmode__text__233&quot;&gt;&amp;quot;Info&amp;quot;&lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;code-snippet__tag js_darkmode__text__234&quot;&gt;&lt;span class=&quot;code-snippet__attr js_darkmode__text__235&quot;&gt;final&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;code-snippet__tag js_darkmode__text__236&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;code-snippet__tag js_darkmode__text__237&quot;&gt;&lt;span class=&quot;code-snippet__string js_darkmode__text__238&quot;&gt;&amp;quot;true&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;code-snippet__tag js_darkmode__text__239&quot;&gt;&amp;nbsp;/&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;br/&gt;&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;code-snippet__comment js_darkmode__text__242&quot;&gt;&amp;lt;!-- 使用通配符匹配记录器名称 --&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;code-snippet__tag js_darkmode__text__245&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;code-snippet__tag js_darkmode__text__246&quot;&gt;&lt;span class=&quot;code-snippet__name js_darkmode__text__247&quot;&gt;logger&lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;code-snippet__tag js_darkmode__text__248&quot;&gt;&lt;span class=&quot;code-snippet__attr js_darkmode__text__249&quot;&gt;name&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;code-snippet__tag js_darkmode__text__250&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;code-snippet__tag js_darkmode__text__251&quot;&gt;&lt;span class=&quot;code-snippet__string js_darkmode__text__252&quot;&gt;&amp;quot;*&amp;quot;&lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;code-snippet__tag js_darkmode__text__253&quot;&gt;&lt;span class=&quot;code-snippet__attr js_darkmode__text__254&quot;&gt;minlevel&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;code-snippet__tag js_darkmode__text__255&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;code-snippet__tag js_darkmode__text__256&quot;&gt;&lt;span class=&quot;code-snippet__string js_darkmode__text__257&quot;&gt;&amp;quot;Info&amp;quot;&lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;code-snippet__tag js_darkmode__text__258&quot;&gt;&lt;span class=&quot;code-snippet__attr js_darkmode__text__259&quot;&gt;writeTo&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;code-snippet__tag js_darkmode__text__260&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;code-snippet__tag js_darkmode__text__261&quot;&gt;&lt;span class=&quot;code-snippet__string js_darkmode__text__262&quot;&gt;&amp;quot;asyncFile&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;code-snippet__tag js_darkmode__text__263&quot;&gt;&amp;nbsp;/&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;br/&gt;&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;code-snippet__comment js_darkmode__text__266&quot;&gt;&amp;lt;!-- 可以为不同级别配置不同目标 --&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;code-snippet__tag js_darkmode__text__269&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;code-snippet__tag js_darkmode__text__270&quot;&gt;&lt;span class=&quot;code-snippet__name js_darkmode__text__271&quot;&gt;logger&lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;code-snippet__tag js_darkmode__text__272&quot;&gt;&lt;span class=&quot;code-snippet__attr js_darkmode__text__273&quot;&gt;name&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;code-snippet__tag js_darkmode__text__274&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;code-snippet__tag js_darkmode__text__275&quot;&gt;&lt;span class=&quot;code-snippet__string js_darkmode__text__276&quot;&gt;&amp;quot;*&amp;quot;&lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;code-snippet__tag js_darkmode__text__277&quot;&gt;&lt;span class=&quot;code-snippet__attr js_darkmode__text__278&quot;&gt;minlevel&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;code-snippet__tag js_darkmode__text__279&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;code-snippet__tag js_darkmode__text__280&quot;&gt;&lt;span class=&quot;code-snippet__string js_darkmode__text__281&quot;&gt;&amp;quot;Warn&amp;quot;&lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;code-snippet__tag js_darkmode__text__282&quot;&gt;&lt;span class=&quot;code-snippet__attr js_darkmode__text__283&quot;&gt;writeTo&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;code-snippet__tag js_darkmode__text__284&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;code-snippet__tag js_darkmode__text__285&quot;&gt;&lt;span class=&quot;code-snippet__string js_darkmode__text__286&quot;&gt;&amp;quot;colorConsole&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;code-snippet__tag js_darkmode__text__287&quot;&gt;&amp;nbsp;/&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&lt;span class=&quot;code-snippet__tag js_darkmode__text__290&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;code-snippet__tag js_darkmode__text__291&quot;&gt;&lt;span class=&quot;code-snippet__name js_darkmode__text__292&quot;&gt;rules&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;code-snippet__tag js_darkmode__text__293&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/section&gt;&lt;/p&gt;&lt;h3 style=&quot;font: 700 20px / 30px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;margin: 32px 0px 16px;color: rgb(15, 17, 21);letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255)&quot; class=&quot;js_darkmode__47 js_darkmode__text__294&quot;&gt;四、性能优化深度分析&lt;/h3&gt;&lt;h4 style=&quot;font: 600 16px / 28px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;margin: 16px 0px;color: rgb(15, 17, 21);letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255)&quot; class=&quot;js_darkmode__48 js_darkmode__text__297&quot;&gt;4.1 异步处理架构&lt;/h4&gt;&lt;p style=&quot;margin: 16px 0px;color: rgb(15, 17, 21);font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255)&quot; class=&quot;js_darkmode__49 js_darkmode__text__300&quot;&gt;从 NLog 4.0 开始，异步日志通过&amp;nbsp;&lt;strong style=&quot;font-weight: 600&quot;&gt;AsyncWrapper&lt;/strong&gt;&amp;nbsp;实现：&lt;/p&gt;&lt;p&gt;&lt;section class=&quot;code-snippet__fix code-snippet__js js_darkmode__text__308&quot;&gt;&lt;ul class=&quot;code-snippet__line-index code-snippet__js list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;pre class=&quot;code-snippet__js js_darkmode__text__309&quot; data-lang=&quot;xml&quot;&gt;&amp;lt;target&amp;nbsp;name=&amp;quot;asyncFile&amp;quot;&amp;nbsp;xsi:type=&amp;quot;AsyncWrapper&amp;quot;&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;!--&amp;nbsp;内部包装同步目标&amp;nbsp;--&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;target&amp;nbsp;name=&amp;quot;file&amp;quot;&amp;nbsp;xsi:type=&amp;quot;File&amp;quot;&amp;nbsp;fileName=&amp;quot;logs.txt&amp;quot;&amp;nbsp;/&amp;gt;&amp;lt;/target&amp;gt;&lt;/pre&gt;&lt;/section&gt;&lt;/p&gt;&lt;p style=&quot;margin: 16px 0px;color: rgb(15, 17, 21);font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255)&quot; class=&quot;js_darkmode__50 js_darkmode__text__356&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;工作队列机制&lt;/strong&gt;：&lt;/p&gt;&lt;ul style=&quot;margin: 16px 0px;padding-left: 18px;color: rgb(15, 17, 21);font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255)&quot; class=&quot;js_darkmode__51 js_darkmode__text__362 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;margin-top: 0px !important;margin-right: 0px;margin-bottom: 0px;margin-left: 0px&quot;&gt;异步目标维护一个&lt;strong style=&quot;font-weight: 600&quot;&gt;有界阻塞队列&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;margin-top: 0px !important;margin-right: 0px;margin-bottom: 0px;margin-left: 0px&quot;&gt;日志事件入队后立即返回，不阻塞业务线程&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;margin-top: 0px !important;margin-right: 0px;margin-bottom: 0px;margin-left: 0px&quot;&gt;后台工作线程批量处理队列中的事件&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;margin-top: 0px !important;margin-right: 0px;margin-bottom: 0px;margin-left: 0px&quot;&gt;支持配置队列大小和溢出行为&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h4 style=&quot;font: 600 16px / 28px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;margin: 16px 0px;color: rgb(15, 17, 21);letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255)&quot; class=&quot;js_darkmode__52 js_darkmode__text__382&quot;&gt;4.2 性能数据与优化策略&lt;/h4&gt;&lt;p style=&quot;margin: 16px 0px;color: rgb(15, 17, 21);font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255)&quot; class=&quot;js_darkmode__53 js_darkmode__text__385&quot;&gt;根据官方公布的数据：&lt;/p&gt;&lt;table width=&quot;752&quot;&gt;&lt;thead&gt;&lt;tr class=&quot;firstRow&quot;&gt;&lt;th style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.12);font: 500 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;border-top-width: medium;border-top-style: none;border-top-color: currentcolor;padding: 10px 16px 10px 0px;text-align: left&quot; class=&quot;js_darkmode__54 js_darkmode__text__391&quot;&gt;优化特性&lt;/th&gt;&lt;th style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.12);font: 500 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;border-top-width: medium;border-top-style: none;border-top-color: currentcolor;padding: 10px 16px;text-align: left&quot; class=&quot;js_darkmode__55 js_darkmode__text__394&quot;&gt;性能表现&lt;/th&gt;&lt;th style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.12);font: 500 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;border-top-width: medium;border-top-style: none;border-top-color: currentcolor;padding: 10px 16px;text-align: left&quot; class=&quot;js_darkmode__56 js_darkmode__text__397&quot;&gt;应用场景&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px 10px 0px&quot; class=&quot;js_darkmode__57 js_darkmode__text__402&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;空日志过滤&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px&quot; class=&quot;js_darkmode__58 js_darkmode__text__406&quot;&gt;1.5亿条/秒（1.6G单核）&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 0px 10px 16px&quot; class=&quot;js_darkmode__59 js_darkmode__text__409&quot;&gt;日志级别关闭时无性能损耗&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px 10px 0px&quot; class=&quot;js_darkmode__60 js_darkmode__text__413&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;异步写入&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px&quot; class=&quot;js_darkmode__61 js_darkmode__text__417&quot;&gt;减少主线程阻塞95%+&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 0px 10px 16px&quot; class=&quot;js_darkmode__62 js_darkmode__text__420&quot;&gt;高吞吐量场景&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px 10px 0px&quot; class=&quot;js_darkmode__63 js_darkmode__text__424&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;批量处理&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px&quot; class=&quot;js_darkmode__64 js_darkmode__text__428&quot;&gt;10倍+ 吞吐量提升&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 0px 10px 16px&quot; class=&quot;js_darkmode__65 js_darkmode__text__431&quot;&gt;数据库/网络目标&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px 10px 0px&quot; class=&quot;js_darkmode__66 js_darkmode__text__435&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;缓存优化&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px&quot; class=&quot;js_darkmode__67 js_darkmode__text__439&quot;&gt;减少GC压力&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 0px 10px 16px&quot; class=&quot;js_darkmode__68 js_darkmode__text__442&quot;&gt;高频日志记录&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p style=&quot;margin: 16px 0px;color: rgb(15, 17, 21);font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255)&quot; class=&quot;js_darkmode__69 js_darkmode__text__445&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;生产环境优化配置&lt;/strong&gt;：&lt;/p&gt;&lt;p&gt;&lt;section class=&quot;code-snippet__fix code-snippet__js js_darkmode__text__451&quot;&gt;&lt;ul class=&quot;code-snippet__line-index code-snippet__js list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;pre class=&quot;code-snippet__js js_darkmode__text__452&quot; data-lang=&quot;typescript&quot;&gt;&lt;code&gt;&amp;lt;target name=&lt;span class=&quot;code-snippet__string js_darkmode__text__455&quot;&gt;&amp;quot;asyncFile&amp;quot;&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;code-snippet__attr js_darkmode__text__456&quot;&gt;xsi&lt;/span&gt;:&lt;span class=&quot;code-snippet__keyword js_darkmode__text__457&quot;&gt;type&lt;/span&gt;=&lt;span class=&quot;code-snippet__string js_darkmode__text__458&quot;&gt;&amp;quot;AsyncWrapper&amp;quot;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; overflowAction=&lt;span class=&quot;code-snippet__string js_darkmode__text__461&quot;&gt;&amp;quot;Block&amp;quot;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;!-- 队列满时阻塞 --&amp;gt;&lt;/code&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; queueLimit=&lt;span class=&quot;code-snippet__string js_darkmode__text__464&quot;&gt;&amp;quot;10000&amp;quot;&lt;/span&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;!-- 队列容量 --&amp;gt;&lt;/code&gt;&lt;code&gt;&lt;br/&gt;&lt;/code&gt;&lt;code&gt;&lt;span class=&quot;code-snippet__tag js_darkmode__text__467&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;code-snippet__tag js_darkmode__text__468&quot;&gt;&lt;span class=&quot;code-snippet__name js_darkmode__text__469&quot;&gt;target&lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;code-snippet__tag js_darkmode__text__470&quot;&gt;&lt;span class=&quot;code-snippet__attr js_darkmode__text__471&quot;&gt;xsi:type&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;code-snippet__tag js_darkmode__text__472&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;code-snippet__tag js_darkmode__text__473&quot;&gt;&lt;span class=&quot;code-snippet__string js_darkmode__text__474&quot;&gt;&amp;quot;File&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span class=&quot;code-snippet__attr js_darkmode__text__477&quot;&gt;fileName&lt;/span&gt;=&lt;span class=&quot;code-snippet__string js_darkmode__text__478&quot;&gt;&amp;quot;logs/${shortdate}.log&amp;quot;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span class=&quot;code-snippet__attr js_darkmode__text__481&quot;&gt;concurrentWrites&lt;/span&gt;=&lt;span class=&quot;code-snippet__string js_darkmode__text__482&quot;&gt;&amp;quot;true&amp;quot;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;lt;!&lt;span class=&quot;code-snippet__attr js_darkmode__text__483&quot;&gt;--&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;code-snippet__attr js_darkmode__text__484&quot;&gt;多线程安全&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;code-snippet__attr js_darkmode__text__485&quot;&gt;--&lt;/span&gt;&amp;gt;&lt;/code&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; keepFileOpen=&amp;quot;true&amp;quot; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;code-snippet__comment js_darkmode__text__488&quot;&gt;&amp;lt;!-- 保持文件打开状态 --&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; openFileFlushTimeout=&amp;quot;5&amp;quot; &amp;nbsp;&amp;nbsp;&lt;span class=&quot;code-snippet__comment js_darkmode__text__491&quot;&gt;&amp;lt;!-- 批量刷新间隔 --&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; archiveAboveSize=&amp;quot;20971520&amp;quot;&amp;nbsp;&lt;span class=&quot;code-snippet__comment js_darkmode__text__494&quot;&gt;&amp;lt;!-- 20MB自动归档 --&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; maxArchiveFiles=&amp;quot;100&amp;quot; /&amp;gt; &amp;nbsp; &amp;nbsp;&amp;lt;!-- 最多保留&lt;span class=&quot;code-snippet__number js_darkmode__text__497&quot;&gt;100&lt;/span&gt;个归档文件 --&amp;gt;&lt;/code&gt;&lt;code&gt;&amp;lt;/target&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/section&gt;&lt;/p&gt;&lt;h3 style=&quot;font: 700 20px / 30px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;margin: 32px 0px 16px;color: rgb(15, 17, 21);letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255)&quot; class=&quot;js_darkmode__70 js_darkmode__text__500&quot;&gt;五、结构化日志与高级布局渲染器&lt;/h3&gt;&lt;h4 style=&quot;font: 600 16px / 28px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;margin: 16px 0px;color: rgb(15, 17, 21);letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255)&quot; class=&quot;js_darkmode__71 js_darkmode__text__503&quot;&gt;5.1 结构化日志输出&lt;/h4&gt;&lt;p&gt;&lt;section class=&quot;code-snippet__fix code-snippet__js js_darkmode__text__506&quot;&gt;&lt;ul class=&quot;code-snippet__line-index code-snippet__js list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;pre class=&quot;code-snippet__js js_darkmode__text__507&quot; data-lang=&quot;xml&quot;&gt;&amp;lt;!--&amp;nbsp;输出为JSON格式&amp;nbsp;--&amp;gt;&amp;lt;target&amp;nbsp;name=&amp;quot;jsonFile&amp;quot;&amp;nbsp;xsi:type=&amp;quot;File&amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;fileName=&amp;quot;logs/log.json&amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;layout=&amp;quot;${json-encode:inner=&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;${longdate}|${level}|${logger}|${message}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;${exception:format=tostring:maxInnerExceptionLevel=5}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;quot;/&amp;gt;&lt;/pre&gt;&lt;/section&gt;&lt;/p&gt;&lt;h4 style=&quot;font: 600 16px / 28px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;margin: 16px 0px;color: rgb(15, 17, 21);letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255)&quot; class=&quot;js_darkmode__72 js_darkmode__text__540&quot;&gt;5.2 内置布局渲染器&lt;/h4&gt;&lt;p style=&quot;margin: 16px 0px;color: rgb(15, 17, 21);font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255)&quot; class=&quot;js_darkmode__73 js_darkmode__text__543&quot;&gt;NLog 内置丰富的&amp;nbsp;&lt;strong style=&quot;font-weight: 600&quot;&gt;Layout Renderer&lt;/strong&gt;，可捕获上下文信息：&lt;/p&gt;&lt;table width=&quot;752&quot;&gt;&lt;thead&gt;&lt;tr class=&quot;firstRow&quot;&gt;&lt;th style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.12);font: 500 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;border-top-width: medium;border-top-style: none;border-top-color: currentcolor;padding: 10px 16px 10px 0px;text-align: left&quot; class=&quot;js_darkmode__74 js_darkmode__text__554&quot;&gt;类别&lt;/th&gt;&lt;th style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.12);font: 500 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;border-top-width: medium;border-top-style: none;border-top-color: currentcolor;padding: 10px 16px;text-align: left&quot; class=&quot;js_darkmode__75 js_darkmode__text__557&quot;&gt;渲染器示例&lt;/th&gt;&lt;th style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.12);font: 500 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;border-top-width: medium;border-top-style: none;border-top-color: currentcolor;padding: 10px 16px;text-align: left&quot; class=&quot;js_darkmode__76 js_darkmode__text__560&quot;&gt;输出内容&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px 10px 0px&quot; class=&quot;js_darkmode__77 js_darkmode__text__565&quot;&gt;时间日期&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px&quot; class=&quot;js_darkmode__78 js_darkmode__text__568&quot;&gt;&lt;code style=&quot;box-sizing: border-box;font: 400 13px / 22px Menlo, Monaco, Consolas, &amp;#39;Cascadia Mono&amp;#39;, &amp;#39;Ubuntu Mono&amp;#39;, &amp;#39;DejaVu Sans Mono&amp;#39;, &amp;#39;Liberation Mono&amp;#39;, &amp;#39;JetBrains Mono&amp;#39;, &amp;#39;Fira Code&amp;#39;, Cousine, &amp;#39;Roboto Mono&amp;#39;, &amp;#39;Courier New&amp;#39;, Courier, sans-serif, system-ui;background-color: rgb(235, 238, 242);border-radius: 6px;align-items: center;padding: 0px 5px;display: inline-flex&quot; class=&quot;js_darkmode__79 js_darkmode__text__569&quot;&gt;${longdate}&lt;/code&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 0px 10px 16px&quot; class=&quot;js_darkmode__80 js_darkmode__text__571&quot;&gt;2025-01-15 14:30:25.1234&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px 10px 0px&quot; class=&quot;js_darkmode__81 js_darkmode__text__575&quot;&gt;环境信息&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px&quot; class=&quot;js_darkmode__82 js_darkmode__text__578&quot;&gt;&lt;code style=&quot;box-sizing: border-box;font: 400 13px / 22px Menlo, Monaco, Consolas, &amp;#39;Cascadia Mono&amp;#39;, &amp;#39;Ubuntu Mono&amp;#39;, &amp;#39;DejaVu Sans Mono&amp;#39;, &amp;#39;Liberation Mono&amp;#39;, &amp;#39;JetBrains Mono&amp;#39;, &amp;#39;Fira Code&amp;#39;, Cousine, &amp;#39;Roboto Mono&amp;#39;, &amp;#39;Courier New&amp;#39;, Courier, sans-serif, system-ui;background-color: rgb(235, 238, 242);border-radius: 6px;align-items: center;padding: 0px 5px;display: inline-flex&quot; class=&quot;js_darkmode__83 js_darkmode__text__579&quot;&gt;${processname}&lt;/code&gt;&amp;nbsp;&lt;code style=&quot;box-sizing: border-box;font: 400 13px / 22px Menlo, Monaco, Consolas, &amp;#39;Cascadia Mono&amp;#39;, &amp;#39;Ubuntu Mono&amp;#39;, &amp;#39;DejaVu Sans Mono&amp;#39;, &amp;#39;Liberation Mono&amp;#39;, &amp;#39;JetBrains Mono&amp;#39;, &amp;#39;Fira Code&amp;#39;, Cousine, &amp;#39;Roboto Mono&amp;#39;, &amp;#39;Courier New&amp;#39;, Courier, sans-serif, system-ui;background-color: rgb(235, 238, 242);border-radius: 6px;align-items: center;padding: 0px 5px;display: inline-flex&quot; class=&quot;js_darkmode__84 js_darkmode__text__581&quot;&gt;${threadid}&lt;/code&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 0px 10px 16px&quot; class=&quot;js_darkmode__85 js_darkmode__text__583&quot;&gt;当前进程名、线程ID&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px 10px 0px&quot; class=&quot;js_darkmode__86 js_darkmode__text__587&quot;&gt;异常堆栈&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px&quot; class=&quot;js_darkmode__87 js_darkmode__text__590&quot;&gt;&lt;code style=&quot;box-sizing: border-box;font: 400 13px / 22px Menlo, Monaco, Consolas, &amp;#39;Cascadia Mono&amp;#39;, &amp;#39;Ubuntu Mono&amp;#39;, &amp;#39;DejaVu Sans Mono&amp;#39;, &amp;#39;Liberation Mono&amp;#39;, &amp;#39;JetBrains Mono&amp;#39;, &amp;#39;Fira Code&amp;#39;, Cousine, &amp;#39;Roboto Mono&amp;#39;, &amp;#39;Courier New&amp;#39;, Courier, sans-serif, system-ui;background-color: rgb(235, 238, 242);border-radius: 6px;align-items: center;padding: 0px 5px;display: inline-flex&quot; class=&quot;js_darkmode__88 js_darkmode__text__591&quot;&gt;${exception:format=ToString}&lt;/code&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 0px 10px 16px&quot; class=&quot;js_darkmode__89 js_darkmode__text__593&quot;&gt;完整异常信息&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px 10px 0px&quot; class=&quot;js_darkmode__90 js_darkmode__text__597&quot;&gt;调用上下文&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px&quot; class=&quot;js_darkmode__91 js_darkmode__text__600&quot;&gt;&lt;code style=&quot;box-sizing: border-box;font: 400 13px / 22px Menlo, Monaco, Consolas, &amp;#39;Cascadia Mono&amp;#39;, &amp;#39;Ubuntu Mono&amp;#39;, &amp;#39;DejaVu Sans Mono&amp;#39;, &amp;#39;Liberation Mono&amp;#39;, &amp;#39;JetBrains Mono&amp;#39;, &amp;#39;Fira Code&amp;#39;, Cousine, &amp;#39;Roboto Mono&amp;#39;, &amp;#39;Courier New&amp;#39;, Courier, sans-serif, system-ui;background-color: rgb(235, 238, 242);border-radius: 6px;align-items: center;padding: 0px 5px;display: inline-flex&quot; class=&quot;js_darkmode__92 js_darkmode__text__601&quot;&gt;${callsite}&lt;/code&gt;&amp;nbsp;&lt;code style=&quot;box-sizing: border-box;font: 400 13px / 22px Menlo, Monaco, Consolas, &amp;#39;Cascadia Mono&amp;#39;, &amp;#39;Ubuntu Mono&amp;#39;, &amp;#39;DejaVu Sans Mono&amp;#39;, &amp;#39;Liberation Mono&amp;#39;, &amp;#39;JetBrains Mono&amp;#39;, &amp;#39;Fira Code&amp;#39;, Cousine, &amp;#39;Roboto Mono&amp;#39;, &amp;#39;Courier New&amp;#39;, Courier, sans-serif, system-ui;background-color: rgb(235, 238, 242);border-radius: 6px;align-items: center;padding: 0px 5px;display: inline-flex&quot; class=&quot;js_darkmode__93 js_darkmode__text__603&quot;&gt;${stacktrace}&lt;/code&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 0px 10px 16px&quot; class=&quot;js_darkmode__94 js_darkmode__text__605&quot;&gt;方法名、调用堆栈&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px 10px 0px&quot; class=&quot;js_darkmode__95 js_darkmode__text__609&quot;&gt;自定义属性&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px&quot; class=&quot;js_darkmode__96 js_darkmode__text__612&quot;&gt;&lt;code style=&quot;box-sizing: border-box;font: 400 13px / 22px Menlo, Monaco, Consolas, &amp;#39;Cascadia Mono&amp;#39;, &amp;#39;Ubuntu Mono&amp;#39;, &amp;#39;DejaVu Sans Mono&amp;#39;, &amp;#39;Liberation Mono&amp;#39;, &amp;#39;JetBrains Mono&amp;#39;, &amp;#39;Fira Code&amp;#39;, Cousine, &amp;#39;Roboto Mono&amp;#39;, &amp;#39;Courier New&amp;#39;, Courier, sans-serif, system-ui;background-color: rgb(235, 238, 242);border-radius: 6px;align-items: center;padding: 0px 5px;display: inline-flex&quot; class=&quot;js_darkmode__97 js_darkmode__text__613&quot;&gt;${event-properties:item=UserId}&lt;/code&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 0px 10px 16px&quot; class=&quot;js_darkmode__98 js_darkmode__text__615&quot;&gt;通过&amp;nbsp;&lt;code style=&quot;box-sizing: border-box;font: 400 13px / 22px Menlo, Monaco, Consolas, &amp;#39;Cascadia Mono&amp;#39;, &amp;#39;Ubuntu Mono&amp;#39;, &amp;#39;DejaVu Sans Mono&amp;#39;, &amp;#39;Liberation Mono&amp;#39;, &amp;#39;JetBrains Mono&amp;#39;, &amp;#39;Fira Code&amp;#39;, Cousine, &amp;#39;Roboto Mono&amp;#39;, &amp;#39;Courier New&amp;#39;, Courier, sans-serif, system-ui;background-color: rgb(235, 238, 242);border-radius: 6px;align-items: center;padding: 0px 5px;display: inline-flex&quot; class=&quot;js_darkmode__99 js_darkmode__text__618&quot;&gt;LogEventInfo.Properties&lt;/code&gt;&amp;nbsp;传入&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;h3 style=&quot;font: 700 20px / 30px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;margin: 32px 0px 16px;color: rgb(15, 17, 21);letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255)&quot; class=&quot;js_darkmode__100 js_darkmode__text__622&quot;&gt;六、企业级实践模式&lt;/h3&gt;&lt;h4 style=&quot;font: 600 16px / 28px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;margin: 16px 0px;color: rgb(15, 17, 21);letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255)&quot; class=&quot;js_darkmode__101 js_darkmode__text__625&quot;&gt;6.1 分层存储策略&lt;/h4&gt;&lt;p&gt;&lt;section class=&quot;code-snippet__fix code-snippet__js js_darkmode__text__628&quot;&gt;&lt;ul class=&quot;code-snippet__line-index code-snippet__js list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;pre class=&quot;code-snippet__js js_darkmode__text__629&quot; data-lang=&quot;bash&quot;&gt;logs/├──&amp;nbsp;flow_logs/&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;业务流程日志│&amp;nbsp;&amp;nbsp;&amp;nbsp;├──&amp;nbsp;{工序1}_{工位1}/│&amp;nbsp;&amp;nbsp;&amp;nbsp;│&amp;nbsp;&amp;nbsp;&amp;nbsp;├──&amp;nbsp;flowlog_2025-01-15.log&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;Info级别│&amp;nbsp;&amp;nbsp;&amp;nbsp;│&amp;nbsp;&amp;nbsp;&amp;nbsp;├──&amp;nbsp;warnlog_2025-01-15.log&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;Warn级别&amp;nbsp;&amp;nbsp;│&amp;nbsp;&amp;nbsp;&amp;nbsp;│&amp;nbsp;&amp;nbsp;&amp;nbsp;└──&amp;nbsp;tracelog_2025-01-15.log&amp;nbsp;&amp;nbsp;#&amp;nbsp;Trace级别│&amp;nbsp;&amp;nbsp;&amp;nbsp;└──&amp;nbsp;{工序2}_{工位1}/├──&amp;nbsp;error_logs/&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;错误日志集中存储└──&amp;nbsp;performance_logs/&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;性能监控日志&lt;/pre&gt;&lt;/section&gt;&lt;/p&gt;&lt;p style=&quot;margin: 16px 0px;color: rgb(15, 17, 21);font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255)&quot; class=&quot;js_darkmode__102 js_darkmode__text__654&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;配置实现&lt;/strong&gt;：&lt;/p&gt;&lt;p&gt;&lt;section class=&quot;code-snippet__fix code-snippet__js js_darkmode__text__660&quot;&gt;&lt;ul class=&quot;code-snippet__line-index code-snippet__js list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;pre class=&quot;code-snippet__js js_darkmode__text__661&quot; data-lang=&quot;xml&quot;&gt;&amp;lt;variable&amp;nbsp;name=&amp;quot;flowLogDirectory&amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;value=&amp;quot;logs/flow_logs/${logger:substring=28:whenEmpty=default}&amp;quot;&amp;nbsp;/&amp;gt;&amp;lt;target&amp;nbsp;name=&amp;quot;flowLog&amp;quot;&amp;nbsp;xsi:type=&amp;quot;File&amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;fileName=&amp;quot;${flowLogDirectory}/flowlog_${shortdate}.log&amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;maxArchiveFiles=&amp;quot;100&amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;archiveAboveSize=&amp;quot;20971520&amp;quot;&amp;nbsp;/&amp;gt;&amp;nbsp;&amp;nbsp;&amp;lt;!--&amp;nbsp;20MB&amp;nbsp;--&amp;gt;&lt;/pre&gt;&lt;/section&gt;&lt;/p&gt;&lt;h4 style=&quot;font: 600 16px / 28px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;margin: 16px 0px;color: rgb(15, 17, 21);letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255)&quot; class=&quot;js_darkmode__103 js_darkmode__text__704&quot;&gt;6.2 业务层封装与上下文传递&lt;/h4&gt;&lt;p&gt;&lt;section style=&quot;text-align: center&quot;&gt;&lt;img class=&quot;rich_pages wxw-img js_insertlocalimg&quot; data-aistatus=&quot;1&quot; data-imgfileid=&quot;100000663&quot; data-s=&quot;300,640&quot; data-src=&quot;https://mmbiz.qpic.cn/mmbiz_png/Qj7nHlfytbDnmwP6NFMWPZoPfvAof4ibcHJVmICpQD2MvBZB9YgQfQ8yKDC1LfXzbm9tWyap0bNYxPy3MxkdsmMr29bLO2VgsTOZfNmu1kVg/640?wx_fmt=png&amp;amp;from=appmsg&amp;amp;watermark=1#imgIndex=7&quot; data-type=&quot;png&quot; type=&quot;block&quot; data-original-style=&quot;null&quot; data-index=&quot;7&quot; data-ratio=&quot;0.6977077363896849&quot; data-w=&quot;698&quot; src=&quot;https://mmbiz.qpic.cn/mmbiz_png/Qj7nHlfytbDnmwP6NFMWPZoPfvAof4ibcHJVmICpQD2MvBZB9YgQfQ8yKDC1LfXzbm9tWyap0bNYxPy3MxkdsmMr29bLO2VgsTOZfNmu1kVg/640?wx_fmt=png&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1&amp;watermark=1#imgIndex=7&quot; _width=&quot;384px&quot; __sec_open_place_holder__=&quot;true&quot; style=&quot;height: auto !important;visibility: visible !important;width: 677px !important&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780237910820&quot; data-report-img-idx=&quot;7&quot; data-fail=&quot;0&quot;/&gt;&lt;/section&gt;&lt;/p&gt;&lt;hr style=&quot;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0.1);border-width: medium;border-style: none;border-color: currentcolor;border-image: initial;height: 1px;margin: 32px 0px;display: block;font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal&quot;/&gt;&lt;h2 style=&quot;font: 700 22px / 32px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;margin: 32px 0px 16px;color: rgb(15, 17, 21);letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255)&quot; class=&quot;js_darkmode__105 js_darkmode__text__707&quot;&gt;💡 第三部分：核心概念与最佳实践&lt;/h2&gt;&lt;h3 style=&quot;font: 700 20px / 30px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;margin: 32px 0px 16px;color: rgb(15, 17, 21);letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255)&quot; class=&quot;js_darkmode__106 js_darkmode__text__710&quot;&gt;日志级别使用指南&lt;/h3&gt;&lt;table width=&quot;752&quot;&gt;&lt;thead&gt;&lt;tr class=&quot;firstRow&quot;&gt;&lt;th style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.12);font: 500 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;border-top-width: medium;border-top-style: none;border-top-color: currentcolor;padding: 10px 16px 10px 0px;text-align: left&quot; class=&quot;js_darkmode__107 js_darkmode__text__716&quot;&gt;级别 (Level)&lt;/th&gt;&lt;th style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.12);font: 500 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;border-top-width: medium;border-top-style: none;border-top-color: currentcolor;padding: 10px 16px;text-align: left&quot; class=&quot;js_darkmode__108 js_darkmode__text__719&quot;&gt;最佳应用场景&lt;/th&gt;&lt;th style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.12);font: 500 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;border-top-width: medium;border-top-style: none;border-top-color: currentcolor;padding: 10px 16px;text-align: left&quot; class=&quot;js_darkmode__109 js_darkmode__text__722&quot;&gt;一句话指南&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px 10px 0px&quot; class=&quot;js_darkmode__110 js_darkmode__text__727&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;Trace&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px&quot; class=&quot;js_darkmode__111 js_darkmode__text__731&quot;&gt;开发调试，如进入/退出方法、变量值变化&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 0px 10px 16px&quot; class=&quot;js_darkmode__112 js_darkmode__text__734&quot;&gt;&amp;quot;无巨细&amp;quot;，只在开发时开启&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px 10px 0px&quot; class=&quot;js_darkmode__113 js_darkmode__text__738&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;Debug&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px&quot; class=&quot;js_darkmode__114 js_darkmode__text__742&quot;&gt;调试信息，用于定位问题的线索&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 0px 10px 16px&quot; class=&quot;js_darkmode__115 js_darkmode__text__745&quot;&gt;&amp;quot;帮我找bug&amp;quot;，调试或测试环境&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px 10px 0px&quot; class=&quot;js_darkmode__116 js_darkmode__text__749&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;Info&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px&quot; class=&quot;js_darkmode__117 js_darkmode__text__753&quot;&gt;记录关键业务节点，如用户登录、订单创建&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 0px 10px 16px&quot; class=&quot;js_darkmode__118 js_darkmode__text__756&quot;&gt;&amp;quot;看，它正常跑着呢&amp;quot;，生产环境常态&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px 10px 0px&quot; class=&quot;js_darkmode__119 js_darkmode__text__760&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;Warn&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px&quot; class=&quot;js_darkmode__120 js_darkmode__text__764&quot;&gt;发生了意外但不影响核心流程，如配置项缺失使用默认值&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 0px 10px 16px&quot; class=&quot;js_darkmode__121 js_darkmode__text__767&quot;&gt;&amp;quot;小心，有情况&amp;quot;，需要关注&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px 10px 0px&quot; class=&quot;js_darkmode__122 js_darkmode__text__771&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;Error&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px&quot; class=&quot;js_darkmode__123 js_darkmode__text__775&quot;&gt;发生了错误，但程序能继续为其他用户服务&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 0px 10px 16px&quot; class=&quot;js_darkmode__124 js_darkmode__text__778&quot;&gt;&amp;quot;出错了，但天没塌&amp;quot;，及时告警&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px 10px 0px&quot; class=&quot;js_darkmode__125 js_darkmode__text__782&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;Fatal&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px&quot; class=&quot;js_darkmode__126 js_darkmode__text__786&quot;&gt;导致应用程序崩溃的灾难性错误&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 0px 10px 16px&quot; class=&quot;js_darkmode__127 js_darkmode__text__789&quot;&gt;&amp;quot;完了，要重启了&amp;quot;，最高级别告警&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p style=&quot;margin: 16px 0px;color: rgb(15, 17, 21);font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255)&quot; class=&quot;js_darkmode__128 js_darkmode__text__792&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;建议&lt;/strong&gt;：在生产环境中，将&amp;nbsp;&lt;code style=&quot;box-sizing: border-box;font-style: normal;font-variant: normal;font-weight: 400;font-stretch: 100%;line-height: 22px;font-optical-sizing: auto;font-size-adjust: none;font-kerning: auto;font-feature-settings: normal;font-variation-settings: normal;font-language-override: normal;font-family: Menlo, Monaco, Consolas, &amp;#39;Cascadia Mono&amp;#39;, &amp;#39;Ubuntu Mono&amp;#39;, &amp;#39;DejaVu Sans Mono&amp;#39;, &amp;#39;Liberation Mono&amp;#39;, &amp;#39;JetBrains Mono&amp;#39;, &amp;#39;Fira Code&amp;#39;, Cousine, &amp;#39;Roboto Mono&amp;#39;, &amp;#39;Courier New&amp;#39;, Courier, sans-serif, system-ui;background-color: rgb(235, 238, 242);border-radius: 6px;align-items: center;padding: 0px 5px;display: inline-flex;font-size: 0.875em !important&quot; class=&quot;js_darkmode__129 js_darkmode__text__798&quot;&gt;minlevel&lt;/code&gt;&amp;nbsp;设置为&amp;nbsp;&lt;code style=&quot;box-sizing: border-box;font-style: normal;font-variant: normal;font-weight: 400;font-stretch: 100%;line-height: 22px;font-optical-sizing: auto;font-size-adjust: none;font-kerning: auto;font-feature-settings: normal;font-variation-settings: normal;font-language-override: normal;font-family: Menlo, Monaco, Consolas, &amp;#39;Cascadia Mono&amp;#39;, &amp;#39;Ubuntu Mono&amp;#39;, &amp;#39;DejaVu Sans Mono&amp;#39;, &amp;#39;Liberation Mono&amp;#39;, &amp;#39;JetBrains Mono&amp;#39;, &amp;#39;Fira Code&amp;#39;, Cousine, &amp;#39;Roboto Mono&amp;#39;, &amp;#39;Courier New&amp;#39;, Courier, sans-serif, system-ui;background-color: rgb(235, 238, 242);border-radius: 6px;align-items: center;padding: 0px 5px;display: inline-flex;font-size: 0.875em !important&quot; class=&quot;js_darkmode__130 js_darkmode__text__802&quot;&gt;Info&lt;/code&gt;，这样既能记录关键信息，又能避免大量&amp;nbsp;&lt;code style=&quot;box-sizing: border-box;font-style: normal;font-variant: normal;font-weight: 400;font-stretch: 100%;line-height: 22px;font-optical-sizing: auto;font-size-adjust: none;font-kerning: auto;font-feature-settings: normal;font-variation-settings: normal;font-language-override: normal;font-family: Menlo, Monaco, Consolas, &amp;#39;Cascadia Mono&amp;#39;, &amp;#39;Ubuntu Mono&amp;#39;, &amp;#39;DejaVu Sans Mono&amp;#39;, &amp;#39;Liberation Mono&amp;#39;, &amp;#39;JetBrains Mono&amp;#39;, &amp;#39;Fira Code&amp;#39;, Cousine, &amp;#39;Roboto Mono&amp;#39;, &amp;#39;Courier New&amp;#39;, Courier, sans-serif, system-ui;background-color: rgb(235, 238, 242);border-radius: 6px;align-items: center;padding: 0px 5px;display: inline-flex;font-size: 0.875em !important&quot; class=&quot;js_darkmode__131 js_darkmode__text__806&quot;&gt;Debug&lt;/code&gt;&amp;nbsp;日志拖慢性能。&lt;/p&gt;&lt;h3 style=&quot;font: 700 20px / 30px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;margin: 32px 0px 16px;color: rgb(15, 17, 21);letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255)&quot; class=&quot;js_darkmode__132 js_darkmode__text__810&quot;&gt;NLog v6.0 核心亮点&lt;/h3&gt;&lt;ul style=&quot;margin: 16px 0px;padding-left: 18px;color: rgb(15, 17, 21);font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255)&quot; class=&quot;js_darkmode__133 js_darkmode__text__813 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p style=&quot;margin-top: 0px !important;margin-right: 0px;margin-bottom: 0px;margin-left: 0px&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;支持 AOT 编译&lt;/strong&gt;：完全支持 Ahead-Of-Time 编译，这对于追求极致启动性能的应用（如微服务、函数计算）是重大利好。&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;margin-top: 0px !important;margin-right: 0px;margin-bottom: 0px;margin-left: 0px&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;减少内存分配&lt;/strong&gt;：支持&amp;nbsp;&lt;code style=&quot;box-sizing: border-box;font-style: normal;font-variant: normal;font-weight: 400;font-stretch: 100%;line-height: 22px;font-optical-sizing: auto;font-size-adjust: none;font-kerning: auto;font-feature-settings: normal;font-variation-settings: normal;font-language-override: normal;font-family: Menlo, Monaco, Consolas, &amp;#39;Cascadia Mono&amp;#39;, &amp;#39;Ubuntu Mono&amp;#39;, &amp;#39;DejaVu Sans Mono&amp;#39;, &amp;#39;Liberation Mono&amp;#39;, &amp;#39;JetBrains Mono&amp;#39;, &amp;#39;Fira Code&amp;#39;, Cousine, &amp;#39;Roboto Mono&amp;#39;, &amp;#39;Courier New&amp;#39;, Courier, sans-serif, system-ui;background-color: rgb(235, 238, 242);border-radius: 6px;align-items: center;padding: 0px 5px;display: inline-flex;font-size: 0.875em !important&quot; class=&quot;js_darkmode__134 js_darkmode__text__828&quot;&gt;ReadOnlySpan&amp;lt;T&amp;gt;&lt;/code&gt;，能有效减少内存分配和垃圾回收（GC）压力。&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;margin-top: 0px !important;margin-right: 0px;margin-bottom: 0px;margin-left: 0px&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;模块化瘦身&lt;/strong&gt;：将许多高级功能（如邮件发送、GZip压缩、网络传输等）拆分成了独立的 NuGet 包，可按需引入。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr style=&quot;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0.1);border-width: medium;border-style: none;border-color: currentcolor;border-image: initial;height: 1px;margin: 32px 0px;display: block;font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal&quot;/&gt;&lt;h2 style=&quot;font: 700 22px / 32px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;margin: 32px 0px 16px;color: rgb(15, 17, 21);letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255)&quot; class=&quot;js_darkmode__136 js_darkmode__text__839&quot;&gt;⚖️ 第四部分：与其他日志库对比&lt;/h2&gt;&lt;p style=&quot;margin: 16px 0px;color: rgb(15, 17, 21);font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255)&quot; class=&quot;js_darkmode__137 js_darkmode__text__842&quot;&gt;在 .NET 生态中，NLog 与 Serilog、log4net 并称三大日志&amp;quot;法器&amp;quot;。&lt;/p&gt;&lt;table width=&quot;NaN&quot;&gt;&lt;thead&gt;&lt;tr class=&quot;firstRow&quot;&gt;&lt;th style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.12);font: 500 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;border-top-width: medium;border-top-style: none;border-top-color: currentcolor;padding: 10px 16px 10px 0px;text-align: left&quot; class=&quot;js_darkmode__138 js_darkmode__text__848&quot;&gt;特性&lt;/th&gt;&lt;th style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.12);font: 500 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;border-top-width: medium;border-top-style: none;border-top-color: currentcolor;padding: 10px 16px;text-align: left&quot; class=&quot;js_darkmode__139 js_darkmode__text__851&quot;&gt;NLog&lt;/th&gt;&lt;th style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.12);font: 500 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;border-top-width: medium;border-top-style: none;border-top-color: currentcolor;padding: 10px 16px;text-align: left&quot; class=&quot;js_darkmode__140 js_darkmode__text__854&quot;&gt;Serilog&lt;/th&gt;&lt;th style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.12);font: 500 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;border-top-width: medium;border-top-style: none;border-top-color: currentcolor;padding: 10px 16px;text-align: left&quot; class=&quot;js_darkmode__141 js_darkmode__text__857&quot;&gt;log4net&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px 10px 0px&quot; class=&quot;js_darkmode__142 js_darkmode__text__862&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;特点&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px&quot; class=&quot;js_darkmode__143 js_darkmode__text__866&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;功能丰富，配置灵活，性能均衡&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px&quot; class=&quot;js_darkmode__144 js_darkmode__text__870&quot;&gt;主打结构化日志，理念现代&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 0px 10px 16px&quot; class=&quot;js_darkmode__145 js_darkmode__text__873&quot;&gt;Apache 基金会项目，历史悠久&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px 10px 0px&quot; class=&quot;js_darkmode__146 js_darkmode__text__877&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;配置方式&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px&quot; class=&quot;js_darkmode__147 js_darkmode__text__881&quot;&gt;支持 XML、JSON、代码配置&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px&quot; class=&quot;js_darkmode__148 js_darkmode__text__884&quot;&gt;以代码配置为主，流畅易读&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 0px 10px 16px&quot; class=&quot;js_darkmode__149 js_darkmode__text__887&quot;&gt;主要使用 XML 配置，学习曲线稍陡&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px 10px 0px&quot; class=&quot;js_darkmode__150 js_darkmode__text__891&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;性能&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px&quot; class=&quot;js_darkmode__151 js_darkmode__text__895&quot;&gt;极高，异步支持好&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px&quot; class=&quot;js_darkmode__152 js_darkmode__text__898&quot;&gt;高性能，但极端场景略逊&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 0px 10px 16px&quot; class=&quot;js_darkmode__153 js_darkmode__text__901&quot;&gt;高性能，与 NLog 持平&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px 10px 0px&quot; class=&quot;js_darkmode__154 js_darkmode__text__905&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;结构化日志&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px&quot; class=&quot;js_darkmode__155 js_darkmode__text__909&quot;&gt;原生支持，功能强大&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px&quot; class=&quot;js_darkmode__156 js_darkmode__text__912&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;杀手锏&lt;/strong&gt;，以此为核心设计&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 0px 10px 16px&quot; class=&quot;js_darkmode__157 js_darkmode__text__918&quot;&gt;支持较弱，需要额外扩展&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px 10px 0px&quot; class=&quot;js_darkmode__158 js_darkmode__text__922&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;跨平台支持&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px&quot; class=&quot;js_darkmode__159 js_darkmode__text__926&quot;&gt;.NET Core/MAUI/Xamarin&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px&quot; class=&quot;js_darkmode__160 js_darkmode__text__929&quot;&gt;完整&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 0px 10px 16px&quot; class=&quot;js_darkmode__161 js_darkmode__text__932&quot;&gt;受限&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px 10px 0px&quot; class=&quot;js_darkmode__162 js_darkmode__text__936&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;活跃维护度&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px&quot; class=&quot;js_darkmode__163 js_darkmode__text__940&quot;&gt;高（持续更新）&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px&quot; class=&quot;js_darkmode__164 js_darkmode__text__943&quot;&gt;高&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 0px 10px 16px&quot; class=&quot;js_darkmode__165 js_darkmode__text__946&quot;&gt;中&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px 10px 0px&quot; class=&quot;js_darkmode__166 js_darkmode__text__950&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;AOT兼容性&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px&quot; class=&quot;js_darkmode__167 js_darkmode__text__954&quot;&gt;✅ v6.0+&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 16px&quot; class=&quot;js_darkmode__168 js_darkmode__text__957&quot;&gt;部分&lt;/td&gt;&lt;td style=&quot;border-bottom: 1px solid rgba(0, 0, 0, 0.1);font: 400 15px / 25px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;min-width: 100px;max-width: min(30vw, 320px);padding: 10px 0px 10px 16px&quot; class=&quot;js_darkmode__169 js_darkmode__text__960&quot;&gt;❌&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p style=&quot;margin: 16px 0px;color: rgb(15, 17, 21);font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255)&quot; class=&quot;js_darkmode__170 js_darkmode__text__963&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;选型建议&lt;/strong&gt;：如果你需要一个&lt;strong style=&quot;font-weight: 600&quot;&gt;功能全面、性能强大、配置灵活且维护活跃&lt;/strong&gt;的日志库，NLog 是一个几乎不会选错的、非常成熟可靠的解决方案。&lt;/p&gt;&lt;hr style=&quot;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0.1);border-width: medium;border-style: none;border-color: currentcolor;border-image: initial;height: 1px;margin: 32px 0px;display: block;font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal&quot;/&gt;&lt;h2 style=&quot;font: 700 22px / 32px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;margin: 32px 0px 16px;color: rgb(15, 17, 21);letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255)&quot; class=&quot;js_darkmode__172 js_darkmode__text__974&quot;&gt;📝 第五部分：总结与最佳实践清单&lt;/h2&gt;&lt;h3 style=&quot;font: 700 20px / 30px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;margin: 32px 0px 16px;color: rgb(15, 17, 21);letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255)&quot; class=&quot;js_darkmode__173 js_darkmode__text__977&quot;&gt;生产环境必做事项&lt;/h3&gt;&lt;ol style=&quot;margin: 16px 0px;padding-left: 18px;color: rgb(15, 17, 21);font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;#39;Open Sans&amp;#39;, &amp;#39;Helvetica Neue&amp;#39;, sans-serif;font-size: 16px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255)&quot; class=&quot;js_darkmode__174 js_darkmode__text__980 list-paddingleft-2&quot; start=&quot;1&quot;&gt;&lt;li&gt;&lt;p style=&quot;margin-top: 0px !important;margin-right: 0px;margin-bottom: 0px;margin-left: 0px&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;始终使用 AsyncWrapper&lt;/strong&gt;：避免同步日志阻塞业务线程&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;margin-top: 0px !important;margin-right: 0px;margin-bottom: 0px;margin-left: 0px&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;合理设置日志级别&lt;/strong&gt;：生产环境&amp;nbsp;&lt;code style=&quot;box-sizing: border-box;font-style: normal;font-variant: normal;font-weight: 400;font-stretch: 100%;line-height: 22px;font-optical-sizing: auto;font-size-adjust: none;font-kerning: auto;font-feature-settings: normal;font-variation-settings: normal;font-language-override: normal;font-family: Menlo, Monaco, Consolas, &amp;#39;Cascadia Mono&amp;#39;, &amp;#39;Ubuntu Mono&amp;#39;, &amp;#39;DejaVu Sans Mono&amp;#39;, &amp;#39;Liberation Mono&amp;#39;, &amp;#39;JetBrains Mono&amp;#39;, &amp;#39;Fira Code&amp;#39;, Cousine, &amp;#39;Roboto Mono&amp;#39;, &amp;#39;Courier New&amp;#39;, Courier, sans-serif, system-ui;background-color: rgb(235, 238, 242);border-radius: 6px;align-items: center;padding: 0px 5px;display: inline-flex;font-size: 0.875em !important&quot; class=&quot;js_darkmode__175 js_darkmode__text__995&quot;&gt;minlevel=&amp;quot;Info&amp;quot;&lt;/code&gt;，避免调试日志影响性能&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;margin-top: 0px !important;margin-right: 0px;margin-bottom: 0px;margin-left: 0px&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;充分利用 final 规则&lt;/strong&gt;：减少不必要的规则匹配开销&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;margin-top: 0px !important;margin-right: 0px;margin-bottom: 0px;margin-left: 0px&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;使用 ${event-properties}&lt;/strong&gt;：传递结构化上下文数据，便于日志分析&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;margin-top: 0px !important;margin-right: 0px;margin-bottom: 0px;margin-left: 0px&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;配置文件分段管理&lt;/strong&gt;：通过&amp;nbsp;&lt;code style=&quot;box-sizing: border-box;font-style: normal;font-variant: normal;font-weight: 400;font-stretch: 100%;line-height: 22px;font-optical-sizing: auto;font-size-adjust: none;font-kerning: auto;font-feature-settings: normal;font-variation-settings: normal;font-language-override: normal;font-family: Menlo, Monaco, Consolas, &amp;#39;Cascadia Mono&amp;#39;, &amp;#39;Ubuntu Mono&amp;#39;, &amp;#39;DejaVu Sans Mono&amp;#39;, &amp;#39;Liberation Mono&amp;#39;, &amp;#39;JetBrains Mono&amp;#39;, &amp;#39;Fira Code&amp;#39;, Cousine, &amp;#39;Roboto Mono&amp;#39;, &amp;#39;Courier New&amp;#39;, Courier, sans-serif, system-ui;background-color: rgb(235, 238, 242);border-radius: 6px;align-items: center;padding: 0px 5px;display: inline-flex;font-size: 0.875em !important&quot; class=&quot;js_darkmode__176 js_darkmode__text__1020&quot;&gt;&amp;lt;include&amp;gt;&lt;/code&gt;&amp;nbsp;实现模块化配置&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;margin-top: 0px !important;margin-right: 0px;margin-bottom: 0px;margin-left: 0px&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;定期归档清理&lt;/strong&gt;：配置&amp;nbsp;&lt;code style=&quot;box-sizing: border-box;font-style: normal;font-variant: normal;font-weight: 400;font-stretch: 100%;line-height: 22px;font-optical-sizing: auto;font-size-adjust: none;font-kerning: auto;font-feature-settings: normal;font-variation-settings: normal;font-language-override: normal;font-family: Menlo, Monaco, Consolas, &amp;#39;Cascadia Mono&amp;#39;, &amp;#39;Ubuntu Mono&amp;#39;, &amp;#39;DejaVu Sans Mono&amp;#39;, &amp;#39;Liberation Mono&amp;#39;, &amp;#39;JetBrains Mono&amp;#39;, &amp;#39;Fira Code&amp;#39;, Cousine, &amp;#39;Roboto Mono&amp;#39;, &amp;#39;Courier New&amp;#39;, Courier, sans-serif, system-ui;background-color: rgb(235, 238, 242);border-radius: 6px;align-items: center;padding: 0px 5px;display: inline-flex;font-size: 0.875em !important&quot; class=&quot;js_darkmode__177 js_darkmode__text__1031&quot;&gt;maxArchiveFiles&lt;/code&gt;&amp;nbsp;和&amp;nbsp;&lt;code style=&quot;box-sizing: border-box;font-style: normal;font-variant: normal;font-weight: 400;font-stretch: 100%;line-height: 22px;font-optical-sizing: auto;font-size-adjust: none;font-kerning: auto;font-feature-settings: normal;font-variation-settings: normal;font-language-override: normal;font-family: Menlo, Monaco, Consolas, &amp;#39;Cascadia Mono&amp;#39;, &amp;#39;Ubuntu Mono&amp;#39;, &amp;#39;DejaVu Sans Mono&amp;#39;, &amp;#39;Liberation Mono&amp;#39;, &amp;#39;JetBrains Mono&amp;#39;, &amp;#39;Fira Code&amp;#39;, Cousine, &amp;#39;Roboto Mono&amp;#39;, &amp;#39;Courier New&amp;#39;, Courier, sans-serif, system-ui;background-color: rgb(235, 238, 242);border-radius: 6px;align-items: center;padding: 0px 5px;display: inline-flex;font-size: 0.875em !important&quot; class=&quot;js_darkmode__178 js_darkmode__text__1035&quot;&gt;archiveAboveSize&lt;/code&gt;&amp;nbsp;防止磁盘占满&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;margin-top: 0px !important;margin-right: 0px;margin-bottom: 0px;margin-left: 0px&quot;&gt;&lt;strong style=&quot;font-weight: 600&quot;&gt;配置连接池&lt;/strong&gt;：使用数据库目标时启用连接池&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;h3 style=&quot;font: 700 20px / 30px quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, Oxygen, Ubuntu, Cantarell, &amp;quot;Open Sans&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, sans-serif;margin: 32px 0px 16px;color: rgb(15, 17, 21);letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;&quot; class=&quot;js_darkmode__179 js_darkmode__text__1046&quot;&gt;&lt;span class=&quot;js_darkmode__text__1047&quot;&gt;&lt;span class=&quot;js_darkmode__text__1048&quot;&gt;典型配置模板（生产就绪）&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;p&gt;&lt;section style=&quot;text-align: center; margin-bottom: 0px;&quot;&gt;&lt;img class=&quot;rich_pages wxw-img js_insertlocalimg&quot; data-aistatus=&quot;1&quot; data-imgfileid=&quot;100000664&quot; data-s=&quot;300,640&quot; data-src=&quot;https://mmbiz.qpic.cn/mmbiz_png/Qj7nHlfytbA0cQKlxzPd9ibkn7BUIMicEDe8ShvVfqNtqSZmrjrbs4jj8nShTkXZSjA8uD968R8OFaZkdWarD0XGicg2lQXhdCkItWRfUiaAKsk/640?wx_fmt=png&amp;amp;from=appmsg&amp;amp;watermark=1#imgIndex=8&quot; data-type=&quot;png&quot; type=&quot;block&quot; data-original-style=&quot;null&quot; data-index=&quot;8&quot; data-ratio=&quot;0.8586839266450917&quot; data-w=&quot;927&quot; src=&quot;https://mmbiz.qpic.cn/mmbiz_png/Qj7nHlfytbA0cQKlxzPd9ibkn7BUIMicEDe8ShvVfqNtqSZmrjrbs4jj8nShTkXZSjA8uD968R8OFaZkdWarD0XGicg2lQXhdCkItWRfUiaAKsk/640?wx_fmt=png&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1&amp;watermark=1#imgIndex=8&quot; _width=&quot;384px&quot; __sec_open_place_holder__=&quot;true&quot; style=&quot;height: auto !important; visibility: visible !important; width: 677px !important;&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780237930819&quot; data-report-img-idx=&quot;8&quot; data-fail=&quot;0&quot;/&gt;&lt;/section&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Sun, 31 May 2026 22:30:45 +0800</pubDate></item><item><title>前端视角下的 C#</title><link>https://www.codepub.top/post/469.html</link><description>&lt;p&gt;刚毕业的时候写了一年多的 C#, 不过那个时候基本都是 CURD ，没什么感触。这篇文章试图再回过头看这个语言，发现虽然 
TypeScript 和 C# 都是出自微软一家，但是技术形态，行为路径，实现方式等各个方面都不一样。所以今天也试图去回答一个核心问题：&lt;strong&gt;为什么前端和后端在解决相似问题时，会演化出如此不一样的技术形态？&lt;/strong&gt; &amp;nbsp;我试图从类型、运行时、编译原理、工程设计四个维度展开，不局限在 &amp;quot;C# 有强类型，JS 是弱类型&amp;quot; 这种表面判断，而是深入到底层实现去看：&lt;strong&gt;是怎么样的设计决策导致了这些差异？这些差异在不同场景下意味着什么？我们如何在这种异质性中找到最优解？&lt;/strong&gt;&lt;/p&gt;&lt;hr/&gt;&lt;div style=&quot;text-align:right;&quot;&gt;&lt;a rel=&quot;nofollow noopener&quot; href=&quot;https://www.cnblogs.com/wjszxli/p/20206652#_labelTop&quot; style=&quot;color:#f68a33&quot;&gt;回到顶部&lt;/a&gt;&lt;a rel=&quot;nofollow noopener&quot; name=&quot;_label0&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;h2 id=&quot;一类型系统-从-typescript-到-c&quot;&gt;一、类型系统 ——从 TypeScript 到 C#&lt;/h2&gt;&lt;p&gt;&lt;a rel=&quot;nofollow noopener&quot; name=&quot;_label0_0&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;h3 id=&quot;11-结构类型-vs-名义类型两种类型系统的不同&quot;&gt;1.1 结构类型 vs 名义类型：两种类型系统的不同&lt;/h3&gt;&lt;p&gt;TypeScript 经常被前端称为&amp;quot;给 JavaScript 加了类型&amp;quot;，这种表述本身就是带有误导性的。TypeScript 的类型系统是&lt;strong&gt;结构化的（Structural）&lt;/strong&gt; ——类型兼容性由成员结构决定，而不是类型声明。这种设计也不是偶然，而是对 JavaScript 运行时的妥协。&lt;/p&gt;&lt;pre class=&quot;highlighter-hljs&quot; data-mac-style=&quot;true&quot;&gt;&lt;ul class=&quot;awes-linenumber list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;1&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;2&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;3&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;4&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;5&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;6&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;code class=&quot;highlighter-hljs hljs language-typescript hljs-line-numbers&quot;&gt;&lt;table class=&quot;hljs-ln&quot;&gt;&lt;tbody&gt;&lt;tr class=&quot;firstRow&quot;&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;1&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;// TypeScript 的结构类型系统&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;2&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;interface&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;Point&lt;/span&gt; { &lt;span class=&quot;hljs-attr&quot;&gt;x&lt;/span&gt;: &lt;span class=&quot;hljs-built_in&quot;&gt;number&lt;/span&gt;; &lt;span class=&quot;hljs-attr&quot;&gt;y&lt;/span&gt;: &lt;span class=&quot;hljs-built_in&quot;&gt;number&lt;/span&gt;; }&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;3&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;const&lt;/span&gt; pt = { &lt;span class=&quot;hljs-attr&quot;&gt;x&lt;/span&gt;: &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-attr&quot;&gt;y&lt;/span&gt;: &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;, &lt;span class=&quot;hljs-attr&quot;&gt;z&lt;/span&gt;: &lt;span class=&quot;hljs-number&quot;&gt;3&lt;/span&gt; };&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;4&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;hljs-attr&quot;&gt;p&lt;/span&gt;: &lt;span class=&quot;hljs-title class_&quot;&gt;Point&lt;/span&gt; = pt; &lt;span class=&quot;hljs-comment&quot;&gt;// ✅ 合法：pt 的&amp;quot;结构&amp;quot;满足 Point 的约束&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;5&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;6&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;Check&lt;/span&gt; = { &lt;span class=&quot;hljs-attr&quot;&gt;x&lt;/span&gt;: &lt;span class=&quot;hljs-built_in&quot;&gt;number&lt;/span&gt; } &lt;span class=&quot;hljs-keyword&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;Point&lt;/span&gt; ? &lt;span class=&quot;hljs-literal&quot;&gt;true&lt;/span&gt; : &lt;span class=&quot;hljs-literal&quot;&gt;false&lt;/span&gt;; &lt;span class=&quot;hljs-comment&quot;&gt;// true&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;表面上看，结构类型系统很灵活——&amp;quot;鸭子类型&amp;quot; intuitive 且符合 JavaScript 的动态精神。但是在底层，这体现了一个 javascript 最核心的设计约束：&lt;strong&gt;TypeScript 的类型在编译后完全消失了，运行时没有任何类型信息保留&lt;/strong&gt;。&lt;code&gt;interface Point&lt;/code&gt;&amp;nbsp;在编译后的 JavaScript 中彻底不存在，运行时唯一存在的对象是&amp;nbsp;&lt;code&gt;{ x: 1, y: 2, z: 3 }&lt;/code&gt;。类型检查完全是编译期的静态分析，编译器只是在做 &amp;quot;结构兼容性&amp;quot;。&lt;/p&gt;&lt;p&gt;这也意上着 TypeScript 的类型系统本质上是&amp;nbsp;&lt;strong&gt;一套形式上的验证系统&lt;/strong&gt;，没有在运行时的行为进行约束。它可以证伪，但不能证真。实际代码开发中，一个&amp;nbsp;&lt;code&gt;as any&lt;/code&gt;、一个从 API 返回的 JSON、一个&amp;nbsp;&lt;code&gt;eval()&lt;/code&gt;&amp;nbsp;调用，都可以瞬间打破类型系统的所有保证。&lt;/p&gt;&lt;p&gt;C# 走的是完全不同的方式。&lt;strong&gt;名义类型系统（Nominal Typing）&lt;/strong&gt; 要求类型显式声明继承或实现关系，类型兼容性由名称决定，而不是结构。&lt;/p&gt;&lt;pre class=&quot;highlighter-hljs&quot; data-mac-style=&quot;true&quot;&gt;&lt;ul class=&quot;awes-linenumber list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;1&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;2&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;3&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;4&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;5&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;6&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;7&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;8&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;9&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;code class=&quot;highlighter-hljs hljs language-csharp hljs-line-numbers&quot;&gt;&lt;table class=&quot;hljs-ln&quot;&gt;&lt;tbody&gt;&lt;tr class=&quot;firstRow&quot;&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;1&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;// C# 的名义类型系统&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;2&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;Point&lt;/span&gt; { &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt; X { &lt;span class=&quot;hljs-keyword&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;hljs-keyword&quot;&gt;set&lt;/span&gt;; } &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt; Y { &lt;span class=&quot;hljs-keyword&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;hljs-keyword&quot;&gt;set&lt;/span&gt;; } }&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;3&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; pt = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; { X = &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, Y = &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;, Z = &lt;span class=&quot;hljs-number&quot;&gt;3&lt;/span&gt; };&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;4&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;// Point p = pt; // ❌ CS0029：无法从匿名类型隐式转换为 Point&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;5&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;6&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;// 即便结构完全一致，也必须显式建立关系&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;7&quot;&gt;&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;record&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;PointDto&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;&lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt; X, &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt; Y&lt;/span&gt;)&lt;/span&gt;;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;8&quot;&gt;&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;record&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;Point&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;&lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt; X, &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt; Y&lt;/span&gt;)&lt;/span&gt;;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;9&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;// Point p = new PointDto(1, 2); // ❌ 不兼容，尽管字段完全相同&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;这种&amp;quot;死板&amp;quot;背后有一个深刻的工程考虑：&lt;strong&gt;类型不只是编译期的检查工具，更是运行时的身份标识&lt;/strong&gt;。在 CLR 中，每一个对象的头（Object Header）都包含一个指向 Method Table（方法表）的指针，而这个 Method Table 的唯一标识就是类型的完全限定名。运行时反射、多态分派、泛型实例化，全都依赖这个名义类型的身份系统。&lt;/p&gt;&lt;p&gt;&lt;strong&gt;从类型理论的角度看，这是两种类型观念的冲突&lt;/strong&gt;：&lt;/p&gt;&lt;ul class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;结构类型系统&lt;/strong&gt;基于&lt;strong&gt;类型即约束&lt;/strong&gt;（Types as Constraints）——类型是一组属性的集合，任何满足约束的值都是该类型的 inhabitant。&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;名义类型系统&lt;/strong&gt;基于&lt;strong&gt;类型即身份&lt;/strong&gt;（Types as Identity）——类型是一种契约声明，你必须显式签署契约才能获得身份。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;前端为什么演化出结构类型？因为浏览器环境的极端不确定性：API 返回的数据结构可能在版本迭代中增减字段，第三方库的接口定义可能与我们预期不完全一致，polyfill 可能给原型链注入额外方法。在这种环境下，结构类型的&amp;quot;容错性&amp;quot;是生存优势。&lt;/p&gt;&lt;p&gt;但代价是什么？&lt;strong&gt;类型安全的幻觉&lt;/strong&gt;。当我们习惯于&amp;nbsp;&lt;code&gt;const user: User = await fetchUser()&lt;/code&gt;&amp;nbsp;这样的代码时，我们实际上是在做一个未经证明的假设：API 返回的 JSON 结构一定符合&amp;nbsp;&lt;code&gt;User&lt;/code&gt;&amp;nbsp;接口的定义。没有任何运行时机制保证这一点。TypeScript 的类型系统在 API 边界上是完全失效的——这也是在为什么运行时的校验库 Zod、Yup、io-ts 能流行起来的原因。&lt;/p&gt;&lt;p&gt;C# 的名义类型系统在 API 边界上同样面临反序列化问题（JSON 字符串不会自带 CLR 类型信息），但 C# 有&amp;nbsp;&lt;strong&gt;编译期泛型具体化&lt;/strong&gt;&amp;nbsp;作为补偿。写&amp;nbsp;&lt;code&gt;List&amp;lt;int&amp;gt;&lt;/code&gt;&amp;nbsp;和&amp;nbsp;&lt;code&gt;List&amp;lt;string&amp;gt;&lt;/code&gt;&amp;nbsp;时，CLR 在运行时维护着两个完全不同的类型实例——&lt;code&gt;List&amp;#39;1[System.Int32]&lt;/code&gt;&amp;nbsp;和&amp;nbsp;&lt;code&gt;List&amp;#39;1[System.String]&lt;/code&gt;。这让 .NET 的泛型具有运行时可辨识性，使得依赖类型信息进行的分派、反射、优化成为可能。TypeScript 的泛型在编译后全部擦除，&lt;code&gt;Array&amp;lt;number&amp;gt;&lt;/code&gt;&amp;nbsp;和&amp;nbsp;&lt;code&gt;Array&amp;lt;string&amp;gt;&lt;/code&gt;&amp;nbsp;在运行时都是同一个 JavaScript Array 构造器——类型信息彻底湮灭。&lt;/p&gt;&lt;p&gt;&lt;a rel=&quot;nofollow noopener&quot; name=&quot;_label0_1&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;h3 id=&quot;12-值类型与引用类型内存布局的第一次冲击&quot;&gt;1.2 值类型与引用类型：内存布局的第一次冲击&lt;/h3&gt;&lt;p&gt;JavaScript 
的内存模型对前端几乎是透明的。我们说&amp;quot;对象是引用传递&amp;quot;，说&amp;quot;基本类型是值传递&amp;quot;，但是除了在面试中，写代码时候我们其实很少会考虑这些问题：引用是什么？存在哪里？堆和栈的边界在哪里？V8
 的隐藏类（Hidden Class）如何影响对象的内存布局？&lt;/p&gt;&lt;p&gt;但是在写 C# 时，写代码就需要直面这些问题，因为&amp;nbsp;&lt;strong&gt;值类型（Value Types）和引用类型（Reference Types）的区别是 CLR 内存模型的核心&lt;/strong&gt;，它直接影响性能、GC 压力、和并发安全。&lt;/p&gt;&lt;pre class=&quot;highlighter-hljs&quot; data-mac-style=&quot;true&quot;&gt;&lt;ul class=&quot;awes-linenumber list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;1&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;2&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;3&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;4&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;5&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;6&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;7&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;8&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;9&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;10&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;11&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;12&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;13&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;code class=&quot;highlighter-hljs hljs language-csharp hljs-line-numbers&quot;&gt;&lt;table class=&quot;hljs-ln&quot;&gt;&lt;tbody&gt;&lt;tr class=&quot;firstRow&quot;&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;1&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;// 值类型：分配在栈上（或内联在包含类型中）&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;2&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;struct&lt;/span&gt; Point2D&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;3&quot;&gt;{&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;4&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt; X;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;5&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt; Y;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;6&quot;&gt;}&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;7&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;8&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;// 引用类型：分配在托管堆上，变量保存的是引用指针&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;9&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;Person&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;10&quot;&gt;{&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;11&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;string&lt;/span&gt; Name;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;12&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt; Age;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;13&quot;&gt;}&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;当一个&amp;nbsp;&lt;code&gt;Point2D&lt;/code&gt;&amp;nbsp;实例被创建时，如果它是局部变量，CLR 会在当前线程的栈帧上直接分配 8 个字节（两个&amp;nbsp;&lt;code&gt;int&lt;/code&gt;）的连续内存。&lt;strong&gt;没有堆分配，没有 GC 压力，没有引用指针的间接寻址开销&lt;/strong&gt;。当它作为类的字段时，内存直接内联（inline）在对象的堆内存布局中。当你将一个&amp;nbsp;&lt;code&gt;Point2D&lt;/code&gt;&amp;nbsp;赋值给另一个变量时，发生的是&lt;strong&gt;内存按位复制（bitwise copy）&lt;/strong&gt; ——8 个字节直接拷贝。&lt;/p&gt;&lt;p&gt;相反，&lt;code&gt;new Person()&lt;/code&gt;&amp;nbsp;会在托管堆上分配内存，返回一个引用地址。赋值操作只复制引用地址（4 或 8 字节），两个变量指向同一块堆内存。&lt;/p&gt;&lt;p&gt;这对前端意味着什么？在 JavaScript 中，所有对象都在堆上分配，V8 的年轻代 
GC（Scavenger）必须以极高的频率回收短生命周期对象。React 的每次 render 都需要创建新对象字面量、Redux 的 
immutable update 创建新状态树——这些在前端会被视为 &amp;quot;可接受&amp;quot; 的模式，毕竟在浏览器中，最差的结果就是刷新一下页面。但是在 
CLR 的视角下可能是&amp;quot;GC 压力炸弹&amp;quot;。&lt;/p&gt;&lt;p&gt;C# 引入值类型，本质上是对&lt;strong&gt;内存局部性&lt;/strong&gt;的极致追求。在实际的场景中，一个&amp;nbsp;&lt;code&gt;Point2D[]&lt;/code&gt;&amp;nbsp;数组在内存中是 8 * N 字节的连续块，CPU 缓存预取可以完美工作。而在 JavaScript 中，&lt;code&gt;[{x:1,y:2}, {x:3,y:4}]&lt;/code&gt;&amp;nbsp;是一个指针数组，每个元素指向堆上的独立对象，内存访问模式是跳跃式的（pointer chasing），CPU 缓存命中率低得多。&lt;/p&gt;&lt;p&gt;&lt;strong&gt;.NET 7+ 引入的&amp;nbsp;&lt;code&gt;ref struct&lt;/code&gt;&amp;nbsp;更是把这一思想推到了极致&lt;/strong&gt;：&lt;/p&gt;&lt;pre class=&quot;highlighter-hljs&quot; data-mac-style=&quot;true&quot;&gt;12345public&amp;nbsp;ref&amp;nbsp;struct&amp;nbsp;Span&amp;lt;T&amp;gt;{//&amp;nbsp;只能在栈上分配，不能装箱，不能作为类的字段，不能闭包捕获//&amp;nbsp;直接表示一段连续内存的视图，零拷贝}&lt;/pre&gt;&lt;p&gt;&lt;code&gt;Span&amp;lt;T&amp;gt;&lt;/code&gt;&amp;nbsp;是 C# 对&lt;strong&gt;内存安全与零拷贝抽象&lt;/strong&gt;的精妙解答。它让你可以切片数组、操作栈内存、甚至安全地操作非托管内存，同时编译器保证它永远不会逃逸到堆上——这是
 Rust 的所有权系统在 C# 中的部分体现。前端没有对应物，因为 JavaScript 
不提供对内存布局的细粒度控制，其实如果只是做网页应用，应该也不需要。&lt;/p&gt;&lt;p&gt;&lt;a rel=&quot;nofollow noopener&quot; name=&quot;_label0_2&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;h3 id=&quot;13-泛型的两种命运擦除-vs-具体化&quot;&gt;1.3 泛型的两种命运：擦除 vs 具体化&lt;/h3&gt;&lt;p&gt;TypeScript 的泛型是图灵完备的——你可以用它做条件类型、模板字面量类型、甚至递归类型体操。但这种强大是一种&amp;nbsp;&lt;strong&gt;元编程层面的强大&lt;/strong&gt;，不是运行时层面的强大。&lt;/p&gt;&lt;pre class=&quot;highlighter-hljs&quot; data-mac-style=&quot;true&quot;&gt;12345//&amp;nbsp;TypeScript：泛型在编译后完全消失function&amp;nbsp;identity&amp;lt;T&amp;gt;(arg:&amp;nbsp;T):&amp;nbsp;T&amp;nbsp;{&amp;nbsp;return&amp;nbsp;arg;&amp;nbsp;}const&amp;nbsp;a&amp;nbsp;=&amp;nbsp;identity&amp;lt;number&amp;gt;(42);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;编译后：const&amp;nbsp;a&amp;nbsp;=&amp;nbsp;42const&amp;nbsp;b&amp;nbsp;=&amp;nbsp;identity&amp;lt;string&amp;gt;(&amp;quot;hello&amp;quot;);&amp;nbsp;//&amp;nbsp;编译后：const&amp;nbsp;b&amp;nbsp;=&amp;nbsp;&amp;quot;hello&amp;quot;//&amp;nbsp;T&amp;nbsp;在哪里？已经不存在了。&lt;/pre&gt;&lt;p&gt;TypeScript 编译器做泛型推导、类型展开、条件分支求解——这一切发生在编译期，生成的是没有任何类型信息的纯 JavaScript。这种设计称为&amp;nbsp;&lt;strong&gt;类型擦除&lt;/strong&gt;，它的好处是零运行时开销，代价是运行时无法区分&amp;nbsp;&lt;code&gt;Container&amp;lt;number&amp;gt;&lt;/code&gt;&amp;nbsp;和&amp;nbsp;&lt;code&gt;Container&amp;lt;string&amp;gt;&lt;/code&gt;。&lt;/p&gt;&lt;p&gt;C# 的泛型设计做出了截然不同的权衡——&lt;strong&gt;具体化泛型（Reified Generics）&lt;/strong&gt; 。&lt;/p&gt;&lt;pre class=&quot;highlighter-hljs&quot; data-mac-style=&quot;true&quot;&gt;&lt;ul class=&quot;awes-linenumber list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;1&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;2&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;3&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;4&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;5&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;6&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;7&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;8&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;9&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;10&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;11&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;12&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;13&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;14&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;15&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;code class=&quot;highlighter-hljs hljs language-csharp hljs-line-numbers&quot;&gt;&lt;table class=&quot;hljs-ln&quot;&gt;&lt;tbody&gt;&lt;tr class=&quot;firstRow&quot;&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;1&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;// C#：JIT 为每个值类型泛型参数生成专用机器码&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;2&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;Container&lt;/span&gt;&amp;lt;&lt;span class=&quot;hljs-title&quot;&gt;T&lt;/span&gt;&amp;gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;3&quot;&gt;{&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;4&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; T Value;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;5&quot;&gt;&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;PrintType&lt;/span&gt;()&lt;/span&gt; =&amp;gt; Console.WriteLine(&lt;span class=&quot;hljs-keyword&quot;&gt;typeof&lt;/span&gt;(T));&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;6&quot;&gt;}&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;7&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;8&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; intContainer = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; Container&amp;lt;&lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt;&amp;gt;();&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;9&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; stringContainer = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; Container&amp;lt;&lt;span class=&quot;hljs-built_in&quot;&gt;string&lt;/span&gt;&amp;gt;();&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;10&quot;&gt;intContainer.PrintType(); &amp;nbsp; &amp;nbsp;&lt;span class=&quot;hljs-comment&quot;&gt;// System.Int32&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;11&quot;&gt;stringContainer.PrintType(); &lt;span class=&quot;hljs-comment&quot;&gt;// System.String&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;12&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;13&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;// JIT 会为 Container&amp;lt;int&amp;gt; 和 Container&amp;lt;string&amp;gt; 生成不同的机器码&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;14&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;// Container&amp;lt;int&amp;gt;.Value 是内联的 4 字节整数字段&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;15&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;// Container&amp;lt;string&amp;gt;.Value 是 4/8 字节的引用指针&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;在 CLR 中，当你实例化&amp;nbsp;&lt;code&gt;Container&amp;lt;int&amp;gt;&lt;/code&gt;&amp;nbsp;时，JIT 编译器会为这个&amp;nbsp;&lt;strong&gt;具体类型组合&lt;/strong&gt;&amp;nbsp;生成本地机器码。&lt;code&gt;Container&amp;lt;int&amp;gt;&lt;/code&gt;&amp;nbsp;和&amp;nbsp;&lt;code&gt;Container&amp;lt;string&amp;gt;&lt;/code&gt;&amp;nbsp;在运行时是&lt;strong&gt;两个不同的类型&lt;/strong&gt;，各自有独立的 Method Table、独立的 JIT 编译缓存、甚至独立的代码优化路径。对于值类型参数（如&amp;nbsp;&lt;code&gt;int&lt;/code&gt;、&lt;code&gt;double&lt;/code&gt;、&lt;code&gt;Point2D&lt;/code&gt;），JIT 会执行&amp;nbsp;&lt;strong&gt;代码特化（Code Specialization）&lt;/strong&gt; ，将泛型方法中的&amp;nbsp;&lt;code&gt;T&lt;/code&gt;&amp;nbsp;直接替换为具体的值类型，消除装箱和类型检查的开销。&lt;/p&gt;&lt;p&gt;这就是 C# 所说的&lt;strong&gt;零成本抽象（Zero-Cost Abstractions）&lt;/strong&gt; ——泛型的使用不会带来运行时性能损失。对比 JavaScript/TypeScript，我们在写一个处理数字数组的通用函数时，所有元素都是装箱的
 JavaScript 对象（或至少是经过标签指针表示的），没有内联、没有特化、没有 SIMD 向量化优化的可能。&lt;/p&gt;&lt;p&gt;&lt;strong&gt;但 C# 的泛型也有边界&lt;/strong&gt;。CLR 对泛型约束有严格限制——你不能写&amp;nbsp;&lt;code&gt;where T : has static Method()&lt;/code&gt;（C# 11 前的静态接口成员约束缺失）、不能对泛型参数做算术运算（&lt;code&gt;T a, T b; var c = a + b; // 除非 T : INumber&amp;lt;T&amp;gt;&lt;/code&gt;，.NET 7+ 泛型数学才解决这一问题）。TypeScript 的类型系统在这方面反而更灵活，因为类型体操发生在编译期，不受运行时类型系统的约束。&lt;/p&gt;&lt;p&gt;&lt;strong&gt;在 这里其实我们能发现&lt;/strong&gt;：TypeScript 的类型系统和 C# 的类型系统服务于不同的工程目标。TypeScript 追求&amp;nbsp;&lt;strong&gt;编译期的表达能力最大化&lt;/strong&gt;——它允许我们在编码极其复杂的类型逻辑，因为它知道这些逻辑不需要在运行时兑现。C# 追求的是&amp;nbsp;&lt;strong&gt;编译期和运行时的统一&lt;/strong&gt;&amp;nbsp;——类型系统的设计必须能被 CLR 高效地实现，泛型约束必须能被 JIT 编译成优化的机器码。&lt;/p&gt;&lt;p&gt;&lt;a rel=&quot;nofollow noopener&quot; name=&quot;_label0_3&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;h3 id=&quot;14-asyncawait-的同形异构语法糖下面的两种世界&quot;&gt;1.4 async/await 的&amp;quot;同形异构&amp;quot;：语法糖下面的两种世界&lt;/h3&gt;&lt;p&gt;前端的 TypeScript 和后端的 C# 都拥抱了&amp;nbsp;&lt;code&gt;async/await&lt;/code&gt;，以至于很多开发都认为这是 &amp;quot;相同的东西&amp;quot;。&lt;strong&gt;这种认知是错误的，并且这种错误在高并发场景下可能是致命的。&lt;/strong&gt;&lt;/p&gt;&lt;pre class=&quot;highlighter-hljs&quot; data-mac-style=&quot;true&quot;&gt;1234567//&amp;nbsp;JavaScript：async/await&amp;nbsp;的编译产物（简化）async&amp;nbsp;function&amp;nbsp;fetchUser(id)&amp;nbsp;{const&amp;nbsp;res&amp;nbsp;=&amp;nbsp;await&amp;nbsp;fetch(`/api/users/${id}`);return&amp;nbsp;res.json();}//&amp;nbsp;本质上由&amp;nbsp;V8&amp;nbsp;的&amp;nbsp;async/await&amp;nbsp;desugaring&amp;nbsp;转换为：//&amp;nbsp;一个生成器函数&amp;nbsp;+&amp;nbsp;Promise&amp;nbsp;链&amp;nbsp;+&amp;nbsp;微任务调度&lt;/pre&gt;&lt;p&gt;JavaScript 的&amp;nbsp;&lt;code&gt;await&lt;/code&gt;&amp;nbsp;关键字背后，是 V8 引擎将 async 函数转换为一个状态机，通过&amp;nbsp;&lt;code&gt;Promise.then()&lt;/code&gt;&amp;nbsp;和微任务队列（microtask queue）实现异步恢复。这里的关键是：&lt;strong&gt;自始至终只有一个线程在执行你的代码&lt;/strong&gt;——JavaScript 的主线程（Main Thread）。&lt;code&gt;await&lt;/code&gt;&amp;nbsp;只是让出了主线程的执行权，让 Event Loop 可以处理其他事件（用户输入、定时器、其他 Promise 回调）。当 I/O 完成后，一个微任务被排入队列，等待当前调用栈清空后执行。&lt;/p&gt;&lt;p&gt;这意味着在 JavaScript 中，&lt;strong&gt;async 函数的真正并发度为 1&lt;/strong&gt;。你同时发起 1000 个&amp;nbsp;&lt;code&gt;fetch()&lt;/code&gt;&amp;nbsp;请求，V8
 会在底层维持 1000 个网络 I/O 句柄（通过 libuv 或操作系统的异步 I/O 机制），但 JavaScript 
代码的执行始终是串行的。这也解释了为什么 CPU 密集型任务会阻塞整个 Node.js 应用——主线程被计算占用了，Event Loop 
无法推进。&lt;/p&gt;&lt;pre class=&quot;highlighter-hljs&quot; data-mac-style=&quot;true&quot;&gt;12345678//&amp;nbsp;C#：async/await&amp;nbsp;的编译产物（由&amp;nbsp;Roslyn&amp;nbsp;编译器生成）public&amp;nbsp;async&amp;nbsp;Task&amp;lt;User&amp;gt;&amp;nbsp;GetUserAsync(int&amp;nbsp;id){var&amp;nbsp;user&amp;nbsp;=&amp;nbsp;await&amp;nbsp;_dbContext.Users.FindAsync(id);return&amp;nbsp;user;}//&amp;nbsp;Roslyn&amp;nbsp;编译器生成一个实现了&amp;nbsp;IAsyncStateMachine&amp;nbsp;接口的状态机结构体//&amp;nbsp;状态机被传递给&amp;nbsp;TaskAwaiter，I/O&amp;nbsp;完成后由&amp;nbsp;ThreadPool&amp;nbsp;调度恢复&lt;/pre&gt;&lt;p&gt;C# 的&amp;nbsp;&lt;code&gt;async/await&lt;/code&gt;&amp;nbsp;机制远比 JavaScript 复杂。Roslyn 编译器将 async 方法转换为一个&amp;nbsp;&amp;nbsp;&lt;strong&gt;实现了&amp;nbsp;&lt;code&gt;IAsyncStateMachine&lt;/code&gt;&amp;nbsp;接口的结构体&lt;/strong&gt;，包含：&lt;/p&gt;&lt;ol class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;状态字段&lt;/strong&gt;（int）：标记当前执行到哪个&amp;nbsp;&lt;code&gt;await&lt;/code&gt;&amp;nbsp;点&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;异步方法构建器&lt;/strong&gt;（&lt;code&gt;AsyncTaskMethodBuilder&amp;lt;T&amp;gt;&lt;/code&gt;）：负责创建和完成 Task&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;局部变量提升&lt;/strong&gt;：所有 await 点之间需要保持的局部变量被提升为状态机字段&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;MoveNext 方法&lt;/strong&gt;：状态机的核心逻辑，每次 I/O 完成后由 Thread Pool 调用&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;当你执行&amp;nbsp;&lt;code&gt;await someTask&lt;/code&gt;&amp;nbsp;时，C# 运行时会：&lt;/p&gt;&lt;ol class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;检查任务是否已完成——如果已完成，同步继续执行（避免不必要的上下文切换）&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;如果未完成，将当前状态机注册为该任务的 continuation&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;当前线程被释放回线程池&lt;/strong&gt;，可以去执行其他工作&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;当任务完成时，线程池中的一个（可能是另一个）线程取出状态机，调用&amp;nbsp;&lt;code&gt;MoveNext&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;这里的根本差异是：&lt;strong&gt;JavaScript 的 await 释放的是主线程的&amp;quot;执行权&amp;quot;，但代码始终在同一线程上运行；C# 的 await 释放的是真正的操作系统线程，恢复时可能在完全不同的线程上执行。&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;这引出了一个 C# 特有的陷阱——&lt;strong&gt;线程亲和性（Thread Affinity）&lt;/strong&gt; &amp;nbsp;问题。在 JavaScript 中，你完全不需要考虑&amp;quot;这段代码在哪个线程运行&amp;quot;，因为只有一个线程。在 C# 中，&lt;code&gt;await&lt;/code&gt;&amp;nbsp;前后的代码可能运行在不同线程上，这意味着线程局部存储（TLS）、某些 UI 框架的单线程要求（如 WPF 的 Dispatcher）、以及对特定线程有依赖的资源（如数据库连接的线程亲和性）都需要特别注意。&lt;code&gt;ConfigureAwait(false)&lt;/code&gt;&amp;nbsp;的存在就是为了解决这个问题——显式告知运行时不需要回到原来的同步上下文。&lt;/p&gt;&lt;p&gt;这样的设计也就导致了&amp;nbsp;&lt;strong&gt;C# 中滥用 async/await 的代价是真实的&lt;/strong&gt;。每一个 async 方法都有状态机分配的开销（虽然是结构体，通常分配在栈上，但闭包捕获会强制装箱到堆上）。不必要的&amp;nbsp;&lt;code&gt;Task&lt;/code&gt;&amp;nbsp;对象创建、不必要的线程上下文切换、以及在热路径（hot path）中滥用异步——这些都是 Node.js 开发者不会遇到的性能陷阱。&lt;/p&gt;&lt;p&gt;&lt;strong&gt;进一步来看&lt;/strong&gt;：JavaScript 的 Event Loop 并发模型是一种&lt;strong&gt;协作式多任务（Cooperative Multitasking）&lt;/strong&gt; ——代码显式让出控制权（通过 await 或 yield）。C# 的 Thread Pool 模型更接近&lt;strong&gt;抢占式多任务（Preemptive Multitasking）&lt;/strong&gt;
 ——操作系统调度器在线程间切换，代码不需要显式配合。协作式模型简单且没有竞态条件（因为并发度为 1），但无法利用多核 
CPU。抢占式模型可以利用全部 CPU 核心，但需要锁、信号量、原子操作等同步原语来避免数据竞争。这也是前端在与后端对技术方案时， 
最大的认知冲击往往不是语法，而是对锁、信号量、原子操作等概念的理解、——在 JavaScript 中不可能发生的数据竞争，在 C# 
中是默认可能发生的。&lt;/p&gt;&lt;hr/&gt;&lt;div style=&quot;text-align:right;&quot;&gt;&lt;a rel=&quot;nofollow noopener&quot; href=&quot;https://www.cnblogs.com/wjszxli/p/20206652#_labelTop&quot; style=&quot;color:#f68a33&quot;&gt;回到顶部&lt;/a&gt;&lt;a rel=&quot;nofollow noopener&quot; name=&quot;_label1&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;h2 id=&quot;二为什么前端是板块运动c-是大陆漂移&quot;&gt;二、为什么前端是板块运动，C# 是大陆漂移&lt;/h2&gt;&lt;p&gt;&lt;a rel=&quot;nofollow noopener&quot; name=&quot;_label1_0&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;h3 id=&quot;21-npm-的语义化版本陷阱一个不可判定问题&quot;&gt;2.1 npm 的语义化版本陷阱：一个不可判定问题&lt;/h3&gt;&lt;p&gt;前端与依赖管理的搏斗，本质上可以理解成是在与&amp;nbsp;&lt;strong&gt;语义化版本（SemVer）的数学不完备性&lt;/strong&gt;&amp;nbsp;搏斗。&lt;/p&gt;&lt;p&gt;在设计上&amp;nbsp;&lt;code&gt;MAJOR.MINOR.PATCH&lt;/code&gt;&amp;nbsp;分别代表不兼容变更、向后兼容的功能添加、Bug 修复。理论上，&lt;code&gt;^1.2.3&lt;/code&gt;&amp;nbsp;允许&amp;nbsp;&lt;code&gt;1.x.x&lt;/code&gt;但不允许&amp;nbsp;&lt;code&gt;2.0.0&lt;/code&gt;&amp;nbsp;是安全的。但这个承诺在数学上是不可兑现的。&lt;/p&gt;&lt;p&gt;&lt;strong&gt;但在实际过程中：&amp;quot;向后兼容&amp;quot; 是不可判定的。&lt;/strong&gt; &amp;nbsp;我们在实际编码中没办法通过程序自动验证一个库的&amp;nbsp;&lt;code&gt;1.3.0&lt;/code&gt;&amp;nbsp;版本是否真的对&amp;nbsp;&lt;code&gt;1.2.0&lt;/code&gt;&amp;nbsp;的所有使用方式向后兼容。不可判定性也就意味着，判断&amp;quot;这个变更是否会破坏下游用户的代码&amp;quot;是一个不可计算问题。这也解释了为什么有的时候我们开发时，只是在本地 &amp;quot;升级一个小版本但是在服务器编译打包时就报错&amp;quot; 是常态。&lt;/p&gt;&lt;p&gt;npm 的依赖解析算法采用了一个简化的 SAT 求解器，试图在复杂的依赖图中找到一个满足所有版本约束的解。但 npm 的扁平化（flat）依赖结构（v3+）引入了一个更深层的问题：&lt;strong&gt;依赖去重与版本冲突的不可调和矛盾&lt;/strong&gt;。&lt;/p&gt;&lt;pre class=&quot;highlighter-hljs&quot; data-mac-style=&quot;true&quot;&gt;&lt;ul class=&quot;awes-linenumber list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;1&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;2&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;3&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;4&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;5&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;6&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;7&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;8&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;9&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;10&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;11&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;code class=&quot;highlighter-hljs hljs language-kotlin hljs-line-numbers&quot;&gt;&lt;table class=&quot;hljs-ln&quot;&gt;&lt;tbody&gt;&lt;tr class=&quot;firstRow&quot;&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;1&quot;&gt;我们的项目&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;2&quot;&gt;├── &lt;span class=&quot;hljs-symbol&quot;&gt;react@&lt;/span&gt;&lt;span class=&quot;hljs-number&quot;&gt;18.2&lt;/span&gt;&lt;span class=&quot;hljs-number&quot;&gt;.0&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;3&quot;&gt;├── some-ui-&lt;span class=&quot;hljs-symbol&quot;&gt;lib@&lt;/span&gt;&lt;span class=&quot;hljs-number&quot;&gt;1.0&lt;/span&gt;&lt;span class=&quot;hljs-number&quot;&gt;.0&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;4&quot;&gt;│ &amp;nbsp; └── &lt;span class=&quot;hljs-symbol&quot;&gt;react@&lt;/span&gt;^&lt;span class=&quot;hljs-number&quot;&gt;17.0&lt;/span&gt;&lt;span class=&quot;hljs-number&quot;&gt;.0&lt;/span&gt; &amp;nbsp;← 期望 React &lt;span class=&quot;hljs-number&quot;&gt;17&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;5&quot;&gt;└── another-&lt;span class=&quot;hljs-symbol&quot;&gt;lib@&lt;/span&gt;&lt;span class=&quot;hljs-number&quot;&gt;2.0&lt;/span&gt;&lt;span class=&quot;hljs-number&quot;&gt;.0&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;6&quot;&gt;└── &lt;span class=&quot;hljs-symbol&quot;&gt;react@&lt;/span&gt;^&lt;span class=&quot;hljs-number&quot;&gt;18.0&lt;/span&gt;&lt;span class=&quot;hljs-number&quot;&gt;.0&lt;/span&gt; &amp;nbsp;← 期望 React &lt;span class=&quot;hljs-number&quot;&gt;18&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;7&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;8&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;// npm 的解决方案：&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;9&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;// node_modules/react@18.2.0 (顶层)&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;10&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;// node_modules/some-ui-lib/node_modules/react@17.0.2 (嵌套)&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;11&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;// 运行时同一个应用加载了两个 React 版本 → _hooks 规则被破坏 → 运行时崩溃_&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;这种&amp;quot;同一库的多个版本共存&amp;quot;在前端是致命的，因为 React 
等库使用全局单例模式（通过模块级别的变量），两个版本会互相干扰。Node.js 的 CommonJS/ESM 模块系统 + npm 的嵌套 
node_modules 结构，使得这种版本冲突无法被静态分析提前发现。&lt;/p&gt;&lt;p&gt;C#/.NET 的 NuGet 采用了一种更保守但更可靠的策略。&lt;strong&gt;NuGet 的依赖解析是严格的传递闭包计算&lt;/strong&gt;，且 .NET 的强命名程序集（Strong-Named Assemblies）和全局程序集缓存（GAC，.NET Core 后弱化为共享框架）机制，使得同一程序集的多个版本可以通过&lt;strong&gt;绑定重定向（Binding Redirects）&lt;/strong&gt; 被显式管理。&lt;/p&gt;&lt;p&gt;更重要的是，.NET 生态对&lt;strong&gt;向后兼容性的承诺是工程化的、可测试的&lt;/strong&gt;。微软维护着庞大的 API 
兼容性测试套件，每一个新版本的 .NET SDK 都必须通过 API Compat 工具验证：公开的 API 
签名是否被意外修改？行为变更是否在可接受范围内？这种&amp;quot;平台级供应商&amp;quot;的治理模式，与 npm 生态的去中心化、无人治理形成了鲜明对比。&lt;/p&gt;&lt;p&gt;&lt;strong&gt;但这里有一个更深层的不一样&lt;/strong&gt;：&lt;/p&gt;&lt;p&gt;前端生态的&amp;quot;碎片化&amp;quot;是&amp;nbsp;&lt;strong&gt;刻意的设计&lt;/strong&gt;。JavaScript 没有标准库的主导者（虽然 Node.js 
内置模块和 WinterTC 在尝试），任何人都可以发布包、任何人都可以 fork 
现有库。这种去中心化带来了相当快的创新速度——React、Vue、Svelte 三大框架的竞争推动了组件化范式的快速进化，Vite 对 
Webpack 的颠覆仅用了两年时间。&lt;/p&gt;&lt;p&gt;.NET 生态的&amp;quot;统一性&amp;quot;也是&amp;nbsp;&lt;strong&gt;刻意的设计&lt;/strong&gt;。微软作为单一供应商控制语言规范（ECMA-334）、运行时（CLR）、标准库（BCL）、主要 IDE（Visual Studio/Rider）、云平台（Azure）。这种&amp;quot;垂直整合&amp;quot;确保了生态的一致性，但也意味着创新主要由微软的产品路线图驱动。&lt;/p&gt;&lt;p&gt;&lt;a rel=&quot;nofollow noopener&quot; name=&quot;_label1_1&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;h3 id=&quot;22-构建管线的发展&quot;&gt;2.2 构建管线的发展&lt;/h3&gt;&lt;p&gt;前端构建工具的演进史，是一部复杂度指数增长的灾难片。&lt;/p&gt;&lt;p&gt;2012 年，我们只需要一个&amp;nbsp;&lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt;&amp;nbsp;标签。2014 年，Webpack 
用配置地狱换来了模块打包。2016 年，Babel 让我们能用新的的语法写代码。2018 
年，PostCSS、ESLint、Prettier、Jest 各自成为独立工具，前端项目需要维护 5+ 个配置文件。2020 年，Vite 
用原生 ESM 和 esbuild 虽然做到了兼容冰雹，但我们依然需要处理 SSR、SSG、Edge Runtime 等场景的构建差异。&lt;/p&gt;&lt;p&gt;这个复杂度的根本来源是&amp;nbsp;&lt;strong&gt;前端平台（浏览器）与开发语言（JavaScript）的脱节&lt;/strong&gt;。浏览器支持的 JavaScript 特性永远落后于 TC39 的标准化进程，CSS 的模块化没有原生解决方案，静态资源的处理（图片压缩、CSS 提取、代码分割）没有浏览器原语。前端构建工具本质上是在&amp;nbsp;&lt;strong&gt;用 Node.js 来模拟一个理想的浏览器执行环境&lt;/strong&gt;——这个环境支持最新的语言特性、支持真正的模块化、支持编译期的资源优化。&lt;/p&gt;&lt;pre class=&quot;highlighter-hljs&quot; data-mac-style=&quot;true&quot;&gt;12345678前端构建管线（典型）：源代码&amp;nbsp;(.tsx,&amp;nbsp;.css,&amp;nbsp;.svg)→&amp;nbsp;Vite/Rspack&amp;nbsp;(模块解析&amp;nbsp;+&amp;nbsp;HMR&amp;nbsp;引擎)→&amp;nbsp;esbuild/swc&amp;nbsp;(TypeScript/JSX&amp;nbsp;→&amp;nbsp;JavaScript&amp;nbsp;转译)→&amp;nbsp;PostCSS&amp;nbsp;(CSS&amp;nbsp;处理、Tailwind&amp;nbsp;编译)→&amp;nbsp;Rollup&amp;nbsp;(生产环境打包、Tree&amp;nbsp;Shaking)→&amp;nbsp;Terser/SWC&amp;nbsp;Minify&amp;nbsp;(代码压缩)→&amp;nbsp;输出到&amp;nbsp;dist/&lt;/pre&gt;&lt;p&gt;每一步都是一个独立的工具，有独立的配置格式、独立的插件生态、独立的版本周期。前端工程化的 &amp;quot;专业性&amp;quot; 在一定程度上体现在对这些工具链的编排能力上。&lt;/p&gt;&lt;p&gt;C#/.NET 的构建管线则是另一番景象。&lt;/p&gt;&lt;pre class=&quot;highlighter-hljs&quot; data-mac-style=&quot;true&quot;&gt;12345678.NET&amp;nbsp;构建管线：源代码&amp;nbsp;(.cs,&amp;nbsp;.razor,&amp;nbsp;.cshtml)→&amp;nbsp;dotnet&amp;nbsp;build&amp;nbsp;(MSBuild&amp;nbsp;入口)→&amp;nbsp;Roslyn&amp;nbsp;编译器&amp;nbsp;(C#&amp;nbsp;→&amp;nbsp;IL&amp;nbsp;+&amp;nbsp;元数据)→&amp;nbsp;NuGet&amp;nbsp;依赖解析&amp;nbsp;+&amp;nbsp;还原→&amp;nbsp;资源嵌入&amp;nbsp;(嵌入式资源、静态文件)→&amp;nbsp;程序集生成&amp;nbsp;(DLL/EXE&amp;nbsp;+&amp;nbsp;.pdb)→&amp;nbsp;dotnet&amp;nbsp;publish&amp;nbsp;(运行时自包含或框架依赖发布)&lt;/pre&gt;&lt;p&gt;MSBuild 是一个声明式的构建引擎，&lt;code&gt;.csproj&lt;/code&gt;&amp;nbsp;文件本质上是一个 MSBuild 项目文件。关键差异在于：&lt;/p&gt;&lt;ol class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;单一入口&lt;/strong&gt;：&lt;code&gt;dotnet build&lt;/code&gt;&amp;nbsp;调用 MSBuild，MSBuild 调用 Roslyn，Roslyn 调用所有必要的编译步骤。没有前端那种&amp;quot;多个独立工具串联&amp;quot;的复杂性。&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;编译器即中心&lt;/strong&gt;：Roslyn 不仅是一个编译器，还是一个编译平台（Compiler-as-a-Service）。它提供语义分析 API、代码生成 API、诊断分析框架——所有这些都在一个统一的架构下。&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;原生 Hot Reload&lt;/strong&gt;：.NET 6+ 的 Hot Reload 不是通过文件监听和页面刷新实现的，而是 CLR 的&amp;nbsp;&lt;strong&gt;Metadata Update（元数据更新）&lt;/strong&gt; &amp;nbsp;机制——运行时直接替换已加载程序集中的方法体，保留应用程序状态。这比前端 Vite 的 HMR（模块热替换）在速度上会更快，因为它不需要重新执行模块的初始化代码。&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;strong&gt;更深层的对比&lt;/strong&gt;：前端构建工具的复杂度源于&lt;strong&gt;平台碎片化&lt;/strong&gt;。我们需要考虑 4 
种主流浏览器 × 3 个主要版本 × 桌面/移动端 × 不同的网络条件。每一个工具链环节都在试图抽象这种碎片化（Babel 的 
preset-env 决定转译哪些特性，PostCSS 的 autoprefixer 决定添加哪些浏览器前缀）。&lt;/p&gt;&lt;p&gt;.NET 构建工具的简洁性源于&lt;strong&gt;平台统一性&lt;/strong&gt;。你编译的目标框架是明确的（&lt;code&gt;net8.0&lt;/code&gt;、&lt;code&gt;netstandard2.1&lt;/code&gt;），CLR 的行为是规范的，BCL 的 API 是统一的。微软作为平台控制者，有能力将构建管线标准化到&amp;quot;开箱即用&amp;quot;的程度。&lt;/p&gt;&lt;p&gt;&lt;strong&gt;但这并不意味着 .NET 的构建系统更简单&lt;/strong&gt;——只是复杂度的分布不同。当你需要自定义 MSBuild 
逻辑（比如代码生成、多目标框架编译、AOT 发布配置）时，MSBuild 的 XML 文件和属性/项/目标的抽象模型同样有 steep 
learning curve。只是大多数开发者不需要触碰这些，因为 defaults are sensible。&lt;/p&gt;&lt;p&gt;&lt;a rel=&quot;nofollow noopener&quot; name=&quot;_label1_2&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;h3 id=&quot;23-linq一种查询语言的诞生与启示&quot;&gt;2.3 LINQ：一种查询语言的诞生与启示&lt;/h3&gt;&lt;p&gt;LINQ（Language Integrated Query）是 C# 最被低估的设计成就之一。它不仅仅是一个库（&lt;code&gt;System.Linq&lt;/code&gt;），而是一种&amp;nbsp;&lt;strong&gt;将查询能力嵌入类型化语言的语法创新&lt;/strong&gt;。&lt;/p&gt;&lt;pre class=&quot;highlighter-hljs&quot; data-mac-style=&quot;true&quot;&gt;&lt;ul class=&quot;awes-linenumber list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;1&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;2&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;3&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;4&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;5&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;6&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;7&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;8&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;9&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;10&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;11&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;code class=&quot;highlighter-hljs hljs language-csharp hljs-line-numbers&quot;&gt;&lt;table class=&quot;hljs-ln&quot;&gt;&lt;tbody&gt;&lt;tr class=&quot;firstRow&quot;&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;1&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;// LINQ：声明式查询，编译器翻译为方法调用 + Lambda&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;2&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; adults = &lt;span class=&quot;hljs-keyword&quot;&gt;from&lt;/span&gt; p &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; people&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;3&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;where&lt;/span&gt; p.Age &amp;gt;= &lt;span class=&quot;hljs-number&quot;&gt;18&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;4&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;orderby&lt;/span&gt; p.Name&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;5&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;select&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; { p.Name, p.Age };&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;6&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;7&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;// 编译后等价于：&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;8&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; adults = people&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;9&quot;&gt;.Where(p =&amp;gt; p.Age &amp;gt;= &lt;span class=&quot;hljs-number&quot;&gt;18&lt;/span&gt;)&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;10&quot;&gt;.OrderBy(p =&amp;gt; p.Name)&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;11&quot;&gt;.Select(p =&amp;gt; &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; { p.Name, p.Age });&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;前端的 JavaScript 有&amp;nbsp;&lt;code&gt;Array.filter&lt;/code&gt;、&lt;code&gt;Array.map&lt;/code&gt;、&lt;code&gt;Array.sort&lt;/code&gt;，看起来功能类似。但关键差异在于&lt;strong&gt;延迟执行（Deferred Execution）和表达式树（Expression Trees）&lt;/strong&gt; 。&lt;/p&gt;&lt;p&gt;LINQ 的链式调用返回的不是结果，而是&lt;strong&gt;一个查询描述（IEnumerable&amp;nbsp;或 IQueryable）&lt;/strong&gt; 。实际的执行被推迟到结果被消费时（比如&amp;nbsp;&lt;code&gt;ToList()&lt;/code&gt;&amp;nbsp;或&amp;nbsp;&lt;code&gt;foreach&lt;/code&gt;）。更重要的是，当操作&amp;nbsp;&lt;code&gt;IQueryable&amp;lt;T&amp;gt;&lt;/code&gt;（如 Entity Framework Core）时，LINQ 查询被编译为&lt;strong&gt;表达式树（Expression Trees）&lt;/strong&gt; ——一种运行时可遍历、可翻译的抽象语法树（AST）表示。&lt;/p&gt;&lt;pre class=&quot;highlighter-hljs&quot; data-mac-style=&quot;true&quot;&gt;&lt;ul class=&quot;awes-linenumber list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;1&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;2&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;3&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;4&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;5&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;6&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;7&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;code class=&quot;highlighter-hljs hljs language-javascript hljs-line-numbers&quot;&gt;&lt;table class=&quot;hljs-ln&quot;&gt;&lt;tbody&gt;&lt;tr class=&quot;firstRow&quot;&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;1&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;// 这里 where 条件不是委托（Func），而是表达式树（Expression）&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;2&quot;&gt;&lt;span class=&quot;hljs-title class_&quot;&gt;IQueryable&lt;/span&gt;&amp;lt;&lt;span class=&quot;hljs-title class_&quot;&gt;Person&lt;/span&gt;&amp;gt; query = dbContext.&lt;span class=&quot;hljs-property&quot;&gt;People&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;3&quot;&gt;.&lt;span class=&quot;hljs-title class_&quot;&gt;Where&lt;/span&gt;(&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-params&quot;&gt;p&lt;/span&gt; =&amp;gt;&lt;/span&gt; p.&lt;span class=&quot;hljs-property&quot;&gt;Age&lt;/span&gt; &amp;gt;= &lt;span class=&quot;hljs-number&quot;&gt;18&lt;/span&gt;); &amp;nbsp;&lt;span class=&quot;hljs-comment&quot;&gt;// Expression&amp;lt;Func&amp;lt;Person, bool&amp;gt;&amp;gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;4&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;5&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;// Entity Framework Core 可以遍历这个表达式树，&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;6&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;// 将其翻译为 SQL：SELECT ... FROM People WHERE Age &amp;gt;= 18&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;7&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;// 在数据库服务器端执行，而非在内存中过滤&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;这是 C# 的类型系统和编译器基础设施的强大体现：&lt;strong&gt;C# 允许你在编译期和运行时之间操作代码的 AST 表示&lt;/strong&gt;。表达式树让 ORM（对象关系映射）可以&amp;quot;理解&amp;quot;你的查询意图，生成优化的 SQL，而不是盲目地在内存中处理数据。&lt;/p&gt;&lt;p&gt;前端没有直接对应物。JavaScript 的&amp;nbsp;&lt;code&gt;Array.filter&lt;/code&gt;&amp;nbsp;永远是即时执行（eager 
evaluation），操作的是内存中的数组。当我们需要从 API 获取数据并按条件过滤时，我们必须手动构建查询字符串或使用专门的查询库（如 
TanStack Query），没有任何机制能让 JavaScript &amp;quot;理解 &amp;quot;过滤逻辑并自动将其翻译为后端查询。&lt;/p&gt;&lt;p&gt;TypeScript 的类型系统足够强大来做类型安全的查询构建器（如 Prisma 的类型生成），但 Prisma 的做法是在&amp;nbsp;&lt;strong&gt;编译期生成类型定义和查询 builder 代码&lt;/strong&gt;，而不是像 LINQ 那样在运行时通过表达式树进行查询翻译。这是两种解决路径，各有优劣——Prisma 的方案更轻量，LINQ 的方案更灵活（你可以在运行时动态组合查询条件）。&lt;/p&gt;&lt;hr/&gt;&lt;div style=&quot;text-align:right;&quot;&gt;&lt;a rel=&quot;nofollow noopener&quot; href=&quot;https://www.cnblogs.com/wjszxli/p/20206652#_labelTop&quot; style=&quot;color:#f68a33&quot;&gt;回到顶部&lt;/a&gt;&lt;a rel=&quot;nofollow noopener&quot; name=&quot;_label2&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;h2 id=&quot;三v8-与-clr-的区别&quot;&gt;三、V8 与 CLR 的区别&lt;/h2&gt;&lt;p&gt;&lt;a rel=&quot;nofollow noopener&quot; name=&quot;_label2_0&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;h3 id=&quot;31-v8-的隐藏类与内联缓存动态类型的-jit-生存策略&quot;&gt;3.1 V8 的隐藏类与内联缓存：动态类型的 JIT 生存策略&lt;/h3&gt;&lt;p&gt;JavaScript 是动态类型语言，但 V8 的 JIT 编译器必须让动态类型代码跑得接近静态类型代码的速度。它是怎么做到的？&lt;/p&gt;&lt;p&gt;答案是&amp;nbsp;&lt;strong&gt;隐藏类（Hidden Classes，也称 Maps 或 Shapes）+ 内联缓存（Inline Caches, ICs）&lt;/strong&gt; 。&lt;/p&gt;&lt;p&gt;当你在 JavaScript 中创建一个对象：&lt;/p&gt;&lt;pre class=&quot;highlighter-hljs&quot; data-mac-style=&quot;true&quot;&gt;1const&amp;nbsp;point&amp;nbsp;=&amp;nbsp;{&amp;nbsp;x:&amp;nbsp;1,&amp;nbsp;y:&amp;nbsp;2&amp;nbsp;};&lt;/pre&gt;&lt;p&gt;V8 不会简单地创建一个哈希表。相反，它会创建一个&lt;strong&gt;隐藏类（Hidden Class）&lt;/strong&gt; 来记录这个对象的结构：&lt;/p&gt;&lt;pre class=&quot;highlighter-hljs&quot; data-mac-style=&quot;true&quot;&gt;&lt;ul class=&quot;awes-linenumber list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;1&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;2&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;3&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;4&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;5&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;6&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;code class=&quot;highlighter-hljs hljs language-bash hljs-line-numbers&quot;&gt;&lt;table class=&quot;hljs-ln&quot;&gt;&lt;tbody&gt;&lt;tr class=&quot;firstRow&quot;&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;1&quot;&gt;HiddenClass0 (空对象形状)&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;2&quot;&gt;→ 添加属性 &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;x&amp;quot;&lt;/span&gt; → HiddenClass1&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;3&quot;&gt;→ 添加属性 &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;y&amp;quot;&lt;/span&gt; → HiddenClass2&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;4&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;5&quot;&gt;对象内存布局（简化）：&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;6&quot;&gt;[ HiddenClass 指针 | 属性 1 (x) | 属性 2 (y) | ... ]&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;当你后续创建&amp;nbsp;&lt;code&gt;const p2 = { x: 3, y: 4 }&lt;/code&gt;&amp;nbsp;时，如果属性添加顺序相同，V8 会直接复用&amp;nbsp;&lt;code&gt;HiddenClass2&lt;/code&gt;。这意味着相同&amp;quot;形状&amp;quot;的对象在内存中有相同的布局，属性访问可以通过&lt;strong&gt;偏移量（offset）&lt;/strong&gt; 直接定位，而不是哈希查找。&lt;/p&gt;&lt;p&gt;内联缓存（IC）进一步优化属性访问。第一次访问&amp;nbsp;&lt;code&gt;point.x&lt;/code&gt;&amp;nbsp;时，V8 检查&amp;nbsp;&lt;code&gt;point&lt;/code&gt;&amp;nbsp;的 Hidden Class，记录&amp;quot;&lt;code&gt;HiddenClass2&lt;/code&gt;&amp;nbsp;的偏移 0 是属性&amp;nbsp;&lt;code&gt;x&lt;/code&gt;&amp;quot;，并生成一个&lt;strong&gt;单态内联缓存（monomorphic IC）&lt;/strong&gt; ——一段直接根据偏移量读取属性的机器码。如果后续每次访问的对象都有相同的 Hidden Class，这段机器码直接命中，无需任何类型检查。&lt;/p&gt;&lt;p&gt;但如果代码突然执行&amp;nbsp;&lt;code&gt;point.z = 3&lt;/code&gt;，对象的形状改变，隐藏类转换链继续延伸，内联缓存可能需要退化为&lt;strong&gt;多态（polymorphic）&lt;/strong&gt; 甚至&lt;strong&gt;巨态（megamorphic）&lt;/strong&gt; ——即回退到通用的字典查找。这就是 V8 性能优化中最著名的陷阱：&lt;strong&gt;megamorphic property access 的性能可能比初始访问慢 10-100 倍&lt;/strong&gt;。&lt;/p&gt;&lt;pre class=&quot;highlighter-hljs&quot; data-mac-style=&quot;true&quot;&gt;&lt;ul class=&quot;awes-linenumber list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;1&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;2&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;3&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;4&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;5&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;6&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;7&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;8&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;code class=&quot;highlighter-hljs hljs language-scss hljs-line-numbers&quot;&gt;&lt;table class=&quot;hljs-ln&quot;&gt;&lt;tbody&gt;&lt;tr class=&quot;firstRow&quot;&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;1&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;// 这种看似无害的代码会创建大量隐藏类转换，导致 IC 失效&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;2&quot;&gt;function &lt;span class=&quot;hljs-built_in&quot;&gt;process&lt;/span&gt;(obj) {&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;3&quot;&gt;return obj&lt;span class=&quot;hljs-selector-class&quot;&gt;.x&lt;/span&gt; + obj&lt;span class=&quot;hljs-selector-class&quot;&gt;.y&lt;/span&gt;; &amp;nbsp;&lt;span class=&quot;hljs-comment&quot;&gt;// 如果 obj 的&amp;quot;形状&amp;quot;每次不同，这里是巨态访问&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;4&quot;&gt;}&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;5&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;6&quot;&gt;&lt;span class=&quot;hljs-built_in&quot;&gt;process&lt;/span&gt;({ x: &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, y: &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;, z: &lt;span class=&quot;hljs-number&quot;&gt;3&lt;/span&gt; }); &amp;nbsp;&lt;span class=&quot;hljs-comment&quot;&gt;// HiddenClass A&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;7&quot;&gt;&lt;span class=&quot;hljs-built_in&quot;&gt;process&lt;/span&gt;({ x: &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, y: &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;, a: &lt;span class=&quot;hljs-number&quot;&gt;4&lt;/span&gt; }); &amp;nbsp;&lt;span class=&quot;hljs-comment&quot;&gt;// HiddenClass B（不同形状！）&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;8&quot;&gt;&lt;span class=&quot;hljs-built_in&quot;&gt;process&lt;/span&gt;({ y: &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;, x: &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt; }); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;hljs-comment&quot;&gt;// HiddenClass C（属性顺序不同！）&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;前端框架也深受此影响。React 的 JSX 属性被编译为&amp;nbsp;&lt;code&gt;React.createElement(type, props, children)&lt;/code&gt;，每次渲染创建新的&amp;nbsp;&lt;code&gt;props&lt;/code&gt;对象。如果组件的 props 结构不稳定（条件性地添加属性），V8 无法为属性访问建立稳定的内联缓存。这也是为什么 React 团队推荐&lt;strong&gt;稳定的 props 形状&lt;/strong&gt;——本质上是帮 V8 做隐藏类优化。&lt;/p&gt;&lt;p&gt;&lt;a rel=&quot;nofollow noopener&quot; name=&quot;_label2_1&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;h3 id=&quot;32-clr-的方法表与虚方法分派静态类型运行时的效率基石&quot;&gt;3.2 CLR 的方法表与虚方法分派：静态类型运行时的效率基石&lt;/h3&gt;&lt;p&gt;CLR 不需要隐藏类，因为 C# 是静态类型的。但 CLR 有自己的运行时类型系统核心——&lt;strong&gt;方法表（Method Table）&lt;/strong&gt; 。&lt;/p&gt;&lt;p&gt;每个 CLR 对象在内存中的布局是固定的：&lt;/p&gt;&lt;pre class=&quot;highlighter-hljs&quot; data-mac-style=&quot;true&quot;&gt;1234[&amp;nbsp;对象头&amp;nbsp;(8&amp;nbsp;bytes:&amp;nbsp;sync&amp;nbsp;block&amp;nbsp;index&amp;nbsp;+&amp;nbsp;Method&amp;nbsp;Table&amp;nbsp;指针)&amp;nbsp;][&amp;nbsp;字段&amp;nbsp;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;][&amp;nbsp;字段&amp;nbsp;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;][&amp;nbsp;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;]&lt;/pre&gt;&lt;p&gt;方法表（Method Table，也称&amp;nbsp;&lt;code&gt;MethodTable&lt;/code&gt;&amp;nbsp;或&amp;nbsp;&lt;code&gt;EEClass&lt;/code&gt;&amp;nbsp;的快捷路径）是每个类型唯一的数据结构，包含：&lt;/p&gt;&lt;ol class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;类型标识&lt;/strong&gt;：父类的方法表指针、接口实现列表&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;方法槽表（Method Slot Table）&lt;/strong&gt; ：该类型所有方法的函数指针数组&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;虚方法表（V-Table）&lt;/strong&gt; ：用于虚方法的多态分派&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;静态字段指针&lt;/strong&gt;、&lt;strong&gt;GC 信息&lt;/strong&gt;（哪些字段是引用类型，用于 GC 的标记阶段）&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;当你调用一个虚方法：&lt;/p&gt;&lt;pre class=&quot;highlighter-hljs&quot; data-mac-style=&quot;true&quot;&gt;&lt;ul class=&quot;awes-linenumber list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;1&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;2&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;3&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;4&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;5&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;code class=&quot;highlighter-hljs hljs language-csharp hljs-line-numbers&quot;&gt;&lt;table class=&quot;hljs-ln&quot;&gt;&lt;tbody&gt;&lt;tr class=&quot;firstRow&quot;&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;1&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;Animal&lt;/span&gt; { &lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;virtual&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;Speak&lt;/span&gt;()&lt;/span&gt; =&amp;gt; Console.WriteLine(&lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;?&amp;quot;&lt;/span&gt;); }&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;2&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;Dog&lt;/span&gt; : &lt;span class=&quot;hljs-title&quot;&gt;Animal&lt;/span&gt; { &lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;override&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;Speak&lt;/span&gt;()&lt;/span&gt; =&amp;gt; Console.WriteLine(&lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;Woof&amp;quot;&lt;/span&gt;); }&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;3&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;4&quot;&gt;Animal a = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; Dog();&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;5&quot;&gt;a.Speak(); &lt;span class=&quot;hljs-comment&quot;&gt;// &amp;quot;Woof&amp;quot; —— 运行时多态分派&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;CLR 的执行过程是：&lt;/p&gt;&lt;ol class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;读取&amp;nbsp;&lt;code&gt;a&lt;/code&gt;&amp;nbsp;指向的对象头，获取 Method Table 指针（一次内存访问）&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;在 Method Table 的虚方法表中找到&amp;nbsp;&lt;code&gt;Speak&lt;/code&gt;&amp;nbsp;方法的槽位（偏移量已知，编译期确定）&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;调用槽位中存储的函数指针&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;这个过程是&lt;strong&gt;O(1) 的、可预测的、缓存友好的&lt;/strong&gt;。对比 V8 的 megamorphic IC 回退到哈希查找，CLR 的虚方法分派即使在最坏情况下也保持恒定性能。&lt;/p&gt;&lt;p&gt;&lt;strong&gt;更关键的是 JIT 内联（Inlining）&lt;/strong&gt; 。CLR 的 JIT（RyuJIT）在编译虚方法调用时，如果通过类型反馈或 PGO（Profile-Guided Optimization）发现某个调用点 99% 都是某个具体类型，它可以执行 &lt;strong&gt;guarded devirtualization&lt;/strong&gt;——将虚方法调用内联为直接调用，外加一个类型检查 guard。如果 guard 失败，回退到正常的虚方法分派。这种技术在热路径上的效果惊人——理论上一个虚方法调用的开销可以被降低到几乎为零。&lt;/p&gt;&lt;p&gt;&lt;a rel=&quot;nofollow noopener&quot; name=&quot;_label2_2&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;h3 id=&quot;33-垃圾回收器的两种不同处理延迟优先-vs-吞吐优先&quot;&gt;3.3 垃圾回收器的两种不同处理：延迟优先 vs 吞吐优先&lt;/h3&gt;&lt;p&gt;V8 和 CLR 的 GC 设计反映了它们服务场景的根本差异。&lt;/p&gt;&lt;p&gt;&lt;strong&gt;V8 的 GC 架构（Orinoco）&lt;/strong&gt; ：&lt;/p&gt;&lt;pre class=&quot;highlighter-hljs&quot; data-mac-style=&quot;true&quot;&gt;&lt;ul class=&quot;awes-linenumber list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;1&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;2&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;3&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;4&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;5&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;6&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;7&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;8&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;9&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;code class=&quot;highlighter-hljs hljs language-css hljs-line-numbers&quot;&gt;&lt;table class=&quot;hljs-ln&quot;&gt;&lt;tbody&gt;&lt;tr class=&quot;firstRow&quot;&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;1&quot;&gt;新生代（New Space）—— 半空间复制（Semi-Space Copy）&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;2&quot;&gt;├── &lt;span class=&quot;hljs-selector-tag&quot;&gt;From&lt;/span&gt; Space（活跃对象）&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;3&quot;&gt;└── &lt;span class=&quot;hljs-selector-tag&quot;&gt;To&lt;/span&gt; Space（复制目标）&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;4&quot;&gt;回收过程：Scavenger 将存活对象从 &lt;span class=&quot;hljs-selector-tag&quot;&gt;From&lt;/span&gt; 复制到 &lt;span class=&quot;hljs-selector-tag&quot;&gt;To&lt;/span&gt;，交换空间，耗时 &amp;lt; &lt;span class=&quot;hljs-number&quot;&gt;1ms&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;5&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;6&quot;&gt;老生代（Old Space）—— 标记-整理（&lt;span class=&quot;hljs-selector-tag&quot;&gt;Mark&lt;/span&gt;-Compact）&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;7&quot;&gt;├── Major GC（全堆标记）&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;8&quot;&gt;├── 增量标记（Incremental Marking）：与 JS 执行交错，避免长时间停顿&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;9&quot;&gt;└── 并发标记（Concurrent Marking）：辅助线程并行标记&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;V8 的 GC 设计原则是&lt;strong&gt;最小化停顿时间（Pause Time）&lt;/strong&gt; 。浏览器中一个 100ms 的 GC 
停顿会导致明显的 UI 卡顿，所以 V8 不惜牺牲吞吐量和内存效率来换取低延迟。半空间复制算法浪费了一半的新生代内存（To Space 
始终是空的），但换来了极快的回收速度。增量标记增加了 GC 的总工作量（需要额外的 write barrier 
来跟踪增量期间的对象图变化），但将大停顿拆分为小切片。&lt;/p&gt;&lt;p&gt;&lt;strong&gt;CLR 的 GC 架构&lt;/strong&gt;：&lt;/p&gt;&lt;pre class=&quot;highlighter-hljs&quot; data-mac-style=&quot;true&quot;&gt;123第&amp;nbsp;0&amp;nbsp;代（Gen&amp;nbsp;0）——&amp;nbsp;短生命周期对象，新分配的对象默认在此第&amp;nbsp;1&amp;nbsp;代（Gen&amp;nbsp;1）——&amp;nbsp;从&amp;nbsp;Gen&amp;nbsp;0&amp;nbsp;晋升的对象（经过&amp;nbsp;1&amp;nbsp;次&amp;nbsp;GC&amp;nbsp;仍存活）第&amp;nbsp;2&amp;nbsp;代（Gen&amp;nbsp;2）——&amp;nbsp;长生命周期对象，大对象堆（LOH）也在这里&lt;/pre&gt;&lt;p&gt;CLR GC 的设计目标是&lt;strong&gt;最大化吞吐量（Throughput）同时保持可接受的停顿时间&lt;/strong&gt;。分代收集的理论基础是&lt;strong&gt;弱代假设（Weak Generational Hypothesis）&lt;/strong&gt; ：大部分对象在创建后很快死亡，只有少数对象会长期存活。&lt;/p&gt;&lt;ul class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Gen 0 收集&lt;/strong&gt;非常频繁但极快（只扫描最近分配的对象）&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Gen 1 收集&lt;/strong&gt;较少发生，扫描范围稍大&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Gen 2 收集&lt;/strong&gt;（Full GC）最不频繁，但最耗时（扫描整个托管堆）&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;CLR 提供了 V8 没有的能力：&lt;strong&gt;服务器 GC 模式（Server GC）&lt;/strong&gt; 。在服务器模式下，CLR 为每个 CPU 核心创建一个专用的托管堆和 GC 线程，GC 工作在多线程上并行执行。这对于高吞吐量的 ASP.NET Core 应用是革命性的——GC 不再是一个全局停顿事件，而是被分散到多个核心上并行处理。&lt;/p&gt;&lt;p&gt;.NET 还引入了&lt;strong&gt;DATAS（Dynamic Adaptation To Application Sizes）&lt;/strong&gt; （.NET 9），让 GC 根据应用的工作集大小动态调节堆的段大小和 GC 触发阈值。这是对云原生场景（容器化部署、内存限制严格）的回应。&lt;/p&gt;&lt;p&gt;&lt;a rel=&quot;nofollow noopener&quot; name=&quot;_label2_3&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;h3 id=&quot;34-jit-编译器的技术路线不同推测优化-vs-确定性优化&quot;&gt;3.4 JIT 编译器的技术路线不同：推测优化 vs 确定性优化&lt;/h3&gt;&lt;p&gt;V8 的 TurboFan 和 CLR 的 RyuJIT 代表了 JIT 编译的两种考虑。&lt;/p&gt;&lt;p&gt;&lt;strong&gt;TurboFan：基于推测的优化（Speculative Optimization）&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;TurboFan 的优化管线是：&lt;/p&gt;&lt;pre class=&quot;highlighter-hljs&quot; data-mac-style=&quot;true&quot;&gt;12345JavaScript&amp;nbsp;代码→&amp;nbsp;字节码解释器（Ignition）快速执行，收集类型反馈→&amp;nbsp;TurboFan&amp;nbsp;根据类型反馈生成优化机器码→&amp;nbsp;机器码内联了&amp;quot;类型假设&amp;quot;（如：obj&amp;nbsp;的隐藏类是&amp;nbsp;HClass_X）→&amp;nbsp;如果假设失效&amp;nbsp;→&amp;nbsp;去优化（Deoptimization）回解释器&lt;/pre&gt;&lt;p&gt;TurboFan 本质上是&lt;strong&gt;在不确定的环境中做有根据的猜测&lt;/strong&gt;。它假设你的代码是&amp;quot;类型稳定的&amp;quot;——对象的形状不变、变量的类型不突变、数组的元素类型一致。如果这些假设成立，生成的机器码可以接近 C++ 的性能。但如果假设失败，去优化的代价极高：丢弃优化代码、重建栈帧、回退到解释器执行。&lt;/p&gt;&lt;p&gt;这种设计让 JavaScript 的&lt;strong&gt;稳态性能（Steady-State Performance）&lt;/strong&gt; 非常高，但&lt;strong&gt;峰值性能（Peak Performance）&lt;/strong&gt; 和&lt;strong&gt;边缘情况性能（Corner-Case Performance）&lt;/strong&gt; 可能剧烈波动。这也是 JavaScript 不适合硬实时系统的原因之一——我们无法保证最坏情况下的执行时间。&lt;/p&gt;&lt;p&gt;&lt;strong&gt;RyuJIT：基于类型的确定性优化（Type-Based Deterministic Optimization）&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;RyuJIT 的优化管线是：&lt;/p&gt;&lt;pre class=&quot;highlighter-hljs&quot; data-mac-style=&quot;true&quot;&gt;12345C#&amp;nbsp;代码→&amp;nbsp;Roslyn&amp;nbsp;编译为&amp;nbsp;IL（中间语言）+&amp;nbsp;完整元数据→&amp;nbsp;RyuJIT&amp;nbsp;根据&amp;nbsp;IL&amp;nbsp;和类型信息生成本地机器码→&amp;nbsp;优化是确定性的：内联、循环展开、SIMD&amp;nbsp;向量化、寄存器分配→&amp;nbsp;生成的代码不依赖运行时类型假设（除非虚方法调用走&amp;nbsp;PGO&amp;nbsp;路径）&lt;/pre&gt;&lt;p&gt;因为 C# 是静态类型的，RyuJIT 在编译时就拥有完整的类型信息。它不需要&amp;quot;猜测&amp;quot;变量的类型——编译器已经知道&amp;nbsp;&lt;code&gt;int&lt;/code&gt;&amp;nbsp;就是 32 位整数，&lt;code&gt;double[]&lt;/code&gt;&amp;nbsp;就是 64 位浮点数组。这使得 RyuJIT 可以做&lt;strong&gt;确定性优化&lt;/strong&gt;：&lt;/p&gt;&lt;ul class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;值类型内联（Value Type Inlining）&lt;/strong&gt; ：&lt;code&gt;struct Point2D&lt;/code&gt;&amp;nbsp;的字段直接内联到包含对象或数组的内存布局中，消除间接寻址&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;SIMD 向量化（Vectorization）&lt;/strong&gt; ：&lt;code&gt;.NET 8+&lt;/code&gt;&amp;nbsp;的 RyuJIT 可以自动将循环转换为 AVX2/NEON SIMD 指令，一次处理 4-8 个数据元素&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;边界检查消除（Bounds Check Elimination）&lt;/strong&gt; ：如果编译器能证明数组访问在有效范围内，移除运行时检查&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;PGO 增强的去虚拟化（PGO-Devirtualization）&lt;/strong&gt; ：基于运行时分支频率优化虚方法调用&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;这些优化的关键特征是&lt;strong&gt;可预测性&lt;/strong&gt;。你写的 C# 代码，在 .NET 8 上的性能表现是可以预期的——同样的输入、同样的优化路径。JavaScript 的 TurboFan 则可能因为微小的代码变化（改变对象属性的添加顺序、多一个类型分支）导致完全不同的优化结果。&lt;/p&gt;&lt;p&gt;&lt;strong&gt;一个具体的性能对比&lt;/strong&gt;：&lt;/p&gt;&lt;p&gt;在数值计算密集场景中（科学计算、图像处理、游戏物理引擎），C#（通过&amp;nbsp;&lt;code&gt;Span&amp;lt;T&amp;gt;&lt;/code&gt;&amp;nbsp;+ SIMD）通常能达到 C++ 80-95% 的性能。JavaScript（即使是 V8 的 TurboFan 优化后）通常在 C++ 的 20-40% 水平——差距主要来自：&lt;/p&gt;&lt;ol class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;数组访问的边界检查&lt;/strong&gt;：JavaScript 无法消除（类型信息不足），C# 可以&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;SIMD 向量化&lt;/strong&gt;：JavaScript 正在通过 WebAssembly SIMD 和 TC39 提案追赶，但 C# 的&amp;nbsp;&lt;code&gt;System.Numerics.Vector&lt;/code&gt;&amp;nbsp;和&amp;nbsp;&lt;code&gt;System.Runtime.Intrinsics&lt;/code&gt;&amp;nbsp;已经是成熟的一等公民&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;值类型和栈分配&lt;/strong&gt;：JavaScript 的所有对象都在堆上，数值计算产生大量的临时对象和 GC 压力&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;a rel=&quot;nofollow noopener&quot; name=&quot;_label2_4&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;h3 id=&quot;35-aot-编译跨越-jit-的边界&quot;&gt;3.5 AOT 编译：跨越 JIT 的边界&lt;/h3&gt;&lt;p&gt;.NET 的 AOT（Ahead-of-Time）编译是近年来最具战略意义的技术演进。&lt;/p&gt;&lt;p&gt;传统的 .NET 编译流程是：C# → IL（中间语言）→ JIT（运行时编译为机器码）。AOT 则将最后一步提前到构建时：C# → IL →&amp;nbsp;&lt;strong&gt;Native Code（原生机器码）&lt;/strong&gt; 。&lt;/p&gt;&lt;pre class=&quot;highlighter-hljs&quot; data-mac-style=&quot;true&quot;&gt;12#&amp;nbsp;.NET&amp;nbsp;8+&amp;nbsp;的&amp;nbsp;Native&amp;nbsp;AOT&amp;nbsp;编译dotnet&amp;nbsp;publish&amp;nbsp;-r&amp;nbsp;linux-x64&amp;nbsp;-c&amp;nbsp;Release&amp;nbsp;-p:PublishAot=true&lt;/pre&gt;&lt;p&gt;AOT 编译后的可执行文件：&lt;/p&gt;&lt;ul class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;不需要 .NET Runtime 安装&lt;/strong&gt;，完全自包含&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;启动时间极快&lt;/strong&gt;（没有 JIT 预热成本，对 Serverless/冷启动场景至关重要）&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;内存占用更小&lt;/strong&gt;（不需要 JIT 编译器、不需要 IL 代码缓存）&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;可以编译为 WebAssembly&lt;/strong&gt;（Blazor WebAssembly 的 .NET 运行时就是 AOT 编译的）&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;但 AOT 有约束：&lt;strong&gt;不能使用运行时反射创建类型&lt;/strong&gt;（因为编译器需要在构建时知道所有实例化的类型）、&lt;strong&gt;动态代码生成被禁止&lt;/strong&gt;、某些泛型模式受限。&lt;/p&gt;&lt;p&gt;这对前端的意义是什么？&lt;strong&gt;Blazor WebAssembly 的运行时性能因此得到了质的飞跃&lt;/strong&gt;。早期的 
Blazor WASM 使用 IL 解释器在浏览器中运行 .NET 代码，性能远低于 JavaScript。现在通过 AOT 编译，C# 
代码被编译为 WASM 字节码，在执行速度上可以与 JavaScript 竞争。虽然启动时仍需下载和实例化 .NET 运行时（约 2-3MB 的
 WASM 文件），但一旦启动，执行效率是有保证的。&lt;/p&gt;&lt;p&gt;对比 JavaScript，V8 没有 AOT 选项——每一次页面加载都要重新做 JIT 编译（虽然浏览器有代码缓存，但不如真正的 
AOT）。WebAssembly 的出现实际上是在前端领域引入&amp;quot;AOT 思维&amp;quot;的第一步，而 .NET 的 Native AOT 
在服务器端和客户端同时推进，展示了这一技术的全景潜力。&lt;/p&gt;&lt;hr/&gt;&lt;div style=&quot;text-align:right;&quot;&gt;&lt;a rel=&quot;nofollow noopener&quot; href=&quot;https://www.cnblogs.com/wjszxli/p/20206652#_labelTop&quot; style=&quot;color:#f68a33&quot;&gt;回到顶部&lt;/a&gt;&lt;a rel=&quot;nofollow noopener&quot; name=&quot;_label3&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;h2 id=&quot;四-c-要响浏览器大门时的深层博弈&quot;&gt;四、 C# 要响浏览器大门时的深层博弈&lt;/h2&gt;&lt;p&gt;&lt;a rel=&quot;nofollow noopener&quot; name=&quot;_label3_0&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;h3 id=&quot;41-服务端渲染从-blazor-server-到-react-server-components&quot;&gt;4.1 服务端渲染：从 Blazor Server 到 React Server Components&lt;/h3&gt;&lt;p&gt;Blazor 和 React 都在探索&amp;quot;服务端渲染&amp;quot;，但出发点截然不同。&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Blazor Server&lt;/strong&gt;&amp;nbsp;的架构是：&lt;/p&gt;&lt;pre class=&quot;highlighter-hljs&quot; data-mac-style=&quot;true&quot;&gt;12345浏览器&amp;nbsp;←──WebSocket/SSE──→&amp;nbsp;ASP.NET&amp;nbsp;Core&amp;nbsp;服务器│&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;││&amp;nbsp;&amp;nbsp;UI&amp;nbsp;事件&amp;nbsp;(点击、输入)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;│&amp;nbsp;&amp;nbsp;组件状态管理&amp;nbsp;+&amp;nbsp;渲染&amp;nbsp;Diff│&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;│&amp;nbsp;&amp;nbsp;SignalR&amp;nbsp;实时推送│&amp;nbsp;&amp;nbsp;DOM&amp;nbsp;更新指令&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;│&amp;nbsp;&amp;nbsp;Razor&amp;nbsp;组件渲染引擎&lt;/pre&gt;&lt;p&gt;Blazor Server 将所有组件状态保存在服务器内存中，通过 SignalR（WebSocket 
的长连接回退机制）与浏览器通信。用户的每一次交互都经过网络往返：点击按钮 → SignalR 消息 → 服务器处理事件 → 组件重新渲染 → 
计算 UI diff → SignalR 推送 DOM 更新 → 浏览器应用。&lt;/p&gt;&lt;p&gt;这听起来很慢，但实际如果是对于&lt;strong&gt;企业内网应用&lt;/strong&gt;（低延迟网络、大量数据展示、复杂业务逻辑），Blazor Server 的体验往往优于纯客户端渲染。原因是：&lt;/p&gt;&lt;ol class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;零客户端下载&lt;/strong&gt;：不需要下载 .NET 运行时或应用代码，首屏快&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;服务器端数据访问&lt;/strong&gt;：组件可以直接查询数据库，不需要 REST API 层&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;状态在服务端&lt;/strong&gt;：不用担心客户端状态管理的复杂性，所有状态都在可控的服务器内存中&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;但 Blazor Server 有一个也有&amp;nbsp;&lt;strong&gt;致命约束&lt;/strong&gt;：网络延迟直接决定交互响应速度。在 100ms 延迟的网络下，按钮点击的反馈需要 200ms（往返），这已经超出人类感知的&amp;quot;即时&amp;quot;阈值（100ms）。这就让 Blazor Server 不适合面向公网的 C 端应用。&lt;/p&gt;&lt;p&gt;&lt;strong&gt;React Server Components（RSC）&lt;/strong&gt; &amp;nbsp;走了不同的道路：&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;https://show-blog.su.bcebos.com/uPic/mermaid-20260528_154242.png&quot; alt=&quot;&quot; class=&quot;medium-zoom-image&quot;/&gt;&lt;/p&gt;&lt;p&gt;RSC 的核心是&lt;strong&gt;将组件树分为&amp;quot;服务端组件&amp;quot;和&amp;quot;客户端组件&amp;quot;&lt;/strong&gt; ：&lt;/p&gt;&lt;ul class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Server Components&lt;/strong&gt;&amp;nbsp;在服务端执行（可以访问数据库、文件系统），渲染为特殊的序列化格式（RSC Payload）流式传输到客户端&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Client Components&lt;/strong&gt;&amp;nbsp;是传统的 React 组件，需要下载 JS 并在客户端 hydrate&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;这与 Blazor Server 的关键区别是：&lt;strong&gt;RSC 不维持长连接，服务端不保持组件状态&lt;/strong&gt;。每个请求是独立的，服务端组件是无状态的函数调用。这给了 RSC 更好的可伸缩性（无状态服务可以水平扩展），但失去了 Blazor Server 的有状态交互能力。&lt;/p&gt;&lt;p&gt;所以通过我们也可以看到：Blazor Server 本质上是在 Web 上复刻了&lt;strong&gt;桌面应用的&amp;quot;瘦客户端&amp;quot;模式&lt;/strong&gt;（类似 Remote Desktop 或早期的 ASP.NET Web Forms）。React Server Components 则是在&lt;strong&gt;扩展前端的渲染边界&lt;/strong&gt;，让服务端参与 UI 渲染的同时保持前端的组件模型。&lt;/p&gt;&lt;p&gt;&lt;a rel=&quot;nofollow noopener&quot; name=&quot;_label3_1&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;h3 id=&quot;42-blazor-webassemblynet-运行时在浏览器中的方式&quot;&gt;4.2 Blazor WebAssembly：.NET 运行时在浏览器中的方式&lt;/h3&gt;&lt;p&gt;Blazor WebAssembly 是 .NET 对前端领域最大胆的尝试——将完整的 .NET 运行时编译为 WebAssembly，在浏览器中执行 C# 代码。&lt;/p&gt;&lt;pre class=&quot;highlighter-hljs&quot; data-mac-style=&quot;true&quot;&gt;1234567浏览器加载流程：1.&amp;nbsp;下载&amp;nbsp;blazor.webassembly.js（引导脚本，~30KB）2.&amp;nbsp;下载&amp;nbsp;dotnet.wasm（.NET&amp;nbsp;运行时，~2.5MB&amp;nbsp;gzip&amp;nbsp;压缩后）3.&amp;nbsp;下载应用的&amp;nbsp;DLL&amp;nbsp;程序集（我们的代码&amp;nbsp;+&amp;nbsp;依赖库，几百&amp;nbsp;KB&amp;nbsp;到数&amp;nbsp;MB）4.&amp;nbsp;实例化&amp;nbsp;WASM&amp;nbsp;模块，启动&amp;nbsp;.NET&amp;nbsp;运行时5.&amp;nbsp;加载并执行&amp;nbsp;Program.Main()6.&amp;nbsp;Razor&amp;nbsp;组件渲染引擎接管，渲染初始&amp;nbsp;UI&lt;/pre&gt;&lt;p&gt;这个流程揭示了 Blazor WASM 的核心挑战：&lt;strong&gt;启动时间&lt;/strong&gt;。2.5MB 的运行时下载 + 解析 + 实例化，在移动网络或低端设备上可能需要数秒。相比之下，一个 React 应用的 JS bundle（即使也达到 2MB）不需要额外的&amp;quot;运行时&amp;quot;下载——浏览器原生执行 JavaScript。&lt;/p&gt;&lt;p&gt;但 Blazor WASM 有独特的优势：&lt;/p&gt;&lt;ol class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;真正的代码共享&lt;/strong&gt;：前后端共享 C# 模型类、验证逻辑、业务规则。修改一个模型类，两端同时生效——没有 TypeScript 类型和 C# DTO 之间的映射层。&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;强类型贯穿&lt;/strong&gt;：从数据库（EF Core）到 API（ASP.NET Core）到前端（Blazor组件），类型安全从未中断。不会出现 API 改了字段名、前端 TypeScript 类型没更新的 bug。&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;运行时性能&lt;/strong&gt;：AOT 编译后的 C# WASM 代码在数值计算、数据处理上显著优于 JavaScript。&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;strong&gt;不过这里我们需要警惕的是 JS 互操作（JavaScript Interop）的代价&lt;/strong&gt;：&lt;/p&gt;&lt;pre class=&quot;highlighter-hljs&quot; data-mac-style=&quot;true&quot;&gt;12//&amp;nbsp;C#&amp;nbsp;调用&amp;nbsp;JS：需要序列化参数&amp;nbsp;→&amp;nbsp;通过&amp;nbsp;WASM-JS&amp;nbsp;边界&amp;nbsp;→&amp;nbsp;反序列化&amp;nbsp;→&amp;nbsp;执行&amp;nbsp;→&amp;nbsp;返回序列化var&amp;nbsp;result&amp;nbsp;=&amp;nbsp;await&amp;nbsp;JSRuntime.InvokeAsync&amp;lt;string&amp;gt;(&amp;quot;myJsFunction&amp;quot;,&amp;nbsp;param1,&amp;nbsp;param2);&lt;/pre&gt;&lt;p&gt;每次 JS 互操作调用都有&lt;strong&gt;序列化/反序列化的开销&lt;/strong&gt;，且是异步的（因为 WASM 和 JS 
运行在不同的事件循环上）。频繁的 JS 互操作（比如每帧调用 requestAnimationFrame）会成为性能瓶颈。这意味着 Blazor
 无法高效地操作 Canvas 2D/WebGL、无法实现 60fps 的动画、无法直接调用大量浏览器 API——这些仍然是 
JavaScript 的领地。&lt;/p&gt;&lt;p&gt;&lt;strong&gt;整体的对比可以通过下面的表格来体现&lt;/strong&gt;：&lt;/p&gt;&lt;div class=&quot;table-wrapper&quot;&gt;&lt;table&gt;&lt;thead&gt;&lt;tr class=&quot;firstRow&quot;&gt;&lt;th&gt;场景&lt;/th&gt;&lt;th&gt;推荐技术&lt;/th&gt;&lt;th&gt;原因&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;企业后台管理系统&lt;/td&gt;&lt;td&gt;Blazor Server/WASM&lt;/td&gt;&lt;td&gt;复杂表单、数据密集、团队协作效率优先&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;面向消费者的互联网产品&lt;/td&gt;&lt;td&gt;React/Vue/Svelte&lt;/td&gt;&lt;td&gt;首屏速度、SEO、生态成熟度、动画体验&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;实时协作应用&lt;/td&gt;&lt;td&gt;Blazor Server + SignalR&lt;/td&gt;&lt;td&gt;天然的双向通信基础设施&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;内容型网站/电商&lt;/td&gt;&lt;td&gt;Next.js/Nuxt&lt;/td&gt;&lt;td&gt;SSR/SSG 成熟度、SEO、Edge Runtime&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;跨平台（Web+桌面+移动）&lt;/td&gt;&lt;td&gt;.NET MAUI + Blazor Hybrid&lt;/td&gt;&lt;td&gt;代码共享最大化&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;a rel=&quot;nofollow noopener&quot; name=&quot;_label3_2&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;h3 id=&quot;43-前端框架的对比&quot;&gt;4.3 前端框架的对比&lt;/h3&gt;&lt;p&gt;从架构模式的角度，Blazor 和 React 反映了&amp;quot;后端思维&amp;quot;和&amp;quot;前端思维&amp;quot;在 UI 框架设计上的不一样。&lt;/p&gt;&lt;p&gt;&lt;strong&gt;依赖注入（DI）的差异&lt;/strong&gt;：&lt;/p&gt;&lt;pre class=&quot;highlighter-hljs&quot; data-mac-style=&quot;true&quot;&gt;&lt;ul class=&quot;awes-linenumber list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;1&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;2&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;3&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;4&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;5&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;6&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;7&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;8&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;9&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;10&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;11&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;code class=&quot;highlighter-hljs hljs language-swift hljs-line-numbers&quot;&gt;&lt;table class=&quot;hljs-ln&quot;&gt;&lt;tbody&gt;&lt;tr class=&quot;firstRow&quot;&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;1&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;// Blazor：使用 .NET 原生依赖注入容器&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;2&quot;&gt;&lt;span class=&quot;hljs-meta&quot;&gt;@inject&lt;/span&gt; &lt;span class=&quot;hljs-type&quot;&gt;IUserService&lt;/span&gt; &lt;span class=&quot;hljs-type&quot;&gt;UserService&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;3&quot;&gt;&lt;span class=&quot;hljs-meta&quot;&gt;@inject&lt;/span&gt; &lt;span class=&quot;hljs-type&quot;&gt;IJSRuntime&lt;/span&gt; &lt;span class=&quot;hljs-type&quot;&gt;JSRuntime&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;4&quot;&gt;&lt;span class=&quot;hljs-meta&quot;&gt;@inject&lt;/span&gt; &lt;span class=&quot;hljs-type&quot;&gt;NavigationManager&lt;/span&gt; &lt;span class=&quot;hljs-type&quot;&gt;Navigation&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;5&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;6&quot;&gt;&lt;span class=&quot;hljs-meta&quot;&gt;@code&lt;/span&gt; {&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;7&quot;&gt;protected &lt;span class=&quot;hljs-keyword&quot;&gt;override&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;hljs-type&quot;&gt;Task&lt;/span&gt; &lt;span class=&quot;hljs-type&quot;&gt;OnInitializedAsync&lt;/span&gt;()&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;8&quot;&gt;{&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;9&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; user &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;hljs-type&quot;&gt;UserService&lt;/span&gt;.&lt;span class=&quot;hljs-type&quot;&gt;GetCurrentUserAsync&lt;/span&gt;();&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;10&quot;&gt;}&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;11&quot;&gt;}&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Blazor 的 DI 是&lt;strong&gt;编译期可验证的&lt;/strong&gt;。&lt;code&gt;IUserService&lt;/code&gt;&amp;nbsp;必须在&amp;nbsp;&lt;code&gt;Program.cs&lt;/code&gt;&amp;nbsp;中注册到&amp;nbsp;&lt;code&gt;IServiceCollection&lt;/code&gt;，否则应用在启动时就会抛出异常。服务的生命周期（Singleton/Scoped/Transient）由容器管理，组件不需要关心。&lt;/p&gt;&lt;pre class=&quot;highlighter-hljs&quot; data-mac-style=&quot;true&quot;&gt;&lt;ul class=&quot;awes-linenumber list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;1&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;2&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;3&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;4&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;5&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;6&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;7&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;code class=&quot;highlighter-hljs hljs language-javascript hljs-line-numbers&quot;&gt;&lt;table class=&quot;hljs-ln&quot;&gt;&lt;tbody&gt;&lt;tr class=&quot;firstRow&quot;&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;1&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;// React：依赖注入是约定俗成的模式，不是语言/平台特性&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;2&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; { useUserService } &lt;span class=&quot;hljs-keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;#39;./services/UserService&amp;#39;&lt;/span&gt;;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;3&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;4&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;UserProfile&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;&lt;/span&gt;) {&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;5&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;const&lt;/span&gt; userService = &lt;span class=&quot;hljs-title function_&quot;&gt;useUserService&lt;/span&gt;(); &lt;span class=&quot;hljs-comment&quot;&gt;// 只是自定义 Hook，可能抛运行时错误&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;6&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;const&lt;/span&gt; { data, isLoading } = &lt;span class=&quot;hljs-title function_&quot;&gt;useQuery&lt;/span&gt;([&lt;span class=&quot;hljs-string&quot;&gt;&amp;#39;user&amp;#39;&lt;/span&gt;], &lt;span class=&quot;hljs-function&quot;&gt;() =&amp;gt;&lt;/span&gt; userService.&lt;span class=&quot;hljs-title function_&quot;&gt;getCurrentUser&lt;/span&gt;());&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;7&quot;&gt;}&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;React 没有 DI 容器。&amp;quot;依赖注入&amp;quot;通过模块导入、Context API、或自定义 Hook 实现。这些全部是&lt;strong&gt;运行时约定&lt;/strong&gt;，没有任何编译期验证。你可以轻易忘记包裹 Provider、可以在 Hook 中 import 错误的服务实现——这些错误要到运行时才暴露。&lt;/p&gt;&lt;p&gt;&lt;strong&gt;这不是 React 的缺陷，而是 JavaScript 生态的设计考量&lt;/strong&gt;——灵活性优先于安全性。React 团队相信，通过 ESLint 规则（如&amp;nbsp;&lt;code&gt;react-hooks/exhaustive-deps&lt;/code&gt;）、TypeScript 类型、和良好的工程实践，可以在不引入 DI 容器的情况下管理依赖。这种思路在小型到中型的前端项目中工作良好，但在大型、长生命周期的企业级应用中，C# DI 容器的显式注册和生命周期管理提供了更强的架构约束。&lt;/p&gt;&lt;p&gt;&lt;strong&gt;状态管理&lt;/strong&gt;：&lt;/p&gt;&lt;p&gt;Blazor 的状态管理通过&lt;strong&gt;级联参数（Cascading Parameters）&lt;/strong&gt; 和&lt;strong&gt;服务（Services）&lt;/strong&gt; 实现。一个&amp;nbsp;&lt;code&gt;AppState&lt;/code&gt;&amp;nbsp;服务注册为 Scoped 生命周期，在用户的整个会话中保持状态。组件通过注入这个服务来访问和修改状态。状态变更通过&amp;nbsp;&lt;code&gt;StateHasChanged()&lt;/code&gt;&amp;nbsp;触发重新渲染。&lt;/p&gt;&lt;p&gt;React 的状态管理从&amp;nbsp;&lt;code&gt;useState&lt;/code&gt;&amp;nbsp;到 Redux 到 Zustand 到 Jotai，经历了漫长的探索之路。React 的哲学是&lt;strong&gt;状态应该尽可能局部化&lt;/strong&gt;，只在必要的内容才会提升到共享层。Blazor 的哲学更接近&lt;strong&gt;传统的 MVC/MVVM&lt;/strong&gt;：有一个中央状态服务（类似 ViewModel），组件订阅它。&lt;/p&gt;&lt;p&gt;&lt;strong&gt;没有绝对的好坏，只有场景适配&lt;/strong&gt;。React 的细粒度状态管理在高度交互的 UI（如设计工具、游戏界面）中有优势，因为不必要的重渲染可以被精确控制。Blazor 的中央状态服务在数据密集型 CRUD 应用中有优势，因为状态逻辑集中、易于测试和审计。&lt;/p&gt;&lt;hr/&gt;&lt;div style=&quot;text-align:right;&quot;&gt;&lt;a rel=&quot;nofollow noopener&quot; href=&quot;https://www.cnblogs.com/wjszxli/p/20206652#_labelTop&quot; style=&quot;color:#f68a33&quot;&gt;回到顶部&lt;/a&gt;&lt;a rel=&quot;nofollow noopener&quot; name=&quot;_label4&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;h2 id=&quot;五从像素到架构的范式转换&quot;&gt;五、从像素到架构的范式转换&lt;/h2&gt;&lt;p&gt;&lt;a rel=&quot;nofollow noopener&quot; name=&quot;_label4_0&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;h3 id=&quot;51-前端思维的本质在不确定性中构建确定性体验&quot;&gt;5.1 前端思维的本质：在不确定性中构建确定性体验&lt;/h3&gt;&lt;p&gt;前端开发的核心挑战不是&amp;quot;写出正确的代码&amp;quot;，而是&lt;strong&gt;在一个充满不确定性的环境中，为用户提供确定性的体验&lt;/strong&gt;。这种不确定性来自：&lt;/p&gt;&lt;p&gt;&lt;strong&gt;运行时环境的不确定性&lt;/strong&gt;：&lt;/p&gt;&lt;ul class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;4 种主流浏览器（Chrome、Safari、Firefox、Edge）× 多个版本 × 不同操作系统（不过有些后台系统也可能只考虑 Chrome）；&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;移动设备的 GPU 能力、内存限制、CPU 性能差异巨大&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;网络条件从千兆光纤到 2G 弱网不等&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;用户的辅助技术（屏幕阅读器、高对比度模式、键盘导航）&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;输入数据的不确定性&lt;/strong&gt;：&lt;/p&gt;&lt;ul class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;API 返回的数据结构可能在版本迭代中变化&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;用户输入的不可预测性（XSS、注入攻击）&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;第三方脚本（广告、分析、客服插件）可能污染全局环境&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;上面的这种情况下也让前端的思维模式有下面的特点：&lt;/p&gt;&lt;p&gt;&lt;strong&gt;防御性编程（Defensive Programming）&lt;/strong&gt; 。我们永远不会假设&amp;quot;这个 API 字段一定存在&amp;quot;——我们需要默认值、空值检查、错误边界（Error Boundaries）、降级策略。React 的&amp;nbsp;&lt;code&gt;Suspense&lt;/code&gt;&amp;nbsp;和&amp;nbsp;&lt;code&gt;Error Boundary&lt;/code&gt;&amp;nbsp;就是防御性思维在框架层面的体现。&lt;/p&gt;&lt;p&gt;&lt;strong&gt;渐进增强（Progressive Enhancement）&lt;/strong&gt; 。核心功能必须在最差环境下也能工作，高级特性是&amp;quot;锦上添花&amp;quot;。Server-Side Rendering 的首要目标不是性能，而是确保 JavaScript 失败时用户仍能看到内容。&lt;/p&gt;&lt;p&gt;&lt;strong&gt;局部性原理（Locality Principle）&lt;/strong&gt; 。好的前端代码将状态、逻辑和 UI 
尽可能地局部化。React 的组件化、Hooks 的组合模式、CSS Modules 
的样式隔离——都是在控制&amp;quot;影响范围&amp;quot;。前端系统之所以复杂，很大程度上是因为状态散落在 URL、DOM、React State、Redux 
Store、localStorage、Service Worker 等数十个位置。&lt;/p&gt;&lt;p&gt;&lt;a rel=&quot;nofollow noopener&quot; name=&quot;_label4_1&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;h3 id=&quot;52-后端思维的本质在复杂度中维护确定性的系统行为&quot;&gt;5.2 后端思维的本质：在复杂度中维护确定性的系统行为&lt;/h3&gt;&lt;p&gt;后端开发的核心挑战是&lt;strong&gt;当系统复杂度超过人类心智容量时，如何保证系统的行为是可预测、可维护、可扩展的&lt;/strong&gt;。这种复杂度来自：&lt;/p&gt;&lt;p&gt;&lt;strong&gt;规模的复杂度&lt;/strong&gt;：&lt;/p&gt;&lt;ul class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;百万级并发的请求处理&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;TB/PB 级的数据存储和查询&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;数百个微服务的分布式协作&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;时间的复杂度&lt;/strong&gt;：&lt;/p&gt;&lt;ul class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;代码需要被维护 5 年、10 年、甚至更久&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;团队成员的更替、业务需求的演进&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;技术债务的累积和偿还&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;一致性的复杂度&lt;/strong&gt;：&lt;/p&gt;&lt;ul class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;分布式事务的 ACID 保证&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;缓存与数据库的一致性&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;多个微服务间的数据同步&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;后端工程师的思维模式因此演化出以下特征&lt;/strong&gt;：&lt;/p&gt;&lt;p&gt;&lt;strong&gt;契约式编程（Contract-Based Programming）&lt;/strong&gt; 。接口、抽象类、契约测试——后端系统通过显式契约来隔离变化。C# 的&amp;nbsp;&lt;code&gt;interface&lt;/code&gt;&amp;nbsp;不是&amp;quot;可选项&amp;quot;，而是架构的基石。依赖注入容器强制要求&amp;quot;依赖抽象而非具体实现&amp;quot;，这使得单元测试（通过 Mock 替换真实依赖）成为可能。&lt;/p&gt;&lt;p&gt;&lt;strong&gt;分层架构（Layered Architecture）&lt;/strong&gt; 。几乎每一个 .NET 项目都遵循某种分层模式：&lt;/p&gt;&lt;pre class=&quot;highlighter-hljs&quot; data-mac-style=&quot;true&quot;&gt;1234567Presentation&amp;nbsp;Layer&amp;nbsp;(Controllers/Razor&amp;nbsp;Pages)↓Application&amp;nbsp;Layer&amp;nbsp;(Services/MediatR&amp;nbsp;Handlers)↓Domain&amp;nbsp;Layer&amp;nbsp;(Entities/Value&amp;nbsp;Objects/Domain&amp;nbsp;Services)↓Infrastructure&amp;nbsp;Layer&amp;nbsp;(Repositories/DbContext/External&amp;nbsp;APIs)&lt;/pre&gt;&lt;p&gt;每一层只依赖下一层的抽象（接口），不知道具体实现。这种分层在小型项目中可能显得&amp;quot;过度工程&amp;quot;，但在大型项目中是控制复杂度的关键。&lt;/p&gt;&lt;p&gt;&lt;strong&gt;CQRS 与命令查询职责分离&lt;/strong&gt;：&lt;/p&gt;&lt;pre class=&quot;highlighter-hljs&quot; data-mac-style=&quot;true&quot;&gt;&lt;ul class=&quot;awes-linenumber list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;1&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;2&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;3&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;4&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;5&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;6&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;7&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;8&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;9&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;code class=&quot;highlighter-hljs hljs language-csharp hljs-line-numbers&quot;&gt;&lt;table class=&quot;hljs-ln&quot;&gt;&lt;tbody&gt;&lt;tr class=&quot;firstRow&quot;&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;1&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;// MediatR 实现 CQRS&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;2&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;GetUserQuery&lt;/span&gt; : &lt;span class=&quot;hljs-title&quot;&gt;IRequest&lt;/span&gt;&amp;lt;&lt;span class=&quot;hljs-title&quot;&gt;UserDto&lt;/span&gt;&amp;gt; { &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;int&lt;/span&gt; Id { &lt;span class=&quot;hljs-keyword&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;hljs-keyword&quot;&gt;set&lt;/span&gt;; } }&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;3&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;CreateUserCommand&lt;/span&gt; : &lt;span class=&quot;hljs-title&quot;&gt;IRequest&lt;/span&gt;&amp;lt;&lt;span class=&quot;hljs-title&quot;&gt;int&lt;/span&gt;&amp;gt; { &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;string&lt;/span&gt; Name { &lt;span class=&quot;hljs-keyword&quot;&gt;get&lt;/span&gt;; &lt;span class=&quot;hljs-keyword&quot;&gt;set&lt;/span&gt;; } }&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;4&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;5&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;// 查询：只读，可以走缓存、读副本&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;6&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;GetUserHandler&lt;/span&gt; : &lt;span class=&quot;hljs-title&quot;&gt;IRequestHandler&lt;/span&gt;&amp;lt;&lt;span class=&quot;hljs-title&quot;&gt;GetUserQuery&lt;/span&gt;, &lt;span class=&quot;hljs-title&quot;&gt;UserDto&lt;/span&gt;&amp;gt; { ... }&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;7&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;8&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;// 命令：写入，触发业务规则、事务、领域事件&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;hljs-ln-line hljs-ln-code&quot; data-line-number=&quot;9&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;CreateUserHandler&lt;/span&gt; : &lt;span class=&quot;hljs-title&quot;&gt;IRequestHandler&lt;/span&gt;&amp;lt;&lt;span class=&quot;hljs-title&quot;&gt;CreateUserCommand&lt;/span&gt;, &lt;span class=&quot;hljs-title&quot;&gt;int&lt;/span&gt;&amp;gt; { ... }&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;当我第一次用 MediatR 实现 CQRS 时，我突然理解了 React 的&amp;quot;数据获取与状态更新分离&amp;quot;的深层含义。React Query 的&amp;nbsp;&lt;code&gt;useQuery&lt;/code&gt;（读取）和&amp;nbsp;&lt;code&gt;useMutation&lt;/code&gt;（写入）本质上是在前端世界中应用 CQRS 原则——只是前端通常没有意识到这个连接。&lt;/p&gt;&lt;p&gt;&lt;a rel=&quot;nofollow noopener&quot; name=&quot;_label4_2&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;h3 id=&quot;53-两种思维的碰撞与融合&quot;&gt;5.3 两种思维的碰撞与融合&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;状态管理的殊途同归&lt;/strong&gt;：&lt;/p&gt;&lt;p&gt;Redux 的三原则（单一数据源、State 只读、使用纯函数修改）与后端 Event Sourcing（事件溯源）架构惊人地相似：&lt;/p&gt;&lt;pre class=&quot;highlighter-hljs&quot; data-mac-style=&quot;true&quot;&gt;12345678Redux:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Event&amp;nbsp;Sourcing:Action&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Command/Event↓&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;↓Reducer&amp;nbsp;(纯函数)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Event&amp;nbsp;Handler&amp;nbsp;(纯函数)↓&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;↓New&amp;nbsp;State&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;New&amp;nbsp;State&amp;nbsp;/&amp;nbsp;Event&amp;nbsp;Stream↓&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;↓Store&amp;nbsp;(单一数据源)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Event&amp;nbsp;Store&amp;nbsp;(单一事实来源)&lt;/pre&gt;&lt;p&gt;Redux 的作者 Dan Abramov 并没有声称借鉴了 Event Sourcing，但好的架构模式是跨领域的——它们都是在解决&amp;quot;如何管理复杂状态变更&amp;quot;这一根本问题。&lt;/p&gt;&lt;p&gt;&lt;strong&gt;前端借鉴后端&lt;/strong&gt;：&lt;/p&gt;&lt;ul class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;React Server Components&lt;/strong&gt;&amp;nbsp;→ 借鉴了后端的&amp;quot;服务端模板渲染&amp;quot;思想，但保留了组件模型&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;tRPC&lt;/strong&gt;&amp;nbsp;→ 将后端 API 定义直接暴露给前端，消除了 REST/GraphQL 的&amp;quot;契约翻译层&amp;quot;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Next.js API Routes + Server Actions&lt;/strong&gt;&amp;nbsp;→ 前端框架直接拥有后端能力，前后端边界模糊&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;后端借鉴前端&lt;/strong&gt;：&lt;/p&gt;&lt;ul class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;ASP.NET Core Minimal APIs&lt;/strong&gt;&amp;nbsp;→ 受到 Express.js 等前端友好型后端框架的影响，减少 ceremony&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;.NET Hot Reload&lt;/strong&gt;&amp;nbsp;→ 借鉴了前端 HMR 的开发体验&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong&gt;Blazor&lt;/strong&gt;&amp;nbsp;→ 直接采用前端组件模型&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;归根结底&lt;/strong&gt;：前端和后端的&amp;quot;思维差异&amp;quot;不是本质性的，而是&lt;strong&gt;由平台约束和历史路径塑造的&lt;/strong&gt;。浏览器环境的碎片化迫使前端演化出防御性、渐进增强的思维；服务器环境的规模化迫使后端演化出契约式、分层架构的思维。当技术平台演化（如
 WebAssembly 模糊了前后端边界、Edge Computing 让服务器代码运行在用户附近），两种思维正在快速融合。&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Sat, 30 May 2026 15:30:09 +0800</pubDate></item><item><title>vue3-antdv-admin：可能是 Vue3 后台管理系统最完整的开源方案</title><link>https://www.codepub.top/post/468.html</link><description>&lt;section style=&quot;font-size: 15.2px;font-weight: 400;font-family: -apple-system, &amp;#39;HarmonyOS Sans SC&amp;#39;, &amp;#39;PingFang SC&amp;#39;, &amp;#39;Microsoft YaHei&amp;#39;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(31, 41, 51);background-color: rgba(0, 0, 0, 0);margin: 0px 0px 17.48px;padding: 0px;border: 0px solid rgb(229, 231, 235);border-radius: 0px;text-align: justify;display: block;width: 678px;max-width: 680px;overflow: visible;overflow-wrap: normal;white-space: normal;visibility: visible&quot;&gt;&lt;span style=&quot;visibility: visible&quot;&gt;做后台管理系统，前端绕不开三个问题：&lt;/span&gt;&lt;strong style=&quot;font-size: 15.2px;font-weight: 700;font-family: -apple-system, &amp;#39;HarmonyOS Sans SC&amp;#39;, &amp;#39;PingFang SC&amp;#39;, &amp;#39;Microsoft YaHei&amp;#39;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(26, 68, 128);background-color: rgba(0, 0, 0, 0);padding: 0px;border: 0px solid rgb(229, 231, 235);border-radius: 0px;text-align: justify;display: inline;width: auto;max-width: none;overflow: visible;overflow-wrap: normal;white-space: normal;visibility: visible&quot;&gt;&lt;span style=&quot;font-size: 15.2px;font-weight: 700;font-family: -apple-system, &amp;#39;HarmonyOS Sans SC&amp;#39;, &amp;#39;PingFang SC&amp;#39;, &amp;#39;Microsoft YaHei&amp;#39;, sans-serif;font-style: normal;line-height: 28.576px;color: #1A4480;background-color: ;padding: 0px;border: 0px solid #E5E7EB;border-radius: 0px;text-align: justify;display: inline;width: auto;max-width: none;overflow: visible;overflow-wrap: normal;visibility: visible&quot;&gt;表单怎么管&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;font-size: 15.2px;font-weight: 700;font-family: -apple-system, &amp;#39;HarmonyOS Sans SC&amp;#39;, &amp;#39;PingFang SC&amp;#39;, &amp;#39;Microsoft YaHei&amp;#39;, sans-serif;font-style: normal;line-height: 28.576px;color: #1A4480;background-color: ;padding: 0px;border: 0px solid #E5E7EB;border-radius: 0px;text-align: justify;display: inline;width: auto;max-width: none;overflow: visible;overflow-wrap: normal;visibility: visible&quot;&gt;，&lt;/span&gt;&lt;strong style=&quot;font-size: 15.2px;font-weight: 700;font-family: -apple-system, &amp;#39;HarmonyOS Sans SC&amp;#39;, &amp;#39;PingFang SC&amp;#39;, &amp;#39;Microsoft YaHei&amp;#39;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(26, 68, 128);background-color: rgba(0, 0, 0, 0);padding: 0px;border: 0px solid rgb(229, 231, 235);border-radius: 0px;text-align: justify;display: inline;width: auto;max-width: none;overflow: visible;overflow-wrap: normal;white-space: normal;visibility: visible&quot;&gt;&lt;span style=&quot;font-size: 15.2px;font-weight: 700;font-family: -apple-system, &amp;#39;HarmonyOS Sans SC&amp;#39;, &amp;#39;PingFang SC&amp;#39;, &amp;#39;Microsoft YaHei&amp;#39;, sans-serif;font-style: normal;line-height: 28.576px;color: #1A4480;background-color: ;padding: 0px;border: 0px solid #E5E7EB;border-radius: 0px;text-align: justify;display: inline;width: auto;max-width: none;overflow: visible;overflow-wrap: normal;visibility: visible&quot;&gt;表格怎么管&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;font-size: 15.2px;font-weight: 700;font-family: -apple-system, &amp;#39;HarmonyOS Sans SC&amp;#39;, &amp;#39;PingFang SC&amp;#39;, &amp;#39;Microsoft YaHei&amp;#39;, sans-serif;font-style: normal;line-height: 28.576px;color: #1A4480;background-color: ;padding: 0px;border: 0px solid #E5E7EB;border-radius: 0px;text-align: justify;display: inline;width: auto;max-width: none;overflow: visible;overflow-wrap: normal;visibility: visible&quot;&gt;，&lt;/span&gt;&lt;strong style=&quot;font-size: 15.2px;font-weight: 700;font-family: -apple-system, &amp;#39;HarmonyOS Sans SC&amp;#39;, &amp;#39;PingFang SC&amp;#39;, &amp;#39;Microsoft YaHei&amp;#39;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(26, 68, 128);background-color: rgba(0, 0, 0, 0);padding: 0px;border: 0px solid rgb(229, 231, 235);border-radius: 0px;text-align: justify;display: inline;width: auto;max-width: none;overflow: visible;overflow-wrap: normal;white-space: normal;visibility: visible&quot;&gt;&lt;span style=&quot;font-size: 15.2px;font-weight: 700;font-family: -apple-system, &amp;#39;HarmonyOS Sans SC&amp;#39;, &amp;#39;PingFang SC&amp;#39;, &amp;#39;Microsoft YaHei&amp;#39;, sans-serif;font-style: normal;line-height: 28.576px;color: #1A4480;background-color: ;padding: 0px;border: 0px solid #E5E7EB;border-radius: 0px;text-align: justify;display: inline;width: auto;max-width: none;overflow: visible;overflow-wrap: normal;visibility: visible&quot;&gt;权限怎么做&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;visibility: visible&quot;&gt;。&lt;/span&gt;&lt;/section&gt;&lt;p style=&quot;font-size: 15.2px;font-weight: 400;font-family: -apple-system, &amp;#39;HarmonyOS Sans SC&amp;#39;, &amp;#39;PingFang SC&amp;#39;, &amp;#39;Microsoft YaHei&amp;#39;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(31, 41, 51);background-color: rgba(0, 0, 0, 0);margin: 0px 0px 17.48px;padding: 0px;border: 0px solid rgb(229, 231, 235);border-radius: 0px;text-align: justify;display: block;width: 678px;max-width: 680px;overflow: visible;overflow-wrap: normal;white-space: normal;visibility: visible&quot;&gt;&lt;span style=&quot;visibility: visible&quot;&gt;这三个问题，每个都能单独写一篇文章。每个团队的做法也不一样：有的手写一堆表单组件，有的用第三方表格库封装，有的权限控制写死在代码里——维护成本高，扩展性差，新人接手更是头疼。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;font-size: 15.2px;font-weight: 400;font-family: -apple-system, &amp;#39;HarmonyOS Sans SC&amp;#39;, &amp;#39;PingFang SC&amp;#39;, &amp;#39;Microsoft YaHei&amp;#39;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(31, 41, 51);background-color: rgba(0, 0, 0, 0);margin: 0px 0px 17.48px;padding: 0px;border: 0px solid rgb(229, 231, 235);border-radius: 0px;text-align: justify;display: block;width: 678px;max-width: 680px;overflow: visible;overflow-wrap: normal;white-space: normal;visibility: visible&quot;&gt;&lt;strong style=&quot;font-size: 15.2px;font-weight: 700;font-family: -apple-system, &amp;#39;HarmonyOS Sans SC&amp;#39;, &amp;#39;PingFang SC&amp;#39;, &amp;#39;Microsoft YaHei&amp;#39;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(26, 68, 128);background-color: rgba(0, 0, 0, 0);padding: 0px;border: 0px solid rgb(229, 231, 235);border-radius: 0px;text-align: justify;display: inline;width: auto;max-width: none;overflow: visible;overflow-wrap: normal;white-space: normal;visibility: visible&quot;&gt;&lt;span style=&quot;visibility: visible&quot;&gt;vue3-antdv-admin&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;visibility: visible&quot;&gt;&amp;nbsp;是一个基于 Vue3 + Ant Design Vue 的后台管理系统，它把这三个问题的解决方案都做好了，而且不是简单堆砌，是真正能用于生产级别的实现。&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;section class=&quot;code-snippet__fix code-snippet__js&quot; style=&quot;visibility: visible&quot;&gt;&lt;ul class=&quot;code-snippet__line-index code-snippet__js list-paddingleft-2&quot; style=&quot;visibility: visible&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;pre data-lang=&quot;javascript&quot; style=&quot;visibility: visible&quot;&gt;https://github.com/buqiyuan/vue3-antdv-admin&lt;/pre&gt;&lt;/section&gt;&lt;section style=&quot;text-align: center;visibility: visible&quot;&gt;&lt;img class=&quot;rich_pages wxw-img&quot; data-aistatus=&quot;1&quot; data-imgfileid=&quot;100001235&quot; data-s=&quot;300,640&quot; data-src=&quot;https://mmbiz.qpic.cn/mmbiz_png/GrHt0WCylYkWVpRengLP44ANwVZIpyuy4uTUn9nKlC2Em416vNqb4Kn9WX4icfNhUvHSC3w03o44sQjRgbALKEzC13ntqz7VSia84luEkAYIY/640?wx_fmt=png&amp;amp;from=appmsg&amp;amp;watermark=1#imgIndex=0&quot; data-type=&quot;png&quot; type=&quot;block&quot; data-original-style=&quot;null&quot; data-index=&quot;3&quot; data-ratio=&quot;0.4740740740740741&quot; data-w=&quot;1080&quot; src=&quot;https://mmbiz.qpic.cn/mmbiz_png/GrHt0WCylYkWVpRengLP44ANwVZIpyuy4uTUn9nKlC2Em416vNqb4Kn9WX4icfNhUvHSC3w03o44sQjRgbALKEzC13ntqz7VSia84luEkAYIY/640?wx_fmt=png&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1&amp;watermark=1#imgIndex=0&quot; _width=&quot;677px&quot; style=&quot;height: auto !important;visibility: visible !important;width: 677px !important&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780111455964&quot; data-report-img-idx=&quot;0&quot; data-fail=&quot;0&quot;/&gt;&lt;/section&gt;&lt;/p&gt;&lt;h2 style=&quot;font-size: 19.76px;font-weight: 700;font-family: -apple-system, &amp;#39;HarmonyOS Sans SC&amp;#39;, &amp;#39;PingFang SC&amp;#39;, &amp;#39;Microsoft YaHei&amp;#39;, sans-serif;font-style: normal;line-height: 37.1488px;color: rgb(26, 32, 44);background-color: rgba(0, 0, 0, 0);margin: 31.616px 0px 15.808px;padding: 0px 0px 0px 14px;border-radius: 0px 9px 9px 0px;border-left: 4px solid rgb(26, 68, 128);text-align: start;display: block;width: 678px;max-width: 680px;overflow: visible;overflow-wrap: normal;white-space: normal;visibility: visible&quot;&gt;&lt;span style=&quot;visibility: visible&quot;&gt;它是什么&lt;/span&gt;&lt;/h2&gt;&lt;p style=&quot;font-size: 15.2px;font-weight: 400;font-family: -apple-system, &amp;#39;HarmonyOS Sans SC&amp;#39;, &amp;#39;PingFang SC&amp;#39;, &amp;#39;Microsoft YaHei&amp;#39;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(31, 41, 51);background-color: rgba(0, 0, 0, 0);margin: 0px 0px 17.48px;padding: 0px;border: 0px solid rgb(229, 231, 235);border-radius: 0px;text-align: justify;display: block;width: 678px;max-width: 680px;overflow: visible;overflow-wrap: normal;white-space: normal;visibility: visible&quot;&gt;&lt;span style=&quot;visibility: visible&quot;&gt;vue3-antdv-admin 是一套基于&amp;nbsp;&lt;/span&gt;&lt;strong style=&quot;font-size: 15.2px;font-weight: 700;font-family: -apple-system, &amp;#39;HarmonyOS Sans SC&amp;#39;, &amp;#39;PingFang SC&amp;#39;, &amp;#39;Microsoft YaHei&amp;#39;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(26, 68, 128);background-color: rgba(0, 0, 0, 0);padding: 0px;border: 0px solid rgb(229, 231, 235);border-radius: 0px;text-align: justify;display: inline;width: auto;max-width: none;overflow: visible;overflow-wrap: normal;white-space: normal;visibility: visible&quot;&gt;&lt;span style=&quot;visibility: visible&quot;&gt;Vite5 + Vue3 + Ant Design Vue4 + TypeScript5&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;visibility: visible&quot;&gt;&amp;nbsp;的后台管理前端解决方案。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;font-size: 15.2px;font-weight: 400;font-family: -apple-system, &amp;#39;HarmonyOS Sans SC&amp;#39;, &amp;#39;PingFang SC&amp;#39;, &amp;#39;Microsoft YaHei&amp;#39;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(31, 41, 51);background-color: rgba(0, 0, 0, 0);margin: 0px 0px 17.48px;padding: 0px;border: 0px solid rgb(229, 231, 235);border-radius: 0px;text-align: justify;display: block;width: 678px;max-width: 680px;overflow: visible;overflow-wrap: normal;white-space: normal;visibility: visible&quot;&gt;&lt;span style=&quot;visibility: visible&quot;&gt;它的定位很清晰：&lt;/span&gt;&lt;strong style=&quot;font-size: 15.2px;font-weight: 700;font-family: -apple-system, &amp;#39;HarmonyOS Sans SC&amp;#39;, &amp;#39;PingFang SC&amp;#39;, &amp;#39;Microsoft YaHei&amp;#39;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(26, 68, 128);background-color: rgba(0, 0, 0, 0);padding: 0px;border: 0px solid rgb(229, 231, 235);border-radius: 0px;text-align: justify;display: inline;width: auto;max-width: none;overflow: visible;overflow-wrap: normal;white-space: normal;visibility: visible&quot;&gt;&lt;span style=&quot;visibility: visible&quot;&gt;不做底层轮子，只做上层建筑&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;visibility: visible&quot;&gt;。底层技术栈你说了算（Vue3、TypeScript 这些是固定的），但在业务层面，它提供了：&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;#39;HarmonyOS Sans SC&amp;#39;, &amp;#39;PingFang SC&amp;#39;, &amp;#39;Microsoft YaHei&amp;#39;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 16.72px;margin-bottom:16.72px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-align:start;display:block;width:678px;max-width:680px;overflow:visible;word-wrap:normal;white-space:normal&quot; class=&quot;js_darkmode__17 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section&gt;动态表格（配置化，JSON 驱动）&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 16.72px;margin-top:0px;margin-bottom:16.72px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:start;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__17 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section&gt;动态表单（配置化，JSON 驱动）&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;动态路由（权限驱动，菜单即路由）&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;按钮级权限控制&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;多标签页路由&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;国际化（i18n）&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;可视化配置面板&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 17.48px;margin-top:0px;margin-bottom:17.48px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__25&quot;&gt;换句话说：它把后台管理系统里 80% 的重复工作做成了配置化，剩下的 20% 特殊逻辑你再自己写。&lt;/p&gt;&lt;p&gt;&lt;section style=&quot;text-align: center;&quot;&gt;&lt;img class=&quot;rich_pages wxw-img&quot; data-aistatus=&quot;1&quot; data-imgfileid=&quot;100001231&quot; data-ratio=&quot;0.6666666666666666&quot; data-s=&quot;300,640&quot; data-src=&quot;https://mmbiz.qpic.cn/mmbiz_png/GrHt0WCylYnLt2UdtgvA4gyTC2bfWWjJ787mRnPZmFWVBhj6IlBhRjiahicZn1hg5ic0MiatpVntFhE5l92LdiaAbmhHlmOYtx7VzSfqm6UDZ7X0/640?wx_fmt=png&amp;amp;from=appmsg&amp;amp;watermark=1#imgIndex=1&quot; data-type=&quot;png&quot; data-w=&quot;1080&quot; type=&quot;block&quot; data-original-style=&quot;null&quot; data-index=&quot;4&quot; src=&quot;https://mmbiz.qpic.cn/mmbiz_png/GrHt0WCylYnLt2UdtgvA4gyTC2bfWWjJ787mRnPZmFWVBhj6IlBhRjiahicZn1hg5ic0MiatpVntFhE5l92LdiaAbmhHlmOYtx7VzSfqm6UDZ7X0/640?wx_fmt=png&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1&amp;watermark=1#imgIndex=1&quot; _width=&quot;677px&quot; style=&quot;height: auto !important; visibility: visible !important; width: 677px !important;&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780111630764&quot; data-report-img-idx=&quot;1&quot; data-fail=&quot;0&quot;/&gt;&lt;/section&gt;&lt;/p&gt;&lt;h2 style=&quot;font-size:19.76px;font-weight:700;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:37.1488px;color:rgb(26, 32, 44);background-color:rgba(0, 0, 0, 0);margin:31.616px 0px 15.808px;margin-top:31.616px;margin-bottom:15.808px;margin-left:0px;margin-right:0px;padding:0px 0px 0px 14px;padding-top:0px;padding-bottom:0px;padding-left:14px;padding-right:0px;border-radius:0px 9px 9px 0px;border-left:4px solid rgb(26, 68, 128);text-decoration:none;text-align:start;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__26&quot;&gt;技术栈：Vue3 生态全家桶&lt;/h2&gt;&lt;p style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 17.48px;margin-top:0px;margin-bottom:17.48px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__27&quot;&gt;这个项目的技术选型很有诚意，用的都是业界主流方案：&lt;/p&gt;&lt;table class=&quot;js_darkmode__28&quot; width=&quot;678&quot;&gt;&lt;thead&gt;&lt;tr style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:start;display:table-row;width:676px;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__29 firstRow&quot;&gt;&lt;th style=&quot;font-size: 15.2px;font-weight: 600;font-family: -apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(26, 32, 44);background-color: rgba(26, 68, 128, 0.12);margin: 0px;padding: 12px 16px;border-radius: 0px;border-left: 0px solid rgb(229, 231, 235);text-decoration: none;text-align: center;display: table-cell;max-width: none;overflow: visible;word-break: normal;overflow-wrap: normal;white-space: normal;&quot; class=&quot;js_darkmode__30&quot;&gt;&lt;section&gt;分类&lt;/section&gt;&lt;/th&gt;&lt;th style=&quot;font-size: 15.2px;font-weight: 600;font-family: -apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(26, 32, 44);background-color: rgba(26, 68, 128, 0.12);margin: 0px;padding: 12px 16px;border-radius: 0px;border-left: 0px solid rgb(229, 231, 235);text-decoration: none;text-align: center;display: table-cell;max-width: none;overflow: visible;word-break: normal;overflow-wrap: normal;white-space: normal;&quot; class=&quot;js_darkmode__31&quot;&gt;&lt;section&gt;技术&lt;/section&gt;&lt;/th&gt;&lt;th style=&quot;font-size: 15.2px;font-weight: 600;font-family: -apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(26, 32, 44);background-color: rgba(26, 68, 128, 0.12);margin: 0px;padding: 12px 16px;border-radius: 0px;border-left: 0px solid rgb(229, 231, 235);text-decoration: none;text-align: center;display: table-cell;max-width: none;overflow: visible;word-break: normal;overflow-wrap: normal;white-space: normal;&quot; class=&quot;js_darkmode__32&quot;&gt;&lt;section&gt;说明&lt;/section&gt;&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:start;display:table-row;width:676px;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__33&quot;&gt;&lt;td style=&quot;font-size: 15.2px;font-weight: 400;font-family: -apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(31, 41, 51);background-color: rgb(247, 248, 251);margin: 0px;padding: 12px 16px;border-radius: 0px;border-left: 0px solid rgb(229, 231, 235);text-decoration: none;text-align: start;display: table-cell;max-width: none;overflow: visible;word-break: normal;overflow-wrap: normal;white-space: normal;&quot; class=&quot;js_darkmode__34&quot;&gt;&lt;section&gt;构建工具&lt;/section&gt;&lt;/td&gt;&lt;td style=&quot;font-size: 15.2px;font-weight: 400;font-family: -apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(31, 41, 51);background-color: rgb(247, 248, 251);margin: 0px;padding: 12px 16px;border-radius: 0px;border-left: 0px solid rgb(229, 231, 235);text-decoration: none;text-align: start;display: table-cell;max-width: none;overflow: visible;word-break: normal;overflow-wrap: normal;white-space: normal;&quot; class=&quot;js_darkmode__35&quot;&gt;&lt;section&gt;Vite 5.x&lt;/section&gt;&lt;/td&gt;&lt;td style=&quot;font-size: 15.2px;font-weight: 400;font-family: -apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(31, 41, 51);background-color: rgb(247, 248, 251);margin: 0px;padding: 12px 16px;border-radius: 0px;border-left: 0px solid rgb(229, 231, 235);text-decoration: none;text-align: start;display: table-cell;max-width: none;overflow: visible;word-break: normal;overflow-wrap: normal;white-space: normal;&quot; class=&quot;js_darkmode__36&quot;&gt;&lt;section&gt;快速冷启动，HMR 优秀&lt;/section&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:start;display:table-row;width:676px;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__37&quot;&gt;&lt;td style=&quot;font-size: 15.2px;font-weight: 400;font-family: -apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(31, 41, 51);background-color: rgb(247, 248, 251);margin: 0px;padding: 12px 16px;border-radius: 0px;border-left: 0px solid rgb(229, 231, 235);text-decoration: none;text-align: start;display: table-cell;max-width: none;overflow: visible;word-break: normal;overflow-wrap: normal;white-space: normal;&quot; class=&quot;js_darkmode__38&quot;&gt;&lt;section&gt;框架&lt;/section&gt;&lt;/td&gt;&lt;td style=&quot;font-size: 15.2px;font-weight: 400;font-family: -apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(31, 41, 51);background-color: rgb(247, 248, 251);margin: 0px;padding: 12px 16px;border-radius: 0px;border-left: 0px solid rgb(229, 231, 235);text-decoration: none;text-align: start;display: table-cell;max-width: none;overflow: visible;word-break: normal;overflow-wrap: normal;white-space: normal;&quot; class=&quot;js_darkmode__39&quot;&gt;&lt;section&gt;Vue 3.x&lt;/section&gt;&lt;/td&gt;&lt;td style=&quot;font-size: 15.2px;font-weight: 400;font-family: -apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(31, 41, 51);background-color: rgb(247, 248, 251);margin: 0px;padding: 12px 16px;border-radius: 0px;border-left: 0px solid rgb(229, 231, 235);text-decoration: none;text-align: start;display: table-cell;max-width: none;overflow: visible;word-break: normal;overflow-wrap: normal;white-space: normal;&quot; class=&quot;js_darkmode__40&quot;&gt;&lt;section&gt;Composition API，灵活组合&lt;/section&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:start;display:table-row;width:676px;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__41&quot;&gt;&lt;td style=&quot;font-size: 15.2px;font-weight: 400;font-family: -apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(31, 41, 51);background-color: rgb(247, 248, 251);margin: 0px;padding: 12px 16px;border-radius: 0px;border-left: 0px solid rgb(229, 231, 235);text-decoration: none;text-align: start;display: table-cell;max-width: none;overflow: visible;word-break: normal;overflow-wrap: normal;white-space: normal;&quot; class=&quot;js_darkmode__42&quot;&gt;&lt;section&gt;UI 库&lt;/section&gt;&lt;/td&gt;&lt;td style=&quot;font-size: 15.2px;font-weight: 400;font-family: -apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(31, 41, 51);background-color: rgb(247, 248, 251);margin: 0px;padding: 12px 16px;border-radius: 0px;border-left: 0px solid rgb(229, 231, 235);text-decoration: none;text-align: start;display: table-cell;max-width: none;overflow: visible;word-break: normal;overflow-wrap: normal;white-space: normal;&quot; class=&quot;js_darkmode__43&quot;&gt;&lt;section&gt;Ant Design Vue 4.x&lt;/section&gt;&lt;/td&gt;&lt;td style=&quot;font-size: 15.2px;font-weight: 400;font-family: -apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(31, 41, 51);background-color: rgb(247, 248, 251);margin: 0px;padding: 12px 16px;border-radius: 0px;border-left: 0px solid rgb(229, 231, 235);text-decoration: none;text-align: start;display: table-cell;max-width: none;overflow: visible;word-break: normal;overflow-wrap: normal;white-space: normal;&quot; class=&quot;js_darkmode__44&quot;&gt;&lt;section&gt;企业级 UI 组件库&lt;/section&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:start;display:table-row;width:676px;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__45&quot;&gt;&lt;td style=&quot;font-size: 15.2px;font-weight: 400;font-family: -apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(31, 41, 51);background-color: rgb(247, 248, 251);margin: 0px;padding: 12px 16px;border-radius: 0px;border-left: 0px solid rgb(229, 231, 235);text-decoration: none;text-align: start;display: table-cell;max-width: none;overflow: visible;word-break: normal;overflow-wrap: normal;white-space: normal;&quot; class=&quot;js_darkmode__46&quot;&gt;&lt;section&gt;语言&lt;/section&gt;&lt;/td&gt;&lt;td style=&quot;font-size: 15.2px;font-weight: 400;font-family: -apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(31, 41, 51);background-color: rgb(247, 248, 251);margin: 0px;padding: 12px 16px;border-radius: 0px;border-left: 0px solid rgb(229, 231, 235);text-decoration: none;text-align: start;display: table-cell;max-width: none;overflow: visible;word-break: normal;overflow-wrap: normal;white-space: normal;&quot; class=&quot;js_darkmode__47&quot;&gt;&lt;section&gt;TypeScript 5.x&lt;/section&gt;&lt;/td&gt;&lt;td style=&quot;font-size: 15.2px;font-weight: 400;font-family: -apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(31, 41, 51);background-color: rgb(247, 248, 251);margin: 0px;padding: 12px 16px;border-radius: 0px;border-left: 0px solid rgb(229, 231, 235);text-decoration: none;text-align: start;display: table-cell;max-width: none;overflow: visible;word-break: normal;overflow-wrap: normal;white-space: normal;&quot; class=&quot;js_darkmode__48&quot;&gt;&lt;section&gt;类型安全&lt;/section&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:start;display:table-row;width:676px;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__49&quot;&gt;&lt;td style=&quot;font-size: 15.2px;font-weight: 400;font-family: -apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(31, 41, 51);background-color: rgb(247, 248, 251);margin: 0px;padding: 12px 16px;border-radius: 0px;border-left: 0px solid rgb(229, 231, 235);text-decoration: none;text-align: start;display: table-cell;max-width: none;overflow: visible;word-break: normal;overflow-wrap: normal;white-space: normal;&quot; class=&quot;js_darkmode__50&quot;&gt;&lt;section&gt;状态管理&lt;/section&gt;&lt;/td&gt;&lt;td style=&quot;font-size: 15.2px;font-weight: 400;font-family: -apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(31, 41, 51);background-color: rgb(247, 248, 251);margin: 0px;padding: 12px 16px;border-radius: 0px;border-left: 0px solid rgb(229, 231, 235);text-decoration: none;text-align: start;display: table-cell;max-width: none;overflow: visible;word-break: normal;overflow-wrap: normal;white-space: normal;&quot; class=&quot;js_darkmode__51&quot;&gt;&lt;section&gt;Pinia&lt;/section&gt;&lt;/td&gt;&lt;td style=&quot;font-size: 15.2px;font-weight: 400;font-family: -apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(31, 41, 51);background-color: rgb(247, 248, 251);margin: 0px;padding: 12px 16px;border-radius: 0px;border-left: 0px solid rgb(229, 231, 235);text-decoration: none;text-align: start;display: table-cell;max-width: none;overflow: visible;word-break: normal;overflow-wrap: normal;white-space: normal;&quot; class=&quot;js_darkmode__52&quot;&gt;&lt;section&gt;轻量级，比 Vuex 更现代&lt;/section&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:start;display:table-row;width:676px;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__53&quot;&gt;&lt;td style=&quot;font-size: 15.2px;font-weight: 400;font-family: -apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(31, 41, 51);background-color: rgb(247, 248, 251);margin: 0px;padding: 12px 16px;border-radius: 0px;border-left: 0px solid rgb(229, 231, 235);text-decoration: none;text-align: start;display: table-cell;max-width: none;overflow: visible;word-break: normal;overflow-wrap: normal;white-space: normal;&quot; class=&quot;js_darkmode__54&quot;&gt;&lt;section&gt;路由&lt;/section&gt;&lt;/td&gt;&lt;td style=&quot;font-size: 15.2px;font-weight: 400;font-family: -apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(31, 41, 51);background-color: rgb(247, 248, 251);margin: 0px;padding: 12px 16px;border-radius: 0px;border-left: 0px solid rgb(229, 231, 235);text-decoration: none;text-align: start;display: table-cell;max-width: none;overflow: visible;word-break: normal;overflow-wrap: normal;white-space: normal;&quot; class=&quot;js_darkmode__55&quot;&gt;&lt;section&gt;Vue Router 4.x&lt;/section&gt;&lt;/td&gt;&lt;td style=&quot;font-size: 15.2px;font-weight: 400;font-family: -apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(31, 41, 51);background-color: rgb(247, 248, 251);margin: 0px;padding: 12px 16px;border-radius: 0px;border-left: 0px solid rgb(229, 231, 235);text-decoration: none;text-align: start;display: table-cell;max-width: none;overflow: visible;word-break: normal;overflow-wrap: normal;white-space: normal;&quot; class=&quot;js_darkmode__56&quot;&gt;&lt;section&gt;多标签页支持&lt;/section&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:start;display:table-row;width:676px;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__57&quot;&gt;&lt;td style=&quot;font-size: 15.2px;font-weight: 400;font-family: -apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(31, 41, 51);background-color: rgb(247, 248, 251);margin: 0px;padding: 12px 16px;border-radius: 0px;border-left: 0px solid rgb(229, 231, 235);text-decoration: none;text-align: start;display: table-cell;max-width: none;overflow: visible;word-break: normal;overflow-wrap: normal;white-space: normal;&quot; class=&quot;js_darkmode__58&quot;&gt;&lt;section&gt;图表&lt;/section&gt;&lt;/td&gt;&lt;td style=&quot;font-size: 15.2px;font-weight: 400;font-family: -apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(31, 41, 51);background-color: rgb(247, 248, 251);margin: 0px;padding: 12px 16px;border-radius: 0px;border-left: 0px solid rgb(229, 231, 235);text-decoration: none;text-align: start;display: table-cell;max-width: none;overflow: visible;word-break: normal;overflow-wrap: normal;white-space: normal;&quot; class=&quot;js_darkmode__59&quot;&gt;&lt;section&gt;ECharts + vue-echarts&lt;/section&gt;&lt;/td&gt;&lt;td style=&quot;font-size: 15.2px;font-weight: 400;font-family: -apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(31, 41, 51);background-color: rgb(247, 248, 251);margin: 0px;padding: 12px 16px;border-radius: 0px;border-left: 0px solid rgb(229, 231, 235);text-decoration: none;text-align: start;display: table-cell;max-width: none;overflow: visible;word-break: normal;overflow-wrap: normal;white-space: normal;&quot; class=&quot;js_darkmode__60&quot;&gt;&lt;section&gt;数据可视化&lt;/section&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:start;display:table-row;width:676px;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__61&quot;&gt;&lt;td style=&quot;font-size: 15.2px;font-weight: 400;font-family: -apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(31, 41, 51);background-color: rgb(247, 248, 251);margin: 0px;padding: 12px 16px;border-radius: 0px;border-left: 0px solid rgb(229, 231, 235);text-decoration: none;text-align: start;display: table-cell;max-width: none;overflow: visible;word-break: normal;overflow-wrap: normal;white-space: normal;&quot; class=&quot;js_darkmode__62&quot;&gt;&lt;section&gt;样式&lt;/section&gt;&lt;/td&gt;&lt;td style=&quot;font-size: 15.2px;font-weight: 400;font-family: -apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(31, 41, 51);background-color: rgb(247, 248, 251);margin: 0px;padding: 12px 16px;border-radius: 0px;border-left: 0px solid rgb(229, 231, 235);text-decoration: none;text-align: start;display: table-cell;max-width: none;overflow: visible;word-break: normal;overflow-wrap: normal;white-space: normal;&quot; class=&quot;js_darkmode__63&quot;&gt;&lt;section&gt;UnoCSS&lt;/section&gt;&lt;/td&gt;&lt;td style=&quot;font-size: 15.2px;font-weight: 400;font-family: -apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(31, 41, 51);background-color: rgb(247, 248, 251);margin: 0px;padding: 12px 16px;border-radius: 0px;border-left: 0px solid rgb(229, 231, 235);text-decoration: none;text-align: start;display: table-cell;max-width: none;overflow: visible;word-break: normal;overflow-wrap: normal;white-space: normal;&quot; class=&quot;js_darkmode__64&quot;&gt;&lt;section&gt;原子化 CSS，比 Tailwind 更快&lt;/section&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:start;display:table-row;width:676px;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__65&quot;&gt;&lt;td style=&quot;font-size: 15.2px;font-weight: 400;font-family: -apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(31, 41, 51);background-color: rgb(247, 248, 251);margin: 0px;padding: 12px 16px;border-radius: 0px;border-left: 0px solid rgb(229, 231, 235);text-decoration: none;text-align: start;display: table-cell;max-width: none;overflow: visible;word-break: normal;overflow-wrap: normal;white-space: normal;&quot; class=&quot;js_darkmode__66&quot;&gt;&lt;section&gt;构建&lt;/section&gt;&lt;/td&gt;&lt;td style=&quot;font-size: 15.2px;font-weight: 400;font-family: -apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(31, 41, 51);background-color: rgb(247, 248, 251);margin: 0px;padding: 12px 16px;border-radius: 0px;border-left: 0px solid rgb(229, 231, 235);text-decoration: none;text-align: start;display: table-cell;max-width: none;overflow: visible;word-break: normal;overflow-wrap: normal;white-space: normal;&quot; class=&quot;js_darkmode__67&quot;&gt;&lt;section&gt;NX&lt;/section&gt;&lt;/td&gt;&lt;td style=&quot;font-size: 15.2px;font-weight: 400;font-family: -apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style: normal;line-height: 28.576px;color: rgb(31, 41, 51);background-color: rgb(247, 248, 251);margin: 0px;padding: 12px 16px;border-radius: 0px;border-left: 0px solid rgb(229, 231, 235);text-decoration: none;text-align: start;display: table-cell;max-width: none;overflow: visible;word-break: normal;overflow-wrap: normal;white-space: normal;&quot; class=&quot;js_darkmode__68&quot;&gt;&lt;section&gt;Monorepo 架构管理&lt;/section&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 17.48px;margin-top:0px;margin-bottom:17.48px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__69&quot;&gt;值得注意的是，它采用了&amp;nbsp;&lt;strong style=&quot;font-size:15.2px;font-weight:700;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(26, 68, 128);background-color:rgba(0, 0, 0, 0);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__70&quot;&gt;Monorepo 架构&lt;/strong&gt;，主项目下有多个子包：&lt;/p&gt;&lt;ul style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 16.72px;margin-top:0px;margin-bottom:16.72px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:start;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__71 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;code style=&quot;font-size:13.68px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:25.7184px;color:rgb(199, 37, 78);background-color:rgba(26, 68, 128, 0.08);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:3.42px 6.156px;padding-top:3.42px;padding-bottom:3.42px;padding-left:6.156px;padding-right:6.156px;border:1px solid rgba(26, 68, 128, 0.1);border-radius:6px;border-left:1px solid rgba(26, 68, 128, 0.1);text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__73&quot;&gt;@admin-pkg/components&lt;/code&gt;&lt;/p&gt;&lt;section&gt;&amp;nbsp;— 业务组件库&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;code style=&quot;font-size:13.68px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:25.7184px;color:rgb(199, 37, 78);background-color:rgba(26, 68, 128, 0.08);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:3.42px 6.156px;padding-top:3.42px;padding-bottom:3.42px;padding-left:6.156px;padding-right:6.156px;border:1px solid rgba(26, 68, 128, 0.1);border-radius:6px;border-left:1px solid rgba(26, 68, 128, 0.1);text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__75&quot;&gt;@admin-pkg/vite-plugin-msw&lt;/code&gt;&lt;/p&gt;&lt;section&gt;&amp;nbsp;— &lt;span class=&quot;&quot;&gt;Mock Service Worker&lt;/span&gt; 插件&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;code style=&quot;font-size:13.68px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:25.7184px;color:rgb(199, 37, 78);background-color:rgba(26, 68, 128, 0.08);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:3.42px 6.156px;padding-top:3.42px;padding-bottom:3.42px;padding-left:6.156px;padding-right:6.156px;border:1px solid rgba(26, 68, 128, 0.1);border-radius:6px;border-left:1px solid rgba(26, 68, 128, 0.1);text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__77&quot;&gt;@admin-pkg/vite-plugin-http2-proxy&lt;/code&gt;&lt;/p&gt;&lt;section&gt;&amp;nbsp;— HTTP2 代理插件&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;code style=&quot;font-size:13.68px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:25.7184px;color:rgb(199, 37, 78);background-color:rgba(26, 68, 128, 0.08);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:3.42px 6.156px;padding-top:3.42px;padding-bottom:3.42px;padding-left:6.156px;padding-right:6.156px;border:1px solid rgba(26, 68, 128, 0.1);border-radius:6px;border-left:1px solid rgba(26, 68, 128, 0.1);text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__79&quot;&gt;@admin-pkg/vite-plugin-tinymce-resource&lt;/code&gt;&lt;/p&gt;&lt;section&gt;&amp;nbsp;— 富文本编辑器资源插件&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 17.48px;margin-top:0px;margin-bottom:17.48px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__80&quot;&gt;这种架构让项目扩展性很强，新增功能只需要加一个包。&lt;/p&gt;&lt;p&gt;&lt;section style=&quot;text-align: center;&quot;&gt;&lt;img class=&quot;rich_pages wxw-img&quot; data-aistatus=&quot;1&quot; data-imgfileid=&quot;100001232&quot; data-ratio=&quot;0.6666666666666666&quot; data-s=&quot;300,640&quot; data-src=&quot;https://mmbiz.qpic.cn/mmbiz_png/GrHt0WCylYnnHSodplQftrXKswNSHBIyVE57ULAGSMk8Ck0CXDTbLeibGPicGADz6oQytibsFdJGUOLFoSx1wE8rjuJvrQyyjV7KnfxIJHBeT0/640?wx_fmt=png&amp;amp;from=appmsg&amp;amp;watermark=1#imgIndex=2&quot; data-type=&quot;png&quot; data-w=&quot;1080&quot; type=&quot;block&quot; data-original-style=&quot;null&quot; data-index=&quot;5&quot; src=&quot;https://mmbiz.qpic.cn/mmbiz_png/GrHt0WCylYnnHSodplQftrXKswNSHBIyVE57ULAGSMk8Ck0CXDTbLeibGPicGADz6oQytibsFdJGUOLFoSx1wE8rjuJvrQyyjV7KnfxIJHBeT0/640?wx_fmt=png&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1&amp;watermark=1#imgIndex=2&quot; _width=&quot;677px&quot; style=&quot;height: auto !important; visibility: visible !important; width: 677px !important;&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780111640523&quot; data-report-img-idx=&quot;2&quot; data-fail=&quot;0&quot;/&gt;&lt;/section&gt;&lt;/p&gt;&lt;h2 style=&quot;font-size:19.76px;font-weight:700;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:37.1488px;color:rgb(26, 32, 44);background-color:rgba(0, 0, 0, 0);margin:31.616px 0px 15.808px;margin-top:31.616px;margin-bottom:15.808px;margin-left:0px;margin-right:0px;padding:0px 0px 0px 14px;padding-top:0px;padding-bottom:0px;padding-left:14px;padding-right:0px;border-radius:0px 9px 9px 0px;border-left:4px solid rgb(26, 68, 128);text-decoration:none;text-align:start;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__81&quot;&gt;核心亮点：动态表格与动态表单&lt;/h2&gt;&lt;p style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 17.48px;margin-top:0px;margin-bottom:17.48px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__82&quot;&gt;这是 vue3-antdv-admin 最值得说的两个功能。&lt;/p&gt;&lt;h3 style=&quot;font-size:17.024px;font-weight:600;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:32.0051px;color:rgb(26, 32, 44);background-color:rgba(0, 0, 0, 0);margin:21.28px 0px 10.2144px;margin-top:21.28px;margin-bottom:10.2144px;margin-left:0px;margin-right:0px;padding:0px 0px 0px 16px;padding-top:0px;padding-bottom:0px;padding-left:16px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:start;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__83&quot;&gt;动态表格：配置即页面&lt;/h3&gt;&lt;p style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 17.48px;margin-top:0px;margin-bottom:17.48px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__84&quot;&gt;传统做法：每个列表页都要写&amp;nbsp;&lt;code style=&quot;font-size:13.68px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:25.7184px;color:rgb(199, 37, 78);background-color:rgba(26, 68, 128, 0.08);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:3.42px 6.156px;padding-top:3.42px;padding-bottom:3.42px;padding-left:6.156px;padding-right:6.156px;border:1px solid rgba(26, 68, 128, 0.1);border-radius:6px;border-left:1px solid rgba(26, 68, 128, 0.1);text-decoration:none;text-align:justify;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__85&quot;&gt;a-table&lt;/code&gt;、写&amp;nbsp;&lt;code style=&quot;font-size:13.68px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:25.7184px;color:rgb(199, 37, 78);background-color:rgba(26, 68, 128, 0.08);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:3.42px 6.156px;padding-top:3.42px;padding-bottom:3.42px;padding-left:6.156px;padding-right:6.156px;border:1px solid rgba(26, 68, 128, 0.1);border-radius:6px;border-left:1px solid rgba(26, 68, 128, 0.1);text-decoration:none;text-align:justify;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__86&quot;&gt;columns&lt;/code&gt;、写&amp;nbsp;&lt;code style=&quot;font-size:13.68px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:25.7184px;color:rgb(199, 37, 78);background-color:rgba(26, 68, 128, 0.08);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:3.42px 6.156px;padding-top:3.42px;padding-bottom:3.42px;padding-left:6.156px;padding-right:6.156px;border:1px solid rgba(26, 68, 128, 0.1);border-radius:6px;border-left:1px solid rgba(26, 68, 128, 0.1);text-decoration:none;text-align:justify;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__87&quot;&gt;dataSource&lt;/code&gt;、写分页逻辑。二十个列表页，代码量惊人，维护困难。&lt;/p&gt;&lt;p style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 17.48px;margin-top:0px;margin-bottom:17.48px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__88&quot;&gt;vue3-antdv-admin 的做法是&lt;strong style=&quot;font-size:15.2px;font-weight:700;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(26, 68, 128);background-color:rgba(0, 0, 0, 0);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__89&quot;&gt;配置驱动&lt;/strong&gt;：&lt;/p&gt;&lt;pre style=&quot;white-space:pre-wrap;font-size:15.2px;font-weight:400;font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace;font-style:normal;line-height:28.576px;color:rgb(160, 174, 192);background-color:rgb(26, 32, 44);margin:0px 0px 21.28px;margin-top:0px;margin-bottom:21.28px;margin-left:0px;margin-right:0px;padding:18px 20px;padding-top:18px;padding-bottom:18px;padding-left:20px;padding-right:20px;border:0px solid rgb(229, 231, 235);border-radius:16px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:start;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__90&quot;&gt;&lt;code style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:rgb(160, 174, 192);background-color:rgba(0, 0, 0, 0);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px none rgb(160, 174, 192);border-radius:6px;border-left:0px none rgb(160, 174, 192);text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__91&quot;&gt;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#C678DD;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__92&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__93&quot;&gt;columns&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#61AFEF;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__94&quot;&gt;DescType&lt;/span&gt;[] = [&lt;br/&gt;&amp;nbsp; {&lt;br/&gt;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__95&quot;&gt;title&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#98C379;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__96&quot;&gt;&amp;#39;用户名&amp;#39;&lt;/span&gt;,&lt;br/&gt;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__97&quot;&gt;dataIndex&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#98C379;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__98&quot;&gt;&amp;#39;username&amp;#39;&lt;/span&gt;,&lt;br/&gt;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__99&quot;&gt;width&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__100&quot;&gt;120&lt;/span&gt;,&lt;br/&gt;&amp;nbsp; },&lt;br/&gt;&amp;nbsp; {&lt;br/&gt;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__101&quot;&gt;title&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#98C379;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__102&quot;&gt;&amp;#39;邮箱&amp;#39;&lt;/span&gt;,&lt;br/&gt;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__103&quot;&gt;dataIndex&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#98C379;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__104&quot;&gt;&amp;#39;email&amp;#39;&lt;/span&gt;,&lt;br/&gt;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__105&quot;&gt;ellipsis&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#A0AEC0;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__106&quot;&gt;true&lt;/span&gt;,&lt;br/&gt;&amp;nbsp; },&lt;br/&gt;&amp;nbsp; {&lt;br/&gt;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__107&quot;&gt;title&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#98C379;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__108&quot;&gt;&amp;#39;角色&amp;#39;&lt;/span&gt;,&lt;br/&gt;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__109&quot;&gt;dataIndex&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#98C379;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__110&quot;&gt;&amp;#39;roles&amp;#39;&lt;/span&gt;,&lt;br/&gt;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__111&quot;&gt;width&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__112&quot;&gt;150&lt;/span&gt;,&lt;br/&gt;&amp;nbsp; },&lt;br/&gt;&amp;nbsp; {&lt;br/&gt;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__113&quot;&gt;title&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#98C379;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__114&quot;&gt;&amp;#39;状态&amp;#39;&lt;/span&gt;,&lt;br/&gt;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__115&quot;&gt;dataIndex&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#98C379;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__116&quot;&gt;&amp;#39;status&amp;#39;&lt;/span&gt;,&lt;br/&gt;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#61AFEF;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__117&quot;&gt;render&lt;/span&gt;(&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#A0AEC0;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__118&quot;&gt;{ record }&lt;/span&gt;) {&lt;br/&gt;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#C678DD;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__119&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#61AFEF;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__120&quot;&gt;h&lt;/span&gt;(&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#61AFEF;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__121&quot;&gt;Switch&lt;/span&gt;, {&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__122&quot;&gt;checked&lt;/span&gt;: record.&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#A0AEC0;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__123&quot;&gt;status&lt;/span&gt;&amp;nbsp;===&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__124&quot;&gt;1&lt;/span&gt;&amp;nbsp;});&lt;br/&gt;&amp;nbsp; &amp;nbsp; },&lt;br/&gt;&amp;nbsp; },&lt;br/&gt;];&lt;br/&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 17.48px;margin-top:0px;margin-bottom:17.48px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__125&quot;&gt;你只需要定义&amp;nbsp;&lt;code style=&quot;font-size:13.68px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:25.7184px;color:rgb(199, 37, 78);background-color:rgba(26, 68, 128, 0.08);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:3.42px 6.156px;padding-top:3.42px;padding-bottom:3.42px;padding-left:6.156px;padding-right:6.156px;border:1px solid rgba(26, 68, 128, 0.1);border-radius:6px;border-left:1px solid rgba(26, 68, 128, 0.1);text-decoration:none;text-align:justify;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__126&quot;&gt;columns&lt;/code&gt;&amp;nbsp;的配置，表格的分页、排序、筛选、导出全部自动处理。列宽自适应、列设置工具栏（拖拽排序、显隐控制）、单元格编辑——这些功能都是内置的，不需要额外开发。&lt;/p&gt;&lt;p style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 17.48px;margin-top:0px;margin-bottom:17.48px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__127&quot;&gt;而且它支持&lt;strong style=&quot;font-size:15.2px;font-weight:700;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(26, 68, 128);background-color:rgba(0, 0, 0, 0);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__128&quot;&gt;行内编辑&lt;/strong&gt;和&lt;strong style=&quot;font-size:15.2px;font-weight:700;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(26, 68, 128);background-color:rgba(0, 0, 0, 0);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__129&quot;&gt;批量操作&lt;/strong&gt;：选中若干行，一键删除、导出、审批。常规后台系统需要的操作，都覆盖了。&lt;/p&gt;&lt;h3 style=&quot;font-size:17.024px;font-weight:600;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:32.0051px;color:rgb(26, 32, 44);background-color:rgba(0, 0, 0, 0);margin:21.28px 0px 10.2144px;margin-top:21.28px;margin-bottom:10.2144px;margin-left:0px;margin-right:0px;padding:0px 0px 0px 16px;padding-top:0px;padding-bottom:0px;padding-left:16px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:start;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__130&quot;&gt;动态表单：JSON 生成表单&lt;/h3&gt;&lt;p style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 17.48px;margin-top:0px;margin-bottom:17.48px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__131&quot;&gt;表单和表格一样，大部分后台系统的表单都是重复劳动：表单字段、校验规则、布局方式，这些每次都差不多。&lt;/p&gt;&lt;p style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 17.48px;margin-top:0px;margin-bottom:17.48px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__132&quot;&gt;vue3-antdv-admin 的动态表单接受 JSON 配置，自动生成带校验的表单：&lt;/p&gt;&lt;pre style=&quot;white-space:pre-wrap;font-size:15.2px;font-weight:400;font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace;font-style:normal;line-height:28.576px;color:rgb(160, 174, 192);background-color:rgb(26, 32, 44);margin:0px 0px 21.28px;margin-top:0px;margin-bottom:21.28px;margin-left:0px;margin-right:0px;padding:18px 20px;padding-top:18px;padding-bottom:18px;padding-left:20px;padding-right:20px;border:0px solid rgb(229, 231, 235);border-radius:16px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:start;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__133&quot;&gt;&lt;code style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:rgb(160, 174, 192);background-color:rgba(0, 0, 0, 0);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px none rgb(160, 174, 192);border-radius:6px;border-left:0px none rgb(160, 174, 192);text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__134&quot;&gt;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#C678DD;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__135&quot;&gt;const&lt;/span&gt;&amp;nbsp;formSchema = {&lt;br/&gt;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__136&quot;&gt;layout&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#98C379;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__137&quot;&gt;&amp;#39;vertical&amp;#39;&lt;/span&gt;,&lt;br/&gt;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__138&quot;&gt;columns&lt;/span&gt;: [&lt;br/&gt;&amp;nbsp; &amp;nbsp; {&lt;br/&gt;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__139&quot;&gt;label&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#98C379;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__140&quot;&gt;&amp;#39;用户名&amp;#39;&lt;/span&gt;,&lt;br/&gt;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__141&quot;&gt;field&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#98C379;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__142&quot;&gt;&amp;#39;username&amp;#39;&lt;/span&gt;,&lt;br/&gt;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__143&quot;&gt;component&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#98C379;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__144&quot;&gt;&amp;#39;Input&amp;#39;&lt;/span&gt;,&lt;br/&gt;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__145&quot;&gt;rules&lt;/span&gt;: [{&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__146&quot;&gt;required&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#A0AEC0;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__147&quot;&gt;true&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__148&quot;&gt;message&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#98C379;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__149&quot;&gt;&amp;#39;请输入用户名&amp;#39;&lt;/span&gt;&amp;nbsp;}],&lt;br/&gt;&amp;nbsp; &amp;nbsp; },&lt;br/&gt;&amp;nbsp; &amp;nbsp; {&lt;br/&gt;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__150&quot;&gt;label&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#98C379;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__151&quot;&gt;&amp;#39;邮箱&amp;#39;&lt;/span&gt;,&lt;br/&gt;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__152&quot;&gt;field&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#98C379;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__153&quot;&gt;&amp;#39;email&amp;#39;&lt;/span&gt;,&lt;br/&gt;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__154&quot;&gt;component&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#98C379;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__155&quot;&gt;&amp;#39;Input&amp;#39;&lt;/span&gt;,&lt;br/&gt;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__156&quot;&gt;rules&lt;/span&gt;: [&lt;br/&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__157&quot;&gt;required&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#A0AEC0;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__158&quot;&gt;true&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__159&quot;&gt;message&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#98C379;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__160&quot;&gt;&amp;#39;请输入邮箱&amp;#39;&lt;/span&gt;&amp;nbsp;},&lt;br/&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__161&quot;&gt;type&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#98C379;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__162&quot;&gt;&amp;#39;email&amp;#39;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__163&quot;&gt;message&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#98C379;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__164&quot;&gt;&amp;#39;邮箱格式不正确&amp;#39;&lt;/span&gt;&amp;nbsp;},&lt;br/&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ],&lt;br/&gt;&amp;nbsp; &amp;nbsp; },&lt;br/&gt;&amp;nbsp; &amp;nbsp; {&lt;br/&gt;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__165&quot;&gt;label&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#98C379;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__166&quot;&gt;&amp;#39;角色&amp;#39;&lt;/span&gt;,&lt;br/&gt;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__167&quot;&gt;field&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#98C379;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__168&quot;&gt;&amp;#39;roleId&amp;#39;&lt;/span&gt;,&lt;br/&gt;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__169&quot;&gt;component&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#98C379;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__170&quot;&gt;&amp;#39;Select&amp;#39;&lt;/span&gt;,&lt;br/&gt;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__171&quot;&gt;componentProps&lt;/span&gt;: {&lt;br/&gt;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:#D19A66;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__172&quot;&gt;options&lt;/span&gt;: roles,&lt;br/&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;br/&gt;&amp;nbsp; &amp;nbsp; },&lt;br/&gt;&amp;nbsp; ],&lt;br/&gt;};&lt;br/&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 17.48px;margin-top:0px;margin-bottom:17.48px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__173&quot;&gt;配置好之后，表单的渲染、校验、提交全部自动处理。支持级联、动态联动、条件显隐等复杂场景。&lt;/p&gt;&lt;p&gt;&lt;section style=&quot;text-align: center;&quot;&gt;&lt;img class=&quot;rich_pages wxw-img&quot; data-aistatus=&quot;1&quot; data-imgfileid=&quot;100001233&quot; data-ratio=&quot;0.6666666666666666&quot; data-s=&quot;300,640&quot; data-src=&quot;https://mmbiz.qpic.cn/sz_mmbiz_png/GrHt0WCylYk0fqfq9cMV4ibdQagUXib98bFhLp1MxxDExdFZjwY1tBbH6Kg6eZaNNycdSPUy7HWz8fsc8fQVIRIicW8dCDWP8Uy9nficnEvTLMQ/640?wx_fmt=png&amp;amp;from=appmsg&amp;amp;watermark=1#imgIndex=3&quot; data-type=&quot;png&quot; data-w=&quot;1080&quot; type=&quot;block&quot; data-original-style=&quot;null&quot; data-index=&quot;6&quot; src=&quot;https://mmbiz.qpic.cn/sz_mmbiz_png/GrHt0WCylYk0fqfq9cMV4ibdQagUXib98bFhLp1MxxDExdFZjwY1tBbH6Kg6eZaNNycdSPUy7HWz8fsc8fQVIRIicW8dCDWP8Uy9nficnEvTLMQ/640?wx_fmt=png&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1&amp;watermark=1#imgIndex=3&quot; _width=&quot;677px&quot; style=&quot;height: auto !important; visibility: visible !important; width: 677px !important;&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780111646651&quot; data-report-img-idx=&quot;3&quot; data-fail=&quot;0&quot;/&gt;&lt;/section&gt;&lt;/p&gt;&lt;h2 style=&quot;font-size:19.76px;font-weight:700;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:37.1488px;color:rgb(26, 32, 44);background-color:rgba(0, 0, 0, 0);margin:31.616px 0px 15.808px;margin-top:31.616px;margin-bottom:15.808px;margin-left:0px;margin-right:0px;padding:0px 0px 0px 14px;padding-top:0px;padding-bottom:0px;padding-left:14px;padding-right:0px;border-radius:0px 9px 9px 0px;border-left:4px solid rgb(26, 68, 128);text-decoration:none;text-align:start;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__174&quot;&gt;权限体系：菜单即路由，路由即权限&lt;/h2&gt;&lt;p style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 17.48px;margin-top:0px;margin-bottom:17.48px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__175&quot;&gt;很多后台系统的权限控制是&amp;quot;半吊子&amp;quot;的：只控制到菜单级别，菜单能看见就行，具体按钮能不能点，靠的是后端判断，前端只是&amp;quot;看起来&amp;quot;做了权限控制。&lt;/p&gt;&lt;p style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 17.48px;margin-top:0px;margin-bottom:17.48px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__176&quot;&gt;vue3-antdv-admin 的权限体系是&lt;strong style=&quot;font-size:15.2px;font-weight:700;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(26, 68, 128);background-color:rgba(0, 0, 0, 0);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__177&quot;&gt;从前端到后端贯穿的&lt;/strong&gt;：&lt;/p&gt;&lt;p style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 17.48px;margin-top:0px;margin-bottom:17.48px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__178&quot;&gt;&lt;strong style=&quot;font-size:15.2px;font-weight:700;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(26, 68, 128);background-color:rgba(0, 0, 0, 0);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__179&quot;&gt;路由级别&lt;/strong&gt;：菜单即路由，路由由后端返回，前端动态注册。用户能看到哪些菜单，完全由后端权限码控制。&lt;/p&gt;&lt;p style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 17.48px;margin-top:0px;margin-bottom:17.48px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__180&quot;&gt;&lt;strong style=&quot;font-size:15.2px;font-weight:700;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(26, 68, 128);background-color:rgba(0, 0, 0, 0);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__181&quot;&gt;按钮级别&lt;/strong&gt;：每个操作按钮都有对应的权限码，用户有没有这个按钮的权限，前端直接控制显隐，后端也同步校验。两边都对上了，才是真正的安全。&lt;/p&gt;&lt;p style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 17.48px;margin-top:0px;margin-bottom:17.48px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__182&quot;&gt;&lt;strong style=&quot;font-size:15.2px;font-weight:700;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(26, 68, 128);background-color:rgba(0, 0, 0, 0);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__183&quot;&gt;数据级别&lt;/strong&gt;：后端接口返回的数据已经过滤过了，用户只能看到自己有权限看到的数据。前端控制显隐是&amp;quot;遮羞布&amp;quot;，后端过滤才是&amp;quot;真安全&amp;quot;。&lt;/p&gt;&lt;p style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 17.48px;margin-top:0px;margin-bottom:17.48px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__184&quot;&gt;这套权限体系，配合作者的后端项目&amp;nbsp;&lt;strong style=&quot;font-size:15.2px;font-weight:700;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(26, 68, 128);background-color:rgba(0, 0, 0, 0);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__185&quot;&gt;nest-admin&lt;/strong&gt;&amp;nbsp;使用，才是完整方案。当然，前端部分是解耦的，你也可以接自己的后端。&lt;/p&gt;&lt;h2 style=&quot;font-size:19.76px;font-weight:700;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:37.1488px;color:rgb(26, 32, 44);background-color:rgba(0, 0, 0, 0);margin:31.616px 0px 15.808px;margin-top:31.616px;margin-bottom:15.808px;margin-left:0px;margin-right:0px;padding:0px 0px 0px 14px;padding-top:0px;padding-bottom:0px;padding-left:14px;padding-right:0px;border-radius:0px 9px 9px 0px;border-left:4px solid rgb(26, 68, 128);text-decoration:none;text-align:start;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__186&quot;&gt;多标签页路由：做加法容易，做减法难&lt;/h2&gt;&lt;p style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 17.48px;margin-top:0px;margin-bottom:17.48px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__187&quot;&gt;后台系统的标签页（Tabs）是个看似简单、实则复杂的功能。&lt;/p&gt;&lt;p style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 17.48px;margin-top:0px;margin-bottom:17.48px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__188&quot;&gt;做加法容易：新页面就加一个 Tab。但做减法就难了：&lt;strong style=&quot;font-size:15.2px;font-weight:700;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(26, 68, 128);background-color:rgba(0, 0, 0, 0);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__189&quot;&gt;关掉一个 Tab 之后，其他 Tab 的状态要不要保留？刷新页面呢？返回呢？&lt;/strong&gt;&lt;/p&gt;&lt;p style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 17.48px;margin-top:0px;margin-bottom:17.48px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__190&quot;&gt;vue3-antdv-admin 实现了完整的标签页生命周期管理：&lt;/p&gt;&lt;ul style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 16.72px;margin-top:0px;margin-bottom:16.72px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:start;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__191 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section&gt;打开新页面 → 加 Tab&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;关闭当前 Tab → 切到上一个 Tab，状态保留&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;刷新 → 当前 Tab 数据刷新，其他 Tab 状态保留&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;关闭其他 Tab → 可选保留当前或保留指定&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 17.48px;margin-top:0px;margin-bottom:17.48px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__196&quot;&gt;这套逻辑在业界有很多实现方式，vue3-antdv-admin 的实现是&lt;strong style=&quot;font-size:15.2px;font-weight:700;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(26, 68, 128);background-color:rgba(0, 0, 0, 0);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__197&quot;&gt;基于 &lt;span class=&quot;&quot;&gt;KeepAlive&lt;/span&gt; + Pinia&lt;/strong&gt;&amp;nbsp;的，状态管理清晰，缓存策略可配置。&lt;/p&gt;&lt;p&gt;&lt;section style=&quot;text-align: center;&quot;&gt;&lt;img class=&quot;rich_pages wxw-img&quot; data-aistatus=&quot;1&quot; data-imgfileid=&quot;100001234&quot; data-ratio=&quot;0.6666666666666666&quot; data-s=&quot;300,640&quot; data-src=&quot;https://mmbiz.qpic.cn/sz_mmbiz_png/GrHt0WCylYlgFiaW7qBXcaoUB4WL4XaKLRCsDrcW5XhC6bVc6HKgZff6S4fxZVRebribgTnXNLdU1KZmIbiavK6NjvdJcKfSrTD1Bgjp7FXuZE/640?wx_fmt=png&amp;amp;from=appmsg&amp;amp;watermark=1#imgIndex=4&quot; data-type=&quot;png&quot; data-w=&quot;1080&quot; type=&quot;block&quot; data-original-style=&quot;null&quot; data-index=&quot;7&quot; src=&quot;https://mmbiz.qpic.cn/sz_mmbiz_png/GrHt0WCylYlgFiaW7qBXcaoUB4WL4XaKLRCsDrcW5XhC6bVc6HKgZff6S4fxZVRebribgTnXNLdU1KZmIbiavK6NjvdJcKfSrTD1Bgjp7FXuZE/640?wx_fmt=png&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1&amp;watermark=1#imgIndex=4&quot; _width=&quot;677px&quot; style=&quot;height: auto !important; visibility: visible !important; width: 677px !important;&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780115783827&quot; data-report-img-idx=&quot;4&quot; data-fail=&quot;0&quot;/&gt;&lt;/section&gt;&lt;/p&gt;&lt;h2 style=&quot;font-size:19.76px;font-weight:700;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:37.1488px;color:rgb(26, 32, 44);background-color:rgba(0, 0, 0, 0);margin:31.616px 0px 15.808px;margin-top:31.616px;margin-bottom:15.808px;margin-left:0px;margin-right:0px;padding:0px 0px 0px 14px;padding-top:0px;padding-bottom:0px;padding-left:14px;padding-right:0px;border-radius:0px 9px 9px 0px;border-left:4px solid rgb(26, 68, 128);text-decoration:none;text-align:start;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__198&quot;&gt;开发体验：TypeScript + ESLint + Mock&lt;/h2&gt;&lt;p style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 17.48px;margin-top:0px;margin-bottom:17.48px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__199&quot;&gt;这个项目的开发体验也值得一说。&lt;/p&gt;&lt;p style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 17.48px;margin-top:0px;margin-bottom:17.48px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__200&quot;&gt;&lt;strong style=&quot;font-size:15.2px;font-weight:700;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(26, 68, 128);background-color:rgba(0, 0, 0, 0);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__201&quot;&gt;TypeScript 严格模式&lt;/strong&gt;：项目使用了 TypeScript 5.x，并且开启了严格类型检查。这对代码质量有帮助，新人上手也能通过类型提示快速理解代码。&lt;/p&gt;&lt;p style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 17.48px;margin-top:0px;margin-bottom:17.48px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__202&quot;&gt;&lt;strong style=&quot;font-size:15.2px;font-weight:700;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(26, 68, 128);background-color:rgba(0, 0, 0, 0);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__203&quot;&gt;ESLint + UnoCSS ESLint 插件&lt;/strong&gt;：代码风格统一，格式化自动化。&lt;/p&gt;&lt;p style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 17.48px;margin-top:0px;margin-bottom:17.48px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__204&quot;&gt;&lt;strong style=&quot;font-size:15.2px;font-weight:700;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(26, 68, 128);background-color:rgba(0, 0, 0, 0);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__205&quot;&gt;&lt;span class=&quot;&quot;&gt;MSW&lt;/span&gt;（Mock Service Worker）&lt;/strong&gt;：前端 Mock API 的方案有很多，MSW 是其中最接近真实场景的——它拦截的是实际的网络请求，在浏览器里和在后端里行为完全一致。不需要改任何业务代码，直接切换到真实后端。&lt;/p&gt;&lt;pre style=&quot;white-space:pre-wrap;font-size:15.2px;font-weight:400;font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace;font-style:normal;line-height:28.576px;color:rgb(160, 174, 192);background-color:rgb(26, 32, 44);margin:0px 0px 21.28px;margin-top:0px;margin-bottom:21.28px;margin-left:0px;margin-right:0px;padding:18px 20px;padding-top:18px;padding-bottom:18px;padding-left:20px;padding-right:20px;border:0px solid rgb(229, 231, 235);border-radius:16px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:start;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__206&quot;&gt;&lt;code style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:27.1472px;color:rgb(160, 174, 192);background-color:rgba(0, 0, 0, 0);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px none rgb(160, 174, 192);border-radius:6px;border-left:0px none rgb(160, 174, 192);text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__207&quot;&gt;pnpm dev &amp;nbsp;&lt;span style=&quot;white-space:pre-wrap;font-size:14.44px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:italic;line-height:27.1472px;color:#5C6370;background-color:;margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid #E5E7EB;border-radius:0px;border-left:0px solid #E5E7EB;text-decoration:none;text-align:start;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;&quot; class=&quot;js_darkmode__208&quot;&gt;# 启动开发服务器，MSW 自动生效&lt;/span&gt;&lt;br/&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 17.48px;margin-top:0px;margin-bottom:17.48px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__209&quot;&gt;&lt;strong style=&quot;font-size:15.2px;font-weight:700;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(26, 68, 128);background-color:rgba(0, 0, 0, 0);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__210&quot;&gt;OpenAPI 代码生成&lt;/strong&gt;：项目自带&amp;nbsp;&lt;code style=&quot;font-size:13.68px;font-weight:400;font-family:&amp;quot;JetBrains Mono&amp;quot;, Consolas, monospace;font-style:normal;line-height:25.7184px;color:rgb(199, 37, 78);background-color:rgba(26, 68, 128, 0.08);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:3.42px 6.156px;padding-top:3.42px;padding-bottom:3.42px;padding-left:6.156px;padding-right:6.156px;border:1px solid rgba(26, 68, 128, 0.1);border-radius:6px;border-left:1px solid rgba(26, 68, 128, 0.1);text-decoration:none;text-align:justify;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__211&quot;&gt;@umijs/openapi&lt;/code&gt;，可以基于 Swagger 文档自动生成 TypeScript 类型和 API 请求函数。后端接口改了，跑一下命令，前端类型同步更新。&lt;/p&gt;&lt;h2 style=&quot;font-size:19.76px;font-weight:700;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:37.1488px;color:rgb(26, 32, 44);background-color:rgba(0, 0, 0, 0);margin:31.616px 0px 15.808px;margin-top:31.616px;margin-bottom:15.808px;margin-left:0px;margin-right:0px;padding:0px 0px 0px 14px;padding-top:0px;padding-bottom:0px;padding-left:14px;padding-right:0px;border-radius:0px 9px 9px 0px;border-left:4px solid rgb(26, 68, 128);text-decoration:none;text-align:start;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__212&quot;&gt;配套后端：nest-admin&lt;/h2&gt;&lt;p style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 17.48px;margin-top:0px;margin-bottom:17.48px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__213&quot;&gt;vue3-antdv-admin 的作者同时维护了一个&amp;nbsp;&lt;strong style=&quot;font-size:15.2px;font-weight:700;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(26, 68, 128);background-color:rgba(0, 0, 0, 0);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__214&quot;&gt;nest-admin&lt;/strong&gt;&amp;nbsp;项目，基于 &lt;span class=&quot;&quot;&gt;NestJS&lt;/span&gt; + TypeORM + MySQL/PostgreSQL。&lt;/p&gt;&lt;p style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 17.48px;margin-top:0px;margin-bottom:17.48px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__215&quot;&gt;这个后端是专门为前端项目设计的：&lt;/p&gt;&lt;ul style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 16.72px;margin-top:0px;margin-bottom:16.72px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:start;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__216 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section&gt;权限体系与前端一一对应&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;数据库设计直接映射前端表单和表格&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;提供完整的 &lt;span class=&quot;&quot;&gt;CRUD&lt;/span&gt; 接口&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;支持代码生成&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 17.48px;margin-top:0px;margin-bottom:17.48px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__221&quot;&gt;如果你想快速搭一个完整的后台管理系统，用 vue3-antdv-admin + nest-admin，从前端到后端都有，是目前开源社区里难得的&lt;strong style=&quot;font-size:15.2px;font-weight:700;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(26, 68, 128);background-color:rgba(0, 0, 0, 0);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__222&quot;&gt;完整方案&lt;/strong&gt;。&lt;/p&gt;&lt;h2 style=&quot;font-size:19.76px;font-weight:700;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:37.1488px;color:rgb(26, 32, 44);background-color:rgba(0, 0, 0, 0);margin:31.616px 0px 15.808px;margin-top:31.616px;margin-bottom:15.808px;margin-left:0px;margin-right:0px;padding:0px 0px 0px 14px;padding-top:0px;padding-bottom:0px;padding-left:14px;padding-right:0px;border-radius:0px 9px 9px 0px;border-left:4px solid rgb(26, 68, 128);text-decoration:none;text-align:start;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__223&quot;&gt;结语&lt;/h2&gt;&lt;p style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 17.48px;margin-top:0px;margin-bottom:17.48px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__224&quot;&gt;vue3-antdv-admin 不是一个&amp;quot;看起来能用但实际差很远&amp;quot;的练手项目。它是一个&lt;strong style=&quot;font-size:15.2px;font-weight:700;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(26, 68, 128);background-color:rgba(0, 0, 0, 0);margin:0px;margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:inline;width:auto;max-width:none;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__225&quot;&gt;真正用于生产&lt;/strong&gt;的后台管理前端方案。&lt;/p&gt;&lt;p style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 17.48px;margin-top:0px;margin-bottom:17.48px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__226&quot;&gt;动态表格、动态表单、权限体系、多标签页、Mock API、代码生成——这些功能每一个单拎出来都能写一篇文章，但它们在同一个项目里形成了一套完整体系。&lt;/p&gt;&lt;p style=&quot;font-size:15.2px;font-weight:400;font-family:-apple-system, &amp;quot;HarmonyOS Sans SC&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, sans-serif;font-style:normal;line-height:28.576px;color:rgb(31, 41, 51);background-color:rgba(0, 0, 0, 0);margin:0px 0px 17.48px;margin-top:0px;margin-bottom:17.48px;margin-left:0px;margin-right:0px;padding:0px;padding-top:0px;padding-bottom:0px;padding-left:0px;padding-right:0px;border:0px solid rgb(229, 231, 235);border-radius:0px;border-left:0px solid rgb(229, 231, 235);text-decoration:none;text-align:justify;display:block;width:678px;max-width:680px;overflow:visible;word-break:normal;word-wrap:normal;white-space:normal;&quot; class=&quot;js_darkmode__227&quot;&gt;对于需要快速搭建后台管理系统的团队，与其从零开始，不如先看看这套方案。它可能不是最简单的，但它是最完整的。&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Sat, 30 May 2026 12:34:50 +0800</pubDate></item><item><title>从内核到超算：Linux能做而Windows永远做不到的8件事</title><link>https://www.codepub.top/post/467.html</link><description>&lt;p style=&quot;font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, &amp;quot;Noto Sans&amp;quot;, sans-serif; font-size: 15px; line-height: 1.8; color: rgb(62, 62, 62); margin: 0px 0px 24px; text-align: justify; letter-spacing: 0px; visibility: visible;&quot; class=&quot;js_darkmode__1&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;Linux 和 Windows 的设计哲学根本不同：一个开源、模块化，以自由和可定制为核心；另一个是商业闭源系统，侧重易用和生态统一。因此，确实有一些事情是&amp;nbsp;&lt;/span&gt;&lt;strong style=&quot;font-weight: bold; color: rgb(3, 102, 214); visibility: visible;&quot; class=&quot;js_darkmode__2&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;Linux 内核与系统原生就能做到，而 Windows（在不借助虚拟机或 WSL 等额外运行 Linux 环境的情况下）完全无法做到或无法等价实现&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;。&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;figure style=&quot;display: block; margin: 16px 0px; text-align: center; visibility: visible;&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;&lt;img class=&quot;rich_pages wxw-img&quot; data-aistatus=&quot;1&quot; data-imgfileid=&quot;100002151&quot; data-src=&quot;https://mmbiz.qpic.cn/mmbiz_jpg/x4icnictNGicLa1gCiaqyduXCsRT4kVvNFVzqWEDiaMRxFI0zGcVX9KjAC1fYicbudqNgfibey3ibiat3PZCDpiaLZBmovOCYGkPtbyYic3ZJW0OMEBpRE/640?wx_fmt=jpeg&amp;amp;from=appmsg&amp;amp;watermark=1#imgIndex=0&quot; data-type=&quot;jpeg&quot; style=&quot;display: block; margin: 0px auto; max-width: 100%; border-radius: 4px; height: auto !important; visibility: visible !important; width: 647px !important;&quot; data-original-style=&quot;display: block;margin: 0 auto;max-width: 100%;border-radius: 4px;&quot; data-index=&quot;3&quot; data-ratio=&quot;0.512962962962963&quot; data-w=&quot;1080&quot; src=&quot;https://mmbiz.qpic.cn/mmbiz_jpg/x4icnictNGicLa1gCiaqyduXCsRT4kVvNFVzqWEDiaMRxFI0zGcVX9KjAC1fYicbudqNgfibey3ibiat3PZCDpiaLZBmovOCYGkPtbyYic3ZJW0OMEBpRE/640?wx_fmt=jpeg&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1&amp;watermark=1#imgIndex=0&quot; _width=&quot;677px&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780110943310&quot; data-report-img-idx=&quot;0&quot; data-fail=&quot;0&quot;/&gt;&lt;/span&gt;&lt;figcaption style=&quot;font-size: 12px; color: rgb(153, 153, 153); text-align: center; margin-top: 8px; visibility: visible;&quot; class=&quot;js_darkmode__3&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;&lt;br style=&quot;visibility: visible;&quot;/&gt;&lt;/span&gt;&lt;/figcaption&gt;&lt;/figure&gt;&lt;/p&gt;&lt;p style=&quot;font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, &amp;quot;Noto Sans&amp;quot;, sans-serif; font-size: 15px; line-height: 1.8; color: rgb(62, 62, 62); margin: 0px 0px 24px; text-align: justify; letter-spacing: 0px; visibility: visible;&quot; class=&quot;js_darkmode__4&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;以下列举的关键差异，都围绕“Windows NT 内核自身无法实现”这一标准：&lt;/span&gt;&lt;/p&gt;&lt;hr style=&quot;border-width: 1px 0px 0px; border-right-style: initial; border-bottom-style: initial; border-left-style: initial; border-right-color: initial; border-bottom-color: initial; border-left-color: initial; border-image: initial; border-top-style: solid; border-top-color: rgba(0, 0, 0, 0.08); margin: 40px 0px; visibility: visible;&quot; class=&quot;js_darkmode__5&quot;/&gt;&lt;h3 style=&quot;font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, &amp;quot;Noto Sans&amp;quot;, sans-serif; display: block; font-size: 17px; font-weight: bold; margin: 20px 0px 12px; text-align: left; color: rgb(62, 62, 62); line-height: 1.3; border-left: 4px solid rgb(3, 102, 214); padding-left: 10px; visibility: visible;&quot; class=&quot;js_darkmode__6&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;1. 完全掌控内核与系统的每一行代码&lt;/span&gt;&lt;/h3&gt;&lt;ul style=&quot;list-style-type: disc;&quot; class=&quot;js_darkmode__7 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;display: block; margin: 0px; padding: 0px; line-height: 1.8; visibility: visible;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: #0366D6; display: inline !important; width: auto !important; float: none !important; visibility: visible;&quot; class=&quot;js_darkmode__9&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;Linux 能做&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;： 你可以拿到完整源代码，自由修改、裁剪、重新编译内核。无论是删除不必要的驱动来适配嵌入式设备，还是添加自定义系统调用，或者给内核打实时补丁（如&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background: rgba(3, 102, 214, 0.1); color: rgb(3, 102, 214); padding: 2px 4px; border-radius: 3px; font-family: &amp;quot;SF Mono&amp;quot;, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 13px; vertical-align: baseline; display: inline !important; width: auto !important; float: none !important; margin: 0px 2px !important; visibility: visible;&quot; class=&quot;js_darkmode__10&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;PREEMPT_RT&lt;/span&gt;&lt;/code&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;），都完全合法且可行。系统所有组件（从初始化系统、核心库到图形栈）都可替换，你可以用&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;background: rgba(3, 102, 214, 0.1); color: rgb(3, 102, 214); padding: 2px 4px; border-radius: 3px; font-family: &amp;quot;SF Mono&amp;quot;, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 13px; vertical-align: baseline; display: inline !important; width: auto !important; float: none !important; margin: 0px 2px !important; visibility: visible;&quot; class=&quot;js_darkmode__11&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;systemd&lt;/span&gt;&lt;/code&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;、OpenRC，也可以搭配任何窗口管理器。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;display: block; margin: 0px; padding: 0px; line-height: 1.8; visibility: visible;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: #0366D6; display: inline !important; width: auto !important; float: none !important; visibility: visible;&quot; class=&quot;js_darkmode__13&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;Windows 做不到&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;： 内核和核心组件完全闭源。你只能调用微软公开的 API，无法修改进程调度、内存管理或文件系统驱动的内部逻辑。更换整个桌面环境或 init 系统更是天方夜谭。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 style=&quot;font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, &amp;quot;Noto Sans&amp;quot;, sans-serif; display: block; font-size: 17px; font-weight: bold; margin: 20px 0px 12px; text-align: left; color: rgb(62, 62, 62); line-height: 1.3; border-left: 4px solid rgb(3, 102, 214); padding-left: 10px; visibility: visible;&quot; class=&quot;js_darkmode__14&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;2. 原生运行 Linux ELF 可执行文件与 Linux 容器&lt;/span&gt;&lt;/h3&gt;&lt;ul style=&quot;list-style-type: disc;&quot; class=&quot;js_darkmode__15 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;display:block;margin:0;padding:0;line-height: 1.8;&quot;&gt;&lt;span style=&quot;font-weight: bold;color: #0366d6;display:inline !important;width:auto !important;float:none !important;&quot; class=&quot;js_darkmode__17&quot;&gt;Linux 能做&lt;/span&gt;： Linux 系统可以直接执行 ELF 格式的二进制程序；Docker、Podman 等容器技术直接利用内核的&amp;nbsp;&lt;strong style=&quot;font-weight: bold;color: #0366d6;display:inline !important;width:auto !important;float:none !important;&quot; class=&quot;js_darkmode__18&quot;&gt;&lt;span class=&quot;&quot;&gt;cgroups&lt;/span&gt; 和 namespaces&lt;/strong&gt;&amp;nbsp;实现轻量级虚拟化，没有额外虚拟层损耗。所有 Linux 容器本质上共享宿主内核，启动近乎瞬时。&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;display:block;margin:0;padding:0;line-height: 1.8;&quot;&gt;&lt;span style=&quot;font-weight: bold;color: #0366d6;display:inline !important;width:auto !important;float:none !important;&quot; class=&quot;js_darkmode__20&quot;&gt;Windows 做不到&lt;/span&gt;： Windows 可执行文件是 PE 格式，内核完全不认识 ELF。运行 Linux 程序或 Docker 容器，目前必须依赖&amp;nbsp;&lt;strong style=&quot;font-weight: bold;color: #0366d6;display:inline !important;width:auto !important;float:none !important;&quot; class=&quot;js_darkmode__21&quot;&gt;&lt;span class=&quot;&quot;&gt;WSL 2&lt;/span&gt;（它内部运行的是完整 Linux 内核虚拟机）或 Hyper-V 虚拟机&lt;/strong&gt;。也就是说，这是在跑另一个 Linux，而不是 Windows 自己提供了这些能力。Windows 容器虽然存在，但其生态与 Linux 容器完全不同，无法直接运行绝大多数云原生应用。&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 style=&quot;font-family: -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, &amp;#39;Helvetica Neue&amp;#39;, Arial, &amp;#39;Noto Sans&amp;#39;, sans-serif;display: block;font-size: 17px;font-weight: bold;margin: 20px 0 12px;text-align: left;color: #3e3e3e;line-height: 1.3;border-left: 4px solid #0366d6;padding-left: 10px;&quot; class=&quot;js_darkmode__22&quot;&gt;3. 在几乎没有资源消耗的情况下运行&lt;/h3&gt;&lt;ul style=&quot;list-style-type: disc;&quot; class=&quot;js_darkmode__23 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;display:block;margin:0;padding:0;line-height: 1.8;&quot;&gt;&lt;span style=&quot;font-weight: bold;color: #0366d6;display:inline !important;width:auto !important;float:none !important;&quot; class=&quot;js_darkmode__25&quot;&gt;Linux 能做&lt;/span&gt;： 精简后的 Linux 内核与最小用户态（如 BusyBox）可以在&amp;nbsp;&lt;strong style=&quot;font-weight: bold;color: #0366d6;display:inline !important;width:auto !important;float:none !important;&quot; class=&quot;js_darkmode__26&quot;&gt;几 MB 内存和几 MB 存储&lt;/strong&gt;&amp;nbsp;的设备上流畅运行。一台待机状态的服务器版 Linux，内存占用可低于 50MB，完全无图形界面依然功能强大。&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;display:block;margin:0;padding:0;line-height: 1.8;&quot;&gt;&lt;span style=&quot;font-weight: bold;color: #0366d6;display:inline !important;width:auto !important;float:none !important;&quot; class=&quot;js_darkmode__28&quot;&gt;Windows 做不到&lt;/span&gt;： 即使是最精简的 Windows Server Core 或 IoT Core，内存和存储需求也远高于此。Windows 体系对图形栈、注册表、服务的依赖，使它在极低配硬件上难以生存，且完全无 GUI 的纯命令行服务器能力长期存在功能缺失。&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 style=&quot;font-family: -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, &amp;#39;Helvetica Neue&amp;#39;, Arial, &amp;#39;Noto Sans&amp;#39;, sans-serif;display: block;font-size: 17px;font-weight: bold;margin: 20px 0 12px;text-align: left;color: #3e3e3e;line-height: 1.3;border-left: 4px solid #0366d6;padding-left: 10px;&quot; class=&quot;js_darkmode__29&quot;&gt;4. 深度实时性与&lt;span class=&quot;&quot;&gt;确定性调度&lt;/span&gt;&lt;/h3&gt;&lt;ul style=&quot;list-style-type: disc;&quot; class=&quot;js_darkmode__30 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;display:block;margin:0;padding:0;line-height: 1.8;&quot;&gt;&lt;span style=&quot;font-weight: bold;color: #0366d6;display:inline !important;width:auto !important;float:none !important;&quot; class=&quot;js_darkmode__32&quot;&gt;Linux 能做&lt;/span&gt;： 通过&amp;nbsp;&lt;code style=&quot;background: #0366d61A;color: #0366d6;padding: 2px 4px;border-radius: 3px;font-family: &amp;#39;SF Mono&amp;#39;, Consolas, &amp;#39;Liberation Mono&amp;#39;, Menlo, Courier, monospace;font-size: 13px;display:inline !important;width:auto !important;float:none !important;margin:0 2px !important;vertical-align:baseline;&quot; class=&quot;js_darkmode__33&quot;&gt;PREEMPT_RT&lt;/code&gt;&amp;nbsp;补丁将内核变为完全可抢占的实时内核，中断线程化，优先级继承，能实现微秒级的确定性延迟。被广泛用于工业控制、机器人、金融交易等硬实时领域。&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;display:block;margin:0;padding:0;line-height: 1.8;&quot;&gt;&lt;span style=&quot;font-weight: bold;color: #0366d6;display:inline !important;width:auto !important;float:none !important;&quot; class=&quot;js_darkmode__35&quot;&gt;Windows 做不到&lt;/span&gt;： 桌面和服务器版 Windows 是通用分时系统，没有硬实时调度能力。虽然有第三方的实时扩展（如 IntervalZero），但需付费且会将 Windows 作为低优先级任务跑在实时内核之上，这已不是原生 Windows 的能力。&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 style=&quot;font-family: -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, &amp;#39;Helvetica Neue&amp;#39;, Arial, &amp;#39;Noto Sans&amp;#39;, sans-serif;display: block;font-size: 17px;font-weight: bold;margin: 20px 0 12px;text-align: left;color: #3e3e3e;line-height: 1.3;border-left: 4px solid #0366d6;padding-left: 10px;&quot; class=&quot;js_darkmode__36&quot;&gt;5. 将整个系统状态暴露为文件并直接操控&lt;/h3&gt;&lt;ul style=&quot;list-style-type: disc;&quot; class=&quot;js_darkmode__37 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;display:block;margin:0;padding:0;line-height: 1.8;&quot;&gt;&lt;span style=&quot;font-weight: bold;color: #0366d6;display:inline !important;width:auto !important;float:none !important;&quot; class=&quot;js_darkmode__39&quot;&gt;Linux 能做&lt;/span&gt;：&amp;nbsp;&lt;code style=&quot;background: #0366d61A;color: #0366d6;padding: 2px 4px;border-radius: 3px;font-family: &amp;#39;SF Mono&amp;#39;, Consolas, &amp;#39;Liberation Mono&amp;#39;, Menlo, Courier, monospace;font-size: 13px;display:inline !important;width:auto !important;float:none !important;margin:0 2px !important;vertical-align:baseline;&quot; class=&quot;js_darkmode__40&quot;&gt;/proc&lt;/code&gt;&amp;nbsp;和&amp;nbsp;&lt;code style=&quot;background: #0366d61A;color: #0366d6;padding: 2px 4px;border-radius: 3px;font-family: &amp;#39;SF Mono&amp;#39;, Consolas, &amp;#39;Liberation Mono&amp;#39;, Menlo, Courier, monospace;font-size: 13px;display:inline !important;width:auto !important;float:none !important;margin:0 2px !important;vertical-align:baseline;&quot; class=&quot;js_darkmode__41&quot;&gt;/sys&lt;/code&gt;&amp;nbsp;文件系统提供了访问内核数据结构的直接接口。你可以通过&amp;nbsp;&lt;code style=&quot;background: #0366d61A;color: #0366d6;padding: 2px 4px;border-radius: 3px;font-family: &amp;#39;SF Mono&amp;#39;, Consolas, &amp;#39;Liberation Mono&amp;#39;, Menlo, Courier, monospace;font-size: 13px;display:inline !important;width:auto !important;float:none !important;margin:0 2px !important;vertical-align:baseline;&quot; class=&quot;js_darkmode__42&quot;&gt;cat /proc/cpuinfo&lt;/code&gt;&amp;nbsp;读 CPU 信息，通过&amp;nbsp;&lt;code style=&quot;background: #0366d61A;color: #0366d6;padding: 2px 4px;border-radius: 3px;font-family: &amp;#39;SF Mono&amp;#39;, Consolas, &amp;#39;Liberation Mono&amp;#39;, Menlo, Courier, monospace;font-size: 13px;display:inline !important;width:auto !important;float:none !important;margin:0 2px !important;vertical-align:baseline;&quot; class=&quot;js_darkmode__43&quot;&gt;echo&lt;/code&gt;&amp;nbsp;往特定文件写值来动态调整内核参数、挂载设备、控制系统睡眠等。一切皆文件的哲学使得脚本化和自动化极为一致。&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;display:block;margin:0;padding:0;line-height: 1.8;&quot;&gt;&lt;span style=&quot;font-weight: bold;color: #0366d6;display:inline !important;width:auto !important;float:none !important;&quot; class=&quot;js_darkmode__45&quot;&gt;Windows 做不到&lt;/span&gt;： 系统状态分散在注册表、API 调用、WMI 和各类控制面板中。虽然可以操作注册表，但它不是一棵反映内核运行态的实时文件树，你无法通过读写某个文件来直接改变 TCP 拥塞窗口或查看进程内存映射。&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 style=&quot;font-family: -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, &amp;#39;Helvetica Neue&amp;#39;, Arial, &amp;#39;Noto Sans&amp;#39;, sans-serif;display: block;font-size: 17px;font-weight: bold;margin: 20px 0 12px;text-align: left;color: #3e3e3e;line-height: 1.3;border-left: 4px solid #0366d6;padding-left: 10px;&quot; class=&quot;js_darkmode__46&quot;&gt;6. 自由的软件源与系统级包管理一体化&lt;/h3&gt;&lt;ul style=&quot;list-style-type: disc;&quot; class=&quot;js_darkmode__47 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;display:block;margin:0;padding:0;line-height: 1.8;&quot;&gt;&lt;span style=&quot;font-weight: bold;color: #0366d6;display:inline !important;width:auto !important;float:none !important;&quot; class=&quot;js_darkmode__49&quot;&gt;Linux 能做&lt;/span&gt;： 包管理器（apt, dnf, pacman 等）不仅安装应用软件，还负责&lt;strong style=&quot;font-weight: bold;color: #0366d6;display:inline !important;width:auto !important;float:none !important;&quot; class=&quot;js_darkmode__50&quot;&gt;内核更新、系统库、核心服务&lt;/strong&gt;的升级与依赖解析，一条命令就能更新整个操作系统所有的软件。几乎所有自由软件都能从官方源和社区源获得，不依赖特定商店。&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;display:block;margin:0;padding:0;line-height: 1.8;&quot;&gt;&lt;span style=&quot;font-weight: bold;color: #0366d6;display:inline !important;width:auto !important;float:none !important;&quot; class=&quot;js_darkmode__52&quot;&gt;Windows 做不到&lt;/span&gt;： Windows Update 只管系统和微软组件，第三方应用靠各自安装包或 winget、Chocolatey 等后期补充工具，它们&lt;strong style=&quot;font-weight: bold;color: #0366d6;display:inline !important;width:auto !important;float:none !important;&quot; class=&quot;js_darkmode__53&quot;&gt;无法统一管理内核和系统库的依赖关系&lt;/strong&gt;。你不会用 winget 来升级 Windows 内核或 HAL。&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 style=&quot;font-family: -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, &amp;#39;Helvetica Neue&amp;#39;, Arial, &amp;#39;Noto Sans&amp;#39;, sans-serif;display: block;font-size: 17px;font-weight: bold;margin: 20px 0 12px;text-align: left;color: #3e3e3e;line-height: 1.3;border-left: 4px solid #0366d6;padding-left: 10px;&quot; class=&quot;js_darkmode__54&quot;&gt;7. 原生支持 ZFS、Btrfs 等先进文件系统作为根分区&lt;/h3&gt;&lt;ul style=&quot;list-style-type: disc;&quot; class=&quot;js_darkmode__55 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;display:block;margin:0;padding:0;line-height: 1.8;&quot;&gt;&lt;span style=&quot;font-weight: bold;color: #0366d6;display:inline !important;width:auto !important;float:none !important;&quot; class=&quot;js_darkmode__57&quot;&gt;Linux 能做&lt;/span&gt;： 你可以将系统安装在 Btrfs、ZFS 等文件系统上，享受写时复制快照、透明压缩、数据校验自愈、&lt;span class=&quot;&quot;&gt;子卷&lt;/span&gt;等高级特性，并和启动引导器无缝集成。&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;display:block;margin:0;padding:0;line-height: 1.8;&quot;&gt;&lt;span style=&quot;font-weight: bold;color: #0366d6;display:inline !important;width:auto !important;float:none !important;&quot; class=&quot;js_darkmode__59&quot;&gt;Windows 做不到&lt;/span&gt;： 根文件系统只能使用 NTFS（或部分场景 ReFS，但 ReFS 不支持作为启动卷），这些文件系统不具备原生快照发送、块级校验自愈和无限级子卷等能力。&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 style=&quot;font-family: -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, &amp;#39;Helvetica Neue&amp;#39;, Arial, &amp;#39;Noto Sans&amp;#39;, sans-serif;display: block;font-size: 17px;font-weight: bold;margin: 20px 0 12px;text-align: left;color: #3e3e3e;line-height: 1.3;border-left: 4px solid #0366d6;padding-left: 10px;&quot; class=&quot;js_darkmode__60&quot;&gt;8. 跨无数硬件架构与超级计算机的统治力&lt;/h3&gt;&lt;ul style=&quot;list-style-type: disc;&quot; class=&quot;js_darkmode__61 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;display:block;margin:0;padding:0;line-height: 1.8;&quot;&gt;&lt;span style=&quot;font-weight: bold;color: #0366d6;display:inline !important;width:auto !important;float:none !important;&quot; class=&quot;js_darkmode__63&quot;&gt;Linux 能做&lt;/span&gt;： 能够运行在 x86、ARM、RISC-V、MIPS、&lt;span class=&quot;&quot;&gt;PowerPC&lt;/span&gt;、s390x 等等众多架构上。TOP500 超算&lt;strong style=&quot;font-weight: bold;color: #0366d6;display:inline !important;width:auto !important;float:none !important;&quot; class=&quot;js_darkmode__64&quot;&gt;全部&lt;/strong&gt;运行 Linux，它支撑着世界上所有的公有云底层和几乎所有的 Android 手机。&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;display:block;margin:0;padding:0;line-height: 1.8;&quot;&gt;&lt;span style=&quot;font-weight: bold;color: #0366d6;display:inline !important;width:auto !important;float:none !important;&quot; class=&quot;js_darkmode__66&quot;&gt;Windows 做不到&lt;/span&gt;： 主要支持 x86 和 ARM64，且 ARM 生态仍然有限。在超算、大型机和绝大多数嵌入式设备中，Windows 没有存在感。这并非仅因市场选择，而是其内核架构不具备那样广泛的可移植性。&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;hr style=&quot;border: 0;border-top: 1px solid rgba(0,0,0,0.08);margin: 40px 0;&quot; class=&quot;js_darkmode__67&quot;/&gt;&lt;p style=&quot;font-family: -apple-system, BlinkMacSystemFont, &amp;#39;Segoe UI&amp;#39;, Roboto, &amp;#39;Helvetica Neue&amp;#39;, Arial, &amp;#39;Noto Sans&amp;#39;, sans-serif;font-size: 15px;line-height: 1.8;color: #3e3e3e;margin: 0 0 24px 0;text-align: justify;letter-spacing: 0;&quot; class=&quot;js_darkmode__68&quot;&gt;&lt;strong style=&quot;font-weight: bold;color: #0366d6;&quot; class=&quot;js_darkmode__69&quot;&gt;总结一下核心逻辑&lt;/strong&gt;：上面很多技术，Windows 都能通过“安装一个 Linux 虚拟机 / WSL 2”来间接实现。但这恰恰说明，&lt;strong style=&quot;font-weight: bold;color: #0366d6;&quot; class=&quot;js_darkmode__70&quot;&gt;做这些事需要的是 Linux 环境本身，而不是 Windows&lt;/strong&gt;。Linux 从内核层面就是被设计成一个高度透明、可由用户任意塑形的操作系统，而 Windows 是一个产品化的黑盒平台。这个本质区别，就决定了前者能做到太多后者“办不到”的事情。&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Sat, 30 May 2026 11:20:43 +0800</pubDate></item><item><title>用一套代码同时支持.NET Framework和.NET Core</title><link>https://www.codepub.top/post/466.html</link><description>&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;visibility: visible;&quot; class=&quot;js_darkmode__2&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;visibility: visible;&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;在.NET Core的迁移过程中，我们将原有的.NET Framework代码迁移到.NET Core。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;visibility: visible;&quot; class=&quot;js_darkmode__3&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;visibility: visible;&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;如果线上只有一个小型的应用还好，迁移升级完成后，只需要维护.NET Core这个版本的代码。&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;&lt;br style=&quot;visibility: visible;&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);visibility: visible;&quot; class=&quot;js_darkmode__4&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;&lt;br style=&quot;visibility: visible;&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;visibility: visible;&quot; class=&quot;js_darkmode__5&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;visibility: visible;&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;但是，如果是一个大型分布式应用，几百台Server，上千个.NET 应用进程。这种场景下，在一定的时期内，我们需要同时维护.NET Framework和.NET Core两套代码，同一个产品&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);visibility: visible;&quot; class=&quot;js_darkmode__6&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;&lt;br style=&quot;visibility: visible;&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;visibility: visible;&quot; class=&quot;js_darkmode__7&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;visibility: visible;&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;特性，需要分别在两套代码中实现，这种代码同步的工作量是非常大的。因此，在这种场景下，有必要使用同一套代码既支持.NET Framework又支持.NET Core.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);visibility: visible;&quot; class=&quot;js_darkmode__8&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;&lt;br style=&quot;visibility: visible;&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;visibility: visible;&quot; class=&quot;js_darkmode__9&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;visibility: visible;&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;带着这个需求场景，我们展开今天的.NET Core技术研究分享。先总结一下整体的思路：&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);visibility: visible;&quot; class=&quot;js_darkmode__10&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;&lt;br style=&quot;visibility: visible;&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;visibility: visible;&quot; class=&quot;js_darkmode__11&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;visibility: visible;&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;1、在Project工程层面支持多个目标框架，面向不同的.NET 目标框架添加不同的引用&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);visibility: visible;&quot; class=&quot;js_darkmode__12&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;&lt;br style=&quot;visibility: visible;&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;visibility: visible;&quot; class=&quot;js_darkmode__13&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;visibility: visible;&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;2、代码中使用&lt;span class=&quot;&quot;&gt;预处理指令&lt;/span&gt;同时支持.NET Framework 和 .NET Core&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);visibility: visible;&quot; class=&quot;js_darkmode__14&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;&lt;br style=&quot;visibility: visible;&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;visibility: visible;&quot; class=&quot;js_darkmode__15&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;visibility: visible;&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;3、编译生成两个.NET框架的Dll，制作支持多个.NET目标框架的Nuget包&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);visibility: visible;&quot; class=&quot;js_darkmode__16&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;&lt;br style=&quot;visibility: visible;&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;visibility: visible;&quot; class=&quot;js_darkmode__17&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;visibility: visible;&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;我们先看第一步：&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);visibility: visible;&quot; class=&quot;js_darkmode__18&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;&lt;br style=&quot;visibility: visible;&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;visibility: visible;&quot; class=&quot;js_darkmode__19&quot;&gt;&lt;span style=&quot;outline: 0px;color: #AB1942;visibility: visible;&quot; class=&quot;js_darkmode__20&quot;&gt;&lt;strong style=&quot;outline: 0px;visibility: visible;&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;visibility: visible;&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;一、在Project工程层面支持多个目标框架，面向不同的.NET 目标框架添加不同的引用&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);visibility: visible;&quot; class=&quot;js_darkmode__21&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;&lt;br style=&quot;visibility: visible;&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;visibility: visible;&quot; class=&quot;js_darkmode__22&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;visibility: visible;&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;在这个示例代码中，我们使用了.NET Standard 2.0 Class Library Project。目标框架同时支持.NET Framework 4.5.1和.NET Standard 2.0&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;visibility: visible;&quot; class=&quot;js_darkmode__23&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;visibility: visible;&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;&lt;br style=&quot;visibility: visible;&quot;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;visibility: visible;&quot; class=&quot;js_darkmode__24&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;&quot;&gt;&lt;img class=&quot;rich_pages wxw-img&quot; data-aistatus=&quot;1&quot; data-backh=&quot;398&quot; data-backw=&quot;574&quot; data-before-oversubscription-url=&quot;https://img2018.cnblogs.com/blog/23525/201909/23525-20190930220715542-1215197833.jpg&quot; data-ratio=&quot;0.693359375&quot; data-src=&quot;https://mmbiz.qpic.cn/mmbiz_jpg/7fxWIIIo4QsSWJrLBaAicBRCZunB1lYpWChfKmKXOrfIWVeibENAuNfLdpYv0eckTS6GZ3eEXdz020MxzPic2oaWg/640?wx_fmt=jpeg&amp;amp;wxfrom=5&amp;amp;wx_lazy=1&amp;amp;wx_co=1&amp;amp;tp=wxpic#imgIndex=0&quot; data-type=&quot;jpeg&quot; data-w=&quot;1024&quot; style=&quot;outline: 0px; visibility: visible !important; width: 677px !important; height: auto !important;&quot; data-original-style=&quot;outline: 0px;visibility: visible !important;width: 677px !important;&quot; data-index=&quot;3&quot; src=&quot;https://mmbiz.qpic.cn/mmbiz_jpg/7fxWIIIo4QsSWJrLBaAicBRCZunB1lYpWChfKmKXOrfIWVeibENAuNfLdpYv0eckTS6GZ3eEXdz020MxzPic2oaWg/640?wx_fmt=jpeg&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1&amp;tp=wxpic#imgIndex=0&quot; _width=&quot;677px&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780110898002&quot; data-report-img-idx=&quot;0&quot; data-fail=&quot;0&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);&quot; class=&quot;js_darkmode__25&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;section style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__26&quot;&gt;&lt;img data-src=&quot;https://mmbiz.qpic.cn/mmbiz_png/7fxWIIIo4QsSWJrLBaAicBRCZunB1lYpWJPA9D0EyezA53zjTrvib07kiaDiaDUNZCyq46YbQDl3VPGHTPIoe1R9pg/640?wx_fmt=png&amp;amp;wxfrom=5&amp;amp;wx_lazy=1&amp;amp;wx_co=1&amp;amp;tp=wxpic#imgIndex=1&quot; class=&quot;rich_pages wxw-img&quot; data-ratio=&quot;0.363013698630137&quot; data-type=&quot;png&quot; data-w=&quot;292&quot; style=&quot;outline: 0px; visibility: visible !important; width: 292px !important; height: auto !important;&quot; data-aistatus=&quot;1&quot; data-original-style=&quot;outline: 0px;visibility: visible !important;width: 292px !important;&quot; data-index=&quot;4&quot; src=&quot;https://mmbiz.qpic.cn/mmbiz_png/7fxWIIIo4QsSWJrLBaAicBRCZunB1lYpWJPA9D0EyezA53zjTrvib07kiaDiaDUNZCyq46YbQDl3VPGHTPIoe1R9pg/640?wx_fmt=png&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1&amp;tp=wxpic#imgIndex=1&quot; _width=&quot;292px&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780110998730&quot; data-report-img-idx=&quot;1&quot; data-fail=&quot;0&quot;/&gt;&lt;/section&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__27&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__28&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;&quot;&gt;双击Project, 进入XML文件编辑模式&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__29&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;pre style=&quot;outline: 0px;letter-spacing: 0.544px;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);overflow-x: auto;&quot; class=&quot;js_darkmode__30&quot;&gt;&lt;code style=&quot;margin-right: 0.15em;margin-left: 0.15em;padding: 0.5em;outline: 0px;font-size: 0.85em;font-family: Consolas, Menlo, Courier, monospace;overflow: auto;color: rgb(171, 178, 191);text-size-adjust: none;min-width: 400px;background: none 0% 0% / auto repeat scroll padding-box border-box rgb(40, 44, 52);display: block !important;&quot; class=&quot;js_darkmode__31&quot;&gt;&lt;span style=&quot;outline: 0px;&quot;&gt;&amp;lt;&lt;span style=&quot;outline: 0px;color: #E06C75;&quot;&gt;Project&lt;/span&gt;&lt;span style=&quot;outline: 0px;color: #D19A66;&quot;&gt;Sdk&lt;/span&gt;=&lt;span style=&quot;outline: 0px;color: #98C379;&quot;&gt;&amp;quot;Microsoft.NET.Sdk&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br/&gt;&lt;span style=&quot;outline: 0px;&quot;&gt;&amp;lt;&lt;span style=&quot;outline: 0px;color: #E06C75;&quot;&gt;PropertyGroup&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br/&gt;&lt;span style=&quot;outline: 0px;&quot;&gt;&amp;lt;&lt;span style=&quot;outline: 0px;color: #E06C75;&quot;&gt;TargetFramework&lt;/span&gt;&amp;gt;&lt;/span&gt;netstandard2.0&lt;span style=&quot;outline: 0px;&quot;&gt;&amp;lt;/&lt;span style=&quot;outline: 0px;color: #E06C75;&quot;&gt;TargetFramework&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br/&gt;&lt;span style=&quot;outline: 0px;&quot;&gt;&amp;lt;/&lt;span style=&quot;outline: 0px;color: #E06C75;&quot;&gt;PropertyGroup&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br/&gt;&lt;span style=&quot;outline: 0px;&quot;&gt;&amp;lt;/&lt;span style=&quot;outline: 0px;color: #E06C75;&quot;&gt;Project&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);&quot; class=&quot;js_darkmode__32&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__33&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;&quot;&gt;我们重点编辑TargetFramework这个节，改为TargetFrameworks，例如：&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__34&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;pre style=&quot;outline: 0px;letter-spacing: 0.544px;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);overflow-x: auto;&quot; class=&quot;js_darkmode__35&quot;&gt;&lt;code style=&quot;margin-right: 0.15em;margin-left: 0.15em;padding: 0.5em;outline: 0px;font-size: 0.85em;font-family: Consolas, Menlo, Courier, monospace;overflow: auto;color: rgb(171, 178, 191);text-size-adjust: none;min-width: 400px;background: none 0% 0% / auto repeat scroll padding-box border-box rgb(40, 44, 52);display: block !important;&quot; class=&quot;js_darkmode__36&quot;&gt;&lt;span style=&quot;outline: 0px;&quot;&gt;&amp;lt;&lt;span style=&quot;outline: 0px;color: #E06C75;&quot;&gt;PropertyGroup&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br/&gt;&lt;span style=&quot;outline: 0px;&quot;&gt;&amp;lt;&lt;span style=&quot;outline: 0px;color: #E06C75;&quot;&gt;TargetFrameworks&lt;/span&gt;&amp;gt;&lt;/span&gt;netstandard2.0;net451&lt;span style=&quot;outline: 0px;&quot;&gt;&amp;lt;/&lt;span style=&quot;outline: 0px;color: #E06C75;&quot;&gt;TargetFrameworks&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br/&gt;&lt;span style=&quot;outline: 0px;&quot;&gt;&amp;lt;/&lt;span style=&quot;outline: 0px;color: #E06C75;&quot;&gt;PropertyGroup&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);&quot; class=&quot;js_darkmode__37&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__38&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__39&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;&quot;&gt;保存后，会提示：&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__40&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;&quot;&gt;&lt;br/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;section style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__41&quot;&gt;&lt;img class=&quot;rich_pages wxw-img&quot; data-aistatus=&quot;1&quot; data-before-oversubscription-url=&quot;https://mmbiz.qlogo.cn/mmbiz_jpg/7fxWIIIo4QsSWJrLBaAicBRCZunB1lYpWngPMibIeRGIXhwTfLicdwv2H9tXkUbYjm1HtEzeibOdvg0kgX6bXdGdKA/0?wx_fmt=jpeg&quot; data-oversubscription-url=&quot;http://mmbiz.qpic.cn/mmbiz_jpg/7fxWIIIo4QsSWJrLBaAicBRCZunB1lYpWwXytle8pJJiaDkIDzdCEERp0zteBhoFpSjoVPhxFkg0BubYmIfAOErQ/0?wx_fmt=jpeg&quot; data-ratio=&quot;0.3704545454545455&quot; data-src=&quot;https://mmbiz.qpic.cn/mmbiz_jpg/7fxWIIIo4QsSWJrLBaAicBRCZunB1lYpWngPMibIeRGIXhwTfLicdwv2H9tXkUbYjm1HtEzeibOdvg0kgX6bXdGdKA/640?wx_fmt=jpeg&amp;amp;wxfrom=5&amp;amp;wx_lazy=1&amp;amp;wx_co=1&amp;amp;tp=wxpic#imgIndex=2&quot; data-type=&quot;jpeg&quot; data-w=&quot;440&quot; style=&quot;outline: 0px; visibility: visible !important; width: 574px !important; height: auto !important;&quot; data-original-style=&quot;outline: 0px;visibility: visible !important;width: 574px !important;&quot; data-index=&quot;5&quot; src=&quot;https://mmbiz.qpic.cn/mmbiz_jpg/7fxWIIIo4QsSWJrLBaAicBRCZunB1lYpWngPMibIeRGIXhwTfLicdwv2H9tXkUbYjm1HtEzeibOdvg0kgX6bXdGdKA/640?wx_fmt=jpeg&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1&amp;tp=wxpic#imgIndex=2&quot; _width=&quot;574px&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780110999846&quot; data-report-img-idx=&quot;2&quot; data-fail=&quot;0&quot;/&gt;&lt;/section&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);&quot; class=&quot;js_darkmode__42&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__43&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;&quot;&gt;全部重新加载后，新的Project的依赖项是这样的：&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);&quot; class=&quot;js_darkmode__44&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;section style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__45&quot;&gt;&lt;img data-src=&quot;https://mmbiz.qpic.cn/mmbiz_jpg/7fxWIIIo4QsSWJrLBaAicBRCZunB1lYpW4bZWnv9bMkic6icdL89ia0ZrWR2VjQ1OVMAiaFK30d5ZnbOeETaib7PkgCw/640?wx_fmt=jpeg&amp;amp;wxfrom=5&amp;amp;wx_lazy=1&amp;amp;wx_co=1&amp;amp;tp=wxpic#imgIndex=3&quot; class=&quot;rich_pages wxw-img&quot; data-ratio=&quot;1.239864864864865&quot; data-type=&quot;jpeg&quot; data-w=&quot;296&quot; style=&quot;outline: 0px; visibility: visible !important; width: 296px !important; height: auto !important;&quot; data-aistatus=&quot;1&quot; data-original-style=&quot;outline: 0px;visibility: visible !important;width: 296px !important;&quot; data-index=&quot;6&quot; src=&quot;https://mmbiz.qpic.cn/mmbiz_jpg/7fxWIIIo4QsSWJrLBaAicBRCZunB1lYpW4bZWnv9bMkic6icdL89ia0ZrWR2VjQ1OVMAiaFK30d5ZnbOeETaib7PkgCw/640?wx_fmt=jpeg&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1&amp;tp=wxpic#imgIndex=3&quot; _width=&quot;296px&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780110999947&quot; data-report-img-idx=&quot;3&quot; data-fail=&quot;0&quot;/&gt;&lt;/section&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);&quot; class=&quot;js_darkmode__46&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__47&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;&quot;&gt;这样,这个Project就支持了多个.NET 目标框架，我们可以面向不同的.NET 目标框架添加不同的引用，当然如果依赖的Nuget也同时支持相同的.NET 目标框架，那就最匹配了：例如：Newtonsoft.Json&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);&quot; class=&quot;js_darkmode__48&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;section style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__49&quot;&gt;&lt;img class=&quot;rich_pages wxw-img&quot; data-aistatus=&quot;1&quot; data-backh=&quot;752&quot; data-backw=&quot;505&quot; data-before-oversubscription-url=&quot;https://mmbiz.qlogo.cn/mmbiz_jpg/7fxWIIIo4QsSWJrLBaAicBRCZunB1lYpWvqx8H4Jd372xbOhIy5u0WC4cMLxPxoThBsOhxUMQXvgpCmnLoXohOA/0?wx_fmt=jpeg&quot; data-ratio=&quot;1.489108910891089&quot; data-src=&quot;https://mmbiz.qpic.cn/mmbiz_jpg/7fxWIIIo4QsSWJrLBaAicBRCZunB1lYpWvqx8H4Jd372xbOhIy5u0WC4cMLxPxoThBsOhxUMQXvgpCmnLoXohOA/640?wx_fmt=jpeg&amp;amp;wxfrom=5&amp;amp;wx_lazy=1&amp;amp;wx_co=1&amp;amp;tp=wxpic#imgIndex=4&quot; data-type=&quot;jpeg&quot; data-w=&quot;505&quot; style=&quot;outline: 0px; visibility: visible !important; width: 677px !important; height: auto !important;&quot; data-original-style=&quot;outline: 0px;visibility: visible !important;width: 677px !important;&quot; data-index=&quot;7&quot; src=&quot;https://mmbiz.qpic.cn/mmbiz_jpg/7fxWIIIo4QsSWJrLBaAicBRCZunB1lYpWvqx8H4Jd372xbOhIy5u0WC4cMLxPxoThBsOhxUMQXvgpCmnLoXohOA/640?wx_fmt=jpeg&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1&amp;tp=wxpic#imgIndex=4&quot; _width=&quot;677px&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780111000446&quot; data-report-img-idx=&quot;4&quot; data-fail=&quot;0&quot;/&gt;&lt;/section&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);&quot; class=&quot;js_darkmode__50&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__51&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;&quot;&gt;添加Nuget引用后，Project在不同的.NET 目标框架的引用是这样的：&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);&quot; class=&quot;js_darkmode__52&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;section style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__53&quot;&gt;&lt;img data-src=&quot;https://mmbiz.qpic.cn/mmbiz_jpg/7fxWIIIo4QsSWJrLBaAicBRCZunB1lYpWotpYlvRdASPLJ7CicXuGLnq6GARPSeRMRU40qGMs4Lu6948nV0owu9Q/640?wx_fmt=jpeg&amp;amp;wxfrom=5&amp;amp;wx_lazy=1&amp;amp;wx_co=1&amp;amp;tp=wxpic#imgIndex=5&quot; class=&quot;rich_pages wxw-img&quot; data-ratio=&quot;0.7104377104377104&quot; data-type=&quot;jpeg&quot; data-w=&quot;297&quot; style=&quot;outline: 0px; visibility: visible !important; width: 297px !important; height: auto !important;&quot; data-aistatus=&quot;1&quot; data-original-style=&quot;outline: 0px;visibility: visible !important;width: 297px !important;&quot; data-index=&quot;8&quot; src=&quot;https://mmbiz.qpic.cn/mmbiz_jpg/7fxWIIIo4QsSWJrLBaAicBRCZunB1lYpWotpYlvRdASPLJ7CicXuGLnq6GARPSeRMRU40qGMs4Lu6948nV0owu9Q/640?wx_fmt=jpeg&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1&amp;tp=wxpic#imgIndex=5&quot; _width=&quot;297px&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780111001330&quot; data-report-img-idx=&quot;5&quot; data-fail=&quot;0&quot;/&gt;&lt;/section&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);&quot; class=&quot;js_darkmode__54&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__55&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;&quot;&gt;当然，我们可以为单独为指定的.NET 目标框架添加不同的引用，例如：&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__56&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;pre style=&quot;outline: 0px;letter-spacing: 0.544px;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);overflow-x: auto;&quot; class=&quot;js_darkmode__57&quot;&gt;&lt;code style=&quot;margin-right: 0.15em;margin-left: 0.15em;padding: 0.5em;outline: 0px;font-size: 0.85em;font-family: Consolas, Menlo, Courier, monospace;overflow: auto;color: rgb(171, 178, 191);text-size-adjust: none;min-width: 400px;background: none 0% 0% / auto repeat scroll padding-box border-box rgb(40, 44, 52);display: block !important;&quot; class=&quot;js_darkmode__58&quot;&gt;&lt;span style=&quot;outline: 0px;&quot;&gt;&amp;lt;&lt;span style=&quot;outline: 0px;color: #E06C75;&quot;&gt;Project&lt;/span&gt;&lt;span style=&quot;outline: 0px;color: #D19A66;&quot;&gt;Sdk&lt;/span&gt;=&lt;span style=&quot;outline: 0px;color: #98C379;&quot;&gt;&amp;quot;Microsoft.NET.Sdk&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br/&gt;&lt;span style=&quot;outline: 0px;&quot;&gt;&amp;lt;&lt;span style=&quot;outline: 0px;color: #E06C75;&quot;&gt;PropertyGroup&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br/&gt;&lt;span style=&quot;outline: 0px;&quot;&gt;&amp;lt;&lt;span style=&quot;outline: 0px;color: #E06C75;&quot;&gt;TargetFrameworks&lt;/span&gt;&amp;gt;&lt;/span&gt;netstandard2.0;net451;&lt;span style=&quot;outline: 0px;&quot;&gt;&amp;lt;/&lt;span style=&quot;outline: 0px;color: #E06C75;&quot;&gt;TargetFrameworks&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br/&gt;&lt;span style=&quot;outline: 0px;&quot;&gt;&amp;lt;/&lt;span style=&quot;outline: 0px;color: #E06C75;&quot;&gt;PropertyGroup&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br/&gt;&lt;span style=&quot;outline: 0px;&quot;&gt;&amp;lt;&lt;span style=&quot;outline: 0px;color: #E06C75;&quot;&gt;ItemGroup&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br/&gt;&lt;span style=&quot;outline: 0px;&quot;&gt;&amp;lt;&lt;span style=&quot;outline: 0px;color: #E06C75;&quot;&gt;PackageReference&lt;/span&gt;&lt;span style=&quot;outline: 0px;color: #D19A66;&quot;&gt;Include&lt;/span&gt;=&lt;span style=&quot;outline: 0px;color: #98C379;&quot;&gt;&amp;quot;Newtonsoft.Json&amp;quot;&lt;/span&gt;&lt;span style=&quot;outline: 0px;color: #D19A66;&quot;&gt;Version&lt;/span&gt;=&lt;span style=&quot;outline: 0px;color: #98C379;&quot;&gt;&amp;quot;12.0.2&amp;quot;&lt;/span&gt;&amp;nbsp;/&amp;gt;&lt;/span&gt;&lt;br/&gt;&lt;span style=&quot;outline: 0px;&quot;&gt;&amp;lt;/&lt;span style=&quot;outline: 0px;color: #E06C75;&quot;&gt;ItemGroup&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br/&gt;&lt;span style=&quot;outline: 0px;&quot;&gt;&amp;lt;&lt;span style=&quot;outline: 0px;color: #E06C75;&quot;&gt;ItemGroup&lt;/span&gt;&lt;span style=&quot;outline: 0px;color: #D19A66;&quot;&gt;Condition&lt;/span&gt;=&lt;span style=&quot;outline: 0px;color: #98C379;&quot;&gt;&amp;quot; &amp;#39;$(TargetFramework)&amp;#39; == &amp;#39;net451&amp;#39; &amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br/&gt;&lt;span style=&quot;outline: 0px;&quot;&gt;&amp;lt;&lt;span style=&quot;outline: 0px;color: #E06C75;&quot;&gt;ProjectReference&lt;/span&gt;&lt;span style=&quot;outline: 0px;color: #D19A66;&quot;&gt;Include&lt;/span&gt;=&lt;span style=&quot;outline: 0px;color: #98C379;&quot;&gt;&amp;quot;..\LibNetFramework\LibNetFramework.csproj&amp;quot;&lt;/span&gt;&amp;nbsp;/&amp;gt;&lt;/span&gt;&lt;br/&gt;&lt;span style=&quot;outline: 0px;&quot;&gt;&amp;lt;/&lt;span style=&quot;outline: 0px;color: #E06C75;&quot;&gt;ItemGroup&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br/&gt;&lt;span style=&quot;outline: 0px;&quot;&gt;&amp;lt;&lt;span style=&quot;outline: 0px;color: #E06C75;&quot;&gt;ItemGroup&lt;/span&gt;&lt;span style=&quot;outline: 0px;color: #D19A66;&quot;&gt;Condition&lt;/span&gt;=&lt;span style=&quot;outline: 0px;color: #98C379;&quot;&gt;&amp;quot; &amp;#39;$(TargetFramework)&amp;#39; == &amp;#39;netstandard2.0&amp;#39; &amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br/&gt;&lt;span style=&quot;outline: 0px;&quot;&gt;&amp;lt;&lt;span style=&quot;outline: 0px;color: #E06C75;&quot;&gt;ProjectReference&lt;/span&gt;&lt;span style=&quot;outline: 0px;color: #D19A66;&quot;&gt;Include&lt;/span&gt;=&lt;span style=&quot;outline: 0px;color: #98C379;&quot;&gt;&amp;quot;..\LibNetCore\LibNetCore.csproj&amp;quot;&lt;/span&gt;&amp;nbsp;/&amp;gt;&lt;/span&gt;&lt;br/&gt;&lt;span style=&quot;outline: 0px;&quot;&gt;&amp;lt;/&lt;span style=&quot;outline: 0px;color: #E06C75;&quot;&gt;ItemGroup&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br/&gt;&lt;span style=&quot;outline: 0px;&quot;&gt;&amp;lt;/&lt;span style=&quot;outline: 0px;color: #E06C75;&quot;&gt;Project&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);&quot; class=&quot;js_darkmode__59&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__60&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;&quot;&gt;&lt;br/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__61&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;&quot;&gt;&lt;img data-src=&quot;https://mmbiz.qpic.cn/mmbiz_jpg/7fxWIIIo4QsSWJrLBaAicBRCZunB1lYpWQM4bMMZTYticATXwpReTRDQZzHFe4opStBn3iaibynt8fXBbemqjV37ow/640?wx_fmt=jpeg&amp;amp;wxfrom=5&amp;amp;wx_lazy=1&amp;amp;wx_co=1&amp;amp;tp=wxpic#imgIndex=6&quot; class=&quot;rich_pages wxw-img&quot; data-ratio=&quot;0.839041095890411&quot; data-type=&quot;jpeg&quot; data-w=&quot;292&quot; style=&quot;outline: 0px; visibility: visible !important; width: 292px !important; height: auto !important;&quot; data-aistatus=&quot;1&quot; data-original-style=&quot;outline: 0px;visibility: visible !important;width: 292px !important;&quot; data-index=&quot;9&quot; src=&quot;https://mmbiz.qpic.cn/mmbiz_jpg/7fxWIIIo4QsSWJrLBaAicBRCZunB1lYpWQM4bMMZTYticATXwpReTRDQZzHFe4opStBn3iaibynt8fXBbemqjV37ow/640?wx_fmt=jpeg&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1&amp;tp=wxpic#imgIndex=6&quot; _width=&quot;292px&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780111003179&quot; data-report-img-idx=&quot;6&quot; data-fail=&quot;0&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__62&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;&quot;&gt;&lt;br/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__63&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;&quot;&gt;参考链接：https://docs.microsoft.com/en-us/dotnet/standard/frameworks&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);&quot; class=&quot;js_darkmode__64&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__65&quot;&gt;&lt;span style=&quot;outline: 0px;color: #AB1942;&quot; class=&quot;js_darkmode__66&quot;&gt;&lt;strong style=&quot;outline: 0px;&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;&quot;&gt;二、代码中使用预处理指令同时支持.NET Framework 和 .NET Core&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);&quot; class=&quot;js_darkmode__67&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__68&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;&quot;&gt;如果同一块业务逻辑，在.NET Framework和.NET Core实现不一样，我们在同一个代码中，如果通过预处理指令实现：&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__69&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;pre style=&quot;outline: 0px;letter-spacing: 0.544px;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);overflow-x: auto;&quot; class=&quot;js_darkmode__70&quot;&gt;&lt;code style=&quot;margin-right: 0.15em;margin-left: 0.15em;padding: 0.5em;outline: 0px;font-size: 0.85em;font-family: Consolas, Menlo, Courier, monospace;overflow: auto;color: rgb(171, 178, 191);text-size-adjust: none;min-width: 400px;background: none 0% 0% / auto repeat scroll padding-box border-box rgb(40, 44, 52);display: block !important;&quot; class=&quot;js_darkmode__71&quot;&gt;&lt;span style=&quot;outline: 0px;color: #C678DD;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;outline: 0px;color: #C678DD;&quot;&gt;string&lt;/span&gt;&amp;nbsp;UserID&lt;br/&gt;{&lt;br/&gt;&lt;span style=&quot;outline: 0px;color: #C678DD;&quot;&gt;get&lt;/span&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br/&gt;&lt;span style=&quot;outline: 0px;color: #61AEEE;&quot;&gt;#&lt;span style=&quot;outline: 0px;&quot;&gt;if&lt;/span&gt;&amp;nbsp;NET451&lt;/span&gt;&lt;br/&gt;&lt;span style=&quot;outline: 0px;color: #C678DD;&quot;&gt;return&lt;/span&gt;&amp;nbsp;Convert.ToString(HttpContext.Current.Session[&lt;span style=&quot;outline: 0px;color: #98C379;&quot;&gt;&amp;quot;UserID&amp;quot;&lt;/span&gt;]);&lt;br/&gt;&lt;span style=&quot;outline: 0px;color: #61AEEE;&quot;&gt;#&lt;span style=&quot;outline: 0px;&quot;&gt;elif&lt;/span&gt;&amp;nbsp;NETSTANDARD2_0&lt;/span&gt;&lt;br/&gt;&lt;span style=&quot;outline: 0px;color: #C678DD;&quot;&gt;return&lt;/span&gt;&amp;nbsp;httpContext.Session.GetString(&lt;span style=&quot;outline: 0px;color: #98C379;&quot;&gt;&amp;quot;UserID&amp;quot;&lt;/span&gt;);&lt;br/&gt;&lt;span style=&quot;outline: 0px;color: #61AEEE;&quot;&gt;#&lt;span style=&quot;outline: 0px;&quot;&gt;endif&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br/&gt;&lt;span style=&quot;outline: 0px;color: #C678DD;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;outline: 0px;color: #C678DD;&quot;&gt;set&lt;/span&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br/&gt;&lt;span style=&quot;outline: 0px;color: #61AEEE;&quot;&gt;#&lt;span style=&quot;outline: 0px;&quot;&gt;if&lt;/span&gt;&amp;nbsp;NET451&lt;/span&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; HttpContext.Current.Session[&lt;span style=&quot;outline: 0px;color: #98C379;&quot;&gt;&amp;quot;UserID&amp;quot;&lt;/span&gt;] =&amp;nbsp;&lt;span style=&quot;outline: 0px;color: #C678DD;&quot;&gt;value&lt;/span&gt;;&lt;br/&gt;&lt;span style=&quot;outline: 0px;color: #61AEEE;&quot;&gt;#&lt;span style=&quot;outline: 0px;&quot;&gt;elif&lt;/span&gt;&amp;nbsp;NETSTANDARD2_0&lt;/span&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; httpContext.Session.SetString(&lt;span style=&quot;outline: 0px;color: #98C379;&quot;&gt;&amp;quot;UserID&amp;quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;outline: 0px;color: #C678DD;&quot;&gt;value&lt;/span&gt;);&lt;br/&gt;&lt;span style=&quot;outline: 0px;color: #61AEEE;&quot;&gt;#&lt;span style=&quot;outline: 0px;&quot;&gt;endif&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br/&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__72&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;&quot;&gt;参考链接：&lt;/span&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;&quot;&gt;https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives/preprocessor-if&lt;/span&gt;&lt;br/&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);&quot; class=&quot;js_darkmode__73&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__74&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;&quot;&gt;这个地方有个对照表：&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__75&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;&quot;&gt;&lt;br/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__76&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;&quot;&gt;&lt;img data-src=&quot;https://mmbiz.qpic.cn/mmbiz_jpg/7fxWIIIo4QsSWJrLBaAicBRCZunB1lYpWHmEHeKgHjqI3OhKQNdxeCXNmhpg05UHQnsJI0ZROUYGP8Xf51BKESQ/640?wx_fmt=jpeg&amp;amp;wxfrom=5&amp;amp;wx_lazy=1&amp;amp;wx_co=1&amp;amp;tp=wxpic#imgIndex=7&quot; class=&quot;rich_pages wxw-img&quot; data-ratio=&quot;0.3092885375494071&quot; data-type=&quot;jpeg&quot; data-w=&quot;1012&quot; style=&quot;outline: 0px; visibility: visible !important; width: 677px !important; height: auto !important;&quot; data-backw=&quot;574&quot; data-backh=&quot;178&quot; data-before-oversubscription-url=&quot;https://img2018.cnblogs.com/blog/23525/201909/23525-20190930223936815-151543847.jpg&quot; data-aistatus=&quot;1&quot; data-original-style=&quot;outline: 0px;visibility: visible !important;width: 677px !important;&quot; data-index=&quot;10&quot; src=&quot;https://mmbiz.qpic.cn/mmbiz_jpg/7fxWIIIo4QsSWJrLBaAicBRCZunB1lYpWHmEHeKgHjqI3OhKQNdxeCXNmhpg05UHQnsJI0ZROUYGP8Xf51BKESQ/640?wx_fmt=jpeg&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1&amp;tp=wxpic#imgIndex=7&quot; _width=&quot;677px&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780111005107&quot; data-report-img-idx=&quot;7&quot; data-fail=&quot;0&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);&quot; class=&quot;js_darkmode__77&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__78&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;&quot;&gt;这样，代码写完后，编译一下，可以看到有两个文件夹生成：&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__79&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;pre style=&quot;outline: 0px;letter-spacing: 0.544px;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);overflow-x: auto;&quot; class=&quot;js_darkmode__80&quot;&gt;&lt;code style=&quot;margin-right: 0.15em;margin-left: 0.15em;padding: 0.5em;outline: 0px;font-size: 0.85em;font-family: Consolas, Menlo, Courier, monospace;overflow: auto;color: rgb(171, 178, 191);text-size-adjust: none;min-width: 400px;background: none 0% 0% / auto repeat scroll padding-box border-box rgb(40, 44, 52);display: block !important;&quot; class=&quot;js_darkmode__81&quot;&gt;1&amp;gt;------ 已启动全部重新生成: 项目: LibNetCore, 配置: Debug Any CPU ------&lt;br/&gt;&lt;br/&gt;1&amp;gt;C:\Program Files\dotnet\sdk\3.0.100-preview3-010431\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(151,5): message NETSDK1057: 你正在使用 .NET Core 的预览版。请查看 https://aka.ms/dotnet-core-preview&lt;br/&gt;&lt;br/&gt;1&amp;gt;LibNetCore -&amp;gt; C:\Users\zhougq\&lt;span style=&quot;outline: 0px;color: #E6C07B;&quot;&gt;source&lt;/span&gt;\repos\LibNetCore\bin\Debug\netstandard2.0\LibNetCore.dll&lt;br/&gt;&lt;br/&gt;2&amp;gt;------ 已启动全部重新生成: 项目: TestLibrary, 配置: Debug Any CPU ------&lt;br/&gt;&lt;br/&gt;2&amp;gt;C:\Program Files\dotnet\sdk\3.0.100-preview3-010431\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(151,5): message NETSDK1057: 你正在使用 .NET Core 的预览版。请查看 https://aka.ms/dotnet-core-preview&lt;br/&gt;&lt;br/&gt;2&amp;gt;TestLibrary -&amp;gt; C:\Users\zhougq\&lt;span style=&quot;outline: 0px;color: #E6C07B;&quot;&gt;source&lt;/span&gt;\repos\TestLibrary\bin\Debug\netstandard2.0\TestLibrary.dll&lt;br/&gt;&lt;br/&gt;2&amp;gt;TestLibrary -&amp;gt; C:\Users\zhougq\&lt;span style=&quot;outline: 0px;color: #E6C07B;&quot;&gt;source&lt;/span&gt;\repos\TestLibrary\bin\Debug\net451\TestLibrary.dll&lt;br/&gt;&lt;br/&gt;========== 全部重新生成: 成功 2 个，失败 0 个，跳过 0 个 ==========&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);&quot; class=&quot;js_darkmode__82&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__83&quot;&gt;&lt;span style=&quot;outline: 0px;color: #AB1942;&quot; class=&quot;js_darkmode__84&quot;&gt;&lt;strong style=&quot;outline: 0px;&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;&quot;&gt;三、编译生成两个.NET框架的Dll，制作支持多个.NET目标框架的Nuget包&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);&quot; class=&quot;js_darkmode__85&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__86&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;&quot;&gt;&amp;nbsp;上个步骤中生成的两个.NET 目标版本的dll，可以分别制作支持多个.NET 目标框架的Nuget包。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__88&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;&quot;&gt;右键Project属性设置中，可以设置Nuget打包&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);&quot; class=&quot;js_darkmode__89&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;section style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__90&quot;&gt;&lt;img class=&quot;rich_pages wxw-img&quot; data-aistatus=&quot;1&quot; data-backh=&quot;444&quot; data-backw=&quot;574&quot; data-before-oversubscription-url=&quot;https://img2018.cnblogs.com/blog/23525/201909/23525-20190930224549644-1970219628.jpg&quot; data-ratio=&quot;0.7741935483870968&quot; data-src=&quot;https://mmbiz.qpic.cn/mmbiz_jpg/7fxWIIIo4QsSWJrLBaAicBRCZunB1lYpWKICUL4h1HqTIo0USRUVpz2lvfvE9Yib9OAJqicHNRGRcx5uYP8vDicTaw/640?wx_fmt=jpeg&amp;amp;wxfrom=5&amp;amp;wx_lazy=1&amp;amp;wx_co=1&amp;amp;tp=wxpic#imgIndex=8&quot; data-type=&quot;jpeg&quot; data-w=&quot;1054&quot; style=&quot;outline: 0px; visibility: visible !important; width: 677px !important; height: auto !important;&quot; data-original-style=&quot;outline: 0px;visibility: visible !important;width: 677px !important;&quot; data-index=&quot;11&quot; src=&quot;https://mmbiz.qpic.cn/mmbiz_jpg/7fxWIIIo4QsSWJrLBaAicBRCZunB1lYpWKICUL4h1HqTIo0USRUVpz2lvfvE9Yib9OAJqicHNRGRcx5uYP8vDicTaw/640?wx_fmt=jpeg&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1&amp;tp=wxpic#imgIndex=8&quot; _width=&quot;677px&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780111007423&quot; data-report-img-idx=&quot;8&quot; data-fail=&quot;0&quot;/&gt;&lt;/section&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);&quot; class=&quot;js_darkmode__91&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__92&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;&quot;&gt;编译工程：Successfully created package &amp;#39;C:\Users\zhougq\source\repos\TestLibrary\bin\Debug\TestLibrary.1.0.0.nupkg&amp;#39;.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);&quot; class=&quot;js_darkmode__93&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;text-align: left;&quot;&gt;&lt;br/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);&quot; class=&quot;js_darkmode__94&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;text-align: left;&quot;&gt;使用PackageExplorer编辑生成好的Nuget包：&lt;/span&gt;&lt;br/&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__95&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;&quot;&gt;&lt;br/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);text-align: left;&quot; class=&quot;js_darkmode__96&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;&quot;&gt;&lt;img data-src=&quot;https://mmbiz.qpic.cn/mmbiz_jpg/7fxWIIIo4QsSWJrLBaAicBRCZunB1lYpWpFibcZuksUib5LickiawXEF8ZCeVy2n58Kj6jl6YKptesdB4BBbFJttxJg/640?wx_fmt=jpeg&amp;amp;wxfrom=5&amp;amp;wx_lazy=1&amp;amp;wx_co=1&amp;amp;tp=wxpic#imgIndex=9&quot; class=&quot;rich_pages wxw-img&quot; data-ratio=&quot;0.4441747572815534&quot; data-type=&quot;jpeg&quot; data-w=&quot;824&quot; style=&quot;outline: 0px; visibility: visible !important; width: 677px !important; height: auto !important;&quot; data-backw=&quot;574&quot; data-backh=&quot;255&quot; data-before-oversubscription-url=&quot;https://img2018.cnblogs.com/blog/23525/201909/23525-20190930224918496-654055359.jpg&quot; data-aistatus=&quot;1&quot; data-original-style=&quot;outline: 0px;visibility: visible !important;width: 677px !important;&quot; data-index=&quot;12&quot; src=&quot;https://mmbiz.qpic.cn/mmbiz_jpg/7fxWIIIo4QsSWJrLBaAicBRCZunB1lYpWpFibcZuksUib5LickiawXEF8ZCeVy2n58Kj6jl6YKptesdB4BBbFJttxJg/640?wx_fmt=jpeg&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1&amp;tp=wxpic#imgIndex=9&quot; _width=&quot;677px&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780111010206&quot; data-report-img-idx=&quot;9&quot; data-fail=&quot;0&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);&quot; class=&quot;js_darkmode__97&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0px;outline: 0px;font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(34, 34, 34);background-color: rgb(255, 255, 255);&quot; class=&quot;js_darkmode__98&quot;&gt;&lt;span style=&quot;outline: 0px;font-size: 15px;text-align: left;&quot;&gt;以上就是本次的.NETCore 技术分享。&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Sat, 30 May 2026 11:17:01 +0800</pubDate></item><item><title>C#.NET MemoryMarshal 深入解析：零拷贝内存重解释、二进制读写与使用边界</title><link>https://www.codepub.top/post/465.html</link><description>&lt;h3 data-heading=&quot;true&quot; style=&quot;padding-left: 8px; border-left: 3px solid rgb(15, 76, 129); margin-right: 8px; margin-bottom: 0.75em; margin-left: 0px; color: rgb(63, 63, 63); font-size: 17.6px; font-weight: bold; line-height: 1.2; margin-top: 0px !important; visibility: visible;&quot; class=&quot;js_darkmode__0&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;简介&lt;/span&gt;&lt;/h3&gt;&lt;p style=&quot;margin: 1.5em 8px; letter-spacing: 0.1em; color: rgb(63, 63, 63); visibility: visible;&quot; class=&quot;js_darkmode__1&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;在&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;font-size: 90%; color: rgb(221, 17, 68); background: rgba(27, 31, 35, 0.05); padding: 3px 5px; border-radius: 4px; visibility: visible;&quot; class=&quot;js_darkmode__2&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;.NET&lt;/span&gt;&lt;/code&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;&amp;nbsp;高性能内存编程里，&lt;/span&gt;&lt;code style=&quot;font-size: 90%; color: rgb(221, 17, 68); background: rgba(27, 31, 35, 0.05); padding: 3px 5px; border-radius: 4px; visibility: visible;&quot; class=&quot;js_darkmode__3&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;Span&amp;lt;T&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;&amp;nbsp;解决了一个很实际的问题：&lt;/span&gt;&lt;/p&gt;&lt;blockquote style=&quot;font-style: normal; padding: 1em; border-left: 4px solid rgb(15, 76, 129); border-radius: 6px; color: rgb(63, 63, 63); background: rgb(247, 247, 247); margin-bottom: 1em; visibility: visible;&quot; class=&quot;js_darkmode__4&quot;&gt;&lt;p style=&quot;display: block; font-size: 1em; letter-spacing: 0.1em; color: rgb(63, 63, 63); margin: 0px; visibility: visible;&quot; class=&quot;js_darkmode__5&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;不复制数据，也能操作一段连续内存。&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p style=&quot;margin: 1.5em 8px; letter-spacing: 0.1em; color: rgb(63, 63, 63); visibility: visible;&quot; class=&quot;js_darkmode__6&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;但&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;font-size: 90%; color: rgb(221, 17, 68); background: rgba(27, 31, 35, 0.05); padding: 3px 5px; border-radius: 4px; visibility: visible;&quot; class=&quot;js_darkmode__7&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;Span&amp;lt;T&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;&amp;nbsp;本身还是比较“规矩”的。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px; letter-spacing: 0.1em; color: rgb(63, 63, 63); visibility: visible;&quot; class=&quot;js_darkmode__8&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;比如：&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;list-style-type: circle;&quot; class=&quot;js_darkmode__9 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section style=&quot;visibility: visible;&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;•&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;font-size: 90%; color: rgb(221, 17, 68); background: rgba(27, 31, 35, 0.05); padding: 3px 5px; border-radius: 4px; visibility: visible;&quot; class=&quot;js_darkmode__11&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;Span&amp;lt;byte&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;&amp;nbsp;就是按字节看；&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section style=&quot;visibility: visible;&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;•&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;font-size: 90%; color: rgb(221, 17, 68); background: rgba(27, 31, 35, 0.05); padding: 3px 5px; border-radius: 4px; visibility: visible;&quot; class=&quot;js_darkmode__13&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;Span&amp;lt;int&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;&amp;nbsp;就是按整数看；&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section style=&quot;visibility: visible;&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;•&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;font-size: 90%; color: rgb(221, 17, 68); background: rgba(27, 31, 35, 0.05); padding: 3px 5px; border-radius: 4px; visibility: visible;&quot; class=&quot;js_darkmode__15&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;ReadOnlyMemory&amp;lt;T&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;&amp;nbsp;背后到底是不是数组，不一定直接暴露；&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section style=&quot;visibility: visible;&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;• 想把一段字节当成结构体读出来，也不能直接强转。&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 1.5em 8px; letter-spacing: 0.1em; color: rgb(63, 63, 63); visibility: visible;&quot; class=&quot;js_darkmode__17&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;这时候就会遇到&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;font-size: 90%; color: rgb(221, 17, 68); background: rgba(27, 31, 35, 0.05); padding: 3px 5px; border-radius: 4px; visibility: visible;&quot; class=&quot;js_darkmode__18&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;MemoryMarshal&lt;/span&gt;&lt;/code&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px; letter-spacing: 0.1em; color: rgb(63, 63, 63); visibility: visible;&quot; class=&quot;js_darkmode__19&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;一句话先说清楚：&lt;/span&gt;&lt;/p&gt;&lt;blockquote style=&quot;font-style: normal; padding: 1em; border-left: 4px solid rgb(15, 76, 129); border-radius: 6px; color: rgb(63, 63, 63); background: rgb(247, 247, 247); margin-bottom: 1em; visibility: visible;&quot; class=&quot;js_darkmode__20&quot;&gt;&lt;p style=&quot;display: block; font-size: 1em; letter-spacing: 0.1em; color: rgb(63, 63, 63); margin: 0px; visibility: visible;&quot; class=&quot;js_darkmode__21&quot;&gt;&lt;code style=&quot;font-size: 90%; color: rgb(221, 17, 68); background: rgba(27, 31, 35, 0.05); padding: 3px 5px; border-radius: 4px; visibility: visible;&quot; class=&quot;js_darkmode__22&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;MemoryMarshal&lt;/span&gt;&lt;/code&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;&amp;nbsp;是一组底层内存工具，用来在&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;font-size: 90%; color: rgb(221, 17, 68); background: rgba(27, 31, 35, 0.05); padding: 3px 5px; border-radius: 4px; visibility: visible;&quot; class=&quot;js_darkmode__23&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;Span&amp;lt;T&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;、&lt;/span&gt;&lt;code style=&quot;font-size: 90%; color: rgb(221, 17, 68); background: rgba(27, 31, 35, 0.05); padding: 3px 5px; border-radius: 4px; visibility: visible;&quot; class=&quot;js_darkmode__24&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;Memory&amp;lt;T&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;、结构体和字节之间做零拷贝转换、读取和桥接。&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p style=&quot;margin: 1.5em 8px; letter-spacing: 0.1em; color: rgb(63, 63, 63); visibility: visible;&quot; class=&quot;js_darkmode__25&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;它的价值很直接：&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;list-style-type: circle;&quot; class=&quot;js_darkmode__26 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section style=&quot;visibility: visible;&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;• 少分配；&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section style=&quot;visibility: visible;&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;• 少复制；&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section style=&quot;visibility: visible;&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;• 直接按另一种视角看同一段内存；&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section style=&quot;visibility: visible;&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;• 在二进制协议、文件格式、网络缓冲区、序列化场景里减少中间对象。&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__31&quot;&gt;但它不是日常业务代码里的默认工具。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__32&quot;&gt;因为&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__33&quot;&gt;MemoryMarshal&lt;/code&gt;&amp;nbsp;做的很多事，本质上是在绕过一部分类型系统的保护。用对了，代码很干净，性能也好；用错了，问题通常比较隐蔽。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__34&quot;&gt;这篇文章主要讲清楚：&lt;/p&gt;&lt;ul style=&quot;list-style-type: circle;&quot; class=&quot;js_darkmode__35 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section&gt;•&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__37&quot;&gt;MemoryMarshal&lt;/code&gt;&amp;nbsp;到底是什么；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 它和&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__39&quot;&gt;Span&amp;lt;T&amp;gt;&lt;/code&gt;、&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__40&quot;&gt;Memory&amp;lt;T&amp;gt;&lt;/code&gt;&amp;nbsp;是什么关系；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;•&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__42&quot;&gt;Cast&lt;/code&gt;、&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__43&quot;&gt;AsBytes&lt;/code&gt;、&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__44&quot;&gt;Read&lt;/code&gt;、&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__45&quot;&gt;Write&lt;/code&gt;&amp;nbsp;怎么用；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;•&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__47&quot;&gt;GetReference&lt;/code&gt;、&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__48&quot;&gt;TryGetArray&lt;/code&gt;&amp;nbsp;适合什么场景；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 什么情况下不该用它；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 使用时最容易踩哪些坑。&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 data-heading=&quot;true&quot; style=&quot;padding-left: 8px;border-left: 3px solid #0F4C81;margin: 2em 8px 0.75em 0;color: #3f3f3f;font-size: 17.6px;font-weight: bold;line-height: 1.2;&quot; class=&quot;js_darkmode__51&quot;&gt;先把定位说清楚&lt;/h3&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__52&quot;&gt;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__53&quot;&gt;MemoryMarshal&lt;/code&gt;&amp;nbsp;位于：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__54&quot;&gt;System.Runtime.InteropServices&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__55&quot;&gt;它是一个静态工具类，主要服务于这些类型：&lt;/p&gt;&lt;ul style=&quot;list-style-type: circle;&quot; class=&quot;js_darkmode__56 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section&gt;•&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__58&quot;&gt;Span&amp;lt;T&amp;gt;&lt;/code&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;•&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__60&quot;&gt;ReadOnlySpan&amp;lt;T&amp;gt;&lt;/code&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;•&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__62&quot;&gt;Memory&amp;lt;T&amp;gt;&lt;/code&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;•&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__64&quot;&gt;ReadOnlyMemory&amp;lt;T&amp;gt;&lt;/code&gt;&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__65&quot;&gt;普通代码里，&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__66&quot;&gt;Span&amp;lt;T&amp;gt;&lt;/code&gt;&amp;nbsp;负责表达“一段连续内存”。&lt;br/&gt;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__67&quot;&gt;MemoryMarshal&lt;/code&gt;&amp;nbsp;则负责做更底层的事：&lt;/p&gt;&lt;ul style=&quot;list-style-type: circle;&quot; class=&quot;js_darkmode__68 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section&gt;• 把同一段内存按另一种类型解释；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 把结构体和字节互相读取、写入；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 从&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__72&quot;&gt;Memory&amp;lt;T&amp;gt;&lt;/code&gt;&amp;nbsp;里尝试拿到底层数组；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 从&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__74&quot;&gt;Span&amp;lt;T&amp;gt;&lt;/code&gt;&amp;nbsp;里拿到第一个元素的&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__75&quot;&gt;ref&lt;/code&gt;。&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__76&quot;&gt;可以这么理解：&lt;/p&gt;&lt;ul style=&quot;list-style-type: circle;&quot; class=&quot;js_darkmode__77 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section&gt;•&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__79&quot;&gt;Span&amp;lt;T&amp;gt;&lt;/code&gt;&amp;nbsp;是安全的内存窗口；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;•&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__81&quot;&gt;MemoryMarshal&lt;/code&gt;&amp;nbsp;是操作这个窗口的底层工具箱。&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 data-heading=&quot;true&quot; style=&quot;padding-left: 8px;border-left: 3px solid #0F4C81;margin: 2em 8px 0.75em 0;color: #3f3f3f;font-size: 17.6px;font-weight: bold;line-height: 1.2;&quot; class=&quot;js_darkmode__82&quot;&gt;它解决的不是“能不能做”，而是“要不要复制”&lt;/h3&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__83&quot;&gt;先看一个普通的二进制解析场景。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__84&quot;&gt;假设有 4 个字节：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__85&quot;&gt;byte[]&amp;nbsp;data&amp;nbsp;=&amp;nbsp;{&amp;nbsp;1,&amp;nbsp;0,&amp;nbsp;0,&amp;nbsp;0&amp;nbsp;};&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__86&quot;&gt;想把它解析成一个&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__87&quot;&gt;int&lt;/code&gt;，常见写法是：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__88&quot;&gt;int&amp;nbsp;value&amp;nbsp;=&amp;nbsp;BitConverter.ToInt32(data,&amp;nbsp;0);&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__89&quot;&gt;这没问题，代码也清楚。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__90&quot;&gt;但在更复杂的场景里，比如一大块网络缓冲区里有很多结构体、很多字段、很多连续数据，如果每一步都复制、转换、创建对象，开销就会慢慢堆起来。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__91&quot;&gt;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__92&quot;&gt;MemoryMarshal&lt;/code&gt;&amp;nbsp;的思路不是“再造一份数据”，而是：&lt;/p&gt;&lt;blockquote style=&quot;font-style: normal;padding: 1em;border-left: 4px solid #0F4C81;border-radius: 6px;color: #3f3f3f;background: #f7f7f7;margin-bottom: 1em;&quot; class=&quot;js_darkmode__93&quot;&gt;&lt;p style=&quot;display: block;font-size: 1em;letter-spacing: 0.1em;color: #3f3f3f;margin: 0;&quot; class=&quot;js_darkmode__94&quot;&gt;同一段内存，换一种类型视角来看。&lt;/p&gt;&lt;/blockquote&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__95&quot;&gt;比如：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__96&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot;&gt;Span&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;byte&lt;/span&gt;&amp;gt; bytes = data;&lt;br/&gt;Span&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;int&lt;/span&gt;&amp;gt; ints = MemoryMarshal.Cast&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;byte&lt;/span&gt;,&lt;span style=&quot;color: #ffa657;&quot;&gt;&amp;nbsp;int&lt;/span&gt;&amp;gt;(bytes);&lt;br/&gt;&lt;br/&gt;Console.WriteLine(ints[&lt;span style=&quot;color: #79c0ff;&quot;&gt;0&lt;/span&gt;]);&lt;span style=&quot;color: #8b949e;&quot;&gt;&amp;nbsp;// 1&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__97&quot;&gt;这里没有创建新的&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__98&quot;&gt;int[]&lt;/code&gt;，也没有把字节复制到另一个地方。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__99&quot;&gt;只是把原来的 4 个字节，按一个&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__100&quot;&gt;int&lt;/code&gt;&amp;nbsp;来看。&lt;/p&gt;&lt;h3 data-heading=&quot;true&quot; style=&quot;padding-left: 8px;border-left: 3px solid #0F4C81;margin: 2em 8px 0.75em 0;color: #3f3f3f;font-size: 17.6px;font-weight: bold;line-height: 1.2;&quot; class=&quot;js_darkmode__101&quot;&gt;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__102&quot;&gt;Cast&amp;lt;TFrom, TTo&amp;gt;&lt;/code&gt;：把一段内存换个类型看&lt;/h3&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__103&quot;&gt;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__104&quot;&gt;Cast&lt;/code&gt;&amp;nbsp;是&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__105&quot;&gt;MemoryMarshal&lt;/code&gt;&amp;nbsp;里最常见的方法之一。&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__106&quot;&gt;Span&amp;lt;TTo&amp;gt;&amp;nbsp;MemoryMarshal.Cast&amp;lt;TFrom,&amp;nbsp;TTo&amp;gt;(Span&amp;lt;TFrom&amp;gt;&amp;nbsp;span)&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__107&quot;&gt;它的作用是：&lt;/p&gt;&lt;blockquote style=&quot;font-style: normal;padding: 1em;border-left: 4px solid #0F4C81;border-radius: 6px;color: #3f3f3f;background: #f7f7f7;margin-bottom: 1em;&quot; class=&quot;js_darkmode__108&quot;&gt;&lt;p style=&quot;display: block;font-size: 1em;letter-spacing: 0.1em;color: #3f3f3f;margin: 0;&quot; class=&quot;js_darkmode__109&quot;&gt;把&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__110&quot;&gt;Span&amp;lt;TFrom&amp;gt;&lt;/code&gt;&amp;nbsp;背后的同一段内存，重新解释成&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__111&quot;&gt;Span&amp;lt;TTo&amp;gt;&lt;/code&gt;。&lt;/p&gt;&lt;/blockquote&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__112&quot;&gt;例如：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__113&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot;&gt;&lt;span style=&quot;color: #ffa657;&quot;&gt;byte&lt;/span&gt;[] buffer =&lt;br/&gt;{&lt;span style=&quot;color: #79c0ff;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; 1&lt;/span&gt;,&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;0&lt;/span&gt;,&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;0&lt;/span&gt;,&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;0&lt;/span&gt;,&lt;span style=&quot;color: #79c0ff;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; 2&lt;/span&gt;,&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;0&lt;/span&gt;,&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;0&lt;/span&gt;,&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;0&lt;/span&gt;&lt;br/&gt;};&lt;br/&gt;&lt;br/&gt;Span&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;int&lt;/span&gt;&amp;gt; values = MemoryMarshal.Cast&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;byte&lt;/span&gt;,&lt;span style=&quot;color: #ffa657;&quot;&gt;&amp;nbsp;int&lt;/span&gt;&amp;gt;(buffer);&lt;br/&gt;&lt;br/&gt;Console.WriteLine(values[&lt;span style=&quot;color: #79c0ff;&quot;&gt;0&lt;/span&gt;]);&lt;span style=&quot;color: #8b949e;&quot;&gt;&amp;nbsp;// 1&lt;/span&gt;&lt;br/&gt;Console.WriteLine(values[&lt;span style=&quot;color: #79c0ff;&quot;&gt;1&lt;/span&gt;]);&lt;span style=&quot;color: #8b949e;&quot;&gt;&amp;nbsp;// 2&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__114&quot;&gt;这里的关系是：&lt;/p&gt;&lt;ul style=&quot;list-style-type: circle;&quot; class=&quot;js_darkmode__115 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section&gt;• 原始内存长度是 8 个字节；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 一个&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__118&quot;&gt;int&lt;/code&gt;&amp;nbsp;是 4 个字节；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 所以转换后的&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__120&quot;&gt;Span&amp;lt;int&amp;gt;&lt;/code&gt;&amp;nbsp;长度是 2。&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__121&quot;&gt;反过来也可以：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__122&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot;&gt;&lt;span style=&quot;color: #ffa657;&quot;&gt;int&lt;/span&gt;[] numbers = {&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;1&lt;/span&gt;,&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;2&lt;/span&gt;&amp;nbsp;};&lt;br/&gt;&lt;br/&gt;Span&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;byte&lt;/span&gt;&amp;gt; bytes = MemoryMarshal.Cast&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;int&lt;/span&gt;,&lt;span style=&quot;color: #ffa657;&quot;&gt;&amp;nbsp;byte&lt;/span&gt;&amp;gt;(numbers);&lt;br/&gt;&lt;br/&gt;Console.WriteLine(bytes.Length);&lt;span style=&quot;color: #8b949e;&quot;&gt;&amp;nbsp;// 8&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__123&quot;&gt;这类写法适合：&lt;/p&gt;&lt;ul style=&quot;list-style-type: circle;&quot; class=&quot;js_darkmode__124 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section&gt;• 把一批&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__126&quot;&gt;byte&lt;/code&gt;&amp;nbsp;看成&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__127&quot;&gt;int&lt;/code&gt;、&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__128&quot;&gt;short&lt;/code&gt;、&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__129&quot;&gt;long&lt;/code&gt;；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 把结构体数组看成字节；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 做二进制序列化、哈希、校验、网络发送前的数据视图转换。&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__132&quot;&gt;但&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__133&quot;&gt;Cast&lt;/code&gt;&amp;nbsp;不是普通类型转换。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__134&quot;&gt;下面这种理解是错的：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__135&quot;&gt;把&amp;nbsp;byte&amp;nbsp;转成&amp;nbsp;int&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__136&quot;&gt;更准确的是：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__137&quot;&gt;把同一段内存按&amp;nbsp;int&amp;nbsp;的布局重新解释&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__138&quot;&gt;这意味着它强依赖：&lt;/p&gt;&lt;ul style=&quot;list-style-type: circle;&quot; class=&quot;js_darkmode__139 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section&gt;• 类型大小；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 内存布局；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 当前机器的字节序；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 数据是否真的符合目标类型的解释方式。&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 data-heading=&quot;true&quot; style=&quot;padding-left: 8px;border-left: 3px solid #0F4C81;margin: 2em 8px 0.75em 0;color: #3f3f3f;font-size: 17.6px;font-weight: bold;line-height: 1.2;&quot; class=&quot;js_darkmode__144&quot;&gt;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__145&quot;&gt;AsBytes&amp;lt;T&amp;gt;&lt;/code&gt;：把结构体内存看成字节&lt;/h3&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__146&quot;&gt;如果目标只是把某段结构体内存变成字节视图，&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__147&quot;&gt;AsBytes&lt;/code&gt;&amp;nbsp;比&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__148&quot;&gt;Cast&amp;lt;T, byte&amp;gt;&lt;/code&gt;&amp;nbsp;更直观。&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__149&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot;&gt;&lt;span style=&quot;color: #ffa657;&quot;&gt;int&lt;/span&gt;[] numbers = {&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;1&lt;/span&gt;,&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;2&lt;/span&gt;,&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;3&lt;/span&gt;&amp;nbsp;};&lt;br/&gt;&lt;br/&gt;Span&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;byte&lt;/span&gt;&amp;gt; bytes = MemoryMarshal.AsBytes(numbers.AsSpan());&lt;br/&gt;&lt;br/&gt;Console.WriteLine(bytes.Length);&lt;span style=&quot;color: #8b949e;&quot;&gt;&amp;nbsp;// 12&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__150&quot;&gt;它没有复制&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__151&quot;&gt;numbers&lt;/code&gt;。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__152&quot;&gt;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__153&quot;&gt;bytes&lt;/code&gt;&amp;nbsp;看到的就是&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__154&quot;&gt;numbers&lt;/code&gt;&amp;nbsp;底层那块内存的字节形式。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__155&quot;&gt;修改&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__156&quot;&gt;bytes&lt;/code&gt;&amp;nbsp;也会影响原始数据：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__157&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot;&gt;&lt;span style=&quot;color: #ffa657;&quot;&gt;int&lt;/span&gt;[] numbers = {&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;1&lt;/span&gt;&amp;nbsp;};&lt;br/&gt;&lt;br/&gt;Span&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;byte&lt;/span&gt;&amp;gt; bytes = MemoryMarshal.AsBytes(numbers.AsSpan());&lt;br/&gt;bytes[&lt;span style=&quot;color: #79c0ff;&quot;&gt;0&lt;/span&gt;] =&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;2&lt;/span&gt;;&lt;br/&gt;&lt;br/&gt;Console.WriteLine(numbers[&lt;span style=&quot;color: #79c0ff;&quot;&gt;0&lt;/span&gt;]);&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__158&quot;&gt;在常见小端机器上，输出通常是：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__159&quot;&gt;2&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__160&quot;&gt;这也顺手暴露了一个关键点：&lt;/p&gt;&lt;blockquote style=&quot;font-style: normal;padding: 1em;border-left: 4px solid #0F4C81;border-radius: 6px;color: #3f3f3f;background: #f7f7f7;margin-bottom: 1em;&quot; class=&quot;js_darkmode__161&quot;&gt;&lt;p style=&quot;display: block;font-size: 1em;letter-spacing: 0.1em;color: #3f3f3f;margin: 0;&quot; class=&quot;js_darkmode__162&quot;&gt;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__163&quot;&gt;MemoryMarshal&lt;/code&gt;&amp;nbsp;操作的是内存原始表示，不会帮忙屏蔽字节序差异。&lt;/p&gt;&lt;/blockquote&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__164&quot;&gt;跨平台协议、网络协议、文件格式，只要规定了字节序，就不能只靠&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__165&quot;&gt;MemoryMarshal&lt;/code&gt;&amp;nbsp;猜。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__166&quot;&gt;这种场景通常要配合：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__167&quot;&gt;System.Buffers.Binary.BinaryPrimitives&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__168&quot;&gt;例如：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__169&quot;&gt;int&amp;nbsp;value&amp;nbsp;=&amp;nbsp;BinaryPrimitives.ReadInt32LittleEndian(buffer);&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__170&quot;&gt;或者：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__171&quot;&gt;int&amp;nbsp;value&amp;nbsp;=&amp;nbsp;BinaryPrimitives.ReadInt32BigEndian(buffer);&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__172&quot;&gt;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__173&quot;&gt;MemoryMarshal&lt;/code&gt;&amp;nbsp;适合“按当前内存布局读取”。&lt;br/&gt;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__174&quot;&gt;BinaryPrimitives&lt;/code&gt;&amp;nbsp;更适合“按明确字节序读取”。&lt;/p&gt;&lt;h3 data-heading=&quot;true&quot; style=&quot;padding-left: 8px;border-left: 3px solid #0F4C81;margin: 2em 8px 0.75em 0;color: #3f3f3f;font-size: 17.6px;font-weight: bold;line-height: 1.2;&quot; class=&quot;js_darkmode__175&quot;&gt;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__176&quot;&gt;Read&amp;lt;T&amp;gt;&lt;/code&gt;：从字节里读出一个结构体&lt;/h3&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__177&quot;&gt;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__178&quot;&gt;Read&amp;lt;T&amp;gt;&lt;/code&gt;&amp;nbsp;用来从&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__179&quot;&gt;ReadOnlySpan&amp;lt;byte&amp;gt;&lt;/code&gt;&amp;nbsp;中读取一个结构体：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__180&quot;&gt;T&amp;nbsp;value&amp;nbsp;=&amp;nbsp;MemoryMarshal.Read&amp;lt;T&amp;gt;(buffer);&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__181&quot;&gt;例如定义一个协议头：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__182&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot;&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;using&lt;/span&gt;&amp;nbsp;System.Runtime.InteropServices;&lt;br/&gt;&lt;br/&gt;[&lt;span style=&quot;color: #79c0ff;&quot;&gt;StructLayout(LayoutKind.Sequential, Pack = 1)&lt;/span&gt;]&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;public&lt;/span&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;struct&lt;/span&gt;&amp;nbsp;MessageHeader&lt;br/&gt;{&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;color: #ffa657;&quot;&gt;&amp;nbsp;int&lt;/span&gt;&amp;nbsp;Id;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;color: #ffa657;&quot;&gt;&amp;nbsp;short&lt;/span&gt;&amp;nbsp;Length;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;color: #ffa657;&quot;&gt;&amp;nbsp;byte&lt;/span&gt;&amp;nbsp;Type;&lt;br/&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__183&quot;&gt;读取：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__184&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot;&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;static&lt;/span&gt;&amp;nbsp;MessageHeader&lt;span style=&quot;color: #d2a8ff;&quot;&gt;&amp;nbsp;ReadHeader&lt;/span&gt;(ReadOnlySpan&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;byte&lt;/span&gt;&amp;gt; buffer)&lt;br/&gt;{&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; const&lt;/span&gt;&lt;span style=&quot;color: #ffa657;&quot;&gt;&amp;nbsp;int&lt;/span&gt;&amp;nbsp;HeaderSize =&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;7&lt;/span&gt;;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; if&lt;/span&gt;&amp;nbsp;(buffer.Length &amp;lt; HeaderSize)&lt;br/&gt;&amp;nbsp; &amp;nbsp; {&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; throw&lt;/span&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;new&lt;/span&gt;&amp;nbsp;ArgumentException(&lt;span style=&quot;color: #a5d6ff;&quot;&gt;&amp;quot;缓冲区长度不够。&amp;quot;&lt;/span&gt;,&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;nameof&lt;/span&gt;(buffer));&lt;br/&gt;&amp;nbsp; &amp;nbsp; }&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; return&lt;/span&gt;&amp;nbsp;MemoryMarshal.Read&amp;lt;MessageHeader&amp;gt;(buffer);&lt;br/&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__185&quot;&gt;这里没有手动一个字段一个字段解析，而是直接把前 7 个字节按&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__186&quot;&gt;MessageHeader&lt;/code&gt;&amp;nbsp;读出来。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__187&quot;&gt;这很快，也很简洁。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__188&quot;&gt;但条件也很明确：&lt;/p&gt;&lt;ul style=&quot;list-style-type: circle;&quot; class=&quot;js_darkmode__189 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section&gt;• 结构体布局必须可控；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 字段顺序、对齐、大小要和二进制数据一致；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 结构体里不能包含引用类型字段；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 字节序必须符合预期。&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__194&quot;&gt;所以协议结构体通常要显式标注：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__195&quot;&gt;[StructLayout(LayoutKind.Sequential,&amp;nbsp;Pack&amp;nbsp;=&amp;nbsp;1)]&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__196&quot;&gt;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__197&quot;&gt;Pack = 1&lt;/code&gt;&amp;nbsp;的意思是减少默认对齐填充，让结构体布局更贴近协议定义。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__198&quot;&gt;但这也不是所有场景都要写死。结构体如果要和 C 侧 &lt;span class=&quot;&quot;&gt;ABI&lt;/span&gt; 对齐，&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__199&quot;&gt;Pack&lt;/code&gt;&amp;nbsp;要按对方的真实布局来，不是越小越好。&lt;/p&gt;&lt;h3 data-heading=&quot;true&quot; style=&quot;padding-left: 8px;border-left: 3px solid #0F4C81;margin: 2em 8px 0.75em 0;color: #3f3f3f;font-size: 17.6px;font-weight: bold;line-height: 1.2;&quot; class=&quot;js_darkmode__200&quot;&gt;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__201&quot;&gt;Write&amp;lt;T&amp;gt;&lt;/code&gt;：把结构体写进字节缓冲区&lt;/h3&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__202&quot;&gt;和&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__203&quot;&gt;Read&amp;lt;T&amp;gt;&lt;/code&gt;&amp;nbsp;对应的是&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__204&quot;&gt;Write&amp;lt;T&amp;gt;&lt;/code&gt;。&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__205&quot;&gt;MemoryMarshal.Write(buffer,&amp;nbsp;in&amp;nbsp;value);&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__206&quot;&gt;例如：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__207&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot;&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;static&lt;/span&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;void&lt;/span&gt;&lt;span style=&quot;color: #d2a8ff;&quot;&gt;&amp;nbsp;WriteHeader&lt;/span&gt;(Span&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;byte&lt;/span&gt;&amp;gt; buffer, MessageHeader header)&lt;br/&gt;{&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; const&lt;/span&gt;&lt;span style=&quot;color: #ffa657;&quot;&gt;&amp;nbsp;int&lt;/span&gt;&amp;nbsp;HeaderSize =&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;7&lt;/span&gt;;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; if&lt;/span&gt;&amp;nbsp;(buffer.Length &amp;lt; HeaderSize)&lt;br/&gt;&amp;nbsp; &amp;nbsp; {&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; throw&lt;/span&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;new&lt;/span&gt;&amp;nbsp;ArgumentException(&lt;span style=&quot;color: #a5d6ff;&quot;&gt;&amp;quot;缓冲区长度不够。&amp;quot;&lt;/span&gt;,&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;nameof&lt;/span&gt;(buffer));&lt;br/&gt;&amp;nbsp; &amp;nbsp; }&lt;br/&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; MemoryMarshal.Write(buffer,&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;in&lt;/span&gt;&amp;nbsp;header);&lt;br/&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__208&quot;&gt;这会把&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__209&quot;&gt;header&lt;/code&gt;&amp;nbsp;的内存表示写到&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__210&quot;&gt;buffer&lt;/code&gt;&amp;nbsp;里。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__211&quot;&gt;还是同一句话：&lt;/p&gt;&lt;blockquote style=&quot;font-style: normal;padding: 1em;border-left: 4px solid #0F4C81;border-radius: 6px;color: #3f3f3f;background: #f7f7f7;margin-bottom: 1em;&quot; class=&quot;js_darkmode__212&quot;&gt;&lt;p style=&quot;display: block;font-size: 1em;letter-spacing: 0.1em;color: #3f3f3f;margin: 0;&quot; class=&quot;js_darkmode__213&quot;&gt;写进去的是结构体的内存表示，不是某种自动跨平台协议格式。&lt;/p&gt;&lt;/blockquote&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__214&quot;&gt;如果协议要求大端序，或者字段需要固定编码方式，就不能简单&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__215&quot;&gt;Write&lt;/code&gt;&amp;nbsp;完事。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__216&quot;&gt;这种场景更适合一个字段一个字段写：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__217&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot;&gt;BinaryPrimitives.WriteInt32BigEndian(buffer, header.Id);&lt;br/&gt;BinaryPrimitives.WriteInt16BigEndian(buffer.Slice(&lt;span style=&quot;color: #79c0ff;&quot;&gt;4&lt;/span&gt;), header.Length);&lt;br/&gt;buffer[&lt;span style=&quot;color: #79c0ff;&quot;&gt;6&lt;/span&gt;] = header.Type;&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__218&quot;&gt;可读性更强，也不会把平台字节序混进协议里。&lt;/p&gt;&lt;h3 data-heading=&quot;true&quot; style=&quot;padding-left: 8px;border-left: 3px solid #0F4C81;margin: 2em 8px 0.75em 0;color: #3f3f3f;font-size: 17.6px;font-weight: bold;line-height: 1.2;&quot; class=&quot;js_darkmode__219&quot;&gt;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__220&quot;&gt;AsRef&amp;lt;T&amp;gt;&lt;/code&gt;：把字节视图当成结构体引用&lt;/h3&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__221&quot;&gt;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__222&quot;&gt;Read&amp;lt;T&amp;gt;&lt;/code&gt;&amp;nbsp;会返回一个结构体值。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__223&quot;&gt;有时需要直接拿到这段字节对应的结构体引用，可以用：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__224&quot;&gt;ref&amp;nbsp;T&amp;nbsp;value&amp;nbsp;=&amp;nbsp;ref&amp;nbsp;MemoryMarshal.AsRef&amp;lt;T&amp;gt;(span);&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__225&quot;&gt;例如：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__226&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot;&gt;Span&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;byte&lt;/span&gt;&amp;gt; buffer =&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;stackalloc&lt;/span&gt;&lt;span style=&quot;color: #ffa657;&quot;&gt;&amp;nbsp;byte&lt;/span&gt;[&lt;span style=&quot;color: #79c0ff;&quot;&gt;7&lt;/span&gt;];&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&lt;br/&gt;ref&lt;/span&gt;&amp;nbsp;MessageHeader header =&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;ref&lt;/span&gt;&amp;nbsp;MemoryMarshal.AsRef&amp;lt;MessageHeader&amp;gt;(buffer);&lt;br/&gt;&lt;br/&gt;header.Id =&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;1001&lt;/span&gt;;&lt;br/&gt;header.Length =&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;32&lt;/span&gt;;&lt;br/&gt;header.Type =&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;1&lt;/span&gt;;&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__227&quot;&gt;这段代码的效果是：&lt;/p&gt;&lt;ul style=&quot;list-style-type: circle;&quot; class=&quot;js_darkmode__228 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section&gt;•&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__230&quot;&gt;header&lt;/code&gt;&amp;nbsp;不是新对象；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 它直接引用&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__232&quot;&gt;buffer&lt;/code&gt;&amp;nbsp;里的那块内存；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 修改&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__234&quot;&gt;header&lt;/code&gt;，就是修改&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__235&quot;&gt;buffer&lt;/code&gt;。&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__236&quot;&gt;这类写法很底层，也更危险。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__237&quot;&gt;一般只有在非常明确的热路径里才值得这样做。普通解析代码里，&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__238&quot;&gt;Read&amp;lt;T&amp;gt;&lt;/code&gt;&amp;nbsp;和&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__239&quot;&gt;Write&amp;lt;T&amp;gt;&lt;/code&gt;&amp;nbsp;已经够用。&lt;/p&gt;&lt;h3 data-heading=&quot;true&quot; style=&quot;padding-left: 8px;border-left: 3px solid #0F4C81;margin: 2em 8px 0.75em 0;color: #3f3f3f;font-size: 17.6px;font-weight: bold;line-height: 1.2;&quot; class=&quot;js_darkmode__240&quot;&gt;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__241&quot;&gt;TryGetArray&lt;/code&gt;：从&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__242&quot;&gt;Memory&amp;lt;T&amp;gt;&lt;/code&gt;&amp;nbsp;里尽量拿到底层数组&lt;/h3&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__243&quot;&gt;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__244&quot;&gt;Memory&amp;lt;T&amp;gt;&lt;/code&gt;&amp;nbsp;比&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__245&quot;&gt;Span&amp;lt;T&amp;gt;&lt;/code&gt;&amp;nbsp;更适合长期保存，也可以跨&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__246&quot;&gt;await&lt;/code&gt;。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__247&quot;&gt;但它只是一个抽象。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__248&quot;&gt;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__249&quot;&gt;Memory&amp;lt;T&amp;gt;&lt;/code&gt;&amp;nbsp;背后可能是：&lt;/p&gt;&lt;ul style=&quot;list-style-type: circle;&quot; class=&quot;js_darkmode__250 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section&gt;• 数组；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 字符串；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 自定义&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__254&quot;&gt;MemoryManager&amp;lt;T&amp;gt;&lt;/code&gt;；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 其他内存来源。&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__256&quot;&gt;有些老 API 只接受数组：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__257&quot;&gt;void&amp;nbsp;Send(byte[]&amp;nbsp;buffer,&amp;nbsp;int&amp;nbsp;offset,&amp;nbsp;int&amp;nbsp;count);&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__258&quot;&gt;如果手里是：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__259&quot;&gt;ReadOnlyMemory&amp;lt;byte&amp;gt;&amp;nbsp;memory&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__260&quot;&gt;不一定能直接拿到数组。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__261&quot;&gt;这时可以用：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__262&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot;&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(MemoryMarshal.TryGetArray(memory,&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;out&lt;/span&gt;&amp;nbsp;ArraySegment&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;byte&lt;/span&gt;&amp;gt; segment))&lt;br/&gt;{&lt;br/&gt;&amp;nbsp; &amp;nbsp; Send(segment.Array!, segment.Offset, segment.Count);&lt;br/&gt;}&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;else&lt;/span&gt;&lt;br/&gt;{&lt;span style=&quot;color: #ffa657;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; byte&lt;/span&gt;[] rented = ArrayPool&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;byte&lt;/span&gt;&amp;gt;.Shared.Rent(memory.Length);&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; try&lt;/span&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; {&lt;br/&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; memory.Span.CopyTo(rented);&lt;br/&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Send(rented,&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;0&lt;/span&gt;, memory.Length);&lt;br/&gt;&amp;nbsp; &amp;nbsp; }&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; finally&lt;/span&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; {&lt;br/&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ArrayPool&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;byte&lt;/span&gt;&amp;gt;.Shared.Return(rented);&lt;br/&gt;&amp;nbsp; &amp;nbsp; }&lt;br/&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__263&quot;&gt;这段代码表达的是：&lt;/p&gt;&lt;ul style=&quot;list-style-type: circle;&quot; class=&quot;js_darkmode__264 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section&gt;• 如果&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__266&quot;&gt;Memory&amp;lt;byte&amp;gt;&lt;/code&gt;&amp;nbsp;背后本来就是数组，就直接用；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 如果不是数组，就走一次拷贝兜底。&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__268&quot;&gt;这比盲目调用&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__269&quot;&gt;ToArray()&lt;/code&gt;&amp;nbsp;更好，因为它保留了零拷贝机会。&lt;/p&gt;&lt;h3 data-heading=&quot;true&quot; style=&quot;padding-left: 8px;border-left: 3px solid #0F4C81;margin: 2em 8px 0.75em 0;color: #3f3f3f;font-size: 17.6px;font-weight: bold;line-height: 1.2;&quot; class=&quot;js_darkmode__270&quot;&gt;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__271&quot;&gt;GetReference&lt;/code&gt;：拿到&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__272&quot;&gt;Span&amp;lt;T&amp;gt;&lt;/code&gt;&amp;nbsp;的第一个元素引用&lt;/h3&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__273&quot;&gt;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__274&quot;&gt;GetReference&lt;/code&gt;&amp;nbsp;会返回&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__275&quot;&gt;Span&amp;lt;T&amp;gt;&lt;/code&gt;&amp;nbsp;第一个元素的&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__276&quot;&gt;ref&lt;/code&gt;：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__277&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot;&gt;Span&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;int&lt;/span&gt;&amp;gt; numbers =&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;stackalloc&lt;/span&gt;&lt;span style=&quot;color: #ffa657;&quot;&gt;&amp;nbsp;int&lt;/span&gt;[&lt;span style=&quot;color: #79c0ff;&quot;&gt;3&lt;/span&gt;] {&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;1&lt;/span&gt;,&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;2&lt;/span&gt;,&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;3&lt;/span&gt;&amp;nbsp;};&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&lt;br/&gt;ref&lt;/span&gt;&lt;span style=&quot;color: #ffa657;&quot;&gt;&amp;nbsp;int&lt;/span&gt;&amp;nbsp;first =&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;ref&lt;/span&gt;&amp;nbsp;MemoryMarshal.GetReference(numbers);&lt;br/&gt;&lt;br/&gt;first =&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;99&lt;/span&gt;;&lt;br/&gt;&lt;br/&gt;Console.WriteLine(numbers[&lt;span style=&quot;color: #79c0ff;&quot;&gt;0&lt;/span&gt;]);&lt;span style=&quot;color: #8b949e;&quot;&gt;&amp;nbsp;// 99&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__278&quot;&gt;这个方法常见于更底层的优化代码，比如和&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__279&quot;&gt;Unsafe.Add&lt;/code&gt;&amp;nbsp;配合做无索引器访问：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__280&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot;&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;using&lt;/span&gt;&amp;nbsp;System.Runtime.CompilerServices;&lt;br/&gt;&lt;br/&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;static&lt;/span&gt;&lt;span style=&quot;color: #ffa657;&quot;&gt;&amp;nbsp;int&lt;/span&gt;&lt;span style=&quot;color: #d2a8ff;&quot;&gt;&amp;nbsp;Sum&lt;/span&gt;(ReadOnlySpan&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;int&lt;/span&gt;&amp;gt; values)&lt;br/&gt;{&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; ref&lt;/span&gt;&lt;span style=&quot;color: #ffa657;&quot;&gt;&amp;nbsp;int&lt;/span&gt;&amp;nbsp;start =&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;ref&lt;/span&gt;&amp;nbsp;MemoryMarshal.GetReference(values);&lt;span style=&quot;color: #ffa657;&quot;&gt;&lt;br/&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; int&lt;/span&gt;&amp;nbsp;sum =&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;0&lt;/span&gt;;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #ffa657;&quot;&gt;int&lt;/span&gt;&amp;nbsp;i =&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;0&lt;/span&gt;; i &amp;lt; values.Length; i++)&lt;br/&gt;&amp;nbsp; &amp;nbsp; {&lt;br/&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sum += Unsafe.Add(&lt;span style=&quot;color: #ff7b72;&quot;&gt;ref&lt;/span&gt;&amp;nbsp;start, i);&lt;br/&gt;&amp;nbsp; &amp;nbsp; }&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; return&lt;/span&gt;&amp;nbsp;sum;&lt;br/&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__281&quot;&gt;这类代码不是普通业务里的默认写法。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__282&quot;&gt;现代 &lt;span class=&quot;&quot;&gt;JIT&lt;/span&gt; 对普通&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__283&quot;&gt;Span&amp;lt;T&amp;gt;&lt;/code&gt;&amp;nbsp;循环已经做了很多优化。很多时候，下面这种代码已经足够好：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__284&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot;&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;static&lt;/span&gt;&lt;span style=&quot;color: #ffa657;&quot;&gt;&amp;nbsp;int&lt;/span&gt;&lt;span style=&quot;color: #d2a8ff;&quot;&gt;&amp;nbsp;Sum&lt;/span&gt;(ReadOnlySpan&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;int&lt;/span&gt;&amp;gt; values)&lt;br/&gt;{&lt;span style=&quot;color: #ffa657;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; int&lt;/span&gt;&amp;nbsp;sum =&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;0&lt;/span&gt;;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; foreach&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #ffa657;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;value&lt;/span&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;in&lt;/span&gt;&amp;nbsp;values)&lt;br/&gt;&amp;nbsp; &amp;nbsp; {&lt;br/&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sum +=&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;value&lt;/span&gt;;&lt;br/&gt;&amp;nbsp; &amp;nbsp; }&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; return&lt;/span&gt;&amp;nbsp;sum;&lt;br/&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__285&quot;&gt;除非基准测试证明边界检查或索引器访问真的成了热点，否则没必要为了“看起来底层”而上&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__286&quot;&gt;GetReference + Unsafe.Add&lt;/code&gt;。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__287&quot;&gt;另外，空&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__288&quot;&gt;Span&amp;lt;T&amp;gt;&lt;/code&gt;&amp;nbsp;上调用&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__289&quot;&gt;GetReference&lt;/code&gt;&amp;nbsp;时，返回的引用不能解引用。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__290&quot;&gt;所以这种代码必须先检查长度：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__291&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot;&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(values.IsEmpty)&lt;br/&gt;{&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; return&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;0&lt;/span&gt;;&lt;br/&gt;}&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&lt;br/&gt;ref&lt;/span&gt;&lt;span style=&quot;color: #ffa657;&quot;&gt;&amp;nbsp;int&lt;/span&gt;&amp;nbsp;first =&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;ref&lt;/span&gt;&amp;nbsp;MemoryMarshal.GetReference(values);&lt;/code&gt;&lt;/pre&gt;&lt;h3 data-heading=&quot;true&quot; style=&quot;padding-left: 8px;border-left: 3px solid #0F4C81;margin: 2em 8px 0.75em 0;color: #3f3f3f;font-size: 17.6px;font-weight: bold;line-height: 1.2;&quot; class=&quot;js_darkmode__292&quot;&gt;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__293&quot;&gt;CreateSpan&lt;/code&gt;：从一个引用造出 Span&lt;/h3&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__294&quot;&gt;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__295&quot;&gt;CreateSpan&lt;/code&gt;&amp;nbsp;可以从一个&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__296&quot;&gt;ref T&lt;/code&gt;&amp;nbsp;和长度创建&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__297&quot;&gt;Span&amp;lt;T&amp;gt;&lt;/code&gt;：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__298&quot;&gt;Span&amp;lt;T&amp;gt;&amp;nbsp;span&amp;nbsp;=&amp;nbsp;MemoryMarshal.CreateSpan(ref&amp;nbsp;reference,&amp;nbsp;length);&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__299&quot;&gt;例如：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__300&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot;&gt;&lt;span style=&quot;color: #ffa657;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;value&lt;/span&gt;&amp;nbsp;=&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;10&lt;/span&gt;;&lt;br/&gt;&lt;br/&gt;Span&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;int&lt;/span&gt;&amp;gt; one = MemoryMarshal.CreateSpan(&lt;span style=&quot;color: #ff7b72;&quot;&gt;ref&lt;/span&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;value&lt;/span&gt;,&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;1&lt;/span&gt;);&lt;br/&gt;one[&lt;span style=&quot;color: #79c0ff;&quot;&gt;0&lt;/span&gt;] =&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;20&lt;/span&gt;;&lt;br/&gt;&lt;br/&gt;Console.WriteLine(&lt;span style=&quot;color: #ff7b72;&quot;&gt;value&lt;/span&gt;);&lt;span style=&quot;color: #8b949e;&quot;&gt;&amp;nbsp;// 20&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__301&quot;&gt;这看起来很方便，但它是&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__302&quot;&gt;MemoryMarshal&lt;/code&gt;&amp;nbsp;里风险更高的一类方法。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__303&quot;&gt;因为它相信传入的&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__304&quot;&gt;ref&lt;/code&gt;&amp;nbsp;后面真的有&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__305&quot;&gt;length&lt;/code&gt;&amp;nbsp;个连续元素。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__306&quot;&gt;如果只有一个变量，却写成：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__307&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot;&gt;&lt;span style=&quot;color: #ffa657;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;value&lt;/span&gt;&amp;nbsp;=&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;10&lt;/span&gt;;&lt;br/&gt;Span&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;int&lt;/span&gt;&amp;gt; broken = MemoryMarshal.CreateSpan(&lt;span style=&quot;color: #ff7b72;&quot;&gt;ref&lt;/span&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;value&lt;/span&gt;,&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;10&lt;/span&gt;);&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__308&quot;&gt;那就相当于告诉运行时：&lt;/p&gt;&lt;blockquote style=&quot;font-style: normal;padding: 1em;border-left: 4px solid #0F4C81;border-radius: 6px;color: #3f3f3f;background: #f7f7f7;margin-bottom: 1em;&quot; class=&quot;js_darkmode__309&quot;&gt;&lt;p style=&quot;display: block;font-size: 1em;letter-spacing: 0.1em;color: #3f3f3f;margin: 0;&quot; class=&quot;js_darkmode__310&quot;&gt;从这个&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__311&quot;&gt;int&lt;/code&gt;&amp;nbsp;开始，后面还有 10 个连续&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__312&quot;&gt;int&lt;/code&gt;&amp;nbsp;可以访问。&lt;/p&gt;&lt;/blockquote&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__313&quot;&gt;事实并不是这样。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__314&quot;&gt;这种错误不会像普通数组越界那样容易理解，后果也更难排查。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__315&quot;&gt;所以&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__316&quot;&gt;CreateSpan&lt;/code&gt;&amp;nbsp;更适合框架代码、底层库代码，普通业务代码能不用就不用。&lt;/p&gt;&lt;h3 data-heading=&quot;true&quot; style=&quot;padding-left: 8px;border-left: 3px solid #0F4C81;margin: 2em 8px 0.75em 0;color: #3f3f3f;font-size: 17.6px;font-weight: bold;line-height: 1.2;&quot; class=&quot;js_darkmode__317&quot;&gt;几个更贴近实际的使用示例&lt;/h3&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__318&quot;&gt;上面的例子主要是说明 API 行为，下面几个场景更接近真实代码。&lt;/p&gt;&lt;h4 data-heading=&quot;true&quot; style=&quot;margin: 2em 8px 0.5em;color: #0F4C81;font-size: 16px;font-weight: bold;&quot; class=&quot;js_darkmode__319&quot;&gt;示例 1：解析固定协议头，再切出消息体&lt;/h4&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__320&quot;&gt;很多二进制协议都会有一个固定头部，比如：&lt;/p&gt;&lt;ul style=&quot;list-style-type: circle;&quot; class=&quot;js_darkmode__321 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section&gt;• 4 字节消息长度；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 2 字节消息类型；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 2 字节标志位；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 后面跟着消息体。&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__326&quot;&gt;如果协议明确使用大端序，字段级解析更适合用&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__327&quot;&gt;BinaryPrimitives&lt;/code&gt;：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__328&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot;&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;using&lt;/span&gt;&amp;nbsp;System.Buffers.Binary;&lt;br/&gt;&lt;br/&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;readonly&lt;/span&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;record&lt;/span&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;struct&lt;/span&gt;&lt;span style=&quot;color: #d2a8ff;&quot;&gt;&amp;nbsp;PacketHeader&lt;/span&gt;(&lt;span style=&quot;color: #ffa657;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; int&lt;/span&gt;&amp;nbsp;BodyLength,&lt;span style=&quot;color: #ffa657;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; ushort&lt;/span&gt;&amp;nbsp;MessageType,&lt;span style=&quot;color: #ffa657;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; ushort&lt;/span&gt;&amp;nbsp;Flags);&lt;br/&gt;&lt;br/&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;static&lt;/span&gt;&lt;span style=&quot;color: #ffa657;&quot;&gt;&amp;nbsp;bool&lt;/span&gt;&lt;span style=&quot;color: #d2a8ff;&quot;&gt;&amp;nbsp;TryReadPacket&lt;/span&gt;(&lt;br/&gt;&amp;nbsp; &amp;nbsp; ReadOnlySpan&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;byte&lt;/span&gt;&amp;gt; buffer,&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; out&lt;/span&gt;&amp;nbsp;PacketHeader header,&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; out&lt;/span&gt;&amp;nbsp;ReadOnlySpan&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;byte&lt;/span&gt;&amp;gt; body)&lt;br/&gt;{&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; const&lt;/span&gt;&lt;span style=&quot;color: #ffa657;&quot;&gt;&amp;nbsp;int&lt;/span&gt;&amp;nbsp;HeaderSize =&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;8&lt;/span&gt;;&lt;br/&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; header =&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;default&lt;/span&gt;;&lt;br/&gt;&amp;nbsp; &amp;nbsp; body =&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;default&lt;/span&gt;;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; if&lt;/span&gt;&amp;nbsp;(buffer.Length &amp;lt; HeaderSize)&lt;br/&gt;&amp;nbsp; &amp;nbsp; {&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;false&lt;/span&gt;;&lt;br/&gt;&amp;nbsp; &amp;nbsp; }&lt;span style=&quot;color: #ffa657;&quot;&gt;&lt;br/&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; int&lt;/span&gt;&amp;nbsp;bodyLength = BinaryPrimitives.ReadInt32BigEndian(buffer);&lt;span style=&quot;color: #ffa657;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; ushort&lt;/span&gt;&amp;nbsp;messageType = BinaryPrimitives.ReadUInt16BigEndian(buffer.Slice(&lt;span style=&quot;color: #79c0ff;&quot;&gt;4&lt;/span&gt;));&lt;span style=&quot;color: #ffa657;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; ushort&lt;/span&gt;&amp;nbsp;flags = BinaryPrimitives.ReadUInt16BigEndian(buffer.Slice(&lt;span style=&quot;color: #79c0ff;&quot;&gt;6&lt;/span&gt;));&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; if&lt;/span&gt;&amp;nbsp;(bodyLength &amp;lt;&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;0&lt;/span&gt;&amp;nbsp;|| buffer.Length &amp;lt; HeaderSize + bodyLength)&lt;br/&gt;&amp;nbsp; &amp;nbsp; {&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;false&lt;/span&gt;;&lt;br/&gt;&amp;nbsp; &amp;nbsp; }&lt;br/&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; header =&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;new&lt;/span&gt;&amp;nbsp;PacketHeader(bodyLength, messageType, flags);&lt;br/&gt;&amp;nbsp; &amp;nbsp; body = buffer.Slice(HeaderSize, bodyLength);&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; return&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;true&lt;/span&gt;;&lt;br/&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__329&quot;&gt;这个例子里没有直接用&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__330&quot;&gt;MemoryMarshal.Read&amp;lt;T&amp;gt;&lt;/code&gt;，原因很简单：&lt;/p&gt;&lt;ul style=&quot;list-style-type: circle;&quot; class=&quot;js_darkmode__331 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section&gt;• 协议字段有明确大端序；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;•&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__334&quot;&gt;MemoryMarshal.Read&amp;lt;T&amp;gt;&lt;/code&gt;&amp;nbsp;按当前机器内存表示读；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 字段级解析更清楚，也更稳定。&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__336&quot;&gt;这也是&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__337&quot;&gt;MemoryMarshal&lt;/code&gt;&amp;nbsp;的一个重要使用边界。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__338&quot;&gt;有些场景里，不用它反而更合适。&lt;/p&gt;&lt;h4 data-heading=&quot;true&quot; style=&quot;margin: 2em 8px 0.5em;color: #0F4C81;font-size: 16px;font-weight: bold;&quot; class=&quot;js_darkmode__339&quot;&gt;示例 2：批量把结构体写入网络缓冲区&lt;/h4&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__340&quot;&gt;如果一批数据只在同一套系统内部传输，结构体布局也完全可控，可以把结构体数组直接看成字节。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__341&quot;&gt;例如一批传感器采样数据：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__342&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot;&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;using&lt;/span&gt;&amp;nbsp;System.Runtime.InteropServices;&lt;br/&gt;&lt;br/&gt;[&lt;span style=&quot;color: #79c0ff;&quot;&gt;StructLayout(LayoutKind.Sequential, Pack = 1)&lt;/span&gt;]&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;public&lt;/span&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;struct&lt;/span&gt;&amp;nbsp;SensorSample&lt;br/&gt;{&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;color: #ffa657;&quot;&gt;&amp;nbsp;int&lt;/span&gt;&amp;nbsp;DeviceId;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;color: #ffa657;&quot;&gt;&amp;nbsp;long&lt;/span&gt;&amp;nbsp;Timestamp;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;color: #ffa657;&quot;&gt;&amp;nbsp;float&lt;/span&gt;&amp;nbsp;Value;&lt;br/&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__343&quot;&gt;发送前拿到字节视图：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__344&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot;&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;static&lt;/span&gt;&amp;nbsp;ReadOnlySpan&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;byte&lt;/span&gt;&amp;gt;&lt;span style=&quot;color: #d2a8ff;&quot;&gt;&amp;nbsp;AsPayload&lt;/span&gt;(ReadOnlySpan&amp;lt;SensorSample&amp;gt; samples)&lt;br/&gt;{&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; return&lt;/span&gt;&amp;nbsp;MemoryMarshal.AsBytes(samples);&lt;br/&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__345&quot;&gt;如果要写入已有缓冲区：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__346&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot;&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;static&lt;/span&gt;&lt;span style=&quot;color: #ffa657;&quot;&gt;&amp;nbsp;int&lt;/span&gt;&lt;span style=&quot;color: #d2a8ff;&quot;&gt;&amp;nbsp;WriteSamples&lt;/span&gt;(&lt;br/&gt;&amp;nbsp; &amp;nbsp; ReadOnlySpan&amp;lt;SensorSample&amp;gt; samples,&lt;br/&gt;&amp;nbsp; &amp;nbsp; Span&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;byte&lt;/span&gt;&amp;gt; destination)&lt;br/&gt;{&lt;br/&gt;&amp;nbsp; &amp;nbsp; ReadOnlySpan&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;byte&lt;/span&gt;&amp;gt; payload = MemoryMarshal.AsBytes(samples);&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; if&lt;/span&gt;&amp;nbsp;(destination.Length &amp;lt; payload.Length)&lt;br/&gt;&amp;nbsp; &amp;nbsp; {&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; throw&lt;/span&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;new&lt;/span&gt;&amp;nbsp;ArgumentException(&lt;span style=&quot;color: #a5d6ff;&quot;&gt;&amp;quot;目标缓冲区长度不够。&amp;quot;&lt;/span&gt;,&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;nameof&lt;/span&gt;(destination));&lt;br/&gt;&amp;nbsp; &amp;nbsp; }&lt;br/&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; payload.CopyTo(destination);&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; return&lt;/span&gt;&amp;nbsp;payload.Length;&lt;br/&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__347&quot;&gt;这类写法的好处是：&lt;/p&gt;&lt;ul style=&quot;list-style-type: circle;&quot; class=&quot;js_darkmode__348 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section&gt;• 不需要逐个字段写入；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 不需要为每条数据创建临时&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__351&quot;&gt;byte[]&lt;/code&gt;；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 一批结构体可以直接形成连续字节视图。&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__353&quot;&gt;但前提也很硬：&lt;/p&gt;&lt;ul style=&quot;list-style-type: circle;&quot; class=&quot;js_darkmode__354 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section&gt;• 发送方和接收方都认可这个结构体布局；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 没有跨语言、跨架构、跨版本的布局差异；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 不要求独立于平台字节序。&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__358&quot;&gt;只要数据要落盘长期保存，或者要跨系统传输，通常更推荐定义明确的协议格式，而不是直接裸写结构体内存。&lt;/p&gt;&lt;h4 data-heading=&quot;true&quot; style=&quot;margin: 2em 8px 0.5em;color: #0F4C81;font-size: 16px;font-weight: bold;&quot; class=&quot;js_darkmode__359&quot;&gt;示例 3：从文件块中批量读取结构体记录&lt;/h4&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__360&quot;&gt;某些内部文件格式会把固定大小记录连续写入文件。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__361&quot;&gt;例如文件内容是一批&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__362&quot;&gt;SensorSample&lt;/code&gt;：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__363&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot;&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;static&lt;/span&gt;&amp;nbsp;ReadOnlySpan&amp;lt;SensorSample&amp;gt;&lt;span style=&quot;color: #d2a8ff;&quot;&gt;&amp;nbsp;ReadSamples&lt;/span&gt;(ReadOnlySpan&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;byte&lt;/span&gt;&amp;gt; fileBlock)&lt;br/&gt;{&lt;span style=&quot;color: #ffa657;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; int&lt;/span&gt;&amp;nbsp;size = Marshal.SizeOf&amp;lt;SensorSample&amp;gt;();&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; if&lt;/span&gt;&amp;nbsp;(fileBlock.Length % size !=&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;0&lt;/span&gt;)&lt;br/&gt;&amp;nbsp; &amp;nbsp; {&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; throw&lt;/span&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;new&lt;/span&gt;&amp;nbsp;InvalidDataException(&lt;span style=&quot;color: #a5d6ff;&quot;&gt;&amp;quot;文件块长度不是记录大小的整数倍。&amp;quot;&lt;/span&gt;);&lt;br/&gt;&amp;nbsp; &amp;nbsp; }&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; return&lt;/span&gt;&amp;nbsp;MemoryMarshal.Cast&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;byte&lt;/span&gt;, SensorSample&amp;gt;(fileBlock);&lt;br/&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__364&quot;&gt;这段代码没有把文件块复制成&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__365&quot;&gt;SensorSample[]&lt;/code&gt;，而是直接拿到一个结构体视图。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__366&quot;&gt;遍历时就可以这样写：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__367&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot;&gt;ReadOnlySpan&amp;lt;SensorSample&amp;gt; samples = ReadSamples(fileBlock);&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&lt;br/&gt;foreach&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #ff7b72;&quot;&gt;ref&lt;/span&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;readonly&lt;/span&gt;&amp;nbsp;SensorSample sample&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;in&lt;/span&gt;&amp;nbsp;samples)&lt;br/&gt;{&lt;span style=&quot;color: #8b949e;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; // 处理 sample&lt;/span&gt;&lt;br/&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__368&quot;&gt;这种写法适合内部格式、临时文件、缓存文件。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__369&quot;&gt;如果文件格式需要长期兼容，字段级解析会更稳。结构体一旦加字段、改字段类型、调整&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__370&quot;&gt;Pack&lt;/code&gt;，直接&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__371&quot;&gt;Cast&lt;/code&gt;&amp;nbsp;的格式就可能不兼容。&lt;/p&gt;&lt;h4 data-heading=&quot;true&quot; style=&quot;margin: 2em 8px 0.5em;color: #0F4C81;font-size: 16px;font-weight: bold;&quot; class=&quot;js_darkmode__372&quot;&gt;示例 4：分块计算校验值&lt;/h4&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__373&quot;&gt;有时一段字节数据可以按更大的整数单位批量处理。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__374&quot;&gt;例如一个简单的 16 位累加校验：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__375&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot;&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;static&lt;/span&gt;&lt;span style=&quot;color: #ffa657;&quot;&gt;&amp;nbsp;uint&lt;/span&gt;&lt;span style=&quot;color: #d2a8ff;&quot;&gt;&amp;nbsp;SumUInt16&lt;/span&gt;(ReadOnlySpan&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;byte&lt;/span&gt;&amp;gt; data)&lt;br/&gt;{&lt;br/&gt;&amp;nbsp; &amp;nbsp; ReadOnlySpan&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;ushort&lt;/span&gt;&amp;gt; words = MemoryMarshal.Cast&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;byte&lt;/span&gt;,&lt;span style=&quot;color: #ffa657;&quot;&gt;&amp;nbsp;ushort&lt;/span&gt;&amp;gt;(&lt;br/&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; data.Slice(&lt;span style=&quot;color: #79c0ff;&quot;&gt;0&lt;/span&gt;, data.Length /&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;2&lt;/span&gt;&amp;nbsp;*&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;2&lt;/span&gt;));&lt;span style=&quot;color: #ffa657;&quot;&gt;&lt;br/&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; uint&lt;/span&gt;&amp;nbsp;sum =&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;0&lt;/span&gt;;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; foreach&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #ffa657;&quot;&gt;ushort&lt;/span&gt;&amp;nbsp;word&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;in&lt;/span&gt;&amp;nbsp;words)&lt;br/&gt;&amp;nbsp; &amp;nbsp; {&lt;br/&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sum += word;&lt;br/&gt;&amp;nbsp; &amp;nbsp; }&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; if&lt;/span&gt;&amp;nbsp;((data.Length &amp;amp;&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;1&lt;/span&gt;) !=&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;0&lt;/span&gt;)&lt;br/&gt;&amp;nbsp; &amp;nbsp; {&lt;br/&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sum += data[^&lt;span style=&quot;color: #79c0ff;&quot;&gt;1&lt;/span&gt;];&lt;br/&gt;&amp;nbsp; &amp;nbsp; }&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; return&lt;/span&gt;&amp;nbsp;sum;&lt;br/&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__376&quot;&gt;这里通过&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__377&quot;&gt;Cast&amp;lt;byte, ushort&amp;gt;&lt;/code&gt;，把偶数字节部分按&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__378&quot;&gt;ushort&lt;/code&gt;&amp;nbsp;批量处理。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__379&quot;&gt;不过这类校验通常也会涉及字节序定义。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__380&quot;&gt;如果校验算法规定了网络字节序，仍然要按算法要求显式处理，而不能默认使用本机内存表示。&lt;/p&gt;&lt;h4 data-heading=&quot;true&quot; style=&quot;margin: 2em 8px 0.5em;color: #0F4C81;font-size: 16px;font-weight: bold;&quot; class=&quot;js_darkmode__381&quot;&gt;示例 5：和&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__382&quot;&gt;ArrayPool&amp;lt;byte&amp;gt;&lt;/code&gt;&amp;nbsp;配合减少临时分配&lt;/h4&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__383&quot;&gt;在高频构造二进制消息时，常见做法是从&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__384&quot;&gt;ArrayPool&amp;lt;byte&amp;gt;&lt;/code&gt;&amp;nbsp;租一个缓冲区，然后在这块缓冲区上写数据。&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__385&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot;&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;using&lt;/span&gt;&amp;nbsp;System.Buffers;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;using&lt;/span&gt;&amp;nbsp;System.Buffers.Binary;&lt;br/&gt;&lt;br/&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;static&lt;/span&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;void&lt;/span&gt;&lt;span style=&quot;color: #d2a8ff;&quot;&gt;&amp;nbsp;SendMessage&lt;/span&gt;(&lt;span style=&quot;color: #ffa657;&quot;&gt;int&lt;/span&gt;&amp;nbsp;id, ReadOnlySpan&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;byte&lt;/span&gt;&amp;gt; payload)&lt;br/&gt;{&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; const&lt;/span&gt;&lt;span style=&quot;color: #ffa657;&quot;&gt;&amp;nbsp;int&lt;/span&gt;&amp;nbsp;HeaderSize =&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;8&lt;/span&gt;;&lt;span style=&quot;color: #ffa657;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; int&lt;/span&gt;&amp;nbsp;totalLength = HeaderSize + payload.Length;&lt;span style=&quot;color: #ffa657;&quot;&gt;&lt;br/&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; byte&lt;/span&gt;[] buffer = ArrayPool&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;byte&lt;/span&gt;&amp;gt;.Shared.Rent(totalLength);&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; try&lt;/span&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; {&lt;br/&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Span&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;byte&lt;/span&gt;&amp;gt; message = buffer.AsSpan(&lt;span style=&quot;color: #79c0ff;&quot;&gt;0&lt;/span&gt;, totalLength);&lt;br/&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; BinaryPrimitives.WriteInt32BigEndian(message, payload.Length);&lt;br/&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; BinaryPrimitives.WriteInt32BigEndian(message.Slice(&lt;span style=&quot;color: #79c0ff;&quot;&gt;4&lt;/span&gt;), id);&lt;br/&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; payload.CopyTo(message.Slice(HeaderSize));&lt;br/&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SendToTransport(message);&lt;br/&gt;&amp;nbsp; &amp;nbsp; }&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; finally&lt;/span&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; {&lt;br/&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ArrayPool&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;byte&lt;/span&gt;&amp;gt;.Shared.Return(buffer);&lt;br/&gt;&amp;nbsp; &amp;nbsp; }&lt;br/&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__386&quot;&gt;这段代码的重点是：&lt;/p&gt;&lt;ul style=&quot;list-style-type: circle;&quot; class=&quot;js_darkmode__387 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section&gt;• 只使用&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__389&quot;&gt;buffer.AsSpan(0, totalLength)&lt;/code&gt;&amp;nbsp;这段有效区域；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 写完后把有效区域交给发送逻辑；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 不管发送是否成功，都在&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__392&quot;&gt;finally&lt;/code&gt;&amp;nbsp;里归还数组。&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__393&quot;&gt;如果缓冲区里可能包含敏感数据，归还时可以考虑清理：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__394&quot;&gt;ArrayPool&amp;lt;byte&amp;gt;.Shared.Return(buffer,&amp;nbsp;clearArray:&amp;nbsp;true);&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__395&quot;&gt;如果头部是本地内部结构体，也可以这样写：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__396&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot;&gt;[&lt;span style=&quot;color: #79c0ff;&quot;&gt;StructLayout(LayoutKind.Sequential, Pack = 1)&lt;/span&gt;]&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;public&lt;/span&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;struct&lt;/span&gt;&amp;nbsp;LocalHeader&lt;br/&gt;{&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;color: #ffa657;&quot;&gt;&amp;nbsp;int&lt;/span&gt;&amp;nbsp;Length;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;color: #ffa657;&quot;&gt;&amp;nbsp;int&lt;/span&gt;&amp;nbsp;Id;&lt;br/&gt;}&lt;br/&gt;&lt;br/&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;static&lt;/span&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;void&lt;/span&gt;&lt;span style=&quot;color: #d2a8ff;&quot;&gt;&amp;nbsp;WriteLocalHeader&lt;/span&gt;(Span&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;byte&lt;/span&gt;&amp;gt; destination, LocalHeader header)&lt;br/&gt;{&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; if&lt;/span&gt;&amp;nbsp;(destination.Length &amp;lt; Marshal.SizeOf&amp;lt;LocalHeader&amp;gt;())&lt;br/&gt;&amp;nbsp; &amp;nbsp; {&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; throw&lt;/span&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;new&lt;/span&gt;&amp;nbsp;ArgumentException(&lt;span style=&quot;color: #a5d6ff;&quot;&gt;&amp;quot;目标缓冲区长度不够。&amp;quot;&lt;/span&gt;,&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;nameof&lt;/span&gt;(destination));&lt;br/&gt;&amp;nbsp; &amp;nbsp; }&lt;br/&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; MemoryMarshal.Write(destination,&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;in&lt;/span&gt;&amp;nbsp;header);&lt;br/&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__397&quot;&gt;两种写法的选择点还是一样：&lt;/p&gt;&lt;ul style=&quot;list-style-type: circle;&quot; class=&quot;js_darkmode__398 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section&gt;• 明确协议格式，优先&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__400&quot;&gt;BinaryPrimitives&lt;/code&gt;；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 明确本地布局，才考虑&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__402&quot;&gt;MemoryMarshal.Write&lt;/code&gt;。&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 data-heading=&quot;true&quot; style=&quot;padding-left: 8px;border-left: 3px solid #0F4C81;margin: 2em 8px 0.75em 0;color: #3f3f3f;font-size: 17.6px;font-weight: bold;line-height: 1.2;&quot; class=&quot;js_darkmode__403&quot;&gt;和&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__404&quot;&gt;BitConverter&lt;/code&gt;、&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__405&quot;&gt;BinaryPrimitives&lt;/code&gt;&amp;nbsp;怎么选？&lt;/h3&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__406&quot;&gt;这几个 API 很容易混在一起。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__407&quot;&gt;可以按场景区分。&lt;/p&gt;&lt;h4 data-heading=&quot;true&quot; style=&quot;margin: 2em 8px 0.5em;color: #0F4C81;font-size: 16px;font-weight: bold;&quot; class=&quot;js_darkmode__408&quot;&gt;用&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__409&quot;&gt;BitConverter&lt;/code&gt;&lt;/h4&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__410&quot;&gt;适合简单转换：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__411&quot;&gt;int&amp;nbsp;value&amp;nbsp;=&amp;nbsp;BitConverter.ToInt32(bytes);&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__412&quot;&gt;特点是：&lt;/p&gt;&lt;ul style=&quot;list-style-type: circle;&quot; class=&quot;js_darkmode__413 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section&gt;• 用法简单；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 适合不在热点路径里的普通转换；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 字节序跟当前机器相关。&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h4 data-heading=&quot;true&quot; style=&quot;margin: 2em 8px 0.5em;color: #0F4C81;font-size: 16px;font-weight: bold;&quot; class=&quot;js_darkmode__417&quot;&gt;用&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__418&quot;&gt;BinaryPrimitives&lt;/code&gt;&lt;/h4&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__419&quot;&gt;适合协议、文件格式、网络字节序：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__420&quot;&gt;int&amp;nbsp;value&amp;nbsp;=&amp;nbsp;BinaryPrimitives.ReadInt32BigEndian(bytes);&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__421&quot;&gt;特点是：&lt;/p&gt;&lt;ul style=&quot;list-style-type: circle;&quot; class=&quot;js_darkmode__422 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section&gt;• 明确指定大小端；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 代码语义清楚；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 很适合字段级解析。&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h4 data-heading=&quot;true&quot; style=&quot;margin: 2em 8px 0.5em;color: #0F4C81;font-size: 16px;font-weight: bold;&quot; class=&quot;js_darkmode__426&quot;&gt;用&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__427&quot;&gt;MemoryMarshal&lt;/code&gt;&lt;/h4&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__428&quot;&gt;适合把一段内存整体按某个结构体或类型视图处理：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__429&quot;&gt;MessageHeader&amp;nbsp;header&amp;nbsp;=&amp;nbsp;MemoryMarshal.Read&amp;lt;MessageHeader&amp;gt;(bytes);&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__430&quot;&gt;特点是：&lt;/p&gt;&lt;ul style=&quot;list-style-type: circle;&quot; class=&quot;js_darkmode__431 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section&gt;• 少复制；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 更底层；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 强依赖布局和字节序；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 更适合高频、批量、明确布局的场景。&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__436&quot;&gt;简单说：&lt;/p&gt;&lt;ul style=&quot;list-style-type: circle;&quot; class=&quot;js_darkmode__437 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section&gt;• 单个字段解析，优先&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__439&quot;&gt;BinaryPrimitives&lt;/code&gt;；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 整块结构体重解释，再考虑&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__441&quot;&gt;MemoryMarshal&lt;/code&gt;；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 不在性能热点，普通写法更稳。&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 data-heading=&quot;true&quot; style=&quot;padding-left: 8px;border-left: 3px solid #0F4C81;margin: 2em 8px 0.75em 0;color: #3f3f3f;font-size: 17.6px;font-weight: bold;line-height: 1.2;&quot; class=&quot;js_darkmode__443&quot;&gt;它和&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__444&quot;&gt;unsafe&lt;/code&gt;&amp;nbsp;是什么关系？&lt;/h3&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__445&quot;&gt;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__446&quot;&gt;MemoryMarshal&lt;/code&gt;&amp;nbsp;不要求代码块写&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__447&quot;&gt;unsafe&lt;/code&gt;。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__448&quot;&gt;但它提供的很多能力，本质上已经很接近&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__449&quot;&gt;unsafe&lt;/code&gt;：&lt;/p&gt;&lt;ul style=&quot;list-style-type: circle;&quot; class=&quot;js_darkmode__450 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section&gt;• 直接拿&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__452&quot;&gt;ref&lt;/code&gt;；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 重解释内存；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 从引用创建一段连续视图；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 把字节当成结构体。&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__456&quot;&gt;区别在于：&lt;/p&gt;&lt;ul style=&quot;list-style-type: circle;&quot; class=&quot;js_darkmode__457 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section&gt;•&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__459&quot;&gt;Span&amp;lt;T&amp;gt;&lt;/code&gt;&amp;nbsp;仍然保留长度信息；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 很多访问仍然有边界检查；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 编译器和运行时仍然能做一部分保护。&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__462&quot;&gt;所以它不是“完全安全的魔法工具”，更像：&lt;/p&gt;&lt;blockquote style=&quot;font-style: normal;padding: 1em;border-left: 4px solid #0F4C81;border-radius: 6px;color: #3f3f3f;background: #f7f7f7;margin-bottom: 1em;&quot; class=&quot;js_darkmode__463&quot;&gt;&lt;p style=&quot;display: block;font-size: 1em;letter-spacing: 0.1em;color: #3f3f3f;margin: 0;&quot; class=&quot;js_darkmode__464&quot;&gt;在不直接写指针的前提下，开放一部分底层内存能力。&lt;/p&gt;&lt;/blockquote&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__465&quot;&gt;这也是它的使用边界。&lt;/p&gt;&lt;h3 data-heading=&quot;true&quot; style=&quot;padding-left: 8px;border-left: 3px solid #0F4C81;margin: 2em 8px 0.75em 0;color: #3f3f3f;font-size: 17.6px;font-weight: bold;line-height: 1.2;&quot; class=&quot;js_darkmode__466&quot;&gt;常见坑 1：把重解释当成类型转换&lt;/h3&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__467&quot;&gt;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__468&quot;&gt;MemoryMarshal.Cast&amp;lt;byte, int&amp;gt;&lt;/code&gt;&amp;nbsp;不是把每个&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__469&quot;&gt;byte&lt;/code&gt;&amp;nbsp;转成一个&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__470&quot;&gt;int&lt;/code&gt;。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__471&quot;&gt;它不是这样：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__472&quot;&gt;{&amp;nbsp;1,&amp;nbsp;2,&amp;nbsp;3,&amp;nbsp;4&amp;nbsp;}&amp;nbsp;-&amp;gt;&amp;nbsp;{&amp;nbsp;1,&amp;nbsp;2,&amp;nbsp;3,&amp;nbsp;4&amp;nbsp;}&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__473&quot;&gt;而是这样：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__474&quot;&gt;{&amp;nbsp;1,&amp;nbsp;0,&amp;nbsp;0,&amp;nbsp;0&amp;nbsp;}&amp;nbsp;-&amp;gt;&amp;nbsp;一个&amp;nbsp;int：1&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__475&quot;&gt;它看的是同一段内存，只是换了目标类型的大小和布局。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__476&quot;&gt;所以数据长度、类型大小、字节序都要对得上。&lt;/p&gt;&lt;h3 data-heading=&quot;true&quot; style=&quot;padding-left: 8px;border-left: 3px solid #0F4C81;margin: 2em 8px 0.75em 0;color: #3f3f3f;font-size: 17.6px;font-weight: bold;line-height: 1.2;&quot; class=&quot;js_darkmode__477&quot;&gt;常见坑 2：忽略字节序&lt;/h3&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__478&quot;&gt;本机是小端序时：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__479&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot;&gt;&lt;span style=&quot;color: #ffa657;&quot;&gt;byte&lt;/span&gt;[] data = {&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;1&lt;/span&gt;,&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;0&lt;/span&gt;,&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;0&lt;/span&gt;,&lt;span style=&quot;color: #79c0ff;&quot;&gt;&amp;nbsp;0&lt;/span&gt;&amp;nbsp;};&lt;span style=&quot;color: #ffa657;&quot;&gt;&lt;br/&gt;int&lt;/span&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;value&lt;/span&gt;&amp;nbsp;= MemoryMarshal.Read&amp;lt;&lt;span style=&quot;color: #ffa657;&quot;&gt;int&lt;/span&gt;&amp;gt;(data);&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__480&quot;&gt;读出来通常是：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__481&quot;&gt;1&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__482&quot;&gt;但如果协议规定的是大端序，这么读就是错的。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__483&quot;&gt;协议解析不要靠“当前机器刚好这样存”。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__484&quot;&gt;更稳的写法是：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__485&quot;&gt;int&amp;nbsp;value&amp;nbsp;=&amp;nbsp;BinaryPrimitives.ReadInt32BigEndian(data);&lt;/pre&gt;&lt;h3 data-heading=&quot;true&quot; style=&quot;padding-left: 8px;border-left: 3px solid #0F4C81;margin: 2em 8px 0.75em 0;color: #3f3f3f;font-size: 17.6px;font-weight: bold;line-height: 1.2;&quot; class=&quot;js_darkmode__486&quot;&gt;常见坑 3：结构体里放引用类型字段&lt;/h3&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__487&quot;&gt;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__488&quot;&gt;MemoryMarshal.Read&amp;lt;T&amp;gt;&lt;/code&gt;、&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__489&quot;&gt;Write&amp;lt;T&amp;gt;&lt;/code&gt;、&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__490&quot;&gt;AsBytes&amp;lt;T&amp;gt;&lt;/code&gt;&amp;nbsp;这类方法并不适合随便拿任意结构体来用。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__491&quot;&gt;下面这种结构体就不适合：&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__492&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot;&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&amp;nbsp;struct&lt;/span&gt;&amp;nbsp;UserInfo&lt;br/&gt;{&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;color: #ffa657;&quot;&gt;&amp;nbsp;int&lt;/span&gt;&amp;nbsp;Id;&lt;span style=&quot;color: #ff7b72;&quot;&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;color: #ffa657;&quot;&gt;&amp;nbsp;string&lt;/span&gt;&amp;nbsp;Name;&lt;br/&gt;}&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__493&quot;&gt;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__494&quot;&gt;string&lt;/code&gt;&amp;nbsp;是引用类型。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__495&quot;&gt;它的内存里放的不是字符串内容本身，而是对象引用。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__496&quot;&gt;把这种结构体直接写成字节，不会得到一个可跨进程、可落盘、可传输的稳定格式。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__497&quot;&gt;适合&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__498&quot;&gt;MemoryMarshal&lt;/code&gt;&amp;nbsp;直接读写的结构体，通常只包含：&lt;/p&gt;&lt;ul style=&quot;list-style-type: circle;&quot; class=&quot;js_darkmode__499 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section&gt;• 基础数值类型；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 其他同样明确布局的结构体；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 固定大小、布局稳定的数据。&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 data-heading=&quot;true&quot; style=&quot;padding-left: 8px;border-left: 3px solid #0F4C81;margin: 2em 8px 0.75em 0;color: #3f3f3f;font-size: 17.6px;font-weight: bold;line-height: 1.2;&quot; class=&quot;js_darkmode__503&quot;&gt;常见坑 4：以为零拷贝一定更好&lt;/h3&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__504&quot;&gt;零拷贝不是免费午餐。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__505&quot;&gt;它减少的是分配和复制，但会增加：&lt;/p&gt;&lt;ul style=&quot;list-style-type: circle;&quot; class=&quot;js_darkmode__506 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section&gt;• 对布局的依赖；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 对字节序的依赖；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 对调用方输入合法性的要求；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 代码理解成本。&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__511&quot;&gt;很多业务代码根本不在热点路径。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__512&quot;&gt;这种情况下，清楚、稳定、容易维护的写法更划算。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__513&quot;&gt;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__514&quot;&gt;MemoryMarshal&lt;/code&gt;&amp;nbsp;更适合出现在这些地方：&lt;/p&gt;&lt;ul style=&quot;list-style-type: circle;&quot; class=&quot;js_darkmode__515 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section&gt;• 明确的性能热点；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 二进制协议解析；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 序列化框架；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 网络库；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 文件格式处理；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 已经用&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__522&quot;&gt;Span&amp;lt;T&amp;gt;&lt;/code&gt;&amp;nbsp;/&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__523&quot;&gt;Memory&amp;lt;T&amp;gt;&lt;/code&gt;&amp;nbsp;组织起来的底层缓冲区代码。&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 data-heading=&quot;true&quot; style=&quot;padding-left: 8px;border-left: 3px solid #0F4C81;margin: 2em 8px 0.75em 0;color: #3f3f3f;font-size: 17.6px;font-weight: bold;line-height: 1.2;&quot; class=&quot;js_darkmode__524&quot;&gt;常见坑 5：长期保存底层引用&lt;/h3&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__525&quot;&gt;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__526&quot;&gt;GetReference&lt;/code&gt;&amp;nbsp;拿到的是&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__527&quot;&gt;ref&lt;/code&gt;，不是一个可以长期保存的稳定地址。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__528&quot;&gt;托管对象仍然可能被&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__529&quot;&gt;GC&lt;/code&gt;&amp;nbsp;移动。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__530&quot;&gt;如果需要把地址交给原生代码长期使用，就要进入固定内存、&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__531&quot;&gt;GCHandle&lt;/code&gt;、&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__532&quot;&gt;fixed&lt;/code&gt;、&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__533&quot;&gt;MemoryHandle&lt;/code&gt;&amp;nbsp;这些话题。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__534&quot;&gt;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__535&quot;&gt;MemoryMarshal&lt;/code&gt;&amp;nbsp;本身不等于“固定内存”。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__536&quot;&gt;这点很容易混淆。&lt;/p&gt;&lt;h3 data-heading=&quot;true&quot; style=&quot;padding-left: 8px;border-left: 3px solid #0F4C81;margin: 2em 8px 0.75em 0;color: #3f3f3f;font-size: 17.6px;font-weight: bold;line-height: 1.2;&quot; class=&quot;js_darkmode__537&quot;&gt;一张图看懂&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__538&quot;&gt;MemoryMarshal&lt;/code&gt;&amp;nbsp;的位置&lt;/h3&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__539&quot;&gt;可以把它放在这条链路里理解：&lt;/p&gt;&lt;p&gt;&lt;svg width=&quot;100%&quot; style=&quot;font-family: &amp;#39;trebuchet ms&amp;#39;,verdana,arial,sans-serif;font-size: 16px;fill: #333;max-width: 1071.28125px;&quot; viewbox=&quot;0 0 1071.28125 94&quot; aria-roledescription=&quot;flowchart-v2&quot; aria-label=&quot;插图&quot;&gt;&lt;g&gt;&lt;marker viewbox=&quot;0 0 10 10&quot; refx=&quot;5&quot; refy=&quot;5&quot; markerunits=&quot;userSpaceOnUse&quot; markerwidth=&quot;8&quot; markerheight=&quot;8&quot; orient=&quot;auto&quot; style=&quot;fill: #333333;stroke: #333333;&quot;&gt;&lt;path d=&quot;M 0 0 L 10 5 L 0 10 z&quot; style=&quot;stroke-width: 1;stroke-dasharray: 1, 0;&quot;&gt;&lt;/path&gt;&lt;/marker&gt;&lt;marker viewbox=&quot;0 0 10 10&quot; refx=&quot;4.5&quot; refy=&quot;5&quot; markerunits=&quot;userSpaceOnUse&quot; markerwidth=&quot;8&quot; markerheight=&quot;8&quot; orient=&quot;auto&quot; style=&quot;fill: #333333;stroke: #333333;&quot;&gt;&lt;path d=&quot;M 0 5 L 10 10 L 10 0 z&quot; style=&quot;stroke-width: 1;stroke-dasharray: 1, 0;&quot;&gt;&lt;/path&gt;&lt;/marker&gt;&lt;marker viewbox=&quot;0 0 11.5 14&quot; refx=&quot;11.5&quot; refy=&quot;7&quot; markerunits=&quot;userSpaceOnUse&quot; markerwidth=&quot;10.5&quot; markerheight=&quot;14&quot; orient=&quot;auto&quot; style=&quot;fill: #333333;stroke: #333333;&quot;&gt;&lt;path d=&quot;M 0 0 L 11.5 7 L 0 14 z&quot; style=&quot;stroke-width: 0;stroke-dasharray: 1, 0;&quot;&gt;&lt;/path&gt;&lt;/marker&gt;&lt;marker viewbox=&quot;0 0 11.5 14&quot; refx=&quot;1&quot; refy=&quot;7&quot; markerunits=&quot;userSpaceOnUse&quot; markerwidth=&quot;11.5&quot; markerheight=&quot;14&quot; orient=&quot;auto&quot; style=&quot;fill: #333333;stroke: #333333;&quot;&gt;&lt;polygon points=&quot;0,7 11.5,14 11.5,0&quot; style=&quot;stroke-width: 0;stroke-dasharray: 1, 0;&quot;&gt;&lt;/polygon&gt;&lt;/marker&gt;&lt;marker viewbox=&quot;0 0 10 10&quot; refx=&quot;11&quot; refy=&quot;5&quot; markerunits=&quot;userSpaceOnUse&quot; markerwidth=&quot;11&quot; markerheight=&quot;11&quot; orient=&quot;auto&quot; style=&quot;fill: #333333;stroke: #333333;&quot;&gt;&lt;circle cx=&quot;5&quot; cy=&quot;5&quot; r=&quot;5&quot; style=&quot;stroke-width: 1;stroke-dasharray: 1, 0;&quot;&gt;&lt;/circle&gt;&lt;/marker&gt;&lt;marker viewbox=&quot;0 0 10 10&quot; refx=&quot;-1&quot; refy=&quot;5&quot; markerunits=&quot;userSpaceOnUse&quot; markerwidth=&quot;11&quot; markerheight=&quot;11&quot; orient=&quot;auto&quot; style=&quot;fill: #333333;stroke: #333333;&quot;&gt;&lt;circle cx=&quot;5&quot; cy=&quot;5&quot; r=&quot;5&quot; style=&quot;stroke-width: 1;stroke-dasharray: 1, 0;&quot;&gt;&lt;/circle&gt;&lt;/marker&gt;&lt;marker viewbox=&quot;0 0 10 10&quot; refy=&quot;5&quot; refx=&quot;12.25&quot; markerunits=&quot;userSpaceOnUse&quot; markerwidth=&quot;14&quot; markerheight=&quot;14&quot; orient=&quot;auto&quot; style=&quot;fill: #333333;stroke: #333333;&quot;&gt;&lt;circle cx=&quot;5&quot; cy=&quot;5&quot; r=&quot;5&quot; style=&quot;stroke-width: 0;stroke-dasharray: 1, 0;&quot;&gt;&lt;/circle&gt;&lt;/marker&gt;&lt;marker viewbox=&quot;0 0 10 10&quot; refx=&quot;-2&quot; refy=&quot;5&quot; markerunits=&quot;userSpaceOnUse&quot; markerwidth=&quot;14&quot; markerheight=&quot;14&quot; orient=&quot;auto&quot; style=&quot;fill: #333333;stroke: #333333;&quot;&gt;&lt;circle cx=&quot;5&quot; cy=&quot;5&quot; r=&quot;5&quot; style=&quot;stroke-width: 0;stroke-dasharray: 1, 0;&quot;&gt;&lt;/circle&gt;&lt;/marker&gt;&lt;marker viewbox=&quot;0 0 11 11&quot; refx=&quot;12&quot; refy=&quot;5.2&quot; markerunits=&quot;userSpaceOnUse&quot; markerwidth=&quot;11&quot; markerheight=&quot;11&quot; orient=&quot;auto&quot; style=&quot;fill: #333333;stroke: #333333;&quot;&gt;&lt;path d=&quot;M 1,1 l 9,9 M 10,1 l -9,9&quot; style=&quot;stroke-width: 2;stroke-dasharray: 1, 0;&quot;&gt;&lt;/path&gt;&lt;/marker&gt;&lt;marker viewbox=&quot;0 0 11 11&quot; refx=&quot;-1&quot; refy=&quot;5.2&quot; markerunits=&quot;userSpaceOnUse&quot; markerwidth=&quot;11&quot; markerheight=&quot;11&quot; orient=&quot;auto&quot; style=&quot;fill: #333333;stroke: #333333;&quot;&gt;&lt;path d=&quot;M 1,1 l 9,9 M 10,1 l -9,9&quot; style=&quot;stroke-width: 2;stroke-dasharray: 1, 0;&quot;&gt;&lt;/path&gt;&lt;/marker&gt;&lt;marker viewbox=&quot;0 0 15 15&quot; refx=&quot;17.7&quot; refy=&quot;7.5&quot; markerunits=&quot;userSpaceOnUse&quot; markerwidth=&quot;12&quot; markerheight=&quot;12&quot; orient=&quot;auto&quot; style=&quot;fill: #333333;stroke: #333333;&quot;&gt;&lt;path d=&quot;M 1,1 L 14,14 M 1,14 L 14,1&quot; style=&quot;stroke-width: 2.5;&quot;&gt;&lt;/path&gt;&lt;/marker&gt;&lt;marker viewbox=&quot;0 0 15 15&quot; refx=&quot;-3.5&quot; refy=&quot;7.5&quot; markerunits=&quot;userSpaceOnUse&quot; markerwidth=&quot;12&quot; markerheight=&quot;12&quot; orient=&quot;auto&quot; style=&quot;fill: #333333;stroke: #333333;&quot;&gt;&lt;path d=&quot;M 1,1 L 14,14 M 1,14 L 14,1&quot; style=&quot;stroke-width: 2.5;stroke-dasharray: 1, 0;&quot;&gt;&lt;/path&gt;&lt;/marker&gt;&lt;g&gt;&lt;g&gt;&lt;/g&gt;&lt;g&gt;&lt;path d=&quot;M133.281,47L137.448,47C141.615,47,149.948,47,157.615,47C165.281,47,172.281,47,175.781,47L179.281,47&quot; style=&quot;stroke-width: 1px;stroke-dasharray: 0;stroke: #333333;fill: none;&quot; data-edge=&quot;true&quot; data-et=&quot;edge&quot; data-id=&quot;L_A_B_0&quot; data-points=&quot;W3sieCI6MTMzLjI4MTI1LCJ5Ijo0N30seyJ4IjoxNTguMjgxMjUsInkiOjQ3fSx7IngiOjE4My4yODEyNSwieSI6NDd9XQ==&quot; data-look=&quot;classic&quot; marker-end=&quot;url(#mermaid-svg-p9dlp_flowchart-v2-pointEnd)&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M443.281,47L447.448,47C451.615,47,459.948,47,467.615,47C475.281,47,482.281,47,485.781,47L489.281,47&quot; style=&quot;stroke-width: 1px;stroke-dasharray: 0;stroke: #333333;fill: none;&quot; data-edge=&quot;true&quot; data-et=&quot;edge&quot; data-id=&quot;L_B_C_0&quot; data-points=&quot;W3sieCI6NDQzLjI4MTI1LCJ5Ijo0N30seyJ4Ijo0NjguMjgxMjUsInkiOjQ3fSx7IngiOjQ5My4yODEyNSwieSI6NDd9XQ==&quot; data-look=&quot;classic&quot; marker-end=&quot;url(#mermaid-svg-p9dlp_flowchart-v2-pointEnd)&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M753.281,47L757.448,47C761.615,47,769.948,47,777.615,47C785.281,47,792.281,47,795.781,47L799.281,47&quot; style=&quot;stroke-width: 1px;stroke-dasharray: 0;stroke: #333333;fill: none;&quot; data-edge=&quot;true&quot; data-et=&quot;edge&quot; data-id=&quot;L_C_D_0&quot; data-points=&quot;W3sieCI6NzUzLjI4MTI1LCJ5Ijo0N30seyJ4Ijo3NzguMjgxMjUsInkiOjQ3fSx7IngiOjgwMy4yODEyNSwieSI6NDd9XQ==&quot; data-look=&quot;classic&quot; marker-end=&quot;url(#mermaid-svg-p9dlp_flowchart-v2-pointEnd)&quot;&gt;&lt;/path&gt;&lt;/g&gt;&lt;g&gt;&lt;g style=&quot;background-color: rgba(232,232,232, 0.8);text-align: center;&quot; class=&quot;js_darkmode__540&quot;&gt;&lt;g data-id=&quot;L_A_B_0&quot; transform=&quot;translate(0, 0)&quot; style=&quot;font-family: &amp;#39;trebuchet ms&amp;#39;,verdana,arial,sans-serif;color: #333;&quot; class=&quot;js_darkmode__541&quot;&gt;&lt;foreignobject width=&quot;0&quot; height=&quot;0&quot;&gt;&lt;/foreignobject&gt;&lt;/g&gt;&lt;/g&gt;&lt;g style=&quot;background-color: rgba(232,232,232, 0.8);text-align: center;&quot; class=&quot;js_darkmode__542&quot;&gt;&lt;g data-id=&quot;L_B_C_0&quot; transform=&quot;translate(0, 0)&quot; style=&quot;font-family: &amp;#39;trebuchet ms&amp;#39;,verdana,arial,sans-serif;color: #333;&quot; class=&quot;js_darkmode__543&quot;&gt;&lt;foreignobject width=&quot;0&quot; height=&quot;0&quot;&gt;&lt;/foreignobject&gt;&lt;/g&gt;&lt;/g&gt;&lt;g style=&quot;background-color: rgba(232,232,232, 0.8);text-align: center;&quot; class=&quot;js_darkmode__544&quot;&gt;&lt;g data-id=&quot;L_C_D_0&quot; transform=&quot;translate(0, 0)&quot; style=&quot;font-family: &amp;#39;trebuchet ms&amp;#39;,verdana,arial,sans-serif;color: #333;&quot; class=&quot;js_darkmode__545&quot;&gt;&lt;foreignobject width=&quot;0&quot; height=&quot;0&quot;&gt;&lt;/foreignobject&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;g&gt;&lt;g data-look=&quot;classic&quot; transform=&quot;translate(70.640625, 47)&quot;&gt;&lt;rect style=&quot;fill: #ECECFF;stroke: #9370DB;stroke-width: 1px;&quot; x=&quot;-62.640625&quot; y=&quot;-27&quot; width=&quot;125.28125&quot; height=&quot;54&quot;&gt;&lt;/rect&gt;&lt;g style=&quot;font-family: &amp;#39;trebuchet ms&amp;#39;,verdana,arial,sans-serif;color: #333;text-align: center;&quot; transform=&quot;translate(-32.640625, -12)&quot; class=&quot;js_darkmode__546&quot;&gt;&lt;rect style=&quot;fill: #ECECFF;stroke: #9370DB;stroke-width: 1px;&quot;&gt;&lt;/rect&gt;&lt;foreignobject width=&quot;65.28125&quot; height=&quot;24&quot;&gt;&lt;section style=&quot;display: table-cell;white-space: nowrap;line-height: 1.5;max-width: 200px;text-align: center;&quot;&gt;&lt;span style=&quot;fill: #333;color: #333;&quot; class=&quot;js_darkmode__547&quot;&gt;原始数据&lt;/span&gt;&lt;/section&gt;&lt;/foreignobject&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-look=&quot;classic&quot; transform=&quot;translate(313.28125, 47)&quot;&gt;&lt;rect style=&quot;fill: #ECECFF;stroke: #9370DB;stroke-width: 1px;&quot; x=&quot;-130&quot; y=&quot;-39&quot; width=&quot;260&quot; height=&quot;78&quot;&gt;&lt;/rect&gt;&lt;g style=&quot;font-family: &amp;#39;trebuchet ms&amp;#39;,verdana,arial,sans-serif;color: #333;text-align: center;&quot; transform=&quot;translate(-100, -24)&quot; class=&quot;js_darkmode__548&quot;&gt;&lt;rect style=&quot;fill: #ECECFF;stroke: #9370DB;stroke-width: 1px;&quot;&gt;&lt;/rect&gt;&lt;foreignobject width=&quot;200&quot; height=&quot;48&quot;&gt;&lt;section style=&quot;display: table;white-space: break-spaces;line-height: 1.5;max-width: 200px;text-align: center;width: 200px;&quot;&gt;&lt;span style=&quot;fill: #333;color: #333;&quot; class=&quot;js_darkmode__549&quot;&gt;Span / Memory 连续内存视图&lt;/span&gt;&lt;/section&gt;&lt;/foreignobject&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-look=&quot;classic&quot; transform=&quot;translate(623.28125, 47)&quot;&gt;&lt;rect style=&quot;fill: #ECECFF;stroke: #9370DB;stroke-width: 1px;&quot; x=&quot;-130&quot; y=&quot;-39&quot; width=&quot;260&quot; height=&quot;78&quot;&gt;&lt;/rect&gt;&lt;g style=&quot;font-family: &amp;#39;trebuchet ms&amp;#39;,verdana,arial,sans-serif;color: #333;text-align: center;&quot; transform=&quot;translate(-100, -24)&quot; class=&quot;js_darkmode__550&quot;&gt;&lt;rect style=&quot;fill: #ECECFF;stroke: #9370DB;stroke-width: 1px;&quot;&gt;&lt;/rect&gt;&lt;foreignobject width=&quot;200&quot; height=&quot;48&quot;&gt;&lt;section style=&quot;display: table;white-space: break-spaces;line-height: 1.5;max-width: 200px;text-align: center;width: 200px;&quot;&gt;&lt;span style=&quot;fill: #333;color: #333;&quot; class=&quot;js_darkmode__551&quot;&gt;MemoryMarshal 重解释 / 读写 / 获取引用&lt;/span&gt;&lt;/section&gt;&lt;/foreignobject&gt;&lt;/g&gt;&lt;/g&gt;&lt;g data-look=&quot;classic&quot; transform=&quot;translate(933.28125, 47)&quot;&gt;&lt;rect style=&quot;fill: #ECECFF;stroke: #9370DB;stroke-width: 1px;&quot; x=&quot;-130&quot; y=&quot;-39&quot; width=&quot;260&quot; height=&quot;78&quot;&gt;&lt;/rect&gt;&lt;g style=&quot;font-family: &amp;#39;trebuchet ms&amp;#39;,verdana,arial,sans-serif;color: #333;text-align: center;&quot; transform=&quot;translate(-100, -24)&quot; class=&quot;js_darkmode__552&quot;&gt;&lt;rect style=&quot;fill: #ECECFF;stroke: #9370DB;stroke-width: 1px;&quot;&gt;&lt;/rect&gt;&lt;foreignobject width=&quot;200&quot; height=&quot;48&quot;&gt;&lt;section style=&quot;display: table;white-space: break-spaces;line-height: 1.5;max-width: 200px;text-align: center;width: 200px;&quot;&gt;&lt;span style=&quot;fill: #333;color: #333;&quot; class=&quot;js_darkmode__553&quot;&gt;结构体 / 字节视图 / ref / ArraySegment&lt;/span&gt;&lt;/section&gt;&lt;/foreignobject&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;/g&gt;&lt;defs&gt;&lt;filter height=&quot;130%&quot; width=&quot;130%&quot;&gt;&lt;fedropshadow dx=&quot;4&quot; dy=&quot;4&quot; stddeviation=&quot;0&quot; flood-opacity=&quot;0.06&quot; flood-color=&quot;#000000&quot;&gt;&lt;/fedropshadow&gt;&lt;/filter&gt;&lt;/defs&gt;&lt;defs&gt;&lt;filter height=&quot;150%&quot; width=&quot;150%&quot;&gt;&lt;fedropshadow dx=&quot;2&quot; dy=&quot;2&quot; stddeviation=&quot;0&quot; flood-opacity=&quot;0.06&quot; flood-color=&quot;#000000&quot;&gt;&lt;/fedropshadow&gt;&lt;/filter&gt;&lt;/defs&gt;&lt;/svg&gt;&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__554&quot;&gt;普通代码多数时候停在&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__555&quot;&gt;Span&amp;lt;T&amp;gt;&lt;/code&gt;&amp;nbsp;/&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__556&quot;&gt;Memory&amp;lt;T&amp;gt;&lt;/code&gt;&amp;nbsp;就够了。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__557&quot;&gt;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__558&quot;&gt;MemoryMarshal&lt;/code&gt;&amp;nbsp;是继续往下一层走，处理“怎么按底层内存表示理解这段数据”。&lt;/p&gt;&lt;h3 data-heading=&quot;true&quot; style=&quot;padding-left: 8px;border-left: 3px solid #0F4C81;margin: 2em 8px 0.75em 0;color: #3f3f3f;font-size: 17.6px;font-weight: bold;line-height: 1.2;&quot; class=&quot;js_darkmode__559&quot;&gt;总结&lt;/h3&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__560&quot;&gt;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__561&quot;&gt;MemoryMarshal&lt;/code&gt;&amp;nbsp;的核心不是“神奇转换”，而是：&lt;/p&gt;&lt;blockquote style=&quot;font-style: normal;padding: 1em;border-left: 4px solid #0F4C81;border-radius: 6px;color: #3f3f3f;background: #f7f7f7;margin-bottom: 1em;&quot; class=&quot;js_darkmode__562&quot;&gt;&lt;p style=&quot;display: block;font-size: 1em;letter-spacing: 0.1em;color: #3f3f3f;margin: 0;&quot; class=&quot;js_darkmode__563&quot;&gt;在不复制数据的前提下，把同一段内存换一种方式读取、写入或暴露出来。&lt;/p&gt;&lt;/blockquote&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__564&quot;&gt;它最常用的几类能力是：&lt;/p&gt;&lt;ul style=&quot;list-style-type: circle;&quot; class=&quot;js_darkmode__565 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section&gt;•&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__567&quot;&gt;Cast&lt;/code&gt;：把一段内存按另一种元素类型看；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;•&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__569&quot;&gt;AsBytes&lt;/code&gt;：把结构体内存看成字节；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;•&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__571&quot;&gt;Read&lt;/code&gt;&amp;nbsp;/&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__572&quot;&gt;Write&lt;/code&gt;：从字节缓冲区读写结构体；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;•&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__574&quot;&gt;TryGetArray&lt;/code&gt;：从&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__575&quot;&gt;Memory&amp;lt;T&amp;gt;&lt;/code&gt;&amp;nbsp;里尽量拿到底层数组；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;•&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__577&quot;&gt;GetReference&lt;/code&gt;&amp;nbsp;/&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__578&quot;&gt;CreateSpan&lt;/code&gt;：做更底层的&amp;nbsp;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__579&quot;&gt;ref&lt;/code&gt;&amp;nbsp;级操作。&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__580&quot;&gt;真正需要记住的是边界：&lt;/p&gt;&lt;ul style=&quot;list-style-type: circle;&quot; class=&quot;js_darkmode__581 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section&gt;• 它不负责处理协议字节序；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 它不负责保证结构体布局一定符合外部数据；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 它不适合带引用类型字段的结构体直接落盘或传输；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 它不等于固定内存；&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section&gt;• 它也不是普通业务代码的默认选择。&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__587&quot;&gt;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__588&quot;&gt;MemoryMarshal&lt;/code&gt;&amp;nbsp;更像一把薄刀。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__589&quot;&gt;适合在明确知道内存布局、明确知道数据来源、明确需要减少复制的地方使用。&lt;/p&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__590&quot;&gt;如果只是为了“看起来高性能”而使用它，通常不值得。&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Sat, 30 May 2026 11:12:41 +0800</pubDate></item><item><title>苦等十年！Nodejs 终于发布全栈神器 TypeORM 1.0！</title><link>https://www.codepub.top/post/464.html</link><description>&lt;p&gt;&lt;strong style=&quot;box-sizing: border-box; font-weight: bold; cursor: pointer; color: rgb(0, 0, 0); background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); width: auto; height: auto; margin: 0px; padding: 0px; border-style: none; border-width: 3px; border-color: rgba(0, 0, 0, 0.4); border-radius: 0px; visibility: visible;&quot; class=&quot;js_darkmode__1&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;TypeORM 1.0.0 已于 2026年5月正式发布&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;，距首个版本发布已过去近10年，是一次里程碑式的重大更新。&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;img class=&quot;ue-image&quot; src=&quot;https://www.codepub.top/zb_users/upload/2026/05/202605301780110670711872.jpg&quot; title=&quot;ScreenShot_2026-05-30_111026_468.jpg&quot; alt=&quot;ScreenShot_2026-05-30_111026_468.jpg&quot;/&gt;&lt;/p&gt;&lt;h3 style=&quot;box-sizing: border-box; margin: 30px 0px 15px; color: rgba(0, 0, 0, 0.85); font-weight: 500; cursor: pointer; padding: 0px; display: flex; font-family: Optima, PingFangSC-regular, serif; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; visibility: visible;&quot; class=&quot;js_darkmode__2&quot;&gt;&lt;span style=&quot;box-sizing: border-box; cursor: pointer; font-size: 20px; color: #773098; line-height: 1.5em; letter-spacing: 0em; font-weight: bold; display: block; visibility: visible;&quot; class=&quot;js_darkmode__3&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;一、核心定位&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;ul style=&quot;list-style-type: disc;&quot; class=&quot;js_darkmode__4 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section style=&quot;box-sizing: border-box; cursor: pointer; margin-top: 5px; margin-bottom: 5px; color: rgb(90, 90, 90); font-size: 15px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal; visibility: visible;&quot;&gt;&lt;strong style=&quot;box-sizing: border-box; font-weight: bold; cursor: pointer; color: rgb(0, 0, 0); background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); width: auto; height: auto; margin: 0px; padding: 0px; border-style: none; border-width: 3px; border-color: rgba(0, 0, 0, 0.4); border-radius: 0px; visibility: visible;&quot; class=&quot;js_darkmode__5&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;长期 deprecated API 全部清除&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;，架构全面现代化。&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section style=&quot;box-sizing: border-box; cursor: pointer; margin-top: 5px; margin-bottom: 5px; color: rgb(90, 90, 90); font-size: 15px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal; visibility: visible;&quot;&gt;&lt;strong style=&quot;box-sizing: border-box; font-weight: bold; cursor: pointer; color: rgb(0, 0, 0); background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); width: auto; height: auto; margin: 0px; padding: 0px; border-style: none; border-width: 3px; border-color: rgba(0, 0, 0, 0.4); border-radius: 0px; visibility: visible;&quot; class=&quot;js_darkmode__6&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;最低要求 &lt;span class=&quot;&quot;&gt;Node.js 20+&lt;/span&gt;、ES2023&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;，不再支持 Node.js 16/18。&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section style=&quot;box-sizing: border-box; cursor: pointer; margin-top: 5px; margin-bottom: 5px; color: rgb(90, 90, 90); font-size: 15px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal; visibility: visible;&quot;&gt;&lt;strong style=&quot;box-sizing: border-box; font-weight: bold; cursor: pointer; color: rgb(0, 0, 0); background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); width: auto; height: auto; margin: 0px; padding: 0px; border-style: none; border-width: 3px; border-color: rgba(0, 0, 0, 0.4); border-radius: 0px; visibility: visible;&quot; class=&quot;js_darkmode__7&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;统一使用 &lt;span class=&quot;&quot;&gt;DataSource&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;，彻底移除旧版 Connection / createConnection。&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 style=&quot;box-sizing: border-box; margin: 30px 0px 15px; color: rgba(0, 0, 0, 0.85); font-weight: 500; cursor: pointer; padding: 0px; display: flex; font-family: Optima, PingFangSC-regular, serif; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; visibility: visible;&quot; class=&quot;js_darkmode__8&quot;&gt;&lt;span style=&quot;box-sizing: border-box; cursor: pointer; font-size: 20px; color: #773098; line-height: 1.5em; letter-spacing: 0em; font-weight: bold; display: block; visibility: visible;&quot; class=&quot;js_darkmode__9&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;二、主要破坏性变更（必看）&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;ol style=&quot;list-style-type: decimal;&quot; class=&quot;js_darkmode__10 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section style=&quot;box-sizing: border-box; cursor: pointer; margin-top: 5px; margin-bottom: 5px; color: rgb(90, 90, 90); font-size: 15px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal; visibility: visible;&quot;&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px 0px; cursor: pointer; color: rgb(90, 90, 90); font-size: 15px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; text-indent: 0em; padding: 8px 0px; visibility: visible;&quot;&gt;&lt;strong style=&quot;box-sizing: border-box; font-weight: bold; cursor: pointer; color: rgb(0, 0, 0); background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); width: auto; height: auto; margin: 0px; padding: 0px; border-style: none; border-width: 3px; border-color: rgba(0, 0, 0, 0.4); border-radius: 0px; visibility: visible;&quot; class=&quot;js_darkmode__11&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;运行时环境&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;/section&gt;&lt;/li&gt;&lt;ul style=&quot;list-style-type: disc;&quot; class=&quot;js_darkmode__12 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section style=&quot;box-sizing: border-box; cursor: pointer; margin-top: 5px; margin-bottom: 5px; color: rgb(90, 90, 90); font-size: 15px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal; visibility: visible;&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;Node.js 最低 20.x；目标 ES2023。&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section style=&quot;box-sizing: border-box; cursor: pointer; margin-top: 5px; margin-bottom: 5px; color: rgb(90, 90, 90); font-size: 15px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal; visibility: visible;&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;非 Node 平台二进制用&amp;nbsp;&lt;/span&gt;&lt;strong style=&quot;box-sizing: border-box; font-weight: bold; cursor: pointer; color: rgb(0, 0, 0); background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); width: auto; height: auto; margin: 0px; padding: 0px; border-style: none; border-width: 3px; border-color: rgba(0, 0, 0, 0.4); border-radius: 0px; visibility: visible;&quot; class=&quot;js_darkmode__13&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;&lt;span class=&quot;&quot;&gt;Uint8Array&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;&amp;nbsp;替代 Buffer。&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;&lt;section style=&quot;box-sizing: border-box; cursor: pointer; margin-top: 5px; margin-bottom: 5px; color: rgb(90, 90, 90); font-size: 15px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; font-weight: normal; visibility: visible;&quot;&gt;&lt;p style=&quot;box-sizing: border-box; margin: 10px 0px; cursor: pointer; color: rgb(90, 90, 90); font-size: 15px; line-height: 1.8em; letter-spacing: 0.02em; text-align: left; text-indent: 0em; padding: 8px 0px; visibility: visible;&quot;&gt;&lt;strong style=&quot;box-sizing: border-box; font-weight: bold; cursor: pointer; color: rgb(0, 0, 0); background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0); width: auto; height: auto; margin: 0px; padding: 0px; border-style: none; border-width: 3px; border-color: rgba(0, 0, 0, 0.4); border-radius: 0px; visibility: visible;&quot; class=&quot;js_darkmode__14&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;连接体系重构&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;/section&gt;&lt;/li&gt;&lt;ul style=&quot;list-style-type: disc;&quot; class=&quot;js_darkmode__15 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section style=&quot;box-sizing: border-box;cursor: pointer;margin-top: 5px;margin-bottom: 5px;color: rgb(90, 90, 90);font-size: 15px;line-height: 1.8em;letter-spacing: 0.02em;text-align: left;font-weight: normal;&quot;&gt;&lt;code style=&quot;box-sizing: border-box;font-family: &amp;quot;Operator Mono&amp;quot;, Consolas, Monaco, Menlo, monospace;font-size: 1em;cursor: pointer;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;margin: 0px 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;overflow-wrap: break-word;word-break: break-all;&quot; class=&quot;js_darkmode__16&quot;&gt;connection.close()&lt;/code&gt;&amp;nbsp;→&amp;nbsp;&lt;code style=&quot;box-sizing: border-box;font-family: &amp;quot;Operator Mono&amp;quot;, Consolas, Monaco, Menlo, monospace;font-size: 1em;cursor: pointer;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;margin: 0px 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;overflow-wrap: break-word;word-break: break-all;&quot; class=&quot;js_darkmode__17&quot;&gt;dataSource.destroy()&lt;/code&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section style=&quot;box-sizing: border-box;cursor: pointer;margin-top: 5px;margin-bottom: 5px;color: rgb(90, 90, 90);font-size: 15px;line-height: 1.8em;letter-spacing: 0.02em;text-align: left;font-weight: normal;&quot;&gt;&lt;code style=&quot;box-sizing: border-box;font-family: &amp;quot;Operator Mono&amp;quot;, Consolas, Monaco, Menlo, monospace;font-size: 1em;cursor: pointer;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;margin: 0px 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;overflow-wrap: break-word;word-break: break-all;&quot; class=&quot;js_darkmode__18&quot;&gt;connection.isConnected&lt;/code&gt;&amp;nbsp;→&amp;nbsp;&lt;code style=&quot;box-sizing: border-box;font-family: &amp;quot;Operator Mono&amp;quot;, Consolas, Monaco, Menlo, monospace;font-size: 1em;cursor: pointer;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;margin: 0px 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;overflow-wrap: break-word;word-break: break-all;&quot; class=&quot;js_darkmode__19&quot;&gt;dataSource.isInitialized&lt;/code&gt;。&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section style=&quot;box-sizing: border-box;cursor: pointer;margin-top: 5px;margin-bottom: 5px;color: rgb(90, 90, 90);font-size: 15px;line-height: 1.8em;letter-spacing: 0.02em;text-align: left;font-weight: normal;&quot;&gt;✅ 保留：&lt;code style=&quot;box-sizing: border-box;font-family: &amp;quot;Operator Mono&amp;quot;, Consolas, Monaco, Menlo, monospace;font-size: 1em;cursor: pointer;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;margin: 0px 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;overflow-wrap: break-word;word-break: break-all;&quot; class=&quot;js_darkmode__21&quot;&gt;new DataSource({ ... }).initialize()&lt;/code&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section style=&quot;box-sizing: border-box;cursor: pointer;margin-top: 5px;margin-bottom: 5px;color: rgb(90, 90, 90);font-size: 15px;line-height: 1.8em;letter-spacing: 0.02em;text-align: left;font-weight: normal;&quot;&gt;❌ 移除：&lt;code style=&quot;box-sizing: border-box;font-family: &amp;quot;Operator Mono&amp;quot;, Consolas, Monaco, Menlo, monospace;font-size: 1em;cursor: pointer;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;margin: 0px 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;overflow-wrap: break-word;word-break: break-all;&quot; class=&quot;js_darkmode__22&quot;&gt;Connection&lt;/code&gt;&amp;nbsp;类、&lt;code style=&quot;box-sizing: border-box;font-family: &amp;quot;Operator Mono&amp;quot;, Consolas, Monaco, Menlo, monospace;font-size: 1em;cursor: pointer;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;margin: 0px 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;overflow-wrap: break-word;word-break: break-all;&quot; class=&quot;js_darkmode__23&quot;&gt;createConnection()&lt;/code&gt;、&lt;code style=&quot;box-sizing: border-box;font-family: &amp;quot;Operator Mono&amp;quot;, Consolas, Monaco, Menlo, monospace;font-size: 1em;cursor: pointer;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;margin: 0px 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;overflow-wrap: break-word;word-break: break-all;&quot; class=&quot;js_darkmode__24&quot;&gt;connection.close()&lt;/code&gt;、&lt;code style=&quot;box-sizing: border-box;font-family: &amp;quot;Operator Mono&amp;quot;, Consolas, Monaco, Menlo, monospace;font-size: 1em;cursor: pointer;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;margin: 0px 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;overflow-wrap: break-word;word-break: break-all;&quot; class=&quot;js_darkmode__25&quot;&gt;connection.isConnected&lt;/code&gt;。&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section style=&quot;box-sizing: border-box;cursor: pointer;margin-top: 5px;margin-bottom: 5px;color: rgb(90, 90, 90);font-size: 15px;line-height: 1.8em;letter-spacing: 0.02em;text-align: left;font-weight: normal;&quot;&gt;对应替换：&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;&lt;section style=&quot;box-sizing: border-box;cursor: pointer;margin-top: 5px;margin-bottom: 5px;color: rgb(90, 90, 90);font-size: 15px;line-height: 1.8em;letter-spacing: 0.02em;text-align: left;font-weight: normal;&quot;&gt;&lt;p style=&quot;box-sizing: border-box;margin: 10px 0px;cursor: pointer;color: rgb(90, 90, 90);font-size: 15px;line-height: 1.8em;letter-spacing: 0.02em;text-align: left;text-indent: 0em;padding: 8px 0px;&quot;&gt;&lt;strong style=&quot;box-sizing: border-box;font-weight: bold;cursor: pointer;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0);width: auto;height: auto;margin: 0px;padding: 0px;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;&quot; class=&quot;js_darkmode__26&quot;&gt;MySQL 相关&lt;/strong&gt;&lt;/p&gt;&lt;/section&gt;&lt;/li&gt;&lt;ul style=&quot;list-style-type: disc;&quot; class=&quot;js_darkmode__27 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section style=&quot;box-sizing: border-box;cursor: pointer;margin-top: 5px;margin-bottom: 5px;color: rgb(90, 90, 90);font-size: 15px;line-height: 1.8em;letter-spacing: 0.02em;text-align: left;font-weight: normal;&quot;&gt;仅支持&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box;font-weight: bold;cursor: pointer;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0);width: auto;height: auto;margin: 0px;padding: 0px;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;&quot; class=&quot;js_darkmode__28&quot;&gt;mysql2&lt;/strong&gt;，移除旧 mysql 客户端。&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section style=&quot;box-sizing: border-box;cursor: pointer;margin-top: 5px;margin-bottom: 5px;color: rgb(90, 90, 90);font-size: 15px;line-height: 1.8em;letter-spacing: 0.02em;text-align: left;font-weight: normal;&quot;&gt;&lt;code style=&quot;box-sizing: border-box;font-family: &amp;quot;Operator Mono&amp;quot;, Consolas, Monaco, Menlo, monospace;font-size: 1em;cursor: pointer;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;margin: 0px 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;overflow-wrap: break-word;word-break: break-all;&quot; class=&quot;js_darkmode__29&quot;&gt;legacySpatialSupport&lt;/code&gt;&amp;nbsp;默认&amp;nbsp;&lt;code style=&quot;box-sizing: border-box;font-family: &amp;quot;Operator Mono&amp;quot;, Consolas, Monaco, Menlo, monospace;font-size: 1em;cursor: pointer;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;margin: 0px 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;overflow-wrap: break-word;word-break: break-all;&quot; class=&quot;js_darkmode__30&quot;&gt;false&lt;/code&gt;，用标准&amp;nbsp;&lt;code style=&quot;box-sizing: border-box;font-family: &amp;quot;Operator Mono&amp;quot;, Consolas, Monaco, Menlo, monospace;font-size: 1em;cursor: pointer;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;margin: 0px 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;overflow-wrap: break-word;word-break: break-all;&quot; class=&quot;js_darkmode__31&quot;&gt;ST_GeomFromText&lt;/code&gt;。&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section style=&quot;box-sizing: border-box;cursor: pointer;margin-top: 5px;margin-bottom: 5px;color: rgb(90, 90, 90);font-size: 15px;line-height: 1.8em;letter-spacing: 0.02em;text-align: left;font-weight: normal;&quot;&gt;移除&amp;nbsp;&lt;code style=&quot;box-sizing: border-box;font-family: &amp;quot;Operator Mono&amp;quot;, Consolas, Monaco, Menlo, monospace;font-size: 1em;cursor: pointer;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;margin: 0px 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;overflow-wrap: break-word;word-break: break-all;&quot; class=&quot;js_darkmode__32&quot;&gt;width&lt;/code&gt;、&lt;code style=&quot;box-sizing: border-box;font-family: &amp;quot;Operator Mono&amp;quot;, Consolas, Monaco, Menlo, monospace;font-size: 1em;cursor: pointer;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;margin: 0px 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;overflow-wrap: break-word;word-break: break-all;&quot; class=&quot;js_darkmode__33&quot;&gt;zerofill&lt;/code&gt;&amp;nbsp;列选项（MySQL 8.4 已移除）。&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;&lt;section style=&quot;box-sizing: border-box;cursor: pointer;margin-top: 5px;margin-bottom: 5px;color: rgb(90, 90, 90);font-size: 15px;line-height: 1.8em;letter-spacing: 0.02em;text-align: left;font-weight: normal;&quot;&gt;&lt;p style=&quot;box-sizing: border-box;margin: 10px 0px;cursor: pointer;color: rgb(90, 90, 90);font-size: 15px;line-height: 1.8em;letter-spacing: 0.02em;text-align: left;text-indent: 0em;padding: 8px 0px;&quot;&gt;&lt;strong style=&quot;box-sizing: border-box;font-weight: bold;cursor: pointer;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0);width: auto;height: auto;margin: 0px;padding: 0px;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;&quot; class=&quot;js_darkmode__34&quot;&gt;查询与数据校验&lt;/strong&gt;&lt;/p&gt;&lt;/section&gt;&lt;/li&gt;&lt;ul style=&quot;list-style-type: disc;&quot; class=&quot;js_darkmode__35 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section style=&quot;box-sizing: border-box;cursor: pointer;margin-top: 5px;margin-bottom: 5px;color: rgb(90, 90, 90);font-size: 15px;line-height: 1.8em;letter-spacing: 0.02em;text-align: left;font-weight: normal;&quot;&gt;&lt;code style=&quot;box-sizing: border-box;font-family: &amp;quot;Operator Mono&amp;quot;, Consolas, Monaco, Menlo, monospace;font-size: 1em;cursor: pointer;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;margin: 0px 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;overflow-wrap: break-word;word-break: break-all;&quot; class=&quot;js_darkmode__36&quot;&gt;find({ where: { text: null } })&lt;/code&gt;&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box;font-weight: bold;cursor: pointer;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0);width: auto;height: auto;margin: 0px;padding: 0px;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;&quot; class=&quot;js_darkmode__37&quot;&gt;不再静默匹配所有&lt;/strong&gt;，直接抛错。&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section style=&quot;box-sizing: border-box;cursor: pointer;margin-top: 5px;margin-bottom: 5px;color: rgb(90, 90, 90);font-size: 15px;line-height: 1.8em;letter-spacing: 0.02em;text-align: left;font-weight: normal;&quot;&gt;QueryBuilder&amp;nbsp;&lt;code style=&quot;box-sizing: border-box;font-family: &amp;quot;Operator Mono&amp;quot;, Consolas, Monaco, Menlo, monospace;font-size: 1em;cursor: pointer;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;margin: 0px 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;overflow-wrap: break-word;word-break: break-all;&quot; class=&quot;js_darkmode__38&quot;&gt;orderBy&lt;/code&gt;&amp;nbsp;增加运行时校验，防注入。&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/ol&gt;&lt;h3 style=&quot;box-sizing: border-box;margin: 30px 0px 15px;color: rgba(0, 0, 0, 0.85);font-weight: 500;cursor: pointer;padding: 0px;display: flex;font-family: Optima, PingFangSC-regular, serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: left;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;&quot; class=&quot;js_darkmode__39&quot;&gt;&lt;span style=&quot;box-sizing: border-box;cursor: pointer;font-size: 20px;color: #773098;line-height: 1.5em;letter-spacing: 0em;font-weight: bold;display: block;&quot; class=&quot;js_darkmode__40&quot;&gt;三、重要新特性&lt;/span&gt;&lt;/h3&gt;&lt;ul style=&quot;list-style-type: disc;&quot; class=&quot;js_darkmode__41 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section style=&quot;box-sizing: border-box;cursor: pointer;margin-top: 5px;margin-bottom: 5px;color: rgb(90, 90, 90);font-size: 15px;line-height: 1.8em;letter-spacing: 0.02em;text-align: left;font-weight: normal;&quot;&gt;**QueryRunner 支持&amp;nbsp;&lt;code style=&quot;box-sizing: border-box;font-family: &amp;quot;Operator Mono&amp;quot;, Consolas, Monaco, Menlo, monospace;font-size: 1em;cursor: pointer;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;margin: 0px 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;overflow-wrap: break-word;word-break: break-all;&quot; class=&quot;js_darkmode__42&quot;&gt;await using&lt;/code&gt;**（TS 5.2+），自动资源释放。&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section style=&quot;box-sizing: border-box;cursor: pointer;margin-top: 5px;margin-bottom: 5px;color: rgb(90, 90, 90);font-size: 15px;line-height: 1.8em;letter-spacing: 0.02em;text-align: left;font-weight: normal;&quot;&gt;**所有 drop 方法支持&amp;nbsp;&lt;code style=&quot;box-sizing: border-box;font-family: &amp;quot;Operator Mono&amp;quot;, Consolas, Monaco, Menlo, monospace;font-size: 1em;cursor: pointer;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;margin: 0px 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;overflow-wrap: break-word;word-break: break-all;&quot; class=&quot;js_darkmode__43&quot;&gt;ifExists&lt;/code&gt;**（列、索引、主键、外键等）。&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section style=&quot;box-sizing: border-box;cursor: pointer;margin-top: 5px;margin-bottom: 5px;color: rgb(90, 90, 90);font-size: 15px;line-height: 1.8em;letter-spacing: 0.02em;text-align: left;font-weight: normal;&quot;&gt;&lt;strong style=&quot;box-sizing: border-box;font-weight: bold;cursor: pointer;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0);width: auto;height: auto;margin: 0px;padding: 0px;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;&quot; class=&quot;js_darkmode__44&quot;&gt;DataSource 级默认&lt;span class=&quot;&quot;&gt;事务隔离级别&lt;/span&gt;&lt;/strong&gt;，统一全局事务行为。&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section style=&quot;box-sizing: border-box;cursor: pointer;margin-top: 5px;margin-bottom: 5px;color: rgb(90, 90, 90);font-size: 15px;line-height: 1.8em;letter-spacing: 0.02em;text-align: left;font-weight: normal;&quot;&gt;&lt;strong style=&quot;box-sizing: border-box;font-weight: bold;cursor: pointer;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0);width: auto;height: auto;margin: 0px;padding: 0px;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;&quot; class=&quot;js_darkmode__45&quot;&gt;依赖精简&lt;/strong&gt;：glob → tinyglobby，移除 rimraf，哈希改用原生 &lt;span class=&quot;&quot;&gt;crypto&lt;/span&gt;。&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 style=&quot;box-sizing: border-box;margin: 30px 0px 15px;color: rgba(0, 0, 0, 0.85);font-weight: 500;cursor: pointer;padding: 0px;display: flex;font-family: Optima, PingFangSC-regular, serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: left;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;&quot; class=&quot;js_darkmode__46&quot;&gt;&lt;span style=&quot;box-sizing: border-box;cursor: pointer;font-size: 20px;color: #773098;line-height: 1.5em;letter-spacing: 0em;font-weight: bold;display: block;&quot; class=&quot;js_darkmode__47&quot;&gt;四、升级要点（从 0.3.x）&lt;/span&gt;&lt;/h3&gt;&lt;ol style=&quot;list-style-type: decimal;&quot; class=&quot;js_darkmode__48 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section style=&quot;box-sizing: border-box;cursor: pointer;margin-top: 5px;margin-bottom: 5px;color: rgb(90, 90, 90);font-size: 15px;line-height: 1.8em;letter-spacing: 0.02em;text-align: left;font-weight: normal;&quot;&gt;升级 Node.js 到 **20+**、TS 到 **5.2+**。&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section style=&quot;box-sizing: border-box;cursor: pointer;margin-top: 5px;margin-bottom: 5px;color: rgb(90, 90, 90);font-size: 15px;line-height: 1.8em;letter-spacing: 0.02em;text-align: left;font-weight: normal;&quot;&gt;全局替换：&lt;/section&gt;&lt;/li&gt;&lt;ul style=&quot;list-style-type: disc;&quot; class=&quot;js_darkmode__49 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section style=&quot;box-sizing: border-box;cursor: pointer;margin-top: 5px;margin-bottom: 5px;color: rgb(90, 90, 90);font-size: 15px;line-height: 1.8em;letter-spacing: 0.02em;text-align: left;font-weight: normal;&quot;&gt;&lt;code style=&quot;box-sizing: border-box;font-family: &amp;quot;Operator Mono&amp;quot;, Consolas, Monaco, Menlo, monospace;font-size: 1em;cursor: pointer;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;margin: 0px 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;overflow-wrap: break-word;word-break: break-all;&quot; class=&quot;js_darkmode__50&quot;&gt;createConnection()&lt;/code&gt;&amp;nbsp;→&amp;nbsp;&lt;code style=&quot;box-sizing: border-box;font-family: &amp;quot;Operator Mono&amp;quot;, Consolas, Monaco, Menlo, monospace;font-size: 1em;cursor: pointer;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;margin: 0px 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;overflow-wrap: break-word;word-break: break-all;&quot; class=&quot;js_darkmode__51&quot;&gt;new DataSource().initialize()&lt;/code&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section style=&quot;box-sizing: border-box;cursor: pointer;margin-top: 5px;margin-bottom: 5px;color: rgb(90, 90, 90);font-size: 15px;line-height: 1.8em;letter-spacing: 0.02em;text-align: left;font-weight: normal;&quot;&gt;&lt;code style=&quot;box-sizing: border-box;font-family: &amp;quot;Operator Mono&amp;quot;, Consolas, Monaco, Menlo, monospace;font-size: 1em;cursor: pointer;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;margin: 0px 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;overflow-wrap: break-word;word-break: break-all;&quot; class=&quot;js_darkmode__52&quot;&gt;connection&lt;/code&gt;&amp;nbsp;实例 →&amp;nbsp;&lt;code style=&quot;box-sizing: border-box;font-family: &amp;quot;Operator Mono&amp;quot;, Consolas, Monaco, Menlo, monospace;font-size: 1em;cursor: pointer;background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(27, 31, 35, 0.05);width: auto;margin: 0px 2px;padding: 2px 4px;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);border-radius: 4px;overflow-wrap: break-word;word-break: break-all;&quot; class=&quot;js_darkmode__53&quot;&gt;dataSource&lt;/code&gt;。&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;&lt;section style=&quot;box-sizing: border-box;cursor: pointer;margin-top: 5px;margin-bottom: 5px;color: rgb(90, 90, 90);font-size: 15px;line-height: 1.8em;letter-spacing: 0.02em;text-align: left;font-weight: normal;&quot;&gt;检查并移除所有已废弃装饰器/选项。&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section style=&quot;box-sizing: border-box;cursor: pointer;margin-top: 5px;margin-bottom: 5px;color: rgb(90, 90, 90);font-size: 15px;line-height: 1.8em;letter-spacing: 0.02em;text-align: left;font-weight: normal;&quot;&gt;NestJS 用户：等待&amp;nbsp;&lt;strong style=&quot;box-sizing: border-box;font-weight: bold;cursor: pointer;color: rgb(0, 0, 0);background: none 0% 0% / auto no-repeat scroll padding-box border-box rgba(0, 0, 0, 0);width: auto;height: auto;margin: 0px;padding: 0px;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;&quot; class=&quot;js_darkmode__54&quot;&gt;@nestjs/typeorm 适配版&lt;/strong&gt;（v11 暂不兼容）。&lt;/section&gt;&lt;/li&gt;&lt;/ol&gt;&lt;h3 style=&quot;box-sizing: border-box;margin: 30px 0px 15px;color: rgba(0, 0, 0, 0.85);font-weight: 500;cursor: pointer;padding: 0px;display: flex;font-family: Optima, PingFangSC-regular, serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: left;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;&quot; class=&quot;js_darkmode__55&quot;&gt;&lt;span style=&quot;box-sizing: border-box;cursor: pointer;font-size: 20px;color: #773098;line-height: 1.5em;letter-spacing: 0em;font-weight: bold;display: block;&quot; class=&quot;js_darkmode__56&quot;&gt;五、安装&lt;/span&gt;&lt;/h3&gt;&lt;pre style=&quot;box-sizing: border-box;font-size: 16px;font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace;margin: 10px 0px;overflow: auto;cursor: pointer;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;text-align: left;padding: 0px;color: rgb(0, 0, 0);font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;&quot; class=&quot;js_darkmode__57&quot;&gt;&lt;code style=&quot;box-sizing: border-box;font-family: Consolas, Monaco, Menlo, monospace;font-size: 12px;display: -webkit-box;overflow-x: auto;padding: 15px 16px 16px;color: rgb(171, 178, 191);background: rgb(40, 44, 52);cursor: pointer;border-radius: 5px;&quot; class=&quot;js_darkmode__58&quot;&gt;npm install typeorm@1.0.0&lt;br style=&quot;box-sizing: border-box;cursor: pointer;&quot;/&gt;&lt;span style=&quot;box-sizing: border-box;color: #5C6370;font-style: italic;cursor: pointer;line-height: 26px;&quot; class=&quot;js_darkmode__59&quot;&gt;# 或&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box;cursor: pointer;&quot;/&gt;yarn add typeorm@1.0.0&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Sat, 30 May 2026 11:09:44 +0800</pubDate></item><item><title>开箱即用的 .NET 8 + Avalonia + SukiUI 桌面应用模板</title><link>https://www.codepub.top/post/462.html</link><description>&lt;h1 data-tool=&quot;mdnice编辑器&quot; style=&quot;padding: 0px; display: block; font-size: 16px; margin: 0px; text-align: left; line-height: 1.75em; visibility: visible;&quot;&gt;&lt;span style=&quot;font-size: 16px; color: #0052FF; letter-spacing: 0em; font-weight: bold; display: block; padding-bottom: 5px; visibility: visible;&quot; class=&quot;js_darkmode__1&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;前言&lt;/span&gt;&lt;/span&gt;&lt;/h1&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0); font-size: 16px; line-height: 1.75em; letter-spacing: 0em; text-align: left; text-indent: 0em; margin: 0px; padding: 5px 0px; visibility: visible;&quot; class=&quot;js_darkmode__2&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;在跨平台桌面应用开发领域，Avalonia凭借其与WPF相似的API设计和跨平台特性，逐渐成为.NET生态中备受关注的UI框架。&lt;/span&gt;&lt;/p&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0); font-size: 16px; line-height: 1.75em; letter-spacing: 0em; text-align: left; text-indent: 0em; margin: 0px; padding: 5px 0px; visibility: visible;&quot; class=&quot;js_darkmode__3&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;然而，对于初学者而言，从零搭建一个包含数据展示、浏览器集成、多语言支持等功能的完整应用仍存在较高门槛。&lt;/span&gt;&lt;/p&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0); font-size: 16px; line-height: 1.75em; letter-spacing: 0em; text-align: left; text-indent: 0em; margin: 0px; padding: 5px 0px; visibility: visible;&quot; class=&quot;js_darkmode__4&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;推荐一个通过整合Avalonia、&lt;span class=&quot;&quot;&gt;SukiUI&lt;/span&gt;等核心组件，提供一套开箱即用的桌面应用开发模板，在降低学习成本，加速开发流程。本文将从项目架构、功能实现、技术特点等维度展开分析，为大家提供全面的参考指南。&lt;/span&gt;&lt;/p&gt;&lt;h2 data-tool=&quot;mdnice编辑器&quot; style=&quot;padding: 0px; display: block; font-size: 16px; margin: 0px; text-align: left; line-height: 1.75em; visibility: visible;&quot;&gt;&lt;span style=&quot;font-size: 16px; color: #0052FF; letter-spacing: 0em; font-weight: bold; display: block; padding: 5px 0px; visibility: visible;&quot; class=&quot;js_darkmode__5&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;项目介绍&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0); font-size: 16px; line-height: 1.75em; letter-spacing: 0em; text-align: left; text-indent: 0em; margin: 0px; padding: 5px 0px; visibility: visible;&quot; class=&quot;js_darkmode__6&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;一个简易的桌面应用集成框架，其核心在于展示如何基于Avalonia与SukiUI开发一个简单的桌面应用，并整合了如DataGrid、CefGlue.Avalonia等常用功能，以简化开发流程并提高效率。&lt;/span&gt;&lt;/p&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0); font-size: 16px; line-height: 1.75em; letter-spacing: 0em; text-align: left; text-indent: 0em; margin: 0px; padding: 5px 0px; visibility: visible;&quot; class=&quot;js_darkmode__7&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;该框架不仅展示基本组件的使用方法，还提供对图表（&lt;span class=&quot;&quot;&gt;LiveChartsCore&lt;/span&gt;）、图标库（Material.Icons.Avalonia）的支持，以及多语言环境和更新功能的搭建示例。&lt;/span&gt;&lt;/p&gt;&lt;h2 data-tool=&quot;mdnice编辑器&quot; style=&quot;padding: 0px; display: block; font-size: 16px; margin: 0px; text-align: left; line-height: 1.75em; visibility: visible;&quot;&gt;&lt;span style=&quot;font-size: 16px; color: #0052FF; letter-spacing: 0em; font-weight: bold; display: block; padding: 5px 0px; visibility: visible;&quot; class=&quot;js_darkmode__8&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;项目功能&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h3 data-tool=&quot;mdnice编辑器&quot; style=&quot;padding: 0px; display: block; margin: 0px; text-align: left; line-height: 1.75em; visibility: visible;&quot;&gt;&lt;span style=&quot;font-size: 16px; color: #000000; letter-spacing: 0em; font-weight: bold; display: block; padding: 5px 0px; visibility: visible;&quot; class=&quot;js_darkmode__9&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;1、数据网格（DataGrid）与分页功能&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0); font-size: 16px; line-height: 1.75em; letter-spacing: 0em; text-align: left; text-indent: 0em; margin: 0px; padding: 5px 0px; visibility: visible;&quot; class=&quot;js_darkmode__10&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;实现方式：基于&lt;/span&gt;&lt;code style=&quot;font-size: 14px; letter-spacing: 0em; width: auto; height: auto; border-style: none; border-width: 3px; border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4); font-family: Consolas, Monaco, Menlo, monospace; word-break: break-all; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: rgb(233, 105, 0); background: rgb(248, 248, 248); visibility: visible;&quot; class=&quot;js_darkmode__11&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;Avalonia.Controls.DataGrid&lt;/span&gt;&lt;/code&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;控件，通过自定义&lt;/span&gt;&lt;code style=&quot;font-size: 14px; letter-spacing: 0em; width: auto; height: auto; border-style: none; border-width: 3px; border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4); font-family: Consolas, Monaco, Menlo, monospace; word-break: break-all; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: rgb(233, 105, 0); background: rgb(248, 248, 248); visibility: visible;&quot; class=&quot;js_darkmode__12&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;PagedCollection&amp;lt;T&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;类实现数据分页加载；&lt;/span&gt;&lt;/p&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0); font-size: 16px; line-height: 1.75em; letter-spacing: 0em; text-align: left; text-indent: 0em; margin: 0px; padding: 5px 0px; visibility: visible;&quot; class=&quot;js_darkmode__13&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;交互逻辑：分页控件与DataGrid双向绑定，用户点击页码时触发&lt;/span&gt;&lt;code style=&quot;font-size: 14px; letter-spacing: 0em; width: auto; height: auto; border-style: none; border-width: 3px; border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4); font-family: Consolas, Monaco, Menlo, monospace; word-break: break-all; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: rgb(233, 105, 0); background: rgb(248, 248, 248); visibility: visible;&quot; class=&quot;js_darkmode__14&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;LoadPageCommand&lt;/span&gt;&lt;/code&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;命令，动态更新数据源；&lt;/span&gt;&lt;/p&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0); font-size: 16px; line-height: 1.75em; letter-spacing: 0em; text-align: left; text-indent: 0em; margin: 0px; padding: 5px 0px; visibility: visible;&quot; class=&quot;js_darkmode__15&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;示例代码：&lt;/span&gt;&lt;code style=&quot;font-size: 14px; letter-spacing: 0em; width: auto; height: auto; border-style: none; border-width: 3px; border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4); font-family: Consolas, Monaco, Menlo, monospace; word-break: break-all; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: rgb(233, 105, 0); background: rgb(248, 248, 248); visibility: visible;&quot; class=&quot;js_darkmode__16&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;DataGridFeature.axaml&lt;/span&gt;&lt;/code&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;中定义了列配置与分页控件布局，&lt;/span&gt;&lt;code style=&quot;font-size: 14px; letter-spacing: 0em; width: auto; height: auto; border-style: none; border-width: 3px; border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4); font-family: Consolas, Monaco, Menlo, monospace; word-break: break-all; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: rgb(233, 105, 0); background: rgb(248, 248, 248); visibility: visible;&quot; class=&quot;js_darkmode__17&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;DataGridViewModel.cs&lt;/span&gt;&lt;/code&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;处理数据加载与分页逻辑。&lt;/span&gt;&lt;/p&gt;&lt;h3 data-tool=&quot;mdnice编辑器&quot; style=&quot;padding: 0px; display: block; margin: 0px; text-align: left; line-height: 1.75em; visibility: visible;&quot;&gt;&lt;span style=&quot;font-size: 16px; color: #000000; letter-spacing: 0em; font-weight: bold; display: block; padding: 5px 0px; visibility: visible;&quot; class=&quot;js_darkmode__18&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;2、内嵌浏览器（CEF）集成&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0); font-size: 16px; line-height: 1.75em; letter-spacing: 0em; text-align: left; text-indent: 0em; margin: 0px; padding: 5px 0px; visibility: visible;&quot; class=&quot;js_darkmode__19&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;技术选型：采用&lt;/span&gt;&lt;code style=&quot;font-size: 14px; letter-spacing: 0em; width: auto; height: auto; border-style: none; border-width: 3px; border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4); font-family: Consolas, Monaco, Menlo, monospace; word-break: break-all; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: rgb(233, 105, 0); background: rgb(248, 248, 248); visibility: visible;&quot; class=&quot;js_darkmode__20&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;CefGlue.Avalonia&lt;/span&gt;&lt;/code&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;实现Chromium嵌入式框架的集成；&lt;/span&gt;&lt;/p&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0); font-size: 16px; line-height: 1.75em; letter-spacing: 0em; text-align: left; text-indent: 0em; margin: 0px; padding: 5px 0px; visibility: visible;&quot; class=&quot;js_darkmode__21&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;当前限制：暂未实现页面内容解析（如DOM操作）与代理设置，但支持基础导航与地址栏显示；&lt;/span&gt;&lt;/p&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0); font-size: 16px; line-height: 1.75em; letter-spacing: 0em; text-align: left; text-indent: 0em; margin: 0px; padding: 5px 0px; visibility: visible;&quot; class=&quot;js_darkmode__22&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;使用场景：适合需要嵌入Web应用（如内部管理系统、帮助文档）的桌面工具。&lt;/span&gt;&lt;/p&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0); font-size: 16px; line-height: 1.75em; letter-spacing: 0em; text-align: left; text-indent: 0em; margin: 0px; padding: 5px 0px; visibility: visible;&quot; class=&quot;js_darkmode__23&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;3、动态图表渲染（LiveChartsCore）&lt;/span&gt;&lt;/p&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0); font-size: 16px; line-height: 1.75em; letter-spacing: 0em; text-align: left; text-indent: 0em; margin: 0px; padding: 5px 0px; visibility: visible;&quot; class=&quot;js_darkmode__24&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;功能覆盖：支持折线图、柱状图、饼图等常见图表类型；&lt;/span&gt;&lt;/p&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0); font-size: 16px; line-height: 1.75em; letter-spacing: 0em; text-align: left; text-indent: 0em; margin: 0px; padding: 5px 0px; visibility: visible;&quot; class=&quot;js_darkmode__25&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;数据绑定：通过&lt;/span&gt;&lt;code style=&quot;font-size: 14px; letter-spacing: 0em; width: auto; height: auto; border-style: none; border-width: 3px; border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4); font-family: Consolas, Monaco, Menlo, monospace; word-break: break-all; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: rgb(233, 105, 0); background: rgb(248, 248, 248); visibility: visible;&quot; class=&quot;js_darkmode__26&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;SeriesCollection&lt;/span&gt;&lt;/code&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;绑定动态数据源，例如实时监控系统中的传感器数据；&lt;/span&gt;&lt;/p&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0); font-size: 16px; line-height: 1.75em; letter-spacing: 0em; text-align: left; text-indent: 0em; margin: 0px; padding: 5px 0px; visibility: visible;&quot; class=&quot;js_darkmode__27&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;交互扩展：支持图表缩放、鼠标悬停提示等高级功能。&lt;/span&gt;&lt;/p&gt;&lt;h3 data-tool=&quot;mdnice编辑器&quot; style=&quot;padding: 0px; display: block; margin: 0px; text-align: left; line-height: 1.75em; visibility: visible;&quot;&gt;&lt;span style=&quot;font-size: 16px; color: #000000; letter-spacing: 0em; font-weight: bold; display: block; padding: 5px 0px; visibility: visible;&quot; class=&quot;js_darkmode__28&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;4、图标库（Material.Icons.Avalonia）&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0); font-size: 16px; line-height: 1.75em; letter-spacing: 0em; text-align: left; text-indent: 0em; margin: 0px; padding: 5px 0px; visibility: visible;&quot; class=&quot;js_darkmode__29&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;引入方式：通过NuGet包直接添加依赖，无需手动复制资源文件；&lt;/span&gt;&lt;/p&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0); font-size: 16px; line-height: 1.75em; letter-spacing: 0em; text-align: left; text-indent: 0em; margin: 0px; padding: 5px 0px; visibility: visible;&quot; class=&quot;js_darkmode__30&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;使用示例：在XAML中通过&lt;/span&gt;&lt;code style=&quot;font-size: 14px; letter-spacing: 0em; width: auto; height: auto; border-style: none; border-width: 3px; border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4); font-family: Consolas, Monaco, Menlo, monospace; word-break: break-all; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: rgb(233, 105, 0); background: rgb(248, 248, 248); visibility: visible;&quot; class=&quot;js_darkmode__31&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;&amp;lt;materialIcon:MaterialIcon Kind=&amp;quot;Home&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;快速插入&lt;span class=&quot;&quot;&gt;Material Design&lt;/span&gt;图标。&lt;/span&gt;&lt;/p&gt;&lt;h3 data-tool=&quot;mdnice编辑器&quot; style=&quot;padding: 0px; display: block; margin: 0px; text-align: left; line-height: 1.75em; visibility: visible;&quot;&gt;&lt;span style=&quot;font-size: 16px; color: #000000; letter-spacing: 0em; font-weight: bold; display: block; padding: 5px 0px; visibility: visible;&quot; class=&quot;js_darkmode__32&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;5、多语言支持&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0); font-size: 16px; line-height: 1.75em; letter-spacing: 0em; text-align: left; text-indent: 0em; margin: 0px; padding: 5px 0px; visibility: visible;&quot; class=&quot;js_darkmode__33&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;实现机制：使用CSV文件存储翻译键值对（如&lt;/span&gt;&lt;code style=&quot;font-size: 14px; letter-spacing: 0em; width: auto; height: auto; border-style: none; border-width: 3px; border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4); font-family: Consolas, Monaco, Menlo, monospace; word-break: break-all; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: rgb(233, 105, 0); background: rgb(248, 248, 248); visibility: visible;&quot; class=&quot;js_darkmode__34&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;Resources/zh-CN.csv&lt;/span&gt;&lt;/code&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;），通过&lt;/span&gt;&lt;code style=&quot;font-size: 14px; letter-spacing: 0em; width: auto; height: auto; border-style: none; border-width: 3px; border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4); font-family: Consolas, Monaco, Menlo, monospace; word-break: break-all; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: rgb(233, 105, 0); background: rgb(248, 248, 248); visibility: visible;&quot; class=&quot;js_darkmode__35&quot;&gt;&lt;span style=&quot;visibility: visible;&quot;&gt;Localization.cs&lt;/span&gt;&lt;/code&gt;工具类动态加载语言包；&lt;/p&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0);font-size: 16px;line-height: 1.75em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin: 0px;padding: 5px 0px;&quot; class=&quot;js_darkmode__36&quot;&gt;切换方式：调用&lt;code style=&quot;font-size: 14px;letter-spacing: 0em;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);font-family: Consolas, Monaco, Menlo, monospace;word-break: break-all;overflow-wrap: break-word;padding: 2px 4px;border-radius: 4px;margin: 0px 2px;color: rgb(233, 105, 0);background: rgb(248, 248, 248);&quot; class=&quot;js_darkmode__37&quot;&gt;Localization.SetLanguage(&amp;quot;en-US&amp;quot;)&lt;/code&gt;即可全局更新UI文本，无需重启应用。&lt;/p&gt;&lt;h3 data-tool=&quot;mdnice编辑器&quot; style=&quot;padding: 0px;display: block;margin: 0px;text-align: left;line-height: 1.75em;&quot;&gt;&lt;span style=&quot;font-size: 16px;color: #000000;letter-spacing: 0em;font-weight: bold;display: block;padding: 5px 0px;&quot; class=&quot;js_darkmode__38&quot;&gt;6、自动更新功能&lt;/span&gt;&lt;/h3&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0);font-size: 16px;line-height: 1.75em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin: 0px;padding: 5px 0px;&quot; class=&quot;js_darkmode__39&quot;&gt;技术栈：集成&lt;code style=&quot;font-size: 14px;letter-spacing: 0em;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);font-family: Consolas, Monaco, Menlo, monospace;word-break: break-all;overflow-wrap: break-word;padding: 2px 4px;border-radius: 4px;margin: 0px 2px;color: rgb(233, 105, 0);background: rgb(248, 248, 248);&quot; class=&quot;js_darkmode__40&quot;&gt;Downloader&lt;/code&gt;库实现后台版本检查与文件下载；&lt;/p&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0);font-size: 16px;line-height: 1.75em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin: 0px;padding: 5px 0px;&quot; class=&quot;js_darkmode__41&quot;&gt;触发流程：&lt;code style=&quot;font-size: 14px;letter-spacing: 0em;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);font-family: Consolas, Monaco, Menlo, monospace;word-break: break-all;overflow-wrap: break-word;padding: 2px 4px;border-radius: 4px;margin: 0px 2px;color: rgb(233, 105, 0);background: rgb(248, 248, 248);&quot; class=&quot;js_darkmode__42&quot;&gt;UpdateTask.cs&lt;/code&gt;定期调用&lt;code style=&quot;font-size: 14px;letter-spacing: 0em;width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgb(0, 0, 0) rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.4);font-family: Consolas, Monaco, Menlo, monospace;word-break: break-all;overflow-wrap: break-word;padding: 2px 4px;border-radius: 4px;margin: 0px 2px;color: rgb(233, 105, 0);background: rgb(248, 248, 248);&quot; class=&quot;js_darkmode__43&quot;&gt;CheckVersion()&lt;/code&gt;方法，检测到新版本后下载安装包并提示用户重启。&lt;/p&gt;&lt;h2 data-tool=&quot;mdnice编辑器&quot; style=&quot;padding: 0px;display: block;font-size: 16px;margin: 0px;text-align: left;line-height: 1.75em;&quot;&gt;&lt;span style=&quot;font-size: 16px;color: #0052FF;letter-spacing: 0em;font-weight: bold;display: block;padding: 5px 0px;&quot; class=&quot;js_darkmode__44&quot;&gt;项目特点&lt;/span&gt;&lt;/h2&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0);font-size: 16px;line-height: 1.75em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin: 0px;padding: 5px 0px;&quot; class=&quot;js_darkmode__45&quot;&gt;1、简单易懂：大多数功能直接使用，减少封装层级，方便理解。&lt;/p&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0);font-size: 16px;line-height: 1.75em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin: 0px;padding: 5px 0px;&quot; class=&quot;js_darkmode__46&quot;&gt;2、跨平台支持：基于Avalonia框架，确保在Windows、macOS和Linux等多个操作系统上的兼容性。&lt;/p&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0);font-size: 16px;line-height: 1.75em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin: 0px;padding: 5px 0px;&quot; class=&quot;js_darkmode__47&quot;&gt;3、功能全面：涵盖从数据展示到用户交互，再到更新机制在内的多个方面。&lt;/p&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0);font-size: 16px;line-height: 1.75em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin: 0px;padding: 5px 0px;&quot; class=&quot;js_darkmode__48&quot;&gt;4、高度定制化：通过SukiUI提供的丰富的UI控件和主题选项，满足个性化需求。&lt;/p&gt;&lt;h2 data-tool=&quot;mdnice编辑器&quot; style=&quot;padding: 0px;display: block;font-size: 16px;margin: 0px;text-align: left;line-height: 1.75em;&quot;&gt;&lt;span style=&quot;font-size: 16px;color: #0052FF;letter-spacing: 0em;font-weight: bold;display: block;padding: 5px 0px;&quot; class=&quot;js_darkmode__49&quot;&gt;项目结构&lt;/span&gt;&lt;/h2&gt;&lt;pre data-tool=&quot;mdnice编辑器&quot; style=&quot;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;text-align: left;margin: 10px 0px;padding: 0px;line-height: 1.75em;&quot; class=&quot;js_darkmode__50&quot;&gt;&lt;span data-cacheurl=&quot;&quot; data-remoteid=&quot;&quot; style=&quot;display: block;background: url(&amp;quot;https://mmbiz.qpic.cn/mmbiz_svg/VNMic85jx3X6UZ7JN1CrmsyLq0QG09DEXDvBHS3WZeTpR2h4R5cTmccuHmO6FRhgGCFKZW2Dz58hnHR1zT64C7WA245WU99CI/640?wx_fmt=svg&amp;amp;from=appmsg&amp;quot;) 10px 10px / 40px no-repeat #282C34;height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;&quot; class=&quot;js_darkmode__bg__0 js_darkmode__51&quot;&gt;&lt;/span&gt;&lt;code style=&quot;overflow-x: auto;padding: 15px 16px 16px;color: rgb(171, 178, 191);background: rgb(40, 44, 52);border-radius: 5px;display: -webkit-box;font-family: Consolas, Monaco, Menlo, monospace;font-size: 12px;&quot; class=&quot;js_darkmode__52&quot;&gt;EasyTemplate.Desktop.Avalonia/&lt;br/&gt;├── EasyTemplate.Ava.Desktop/ &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #5C6370;font-style: italic;&quot; class=&quot;js_darkmode__53&quot;&gt;# 主启动项目&lt;/span&gt;&lt;br/&gt;├── EasyTemplate.Ava/ &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #5C6370;font-style: italic;&quot; class=&quot;js_darkmode__54&quot;&gt;# 桌面组件主要项目&lt;/span&gt;&lt;br/&gt;│ &amp;nbsp; └── Features/ &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #5C6370;font-style: italic;&quot; class=&quot;js_darkmode__55&quot;&gt;# 组件存放目录&lt;/span&gt;&lt;br/&gt;├── EasyTemplate.Ava.Tool/ &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #5C6370;font-style: italic;&quot; class=&quot;js_darkmode__56&quot;&gt;# 工具类、实体和配置&lt;/span&gt;&lt;br/&gt;│ &amp;nbsp; ├── Resources/ &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #5C6370;font-style: italic;&quot; class=&quot;js_darkmode__57&quot;&gt;# 多语言资源文件&lt;/span&gt;&lt;br/&gt;│ &amp;nbsp; ├── Util/ &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #5C6370;font-style: italic;&quot; class=&quot;js_darkmode__58&quot;&gt;# 工具类&lt;/span&gt;&lt;br/&gt;│ &amp;nbsp; ├── Configuration/ &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #5C6370;font-style: italic;&quot; class=&quot;js_darkmode__59&quot;&gt;# 配置文件&lt;/span&gt;&lt;br/&gt;│ &amp;nbsp; └── Entity/ &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #5C6370;font-style: italic;&quot; class=&quot;js_darkmode__60&quot;&gt;# 实体类&lt;/span&gt;&lt;br/&gt;└── ThirdPartyDemo/ &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #5C6370;font-style: italic;&quot; class=&quot;js_darkmode__61&quot;&gt;# 第三方示例（已编译版本）&lt;/span&gt;&lt;br/&gt;&amp;nbsp; &amp;nbsp; ├── SukiUI.Demo/&lt;br/&gt;&amp;nbsp; &amp;nbsp; └── Material.Icons.Avalonia/&lt;br/&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 data-tool=&quot;mdnice编辑器&quot; style=&quot;padding: 0px;display: block;font-size: 16px;margin: 0px;text-align: left;line-height: 1.75em;&quot;&gt;&lt;span style=&quot;font-size: 16px;color: #0052FF;letter-spacing: 0em;font-weight: bold;display: block;padding: 5px 0px;&quot; class=&quot;js_darkmode__62&quot;&gt;项目技术&lt;/span&gt;&lt;/h2&gt;&lt;h3 data-tool=&quot;mdnice编辑器&quot; style=&quot;padding: 0px;display: block;margin: 0px;text-align: left;line-height: 1.75em;&quot;&gt;&lt;span style=&quot;font-size: 16px;color: #000000;letter-spacing: 0em;font-weight: bold;display: block;padding: 5px 0px;&quot; class=&quot;js_darkmode__63&quot;&gt;.NET 8&lt;/span&gt;&lt;/h3&gt;&lt;ul style=&quot;list-style-type: disc;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0);font-size: 16px;line-height: 1.75em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin: 0px;padding: 5px 0px;&quot; class=&quot;js_darkmode__64&quot;&gt;作为长期支持（LTS）版本，提供性能优化与新特性（如原生AOT编译）；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 data-tool=&quot;mdnice编辑器&quot; style=&quot;padding: 0px;display: block;margin: 0px;text-align: left;line-height: 1.75em;&quot;&gt;&lt;span style=&quot;font-size: 16px;color: #000000;letter-spacing: 0em;font-weight: bold;display: block;padding: 5px 0px;&quot; class=&quot;js_darkmode__65&quot;&gt;Avalonia 11&lt;/span&gt;&lt;/h3&gt;&lt;ul style=&quot;list-style-type: disc;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0);font-size: 16px;line-height: 1.75em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin: 0px;padding: 5px 0px;&quot; class=&quot;js_darkmode__66&quot;&gt;跨平台UI框架，支持Windows/macOS/Linux，API设计兼容WPF开发；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 data-tool=&quot;mdnice编辑器&quot; style=&quot;padding: 0px;display: block;margin: 0px;text-align: left;line-height: 1.75em;&quot;&gt;&lt;span style=&quot;font-size: 16px;color: #000000;letter-spacing: 0em;font-weight: bold;display: block;padding: 5px 0px;&quot; class=&quot;js_darkmode__67&quot;&gt;SukiUI&lt;/span&gt;&lt;/h3&gt;&lt;ul style=&quot;list-style-type: disc;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0);font-size: 16px;line-height: 1.75em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin: 0px;padding: 5px 0px;&quot; class=&quot;js_darkmode__68&quot;&gt;现代化控件库，补充Avalonia原生控件的不足（如导航栏、卡片布局）；&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 data-tool=&quot;mdnice编辑器&quot; style=&quot;padding: 0px;display: block;margin: 0px;text-align: left;line-height: 1.75em;&quot;&gt;&lt;span style=&quot;font-size: 16px;color: #000000;letter-spacing: 0em;font-weight: bold;display: block;padding: 5px 0px;&quot; class=&quot;js_darkmode__69&quot;&gt;LiveChartsCore&lt;/span&gt;&lt;/h3&gt;&lt;ul style=&quot;list-style-type: disc;&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0);font-size: 16px;line-height: 1.75em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin: 0px;padding: 5px 0px;&quot; class=&quot;js_darkmode__70&quot;&gt;轻量级图表库，相比OxyPlot更易上手，适合快速实现数据可视化。&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2 data-tool=&quot;mdnice编辑器&quot; style=&quot;padding: 0px;display: block;font-size: 16px;margin: 0px;text-align: left;line-height: 1.75em;&quot;&gt;&lt;span style=&quot;font-size: 16px;color: #0052FF;letter-spacing: 0em;font-weight: bold;display: block;padding: 5px 0px;&quot; class=&quot;js_darkmode__71&quot;&gt;项目效果&lt;/span&gt;&lt;/h2&gt;&lt;h3 data-tool=&quot;mdnice编辑器&quot; style=&quot;padding: 0px;display: block;margin: 0px;text-align: left;line-height: 1.75em;&quot;&gt;&lt;span style=&quot;font-size: 16px;color: #000000;letter-spacing: 0em;font-weight: bold;display: block;padding: 5px 0px;&quot; class=&quot;js_darkmode__72&quot;&gt;模版效果&lt;/span&gt;&lt;/h3&gt;&lt;p&gt;&lt;/p&gt;&lt;section style=&quot;text-align: center;&quot;&gt;&lt;img data-src=&quot;https://mmbiz.qpic.cn/sz_mmbiz_gif/oicJiaCwicKClnevzlDTmkRKcia6YHf4aLeE2gQdtJU7FGtQC8Aok6NCIicibSPnZo0VdL8ogCUU67Tpaakcp2634gibw/640?wx_fmt=gif&amp;amp;from=appmsg#imgIndex=0&quot; class=&quot;rich_pages wxw-img __bg_gif&quot; data-ratio=&quot;0.5407407407407407&quot; data-type=&quot;gif&quot; data-w=&quot;1080&quot; style=&quot;width: 677px !important; height: auto !important; visibility: visible !important;&quot; type=&quot;block&quot; data-backw=&quot;578&quot; data-backh=&quot;313&quot; data-imgfileid=&quot;309489954&quot; data-aistatus=&quot;1&quot; data-original-style=&quot;width:100%;&quot; data-index=&quot;3&quot; src=&quot;https://mmbiz.qpic.cn/sz_mmbiz_gif/oicJiaCwicKClnevzlDTmkRKcia6YHf4aLeE2gQdtJU7FGtQC8Aok6NCIicibSPnZo0VdL8ogCUU67Tpaakcp2634gibw/640?wx_fmt=gif&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1#imgIndex=0&quot; _width=&quot;100%&quot; data-order=&quot;0&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780038486644&quot; data-report-img-idx=&quot;0&quot; data-fail=&quot;0&quot;/&gt;&lt;/section&gt;&lt;p&gt;&lt;/p&gt;&lt;h3 data-tool=&quot;mdnice编辑器&quot; style=&quot;padding: 0px;display: block;margin: 0px;text-align: left;line-height: 1.75em;&quot;&gt;&lt;br/&gt;&lt;/h3&gt;&lt;h3 data-tool=&quot;mdnice编辑器&quot; style=&quot;padding: 0px;display: block;margin: 0px;text-align: left;line-height: 1.75em;&quot;&gt;&lt;span style=&quot;font-size: 16px;color: #000000;letter-spacing: 0em;font-weight: bold;display: block;padding: 5px 0px;&quot; class=&quot;js_darkmode__73&quot;&gt;模版首页&lt;/span&gt;&lt;/h3&gt;&lt;p&gt;&lt;/p&gt;&lt;figure data-tool=&quot;mdnice编辑器&quot; style=&quot;display: flex;flex-direction: column;justify-content: center;align-items: center;font-size: 16px;margin: 0px;padding: 0px;&quot;&gt;&lt;img data-src=&quot;https://mmbiz.qpic.cn/sz_mmbiz_png/oicJiaCwicKClnevzlDTmkRKcia6YHf4aLeEiboTvtzVAXC7bGicRFadeaHibUIFhn2gj4kpTWSnEWQRopFL1tV1ugU1w/640?wx_fmt=png&amp;amp;from=appmsg&amp;amp;watermark=1#imgIndex=1&quot; class=&quot;rich_pages wxw-img js_darkmode__74&quot; data-ratio=&quot;0.525&quot; data-type=&quot;png&quot; data-w=&quot;1080&quot; style=&quot;display: block; margin: 0px auto; max-width: 100%; border-style: none; border-width: 3px; border-color: rgba(0, 0, 0, 0.4); border-radius: 0px; object-fit: fill; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px; width: 677px !important; height: auto !important; visibility: visible !important;&quot; data-backw=&quot;578&quot; data-backh=&quot;304&quot; data-imgfileid=&quot;309489949&quot; data-aistatus=&quot;1&quot; data-original-style=&quot;display:block;margin:0px auto;max-width:100%;border-style:none;border-width:3px;border-color:rgba(0, 0, 0, 0.4);border-radius:0px;object-fit:fill;box-shadow:rgba(0, 0, 0, 0) 0px 0px 0px 0px;width:100%;&quot; data-index=&quot;4&quot; src=&quot;https://mmbiz.qpic.cn/sz_mmbiz_png/oicJiaCwicKClnevzlDTmkRKcia6YHf4aLeEiboTvtzVAXC7bGicRFadeaHibUIFhn2gj4kpTWSnEWQRopFL1tV1ugU1w/640?wx_fmt=png&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1&amp;watermark=1#imgIndex=1&quot; _width=&quot;100%&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780038486984&quot; data-report-img-idx=&quot;1&quot; data-fail=&quot;0&quot;/&gt;&lt;/figure&gt;&lt;p&gt;&lt;/p&gt;&lt;h3 data-tool=&quot;mdnice编辑器&quot; style=&quot;padding: 0px;display: block;margin: 0px;text-align: left;line-height: 1.75em;&quot;&gt;&lt;span style=&quot;font-size: 16px;color: #000000;letter-spacing: 0em;font-weight: bold;display: block;padding: 5px 0px;&quot; class=&quot;js_darkmode__75&quot;&gt;数据管理&lt;/span&gt;&lt;/h3&gt;&lt;p&gt;&lt;/p&gt;&lt;figure data-tool=&quot;mdnice编辑器&quot; style=&quot;display: flex;flex-direction: column;justify-content: center;align-items: center;font-size: 16px;margin: 0px;padding: 0px;&quot;&gt;&lt;img data-src=&quot;https://mmbiz.qpic.cn/sz_mmbiz_png/oicJiaCwicKClnevzlDTmkRKcia6YHf4aLeEZTpLibgK02JHLZNkYPucnibeyQnU7S7BbBb57MqB0DBXhgzLM1STtRkw/640?wx_fmt=png&amp;amp;from=appmsg&amp;amp;watermark=1#imgIndex=2&quot; class=&quot;rich_pages wxw-img js_darkmode__76&quot; data-ratio=&quot;0.5472222222222223&quot; data-type=&quot;png&quot; data-w=&quot;1080&quot; style=&quot;display: block; margin: 0px auto; max-width: 100%; border-style: none; border-width: 3px; border-color: rgba(0, 0, 0, 0.4); border-radius: 0px; object-fit: fill; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px; width: 677px !important; height: auto !important; visibility: visible !important;&quot; data-backw=&quot;578&quot; data-backh=&quot;316&quot; data-imgfileid=&quot;309489952&quot; data-aistatus=&quot;1&quot; data-original-style=&quot;display:block;margin:0px auto;max-width:100%;border-style:none;border-width:3px;border-color:rgba(0, 0, 0, 0.4);border-radius:0px;object-fit:fill;box-shadow:rgba(0, 0, 0, 0) 0px 0px 0px 0px;width:100%;&quot; data-index=&quot;5&quot; src=&quot;https://mmbiz.qpic.cn/sz_mmbiz_png/oicJiaCwicKClnevzlDTmkRKcia6YHf4aLeEZTpLibgK02JHLZNkYPucnibeyQnU7S7BbBb57MqB0DBXhgzLM1STtRkw/640?wx_fmt=png&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1&amp;watermark=1#imgIndex=2&quot; _width=&quot;100%&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780038487463&quot; data-report-img-idx=&quot;2&quot; data-fail=&quot;0&quot;/&gt;&lt;/figure&gt;&lt;p&gt;&lt;/p&gt;&lt;h3 data-tool=&quot;mdnice编辑器&quot; style=&quot;padding: 0px;display: block;margin: 0px;text-align: left;line-height: 1.75em;&quot;&gt;&lt;span style=&quot;font-size: 16px;color: #000000;letter-spacing: 0em;font-weight: bold;display: block;padding: 5px 0px;&quot; class=&quot;js_darkmode__77&quot;&gt;内嵌浏览器&lt;/span&gt;&lt;/h3&gt;&lt;p&gt;&lt;/p&gt;&lt;figure data-tool=&quot;mdnice编辑器&quot; style=&quot;display: flex;flex-direction: column;justify-content: center;align-items: center;font-size: 16px;margin: 0px;padding: 0px;&quot;&gt;&lt;img data-src=&quot;https://mmbiz.qpic.cn/sz_mmbiz_jpg/oicJiaCwicKClnevzlDTmkRKcia6YHf4aLeELWE2esNvV8ef9lojV4estCQZwubYVdhMib2vqpuuzamI1I4LiaRW3KHQ/640?wx_fmt=jpeg&amp;amp;from=appmsg&amp;amp;watermark=1#imgIndex=3&quot; class=&quot;rich_pages wxw-img js_darkmode__78&quot; data-ratio=&quot;0.55&quot; data-type=&quot;jpeg&quot; data-w=&quot;1080&quot; style=&quot;display: block; margin: 0px auto; max-width: 100%; border-style: none; border-width: 3px; border-color: rgba(0, 0, 0, 0.4); border-radius: 0px; object-fit: fill; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px; width: 677px !important; height: auto !important; visibility: visible !important;&quot; data-backw=&quot;578&quot; data-backh=&quot;318&quot; data-imgfileid=&quot;309489950&quot; data-aistatus=&quot;1&quot; data-original-style=&quot;display:block;margin:0px auto;max-width:100%;border-style:none;border-width:3px;border-color:rgba(0, 0, 0, 0.4);border-radius:0px;object-fit:fill;box-shadow:rgba(0, 0, 0, 0) 0px 0px 0px 0px;width:100%;&quot; data-index=&quot;6&quot; src=&quot;https://mmbiz.qpic.cn/sz_mmbiz_jpg/oicJiaCwicKClnevzlDTmkRKcia6YHf4aLeELWE2esNvV8ef9lojV4estCQZwubYVdhMib2vqpuuzamI1I4LiaRW3KHQ/640?wx_fmt=jpeg&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1&amp;watermark=1#imgIndex=3&quot; _width=&quot;100%&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780038488002&quot; data-report-img-idx=&quot;3&quot; data-fail=&quot;0&quot;/&gt;&lt;/figure&gt;&lt;p&gt;&lt;/p&gt;&lt;h3 data-tool=&quot;mdnice编辑器&quot; style=&quot;padding: 0px;display: block;margin: 0px;text-align: left;line-height: 1.75em;&quot;&gt;&lt;span style=&quot;font-size: 16px;color: #000000;letter-spacing: 0em;font-weight: bold;display: block;padding: 5px 0px;&quot; class=&quot;js_darkmode__79&quot;&gt;系统设置&lt;/span&gt;&lt;/h3&gt;&lt;p&gt;&lt;/p&gt;&lt;figure data-tool=&quot;mdnice编辑器&quot; style=&quot;display: flex;flex-direction: column;justify-content: center;align-items: center;font-size: 16px;margin: 0px;padding: 0px;&quot;&gt;&lt;img data-src=&quot;https://mmbiz.qpic.cn/sz_mmbiz_png/oicJiaCwicKClnevzlDTmkRKcia6YHf4aLeE5ceb6NXPUBPqd6ibyicoffATlDF6pzYfaECZtjic1OBqNP9sjxFa2lVdA/640?wx_fmt=png&amp;amp;from=appmsg&amp;amp;watermark=1#imgIndex=4&quot; class=&quot;rich_pages wxw-img js_darkmode__80&quot; data-ratio=&quot;0.537962962962963&quot; data-type=&quot;png&quot; data-w=&quot;1080&quot; style=&quot;display: block; margin: 0px auto; max-width: 100%; border-style: none; border-width: 3px; border-color: rgba(0, 0, 0, 0.4); border-radius: 0px; object-fit: fill; box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px; width: 677px !important; height: auto !important; visibility: visible !important;&quot; data-backw=&quot;578&quot; data-backh=&quot;311&quot; data-imgfileid=&quot;309489951&quot; data-aistatus=&quot;1&quot; data-original-style=&quot;display:block;margin:0px auto;max-width:100%;border-style:none;border-width:3px;border-color:rgba(0, 0, 0, 0.4);border-radius:0px;object-fit:fill;box-shadow:rgba(0, 0, 0, 0) 0px 0px 0px 0px;width:100%;&quot; data-index=&quot;7&quot; src=&quot;https://mmbiz.qpic.cn/sz_mmbiz_png/oicJiaCwicKClnevzlDTmkRKcia6YHf4aLeE5ceb6NXPUBPqd6ibyicoffATlDF6pzYfaECZtjic1OBqNP9sjxFa2lVdA/640?wx_fmt=png&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1&amp;watermark=1#imgIndex=4&quot; _width=&quot;100%&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780038488544&quot; data-report-img-idx=&quot;4&quot; data-fail=&quot;0&quot;/&gt;&lt;/figure&gt;&lt;p&gt;&lt;/p&gt;&lt;h2 data-tool=&quot;mdnice编辑器&quot; style=&quot;padding: 0px;display: block;font-size: 16px;margin: 0px;text-align: left;line-height: 1.75em;&quot;&gt;&lt;span style=&quot;font-size: 16px;color: #0052FF;letter-spacing: 0em;font-weight: bold;display: block;padding: 5px 0px;&quot; class=&quot;js_darkmode__81&quot;&gt;项目源码&lt;/span&gt;&lt;/h2&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0);font-size: 16px;line-height: 1.75em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin: 0px;padding: 5px 0px;&quot; class=&quot;js_darkmode__82&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Gitee：&lt;/span&gt;https://gitee.com/allofyouenemies/EasyTemplate.Desktop.Avalonia&lt;/p&gt;&lt;h2 data-tool=&quot;mdnice编辑器&quot; style=&quot;padding: 0px;display: block;font-size: 16px;margin: 0px;text-align: left;line-height: 1.75em;&quot;&gt;&lt;span style=&quot;font-size: 16px;color: #0052FF;letter-spacing: 0em;font-weight: bold;display: block;padding: 5px 0px;&quot; class=&quot;js_darkmode__83&quot;&gt;其他组件&lt;/span&gt;&lt;/h2&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0);font-size: 16px;line-height: 1.75em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin: 0px;padding: 5px 0px;&quot; class=&quot;js_darkmode__84&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Avalonia 官方文档&lt;/span&gt;&lt;/p&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0);font-size: 16px;line-height: 1.75em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin: 0px;padding: 5px 0px;&quot; class=&quot;js_darkmode__85&quot;&gt;https://docs.avaloniaui.net/zh-Hans/docs/welcome&lt;/p&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0);font-size: 16px;line-height: 1.75em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin: 0px;padding: 5px 0px;&quot; class=&quot;js_darkmode__86&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;SukiUI 官方文档&lt;/span&gt;&lt;/p&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0);font-size: 16px;line-height: 1.75em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin: 0px;padding: 5px 0px;&quot; class=&quot;js_darkmode__87&quot;&gt;https://kikipoulet.github.io/SukiUI/documentation/controls/navigation/stackpage.html&lt;/p&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0);font-size: 16px;line-height: 1.75em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin: 0px;padding: 5px 0px;&quot; class=&quot;js_darkmode__88&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;SukiUI&lt;/span&gt;&lt;/p&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0);font-size: 16px;line-height: 1.75em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin: 0px;padding: 5px 0px;&quot; class=&quot;js_darkmode__89&quot;&gt;https://github.com/kikipoulet/SukiUI&lt;/p&gt;&lt;h2 data-tool=&quot;mdnice编辑器&quot; style=&quot;padding: 0px;display: block;font-size: 16px;margin: 0px;text-align: left;line-height: 1.75em;&quot;&gt;&lt;span style=&quot;font-size: 16px;color: #0052FF;letter-spacing: 0em;font-weight: bold;display: block;padding: 5px 0px;&quot; class=&quot;js_darkmode__90&quot;&gt;总结&lt;/span&gt;&lt;/h2&gt;&lt;p data-tool=&quot;mdnice编辑器&quot; style=&quot;color: rgb(0, 0, 0);font-size: 16px;line-height: 1.75em;letter-spacing: 0em;text-align: left;text-indent: 0em;margin: 0px;padding: 5px 0px;&quot; class=&quot;js_darkmode__91&quot;&gt;EasyTemplate.Desktop.Avalonia 作为一个开源项目，为桌面应用程序的开发提供一个良好的起点。它不仅展示了如何利用Avalonia和SukiUI构建跨平台应用，而且还集成了多种实用功能，大家可以更加专注于业务逻辑的实现。&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Fri, 29 May 2026 15:08:44 +0800</pubDate></item><item><title>Docker Desktop + WSL 2：容器开发的黄金搭档</title><link>https://www.codepub.top/post/461.html</link><description>&lt;h2 data-heading=&quot;true&quot; style=&quot;display: table;padding: 0 0.2em;margin: 4em auto 2em;color: #fff;background: #0F4C81;font-size: 19.2px;font-weight: bold;text-align: center;&quot; class=&quot;js_darkmode__text__16&quot;&gt;&lt;span class=&quot;js_darkmode__text__17&quot;&gt;为什么 WSL + Docker 是黄金组合？&lt;/span&gt;&lt;/h2&gt;&lt;h3 data-heading=&quot;true&quot; style=&quot;padding-left: 8px;border-left: 3px solid #0F4C81;margin: 2em 8px 0.75em 0;color: #3f3f3f;font-size: 17.6px;font-weight: bold;line-height: 1.2;&quot; class=&quot;js_darkmode__8 js_darkmode__text__18&quot;&gt;&lt;span class=&quot;js_darkmode__text__19&quot;&gt;传统方式 vs WSL 后端&lt;/span&gt;&lt;/h3&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__9 js_darkmode__text__20&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code data-language-pending=&quot;&quot; data-raw-code=&quot;❌ 旧版 Docker（Hyper-V 后端）：
Windows → Hyper-V 虚拟机 → Docker Engine → Containers
         ↑ 额外虚拟化层，资源开销大

✅ WSL 2 后端：
Windows → WSL 2 VM → Docker Engine → Containers
         ↑ 复用已有的 WSL VM，无需额外开销！&quot; data-show-line-number=&quot;false&quot; style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot; class=&quot;js_darkmode__text__21&quot;&gt;&lt;span class=&quot;js_darkmode__text__22&quot;&gt;❌ 旧版 Docker（Hyper-V 后端）：&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__23&quot;&gt;Windows → Hyper-V 虚拟机 → Docker Engine → Containers&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__24&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;↑ 额外虚拟化层，资源开销大&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__25&quot;&gt;✅ WSL 2 后端：&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__26&quot;&gt;Windows → WSL 2 VM → Docker Engine → Containers&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__27&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;↑ 复用已有的 WSL VM，无需额外开销！&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 data-heading=&quot;true&quot; style=&quot;padding-left: 8px;border-left: 3px solid #0F4C81;margin: 2em 8px 0.75em 0;color: #3f3f3f;font-size: 17.6px;font-weight: bold;line-height: 1.2;&quot; class=&quot;js_darkmode__10 js_darkmode__text__28&quot;&gt;&lt;span class=&quot;js_darkmode__text__29&quot;&gt;核心优势&lt;/span&gt;&lt;/h3&gt;&lt;section style=&quot;font-family: -apple-system-font,BlinkMacSystemFont, Helvetica Neue, PingFang SC, Hiragino Sans GB , Microsoft YaHei UI , Microsoft YaHei ,Arial,sans-serif;font-size: 16px;line-height: 1.75;text-align: left;max-width: 100%;overflow: auto;-webkit-overflow-scrolling: touch;&quot; class=&quot;js_darkmode__text__30&quot;&gt;&lt;table class=&quot;js_darkmode__11 js_darkmode__text__31&quot;&gt;&lt;thead class=&quot;js_darkmode__text__32&quot;&gt;&lt;tr class=&quot;js_darkmode__text__33 firstRow&quot;&gt;&lt;th align=&quot;left&quot; style=&quot;border: 1px solid #dfdfdf;padding: 0.25em 0.5em;color: #3f3f3f;word-break: keep-all;background: rgba(0, 0, 0, 0.05);text-align: left;&quot; class=&quot;js_darkmode__12 js_darkmode__text__34&quot;&gt;&lt;section class=&quot;js_darkmode__text__35&quot;&gt;&lt;span class=&quot;js_darkmode__text__36&quot;&gt;特性&lt;/span&gt;&lt;/section&gt;&lt;/th&gt;&lt;th align=&quot;left&quot; style=&quot;border: 1px solid #dfdfdf;padding: 0.25em 0.5em;color: #3f3f3f;word-break: keep-all;background: rgba(0, 0, 0, 0.05);text-align: left;&quot; class=&quot;js_darkmode__13 js_darkmode__text__37&quot;&gt;&lt;section class=&quot;js_darkmode__text__38&quot;&gt;&lt;span class=&quot;js_darkmode__text__39&quot;&gt;说明&lt;/span&gt;&lt;/section&gt;&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody class=&quot;js_darkmode__text__40&quot;&gt;&lt;tr class=&quot;js_darkmode__text__41&quot;&gt;&lt;td align=&quot;left&quot; style=&quot;border: 1px solid #dfdfdf;padding: 0.25em 0.5em;color: #3f3f3f;word-break: keep-all;text-align: left;&quot; class=&quot;js_darkmode__14 js_darkmode__text__42&quot;&gt;&lt;strong style=&quot;color: #0F4C81;font-weight: bold;font-size: inherit;&quot; class=&quot;js_darkmode__15 js_darkmode__text__43&quot;&gt;&lt;span class=&quot;js_darkmode__text__44&quot;&gt;启动速度&lt;/span&gt;&lt;/strong&gt;&lt;/td&gt;&lt;td align=&quot;left&quot; style=&quot;border: 1px solid #dfdfdf;padding: 0.25em 0.5em;color: #3f3f3f;word-break: keep-all;text-align: left;&quot; class=&quot;js_darkmode__16 js_darkmode__text__45&quot;&gt;&lt;section class=&quot;js_darkmode__text__46&quot;&gt;&lt;span class=&quot;js_darkmode__text__47&quot;&gt;利用已有 WSL 内核，秒级启动容器&lt;/span&gt;&lt;/section&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr class=&quot;js_darkmode__text__48&quot;&gt;&lt;td align=&quot;left&quot; style=&quot;border: 1px solid #dfdfdf;padding: 0.25em 0.5em;color: #3f3f3f;word-break: keep-all;text-align: left;&quot; class=&quot;js_darkmode__17 js_darkmode__text__49&quot;&gt;&lt;strong style=&quot;color: #0F4C81;font-weight: bold;font-size: inherit;&quot; class=&quot;js_darkmode__18 js_darkmode__text__50&quot;&gt;&lt;span class=&quot;js_darkmode__text__51&quot;&gt;文件系统&lt;/span&gt;&lt;/strong&gt;&lt;/td&gt;&lt;td align=&quot;left&quot; style=&quot;border: 1px solid #dfdfdf;padding: 0.25em 0.5em;color: #3f3f3f;word-break: keep-all;text-align: left;&quot; class=&quot;js_darkmode__19 js_darkmode__text__52&quot;&gt;&lt;section class=&quot;js_darkmode__text__53&quot;&gt;&lt;span class=&quot;js_darkmode__text__54&quot;&gt;容器直接使用 ext4，I/O 性能极佳&lt;/span&gt;&lt;/section&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr class=&quot;js_darkmode__text__55&quot;&gt;&lt;td align=&quot;left&quot; style=&quot;border: 1px solid #dfdfdf;padding: 0.25em 0.5em;color: #3f3f3f;word-break: keep-all;text-align: left;&quot; class=&quot;js_darkmode__20 js_darkmode__text__56&quot;&gt;&lt;strong style=&quot;color: #0F4C81;font-weight: bold;font-size: inherit;&quot; class=&quot;js_darkmode__21 js_darkmode__text__57&quot;&gt;&lt;span class=&quot;js_darkmode__text__58&quot;&gt;网络集成&lt;/span&gt;&lt;/strong&gt;&lt;/td&gt;&lt;td align=&quot;left&quot; style=&quot;border: 1px solid #dfdfdf;padding: 0.25em 0.5em;color: #3f3f3f;word-break: keep-all;text-align: left;&quot; class=&quot;js_darkmode__22 js_darkmode__text__59&quot;&gt;&lt;section class=&quot;js_darkmode__text__60&quot;&gt;&lt;span class=&quot;js_darkmode__text__61&quot;&gt;localhost 直接访问容器端口&lt;/span&gt;&lt;/section&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr class=&quot;js_darkmode__text__62&quot;&gt;&lt;td align=&quot;left&quot; style=&quot;border: 1px solid #dfdfdf;padding: 0.25em 0.5em;color: #3f3f3f;word-break: keep-all;text-align: left;&quot; class=&quot;js_darkmode__23 js_darkmode__text__63&quot;&gt;&lt;strong style=&quot;color: #0F4C81;font-weight: bold;font-size: inherit;&quot; class=&quot;js_darkmode__24 js_darkmode__text__64&quot;&gt;&lt;span class=&quot;js_darkmode__text__65&quot;&gt;开发体验&lt;/span&gt;&lt;/strong&gt;&lt;/td&gt;&lt;td align=&quot;left&quot; style=&quot;border: 1px solid #dfdfdf;padding: 0.25em 0.5em;color: #3f3f3f;word-break: keep-all;text-align: left;&quot; class=&quot;js_darkmode__25 js_darkmode__text__66&quot;&gt;&lt;section class=&quot;js_darkmode__text__67&quot;&gt;&lt;span class=&quot;js_darkmode__text__68&quot;&gt;VS Code Remote + Docker 扩展完美配合&lt;/span&gt;&lt;/section&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr class=&quot;js_darkmode__text__69&quot;&gt;&lt;td align=&quot;left&quot; style=&quot;border: 1px solid #dfdfdf;padding: 0.25em 0.5em;color: #3f3f3f;word-break: keep-all;text-align: left;&quot; class=&quot;js_darkmode__26 js_darkmode__text__70&quot;&gt;&lt;strong style=&quot;color: #0F4C81;font-weight: bold;font-size: inherit;&quot; class=&quot;js_darkmode__27 js_darkmode__text__71&quot;&gt;&lt;span class=&quot;js_darkmode__text__72&quot;&gt;一致性&lt;/span&gt;&lt;/strong&gt;&lt;/td&gt;&lt;td align=&quot;left&quot; style=&quot;border: 1px solid #dfdfdf;padding: 0.25em 0.5em;color: #3f3f3f;word-break: keep-all;text-align: left;&quot; class=&quot;js_darkmode__28 js_darkmode__text__73&quot;&gt;&lt;section class=&quot;js_darkmode__text__74&quot;&gt;&lt;span class=&quot;js_darkmode__text__75&quot;&gt;开发环境 ≈ 生产环境（都是 Linux）&lt;/span&gt;&lt;/section&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/section&gt;&lt;hr style=&quot;border-style: solid;border-width: 2px 0 0;border-color: rgba(0, 0, 0, 0.1);-webkit-transform-origin: 0 0;-webkit-transform: scale(1, 0.5);transform-origin: 0 0;transform: scale(1, 0.5);height: 0.4em;margin: 1.5em 0;&quot; class=&quot;js_darkmode__29&quot;/&gt;&lt;h2 data-heading=&quot;true&quot; style=&quot;display: table;padding: 0 0.2em;margin: 4em auto 2em;color: #fff;background: #0F4C81;font-size: 19.2px;font-weight: bold;text-align: center;&quot; class=&quot;js_darkmode__text__76&quot;&gt;&lt;span class=&quot;js_darkmode__text__77&quot;&gt;安装与配置&lt;/span&gt;&lt;/h2&gt;&lt;h3 data-heading=&quot;true&quot; style=&quot;padding-left: 8px;border-left: 3px solid #0F4C81;margin: 2em 8px 0.75em 0;color: #3f3f3f;font-size: 17.6px;font-weight: bold;line-height: 1.2;&quot; class=&quot;js_darkmode__30 js_darkmode__text__78&quot;&gt;&lt;span class=&quot;js_darkmode__text__79&quot;&gt;Step 1：下载安装 Docker Desktop&lt;/span&gt;&lt;/h3&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__31 js_darkmode__text__80&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot; class=&quot;js_darkmode__text__81&quot;&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__82&quot;&gt;&lt;span class=&quot;js_darkmode__text__83&quot;&gt;# 方法一：官网下载&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__84&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__85&quot;&gt;# 访问 https://www.docker.com/products/docker-desktop/&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__86&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__87&quot;&gt;# 下载 Windows 版安装包&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__88&quot;&gt;&lt;br/&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__89&quot;&gt;# 方法二：winget 安装&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__90&quot;&gt;winget install Docker.DockerDesktop&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__91&quot;&gt;&lt;br/&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__92&quot;&gt;# 安装过程：一路 Next 即可（免费注册 Docker 账号可选）&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 data-heading=&quot;true&quot; style=&quot;padding-left: 8px;border-left: 3px solid #0F4C81;margin: 2em 8px 0.75em 0;color: #3f3f3f;font-size: 17.6px;font-weight: bold;line-height: 1.2;&quot; class=&quot;js_darkmode__32 js_darkmode__text__93&quot;&gt;&lt;span class=&quot;js_darkmode__text__94&quot;&gt;Step 2：设置 WSL 2 后端&lt;/span&gt;&lt;/h3&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__33 js_darkmode__text__95&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code data-language-pending=&quot;&quot; data-raw-code=&quot;1. 启动 Docker Desktop
2. 点击右上角 ⚙️ 设置图标
3. General 选项卡：
   ☑️ Use the WSL 2 based engine    ← 关键！
4. Resources → WSL Integration：
   ☑️ Enable integration with my default WSL distro
   ☑️ Ubuntu-24.04                  ← 勾选你的发行版
5. Apply &amp;amp; Restart&quot; data-show-line-number=&quot;false&quot; style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot; class=&quot;js_darkmode__text__96&quot;&gt;&lt;span class=&quot;js_darkmode__text__97&quot;&gt;1. 启动 Docker Desktop&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__98&quot;&gt;2. 点击右上角 ⚙️ 设置图标&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__99&quot;&gt;3. General 选项卡：&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__100&quot;&gt;&amp;nbsp; &amp;nbsp;☑️ Use the WSL 2 based engine &amp;nbsp; &amp;nbsp;← 关键！&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__101&quot;&gt;4. Resources → WSL Integration：&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__102&quot;&gt;&amp;nbsp; &amp;nbsp;☑️ Enable integration with my default WSL distro&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__103&quot;&gt;&amp;nbsp; &amp;nbsp;☑️ Ubuntu-24.04 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;← 勾选你的发行版&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__104&quot;&gt;5. Apply &amp;amp; Restart&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 data-heading=&quot;true&quot; style=&quot;padding-left: 8px;border-left: 3px solid #0F4C81;margin: 2em 8px 0.75em 0;color: #3f3f3f;font-size: 17.6px;font-weight: bold;line-height: 1.2;&quot; class=&quot;js_darkmode__34 js_darkmode__text__105&quot;&gt;&lt;span class=&quot;js_darkmode__text__106&quot;&gt;Step 3：验证安装&lt;/span&gt;&lt;/h3&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__35 js_darkmode__text__107&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot; class=&quot;js_darkmode__text__108&quot;&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__109&quot;&gt;&lt;span class=&quot;js_darkmode__text__110&quot;&gt;# 在 WSL 终端中验证&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__111&quot;&gt;docker --version&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__112&quot;&gt;&lt;span class=&quot;js_darkmode__text__113&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; # Docker 引擎版本&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__114&quot;&gt;docker compose version&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__115&quot;&gt;&lt;span class=&quot;js_darkmode__text__116&quot;&gt;&amp;nbsp; # Compose 插件版本&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__117&quot;&gt;&lt;br/&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__118&quot;&gt;# 运行测试容器&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__119&quot;&gt;docker run hello-world&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__120&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__121&quot;&gt;# 输出 &amp;quot;Hello from Docker!&amp;quot; 表示成功 ✅&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__36 js_darkmode__text__122&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code data-language-pending=&quot;&quot; data-raw-code=&quot;验证检查清单：
✅ docker --version 有输出
✅ docker run hello-world 成功
✅ 在 WSL 中可以直接执行 docker 命令
✅ VS Code Docker 扩展可以连接&quot; data-show-line-number=&quot;false&quot; style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot; class=&quot;js_darkmode__text__123&quot;&gt;&lt;span class=&quot;js_darkmode__text__124&quot;&gt;验证检查清单：&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__125&quot;&gt;✅ docker --version 有输出&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__126&quot;&gt;✅ docker run hello-world 成功&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__127&quot;&gt;✅ 在 WSL 中可以直接执行 docker 命令&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__128&quot;&gt;✅ VS Code Docker 扩展可以连接&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;hr style=&quot;border-style: solid;border-width: 2px 0 0;border-color: rgba(0, 0, 0, 0.1);-webkit-transform-origin: 0 0;-webkit-transform: scale(1, 0.5);transform-origin: 0 0;transform: scale(1, 0.5);height: 0.4em;margin: 1.5em 0;&quot; class=&quot;js_darkmode__37&quot;/&gt;&lt;h2 data-heading=&quot;true&quot; style=&quot;display: table;padding: 0 0.2em;margin: 4em auto 2em;color: #fff;background: #0F4C81;font-size: 19.2px;font-weight: bold;text-align: center;&quot; class=&quot;js_darkmode__text__129&quot;&gt;&lt;span class=&quot;js_darkmode__text__130&quot;&gt;Docker 基础命令速查&lt;/span&gt;&lt;/h2&gt;&lt;h3 data-heading=&quot;true&quot; style=&quot;padding-left: 8px;border-left: 3px solid #0F4C81;margin: 2em 8px 0.75em 0;color: #3f3f3f;font-size: 17.6px;font-weight: bold;line-height: 1.2;&quot; class=&quot;js_darkmode__38 js_darkmode__text__131&quot;&gt;&lt;span class=&quot;js_darkmode__text__132&quot;&gt;镜像操作&lt;/span&gt;&lt;/h3&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__39 js_darkmode__text__133&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot; class=&quot;js_darkmode__text__134&quot;&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__135&quot;&gt;&lt;span class=&quot;js_darkmode__text__136&quot;&gt;# 搜索镜像&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__137&quot;&gt;docker search nginx&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__138&quot;&gt;&lt;br/&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__139&quot;&gt;# 拉取镜像&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__140&quot;&gt;docker pull ubuntu:24.04&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__141&quot;&gt;docker pull python:3.12-slim&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__142&quot;&gt;docker pull node:20-alpine&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__143&quot;&gt;&lt;br/&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__144&quot;&gt;# 查看本地镜像&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__145&quot;&gt;docker images&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__146&quot;&gt;docker image&lt;/span&gt;&lt;span style=&quot;color: #ffa657;&quot; class=&quot;js_darkmode__text__147&quot;&gt;&lt;span class=&quot;js_darkmode__text__148&quot;&gt;&amp;nbsp;ls&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__149&quot;&gt;&lt;br/&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__150&quot;&gt;# 删除镜像&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__151&quot;&gt;docker rmi &amp;lt;image_id&amp;gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__152&quot;&gt;docker rmi $(docker images -q -f&lt;/span&gt;&lt;span style=&quot;color: #a5d6ff;&quot; class=&quot;js_darkmode__text__153&quot;&gt;&lt;span class=&quot;js_darkmode__text__154&quot;&gt;&amp;nbsp;&amp;quot;dangling=true&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;js_darkmode__text__155&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__156&quot;&gt;&lt;span class=&quot;js_darkmode__text__157&quot;&gt;&amp;nbsp; &amp;nbsp;# 清理悬空镜像&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 data-heading=&quot;true&quot; style=&quot;padding-left: 8px;border-left: 3px solid #0F4C81;margin: 2em 8px 0.75em 0;color: #3f3f3f;font-size: 17.6px;font-weight: bold;line-height: 1.2;&quot; class=&quot;js_darkmode__40 js_darkmode__text__158&quot;&gt;&lt;span class=&quot;js_darkmode__text__159&quot;&gt;容器操作&lt;/span&gt;&lt;/h3&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__41 js_darkmode__text__160&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot; class=&quot;js_darkmode__text__161&quot;&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__162&quot;&gt;&lt;span class=&quot;js_darkmode__text__163&quot;&gt;# 运行容器（交互模式）&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__164&quot;&gt;docker run -it ubuntu:24.04 /bin/bash&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__165&quot;&gt;&lt;br/&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__166&quot;&gt;# 运行并映射端口&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__167&quot;&gt;docker run -d -p 8080:80 nginx&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__168&quot;&gt;&lt;br/&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__169&quot;&gt;# 运行并挂载卷（数据持久化）&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__170&quot;&gt;docker run -v $(&lt;/span&gt;&lt;span style=&quot;color: #ffa657;&quot; class=&quot;js_darkmode__text__171&quot;&gt;&lt;span class=&quot;js_darkmode__text__172&quot;&gt;pwd&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;js_darkmode__text__173&quot;&gt;):/app -w /app python:3.12-slim python app.py&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__174&quot;&gt;&lt;br/&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__175&quot;&gt;# 查看运行中的容器&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__176&quot;&gt;docker ps&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__177&quot;&gt;docker ps -a&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__178&quot;&gt;&lt;span class=&quot;js_darkmode__text__179&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # 包含已停止的&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__180&quot;&gt;&lt;br/&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__181&quot;&gt;# 进入正在运行的容器&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__182&quot;&gt;docker&lt;/span&gt;&lt;span style=&quot;color: #ffa657;&quot; class=&quot;js_darkmode__text__183&quot;&gt;&lt;span class=&quot;js_darkmode__text__184&quot;&gt;&amp;nbsp;exec&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;js_darkmode__text__185&quot;&gt;&amp;nbsp;-it &amp;lt;container_id&amp;gt; bash&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__186&quot;&gt;&lt;br/&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__187&quot;&gt;# 查看日志&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__188&quot;&gt;docker logs &amp;lt;container_id&amp;gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__189&quot;&gt;docker logs -f &amp;lt;container_id&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__190&quot;&gt;&lt;span class=&quot;js_darkmode__text__191&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;# 实时跟踪日志&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__192&quot;&gt;&lt;br/&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__193&quot;&gt;# 停止/启动/删除容器&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__194&quot;&gt;docker stop &amp;lt;container_id&amp;gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__195&quot;&gt;docker start &amp;lt;container_id&amp;gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__196&quot;&gt;docker&lt;/span&gt;&lt;span style=&quot;color: #ffa657;&quot; class=&quot;js_darkmode__text__197&quot;&gt;&lt;span class=&quot;js_darkmode__text__198&quot;&gt;&amp;nbsp;rm&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;js_darkmode__text__199&quot;&gt;&amp;nbsp;&amp;lt;container_id&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__200&quot;&gt;&lt;br/&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__201&quot;&gt;# 一键清理（释放磁盘空间）&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__202&quot;&gt;docker system prune -a&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__203&quot;&gt;&lt;span class=&quot;js_darkmode__text__204&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;# ⚠️ 会删除所有未使用的容器和镜像&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;hr style=&quot;border-style: solid;border-width: 2px 0 0;border-color: rgba(0, 0, 0, 0.1);-webkit-transform-origin: 0 0;-webkit-transform: scale(1, 0.5);transform-origin: 0 0;transform: scale(1, 0.5);height: 0.4em;margin: 1.5em 0;&quot; class=&quot;js_darkmode__42&quot;/&gt;&lt;h2 data-heading=&quot;true&quot; style=&quot;display: table;padding: 0 0.2em;margin: 4em auto 2em;color: #fff;background: #0F4C81;font-size: 19.2px;font-weight: bold;text-align: center;&quot; class=&quot;js_darkmode__text__205&quot;&gt;&lt;span class=&quot;js_darkmode__text__206&quot;&gt;Docker Compose 编排实战&lt;/span&gt;&lt;/h2&gt;&lt;h3 data-heading=&quot;true&quot; style=&quot;padding-left: 8px;border-left: 3px solid #0F4C81;margin: 2em 8px 0.75em 0;color: #3f3f3f;font-size: 17.6px;font-weight: bold;line-height: 1.2;&quot; class=&quot;js_darkmode__43 js_darkmode__text__207&quot;&gt;&lt;span class=&quot;js_darkmode__text__208&quot;&gt;场景：全栈 Web 应用&lt;/span&gt;&lt;/h3&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__44 js_darkmode__text__209&quot;&gt;&lt;span class=&quot;js_darkmode__text__210&quot;&gt;创建一个包含前后端、数据库、缓存的完整项目：&lt;/span&gt;&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__45 js_darkmode__text__211&quot;&gt;mkdir&amp;nbsp;-p&amp;nbsp;~/projects/docker-demo&amp;nbsp;&amp;amp;&amp;amp;&amp;nbsp;cd&amp;nbsp;~/projects/docker-demo&lt;/pre&gt;&lt;h4 data-heading=&quot;true&quot; style=&quot;margin: 2em 8px 0.5em;color: #0F4C81;font-size: 16px;font-weight: bold;&quot; class=&quot;js_darkmode__46 js_darkmode__text__219&quot;&gt;&lt;span class=&quot;js_darkmode__text__220&quot;&gt;docker-compose.yml&lt;/span&gt;&lt;/h4&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__47 js_darkmode__text__221&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot; class=&quot;js_darkmode__text__222&quot;&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__223&quot;&gt;&lt;span class=&quot;js_darkmode__text__224&quot;&gt;services:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__225&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__226&quot;&gt;&amp;nbsp; # 前端&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__227&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__228&quot;&gt;&amp;nbsp; frontend:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__229&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__230&quot;&gt;&amp;nbsp; &amp;nbsp; build:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__231&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__232&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; context:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a5d6ff;&quot; class=&quot;js_darkmode__text__233&quot;&gt;&lt;span class=&quot;js_darkmode__text__234&quot;&gt;&amp;nbsp;./frontend&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__235&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__236&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; dockerfile:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a5d6ff;&quot; class=&quot;js_darkmode__text__237&quot;&gt;&lt;span class=&quot;js_darkmode__text__238&quot;&gt;&amp;nbsp;Dockerfile&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__239&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__240&quot;&gt;&amp;nbsp; &amp;nbsp; ports:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #f2cc60;&quot; class=&quot;js_darkmode__text__241&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__242&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; -&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a5d6ff;&quot; class=&quot;js_darkmode__text__243&quot;&gt;&lt;span class=&quot;js_darkmode__text__244&quot;&gt;&amp;nbsp;&amp;quot;3000:80&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__245&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__246&quot;&gt;&amp;nbsp; &amp;nbsp; depends_on:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #f2cc60;&quot; class=&quot;js_darkmode__text__247&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__248&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; -&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a5d6ff;&quot; class=&quot;js_darkmode__text__249&quot;&gt;&lt;span class=&quot;js_darkmode__text__250&quot;&gt;&amp;nbsp;backend&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__251&quot;&gt;&lt;br/&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__252&quot;&gt;&amp;nbsp; # 后端 API&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__253&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__254&quot;&gt;&amp;nbsp; backend:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__255&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__256&quot;&gt;&amp;nbsp; &amp;nbsp; build:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__257&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__258&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; context:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a5d6ff;&quot; class=&quot;js_darkmode__text__259&quot;&gt;&lt;span class=&quot;js_darkmode__text__260&quot;&gt;&amp;nbsp;./backend&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__261&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__262&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; dockerfile:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a5d6ff;&quot; class=&quot;js_darkmode__text__263&quot;&gt;&lt;span class=&quot;js_darkmode__text__264&quot;&gt;&amp;nbsp;Dockerfile&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__265&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__266&quot;&gt;&amp;nbsp; &amp;nbsp; ports:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #f2cc60;&quot; class=&quot;js_darkmode__text__267&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__268&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; -&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a5d6ff;&quot; class=&quot;js_darkmode__text__269&quot;&gt;&lt;span class=&quot;js_darkmode__text__270&quot;&gt;&amp;nbsp;&amp;quot;8000:8000&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__271&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__272&quot;&gt;&amp;nbsp; &amp;nbsp; environment:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #f2cc60;&quot; class=&quot;js_darkmode__text__273&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__274&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; -&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a5d6ff;&quot; class=&quot;js_darkmode__text__275&quot;&gt;&lt;span class=&quot;js_darkmode__text__276&quot;&gt;&amp;nbsp;DATABASE_URL=postgresql://dev:dev@db:5432/appdb&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #f2cc60;&quot; class=&quot;js_darkmode__text__277&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__278&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; -&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a5d6ff;&quot; class=&quot;js_darkmode__text__279&quot;&gt;&lt;span class=&quot;js_darkmode__text__280&quot;&gt;&amp;nbsp;REDIS_URL=redis://redis:6379&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__281&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__282&quot;&gt;&amp;nbsp; &amp;nbsp; volumes:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #f2cc60;&quot; class=&quot;js_darkmode__text__283&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__284&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; -&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a5d6ff;&quot; class=&quot;js_darkmode__text__285&quot;&gt;&lt;span class=&quot;js_darkmode__text__286&quot;&gt;&amp;nbsp;./backend:/app&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__287&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__288&quot;&gt;&amp;nbsp; &amp;nbsp; depends_on:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #f2cc60;&quot; class=&quot;js_darkmode__text__289&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__290&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; -&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a5d6ff;&quot; class=&quot;js_darkmode__text__291&quot;&gt;&lt;span class=&quot;js_darkmode__text__292&quot;&gt;&amp;nbsp;db&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #f2cc60;&quot; class=&quot;js_darkmode__text__293&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__294&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; -&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a5d6ff;&quot; class=&quot;js_darkmode__text__295&quot;&gt;&lt;span class=&quot;js_darkmode__text__296&quot;&gt;&amp;nbsp;redis&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__297&quot;&gt;&lt;br/&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__298&quot;&gt;&amp;nbsp; # PostgreSQL 数据库&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__299&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__300&quot;&gt;&amp;nbsp; db:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__301&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__302&quot;&gt;&amp;nbsp; &amp;nbsp; image:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a5d6ff;&quot; class=&quot;js_darkmode__text__303&quot;&gt;&lt;span class=&quot;js_darkmode__text__304&quot;&gt;&amp;nbsp;postgres:16-alpine&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__305&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__306&quot;&gt;&amp;nbsp; &amp;nbsp; environment:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__307&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__308&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; POSTGRES_USER:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a5d6ff;&quot; class=&quot;js_darkmode__text__309&quot;&gt;&lt;span class=&quot;js_darkmode__text__310&quot;&gt;&amp;nbsp;dev&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__311&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__312&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; POSTGRES_PASSWORD:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a5d6ff;&quot; class=&quot;js_darkmode__text__313&quot;&gt;&lt;span class=&quot;js_darkmode__text__314&quot;&gt;&amp;nbsp;dev&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__315&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__316&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; POSTGRES_DB:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a5d6ff;&quot; class=&quot;js_darkmode__text__317&quot;&gt;&lt;span class=&quot;js_darkmode__text__318&quot;&gt;&amp;nbsp;appdb&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__319&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__320&quot;&gt;&amp;nbsp; &amp;nbsp; volumes:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #f2cc60;&quot; class=&quot;js_darkmode__text__321&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__322&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; -&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a5d6ff;&quot; class=&quot;js_darkmode__text__323&quot;&gt;&lt;span class=&quot;js_darkmode__text__324&quot;&gt;&amp;nbsp;pgdata:/var/lib/postgresql/data&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__325&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__326&quot;&gt;&amp;nbsp; &amp;nbsp; ports:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #f2cc60;&quot; class=&quot;js_darkmode__text__327&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__328&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; -&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a5d6ff;&quot; class=&quot;js_darkmode__text__329&quot;&gt;&lt;span class=&quot;js_darkmode__text__330&quot;&gt;&amp;nbsp;&amp;quot;5432:5432&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__331&quot;&gt;&lt;br/&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__332&quot;&gt;&amp;nbsp; # Redis 缓存&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__333&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__334&quot;&gt;&amp;nbsp; redis:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__335&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__336&quot;&gt;&amp;nbsp; &amp;nbsp; image:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a5d6ff;&quot; class=&quot;js_darkmode__text__337&quot;&gt;&lt;span class=&quot;js_darkmode__text__338&quot;&gt;&amp;nbsp;redis:7-alpine&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__339&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__340&quot;&gt;&amp;nbsp; &amp;nbsp; ports:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #f2cc60;&quot; class=&quot;js_darkmode__text__341&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__342&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; -&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a5d6ff;&quot; class=&quot;js_darkmode__text__343&quot;&gt;&lt;span class=&quot;js_darkmode__text__344&quot;&gt;&amp;nbsp;&amp;quot;6379:6379&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__345&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__346&quot;&gt;&amp;nbsp; &amp;nbsp; volumes:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #f2cc60;&quot; class=&quot;js_darkmode__text__347&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__348&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; -&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a5d6ff;&quot; class=&quot;js_darkmode__text__349&quot;&gt;&lt;span class=&quot;js_darkmode__text__350&quot;&gt;&amp;nbsp;redisdata:/data&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__351&quot;&gt;&lt;br/&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__352&quot;&gt;&amp;nbsp; # Nginx 反向代理&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__353&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__354&quot;&gt;&amp;nbsp; nginx:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__355&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__356&quot;&gt;&amp;nbsp; &amp;nbsp; image:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a5d6ff;&quot; class=&quot;js_darkmode__text__357&quot;&gt;&lt;span class=&quot;js_darkmode__text__358&quot;&gt;&amp;nbsp;nginx:alpine&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__359&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__360&quot;&gt;&amp;nbsp; &amp;nbsp; ports:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #f2cc60;&quot; class=&quot;js_darkmode__text__361&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__362&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; -&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a5d6ff;&quot; class=&quot;js_darkmode__text__363&quot;&gt;&lt;span class=&quot;js_darkmode__text__364&quot;&gt;&amp;nbsp;&amp;quot;80:80&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__365&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__366&quot;&gt;&amp;nbsp; &amp;nbsp; volumes:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #f2cc60;&quot; class=&quot;js_darkmode__text__367&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__368&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; -&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a5d6ff;&quot; class=&quot;js_darkmode__text__369&quot;&gt;&lt;span class=&quot;js_darkmode__text__370&quot;&gt;&amp;nbsp;./nginx.conf:/etc/nginx/conf.d/default.conf&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__371&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__372&quot;&gt;&amp;nbsp; &amp;nbsp; depends_on:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #f2cc60;&quot; class=&quot;js_darkmode__text__373&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__374&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; -&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a5d6ff;&quot; class=&quot;js_darkmode__text__375&quot;&gt;&lt;span class=&quot;js_darkmode__text__376&quot;&gt;&amp;nbsp;frontend&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #f2cc60;&quot; class=&quot;js_darkmode__text__377&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__378&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; -&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a5d6ff;&quot; class=&quot;js_darkmode__text__379&quot;&gt;&lt;span class=&quot;js_darkmode__text__380&quot;&gt;&amp;nbsp;backend&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__381&quot;&gt;&lt;br/&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__382&quot;&gt;volumes:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__383&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__384&quot;&gt;&amp;nbsp; pgdata:&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__385&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__386&quot;&gt;&amp;nbsp; redisdata:&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h4 data-heading=&quot;true&quot; style=&quot;margin: 2em 8px 0.5em;color: #0F4C81;font-size: 16px;font-weight: bold;&quot; class=&quot;js_darkmode__48 js_darkmode__text__387&quot;&gt;&lt;span class=&quot;js_darkmode__text__388&quot;&gt;一键启动全部服务&lt;/span&gt;&lt;/h4&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__49 js_darkmode__text__389&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot; class=&quot;js_darkmode__text__390&quot;&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__391&quot;&gt;&lt;span class=&quot;js_darkmode__text__392&quot;&gt;# 构建并启动所有服务&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__393&quot;&gt;docker compose up -d --build&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__394&quot;&gt;&lt;br/&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__395&quot;&gt;# 查看各服务状态&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__396&quot;&gt;docker compose ps&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__397&quot;&gt;&lt;br/&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__398&quot;&gt;# 输出示例：&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__399&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__400&quot;&gt;# NAME &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;STATUS &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;PORTS&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__401&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__402&quot;&gt;# docker-demo-backend-1 &amp;nbsp; &amp;nbsp;Up &amp;nbsp; &amp;nbsp;0.0.0.0:8000-&amp;gt;8000/tcp&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__403&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__404&quot;&gt;# docker-demo-db-1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Up &amp;nbsp; &amp;nbsp;0.0.0.0:5432-&amp;gt;5432/tcp&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__405&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__406&quot;&gt;# docker-demo-frontend-1 &amp;nbsp; &amp;nbsp;Up &amp;nbsp; &amp;nbsp;0.0.0.0:3000-&amp;gt;80/tcp&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__407&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__408&quot;&gt;# docker-demo-nginx-1 &amp;nbsp; &amp;nbsp; &amp;nbsp; Up &amp;nbsp; &amp;nbsp;0.0.0.0:80-&amp;gt;80/tcp&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__409&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__410&quot;&gt;# docker-demo-redis-1 &amp;nbsp; &amp;nbsp; &amp;nbsp; Up &amp;nbsp; &amp;nbsp;0.0.0.0:6379-&amp;gt;6379/tcp&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__411&quot;&gt;&lt;br/&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__412&quot;&gt;# 查看某服务的日志&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__413&quot;&gt;docker compose logs -f backend&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__414&quot;&gt;&lt;br/&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__415&quot;&gt;# 重启单个服务&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__416&quot;&gt;docker compose restart backend&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__417&quot;&gt;&lt;br/&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__418&quot;&gt;# 停止所有服务&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__419&quot;&gt;docker compose down&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__420&quot;&gt;&lt;br/&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__421&quot;&gt;# 停止并删除数据卷（完全清理）&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__422&quot;&gt;docker compose down -v&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;hr style=&quot;border-style: solid;border-width: 2px 0 0;border-color: rgba(0, 0, 0, 0.1);-webkit-transform-origin: 0 0;-webkit-transform: scale(1, 0.5);transform-origin: 0 0;transform: scale(1, 0.5);height: 0.4em;margin: 1.5em 0;&quot; class=&quot;js_darkmode__50&quot;/&gt;&lt;h2 data-heading=&quot;true&quot; style=&quot;display: table;padding: 0 0.2em;margin: 4em auto 2em;color: #fff;background: #0F4C81;font-size: 19.2px;font-weight: bold;text-align: center;&quot; class=&quot;js_darkmode__text__423&quot;&gt;&lt;span class=&quot;js_darkmode__text__424&quot;&gt;镜像加速配置（国内用户）&lt;/span&gt;&lt;/h2&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__51 js_darkmode__text__425&quot;&gt;&lt;span class=&quot;js_darkmode__text__426&quot;&gt;编辑或创建 Docker 配置文件：&lt;/span&gt;&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__52 js_darkmode__text__427&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot; class=&quot;js_darkmode__text__428&quot;&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__429&quot;&gt;&lt;span class=&quot;js_darkmode__text__430&quot;&gt;// ~/.docker/daemon.json&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__431&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__432&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__433&quot;&gt;&amp;nbsp; &amp;quot;registry-mirrors&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;js_darkmode__text__434&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;js_darkmode__text__435&quot;&gt;&amp;nbsp;[&lt;/span&gt;&lt;span style=&quot;color: #a5d6ff;&quot; class=&quot;js_darkmode__text__436&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__437&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;quot;https://docker.1ms.run&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;js_darkmode__text__438&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #a5d6ff;&quot; class=&quot;js_darkmode__text__439&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__440&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;quot;https://docker.xuanyuan.me&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__441&quot;&gt;&amp;nbsp; ]&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__442&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;blockquote style=&quot;font-style: normal;padding: 1em;border-left: 4px solid #0F4C81;border-radius: 6px;color: #3f3f3f;background: #f7f7f7;margin-bottom: 1em;&quot; class=&quot;js_darkmode__53 js_darkmode__text__443&quot;&gt;&lt;p style=&quot;display: block;font-size: 1em;letter-spacing: 0.1em;color: #3f3f3f;margin: 0;&quot; class=&quot;js_darkmode__54 js_darkmode__text__444&quot;&gt;&lt;span class=&quot;js_darkmode__text__445&quot;&gt;💡 国内 Docker Hub 访问慢或不稳定，配了镜像加速后拉取速度从几 KB/s 飙升到几 MB/s。&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__55 js_darkmode__text__446&quot;&gt;&lt;span class=&quot;js_darkmode__text__447&quot;&gt;配置后重启 Docker Desktop 生效。&lt;/span&gt;&lt;/p&gt;&lt;h2 data-heading=&quot;true&quot; style=&quot;display: table;padding: 0 0.2em;margin: 4em auto 2em;color: #fff;background: #0F4C81;font-size: 19.2px;font-weight: bold;text-align: center;&quot; class=&quot;js_darkmode__text__448&quot;&gt;&lt;span class=&quot;js_darkmode__text__449&quot;&gt;资源限制与优化&lt;/span&gt;&lt;/h2&gt;&lt;h3 data-heading=&quot;true&quot; style=&quot;padding-left: 8px;border-left: 3px solid #0F4C81;margin: 2em 8px 0.75em 0;color: #3f3f3f;font-size: 17.6px;font-weight: bold;line-height: 1.2;&quot; class=&quot;js_darkmode__57 js_darkmode__text__450&quot;&gt;&lt;span class=&quot;js_darkmode__text__451&quot;&gt;.wslconfig 中控制 Docker 资源&lt;/span&gt;&lt;/h3&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__58 js_darkmode__text__452&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot; class=&quot;js_darkmode__text__453&quot;&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__454&quot;&gt;&lt;span class=&quot;js_darkmode__text__455&quot;&gt;# C:\Users\&amp;lt;你&amp;gt;\.wslconfig&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #1f6feb;font-weight: 700;&quot; class=&quot;js_darkmode__59 js_darkmode__text__456&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__457&quot;&gt;[wsl2]&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__458&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__459&quot;&gt;memory&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;js_darkmode__text__460&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__461&quot;&gt;&lt;span class=&quot;js_darkmode__text__462&quot;&gt;8&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;js_darkmode__text__463&quot;&gt;GB&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__464&quot;&gt;&lt;span class=&quot;js_darkmode__text__465&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;# 给 WSL/Docker 足够内存&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__466&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__467&quot;&gt;processors&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;js_darkmode__text__468&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__469&quot;&gt;&lt;span class=&quot;js_darkmode__text__470&quot;&gt;6&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__471&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__472&quot;&gt;swap&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;js_darkmode__text__473&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__474&quot;&gt;&lt;span class=&quot;js_darkmode__text__475&quot;&gt;4&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;js_darkmode__text__476&quot;&gt;GB&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__477&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__478&quot;&gt;vmIdleTimeout&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;js_darkmode__text__479&quot;&gt;=-&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__480&quot;&gt;&lt;span class=&quot;js_darkmode__text__481&quot;&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 data-heading=&quot;true&quot; style=&quot;padding-left: 8px;border-left: 3px solid #0F4C81;margin: 2em 8px 0.75em 0;color: #3f3f3f;font-size: 17.6px;font-weight: bold;line-height: 1.2;&quot; class=&quot;js_darkmode__60 js_darkmode__text__482&quot;&gt;&lt;span class=&quot;js_darkmode__text__483&quot;&gt;Docker Desktop 自身设置&lt;/span&gt;&lt;/h3&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__61 js_darkmode__text__484&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code data-language-pending=&quot;&quot; data-raw-code=&quot;Docker Desktop → Settings → Resources:

Advanced:
├── CPUs: 4                    （留给 Windows 2-4 核）
├── Memory: 4 GB               （WSL 总内存的一部分）
└── Disk image size: 60 GB     （根据需要调整）

Resource Control:
☑️ Enable resource saver mode   （空闲时自动降低占用）&quot; data-show-line-number=&quot;false&quot; style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot; class=&quot;js_darkmode__text__485&quot;&gt;&lt;span class=&quot;js_darkmode__text__486&quot;&gt;Docker Desktop → Settings → Resources:&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__487&quot;&gt;Advanced:&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__488&quot;&gt;├── CPUs: 4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;（留给 Windows 2-4 核）&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__489&quot;&gt;├── Memory: 4 GB &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; （WSL 总内存的一部分）&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__490&quot;&gt;└── Disk image size: 60 GB &amp;nbsp; &amp;nbsp; （根据需要调整）&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__491&quot;&gt;Resource Control:&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__492&quot;&gt;☑️ Enable resource saver mode &amp;nbsp; （空闲时自动降低占用）&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 data-heading=&quot;true&quot; style=&quot;padding-left: 8px;border-left: 3px solid #0F4C81;margin: 2em 8px 0.75em 0;color: #3f3f3f;font-size: 17.6px;font-weight: bold;line-height: 1.2;&quot; class=&quot;js_darkmode__62 js_darkmode__text__493&quot;&gt;&lt;span class=&quot;js_darkmode__text__494&quot;&gt;磁盘空间清理&lt;/span&gt;&lt;/h3&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__63 js_darkmode__text__495&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot; class=&quot;js_darkmode__text__496&quot;&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__497&quot;&gt;&lt;span class=&quot;js_darkmode__text__498&quot;&gt;# 查看磁盘占用&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__499&quot;&gt;docker system&lt;/span&gt;&lt;span style=&quot;color: #ffa657;&quot; class=&quot;js_darkmode__text__500&quot;&gt;&lt;span class=&quot;js_darkmode__text__501&quot;&gt;&amp;nbsp;df&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__502&quot;&gt;&lt;br/&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__503&quot;&gt;# 清理未使用的资源（安全）&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__504&quot;&gt;docker system prune&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__505&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__506&quot;&gt;# 可回收：&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__507&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__508&quot;&gt;# · 停止的容器&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__509&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__510&quot;&gt;# · 未使用的网络&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__511&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__512&quot;&gt;# · 悬空的镜像&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__513&quot;&gt;&lt;br/&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__514&quot;&gt;# 深度清理（包括未使用的镜像）⚠️&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__515&quot;&gt;docker system prune -a&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__516&quot;&gt;&lt;br/&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__517&quot;&gt;# 手动清理特定内容&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__518&quot;&gt;docker container prune&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__519&quot;&gt;&lt;span class=&quot;js_darkmode__text__520&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # 所有停止的容器&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__521&quot;&gt;docker volume prune&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__522&quot;&gt;&lt;span class=&quot;js_darkmode__text__523&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;# 未使用的卷&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__524&quot;&gt;docker image prune -a&lt;/span&gt;&lt;span style=&quot;color: #8b949e;&quot; class=&quot;js_darkmode__text__525&quot;&gt;&lt;span class=&quot;js_darkmode__text__526&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # 未使用的镜像&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;hr style=&quot;border-style: solid;border-width: 2px 0 0;border-color: rgba(0, 0, 0, 0.1);-webkit-transform-origin: 0 0;-webkit-transform: scale(1, 0.5);transform-origin: 0 0;transform: scale(1, 0.5);height: 0.4em;margin: 1.5em 0;&quot; class=&quot;js_darkmode__64&quot;/&gt;&lt;h2 data-heading=&quot;true&quot; style=&quot;display: table;padding: 0 0.2em;margin: 4em auto 2em;color: #fff;background: #0F4C81;font-size: 19.2px;font-weight: bold;text-align: center;&quot; class=&quot;js_darkmode__text__527&quot;&gt;&lt;span class=&quot;js_darkmode__text__528&quot;&gt;Dev Container 开发提示&lt;/span&gt;&lt;/h2&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__65 js_darkmode__text__529&quot;&gt;&lt;span class=&quot;js_darkmode__text__530&quot;&gt;如果你在 VS Code 中使用 Remote-Containers：&lt;/span&gt;&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__66 js_darkmode__text__531&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code data-language-pending=&quot;&quot; data-raw-code=&quot;F1 → &amp;quot;Dev Containers: Open Folder in Container&amp;quot;
→ 自动构建开发容器并在其中打开代码
→ 终端、扩展、调试器全部在容器内运行
→ 团队成员用同一个 devcontainer.json 就能获得一致环境&quot; data-show-line-number=&quot;false&quot; style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot; class=&quot;js_darkmode__text__532&quot;&gt;&lt;span class=&quot;js_darkmode__text__533&quot;&gt;F1 → &amp;quot;Dev Containers: Open Folder in Container&amp;quot;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__534&quot;&gt;→ 自动构建开发容器并在其中打开代码&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__535&quot;&gt;→ 终端、扩展、调试器全部在容器内运行&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__536&quot;&gt;→ 团队成员用同一个 devcontainer.json 就能获得一致环境&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin: 1.5em 8px;letter-spacing: 0.1em;color: #3f3f3f;&quot; class=&quot;js_darkmode__67 js_darkmode__text__537&quot;&gt;&lt;code style=&quot;font-size: 90%;color: #d14;background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;&quot; class=&quot;js_darkmode__68 js_darkmode__text__538&quot;&gt;&lt;span class=&quot;js_darkmode__text__539&quot;&gt;devcontainer.json&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;js_darkmode__text__540&quot;&gt;&amp;nbsp;示例：&lt;/span&gt;&lt;/p&gt;&lt;pre style=&quot;color: #c9d1d9;background: #0d1117;font-size: 90%;overflow-x: auto;border-radius: 8px;line-height: 1.5;margin: 10px 8px;padding: 0 !important;&quot; class=&quot;js_darkmode__69 js_darkmode__text__541&quot;&gt;&lt;span style=&quot;display: flex;padding: 10px 14px 0;&quot;&gt;&lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;45px&quot; height=&quot;13px&quot; viewbox=&quot;0 0 450 130&quot; aria-label=&quot;插图&quot;&gt;&lt;ellipse cx=&quot;50&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(220,60,54)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(237,108,96)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;225&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(218,151,33)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(247,193,81)&quot;&gt;&lt;/ellipse&gt;&lt;ellipse cx=&quot;400&quot; cy=&quot;65&quot; rx=&quot;50&quot; ry=&quot;52&quot; stroke=&quot;rgb(27,161,37)&quot; stroke-width=&quot;2&quot; fill=&quot;rgb(100,200,86)&quot;&gt;&lt;/ellipse&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code style=&quot;font-size: 90%;border-radius: 4px;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;text-indent: 0;color: inherit;background: none;white-space: nowrap;margin: 0;&quot; class=&quot;js_darkmode__text__542&quot;&gt;&lt;span class=&quot;js_darkmode__text__543&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__544&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__545&quot;&gt;&amp;nbsp; &amp;quot;name&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;js_darkmode__text__546&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #a5d6ff;&quot; class=&quot;js_darkmode__text__547&quot;&gt;&lt;span class=&quot;js_darkmode__text__548&quot;&gt;&amp;nbsp;&amp;quot;My Python Project&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;js_darkmode__text__549&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__550&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__551&quot;&gt;&amp;nbsp; &amp;quot;image&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;js_darkmode__text__552&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #a5d6ff;&quot; class=&quot;js_darkmode__text__553&quot;&gt;&lt;span class=&quot;js_darkmode__text__554&quot;&gt;&amp;nbsp;&amp;quot;mcr.microsoft.com/devcontainers/python:3.12&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;js_darkmode__text__555&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__556&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__557&quot;&gt;&amp;nbsp; &amp;quot;features&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;js_darkmode__text__558&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;js_darkmode__text__559&quot;&gt;&amp;nbsp;{&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__560&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__561&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;quot;ghcr.io/devcontainers/features/docker-in-docker:2&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;js_darkmode__text__562&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;js_darkmode__text__563&quot;&gt;&amp;nbsp;{&lt;/span&gt;&lt;span class=&quot;js_darkmode__text__564&quot;&gt;}&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__565&quot;&gt;&amp;nbsp; }&lt;/span&gt;&lt;span class=&quot;js_darkmode__text__566&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__567&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__568&quot;&gt;&amp;nbsp; &amp;quot;postCreateCommand&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;js_darkmode__text__569&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #a5d6ff;&quot; class=&quot;js_darkmode__text__570&quot;&gt;&lt;span class=&quot;js_darkmode__text__571&quot;&gt;&amp;nbsp;&amp;quot;pip install -r requirements.txt&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;js_darkmode__text__572&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__573&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__574&quot;&gt;&amp;nbsp; &amp;quot;customizations&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;js_darkmode__text__575&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;js_darkmode__text__576&quot;&gt;&amp;nbsp;{&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__577&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__578&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;quot;vscode&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;js_darkmode__text__579&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;js_darkmode__text__580&quot;&gt;&amp;nbsp;{&lt;/span&gt;&lt;span style=&quot;color: #79c0ff;&quot; class=&quot;js_darkmode__text__581&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__582&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;quot;extensions&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;js_darkmode__text__583&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;js_darkmode__text__584&quot;&gt;&amp;nbsp;[&lt;/span&gt;&lt;span style=&quot;color: #a5d6ff;&quot; class=&quot;js_darkmode__text__585&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__586&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;quot;ms-python.python&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;js_darkmode__text__587&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #a5d6ff;&quot; class=&quot;js_darkmode__text__588&quot;&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__589&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;quot;ms-python.vscode-pylance&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__590&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ]&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__591&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__592&quot;&gt;&amp;nbsp; }&lt;/span&gt;&lt;br/&gt;&lt;span class=&quot;js_darkmode__text__593&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Fri, 29 May 2026 10:07:55 +0800</pubDate></item><item><title>2026 硬核项目：AI 接口集成 +.NET10 开发 + Nginx 反向代理，全套可部署</title><link>https://www.codepub.top/post/460.html</link><description>&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__0&quot;&gt;&lt;span class=&quot;js_darkmode__text__1&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__2&quot;&gt;2026 年，AI 已经从 &amp;quot;锦上添花&amp;quot; 变成了企业应用的 &amp;quot;标配能力&amp;quot;。但很多开发者依然面临着一个共同的痛点：&lt;/span&gt;&lt;/span&gt;&lt;strong style=&quot;color: rgb(31, 35, 41);font: 700 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;white-space: normal;display: inline;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; data-pm-slice=&quot;0 0 []&quot; class=&quot;js_darkmode__0 js_darkmode__text__3&quot;&gt;&lt;span class=&quot;js_darkmode__text__4&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__5&quot;&gt;如何快速、稳定、低成本地将 AI 能力集成到现有.NET 系统中&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;js_darkmode__text__6&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__7&quot;&gt;？&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;p&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__8&quot;&gt;&lt;span class=&quot;js_darkmode__text__9&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__10&quot;&gt;今天给大家带来一个真正可落地的硬核项目实战：基于最新的&lt;span class=&quot;&quot;&gt;.NET 10&lt;/span&gt; 原生 AI 能力，集成主流大模型接口，配合 Nginx 实现高可用反向代理，从 0 到 1 搭建一套完整的 AI 服务网关。这套架构不仅能直接用于生产环境，还能帮你轻松应对高并发、限流、负载均衡等企业级需求。&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;/p&gt;&lt;hr style=&quot;border-style: solid;border-width: 1px 0 0;border-color: rgba(0,0,0,0.1);-webkit-transform-origin: 0 0;-webkit-transform: scale(1, 0.5);transform-origin: 0 0;transform: scale(1, 0.5);&quot; class=&quot;js_darkmode__1&quot;/&gt;&lt;p&gt;&lt;section style=&quot;text-align: left;&quot;&gt;&lt;br/&gt;&lt;/section&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__11&quot;&gt;&lt;span class=&quot;js_darkmode__text__12&quot;&gt;&lt;span style=&quot;font-size: 20px;font-weight: bold;&quot; class=&quot;js_darkmode__text__13&quot;&gt;为什么选择这个技术栈？&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;/p&gt;&lt;ul class=&quot;js_darkmode__text__14 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong style=&quot;color: rgb(31, 35, 41);font: 700 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;font-size: 16px;font-weight: 700;line-height: 24px;text-align: left;white-space: normal;display: inline;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box;background-color: rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__3 js_darkmode__text__16&quot;&gt;&lt;span class=&quot;js_darkmode__text__17&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__18&quot;&gt;.NET 10 原生 AI 支持&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__19&quot;&gt;&lt;span class=&quot;js_darkmode__text__20&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__21&quot;&gt;：Microsoft.Extensions.AI 正式 GA，告别第三方 SDK 的版本混乱和依赖冲突&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong style=&quot;color: rgb(31, 35, 41);font: 700 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;font-size: 16px;font-weight: 700;line-height: 24px;text-align: left;white-space: normal;display: inline;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box;background-color: rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__5 js_darkmode__text__23&quot;&gt;&lt;span class=&quot;js_darkmode__text__24&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__25&quot;&gt;统一接口抽象&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__26&quot;&gt;&lt;span class=&quot;js_darkmode__text__27&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__28&quot;&gt;：一次编写，无缝切换 GPT-4o、Claude 3.5、DeepSeek V3 等主流大模型&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong style=&quot;color: rgb(31, 35, 41);font: 700 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;font-size: 16px;font-weight: 700;line-height: 24px;text-align: left;white-space: normal;display: inline;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box;background-color: rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__7 js_darkmode__text__30&quot;&gt;&lt;span class=&quot;js_darkmode__text__31&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__32&quot;&gt;Nginx 反向代理&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__33&quot;&gt;&lt;span class=&quot;js_darkmode__text__34&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__35&quot;&gt;：解决跨域、限流、SSL 终止、负载均衡等问题，大幅提升系统稳定性&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong style=&quot;color: rgb(31, 35, 41);font: 700 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;font-size: 16px;font-weight: 700;line-height: 24px;text-align: left;white-space: normal;display: inline;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box;background-color: rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__9 js_darkmode__text__37&quot;&gt;&lt;span class=&quot;js_darkmode__text__38&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__39&quot;&gt;容器化部署&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__40&quot;&gt;&lt;span class=&quot;js_darkmode__text__41&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__42&quot;&gt;：全程使用 Docker，一次构建，到处运行，部署时间从几天缩短到几分钟&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;section style=&quot;text-align: left;&quot;&gt;&lt;br/&gt;&lt;/section&gt;&lt;/p&gt;&lt;hr style=&quot;border-style: solid;border-width: 1px 0 0;border-color: rgba(0,0,0,0.1);-webkit-transform-origin: 0 0;-webkit-transform: scale(1, 0.5);transform-origin: 0 0;transform: scale(1, 0.5);&quot; class=&quot;js_darkmode__10&quot;/&gt;&lt;p&gt;&lt;section style=&quot;text-align: left;&quot;&gt;&lt;br/&gt;&lt;/section&gt;&lt;/p&gt;&lt;h2 style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;text-align: left;white-space: normal;display: block;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; data-pm-slice=&quot;0 0 []&quot; class=&quot;js_darkmode__11 js_darkmode__text__43&quot;&gt;&lt;span class=&quot;js_darkmode__text__44&quot;&gt;&lt;span style=&quot;font-size: 20px;font-weight: bold;&quot; class=&quot;js_darkmode__text__45&quot;&gt;一、项目整体架构设计&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h2 style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;text-align: left;white-space: normal;display: block;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; data-pm-slice=&quot;0 0 []&quot; class=&quot;js_darkmode__12&quot;&gt;&lt;br/&gt;&lt;/h2&gt;&lt;p style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__46&quot;&gt;&lt;span class=&quot;js_darkmode__text__47&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__48&quot;&gt;我们的目标是构建一个&lt;/span&gt;&lt;/span&gt;&lt;strong style=&quot;color: rgb(31, 35, 41);font: 700 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;white-space: normal;display: inline;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__13 js_darkmode__text__49&quot;&gt;&lt;span class=&quot;js_darkmode__text__50&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__51&quot;&gt;松耦合、可扩展、高可用&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;js_darkmode__text__52&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__53&quot;&gt;的 AI 服务网关，整体架构分为三层：&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;ol style=&quot;list-style-type: decimal;&quot; class=&quot;js_darkmode__text__54 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong style=&quot;color: rgb(31, 35, 41);font: 700 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;font-size: 16px;font-weight: 700;line-height: 24px;text-align: left;white-space: normal;display: inline;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box;background-color: rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__15 js_darkmode__text__56&quot;&gt;&lt;span class=&quot;js_darkmode__text__57&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__58&quot;&gt;接入层&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__59&quot;&gt;&lt;span class=&quot;js_darkmode__text__60&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__61&quot;&gt;：Nginx 负责 SSL 终止、请求限流、跨域处理和负载均衡&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong style=&quot;color: rgb(31, 35, 41);font: 700 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;font-size: 16px;font-weight: 700;line-height: 24px;text-align: left;white-space: normal;display: inline;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box;background-color: rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__17 js_darkmode__text__63&quot;&gt;&lt;span class=&quot;js_darkmode__text__64&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__65&quot;&gt;应用层&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__66&quot;&gt;&lt;span class=&quot;js_darkmode__text__67&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__68&quot;&gt;：.NET 10 Web API 实现 AI 接口统一封装、业务逻辑处理和权限认证&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong style=&quot;color: rgb(31, 35, 41);font: 700 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;font-size: 16px;font-weight: 700;line-height: 24px;text-align: left;white-space: normal;display: inline;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box;background-color: rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__19 js_darkmode__text__70&quot;&gt;&lt;span class=&quot;js_darkmode__text__71&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__72&quot;&gt;AI 服务层&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__73&quot;&gt;&lt;span class=&quot;js_darkmode__text__74&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__75&quot;&gt;：对接各大云厂商的大模型 API，支持本地大模型扩展&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;section style=&quot;text-align: left;&quot;&gt;&lt;br/&gt;&lt;/section&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__76&quot;&gt;&lt;span class=&quot;js_darkmode__text__77&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__78&quot;&gt;这种架构的最大优势是&lt;/span&gt;&lt;/span&gt;&lt;strong style=&quot;color: rgb(31, 35, 41);font: 700 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;white-space: normal;display: inline;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; data-pm-slice=&quot;0 0 []&quot; class=&quot;js_darkmode__20 js_darkmode__text__79&quot;&gt;&lt;span class=&quot;js_darkmode__text__80&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__81&quot;&gt;业务与 AI 能力完全解耦&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;js_darkmode__text__82&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__83&quot;&gt;。未来更换大模型供应商时，只需要修改配置文件，不需要改动任何业务代码。&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;/p&gt;&lt;hr style=&quot;border-style: solid;border-width: 1px 0 0;border-color: rgba(0,0,0,0.1);-webkit-transform-origin: 0 0;-webkit-transform: scale(1, 0.5);transform-origin: 0 0;transform: scale(1, 0.5);&quot; class=&quot;js_darkmode__21&quot;/&gt;&lt;p&gt;&lt;section style=&quot;text-align: left;&quot;&gt;&lt;br/&gt;&lt;/section&gt;&lt;/p&gt;&lt;h2 style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;text-align: left;white-space: normal;display: block;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; data-pm-slice=&quot;0 0 []&quot; class=&quot;js_darkmode__22 js_darkmode__text__84&quot;&gt;&lt;span class=&quot;js_darkmode__text__85&quot;&gt;&lt;span style=&quot;font-size: 20px;font-weight: bold;&quot; class=&quot;js_darkmode__text__86&quot;&gt;二、环境准备与项目初始化&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h2 style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;text-align: left;white-space: normal;display: block;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; data-pm-slice=&quot;0 0 []&quot; class=&quot;js_darkmode__23&quot;&gt;&lt;br/&gt;&lt;/h2&gt;&lt;h3 style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;text-align: left;white-space: normal;display: block;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__24 js_darkmode__text__87&quot;&gt;&lt;span class=&quot;js_darkmode__text__88&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: bold;&quot; class=&quot;js_darkmode__text__89&quot;&gt;2.1 必备工具&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3 style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;text-align: left;white-space: normal;display: block;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__25&quot;&gt;&lt;br/&gt;&lt;/h3&gt;&lt;ul class=&quot;js_darkmode__text__90 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__92&quot;&gt;&lt;span class=&quot;js_darkmode__text__93&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__94&quot;&gt;.NET 10 SDK（正式版）&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__96&quot;&gt;&lt;span class=&quot;js_darkmode__text__97&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__98&quot;&gt;Docker Desktop 26.0+&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__100&quot;&gt;&lt;span class=&quot;js_darkmode__text__101&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__102&quot;&gt;Visual Studio 2022 17.12+ / Rider 2026.1&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__104&quot;&gt;&lt;span class=&quot;js_darkmode__text__105&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__106&quot;&gt;Postman / Thunder Client（接口测试）&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;section style=&quot;text-align: left;&quot;&gt;&lt;br/&gt;&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;text-align: left;white-space: normal;display: block;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; data-pm-slice=&quot;0 0 []&quot; class=&quot;js_darkmode__30 js_darkmode__text__107&quot;&gt;&lt;span class=&quot;js_darkmode__text__108&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: bold;&quot; class=&quot;js_darkmode__text__109&quot;&gt;2.2 项目初始化&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3 style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;text-align: left;white-space: normal;display: block;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; data-pm-slice=&quot;0 0 []&quot; class=&quot;js_darkmode__31&quot;&gt;&lt;br/&gt;&lt;/h3&gt;&lt;p style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__110&quot;&gt;&lt;span class=&quot;js_darkmode__text__111&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__112&quot;&gt;打开终端，执行以下命令创建解决方案和项目：&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;section style=&quot;text-align: left;&quot;&gt;&lt;img data-src=&quot;https://mmbiz.qpic.cn/mmbiz_png/W03YkxiaHL9PpDRlGlTabBLgibyflaozgDniaFbVlUbDolo9f4LXtRqtC8z6OqfjibgXZdWcasXZ3ibtYB6wAhoxCUXwBGtZBCMOEMdf1aOic2gRc/640?wx_fmt=png&amp;amp;from=appmsg&amp;amp;watermark=1#imgIndex=0&quot; class=&quot;rich_pages wxw-img&quot; data-ratio=&quot;0.33088235294117646&quot; data-s=&quot;300,640&quot; data-type=&quot;png&quot; data-w=&quot;680&quot; type=&quot;block&quot; data-imgfileid=&quot;100001245&quot; data-aistatus=&quot;1&quot; data-original-style=&quot;null&quot; data-index=&quot;0&quot; src=&quot;https://mmbiz.qpic.cn/mmbiz_png/W03YkxiaHL9PpDRlGlTabBLgibyflaozgDniaFbVlUbDolo9f4LXtRqtC8z6OqfjibgXZdWcasXZ3ibtYB6wAhoxCUXwBGtZBCMOEMdf1aOic2gRc/640?wx_fmt=png&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1&amp;watermark=1#imgIndex=0&quot; _width=&quot;677px&quot; __sec_open_place_holder__=&quot;true&quot; style=&quot;height: auto !important; visibility: visible !important; width: 677px !important;&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780018546297&quot; data-report-img-idx=&quot;0&quot; data-fail=&quot;0&quot;/&gt;&lt;/section&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__113&quot;&gt;&lt;span class=&quot;js_darkmode__text__114&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: bold;&quot; class=&quot;js_darkmode__text__115&quot;&gt;2.3 安装核心 NuGet 包&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;section style=&quot;text-align: left;&quot;&gt;&lt;img data-src=&quot;https://mmbiz.qpic.cn/sz_mmbiz_png/W03YkxiaHL9PficNvv10R6S9icZZa9qyb17mtKSYntYqJcgFFSoc8KxSGF6Z6yXgrJMj4k3owK3ibIkev9gGyTnqDmiaW34iaTBjpOibnVVuI7lXiaQ/640?wx_fmt=png&amp;amp;from=appmsg&amp;amp;watermark=1#imgIndex=1&quot; class=&quot;rich_pages wxw-img&quot; data-ratio=&quot;0.3088235294117647&quot; data-s=&quot;300,640&quot; data-type=&quot;png&quot; data-w=&quot;680&quot; type=&quot;block&quot; data-imgfileid=&quot;100001246&quot; data-aistatus=&quot;1&quot; data-original-style=&quot;null&quot; data-index=&quot;1&quot; src=&quot;https://mmbiz.qpic.cn/sz_mmbiz_png/W03YkxiaHL9PficNvv10R6S9icZZa9qyb17mtKSYntYqJcgFFSoc8KxSGF6Z6yXgrJMj4k3owK3ibIkev9gGyTnqDmiaW34iaTBjpOibnVVuI7lXiaQ/640?wx_fmt=png&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1&amp;watermark=1#imgIndex=1&quot; _width=&quot;677px&quot; __sec_open_place_holder__=&quot;true&quot; style=&quot;height: auto !important; visibility: visible !important; width: 677px !important;&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780018546370&quot; data-report-img-idx=&quot;1&quot; data-fail=&quot;0&quot;/&gt;&lt;/section&gt;&lt;/p&gt;&lt;h2 style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;text-align: left;white-space: normal;display: block;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; data-pm-slice=&quot;0 0 []&quot; class=&quot;js_darkmode__32&quot;&gt;&lt;br/&gt;&lt;/h2&gt;&lt;hr style=&quot;border-style: solid;border-width: 1px 0 0;border-color: rgba(0,0,0,0.1);-webkit-transform-origin: 0 0;-webkit-transform: scale(1, 0.5);transform-origin: 0 0;transform: scale(1, 0.5);&quot; class=&quot;js_darkmode__33&quot;/&gt;&lt;h2 style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;text-align: left;white-space: normal;display: block;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; data-pm-slice=&quot;0 0 []&quot; class=&quot;js_darkmode__34&quot;&gt;&lt;br/&gt;&lt;/h2&gt;&lt;h2 style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;text-align: left;white-space: normal;display: block;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; data-pm-slice=&quot;0 0 []&quot; class=&quot;js_darkmode__35&quot;&gt;&lt;br/&gt;&lt;/h2&gt;&lt;h2 style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;text-align: left;white-space: normal;display: block;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; data-pm-slice=&quot;0 0 []&quot; class=&quot;js_darkmode__36 js_darkmode__text__116&quot;&gt;&lt;span class=&quot;js_darkmode__text__117&quot;&gt;&lt;span style=&quot;font-size: 20px;font-weight: bold;&quot; class=&quot;js_darkmode__text__118&quot;&gt;三、.NET 10 原生 AI 接口集成&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h2 style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;text-align: left;white-space: normal;display: block;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; data-pm-slice=&quot;0 0 []&quot; class=&quot;js_darkmode__37&quot;&gt;&lt;br/&gt;&lt;/h2&gt;&lt;p style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__119&quot;&gt;&lt;span class=&quot;js_darkmode__text__120&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__121&quot;&gt;这是整个项目的核心部分。.NET 10 引入的&lt;/span&gt;&lt;/span&gt;&lt;code style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace;white-space: normal;display: inline;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__38 js_darkmode__text__122&quot;&gt;&lt;span class=&quot;js_darkmode__text__123&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__124&quot;&gt;Microsoft.Extensions.AI&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;js_darkmode__text__125&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__126&quot;&gt;提供了统一的 AI 抽象层，让我们可以用完全相同的代码调用不同的大模型。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;h3 style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;text-align: left;white-space: normal;display: block;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__39 js_darkmode__text__127&quot;&gt;&lt;span class=&quot;js_darkmode__text__128&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: bold;&quot; class=&quot;js_darkmode__text__129&quot;&gt;3.1 配置 AI 服务&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3 style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;text-align: left;white-space: normal;display: block;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__40&quot;&gt;&lt;br/&gt;&lt;/h3&gt;&lt;p style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__130&quot;&gt;&lt;span class=&quot;js_darkmode__text__131&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__132&quot;&gt;首先，在&lt;/span&gt;&lt;/span&gt;&lt;code style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace;white-space: normal;display: inline;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__41 js_darkmode__text__133&quot;&gt;&lt;span class=&quot;js_darkmode__text__134&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__135&quot;&gt;appsettings.json&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;js_darkmode__text__136&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__137&quot;&gt;中添加大模型配置：&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;section style=&quot;text-align: left;&quot;&gt;&lt;img class=&quot;rich_pages wxw-img&quot; data-aistatus=&quot;1&quot; data-imgfileid=&quot;100001247&quot; data-ratio=&quot;0.3570391872278665&quot; data-s=&quot;300,640&quot; data-src=&quot;https://mmbiz.qpic.cn/sz_mmbiz_png/W03YkxiaHL9MjAQUW5kaanbYBTzKhnlD8gUP6g9n4akVwMuzZpLlkhwLga9BzdxHfWfXHO26miaEYfUh6GDYBicoDJ5dmkgdGrnLicqFsTKlOnw/640?wx_fmt=png&amp;amp;from=appmsg&amp;amp;watermark=1#imgIndex=2&quot; data-type=&quot;png&quot; data-w=&quot;689&quot; type=&quot;block&quot; data-original-style=&quot;null&quot; data-index=&quot;2&quot; src=&quot;https://mmbiz.qpic.cn/sz_mmbiz_png/W03YkxiaHL9MjAQUW5kaanbYBTzKhnlD8gUP6g9n4akVwMuzZpLlkhwLga9BzdxHfWfXHO26miaEYfUh6GDYBicoDJ5dmkgdGrnLicqFsTKlOnw/640?wx_fmt=png&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1&amp;watermark=1#imgIndex=2&quot; _width=&quot;677px&quot; __sec_open_place_holder__=&quot;true&quot; style=&quot;height: auto !important; visibility: visible !important; width: 677px !important;&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780018546994&quot; data-report-img-idx=&quot;2&quot; data-fail=&quot;0&quot;/&gt;&lt;/section&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__138&quot;&gt;&lt;span class=&quot;js_darkmode__text__139&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__140&quot;&gt;然后在&lt;/span&gt;&lt;/span&gt;&lt;code style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace;white-space: normal;display: inline;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; data-pm-slice=&quot;0 0 []&quot; class=&quot;js_darkmode__42 js_darkmode__text__141&quot;&gt;&lt;span class=&quot;js_darkmode__text__142&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__143&quot;&gt;Program.cs&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;js_darkmode__text__144&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__145&quot;&gt;中注册 AI 服务：&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;section style=&quot;text-align: left;&quot;&gt;&lt;img data-src=&quot;https://mmbiz.qpic.cn/mmbiz_png/W03YkxiaHL9PcmDnicZSeM4DfVFJibN7MIicZo0vgeRufUkPY49nPwuYJFqj3KwsEAcjN6e5IGMhYapdc0UXjeWr5hJ9t0uiaGVL26fg3PMSDxE8/640?wx_fmt=png&amp;amp;from=appmsg&amp;amp;watermark=1#imgIndex=3&quot; class=&quot;rich_pages wxw-img&quot; data-ratio=&quot;0.5240875912408759&quot; data-s=&quot;300,640&quot; data-type=&quot;png&quot; data-w=&quot;685&quot; type=&quot;block&quot; data-imgfileid=&quot;100001248&quot; data-aistatus=&quot;1&quot; data-original-style=&quot;null&quot; data-index=&quot;3&quot; src=&quot;https://mmbiz.qpic.cn/mmbiz_png/W03YkxiaHL9PcmDnicZSeM4DfVFJibN7MIicZo0vgeRufUkPY49nPwuYJFqj3KwsEAcjN6e5IGMhYapdc0UXjeWr5hJ9t0uiaGVL26fg3PMSDxE8/640?wx_fmt=png&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1&amp;watermark=1#imgIndex=3&quot; _width=&quot;677px&quot; __sec_open_place_holder__=&quot;true&quot; style=&quot;height: auto !important; visibility: visible !important; width: 677px !important;&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780018547054&quot; data-report-img-idx=&quot;3&quot; data-fail=&quot;0&quot;/&gt;&lt;/section&gt;&lt;/p&gt;&lt;h3 style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;text-align: left;white-space: normal;display: block;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; data-pm-slice=&quot;0 0 []&quot; class=&quot;js_darkmode__43 js_darkmode__text__146&quot;&gt;&lt;span class=&quot;js_darkmode__text__147&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: bold;&quot; class=&quot;js_darkmode__text__148&quot;&gt;3.2 实现统一聊天接口&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3 style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;text-align: left;white-space: normal;display: block;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; data-pm-slice=&quot;0 0 []&quot; class=&quot;js_darkmode__44&quot;&gt;&lt;br/&gt;&lt;/h3&gt;&lt;p style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__149&quot;&gt;&lt;span class=&quot;js_darkmode__text__150&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__151&quot;&gt;创建&lt;/span&gt;&lt;/span&gt;&lt;code style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace;white-space: normal;display: inline;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__45 js_darkmode__text__152&quot;&gt;&lt;span class=&quot;js_darkmode__text__153&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__154&quot;&gt;ChatController.cs&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;js_darkmode__text__155&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__156&quot;&gt;，实现一个通用的聊天接口：&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;section style=&quot;text-align: left;&quot;&gt;&lt;img data-src=&quot;https://mmbiz.qpic.cn/mmbiz_png/W03YkxiaHL9NOiaKrkxiaudVkBVicEqlP6INUAHhs2n4ia8ff9G9OdxdQPiaDBCOb0rn4FzBVeBkzjduxxOibBkic1PEvqSibEdF6NBh6B1cIzgcBNW8/640?wx_fmt=png&amp;amp;from=appmsg&amp;amp;watermark=1#imgIndex=4&quot; class=&quot;rich_pages wxw-img&quot; data-ratio=&quot;1.9939831528279182&quot; data-s=&quot;300,640&quot; data-type=&quot;png&quot; data-w=&quot;831&quot; type=&quot;block&quot; data-imgfileid=&quot;100001249&quot; data-aistatus=&quot;1&quot; data-original-style=&quot;null&quot; data-index=&quot;4&quot; src=&quot;https://mmbiz.qpic.cn/mmbiz_png/W03YkxiaHL9NOiaKrkxiaudVkBVicEqlP6INUAHhs2n4ia8ff9G9OdxdQPiaDBCOb0rn4FzBVeBkzjduxxOibBkic1PEvqSibEdF6NBh6B1cIzgcBNW8/640?wx_fmt=png&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1&amp;watermark=1#imgIndex=4&quot; _width=&quot;677px&quot; __sec_open_place_holder__=&quot;true&quot; style=&quot;height: auto !important; visibility: visible !important; width: 677px !important;&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780018547410&quot; data-report-img-idx=&quot;4&quot; data-fail=&quot;0&quot;/&gt;&lt;/section&gt;&lt;/p&gt;&lt;h3 style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;text-align: left;white-space: normal;display: block;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; data-pm-slice=&quot;0 0 []&quot; class=&quot;js_darkmode__46 js_darkmode__text__157&quot;&gt;&lt;span class=&quot;js_darkmode__text__158&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: bold;&quot; class=&quot;js_darkmode__text__159&quot;&gt;3.3 添加限流与权限控制&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3 style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;text-align: left;white-space: normal;display: block;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; data-pm-slice=&quot;0 0 []&quot; class=&quot;js_darkmode__47&quot;&gt;&lt;br/&gt;&lt;/h3&gt;&lt;p style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__160&quot;&gt;&lt;span class=&quot;js_darkmode__text__161&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__162&quot;&gt;为了防止 API 被滥用，我们添加简单的限流和 API Key 认证：&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;section style=&quot;text-align: left;&quot;&gt;&lt;img data-src=&quot;https://mmbiz.qpic.cn/sz_mmbiz_png/W03YkxiaHL9PcA3l3ML6qkMg67EZQbIp1cFLGHSGlOYH5agNLrdStP1VhHtpQtpiawibl2WwBnvVWg8ZN5T1ocobTz1Umvh4hHlBTykqiaeIsvg/640?wx_fmt=png&amp;amp;from=appmsg&amp;amp;watermark=1#imgIndex=5&quot; class=&quot;rich_pages wxw-img&quot; data-ratio=&quot;0.695906432748538&quot; data-s=&quot;300,640&quot; data-type=&quot;png&quot; data-w=&quot;684&quot; type=&quot;block&quot; data-imgfileid=&quot;100001250&quot; data-aistatus=&quot;1&quot; data-original-style=&quot;null&quot; data-index=&quot;5&quot; src=&quot;https://mmbiz.qpic.cn/sz_mmbiz_png/W03YkxiaHL9PcA3l3ML6qkMg67EZQbIp1cFLGHSGlOYH5agNLrdStP1VhHtpQtpiawibl2WwBnvVWg8ZN5T1ocobTz1Umvh4hHlBTykqiaeIsvg/640?wx_fmt=png&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1&amp;watermark=1#imgIndex=5&quot; _width=&quot;677px&quot; __sec_open_place_holder__=&quot;true&quot; style=&quot;height: auto !important; visibility: visible !important; width: 677px !important;&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780018548395&quot; data-report-img-idx=&quot;5&quot; data-fail=&quot;0&quot;/&gt;&lt;/section&gt;&lt;/p&gt;&lt;h2 style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;text-align: left;white-space: normal;display: block;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; data-pm-slice=&quot;0 0 []&quot; class=&quot;js_darkmode__48&quot;&gt;&lt;br/&gt;&lt;/h2&gt;&lt;hr style=&quot;border-style: solid;border-width: 1px 0 0;border-color: rgba(0,0,0,0.1);-webkit-transform-origin: 0 0;-webkit-transform: scale(1, 0.5);transform-origin: 0 0;transform: scale(1, 0.5);&quot; class=&quot;js_darkmode__49&quot;/&gt;&lt;h2 style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;text-align: left;white-space: normal;display: block;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; data-pm-slice=&quot;0 0 []&quot; class=&quot;js_darkmode__50&quot;&gt;&lt;br/&gt;&lt;/h2&gt;&lt;h2 style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;text-align: left;white-space: normal;display: block;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; data-pm-slice=&quot;0 0 []&quot; class=&quot;js_darkmode__51&quot;&gt;&lt;br/&gt;&lt;/h2&gt;&lt;h2 style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;text-align: left;white-space: normal;display: block;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; data-pm-slice=&quot;0 0 []&quot; class=&quot;js_darkmode__52 js_darkmode__text__163&quot;&gt;&lt;span class=&quot;js_darkmode__text__164&quot;&gt;&lt;span style=&quot;font-size: 20px;font-weight: bold;&quot; class=&quot;js_darkmode__text__165&quot;&gt;四、Nginx 反向代理配置&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h2 style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;text-align: left;white-space: normal;display: block;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; data-pm-slice=&quot;0 0 []&quot; class=&quot;js_darkmode__53&quot;&gt;&lt;br/&gt;&lt;/h2&gt;&lt;p style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__166&quot;&gt;&lt;span class=&quot;js_darkmode__text__167&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__168&quot;&gt;Nginx 在这套架构中扮演着至关重要的角色，它负责处理所有客户端请求，然后转发到后端的.NET 服务。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;h3 style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;text-align: left;white-space: normal;display: block;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__54 js_darkmode__text__169&quot;&gt;&lt;span class=&quot;js_darkmode__text__170&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: bold;&quot; class=&quot;js_darkmode__text__171&quot;&gt;4.1 基础 Nginx 配置&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3 style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;text-align: left;white-space: normal;display: block;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__55&quot;&gt;&lt;br/&gt;&lt;/h3&gt;&lt;p style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__172&quot;&gt;&lt;span class=&quot;js_darkmode__text__173&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__174&quot;&gt;创建&lt;/span&gt;&lt;/span&gt;&lt;code style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace;white-space: normal;display: inline;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__56 js_darkmode__text__175&quot;&gt;&lt;span class=&quot;js_darkmode__text__176&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__177&quot;&gt;nginx.conf&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;js_darkmode__text__178&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__179&quot;&gt;文件：&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;section style=&quot;text-align: left;&quot;&gt;&lt;img data-src=&quot;https://mmbiz.qpic.cn/sz_mmbiz_png/W03YkxiaHL9PmkrlAI3VEnsiclmqmJvlsnNgvF8oCPY52xw4yd3EPewdnPWWcGQ9g7OJwnLvRnibrYJ8rGtwsaxhQ0nRga6iatUhlTDQAr0NGXI/640?wx_fmt=png&amp;amp;from=appmsg&amp;amp;watermark=1#imgIndex=6&quot; class=&quot;rich_pages wxw-img&quot; data-ratio=&quot;1.613531047265987&quot; data-s=&quot;300,640&quot; data-type=&quot;png&quot; data-w=&quot;1079&quot; type=&quot;block&quot; data-imgfileid=&quot;100001251&quot; data-aistatus=&quot;1&quot; data-original-style=&quot;null&quot; data-index=&quot;6&quot; src=&quot;https://mmbiz.qpic.cn/sz_mmbiz_png/W03YkxiaHL9PmkrlAI3VEnsiclmqmJvlsnNgvF8oCPY52xw4yd3EPewdnPWWcGQ9g7OJwnLvRnibrYJ8rGtwsaxhQ0nRga6iatUhlTDQAr0NGXI/640?wx_fmt=png&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1&amp;watermark=1#imgIndex=6&quot; _width=&quot;677px&quot; __sec_open_place_holder__=&quot;true&quot; style=&quot;height: auto !important; visibility: visible !important; width: 677px !important;&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780018548764&quot; data-report-img-idx=&quot;6&quot; data-fail=&quot;0&quot;/&gt;&lt;/section&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__180&quot;&gt;&lt;span class=&quot;js_darkmode__text__181&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: bold;&quot; class=&quot;js_darkmode__text__182&quot;&gt;4.2 关键配置说明&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;/p&gt;&lt;ul class=&quot;js_darkmode__text__183 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong style=&quot;color: rgb(31, 35, 41);font: 700 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;font-size: 16px;font-weight: 700;line-height: 24px;text-align: left;white-space: normal;display: inline;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box;background-color: rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__58 js_darkmode__text__185&quot;&gt;&lt;span class=&quot;js_darkmode__text__186&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__187&quot;&gt;流式响应支持&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__188&quot;&gt;&lt;span class=&quot;js_darkmode__text__189&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__190&quot;&gt;：&lt;/span&gt;&lt;/span&gt;&lt;code style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace;white-space: normal;display: inline;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__59 js_darkmode__text__191&quot;&gt;&lt;span class=&quot;js_darkmode__text__192&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__193&quot;&gt;proxy_buffering off&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;js_darkmode__text__194&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__195&quot;&gt;和&lt;/span&gt;&lt;/span&gt;&lt;code style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace;white-space: normal;display: inline;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__60 js_darkmode__text__196&quot;&gt;&lt;span class=&quot;js_darkmode__text__197&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__198&quot;&gt;proxy_cache off&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;js_darkmode__text__199&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__200&quot;&gt;是实现 SSE 流式聊天的关键&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong style=&quot;color: rgb(31, 35, 41);font: 700 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;font-size: 16px;font-weight: 700;line-height: 24px;text-align: left;white-space: normal;display: inline;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box;background-color: rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__62 js_darkmode__text__202&quot;&gt;&lt;span class=&quot;js_darkmode__text__203&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__204&quot;&gt;超时设置&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__205&quot;&gt;&lt;span class=&quot;js_darkmode__text__206&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__207&quot;&gt;：&lt;/span&gt;&lt;/span&gt;&lt;code style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace;white-space: normal;display: inline;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__63 js_darkmode__text__208&quot;&gt;&lt;span class=&quot;js_darkmode__text__209&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__210&quot;&gt;proxy_read_timeout 300s&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;js_darkmode__text__211&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__212&quot;&gt;确保长连接不会被 Nginx 提前断开&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong style=&quot;color: rgb(31, 35, 41);font: 700 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;font-size: 16px;font-weight: 700;line-height: 24px;text-align: left;white-space: normal;display: inline;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box;background-color: rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__65 js_darkmode__text__214&quot;&gt;&lt;span class=&quot;js_darkmode__text__215&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__216&quot;&gt;负载均衡&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__217&quot;&gt;&lt;span class=&quot;js_darkmode__text__218&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__219&quot;&gt;：只需在&lt;/span&gt;&lt;/span&gt;&lt;code style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace;white-space: normal;display: inline;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__66 js_darkmode__text__220&quot;&gt;&lt;span class=&quot;js_darkmode__text__221&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__222&quot;&gt;upstream&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;js_darkmode__text__223&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__224&quot;&gt;块中添加多个后端服务地址即可实现水平扩展&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong style=&quot;color: rgb(31, 35, 41);font: 700 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;font-size: 16px;font-weight: 700;line-height: 24px;text-align: left;white-space: normal;display: inline;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box;background-color: rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__68 js_darkmode__text__226&quot;&gt;&lt;span class=&quot;js_darkmode__text__227&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__228&quot;&gt;SSL 配置&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__229&quot;&gt;&lt;span class=&quot;js_darkmode__text__230&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__231&quot;&gt;：生产环境必须启用 HTTPS，注释部分提供了完整的 SSL 配置模板&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;section style=&quot;text-align: left;&quot;&gt;&lt;br/&gt;&lt;/section&gt;&lt;/p&gt;&lt;hr style=&quot;border-style: solid;border-width: 1px 0 0;border-color: rgba(0,0,0,0.1);-webkit-transform-origin: 0 0;-webkit-transform: scale(1, 0.5);transform-origin: 0 0;transform: scale(1, 0.5);&quot; class=&quot;js_darkmode__69&quot;/&gt;&lt;p&gt;&lt;section style=&quot;text-align: left;&quot;&gt;&lt;br/&gt;&lt;/section&gt;&lt;/p&gt;&lt;h2 style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;text-align: left;white-space: normal;display: block;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; data-pm-slice=&quot;0 0 []&quot; class=&quot;js_darkmode__70 js_darkmode__text__232&quot;&gt;&lt;span class=&quot;js_darkmode__text__233&quot;&gt;&lt;span style=&quot;font-size: 20px;font-weight: bold;&quot; class=&quot;js_darkmode__text__234&quot;&gt;五、Docker 容器化部署&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h2 style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;text-align: left;white-space: normal;display: block;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; data-pm-slice=&quot;0 0 []&quot; class=&quot;js_darkmode__71&quot;&gt;&lt;br/&gt;&lt;/h2&gt;&lt;p style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__235&quot;&gt;&lt;span class=&quot;js_darkmode__text__236&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__237&quot;&gt;使用 Docker Compose 可以一键部署整个应用栈，包括.NET 服务和 Nginx。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;h3 style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;text-align: left;white-space: normal;display: block;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__72 js_darkmode__text__238&quot;&gt;&lt;span class=&quot;js_darkmode__text__239&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: bold;&quot; class=&quot;js_darkmode__text__240&quot;&gt;5.1 创建.NET 项目 Dockerfile&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3 style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;text-align: left;white-space: normal;display: block;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__73&quot;&gt;&lt;br/&gt;&lt;/h3&gt;&lt;p style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__241&quot;&gt;&lt;span class=&quot;js_darkmode__text__242&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__243&quot;&gt;在&lt;/span&gt;&lt;/span&gt;&lt;code style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace;white-space: normal;display: inline;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__74 js_darkmode__text__244&quot;&gt;&lt;span class=&quot;js_darkmode__text__245&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__246&quot;&gt;AIServiceGateway.API&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;js_darkmode__text__247&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__248&quot;&gt;目录下创建&lt;/span&gt;&lt;/span&gt;&lt;code style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace;white-space: normal;display: inline;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__75 js_darkmode__text__249&quot;&gt;&lt;span class=&quot;js_darkmode__text__250&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__251&quot;&gt;Dockerfile&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;js_darkmode__text__252&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__253&quot;&gt;：&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;section style=&quot;text-align: left;&quot;&gt;&lt;img data-src=&quot;https://mmbiz.qpic.cn/sz_mmbiz_png/W03YkxiaHL9MCA6AxZ05hg9LhSoK8qjyxxrIulsUUL76E7yPC9sr9icAQYMOXrWXibUlKD86SchOGFlEBopxoPvJd9VGmg4fNH2oFGAoTjKQ6M/640?wx_fmt=png&amp;amp;from=appmsg&amp;amp;watermark=1#imgIndex=7&quot; class=&quot;rich_pages wxw-img&quot; data-ratio=&quot;0.5482014388489208&quot; data-s=&quot;300,640&quot; data-type=&quot;png&quot; data-w=&quot;695&quot; type=&quot;block&quot; data-imgfileid=&quot;100001252&quot; data-aistatus=&quot;1&quot; data-original-style=&quot;null&quot; data-index=&quot;7&quot; src=&quot;https://mmbiz.qpic.cn/sz_mmbiz_png/W03YkxiaHL9MCA6AxZ05hg9LhSoK8qjyxxrIulsUUL76E7yPC9sr9icAQYMOXrWXibUlKD86SchOGFlEBopxoPvJd9VGmg4fNH2oFGAoTjKQ6M/640?wx_fmt=png&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1&amp;watermark=1#imgIndex=7&quot; _width=&quot;677px&quot; __sec_open_place_holder__=&quot;true&quot; style=&quot;height: auto !important; visibility: visible !important; width: 677px !important;&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780018577722&quot; data-report-img-idx=&quot;7&quot; data-fail=&quot;0&quot;/&gt;&lt;/section&gt;&lt;/p&gt;&lt;h3 style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;text-align: left;white-space: normal;display: block;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; data-pm-slice=&quot;0 0 []&quot; class=&quot;js_darkmode__76 js_darkmode__text__254&quot;&gt;&lt;span class=&quot;js_darkmode__text__255&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: bold;&quot; class=&quot;js_darkmode__text__256&quot;&gt;5.2 创建 docker-compose.yml&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3 style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;text-align: left;white-space: normal;display: block;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; data-pm-slice=&quot;0 0 []&quot; class=&quot;js_darkmode__77&quot;&gt;&lt;br/&gt;&lt;/h3&gt;&lt;p style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__257&quot;&gt;&lt;span class=&quot;js_darkmode__text__258&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__259&quot;&gt;在解决方案根目录创建&lt;/span&gt;&lt;/span&gt;&lt;code style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace;white-space: normal;display: inline;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__78 js_darkmode__text__260&quot;&gt;&lt;span class=&quot;js_darkmode__text__261&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__262&quot;&gt;docker-compose.yml&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;js_darkmode__text__263&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__264&quot;&gt;：&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;section style=&quot;text-align: left;&quot;&gt;&lt;img class=&quot;rich_pages wxw-img&quot; data-aistatus=&quot;1&quot; data-imgfileid=&quot;100001253&quot; data-ratio=&quot;1.0058737151248165&quot; data-s=&quot;300,640&quot; data-src=&quot;https://mmbiz.qpic.cn/mmbiz_png/W03YkxiaHL9PHtOTmTbRTkoOfAzIUdyC9obP6yDqCtrqpnN4Ajia9M3u7txuiafbruMFUko0VbKft7Xyz3CzTAvVUibeFh6krQIJ58hPqHr1LLE/640?wx_fmt=png&amp;amp;from=appmsg&amp;amp;watermark=1#imgIndex=8&quot; data-type=&quot;png&quot; data-w=&quot;681&quot; type=&quot;block&quot; data-original-style=&quot;null&quot; data-index=&quot;8&quot; src=&quot;https://mmbiz.qpic.cn/mmbiz_png/W03YkxiaHL9PHtOTmTbRTkoOfAzIUdyC9obP6yDqCtrqpnN4Ajia9M3u7txuiafbruMFUko0VbKft7Xyz3CzTAvVUibeFh6krQIJ58hPqHr1LLE/640?wx_fmt=png&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1&amp;watermark=1#imgIndex=8&quot; _width=&quot;677px&quot; __sec_open_place_holder__=&quot;true&quot; style=&quot;height: auto !important; visibility: visible !important; width: 677px !important;&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780018578054&quot; data-report-img-idx=&quot;8&quot; data-fail=&quot;0&quot;/&gt;&lt;/section&gt;&lt;/p&gt;&lt;h3 style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;text-align: left;white-space: normal;display: block;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; data-pm-slice=&quot;0 0 []&quot; class=&quot;js_darkmode__79 js_darkmode__text__265&quot;&gt;&lt;span class=&quot;js_darkmode__text__266&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: bold;&quot; class=&quot;js_darkmode__text__267&quot;&gt;5.3 一键部署&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3 style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;text-align: left;white-space: normal;display: block;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; data-pm-slice=&quot;0 0 []&quot; class=&quot;js_darkmode__80&quot;&gt;&lt;br/&gt;&lt;/h3&gt;&lt;p style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__268&quot;&gt;&lt;span class=&quot;js_darkmode__text__269&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__270&quot;&gt;在解决方案根目录执行以下命令：&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;section style=&quot;text-align: left;&quot;&gt;&lt;img data-src=&quot;https://mmbiz.qpic.cn/mmbiz_png/W03YkxiaHL9MH7BQJKYULbSejPytoN44icicjzjn8zKD5Q8qyO2KqdZmVRqUypzBRGwCIFzgyjcAwSzKnq50ovK5yC9E0OvPvK5mnjZ5Qe5qVg/640?wx_fmt=png&amp;amp;from=appmsg&amp;amp;watermark=1#imgIndex=9&quot; class=&quot;rich_pages wxw-img&quot; data-ratio=&quot;0.19285714285714287&quot; data-s=&quot;300,640&quot; data-type=&quot;png&quot; data-w=&quot;700&quot; type=&quot;block&quot; data-imgfileid=&quot;100001254&quot; data-aistatus=&quot;1&quot; data-original-style=&quot;null&quot; data-index=&quot;9&quot; src=&quot;https://mmbiz.qpic.cn/mmbiz_png/W03YkxiaHL9MH7BQJKYULbSejPytoN44icicjzjn8zKD5Q8qyO2KqdZmVRqUypzBRGwCIFzgyjcAwSzKnq50ovK5yC9E0OvPvK5mnjZ5Qe5qVg/640?wx_fmt=png&amp;from=appmsg&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1&amp;watermark=1#imgIndex=9&quot; _width=&quot;677px&quot; __sec_open_place_holder__=&quot;true&quot; style=&quot;height: auto !important; visibility: visible !important; width: 677px !important;&quot; alt=&quot;图片&quot; data-before-load-time=&quot;1780018578999&quot; data-report-img-idx=&quot;9&quot; data-fail=&quot;0&quot;/&gt;&lt;/section&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__271&quot;&gt;&lt;span class=&quot;js_darkmode__text__272&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__273&quot;&gt;部署完成后，访问&lt;/span&gt;&lt;/span&gt;&lt;code style=&quot;color: rgb(31, 35, 41);font: 400 16px / 24px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace;white-space: normal;display: inline;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);&quot; data-pm-slice=&quot;0 0 []&quot; class=&quot;js_darkmode__81 js_darkmode__text__274&quot;&gt;&lt;span class=&quot;js_darkmode__text__275&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__276&quot;&gt;http://localhost/swagger&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;span class=&quot;js_darkmode__text__277&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__278&quot;&gt;即可查看并测试所有 API 接口。&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;/p&gt;&lt;hr style=&quot;border-style: solid;border-width: 1px 0 0;border-color: rgba(0,0,0,0.1);-webkit-transform-origin: 0 0;-webkit-transform: scale(1, 0.5);transform-origin: 0 0;transform: scale(1, 0.5);&quot; class=&quot;js_darkmode__82&quot;/&gt;&lt;p&gt;&lt;section style=&quot;text-align: left;&quot;&gt;&lt;br/&gt;&lt;/section&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__279&quot;&gt;&lt;span class=&quot;js_darkmode__text__280&quot;&gt;&lt;span style=&quot;font-size: 20px;font-weight: bold;&quot; class=&quot;js_darkmode__text__281&quot;&gt;六、生产环境优化建议&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;/p&gt;&lt;ol style=&quot;list-style-type: decimal;&quot; class=&quot;js_darkmode__text__282 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;strong style=&quot;color: rgb(31, 35, 41);font: 700 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;font-size: 16px;font-weight: 700;line-height: 24px;text-align: left;white-space: normal;display: inline;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box;background-color: rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__84 js_darkmode__text__284&quot;&gt;&lt;span class=&quot;js_darkmode__text__285&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__286&quot;&gt;添加 Redis 缓存&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__287&quot;&gt;&lt;span class=&quot;js_darkmode__text__288&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__289&quot;&gt;：缓存常见问题的回答，大幅降低 AI 调用成本&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong style=&quot;color: rgb(31, 35, 41);font: 700 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;font-size: 16px;font-weight: 700;line-height: 24px;text-align: left;white-space: normal;display: inline;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box;background-color: rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__86 js_darkmode__text__291&quot;&gt;&lt;span class=&quot;js_darkmode__text__292&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__293&quot;&gt;实现请求队列&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__294&quot;&gt;&lt;span class=&quot;js_darkmode__text__295&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__296&quot;&gt;：使用 RabbitMQ 或 Azure Service Queue 处理高并发请求&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong style=&quot;color: rgb(31, 35, 41);font: 700 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;font-size: 16px;font-weight: 700;line-height: 24px;text-align: left;white-space: normal;display: inline;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box;background-color: rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__88 js_darkmode__text__298&quot;&gt;&lt;span class=&quot;js_darkmode__text__299&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__300&quot;&gt;完善监控&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__301&quot;&gt;&lt;span class=&quot;js_darkmode__text__302&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__303&quot;&gt;：集成 Prometheus + Grafana 监控系统性能和 AI 调用指标&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong style=&quot;color: rgb(31, 35, 41);font: 700 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;font-size: 16px;font-weight: 700;line-height: 24px;text-align: left;white-space: normal;display: inline;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box;background-color: rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__90 js_darkmode__text__305&quot;&gt;&lt;span class=&quot;js_darkmode__text__306&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__307&quot;&gt;添加&lt;span class=&quot;&quot;&gt;熔断机制&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__308&quot;&gt;&lt;span class=&quot;js_darkmode__text__309&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__310&quot;&gt;：使用 &lt;span class=&quot;&quot;&gt;Polly&lt;/span&gt; 实现服务熔断和降级，防止级联故障&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong style=&quot;color: rgb(31, 35, 41);font: 700 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;font-size: 16px;font-weight: 700;line-height: 24px;text-align: left;white-space: normal;display: inline;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box;background-color: rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__92 js_darkmode__text__312&quot;&gt;&lt;span class=&quot;js_darkmode__text__313&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__314&quot;&gt;密钥管理&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__315&quot;&gt;&lt;span class=&quot;js_darkmode__text__316&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__317&quot;&gt;：使用 Azure Key Vault 或 AWS Secrets Manager 管理 API 密钥&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;strong style=&quot;color: rgb(31, 35, 41);font: 700 16px / 24px ui-sans-serif, system-ui, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;;font-size: 16px;font-weight: 700;line-height: 24px;text-align: left;white-space: normal;display: inline;flex: 0 1 auto;flex-direction: row;justify-content: normal;align-items: normal;padding: 0px;margin: 0px;background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box;background-color: rgba(0, 0, 0, 0);&quot; class=&quot;js_darkmode__94 js_darkmode__text__319&quot;&gt;&lt;span class=&quot;js_darkmode__text__320&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__321&quot;&gt;日志聚合&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__322&quot;&gt;&lt;span class=&quot;js_darkmode__text__323&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__324&quot;&gt;：使用 &lt;span class=&quot;&quot;&gt;ELK Stack&lt;/span&gt; 或 Seq 统一收集和分析日志&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;section style=&quot;text-align: left;&quot;&gt;&lt;br/&gt;&lt;/section&gt;&lt;/p&gt;&lt;hr style=&quot;border-style: solid;border-width: 1px 0 0;border-color: rgba(0,0,0,0.1);-webkit-transform-origin: 0 0;-webkit-transform: scale(1, 0.5);transform-origin: 0 0;transform: scale(1, 0.5);&quot; class=&quot;js_darkmode__95&quot;/&gt;&lt;p&gt;&lt;section style=&quot;text-align: left;&quot;&gt;&lt;br/&gt;&lt;/section&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__325&quot;&gt;&lt;span class=&quot;js_darkmode__text__326&quot;&gt;&lt;span style=&quot;font-size: 20px;font-weight: bold;&quot; class=&quot;js_darkmode__text__327&quot;&gt;七、项目扩展方向&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;/p&gt;&lt;ul class=&quot;js_darkmode__text__328 list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__330&quot;&gt;&lt;span class=&quot;js_darkmode__text__331&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__332&quot;&gt;集成本地大模型（如 Llama 3、Qwen 2）&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__334&quot;&gt;&lt;span class=&quot;js_darkmode__text__335&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__336&quot;&gt;添加&lt;span class=&quot;&quot;&gt;向量数据库&lt;/span&gt;支持，实现 RAG 知识库问答&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__338&quot;&gt;&lt;span class=&quot;js_darkmode__text__339&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__340&quot;&gt;开发前端管理界面，实现 API 用量统计和用户管理&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__342&quot;&gt;&lt;span class=&quot;js_darkmode__text__343&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__344&quot;&gt;支持多模态输入（图片、语音）&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;li&gt;&lt;section style=&quot;text-align: left;&quot; class=&quot;js_darkmode__text__346&quot;&gt;&lt;span class=&quot;js_darkmode__text__347&quot;&gt;&lt;span style=&quot;font-size: 17px;font-weight: normal;&quot; class=&quot;js_darkmode__text__348&quot;&gt;集成函数调用能力，实现 AI 驱动的自动化任务&lt;/span&gt;&lt;/span&gt;&lt;/section&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Fri, 29 May 2026 09:36:04 +0800</pubDate></item></channel></rss>