<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh">
    <title>我的网站</title>
    <subtitle>一个分享和探索想法的地方。</subtitle>
    <link rel="self" type="application/atom+xml" href="https://minsignal.plotsignal.com/zh/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://minsignal.plotsignal.com"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2025-01-03T20:30:00+00:00</updated>
    <id>https://minsignal.plotsignal.com/zh/atom.xml</id>
    <entry xml:lang="zh">
        <title>使用 Husky Git 钩子在提交前运行脚本</title>
        <published>2025-01-03T20:30:00+00:00</published>
        <updated>2025-01-03T20:30:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://minsignal.plotsignal.com/zh/husky-git-hook/"/>
        <id>https://minsignal.plotsignal.com/zh/husky-git-hook/</id>
        
        <content type="html" xml:base="https://minsignal.plotsignal.com/zh/husky-git-hook/">&lt;p&gt;Git 钩子可以帮助你在工作流中自动化一些任务，但手动管理它们可能很麻烦。&lt;strong&gt;&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;typicode.github.io&#x2F;husky&#x2F;&quot;&gt;Husky&lt;&#x2F;a&gt;&lt;&#x2F;strong&gt; 简化了这一过程，让你可以轻松设置钩子，比如预提交检查。以下是结合 &lt;strong&gt;Prettier&lt;&#x2F;strong&gt; 实现提交前代码格式化的操作方法。&lt;&#x2F;p&gt;
&lt;h2 id=&quot;she-zhi-bu-zou&quot;&gt;设置步骤&lt;&#x2F;h2&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;安装 Husky：&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;npx husky init
&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;编辑第一步中创建的 &lt;code&gt;.husky&#x2F;pre-commit&lt;&#x2F;code&gt; 文件：&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;prettier $(git diff --cached --name-only --diff-filter=ACMR | sed &amp;#x27;s| |\\ |g&amp;#x27;) --write --ignore-unknown
git update-index --again
&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;h3 id=&quot;jie-shi&quot;&gt;解释：&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;git diff --cached --name-only --diff-filter=ACMR&lt;&#x2F;code&gt;&lt;&#x2F;strong&gt;：列出已暂存的新增、修改、重命名或复制的文件。&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;sed &#x27;s| |\\ |g&#x27;&lt;&#x2F;code&gt;&lt;&#x2F;strong&gt;：处理文件名中的空格。&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;prettier --write&lt;&#x2F;code&gt;&lt;&#x2F;strong&gt;：使用 Prettier 格式化文件。&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;--ignore-unknown&lt;&#x2F;code&gt;&lt;&#x2F;strong&gt;：忽略不支持的文件类型或二进制文件。&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;这确保了在提交之前格式化已暂存的文件。&lt;&#x2F;p&gt;
&lt;h2 id=&quot;ce-shi-bu-zou&quot;&gt;测试步骤&lt;&#x2F;h2&gt;
&lt;ol&gt;
&lt;li&gt;使用 &lt;code&gt;git add&lt;&#x2F;code&gt; 暂存更改。&lt;&#x2F;li&gt;
&lt;li&gt;使用 &lt;code&gt;git commit -m &quot;测试&quot;&lt;&#x2F;code&gt; 提交。&lt;&#x2F;li&gt;
&lt;li&gt;Husky 会在提交前自动格式化已暂存的文件。&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;h3 id=&quot;jie-guo&quot;&gt;结果&lt;&#x2F;h3&gt;
&lt;p&gt;下面是一个 Husky 钩子使用 Prettier 格式化 JavaScript 文件的示例：&lt;&#x2F;p&gt;
 &lt;figure class=&quot;fi ci&quot;&gt;&lt;img src=&quot;prettier_js_file.png&quot; class=&quot;ci&quot; alt=&quot;prettier javascript file&quot; width=&quot;1000&quot; height=&quot;438&quot; loading=&quot;lazy&quot; &#x2F;&gt;&lt;figcaption&gt;Prettier Javascript file&lt;&#x2F;figcaption&gt;&lt;&#x2F;figure&gt;
&lt;hr &#x2F;&gt;
&lt;h2 id=&quot;jie-lun&quot;&gt;结论&lt;&#x2F;h2&gt;
&lt;p&gt;Husky 可以帮助你强制执行代码标准并自动化常规任务，让 Git 工作流更高效，代码库更整洁。试试看吧！&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="zh">
        <title>通过安全的联系表单架构对抗垃圾信息</title>
        <published>2024-12-21T12:40:00+00:00</published>
        <updated>2024-12-21T12:40:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://minsignal.plotsignal.com/zh/contact-spam-filter/"/>
        <id>https://minsignal.plotsignal.com/zh/contact-spam-filter/</id>
        
        <content type="html" xml:base="https://minsignal.plotsignal.com/zh/contact-spam-filter/">&lt;p&gt;高效处理垃圾信息是维护安全可靠的联系表单的关键。我的架构结合了 Cloudflare Workers、KV Storage、AWS DynamoDB、SES、S3 和 SNS，实现了安全性与卓越的操作性能。&lt;&#x2F;p&gt;
 &lt;figure class=&quot;fi ci&quot;&gt;&lt;img src=&quot;contact_form_spam_filtering.png&quot; class=&quot;ci&quot; alt=&quot;反垃圾架构&quot; width=&quot;600&quot; height=&quot;918&quot; loading=&quot;lazy&quot; &#x2F;&gt;&lt;figcaption&gt;反垃圾架构&lt;&#x2F;figcaption&gt;&lt;&#x2F;figure&gt;
&lt;p&gt;该架构处理表单提交，检测垃圾信息，警告潜在的垃圾信息发送者，并通过安全方式保存数据和发送通知来处理合法消息。&lt;&#x2F;p&gt;
&lt;hr &#x2F;&gt;
&lt;h2 id=&quot;yan-shi-jie-guo&quot;&gt;演示结果&lt;&#x2F;h2&gt;
&lt;p&gt;好奇效果如何？查看演示：&lt;a rel=&quot;noopener&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;x.com&#x2F;biajia&#x2F;status&#x2F;1867890765860606100&quot;&gt;查看演示&lt;&#x2F;a&gt;&lt;br &#x2F;&gt;
（该演示展示了实时垃圾信息过滤和消息处理。）&lt;&#x2F;p&gt;
&lt;hr &#x2F;&gt;
&lt;p&gt;通过使用上述系统，我们能够确保垃圾信息被彻底阻止，同时合法通信得以顺利处理。该架构会自动警告垃圾信息发送者，并将干净的数据存储以供后续处理。&lt;&#x2F;p&gt;
&lt;hr &#x2F;&gt;
&lt;p&gt;敬请关注更多关于构建现代 Web 应用程序的安全、可扩展系统的见解。&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="zh">
        <title>利用 Azure、GCP、AWS 和 Cloudflare 提供网络服务</title>
        <published>2024-12-07T10:01:00+00:00</published>
        <updated>2024-12-07T10:01:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://minsignal.plotsignal.com/zh/cloud-services/"/>
        <id>https://minsignal.plotsignal.com/zh/cloud-services/</id>
        
        <summary type="html">&lt;p&gt;在快速发展的网络服务领域，选择合适的工具和平台至关重要，它们能决定您的应用是否成功。&lt;&#x2F;p&gt;
</summary>
        
    </entry>
</feed>
