<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Yucol</title>
    <description>个人的一个技术博客站点，主要用于记录个人在学习过程中遇到的技术问题及解决方法、以及一些比较有趣的事情。</description>
    <link>https://yucol.top//</link>
    <atom:link href="https://yucol.top/feed.xml" rel="self" type="application/rss+xml" />
    <pubDate>Sat, 04 Apr 2026 02:25:31 +0000</pubDate>
    <lastBuildDate>Sat, 04 Apr 2026 02:25:31 +0000</lastBuildDate>
    <generator>Jekyll v4.4.1</generator>
    
      <item>
        <title>我的现场编年史：不只是听歌！</title>
        <description>&lt;h1 id=&quot;-我的演唱会流浪计划&quot;&gt;🚀 我的演唱会流浪计划&lt;/h1&gt;

&lt;hr /&gt;
&lt;h3 id=&quot;-no001--房东的猫---世界青年-2024巡回演唱会&quot;&gt;🎵 NO.[001] | [房东的猫] - [世界/青年 2024巡回演唱会]&lt;/h3&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;📅 时间：&lt;/strong&gt; 2024 年 06 月 29 日&lt;br /&gt;
&lt;strong&gt;📍 地点：&lt;/strong&gt; [北京] · [首都体育馆]&lt;br /&gt;
&lt;strong&gt;🎫 座位：&lt;/strong&gt; [ 看台山顶 ]
&lt;strong&gt;🏷️ 关键词：&lt;/strong&gt; #第一次演唱会 #合唱 #太治愈了&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4 id=&quot;1--content&quot;&gt;1. 📜 Content&lt;/h4&gt;

&lt;p&gt;到北京上学后，有机会看到了人生中的第一次演唱会。那个周末是最开心的时候（周六听房东的猫，周日看成果🥳），从此激起了对演唱会的热爱。&lt;del&gt;直到现在工作后的平淡无趣&lt;/del&gt;&lt;/p&gt;

&lt;h4 id=&quot;2--memory&quot;&gt;2. 📸 Memory&lt;/h4&gt;

&lt;p&gt;&lt;img src=&quot;https://img.yucol.uk/2026/02/03c35fc6b5402510d671a28704338784.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/b08933f2fec09709c5e4ce5c72c7b710.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/6dc51b2e507b801b2d4e1237202e5d50.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/4f880cf7da00e9bf01004dac6542c814.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/ecfa47753c2c0d15679f02a36afb924c.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/eb23d7c5e5d14d200732fbcd4574e803.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/6af2fb0d633f677461f94a63cc649083.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/52158116f13f17fac1f55f5cc1313a47.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/04d872bbc0a16cfc83e5431853dbd6e4.webp&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;3--个人评分&quot;&gt;3. ⭐ 个人评分&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;曲目编排：&lt;/strong&gt; ⭐⭐⭐⭐⭐&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;舞美视听：&lt;/strong&gt; ⭐⭐⭐⭐⭐&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;歌手状态：&lt;/strong&gt; ⭐⭐⭐⭐⭐&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;推荐指数：&lt;/strong&gt; ⭐⭐⭐⭐⭐&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;综合评分：&lt;/strong&gt; ⭐⭐⭐⭐⭐&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;
&lt;h3 id=&quot;-no002--成果---海王星飞船&quot;&gt;🎵 NO.[002] | [成果] - [海王星飞船]&lt;/h3&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;📅 时间：&lt;/strong&gt; 2024 年 06 月 30 日&lt;br /&gt;
&lt;strong&gt;📍 地点：&lt;/strong&gt; [北京] · [晓剧场]&lt;br /&gt;
&lt;strong&gt;🎫 座位：&lt;/strong&gt; [ 3排 16号 ]&lt;br /&gt;
&lt;strong&gt;🏷️ 关键词：&lt;/strong&gt; #音乐 #舞台剧 #合影（线下真实版）&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4 id=&quot;1--content-1&quot;&gt;1. 📜 Content&lt;/h4&gt;

&lt;p&gt;狗哥的第一次舞台剧（成年儿童版😄），虽然不是演唱会，但却是第一次线下见面。&lt;/p&gt;

&lt;h4 id=&quot;2--memory-1&quot;&gt;2. 📸 Memory&lt;/h4&gt;

&lt;p&gt;&lt;img src=&quot;https://img.yucol.uk/2026/02/09010902d25eba6b5e0d4c03d192dc18.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/3a61aeeadff176eade7bf7c7a1ffafbe.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/71176807134ee73c254b0ae91fe8f165.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/25f11ae3934295c98afea56033a64f2c.webp&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;3--个人评分-1&quot;&gt;3. ⭐ 个人评分&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;曲目编排：&lt;/strong&gt; ⭐⭐⭐⭐⭐&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;舞美视听：&lt;/strong&gt; ⭐⭐⭐⭐⭐&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;演员状态：&lt;/strong&gt; ⭐⭐⭐⭐⭐&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;推荐指数：&lt;/strong&gt; ⭐⭐⭐⭐⭐&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;综合评分：&lt;/strong&gt; ⭐⭐⭐⭐⭐&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;-no003--夏日入侵企画---温暖人心的冬日聚会-不插电特别专场&quot;&gt;🎵 NO.[003] | [夏日入侵企画] - [温暖人心的冬日聚会-不插电特别专场]&lt;/h3&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;📅 时间：&lt;/strong&gt; 2024 年 12 月 26 日&lt;br /&gt;
&lt;strong&gt;📍 地点：&lt;/strong&gt; [北京] · [福浪LIVEHOUSE-福]&lt;br /&gt;
&lt;strong&gt;🎫 座位：&lt;/strong&gt; [ Live House ]
&lt;strong&gt;🏷️ 关键词：&lt;/strong&gt; #欢乐 #蹦迪 #近距离&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4 id=&quot;1--content-2&quot;&gt;1. 📜 Content&lt;/h4&gt;

&lt;p&gt;首次参加live house，夏企的魅力太足了，从开头蹦到结尾！我去的比较早，所以抢到了比较靠前的位置 &lt;del&gt;（早去早罚站）&lt;/del&gt;。&lt;/p&gt;

&lt;h4 id=&quot;2--memory-2&quot;&gt;2. 📸 Memory&lt;/h4&gt;

&lt;p&gt;&lt;img src=&quot;https://img.yucol.uk/2026/02/d30bfd4a68f4dc0b0ae8ea722758091e.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/9ce5697d3c3a05e611248f2a1756fb61.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/a07dfafb65d1067e68bacb9cb98fb3e2.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/9214b0d4ecb795c553c7a016c6e0502f.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/0423acd25e4b2249b3d44caadcbe9d6a.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/510149ef4a309514aba2e355bde0f8e8.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/fb7ee9c7157b2475f11d861938ce9642.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/e550a42cc6d94c5b7866bfebdd73e16e.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/15218fcce6159777c7985751a353f7b6.webp&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;3--个人评分-2&quot;&gt;3. ⭐ 个人评分&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;曲目编排：&lt;/strong&gt; ⭐⭐⭐⭐⭐&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;舞美视听：&lt;/strong&gt; ⭐⭐⭐⭐⭐&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;歌手状态：&lt;/strong&gt; ⭐⭐⭐⭐⭐&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;推荐指数：&lt;/strong&gt; ⭐⭐⭐⭐⭐&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;综合评分：&lt;/strong&gt; ⭐⭐⭐⭐⭐&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;-no004--双笙---经过时你我相遇&quot;&gt;🎵 NO.[004] | [双笙] - [经过时你我相遇]&lt;/h3&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;📅 时间：&lt;/strong&gt; 2024 年 12 月 30 日&lt;br /&gt;
&lt;strong&gt;📍 地点：&lt;/strong&gt; [北京] · [北京展览馆剧场]&lt;br /&gt;
&lt;strong&gt;🎫 座位：&lt;/strong&gt; [ 一层 27排 74号 ]
&lt;strong&gt;🏷️ 关键词：&lt;/strong&gt; #国风 #老粉&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4 id=&quot;1--content-3&quot;&gt;1. 📜 Content&lt;/h4&gt;

&lt;p&gt;大学时特别喜欢&lt;strong&gt;双笙&lt;/strong&gt;的歌曲，声音清甜，歌曲时而温柔，时而清脆。这次演唱会开到了北京，终于有机会可以现场听她唱的歌。&lt;/p&gt;

&lt;p&gt;现场的人数没有满座，但是也有很多人来捧场，上次关注双笙的时间我已经记不清了，我的记忆里还是她之前唱过的歌，所以演唱会上很多歌我都不太熟悉，算是个小遗憾吧。&lt;/p&gt;

&lt;h4 id=&quot;2--memory-3&quot;&gt;2. 📸 Memory&lt;/h4&gt;

&lt;p&gt;&lt;img src=&quot;https://img.yucol.uk/2026/02/57e8bbeebc68f673226fc632cdf1af5e.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/7dc997c6941d520ae27eaa5c99089d9d.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/9d43b58f0aabe1f2cf45910caa1d968f.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/bf662e347ad4267f56099d337ac1e3d1.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/5cbd4184524954e55f8c0aa403f5a525.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/3d11d108aab3971c2f81224e7eedbd07.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/9b495142e3b4af457bd9bdcd9123036a.webp&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;3--个人评分-3&quot;&gt;3. ⭐ 个人评分&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;曲目编排：&lt;/strong&gt; ⭐⭐⭐⭐&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;舞美视听：&lt;/strong&gt; ⭐⭐⭐⭐&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;歌手状态：&lt;/strong&gt; ⭐⭐⭐⭐⭐&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;推荐指数：&lt;/strong&gt; ⭐⭐⭐⭐⭐&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;综合评分：&lt;/strong&gt; ⭐⭐⭐⭐⭐&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;-no005--张杰---未live---开往1982&quot;&gt;🎵 NO.[005] | [张杰] - [未·LIVE - 开往1982]&lt;/h3&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;📅 时间：&lt;/strong&gt; 2025 年 04 月 19 日&lt;br /&gt;
&lt;strong&gt;📍 地点：&lt;/strong&gt; [北京] · [国家体育场-鸟巢]&lt;br /&gt;
&lt;strong&gt;🎫 座位：&lt;/strong&gt; [ G区 529通道 五层 19排 25号 ]
&lt;strong&gt;🏷️ 关键词：&lt;/strong&gt; #逆战 #哪个男孩子不想现场听张杰唱逆战 #直接给到夯&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4 id=&quot;1--content-4&quot;&gt;1. 📜 Content&lt;/h4&gt;

&lt;p&gt;遥想12年的夏天，我拥有了人生中的第一台电脑，第一件事就是把《逆战》（游戏）下载下来。无他，因为&lt;strong&gt;逆战&lt;/strong&gt;这首歌在当时就是现在小学生心目中的&lt;strong&gt;孤勇者&lt;/strong&gt;。&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;张杰&lt;/strong&gt;的演唱会真的太顶了，不论是氛围、嗓音、歌曲、编舞、音效还是灯光都是无敌的存在！&lt;/p&gt;

&lt;p&gt;还有个小插曲，演唱会结束后发现我的一位初中同学和另一位朋友竟然和我一块在现场。&lt;/p&gt;

&lt;h4 id=&quot;2--memory-4&quot;&gt;2. 📸 Memory&lt;/h4&gt;

&lt;p&gt;&lt;img src=&quot;https://img.yucol.uk/2026/02/b28c1685eb4743eb21ab2986f0750d45.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/842b5b707b6db0d659e13a7d292d19b5.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/e99d4ffbce3959249a29e2a1045b4c42.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/fcc01ffc42829688b50d782019e66d6b.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/059de7b30040024af60e69b08e08bfb7.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/a7d38cca39226b693c41a854492baf27.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/aff90d71d1257b3f8520bd1b93f4010e.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/4b18796a1d5883e642d1f1ea8e291307.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/f675fd3bdd93dd46098a61e6e71990fd.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/e29cb6bd399aafca0fb923fe7606e1d2.webp&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;3--个人评分-4&quot;&gt;3. ⭐ 个人评分&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;曲目编排：&lt;/strong&gt; ⭐⭐⭐⭐⭐&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;舞美视听：&lt;/strong&gt; ⭐⭐⭐⭐⭐&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;歌手状态：&lt;/strong&gt; ⭐⭐⭐⭐⭐&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;推荐指数：&lt;/strong&gt; ⭐⭐⭐⭐⭐&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;综合评分：&lt;/strong&gt; ⭐⭐⭐⭐⭐&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;-no006--凤凰传奇---吉祥如意&quot;&gt;🎵 NO.[006] | [凤凰传奇] - [吉祥如意]&lt;/h3&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;📅 时间：&lt;/strong&gt; 2025 年 05 月 24 日&lt;br /&gt;
&lt;strong&gt;📍 地点：&lt;/strong&gt; [北京] · [国家体育场-鸟巢]&lt;br /&gt;
&lt;strong&gt;🎫 座位：&lt;/strong&gt; [ H区 635通道 六层 26排 7~10号 ]
&lt;strong&gt;🏷️ 关键词：&lt;/strong&gt; #组队看演唱会 #蹦迪&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4 id=&quot;1--content-5&quot;&gt;1. 📜 Content&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;这一次，四人终于抵达了他们忠诚的鸟巢！&lt;/strong&gt;&lt;/p&gt;

&lt;h4 id=&quot;2--memory-5&quot;&gt;2. 📸 Memory&lt;/h4&gt;

&lt;p&gt;&lt;img src=&quot;https://img.yucol.uk/2026/02/a54d93c781ef47f0f8ddb1637ebb7a2b.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/94c0b136f85d70fb02f49b208070b8d5.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/f2ed607b6e326f2e5b7fe388a869bce0.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/4a0e4c8c8e75c6e242ebb87f62eaf6e5.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/07b83a6cf11f23014e9c68704b1b2baa.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/f657397dad165ca1f5e1d670ef46e4a4.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/5b56bd318c476f65dce021c7b070b500.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/5fdc7c1d644c05f1148a86bbcdf9e8fb.webp&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;3--个人评分-5&quot;&gt;3. ⭐ 个人评分&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;曲目编排：&lt;/strong&gt; ⭐⭐⭐⭐⭐&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;舞美视听：&lt;/strong&gt; ⭐⭐⭐⭐⭐&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;歌手状态：&lt;/strong&gt; ⭐⭐⭐⭐⭐&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;推荐指数：&lt;/strong&gt; ⭐⭐⭐⭐⭐&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;综合评分：&lt;/strong&gt; ⭐⭐⭐⭐⭐&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;-no007--房东的猫---世界青年---2025巡回演唱会--南京站&quot;&gt;🎵 NO.[007] | [房东的猫] - [世界/青年 - 2025巡回演唱会- 南京站]&lt;/h3&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;📅 时间：&lt;/strong&gt; 2025 年 06 月 14 日&lt;br /&gt;
&lt;strong&gt;📍 地点：&lt;/strong&gt; [南京] · [南京奥体中心国缘V9体育馆]&lt;br /&gt;
&lt;strong&gt;🎫 座位：&lt;/strong&gt; [ 看台六十五区 看台6F 3排 4座 ]
&lt;strong&gt;🏷️ 关键词：&lt;/strong&gt; #毕业旅行&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4 id=&quot;1--content-6&quot;&gt;1. 📜 Content&lt;/h4&gt;

&lt;p&gt;临近毕业的阶段，买到了南京站的🎫（卡点抢的票，结果后面打折卖，可恶的大麦！）。下午去参加粉丝活动的时候认识了一位南林大的新朋友，从而使这段旅程没有太过“安静”。晚上演唱会结束后下起了暴雨⛈️，没有带伞，而免费雨披也送完了，所以就做了一次“雨中追雨的少年”，回到酒店后衣服都湿透了。&lt;/p&gt;

&lt;p&gt;之后在南京玩了三天，美丽的南京，去了还想去。“旅途”最后两天去了上海找我同学，25岁第一次踏上了我曾梦想去的城市-上海。&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;无论在何处，祝你美梦成真&lt;/strong&gt;&lt;/p&gt;

&lt;h4 id=&quot;2--memory-6&quot;&gt;2. 📸 Memory&lt;/h4&gt;

&lt;p&gt;&lt;img src=&quot;https://img.yucol.uk/2026/02/ad24a56a290d4ba114b755465661b09c.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/2dd6aa01f510c8f605d047e7eebe001d.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/ab9644a46148cdcdd090204fbb04c5fd.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/224605f108ac8205dd767e3e2648de3a.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/7cd6790b2ac8938c8946256479b8900c.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/7a6ee0db182e98c183e92d16f8789ac4.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/9e7136d0f5a64e093ad0de3ef28b3e00.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/7c16fa33c0b4fa5d95c7426d335a7dbf.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/e4283321f950066abf9d43c24fdd106b.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/51341cf870e66bd1fdf1bd95a36b4795.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/1beaa9477f2f0363afb028cec83299f5.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/c92e27acfc7c79442ea914015072e09c.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/71e01ee963fa31b66f11df3247abed7a.webp&quot; alt=&quot;&quot; /&gt;
&lt;img src=&quot;https://img.yucol.uk/2026/02/4ddd9f16a8e1802cf77421aa868e0b05.webp&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;3--个人评分-6&quot;&gt;3. ⭐ 个人评分&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;曲目编排：&lt;/strong&gt; ⭐⭐⭐⭐⭐&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;舞美视听：&lt;/strong&gt; ⭐⭐⭐⭐⭐&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;歌手状态：&lt;/strong&gt; ⭐⭐⭐⭐⭐&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;推荐指数：&lt;/strong&gt; ⭐⭐⭐⭐⭐&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;综合评分：&lt;/strong&gt; ⭐⭐⭐⭐⭐&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;
</description>
        <pubDate>Wed, 25 Feb 2026 04:00:00 +0000</pubDate>
        <link>https://yucol.top/life/concert.html</link>
        <guid isPermaLink="true">https://yucol.top/life/concert.html</guid>
        
        <category>演唱会</category>
        
        <category>房东的猫</category>
        
        <category>成果</category>
        
        <category>夏日入侵企画</category>
        
        <category>双笙</category>
        
        <category>张杰</category>
        
        <category>凤凰传奇</category>
        
        
        <category>life</category>
        
      </item>
    
      <item>
        <title>从零到一：阿里云 200M 带宽服务器的全栈基建（1Panel + Docker + GitHub Actions）</title>
        <description>&lt;h1 id=&quot;1-前言为什么放弃手动搬运&quot;&gt;1. 前言：为什么放弃“手动搬运”？&lt;/h1&gt;

&lt;p&gt;在拥有了自己的服务器后，第一反应是手动上传文件。但这存在三个弊端：&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;效率低&lt;/strong&gt;：改一个字也要开一遍 FTP。&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;易出错&lt;/strong&gt;：容易漏传或传错目录。&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;无版本控制&lt;/strong&gt;：无法回溯历史。
本篇记录如何利用 &lt;strong&gt;GitHub Actions&lt;/strong&gt; 打造一条自动化流水线，实现“本地代码一推，服务器即刻更新”。&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h1 id=&quot;2-环境说明&quot;&gt;2. 环境说明&lt;/h1&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;服务器&lt;/strong&gt;：阿里云 2核2G / 200M 带宽 / Ubuntu 系统。&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;运维面板&lt;/strong&gt;：1Panel（基于 Docker 的现代化管理面板）。&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;静态引擎&lt;/strong&gt;：Jekyll (Ruby 3.4.4)。&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;部署通道&lt;/strong&gt;：SSH + Rsync。&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h1 id=&quot;3-核心步骤详解&quot;&gt;3. 核心步骤详解&lt;/h1&gt;

&lt;h2 id=&quot;第一步服务器基建-1panel&quot;&gt;第一步：服务器基建 (1Panel)&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;安装 1Panel 并在应用商店安装 &lt;strong&gt;OpenResty&lt;/strong&gt;（Nginx 的增强版）。&lt;/li&gt;
  &lt;li&gt;在“网站”菜单下创建一个静态网站。&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;路径&lt;/strong&gt;：&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/opt/1panel/apps/openresty/openresty/www/sites/test/index&lt;/code&gt;（此路径为后期同步的目标 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;TARGET&lt;/code&gt;）。&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
  &lt;li&gt;确保服务器防火墙已开启 80/443 端口，以及 SSH 通讯所需的 22 端口。&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;第二步建立信任关系-ssh-key&quot;&gt;第二步：建立“信任关系” (SSH Key)&lt;/h2&gt;

&lt;p&gt;为了让 GitHub 机器人能直接登录我们的服务器，需要配置免密登录：&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;本地生成密钥对&lt;/strong&gt;：
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ssh-keygen -t rsa -b 4096 -f id_rsa_github&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;分发公钥&lt;/strong&gt;：将 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;id_rsa_github.pub&lt;/code&gt; 的内容追加到服务器的 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/root/.ssh/authorized_keys&lt;/code&gt; 中。&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;权限加固&lt;/strong&gt;：确保 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.ssh&lt;/code&gt; 目录权限为 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;700&lt;/code&gt;，&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;authorized_keys&lt;/code&gt; 权限为 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;600&lt;/code&gt;。&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;第三步配置-github-secrets&quot;&gt;第三步：配置 GitHub Secrets&lt;/h2&gt;

&lt;p&gt;在 GitHub 仓库的 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Settings -&amp;gt; Secrets and variables -&amp;gt; Actions&lt;/code&gt; 中配置四个关键变量：&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;REMOTE_HOST&lt;/code&gt;: 服务器公网 IP。&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;REMOTE_USER&lt;/code&gt;: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;root&lt;/code&gt;。&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SSH_PRIVATE_KEY&lt;/code&gt;: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;id_rsa_github&lt;/code&gt; 文件里的完整私钥内容。&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;REMOTE_TARGET&lt;/code&gt;: 服务器上的静态目录路径。&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;第四步编写自动化流水线-yaml&quot;&gt;第四步：编写自动化流水线 (YAML)&lt;/h2&gt;

&lt;p&gt;在 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.github/workflows/&lt;/code&gt; 下创建 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jekyll.yml&lt;/code&gt;。核心逻辑是利用 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;easingthemes/ssh-deploy&lt;/code&gt; 插件执行 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rsync&lt;/code&gt;。&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# 关键配置摘要&lt;/span&gt;
&lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Deploy to Aliyun Server&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;uses&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;easingthemes/ssh-deploy@v5.1.0&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;SSH_PRIVATE_KEY&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;$&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;ARGS&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;-rltzvi&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;--delete&quot;&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 增量同步，删除服务器多余文件&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;SOURCE&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;_site/&quot;&lt;/span&gt;         &lt;span class=&quot;c1&quot;&gt;# Jekyll 构建后的产物目录&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;REMOTE_HOST&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;$&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;REMOTE_USER&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;$&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;TARGET&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;$&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;h1 id=&quot;4-外部资源集成&quot;&gt;4. 外部资源集成：&lt;/h1&gt;

&lt;p&gt;为了追求极致的性能和稳定性，我并没有将所有功能都死磕在自己的服务器上，而是引入了更成熟的云原生方案：&lt;/p&gt;

&lt;h2 id=&quot;a-评论系统waline--vercel--neon&quot;&gt;A. 评论系统：Waline + Vercel + Neon&lt;/h2&gt;

&lt;p&gt;为了不让评论数据的存储和处理占用阿里云的 2G 内存，我采用了 &lt;strong&gt;Serverless（无服务器）&lt;/strong&gt; 架构：&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;后端部署 (Vercel)&lt;/strong&gt;：利用 Vercel 的免费额度托管 Waline 后端程序。&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;数据库 (Neon)&lt;/strong&gt;：所有的评论内容存储在 Neon 的云数据库中，安全且免费。&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;集成方式&lt;/strong&gt;：在 Jekyll 模板中引入 Waline 的 JS 脚本，通过 API 与 Vercel 通信。&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;深度心得&lt;/strong&gt;：这种方案实现了“数据随人走”，即便我以后重装服务器系统，评论数据也不会丢失。&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;b-极致图床cloudflare-r2--picgo&quot;&gt;B. 极致图床：Cloudflare R2 + PicGo&lt;/h2&gt;

&lt;p&gt;虽然服务器有 200M 带宽，但为了节省宝贵的公网流量以及应对未来可能的并发访问，我搭建了专业的对象存储图床：&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;存储底座 (Cloudflare R2)&lt;/strong&gt;：利用 Cloudflare 的 R2 存储（S3 兼容模式），免流量费且自带全球 CDN 加速。&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;自动化工具 (PicGo)&lt;/strong&gt;：在本地配置 PicGo 插件，实现“截图 -&amp;gt; 上传 -&amp;gt; 自动生成 Markdown 链接”的一键流。&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;安全加固 (V2 签名)&lt;/strong&gt;：使用 V2 签名机制确保上传接口的安全，防止图床被恶意盗刷。&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h1 id=&quot;5-未来扩展&quot;&gt;5. 未来扩展：&lt;/h1&gt;

&lt;p&gt;目前的基建仅完成了博客的部署。后续计划：&lt;/p&gt;

&lt;ul class=&quot;task-list&quot;&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; /&gt;&lt;strong&gt;后端 API&lt;/strong&gt;：在 1Panel 中使用 Docker 部署 Python (FastAPI) 容器。&lt;/li&gt;
  &lt;li class=&quot;task-list-item&quot;&gt;&lt;input type=&quot;checkbox&quot; class=&quot;task-list-item-checkbox&quot; disabled=&quot;disabled&quot; /&gt;&lt;strong&gt;移动端联调&lt;/strong&gt;：Kotlin 开发的安卓 App 通过 HTTP 请求调用服务器 IP 上的 Python 接口，实现数据上云。&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Wed, 25 Feb 2026 00:00:00 +0000</pubDate>
        <link>https://yucol.top/server/server-setup.html</link>
        <guid isPermaLink="true">https://yucol.top/server/server-setup.html</guid>
        
        <category>服务器</category>
        
        <category>GitHub Actions</category>
        
        <category>blog</category>
        
        
        <category>server</category>
        
      </item>
    
      <item>
        <title>我的第一款酒局神器App“摇了么”</title>
        <description>&lt;h1 id=&quot;-我的第一款酒局神器app摇了么诞生记&quot;&gt;🚀 我的第一款酒局神器App“摇了么”诞生记！&lt;/h1&gt;

&lt;blockquote&gt;
  &lt;p&gt;源代码、安装包及效果图在文章结尾处。&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;一直想做一个既好玩又实用的东西。终于，在AI的帮助下，我的第一款 Android 独立应用——&lt;strong&gt;“摇了么”&lt;/strong&gt;，正式诞生啦！&lt;/p&gt;

&lt;p&gt;这是一款专为酒局、聚会打造的摇骰子小工具。虽然市面上有很多类似的小程序，但作为一个强迫症+体验控，决定亲自操刀，给它注入真正的“灵魂”。&lt;/p&gt;

&lt;h3 id=&quot;-为什么叫摇了么&quot;&gt;🎲 为什么叫“摇了么”？&lt;/h3&gt;

&lt;p&gt;在酒桌上，最常听到的一句话可能就是“该你了，摇了么？”。这个名字既是对朋友的催促，也是这款 App 核心交互的体现——别点屏幕了，直接拿起手机摇吧！&lt;/p&gt;

&lt;h3 id=&quot;-核心亮点把细节死磕到底&quot;&gt;✨ 核心亮点：把细节死磕到底&lt;/h3&gt;

&lt;p&gt;在体验上主要有以下亮点：&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;告别反人类UI，单手掌控全局：&lt;/strong&gt;
抛弃了早期版本中需要呼出软键盘来输入骰子数量的繁琐设计。利用线性布局（LinearLayout）的权重属性，将核心视觉区（骰子展示）固定在中上方，而在底部手指出没的最舒适区域，加入了丝滑的 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-&lt;/code&gt; 和 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;+&lt;/code&gt; 按钮。1到15个骰子，单手一秒切换。&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;注入灵魂的“物理外挂”（摇一摇）：&lt;/strong&gt;
酒局游戏，怎么能只用手指点按钮呢？调用了 Android 的底层硬件——&lt;strong&gt;加速度传感器 (Accelerometer)&lt;/strong&gt;。通过计算 X、Y、Z 三个维度的综合重力加速度，只要你像握着真实骰盅一样用力甩动手机，代码就会自动捕捉你的动作并触发掷骰子！&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;沉浸式的声感与触觉反馈：&lt;/strong&gt;
为了模拟真实的物理反馈，加入了双重感官刺激：
    &lt;ol&gt;
      &lt;li&gt;&lt;strong&gt;听觉&lt;/strong&gt;：接入 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MediaPlayer&lt;/code&gt;，摇晃时伴随清脆的“哗啦哗啦”骰子碰撞声。&lt;/li&gt;
      &lt;li&gt;&lt;strong&gt;触觉&lt;/strong&gt;：调用 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Vibrator&lt;/code&gt; 震动马达。在骰子滚动的 1 秒内，配合动画发出极其高频的轻微震动，停住的瞬间来一次重震。闭上眼睛，你手里握着的仿佛就是个真骰盅！&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;安全纯净无广告：&lt;/strong&gt;
代码完全开源，没有任何联网和收集隐私信息的行为；界面干净整洁，没有任何广告及干扰信息！&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;-核心代码-show-me-the-code&quot;&gt;💻 核心代码 (Show Me The Code)&lt;/h3&gt;

&lt;p&gt;这里分享一下“摇了么”最核心的两个逻辑实现：&lt;/p&gt;

&lt;h4 id=&quot;1-如何让手机听懂摇晃传感器逻辑&quot;&gt;1. 如何让手机听懂“摇晃”？(传感器逻辑)&lt;/h4&gt;

&lt;p&gt;这里用到了初中的物理和数学知识 。手机的加速度传感器会实时返回 X、Y、Z 三个轴的受力。们算出它们除以地球重力加速度后的 G 力，然后利用勾股定理  算出综合受力：&lt;/p&gt;

&lt;div class=&quot;language-kotlin highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// 传感器检测到手机运动时自动调用&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;override&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onSensorChanged&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SensorEvent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;?)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;event&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;null&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;isRolling&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;values&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;values&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;z&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;values&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;// 计算加速度，除以地球重力加速度得出 G 力&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;gX&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SensorManager&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;GRAVITY_EARTH&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;gY&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SensorManager&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;GRAVITY_EARTH&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;gZ&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;z&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SensorManager&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;GRAVITY_EARTH&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;// 勾股定理计算综合受力大小&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;gForce&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;sqrt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;gX&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;gX&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;gY&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;gY&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;gZ&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;gZ&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;toDouble&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;toFloat&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;// 阈值设定为 2.7：大约是用力甩一下手机的力度&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;gForce&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;2.7f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;kd&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;now&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;currentTimeMillis&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;// 设置 1 秒的冷却防抖时间&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;now&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;lastShakeTime&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;lastShakeTime&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;now&lt;/span&gt;
                &lt;span class=&quot;c1&quot;&gt;// 模拟用户点击了摇骰子按钮&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;findViewById&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Button&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;R&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;btnRoll&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;performClick&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;2-如何实现逼真的骰子翻滚与触觉反馈&quot;&gt;2. 如何实现逼真的“骰子翻滚”与触觉反馈？&lt;/h4&gt;

&lt;p&gt;为了不让结果显得太突兀，利用安卓自带的 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CountDownTimer&lt;/code&gt; 写了一个 1 秒钟的动画循环。在这 1 秒内，不仅疯狂切换图片、随机倾斜角度，还同步调用了震动马达：&lt;/p&gt;

&lt;div class=&quot;language-kotlin highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// 开始摇骰子动画（持续1000毫秒，每100毫秒刷新一次）&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;object&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;CountDownTimer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;override&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onTick&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;millisUntilFinished&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Long&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;view&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;diceViews&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;// 随机切图并赋予 -30 到 30 度的随机倾斜角&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;setImageResource&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;diceImages&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Random&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;nextInt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)])&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rotation&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Random&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;nextInt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;toFloat&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// 摇晃过程中：触发 20 毫秒的极轻微震动（模拟骰子撞击杯壁）&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Build&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;VERSION&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;SDK_INT&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Build&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;VERSION_CODES&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;O&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;vibrator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;vibrate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;VibrationEffect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;createOneShot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;VibrationEffect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;DEFAULT_AMPLITUDE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;vibrator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;vibrate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;override&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onFinish&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;view&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;diceViews&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;// 定格最终点数，并将角度摆正&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;setImageResource&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;diceImages&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Random&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;nextInt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)])&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rotation&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;0f&lt;/span&gt; 
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// 摇晃结束：触发 100 毫秒的重震（模拟落桌定音）&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Build&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;VERSION&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;SDK_INT&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Build&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;VERSION_CODES&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;O&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;vibrator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;vibrate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;VibrationEffect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;createOneShot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;VibrationEffect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;DEFAULT_AMPLITUDE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;vibrator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;vibrate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;isRolling&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;false&lt;/span&gt; 
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;-写在最后&quot;&gt;💡 写在最后&lt;/h3&gt;

&lt;p&gt;如果你也想体验一下这款小工具，或者对源码感兴趣，欢迎讨论与交流！&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;项目地址：&lt;a href=&quot;https://github.com/JMbaozi/PartyDice&quot;&gt;https://github.com/JMbaozi/PartyDice&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;安装包地址：&lt;a href=&quot;https://github.com/JMbaozi/PartyDice/releases/tag/v1.0&quot;&gt;摇了么 v1.0&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;https://youke.xn--y7xa690gmna.cn/s1/2026/02/22/699b03b332e82.webp&quot; alt=&quot;home.jpg&quot; /&gt;&lt;/p&gt;
</description>
        <pubDate>Sun, 22 Feb 2026 13:20:00 +0000</pubDate>
        <link>https://yucol.top/app/PartyDice.html</link>
        <guid isPermaLink="true">https://yucol.top/app/PartyDice.html</guid>
        
        <category>安卓</category>
        
        <category>骰子</category>
        
        <category>游戏</category>
        
        <category>独立开发</category>
        
        
        <category>app</category>
        
      </item>
    
      <item>
        <title>从 H2O 到 H2O-ac：我的博客迁移与填坑笔记</title>
        <description>&lt;h2 id=&quot;前言&quot;&gt;前言&lt;/h2&gt;

&lt;p&gt;博客最初的采用的模板是由&lt;a href=&quot;https://github.com/kaeyleo&quot;&gt;kaeyleo&lt;/a&gt;基于&lt;a href=&quot;https://jekyllrb.com/&quot;&gt;jekyll&lt;/a&gt;开发的&lt;a href=&quot;https://github.com/kaeyleo/jekyll-theme-H2O&quot;&gt;H2O&lt;/a&gt;主题。我在此基础上添加了评论区、友链、归档、音乐播放器、访客记录、目录等功能。但是限于能力有限，写的代码一堆BUG。最近我浏览到了一个基于&lt;a href=&quot;https://github.com/kaeyleo/jekyll-theme-H2O&quot;&gt;H2O&lt;/a&gt;修改的&lt;a href=&quot;https://github.com/zhonger/jekyll-theme-H2O-ac&quot;&gt;H2O-ac&lt;/a&gt;主题，其内容丰富，视觉效果和阅读体验非常好。&lt;/p&gt;

&lt;p&gt;所以我决定对博客进行了一次“大手术”，将原本一直使用的H2O模板替换成了目前视觉效果非常出色的 &lt;strong&gt;H2O-ac&lt;/strong&gt; 主题。&lt;/p&gt;

&lt;p&gt;虽然 H2O-ac 带来了极佳的阅读体验和学术风界面，但在迁移和配置自动化的过程中，我遇到了不少令人头大的 Bug。&lt;/p&gt;

&lt;p&gt;为了方便日后查阅，也为了给同样使用该主题的小伙伴提供参考，特写下这篇笔记。&lt;/p&gt;

&lt;h2 id=&quot;迁移过程从手动到全自动&quot;&gt;迁移过程：从手动到全自动&lt;/h2&gt;

&lt;p&gt;最初的迁移并不顺利，旧模板留下的残留文件（如 Azure 的部署脚本等）频繁导致构建失败。&lt;/p&gt;

&lt;h3 id=&quot;1-自动化-cicd-的重建&quot;&gt;1. 自动化 CI/CD 的重建&lt;/h3&gt;
&lt;p&gt;为了实现“推送即发布”，我弃用了原本混乱的部署脚本，重新编写了 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.github/workflows/jekyll.yml&lt;/code&gt;。通过以下逻辑确保了环境的纯净：&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;环境初始化&lt;/strong&gt;：使用 Ruby 3.4.4 环境。&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;强制清理&lt;/strong&gt;：在编译前运行 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bundle exec jekyll clean&lt;/code&gt;。&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;强制覆盖&lt;/strong&gt;：发布到 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gh-pages&lt;/code&gt; 分支时使用 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;force_orphan: true&lt;/code&gt;，彻底杜绝旧文件缓存。&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;2-版权与开源协议&quot;&gt;2. 版权与开源协议&lt;/h3&gt;
&lt;p&gt;由于 H2O-ac 是基于 H2O 主题的 fork 版本，遵循 &lt;strong&gt;MIT 开源协议&lt;/strong&gt;。在迁移过程中，我保留了原作者的版权信息。&lt;/p&gt;

&lt;h2 id=&quot;遇到的问题与-bug-排查重点&quot;&gt;遇到的问题与 Bug 排查（重点）&lt;/h2&gt;

&lt;p&gt;这次迁移最核心的挑战在于：文章在标签（Tags）页能看，但在首页（Blog）和归档（Archives）页却神秘失踪。经过反复排查，我定位到了以下几个“元凶”：&lt;/p&gt;

&lt;h3 id=&quot;bug-1pin-false-逻辑陷阱&quot;&gt;Bug 1：&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pin: false&lt;/code&gt; 逻辑陷阱&lt;/h3&gt;
&lt;p&gt;这是最难发现的一个点。H2O-ac 主题自带了置顶功能，但我发现：&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;当我在文章头部显式写下 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pin: false&lt;/code&gt; 时，首页和归档页会完全无法显示该文章。&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;解决方案&lt;/strong&gt;：普通文章直接&lt;strong&gt;删除 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pin&lt;/code&gt; 属性&lt;/strong&gt;即可。如果不置顶，就不要写这一行，写成 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;false&lt;/code&gt; 反而会被主题逻辑误判并过滤掉。&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;bug-2分支挂载错位&quot;&gt;Bug 2：分支挂载错位&lt;/h3&gt;
&lt;p&gt;在 GitHub Pages 设置中，如果将部署源选为 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;master&lt;/code&gt;，可能无法看到经过 Actions 机器人编译后的成品。&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;解决方法&lt;/strong&gt;：将 GitHub Pages 的部署分支切换到 &lt;strong&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gh-pages&lt;/code&gt;&lt;/strong&gt;，这才是机器人存放 HTML 成品的地方。&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;参考文档&quot;&gt;参考文档&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/zhonger/jekyll-theme-H2O-ac&quot;&gt;H2O-ac主题仓库&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://lisz.me/tech/new-theme-h2o-ac&quot;&gt;H2O-ac主题介绍&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://h2o-ac-doc.lisz.me/&quot;&gt;H2O-ac主题文档&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;结语&quot;&gt;结语&lt;/h2&gt;

&lt;p&gt;感谢 H2O 系列主题的作者们提供的优秀代码。&lt;/p&gt;
</description>
        <pubDate>Sun, 22 Feb 2026 00:00:00 +0000</pubDate>
        <link>https://yucol.top/blog/blog-migration-notes.html</link>
        <guid isPermaLink="true">https://yucol.top/blog/blog-migration-notes.html</guid>
        
        <category>Jekyll</category>
        
        <category>GitHub Actions</category>
        
        <category>填坑</category>
        
        <category>blog</category>
        
        
        <category>blog</category>
        
      </item>
    
      <item>
        <title>HTTP 状态码</title>
        <description>&lt;h1 id=&quot;http-状态码完全指南详解版&quot;&gt;HTTP 状态码完全指南（详解版）&lt;/h1&gt;

&lt;blockquote&gt;
  &lt;p&gt;一篇面向 &lt;strong&gt;Web / 后端 / 前端 / GIS Web 应用开发者&lt;/strong&gt; 的 HTTP 状态码系统性参考文章。&lt;/p&gt;
&lt;/blockquote&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;一什么是-http-状态码&quot;&gt;一、什么是 HTTP 状态码&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;HTTP 状态码（HTTP Status Code）&lt;/strong&gt; 是服务器在响应客户端（浏览器、APP、程序）请求时，返回的一个 &lt;strong&gt;三位数字&lt;/strong&gt;，用于说明：&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;👉 &lt;strong&gt;这次请求发生了什么、结果如何、是否需要进一步操作&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;HTTP 状态码是 &lt;strong&gt;HTTP 协议语义的核心组成部分&lt;/strong&gt;，对于：&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;前后端接口设计&lt;/li&gt;
  &lt;li&gt;RESTful API 规范&lt;/li&gt;
  &lt;li&gt;错误处理与调试&lt;/li&gt;
  &lt;li&gt;网络性能与安全分析&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;都具有非常重要的意义。&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;二http-状态码的五大类&quot;&gt;二、HTTP 状态码的五大类&lt;/h2&gt;

&lt;p&gt;HTTP 状态码按照 &lt;strong&gt;首位数字&lt;/strong&gt; 分为五大类：&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&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;1xx&lt;/td&gt;
      &lt;td&gt;100–199&lt;/td&gt;
      &lt;td&gt;信息性响应（请求已接收）&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2xx&lt;/td&gt;
      &lt;td&gt;200–299&lt;/td&gt;
      &lt;td&gt;成功（请求已成功处理）&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;3xx&lt;/td&gt;
      &lt;td&gt;300–399&lt;/td&gt;
      &lt;td&gt;重定向（需要进一步操作）&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;4xx&lt;/td&gt;
      &lt;td&gt;400–499&lt;/td&gt;
      &lt;td&gt;客户端错误&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;5xx&lt;/td&gt;
      &lt;td&gt;500–599&lt;/td&gt;
      &lt;td&gt;服务器错误&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;三1xx信息性状态码informational&quot;&gt;三、1xx：信息性状态码（Informational）&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;表示请求已被接收，正在处理，&lt;strong&gt;很少在业务代码中直接使用&lt;/strong&gt;。&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;100-continue&quot;&gt;100 Continue&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;含义：客户端可以继续发送请求体&lt;/li&gt;
  &lt;li&gt;场景：大文件上传前的确认机制&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;101-switching-protocols&quot;&gt;101 Switching Protocols&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;含义：服务器同意切换协议&lt;/li&gt;
  &lt;li&gt;场景：HTTP → WebSocket&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;四2xx成功状态码success&quot;&gt;四、2xx：成功状态码（Success）&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;最重要、最常用的一类状态码&lt;/strong&gt;，表示请求被正确处理。&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;200-ok&quot;&gt;200 OK&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;含义：请求成功&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;场景：&lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;GET 查询成功&lt;/li&gt;
      &lt;li&gt;PUT / PATCH 更新成功&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-http highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;err&quot;&gt;GET /api/fields/123
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;HTTP&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;1.1&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;200&lt;/span&gt; &lt;span class=&quot;ne&quot;&gt;OK&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;201-created&quot;&gt;201 Created&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;含义：资源创建成功&lt;/li&gt;
  &lt;li&gt;场景：POST 新建资源&lt;/li&gt;
  &lt;li&gt;建议：返回新资源的 URL&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-http highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;err&quot;&gt;POST /api/fields
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;HTTP&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;1.1&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;201&lt;/span&gt; &lt;span class=&quot;ne&quot;&gt;Created&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Location&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;/api/fields/456&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;202-accepted&quot;&gt;202 Accepted&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;含义：请求已接收，但尚未处理完成&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;场景：&lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;异步任务&lt;/li&gt;
      &lt;li&gt;后台计算（如 GIS 插值、模型分析）&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;204-no-content&quot;&gt;204 No Content&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;含义：请求成功，但无返回内容&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;场景：&lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;删除成功&lt;/li&gt;
      &lt;li&gt;仅触发动作的接口&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-http highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;err&quot;&gt;DELETE /api/fields/123
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;HTTP&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;1.1&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;204&lt;/span&gt; &lt;span class=&quot;ne&quot;&gt;No Content&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;五3xx重定向状态码redirection&quot;&gt;五、3xx：重定向状态码（Redirection）&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;表示资源位置发生变化，需要客户端采取进一步操作。&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;301-moved-permanently&quot;&gt;301 Moved Permanently&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;含义：永久重定向&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;场景：&lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;域名迁移&lt;/li&gt;
      &lt;li&gt;SEO 优化&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;302-found&quot;&gt;302 Found&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;含义：临时重定向（历史遗留）&lt;/li&gt;
  &lt;li&gt;注意：可能被浏览器当作 GET 请求处理&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;303-see-other&quot;&gt;303 See Other&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;含义：使用 GET 访问另一个 URI&lt;/li&gt;
  &lt;li&gt;场景：POST 后跳转页面&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;304-not-modified&quot;&gt;304 Not Modified&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;含义：资源未修改&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;场景：&lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;浏览器缓存&lt;/li&gt;
      &lt;li&gt;ETag / If-Modified-Since&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;六4xx客户端错误client-error&quot;&gt;六、4xx：客户端错误（Client Error）&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;表示问题出在客户端请求本身&lt;/strong&gt;。&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;400-bad-request&quot;&gt;400 Bad Request&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;含义：请求格式错误&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;常见原因：&lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;JSON 语法错误&lt;/li&gt;
      &lt;li&gt;参数缺失&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;401-unauthorized&quot;&gt;401 Unauthorized&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;含义：未认证&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;特点：&lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;需要登录&lt;/li&gt;
      &lt;li&gt;通常配合 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;WWW-Authenticate&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
  &lt;p&gt;⚠️ 注意：401 ≠ 权限不足&lt;/p&gt;
&lt;/blockquote&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;403-forbidden&quot;&gt;403 Forbidden&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;含义：已认证，但无权限&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;场景：&lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;普通用户访问管理员接口&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;404-not-found&quot;&gt;404 Not Found&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;含义：资源不存在&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;场景：&lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;URL 错误&lt;/li&gt;
      &lt;li&gt;资源被删除&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;405-method-not-allowed&quot;&gt;405 Method Not Allowed&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;含义：请求方法不被允许&lt;/li&gt;
  &lt;li&gt;示例：&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-http highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;err&quot;&gt;POST /api/fields/123
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;HTTP&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;1.1&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;405&lt;/span&gt; &lt;span class=&quot;ne&quot;&gt;Method Not Allowed&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Allow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;GET, PUT&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;409-conflict&quot;&gt;409 Conflict&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;含义：资源冲突&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;场景：&lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;重复创建&lt;/li&gt;
      &lt;li&gt;乐观锁冲突&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;422-unprocessable-entity&quot;&gt;422 Unprocessable Entity&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;含义：语义正确，但业务校验失败&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;场景：&lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;表单校验&lt;/li&gt;
      &lt;li&gt;数据规则不满足&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;七5xx服务器错误server-error&quot;&gt;七、5xx：服务器错误（Server Error）&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;表示服务器在处理请求时发生异常&lt;/strong&gt;。&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;500-internal-server-error&quot;&gt;500 Internal Server Error&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;含义：服务器内部错误&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;原因：&lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;未捕获异常&lt;/li&gt;
      &lt;li&gt;代码 Bug&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;502-bad-gateway&quot;&gt;502 Bad Gateway&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;含义：上游服务器返回无效响应&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;场景：&lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;反向代理&lt;/li&gt;
      &lt;li&gt;微服务调用失败&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;503-service-unavailable&quot;&gt;503 Service Unavailable&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;含义：服务暂不可用&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;场景：&lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;服务维护&lt;/li&gt;
      &lt;li&gt;系统过载&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;504-gateway-timeout&quot;&gt;504 Gateway Timeout&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;含义：上游服务超时&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;场景：&lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;GIS 大规模计算&lt;/li&gt;
      &lt;li&gt;数据库响应过慢&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;八restful-api-状态码设计建议&quot;&gt;八、RESTful API 状态码设计建议&lt;/h2&gt;

&lt;h3 id=&quot;1️⃣-成功不要只用-200&quot;&gt;1️⃣ 成功不要只用 200&lt;/h3&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&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;201&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;删除成功&lt;/td&gt;
      &lt;td&gt;204&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;异步处理&lt;/td&gt;
      &lt;td&gt;202&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;2️⃣-错误状态码要语义准确&quot;&gt;2️⃣ 错误状态码要“语义准确”&lt;/h3&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&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;401&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;无权限&lt;/td&gt;
      &lt;td&gt;403&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;参数错误&lt;/td&gt;
      &lt;td&gt;400 / 422&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;资源不存在&lt;/td&gt;
      &lt;td&gt;404&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;3️⃣-状态码--错误信息结构示例&quot;&gt;3️⃣ 状态码 + 错误信息结构示例&lt;/h3&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;code&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;422&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;message&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Validation failed&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;details&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;area&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;must be greater than 0&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;九常见误区总结&quot;&gt;九、常见误区总结&lt;/h2&gt;

&lt;p&gt;❌ 所有错误都返回 200&lt;/p&gt;

&lt;p&gt;❌ 用 500 表示业务校验失败&lt;/p&gt;

&lt;p&gt;❌ 401 和 403 混用&lt;/p&gt;

&lt;p&gt;❌ 前端只判断 code，不看 HTTP 状态码&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;十结语&quot;&gt;十、结语&lt;/h2&gt;

&lt;p&gt;HTTP 状态码不仅是 &lt;strong&gt;网络协议的一部分&lt;/strong&gt;，更是 &lt;strong&gt;接口设计质量的重要体现&lt;/strong&gt;。&lt;/p&gt;

&lt;p&gt;一个设计良好的接口，应该做到：&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;状态码语义清晰&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;前后端理解一致&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;错误可定位、可处理&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Tue, 06 Jan 2026 00:00:00 +0000</pubDate>
        <link>https://yucol.top/tech/HTTP-%E7%8A%B6%E6%80%81%E7%A0%81.html</link>
        <guid isPermaLink="true">https://yucol.top/tech/HTTP-%E7%8A%B6%E6%80%81%E7%A0%81.html</guid>
        
        <category>HTTP</category>
        
        <category>前端</category>
        
        <category>后端</category>
        
        
        <category>tech</category>
        
      </item>
    
      <item>
        <title>土壤采样点</title>
        <description>&lt;blockquote&gt;
  &lt;p&gt;以 &lt;strong&gt;ArcGIS Pro 3.0.2&lt;/strong&gt; 版本为例，制作某区域土壤采样点。
投影坐标系：WGS-84墨卡托&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1 id=&quot;目视采样&quot;&gt;目视采样&lt;/h1&gt;

&lt;p&gt;按照能谱或其他数据（本文所有“异常点”采集样本均为&lt;strong&gt;能谱总计数Total&lt;/strong&gt;）进行空间插值，对高/低值进行目视解译，根据需求选取合适数量的土壤采样点。&lt;/p&gt;

&lt;p&gt;该方法过于简单，不再赘述。&lt;/p&gt;

&lt;h1 id=&quot;完全随机采样&quot;&gt;完全随机采样&lt;/h1&gt;

&lt;h2 id=&quot;全局完全随机采样&quot;&gt;全局完全随机采样&lt;/h2&gt;

&lt;p&gt;将空间插值后的栅格数据进行&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;栅格转点&lt;/code&gt;，之后使用&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;值提取至点&lt;/code&gt;或&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;多值提取至点&lt;/code&gt;。使用&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;数据管理工具&lt;/code&gt;–&amp;gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;采样&lt;/code&gt;–&amp;gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;创建随机点&lt;/code&gt;，根据数据设置参数。&lt;/p&gt;

&lt;p&gt;当前方法是在整个区域内进行采样，只考虑数量，不考虑任何其它因素。虽然使用了&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;值提取至点&lt;/code&gt;或&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;多值提取至点&lt;/code&gt;，但仅是为了后续制图时可以借助参考。&lt;/p&gt;

&lt;h2 id=&quot;探测器行进轨迹上随机采样&quot;&gt;探测器行进轨迹上随机采样&lt;/h2&gt;

&lt;p&gt;与上述方法不同的点在于，随机分为不是全局，而是探测器（无人机、探测车等）的&lt;strong&gt;行进轨迹&lt;/strong&gt;。&lt;/p&gt;

&lt;p&gt;根据数据点的&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;采集时间&lt;/code&gt;字段生成轨迹路线：&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;数据管理工具&lt;/code&gt;–&amp;gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;要素&lt;/code&gt;–&amp;gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;点集转线&lt;/code&gt;，&lt;strong&gt;排序字段&lt;/strong&gt;选择&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;采集时间&lt;/code&gt;字段。&lt;/p&gt;

&lt;p&gt;之后，再将轨迹路线转为点要素：&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;数据管理工具&lt;/code&gt;–&amp;gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;采样&lt;/code&gt;–&amp;gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;沿线生成点&lt;/code&gt;。&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;谨记：切勿使用&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;要素转点&lt;/code&gt;工具，该工具只会生成一个点（中心点）。&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;使用&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;创建随机点&lt;/code&gt;，根据数据设置参数。&lt;/p&gt;

&lt;h1 id=&quot;沿线性要素的分层随机采样&quot;&gt;沿线性要素的分层随机采样&lt;/h1&gt;

&lt;p&gt;该方法是&lt;strong&gt;ArcGIS Pro&lt;/strong&gt;环境下的随机土壤采样点方式之一，其考虑了探测器行进路径及不同属性高低值的因素。&lt;/p&gt;

&lt;p&gt;使用&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;值提取至点&lt;/code&gt;或&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;多值提取至点&lt;/code&gt;，将空间插值数据（Total）提取至轨迹点中。打开点数据的&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;属性表&lt;/code&gt;，&lt;strong&gt;添加&lt;/strong&gt;一个新字段，用以对当前点进行分类，例如字段&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;class&lt;/code&gt;，值有&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;coldPoint&lt;/code&gt;、&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hotPoint&lt;/code&gt;、&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;normalPoint&lt;/code&gt;。随后选中对应的分类，使用&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;创建随机点&lt;/code&gt;，根据数据设置参数。这里三种分类各自的数量可以为5/5/3，最小间隔距离为100米。&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://img14.360buyimg.com/ddimg/jfs/t1/368946/2/1327/174372/691aec6eF98883664/f1f40b9a051b4d08.jpg&quot; alt=&quot;Sampling_Point.png&quot; /&gt;&lt;/p&gt;
</description>
        <pubDate>Mon, 17 Nov 2025 00:00:00 +0000</pubDate>
        <link>https://yucol.top/tech/%E5%9C%9F%E5%A3%A4%E9%87%87%E6%A0%B7%E7%82%B9.html</link>
        <guid isPermaLink="true">https://yucol.top/tech/%E5%9C%9F%E5%A3%A4%E9%87%87%E6%A0%B7%E7%82%B9.html</guid>
        
        <category>智慧农业</category>
        
        <category>测土</category>
        
        <category>土壤采样</category>
        
        
        <category>tech</category>
        
      </item>
    
      <item>
        <title>土壤属性网格图</title>
        <description>&lt;blockquote&gt;
  &lt;p&gt;以 &lt;strong&gt;ArcGIS Pro 3.0.2&lt;/strong&gt; 版本为例，制作某区域pH空间分布网格图。
投影坐标系：WGS-84墨卡托&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1 id=&quot;制作插值图&quot;&gt;制作插值图&lt;/h1&gt;

&lt;p&gt;对已有点数据进行插值，生成当前区域内的pH空间分布图，差值方法为克里金插值。&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://img11.360buyimg.com/ddimg/jfs/t1/355481/40/7951/105945/69141d4cF02e773d9/df5da46c63f068fb.jpg&quot; alt=&quot;Kriging_Region_A_pH.png&quot; /&gt;&lt;/p&gt;

&lt;h1 id=&quot;创建渔网&quot;&gt;创建渔网&lt;/h1&gt;

&lt;p&gt;选择&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;创建渔网&lt;/code&gt;工具，设置范围及像元大小，该演示设置像元宽度x高度为&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;30x30&lt;/code&gt;，几何类型选择&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Polygon&lt;/code&gt;。&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://img14.360buyimg.com/ddimg/jfs/t1/355827/7/8056/95896/69141d4cFc76e7528/3675c3c8bcc1f288.jpg&quot; alt=&quot;Fishnet_Region_A.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;这会创建包围设置范围的一个矩形区域的渔网面要素及点要素。&lt;/p&gt;

&lt;p&gt;之后选择&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;裁剪&lt;/code&gt;工具对渔网面及及点进行裁剪，以当前区域为掩膜，只保留区域范围内的面及点。&lt;/p&gt;

&lt;p&gt;打开渔网面要素的属性表，对面积字段&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Shape_Area&lt;/code&gt;进行降序/升序排列，将边缘不规则的网格进行删除（面积＜规则网格面积）。&lt;/p&gt;

&lt;h1 id=&quot;数据关联&quot;&gt;数据关联&lt;/h1&gt;

&lt;p&gt;选择&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;值提取至点&lt;/code&gt;，将克里金插值栅格数据提取至渔网点数据中。&lt;/p&gt;

&lt;p&gt;右键渔网面要素，选择&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;连接和关联&lt;/code&gt;–&amp;gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;添加空间连接&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://img13.360buyimg.com/ddimg/jfs/t1/346486/40/26084/128448/69141d4bF7c8bac77/9d032a96a2ce653c.jpg&quot; alt=&quot;Grid_Region_A_pH.png&quot; /&gt;&lt;/p&gt;
</description>
        <pubDate>Wed, 12 Nov 2025 00:00:00 +0000</pubDate>
        <link>https://yucol.top/tech/%E5%9C%9F%E5%A3%A4%E5%B1%9E%E6%80%A7%E7%BD%91%E6%A0%BC%E5%9B%BE.html</link>
        <guid isPermaLink="true">https://yucol.top/tech/%E5%9C%9F%E5%A3%A4%E5%B1%9E%E6%80%A7%E7%BD%91%E6%A0%BC%E5%9B%BE.html</guid>
        
        <category>网格图</category>
        
        <category>智慧农业</category>
        
        <category>测土</category>
        
        
        <category>tech</category>
        
      </item>
    
      <item>
        <title>Vue基础知识</title>
        <description>&lt;p&gt;&lt;img src=&quot;https://img10.360buyimg.com/ddimg/jfs/t1/359854/5/117/12576/690db88cF095ad0bd/686b3ea8314345f2.jpg&quot; alt=&quot;image.png&quot; /&gt;&lt;/p&gt;

&lt;h1 id=&quot;数组变化侦听&quot;&gt;数组变化侦听&lt;/h1&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;template&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;h3&amp;gt;&lt;/span&gt;数组变化侦听&lt;span class=&quot;nt&quot;&gt;&amp;lt;/h3&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;button&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;click=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;addListHandle&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;添加数据&lt;span class=&quot;nt&quot;&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;li&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;v-for=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;(item,index) of names&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;:key=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;index&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;{{ item }}&lt;span class=&quot;nt&quot;&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/template&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;na&quot;&gt;names&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;Alice&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;Bob&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;Charlie&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;Diana&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;methods&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nf&quot;&gt;addListHandle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;// this.names.push(&apos;New Name &apos; + (this.names.length + 1));&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;names&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;concat&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;New Name &lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;names&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]);&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// 使用concat不会触发视图更新&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;names&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;names&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;concat&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;New Name &lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;names&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]);&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// 重新赋值可以触发视图更新&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;计算属性computed&quot;&gt;计算属性computed&lt;/h1&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;template&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;h3&amp;gt;&lt;/span&gt;{{ yucol.name }}&lt;span class=&quot;nt&quot;&gt;&amp;lt;/h3&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;&amp;lt;!-- &amp;lt;p&amp;gt;{{ yucol.kills.length &amp;gt; 0 ? &apos;Yes&apos;: &quot;No&quot; }}&amp;lt;/p&amp;gt; --&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;p&amp;gt;&lt;/span&gt;{{ killCount }}&lt;span class=&quot;nt&quot;&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;p&amp;gt;&lt;/span&gt;{{ yucolCounts() }}&lt;span class=&quot;nt&quot;&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/template&amp;gt;&lt;/span&gt;


&lt;span class=&quot;nt&quot;&gt;&amp;lt;script&amp;gt;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// 这里可以添加一些数据属性&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;yucol&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:{&lt;/span&gt;
            &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;yucol&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;na&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;18&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;na&quot;&gt;kills&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;coding&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;gaming&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;reading&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;computed&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// 计算属性&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// 代码不更改时，只会计算一次，提升性能&lt;/span&gt;
        &lt;span class=&quot;nf&quot;&gt;killCount&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;yucol&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;kills&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;Yes&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;No&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;methods&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// 这里可以添加一些方法&lt;/span&gt;
        &lt;span class=&quot;nf&quot;&gt;yucolCounts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;yucol&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;kills&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;Yes&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;No&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;class样式绑定&quot;&gt;Class样式绑定&lt;/h1&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;template&amp;gt;&lt;/span&gt;

    &lt;span class=&quot;c&quot;&gt;&amp;lt;!-- &amp;lt;p :class=&quot;myClass&quot;&amp;gt;Class样式绑定&amp;lt;/p&amp;gt; --&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;p&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;:class=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;{&apos;active&apos;:isActive,&apos;text-danger&apos;:hasError}&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;Class样式绑定&lt;span class=&quot;nt&quot;&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;p&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;:class=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;classObject&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;Class样式绑定（多个对象绑定）&lt;span class=&quot;nt&quot;&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;p&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;:class=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;arrs&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;Class样式绑定（数组绑定）&lt;span class=&quot;nt&quot;&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;p&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;:class=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;[isActive ? &apos;active&apos; : &apos;&apos;, {&apos;text-danger&apos;:hasError}]&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;Class样式绑定（数组和对象）&lt;span class=&quot;nt&quot;&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/template&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;script&amp;gt;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;// 这里可以添加一些数据属性&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;// myClass:&apos;red-text&apos;&lt;/span&gt;
            &lt;span class=&quot;na&quot;&gt;isActive&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;na&quot;&gt;hasError&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;na&quot;&gt;classObject&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:{&lt;/span&gt;
                &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;active&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;text-danger&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
            &lt;span class=&quot;na&quot;&gt;arrs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:[&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;active&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;text-danger&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
            &lt;span class=&quot;na&quot;&gt;arrActive&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;active&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;na&quot;&gt;arrDanger&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;text-danger&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;


&lt;span class=&quot;nt&quot;&gt;&amp;lt;style&amp;gt;&lt;/span&gt;

    &lt;span class=&quot;nc&quot;&gt;.active&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nl&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;red&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;nl&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;30px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;nc&quot;&gt;.text-danger&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nl&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;yellow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;style绑定&quot;&gt;Style绑定&lt;/h1&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;template&amp;gt;&lt;/span&gt;

    &lt;span class=&quot;nt&quot;&gt;&amp;lt;p&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;:style=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;{color:activeColor, fontSize:&apos;30px&apos;}&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;Style绑定&lt;span class=&quot;nt&quot;&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;p&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;:style=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;styleObject&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;Style绑定&lt;span class=&quot;nt&quot;&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;/template&amp;gt;&lt;/span&gt;


&lt;span class=&quot;nt&quot;&gt;&amp;lt;script&amp;gt;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;// 这里可以添加一些数据属性&lt;/span&gt;
            &lt;span class=&quot;na&quot;&gt;activeColor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;red&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;na&quot;&gt;styleObject&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:{&lt;/span&gt;
                &lt;span class=&quot;na&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;green&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                &lt;span class=&quot;na&quot;&gt;fontSize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;30px&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;侦听器watch&quot;&gt;侦听器watch&lt;/h1&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;template&amp;gt;&lt;/span&gt;

    &lt;span class=&quot;nt&quot;&gt;&amp;lt;h3&amp;gt;&lt;/span&gt;侦听器&lt;span class=&quot;nt&quot;&gt;&amp;lt;/h3&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;p&amp;gt;&lt;/span&gt;{{ message }}&lt;span class=&quot;nt&quot;&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;button&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;click=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;updateHandle&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;修改数据&lt;span class=&quot;nt&quot;&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/template&amp;gt;&lt;/span&gt;


&lt;span class=&quot;nt&quot;&gt;&amp;lt;script&amp;gt;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;// 这里可以添加一些数据属性&lt;/span&gt;
            &lt;span class=&quot;na&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;Hello, Watch Demo!&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;methods&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:{&lt;/span&gt;
        &lt;span class=&quot;nf&quot;&gt;updateHandle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;message&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;Data has been updated!&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;watch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:{&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// 监听 message 属性的变化&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// newVal: 新值 oldVal: 旧值&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// 函数名必须与要监听的数据属性名相同&lt;/span&gt;
        &lt;span class=&quot;nf&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;newVal&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;oldVal&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;// 当 message 变化时执行的代码&lt;/span&gt;
            &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;`message changed from &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;oldVal&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot; to &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;newVal&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;表单输入绑定&quot;&gt;表单输入绑定&lt;/h1&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;template&amp;gt;&lt;/span&gt;

    &lt;span class=&quot;nt&quot;&gt;&amp;lt;h3&amp;gt;&lt;/span&gt;表单输入绑定&lt;span class=&quot;nt&quot;&gt;&amp;lt;/h3&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;form&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;action=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;input&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;v-model.lazy=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;message&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;p&amp;gt;&lt;/span&gt;{{ message }}&lt;span class=&quot;nt&quot;&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;input&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;checkbox&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;checkbox&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;v-model=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;checked&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;label&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;for=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;checkbox&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;{{ checked }}&lt;span class=&quot;nt&quot;&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;/template&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;script&amp;gt;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;na&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;na&quot;&gt;checked&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;模板引用&quot;&gt;模板引用&lt;/h1&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;template&amp;gt;&lt;/span&gt;

    &lt;span class=&quot;nt&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;ref=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;container&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;class=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;container&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
        {{ contents }}
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;input&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;ref=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;username&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;button&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;click=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;getElementHandle&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;获取元素&lt;span class=&quot;nt&quot;&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;/template&amp;gt;&lt;/span&gt;


&lt;span class=&quot;nt&quot;&gt;&amp;lt;script&amp;gt;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;    
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;na&quot;&gt;contents&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;内容&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;methods&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nf&quot;&gt;getElementHandle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;// innerHTML:原生js的属性&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;$refs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;container&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;innerHTML&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;hhhhh&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;$refs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;username&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;others&quot;&gt;others…&lt;/h1&gt;
</description>
        <pubDate>Fri, 07 Nov 2025 00:00:00 +0000</pubDate>
        <link>https://yucol.top/tech/Vue%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86.html</link>
        <guid isPermaLink="true">https://yucol.top/tech/Vue%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86.html</guid>
        
        <category>Vue</category>
        
        <category>前端</category>
        
        
        <category>tech</category>
        
      </item>
    
      <item>
        <title>能谱数据处理</title>
        <description>&lt;h1 id=&quot;能谱信息&quot;&gt;能谱信息&lt;/h1&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;元素系&lt;/th&gt;
      &lt;th&gt;代表通道&lt;/th&gt;
      &lt;th&gt;代表核素&lt;/th&gt;
      &lt;th&gt;特征能量 (keV)&lt;/th&gt;
      &lt;th&gt;土壤意义&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;K 系&lt;/td&gt;
      &lt;td&gt;~1460 keV&lt;/td&gt;
      &lt;td&gt;K-40&lt;/td&gt;
      &lt;td&gt;1460&lt;/td&gt;
      &lt;td&gt;钾元素含量&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Th 系&lt;/td&gt;
      &lt;td&gt;~2615 keV&lt;/td&gt;
      &lt;td&gt;Tl-208（来自 Th-232 系）&lt;/td&gt;
      &lt;td&gt;2615&lt;/td&gt;
      &lt;td&gt;钍元素含量&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;U 系&lt;/td&gt;
      &lt;td&gt;~609 keV&lt;/td&gt;
      &lt;td&gt;Bi-214（来自 U-238 系）&lt;/td&gt;
      &lt;td&gt;609&lt;/td&gt;
      &lt;td&gt;铀元素含量&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;目前的能谱探测有两种元件：&lt;strong&gt;NaI&lt;/strong&gt;和&lt;strong&gt;CsI&lt;/strong&gt;，其中：&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;通道总数：1024&lt;/li&gt;
  &lt;li&gt;200通道：608keV Bi-214 (U-238系)&lt;/li&gt;
  &lt;li&gt;490通道：1460keV K-40 (自然放射性)&lt;/li&gt;
  &lt;li&gt;868通道：2614keV Tl-208 (Th-232系)&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;数据处理方法&quot;&gt;数据处理方法&lt;/h1&gt;

&lt;h2 id=&quot;snip背景剔除&quot;&gt;SNIP背景剔除&lt;/h2&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SNIP&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;iterations&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;40&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;iterations&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;iterations&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;background_&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;None&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;net_counts_&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;None&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;fit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;counts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;
        对输入谱执行 SNIP 背景估计（对数域版本）
        &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;counts&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;counts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dtype&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;# 为防止 log(0)，加上一个很小的常数
&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;counts&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;bg&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;copy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;iterations&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;temp&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;copy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;bg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;temp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;temp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;2.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;# 转回线性域
&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;bg&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;exp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;background_&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bg&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;net_counts_&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;counts&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bg&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;background_&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;transform&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;counts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;background_&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;fit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;counts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;net_counts_&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;fit_transform&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;counts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;fit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;counts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;net_counts_&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;process_csv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;input_csv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output_csv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;counts_column&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;counts&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;
        批量处理 CSV 文件
        :param input_csv: 原始 CSV 文件路径
        :param output_csv: 输出 CSV 文件路径
        :param counts_column: 包含通道计数的列名
        &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;df&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;read_csv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;input_csv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;n&quot;&gt;bg_list&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;net_list&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;net_total_counts&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 添加用于存储净计数总和的列表
&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;idx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;row&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;iterrows&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;# 将字符串列表解析为 Python list
&lt;/span&gt;            &lt;span class=&quot;n&quot;&gt;counts&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ast&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;literal_eval&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;row&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;counts_column&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;bg&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;fit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;counts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;net&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;transform&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;counts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

            &lt;span class=&quot;n&quot;&gt;bg_list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;round&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;net_list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;round&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;net&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;net_total_counts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;round&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;net&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)),&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;# 新增列
&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;background&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bg_list&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;net_counts&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;net_list&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;net_total_counts&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;net_total_counts&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# 添加净计数总和列
&lt;/span&gt;        &lt;span class=&quot;c1&quot;&gt;# 创建新的DataFrame，只保留需要的字段
&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;new_df&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;farm_id&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;collection_time&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;latitude&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;longitude&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;counts&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;background&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;net_counts&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;net_total_counts&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]]&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;# 保存
&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;new_df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_csv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;output_csv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;处理完成，已保存到 &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;output_csv&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;plot_spectrum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;input_csv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;counts_col&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;counts&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bg_col&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;background&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;net_col&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;net_counts&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;
        绘制指定索引的谱线对比图（原始谱、背景、净峰谱）
        :param input_csv: CSV 文件路径（包含 counts、background、net_counts）
        :param index: 要绘制的行号（从 0 开始）
        :param counts_col: 原始谱列名
        :param bg_col: 背景谱列名
        :param net_col: 净谱列名
        &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;# 读取数据
&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;df&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;read_csv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;input_csv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;# 检查索引是否超出范围
&lt;/span&gt;        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;index&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;or&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;index&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;raise&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;IndexError&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;索引 &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; 超出范围（共有 &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; 条数据）&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;# 解析为 Python 列表
&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;counts&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ast&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;literal_eval&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;counts_col&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dtype&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;background&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ast&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;literal_eval&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bg_col&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dtype&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;net&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ast&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;literal_eval&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;net_col&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dtype&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;# 绘图
&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;figure&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;figsize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;plot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;counts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;原始谱&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;black&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;linewidth&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;plot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;background&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;背景谱&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;orange&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;linewidth&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;plot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;net&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;净峰谱&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;red&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;linewidth&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;1.2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;xlabel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;通道号&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ylabel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;计数&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;SNIP 谱线对比图（第 &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; 条数据）&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;legend&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;grid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;alpha&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;调用方法（默认迭代40次）：&lt;/p&gt;
&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# SNIP初始化
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;snip&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SNIP&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;iterations&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;40&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;snip&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;process_csv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;../file/point_area_a.csv&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;../file/snip_processed_area_a.csv&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;counts_column&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;counts&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;snip&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;process_csv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;../file/point_area_b.csv&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;../file/snip_processed_area_b.csv&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;counts_column&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;counts&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;snip&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;plot_spectrum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;../file/snip_processed_area_a.csv&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;99&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# 绘制第100条数据
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;img src=&quot;https://img10.360buyimg.com/ddimg/jfs/t1/358857/36/3421/22607/690af6ecF11f4a31b/c69fa9e95096a4f5.jpg&quot; alt=&quot;image.png&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;窗口求和&quot;&gt;窗口求和&lt;/h2&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SpectrumPeak&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;
    根据指定通道和窗口范围计算能谱峰强度（窗口求和），支持批量多通道处理
    &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;counts_column&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;counts&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;counts_column&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;counts_column&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# CSV 中的计数列名
&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;compute_peak&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;counts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;channel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;
        计算指定通道附近窗口的计数和
        :param counts: 样本的计数列表
        :param channel: 中心通道
        :param window: 窗口范围（正负范围）
        :return: 窗口内计数和
        &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;start&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;channel&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;counts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;channel&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;window&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# python 切片是左闭右开
&lt;/span&gt;        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;counts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;process_csv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;input_csv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output_csv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;peaks&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;
        处理 CSV 文件，计算峰强度，并保存新 CSV
        :param input_csv: 输入 CSV 路径
        :param output_csv: 输出 CSV 路径
        :param peaks: dict, {列名: (中心通道, 窗口范围)}
                      例如: {&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;K40_peak&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;: (490, 5), &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;U238_peak&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;: (600, 7)}
        &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;df&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;read_csv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;input_csv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;# 先把原 counts 列解析成列表，方便重复使用
&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;counts_list&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;counts_column&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;apply&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ast&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;literal_eval&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;peak_name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;channel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;peaks&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;items&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;peak_name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;counts_list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;apply&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;lambda&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;compute_peak&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;channel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;

        &lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_csv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;output_csv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;处理完成，已保存到 &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;output_csv&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;调用方法：&lt;/p&gt;
&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# 获取指定通道的窗口求和
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sp&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SpectrumPeak&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;counts_column&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;net_counts&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 定义要计算的峰，键是输出列名，值是 (中心通道, 窗口)
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;peaks_to_calc&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Bi214_peak&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
    &lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;K40_peak&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;490&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
    &lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Tl208_peak&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;868&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;sp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;process_csv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;input_csv&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;../file/snip_processed_area_a.csv&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;output_csv&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;../file/data_peaks_area_a.csv&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;peaks&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;peaks_to_calc&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;主成分分析&quot;&gt;主成分分析&lt;/h2&gt;

&lt;pre&gt;&lt;code class=&quot;language-PYTHON&quot;&gt;class SpectrumPCA:
    &quot;&quot;&quot;
    光谱主成分分析（PCA）封装类
    支持 CSV 文件批量处理、自动保存主成分结果
    &quot;&quot;&quot;

    def __init__(self, n_components=3):
        &quot;&quot;&quot;
        初始化 PCA 模型
        :param n_components: 主成分数量（默认 3）
        &quot;&quot;&quot;
        self.n_components = n_components
        self.pca_model = PCA(n_components=n_components)
        self.components_ = None
        self.explained_variance_ratio_ = None
        self.pca_scores_ = None

    def _parse_counts(self, counts_str):
        &quot;&quot;&quot;
        将字符串 &quot;[1, 2, 3]&quot; 转换为 numpy 数组
        &quot;&quot;&quot;
        if isinstance(counts_str, str):
            return np.array(ast.literal_eval(counts_str), dtype=float)
        elif isinstance(counts_str, (list, np.ndarray)):
            return np.array(counts_str, dtype=float)
        else:
            raise ValueError(&quot;counts 列格式错误，应为字符串或列表&quot;)

    def fit_transform_csv(self, input_csv, output_csv=None, counts_column=&apos;counts&apos;):
        &quot;&quot;&quot;
        从 CSV 文件读取能谱数据，执行 PCA 并保存结果
        :param input_csv: 输入 CSV 文件路径
        :param output_csv: 输出 CSV 文件路径（可选）
        :param counts_column: 光谱列名（默认 &apos;counts&apos;）
        :return: 包含 PCA 结果的 DataFrame
        &quot;&quot;&quot;
        # === 1. 读取 CSV ===
        df = pd.read_csv(input_csv)
        print(f&quot;✅ 成功读取 {len(df)} 条样本&quot;)

        # === 2. 转换 counts 列为矩阵 ===
        spectra = np.array([self._parse_counts(c) for c in df[counts_column]])
        print(f&quot;每条光谱通道数: {spectra.shape[1]}&quot;)

        # === 3. 执行 PCA ===
        self.pca_scores_ = self.pca_model.fit_transform(spectra)
        self.components_ = self.pca_model.components_
        self.explained_variance_ratio_ = self.pca_model.explained_variance_ratio_

        # === 4. 将主成分结果添加到 df ===
        for i in range(self.n_components):
            df[f&apos;PC{i+1}&apos;] = self.pca_scores_[:, i]

        # === 5. 可选保存结果 ===
        if output_csv:
            base, ext = os.path.splitext(output_csv)
            result_csv = f&quot;{base}_pca.csv&quot;
            variance_csv = f&quot;{base}_variance.csv&quot;

            # 保存主成分结果
            df.to_csv(result_csv, index=False)

            # 保存方差贡献率信息
            var_df = pd.DataFrame({
                &apos;PC&apos;: [f&apos;PC{i+1}&apos; for i in range(self.n_components)],
                &apos;Explained_Variance_Ratio&apos;: self.explained_variance_ratio_
            })
            var_df.to_csv(variance_csv, index=False)

            print(f&quot;📂 PCA结果已保存至: {result_csv}&quot;)
            print(f&quot;📊 方差贡献率已保存至: {variance_csv}&quot;)

        return df

    # ==================== 方差贡献率柱状图 ====================
    def plot_variance_ratio(self):
        if self.explained_variance_ratio_ is None:
            raise ValueError(&quot;请先运行 fit_transform_csv()&quot;)
        plt.figure(figsize=(6, 4))
        plt.bar(range(1, len(self.explained_variance_ratio_) + 1),
                self.explained_variance_ratio_ * 100, color=&apos;skyblue&apos;)
        plt.xlabel(&quot;主成分&quot;)
        plt.ylabel(&quot;方差贡献率 (%)&quot;)
        plt.title(&quot;PCA 方差贡献率&quot;)
        plt.grid(True, alpha=0.3)
        plt.show()

    # ==================== PCA 散点图 ====================
    def plot_scatter(self, df, pc_x=1, pc_y=2):
        pc_x_col = f&apos;PC{pc_x}&apos;
        pc_y_col = f&apos;PC{pc_y}&apos;
        if pc_x_col not in df.columns or pc_y_col not in df.columns:
            raise ValueError(&quot;DataFrame 中缺少指定的 PCA 列，请先运行 fit_transform_csv()&quot;)
        plt.figure(figsize=(6, 6))
        plt.scatter(df[pc_x_col], df[pc_y_col], alpha=0.7, edgecolor=&apos;k&apos;)
        plt.xlabel(pc_x_col)
        plt.ylabel(pc_y_col)
        plt.title(f&apos;PCA 散点图 ({pc_x_col} vs {pc_y_col})&apos;)
        plt.grid(True, alpha=0.3)
        plt.show()

    # ==================== 空间可视化 ====================
    def plot_spatial_pca(self, df, pc=1, lat_col=&apos;latitude&apos;, lon_col=&apos;longitude&apos;,
                         method=&apos;scatter&apos;, grid_res=100):
        &quot;&quot;&quot;
        绘制 PCA 空间分布图
        :param df: 包含经纬度和 PCA 列的 DataFrame
        :param pc: PCA 编号（1,2,3,...）
        :param lat_col: 纬度列名
        :param lon_col: 经度列名
        :param method: &apos;scatter&apos; 或 &apos;heatmap&apos;
        :param grid_res: 热力图插值网格分辨率
        &quot;&quot;&quot;
        pc_col = f&apos;PC{pc}&apos;
        if pc_col not in df.columns:
            raise ValueError(f&quot;{pc_col} 列不存在，请先运行 PCA&quot;)

        lats = df[lat_col].values
        lons = df[lon_col].values
        values = df[pc_col].values

        if method == &apos;scatter&apos;:
            plt.figure(figsize=(8, 6))
            sc = plt.scatter(lons, lats, c=values, cmap=&apos;viridis&apos;, s=50, edgecolor=&apos;k&apos;)
            plt.colorbar(sc, label=f&apos;{pc_col} 值&apos;)
            plt.xlabel(&apos;Longitude&apos;)
            plt.ylabel(&apos;Latitude&apos;)
            plt.title(f&apos;{pc_col} 空间散点图&apos;)
            plt.grid(True, alpha=0.3)
            plt.show()

        elif method == &apos;heatmap&apos;:
            # 创建网格
            lon_grid = np.linspace(lons.min(), lons.max(), grid_res)
            lat_grid = np.linspace(lats.min(), lats.max(), grid_res)
            lon_mesh, lat_mesh = np.meshgrid(lon_grid, lat_grid)

            # 插值
            grid_values = griddata((lons, lats), values, (lon_mesh, lat_mesh), method=&apos;cubic&apos;)

            # 绘制热力图
            plt.figure(figsize=(8, 6))
            hm = plt.imshow(grid_values, origin=&apos;lower&apos;,
                            extent=(lons.min(), lons.max(), lats.min(), lats.max()),
                            cmap=&apos;viridis&apos;, aspect=&apos;auto&apos;)
            plt.colorbar(hm, label=f&apos;{pc_col} 值&apos;)
            plt.scatter(lons, lats, c=&apos;white&apos;, s=10, alpha=0.8)  # 原始点位置
            plt.xlabel(&apos;Longitude&apos;)
            plt.ylabel(&apos;Latitude&apos;)
            plt.title(f&apos;{pc_col} 空间热力图&apos;)
            plt.show()
        else:
            raise ValueError(&quot;method 参数只支持 &apos;scatter&apos; 或 &apos;heatmap&apos;&quot;)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;调用方法：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-PYTHON&quot;&gt;# PCA初始化
pca = SpectrumPCA(n_components=3)

# 对 CSV 数据进行 PCA 并保存结果
df_area_a = pca.fit_transform_csv(input_csv=&quot;../file/snip_processed_area_a.csv&quot;, output_csv=&quot;../file/area_a.csv&quot;, counts_column=&apos;net_counts&apos;)
df_area_b = pca.fit_transform_csv(input_csv=&quot;../file/snip_processed_area_b.csv&quot;, output_csv=&quot;../file/area_b.csv&quot;, counts_column=&apos;net_counts&apos;)


# # 绘制方差贡献率图
# pca.plot_variance_ratio()

# # 绘制主成分散点图（PC1 vs PC2）
# pca.plot_scatter(df_area_a, pc_x=1, pc_y=2)

# # 绘制空间散点图（PC1）
# pca.plot_spatial_pca(df_area_a, pc=1, method=&apos;scatter&apos;)

# # 绘制空间热力图（PC1）
# pca.plot_spatial_pca(df_area_a, pc=1, method=&apos;heatmap&apos;, grid_res=200)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;img src=&quot;https://img11.360buyimg.com/ddimg/jfs/t1/337796/37/23098/88535/690af732F81de8443/9ba32d410e1ad71d.jpg&quot; alt=&quot;image.png&quot; /&gt;&lt;/p&gt;
</description>
        <pubDate>Wed, 05 Nov 2025 00:00:00 +0000</pubDate>
        <link>https://yucol.top/tech/%E8%83%BD%E8%B0%B1%E6%95%B0%E6%8D%AE%E5%A4%84%E7%90%86.html</link>
        <guid isPermaLink="true">https://yucol.top/tech/%E8%83%BD%E8%B0%B1%E6%95%B0%E6%8D%AE%E5%A4%84%E7%90%86.html</guid>
        
        <category>土壤处方图</category>
        
        <category>GIS</category>
        
        <category>智慧农业</category>
        
        <category>能谱</category>
        
        
        <category>tech</category>
        
      </item>
    
      <item>
        <title>土壤处方图</title>
        <description>&lt;h1 id=&quot;土壤成分处方图调查&quot;&gt;土壤成分处方图调查&lt;/h1&gt;

&lt;h2 id=&quot;何为土壤成分处方图&quot;&gt;何为土壤成分处方图&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;“土壤成分处方图”（Soil Composition Prescription Map）是近年来智慧农业、精准施肥领域非常重要的一个概念。&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;土壤成分处方图是根据不同地块的土壤养分含量与作物需求，生成的 &lt;strong&gt;“精准管理地图”，指导农民在不同区域定量施肥、灌溉或改良土壤&lt;/strong&gt;。&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&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;strong&gt;精准施肥&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;不同地块施不同的量，避免浪费或缺肥&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;提高产量和品质&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;让作物在“适宜”的营养环境下生长&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;减少环境污染&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;减少氮磷流失、面源污染&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;辅助农机作业&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;无人机、变量施肥机可以按图执行处方作业&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h2 id=&quot;相关企业&quot;&gt;相关企业&lt;/h2&gt;

&lt;h3 id=&quot;soiloptix&quot;&gt;SoilOptix&lt;/h3&gt;

&lt;blockquote&gt;
  &lt;p&gt;技术原理：https://soiloptix.com/case_studies/from-start-to-finish-how-soiloptix-technology-works/&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;这是一家位于加拿大的公司，创始人为&lt;strong&gt;Paul Raymer&lt;/strong&gt;。SoilOptix的传感器以伽马射线为核心原理，以&lt;strong&gt;827个点/公顷&lt;/strong&gt;的分辨率对土壤内腐殖物产生的&lt;strong&gt;铯-137，铀-238，钍-232，钾-40&lt;/strong&gt;物质进行测量。由于这些物质稳定且可重复，因此监测到的数据能够在多年内有效使用。&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://img14.360buyimg.com/ddimg/jfs/t1/245133/12/34980/94840/69017b7aF45bd11ff/da58b5daa3d8caba.jpg&quot; alt=&quot;土壤成分检测技术原理.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;此外，还需要从田间提取土壤样本。每个田地的样品数量基于田地大小，源于每 8 英亩（3 公顷）1 个样品的比率;对于小于 25ac （10ha）的田地，至少需要 3 个样品。&lt;/p&gt;

&lt;p&gt;结合传感器收集数据和土地采样信息，SoilOptix团队会在48小时内为用户们提供一份全方位展现耕地&lt;strong&gt;物理特性、宏微观影响因素、PH值、以及有机物在内的25层土壤分析图&lt;/strong&gt;，直观全面地展现土壤的状况，帮助种植者们准确判断“种什么、种哪里、什么时候种”的问题，达到产量目标、作物死亡率和土壤肥力的最佳平衡，以获得经济和环境的双赢。&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;对80 英亩（32 公顷）的田地进行了采样，其中获得了 10 个土壤样本&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;img src=&quot;https://img10.360buyimg.com/ddimg/jfs/t1/346203/11/18232/52594/69017b8cF8fda93bb/8c789ad7d1393d65.jpg&quot; alt=&quot;土壤成分表1.png&quot; /&gt;
&lt;img src=&quot;https://img13.360buyimg.com/ddimg/jfs/t1/341748/32/19262/65918/69017b9aF0f848466/10fe61aec42c70ed.jpg&quot; alt=&quot;土壤成分表2.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Greasley在德比郡经营一家占地80公顷的畜牧场，SoilOptix的Terramap 产品提供的PH值地图图层让他节约了大量成本。“如果对所有田地都进行无差别的酸碱度调整措施，那么每公顷土地需要消耗5000公斤石灰；但SoilOptix使我们明确需要调整的点位，按需施用仅消耗石灰3050公斤，节省下来的石灰和人力成本可到达每公顷 66 英镑。”&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;原文：https://www.hutchinsons.co.uk/how-terramap-is-saving-a-derbyshire-farmer-over-66-ha-in-liming-costs/&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;img src=&quot;https://img12.360buyimg.com/ddimg/jfs/t1/353557/31/2454/49186/69017bacFe7614018/011fd237278426b8.jpg&quot; alt=&quot;pH.png&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;可用的地表土壤属性&quot;&gt;可用的地表土壤属性&lt;/h4&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;分类&lt;/th&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;strong&gt;Physical Properties（物理性质）&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt;Clay&lt;/td&gt;
      &lt;td&gt;黏土含量 (%)&lt;/td&gt;
      &lt;td&gt;土壤中粒径 &amp;lt;0.002 mm 部分的比例&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt;Sand&lt;/td&gt;
      &lt;td&gt;砂含量 (%)&lt;/td&gt;
      &lt;td&gt;土壤中粒径 0.05–2 mm 部分的比例&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt;Loam&lt;/td&gt;
      &lt;td&gt;壤土比例&lt;/td&gt;
      &lt;td&gt;表征土壤质地平衡程度的综合指标&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt;Silt&lt;/td&gt;
      &lt;td&gt;粉粒含量 (%)&lt;/td&gt;
      &lt;td&gt;土壤中粒径 0.002–0.05 mm 部分的比例&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt;Cation Exchange Capacity (CEC)&lt;/td&gt;
      &lt;td&gt;阳离子交换量&lt;/td&gt;
      &lt;td&gt;土壤吸附与交换养分的能力（单位：cmol(+)/kg）&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt;Organic Matter&lt;/td&gt;
      &lt;td&gt;有机质含量 (%)&lt;/td&gt;
      &lt;td&gt;土壤中来源于动植物残体的有机成分&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;🧪 &lt;strong&gt;Macro Nutrients（常量营养元素）&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt;Calcium (Ca)&lt;/td&gt;
      &lt;td&gt;钙含量&lt;/td&gt;
      &lt;td&gt;促进根系发育、改善土壤结构&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt;Calcium-Base Saturation&lt;/td&gt;
      &lt;td&gt;钙基饱和度 (%)&lt;/td&gt;
      &lt;td&gt;交换性阳离子中钙所占比例&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt;Calcium-Magnesium Ratio&lt;/td&gt;
      &lt;td&gt;钙镁比&lt;/td&gt;
      &lt;td&gt;土壤中钙、镁离子的平衡关系&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt;Magnesium Base Saturation&lt;/td&gt;
      &lt;td&gt;镁基饱和度 (%)&lt;/td&gt;
      &lt;td&gt;交换性阳离子中镁所占比例&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt;Potassium-Magnesium Ratio&lt;/td&gt;
      &lt;td&gt;钾镁比&lt;/td&gt;
      &lt;td&gt;土壤中钾、镁比例关系&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt;pH&lt;/td&gt;
      &lt;td&gt;酸碱度&lt;/td&gt;
      &lt;td&gt;土壤溶液的酸碱水平&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt;Phosphorus-Bicarb&lt;/td&gt;
      &lt;td&gt;重碳酸盐磷（Olsen-P）&lt;/td&gt;
      &lt;td&gt;碳酸盐或中性土壤中可有效利用的磷&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt;Phosphorus-Bray&lt;/td&gt;
      &lt;td&gt;Bray 磷&lt;/td&gt;
      &lt;td&gt;酸性土壤中可利用磷含量&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt;Potassium (K)&lt;/td&gt;
      &lt;td&gt;钾含量&lt;/td&gt;
      &lt;td&gt;作物生长必需的大量元素之一&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt;Potassium Base Saturation&lt;/td&gt;
      &lt;td&gt;钾基饱和度 (%)&lt;/td&gt;
      &lt;td&gt;交换性阳离子中钾所占比例&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt;Nitrate as N&lt;/td&gt;
      &lt;td&gt;硝态氮 (以N计)&lt;/td&gt;
      &lt;td&gt;土壤中可直接被植物吸收的氮形态&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;🧩 &lt;strong&gt;Micro Nutrients（微量营养元素）&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt;Aluminum (Al)&lt;/td&gt;
      &lt;td&gt;铝&lt;/td&gt;
      &lt;td&gt;高浓度时对根系有毒性&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt;Boron (B)&lt;/td&gt;
      &lt;td&gt;硼&lt;/td&gt;
      &lt;td&gt;与花粉活性、细胞分裂相关&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt;Copper (Cu)&lt;/td&gt;
      &lt;td&gt;铜&lt;/td&gt;
      &lt;td&gt;参与酶活性与光合作用&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt;Iron (Fe)&lt;/td&gt;
      &lt;td&gt;铁&lt;/td&gt;
      &lt;td&gt;参与叶绿素合成与电子传递&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt;Manganese (Mn)&lt;/td&gt;
      &lt;td&gt;锰&lt;/td&gt;
      &lt;td&gt;参与光合作用与氧化还原反应&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt;Sodium (Na)&lt;/td&gt;
      &lt;td&gt;钠&lt;/td&gt;
      &lt;td&gt;过高会导致盐害&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt;Sulfur (S)&lt;/td&gt;
      &lt;td&gt;硫&lt;/td&gt;
      &lt;td&gt;构成氨基酸和蛋白质的成分&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt;Zinc (Zn)&lt;/td&gt;
      &lt;td&gt;锌&lt;/td&gt;
      &lt;td&gt;参与酶合成、促进生长素生成&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;⚙️ &lt;strong&gt;Complex Models（复杂模型/衍生属性）&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt;Plant Available Water&lt;/td&gt;
      &lt;td&gt;植物可利用水分&lt;/td&gt;
      &lt;td&gt;指植物能从土壤中吸收的有效水分含量&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt;Elevation&lt;/td&gt;
      &lt;td&gt;高程&lt;/td&gt;
      &lt;td&gt;地表相对高度（m）&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt;Leakability&lt;/td&gt;
      &lt;td&gt;渗透性/漏失性&lt;/td&gt;
      &lt;td&gt;土壤水分渗漏或流失的易发生程度&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;img src=&quot;https://img14.360buyimg.com/ddimg/jfs/t1/338165/12/26237/75425/69017bbcFfdbd1be9/ce08aa71094da58b.jpg&quot; alt=&quot;土壤属性图.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Nutrien VRA 石灰施用处方图（Lime Prescription Zone Map）。基于可变速率施用（Variable Rate Application, VRA）技术生成的石灰施用区划图。
该图用于根据土壤酸碱度（pH）、缓冲能力、有机质及养分状况等差异，将农田划分为多个管理区，从而确定每个区域应施用的石灰量。通过这种方式，可在保证土壤酸碱平衡的同时，实现精准施肥、节约成本、提高作物产量和土壤健康。&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://img10.360buyimg.com/ddimg/jfs/t1/344696/28/19412/114353/69017bcdFd81cbd56/f1202d693505add1.jpg&quot; alt=&quot;石灰施用处方图.png&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;medusa-explorations&quot;&gt;Medusa Explorations&lt;/h3&gt;

&lt;p&gt;公司位于荷兰，其部门&lt;strong&gt;Medusa Radiometrics&lt;/strong&gt;制作伽马射线传感器等来检土壤成分。通过伽马射线可以测量土壤中的&lt;strong&gt;有机质、湿度&lt;/strong&gt;等指标。&lt;/p&gt;

&lt;h4 id=&quot;应用案例土壤测绘以提高作物产量&quot;&gt;应用案例：土壤测绘以提高作物产量&lt;/h4&gt;

&lt;p&gt;在西班牙北部半干旱地区的许多依靠雨水灌溉、位于高海拔的农田中，土壤容易受到侵蚀、压实，并且有机质含量较低。因此，这些土壤的养分供应能力和持水能力都较差。再加上降水量低，导致作物产量低，农业生产难以持续。&lt;/p&gt;

&lt;p&gt;欧盟 LIFE+ 项目“Crops for better soil”（更优土壤作物项目）旨在通过一系列农艺措施，证明这些农田的（土地和经济）产出都可以得到改善。该项目通过在100多个农田上实施这些措施，在相当大的规模上验证了这一方法。这些农田总面积为300至400公顷，分布在卡斯蒂利亚-拉曼查（瓜达拉哈拉）、阿拉贡、纳瓦拉以及卡斯蒂利亚-莱昂（萨莫拉/贝纳文特）等地区，由14至20位不同的农民所有。&lt;/p&gt;

&lt;p&gt;所采取的农艺措施包括：转向有机农业、增加作物轮作、引入豆科植物，以及推广更适应寒冷半干旱气候的传统作物品种。&lt;/p&gt;

&lt;p&gt;为评估哪些作物和哪种轮作适合哪种田地，并评估土壤的改良情况，设计了土壤数据采集和监测计划。要评估的土壤和田地特性包括土壤质地、土壤有机质、耕作层深度、压实度、海拔、坡度和养分浓度。&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://img11.360buyimg.com/ddimg/jfs/t1/346022/27/19006/131292/69017bddF11e82a9b/622cc1c2a8c5bb9e.jpg&quot; alt=&quot;土壤测绘方法.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;所使用的多种数据类型示例如下：IGME 提供的激光雷达数字高程模型（LIDAR DEM，左上）、IGME 的 MAGNA 50 地质图（左上）、由伽马射线能谱仪获取的⁴⁰K（钾-40）浓度分布图（右上）、由地质雷达（GPR）获取的 0–20 厘米深度时间切片（左下）以及 20–80 厘米深度时间切片（右下）。这些农田位于马德里以东、卡斯蒂利亚-拉曼查大区的伊亚纳（Illana）附近。&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://img14.360buyimg.com/ddimg/jfs/t1/345687/17/18435/206272/69017bfbF11731775/1a1d7b0e59008efe.jpg&quot; alt=&quot;多种数据类型图.png&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;处方图相关方法&quot;&gt;处方图相关方法&lt;/h2&gt;

&lt;h3 id=&quot;一般流程&quot;&gt;一般流程&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;土壤样品采集&lt;/li&gt;
  &lt;li&gt;实验室数据分析&lt;/li&gt;
  &lt;li&gt;结果解读&lt;/li&gt;
  &lt;li&gt;肥料施用建议&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;插值方法&quot;&gt;插值方法&lt;/h3&gt;

&lt;h4 id=&quot;克里金插值&quot;&gt;克里金插值&lt;/h4&gt;

&lt;h4 id=&quot;反距离权重插值&quot;&gt;反距离权重插值&lt;/h4&gt;

&lt;h3 id=&quot;土壤数据点采样测土方法&quot;&gt;土壤数据点采样测土方法&lt;/h3&gt;

&lt;h4 id=&quot;grid测土&quot;&gt;Grid测土&lt;/h4&gt;

&lt;p&gt;Grid 测土通常要求较高的采样密度，可能会在1-5米的网格范围内进行采样，适合对土壤特性进行高精度分析。通过规则网格化采样，保证了数据点的均匀分布。每个网格中需要采样点，因此会产生大量数据，有时需要大量的计算和分析。&lt;/p&gt;

&lt;h4 id=&quot;zone测土&quot;&gt;Zone测土&lt;/h4&gt;

&lt;p&gt;土壤的地力成分并不是线性分布的，因此采用格点方式进行分割，取得的测土数据很有可能不能反映出地块的全貌。&lt;/p&gt;

&lt;p&gt;Zone 测土技术，首先利用土壤、遥感、地形等数据将地块划分为若干区域（Zones），每个区域土壤情况相对一致，这样可以适当减少每个区域的测土数量，降低成本；同时，按照区域的方式进行测土规划，能够更加精准地还原土壤数据的全貌，提升测土的精度。&lt;/p&gt;

&lt;p&gt;当拿到基于Zone的测土数据后，我们还可以进一步优化Zone Map，让地块的区域划分更加合理，为后续的测土规划、变量处方图的制作提供更加精准而有力的支撑。&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;项目&lt;/th&gt;
      &lt;th&gt;Grid 测土&lt;/th&gt;
      &lt;th&gt;Zone 测土&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;采样密度&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;高（密集的采样点）&lt;/td&gt;
      &lt;td&gt;低（每个区域一个采样点）&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;数据量&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;数据量大，分析复杂&lt;/td&gt;
      &lt;td&gt;数据量少，分析简单&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;精度&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;高（适合详细分析）&lt;/td&gt;
      &lt;td&gt;低（适合大致评估）&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;成本&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;高（需要更多资源）&lt;/td&gt;
      &lt;td&gt;低（节省资源和时间）&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;适用范围&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;精准农业、土地细分分析&lt;/td&gt;
      &lt;td&gt;土地管理、大规模区域性调查&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;应用场景&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;土壤成分精确分析，作物精准施肥&lt;/td&gt;
      &lt;td&gt;区域性土壤质量监测和评估&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;Grid采样、 EC–Zone Sampling、SoilOptix采样区别：&lt;a href=&quot;https://soiloptix.com/wp-content/uploads/2021/11/SoilOptix-Technology-Comparison-Study.pdf&quot;&gt;pdf&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4 id=&quot;medusa伽马射线光谱仪数据采集示例&quot;&gt;Medusa伽马射线光谱仪数据采集示例&lt;/h4&gt;

&lt;blockquote&gt;
  &lt;p&gt;原文：https://the.medusa.institute/wiki/Working-version/on-accuracy-and-spatial-resolution#Onaccuracyandspatialresolution-RepeatedAverage&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;我们使用了一个来自农田的示例数据集，该农田面积为 300×400 米，测绘时的测线间距为 12 米。采样频率为 1 Hz，车辆以 3.6 km/h 的速度行驶，因此相邻采样点之间的距离约为 1 米。&lt;/p&gt;

&lt;p&gt;该数据集使用三种不同的方法进行了分析。在本次分析中，采用了一个较大的样本窗口，即对 15 个数据点进行平均处理，这会放大平滑效果。通常情况下，并不会采用 15 个样本的滑动平均，而是会使用较少数量的样本进行平滑计算。&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Fit each 方法&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
  &lt;p&gt;对每一个采样点分别进行拟合或插值计算，而不对数据进行平滑或平均。&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;该方法的结果显示了所有数据点，但整体表现出一定的“噪声”特征。使用简单的 &lt;strong&gt;反距离加权（IDW）&lt;/strong&gt; 生成的地图中，可以看到许多极端的高值和低值，因此需要应用 &lt;strong&gt;空间平滑滤波器（spatial smoothing filter）&lt;/strong&gt; 来去除噪声、改善空间连续性。&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://the.medusa.institute/__attachments/351143217/worddavbd47c62cad236a4c73965b3448411173.png?inst-v=e2dfee16-41a5-4baf-a20c-9cfa3e0d709c&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://the.medusa.institute/__attachments/351143217/worddav83dc554e20b3d359685d043d13fc9806.png?inst-v=e2dfee16-41a5-4baf-a20c-9cfa3e0d709c&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;滑动平均法（Running Average）&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;采用滑动平均方法后，数据在测线方向上表现出明显的高值区和低值区。在对数据进行插值时，这种各向异性（anisotropy）特征十分明显，呈现出沿测线分布的条带状结构。&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://the.medusa.institute/__attachments/351143217/worddavf36cd7e04114d6b1aa853986de2a5690.png?inst-v=e2dfee16-41a5-4baf-a20c-9cfa3e0d709c&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://the.medusa.institute/__attachments/351143217/worddav97776506c4baeb2759a3a6bb1615eba5.png?inst-v=e2dfee16-41a5-4baf-a20c-9cfa3e0d709c&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;重复平均法（Repeated Average）&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;经过重复平均分析后，数据集中包含的采样点数量减少，但这些点不再沿测线分布，而是呈现出更加均匀（随机）分布的空间格局。&lt;/p&gt;

&lt;p&gt;每个采样点都具有较高的精度，这在插值结果中得到了体现：高值和低值在网格中表现为&lt;strong&gt;“斑点状（bullet-like）”分布&lt;/strong&gt;。这种分布是&lt;strong&gt;各向同性（omnidirectional）&lt;/strong&gt;的，不会出现沿测线方向的过度采样现象。&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://the.medusa.institute/__attachments/351143217/worddavc1034695c3ec33378bfa845be05af6b6.png?inst-v=e2dfee16-41a5-4baf-a20c-9cfa3e0d709c&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://the.medusa.institute/__attachments/351143217/worddav585b384fb2f913fbb88573e4c54ec955.png?inst-v=e2dfee16-41a5-4baf-a20c-9cfa3e0d709c&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;方法名称&lt;/th&gt;
      &lt;th&gt;原理概述&lt;/th&gt;
      &lt;th&gt;数据特征&lt;/th&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;strong&gt;Fit each&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;对每个采样点单独拟合，不进行平滑或平均处理；所有原始数据直接用于插值&lt;/td&gt;
      &lt;td&gt;数据完整，细节丰富，但噪声大&lt;/td&gt;
      &lt;td&gt;保留全部原始信息；便于发现异常点&lt;/td&gt;
      &lt;td&gt;噪声多，空间连续性差；需后续平滑处理&lt;/td&gt;
      &lt;td&gt;初步数据探索；噪声分析；原始信号验证&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;Running Average&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;沿采样路径对连续数据进行滑动平均（如每次平均 3–5 个点）&lt;/td&gt;
      &lt;td&gt;沿测线方向平滑，形成条带结构（各向异性明显）&lt;/td&gt;
      &lt;td&gt;降低噪声；平滑局部波动&lt;/td&gt;
      &lt;td&gt;容易产生条纹效应；丢失横向空间特征&lt;/td&gt;
      &lt;td&gt;实时监测；沿轨迹数据平滑；线性传感分析&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;Repeated Average&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;多次平均并重新采样，使点分布更加均匀随机&lt;/td&gt;
      &lt;td&gt;数据点更少但分布均匀；无明显方向性&lt;/td&gt;
      &lt;td&gt;平滑且各向同性；噪声低，插值效果更自然&lt;/td&gt;
      &lt;td&gt;细节略有损失；需较多计算&lt;/td&gt;
      &lt;td&gt;制图与建模；空间插值；最终成果展示&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h3 id=&quot;土壤成分探测方法&quot;&gt;土壤成分探测方法&lt;/h3&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;&lt;strong&gt;方法&lt;/strong&gt;&lt;/th&gt;
      &lt;th&gt;&lt;strong&gt;技术描述&lt;/strong&gt;&lt;/th&gt;
      &lt;th&gt;&lt;strong&gt;应用/用途&lt;/strong&gt;&lt;/th&gt;
      &lt;th&gt;&lt;strong&gt;优点&lt;/strong&gt;&lt;/th&gt;
      &lt;th&gt;&lt;strong&gt;缺点&lt;/strong&gt;&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;传统土壤采样与实验室分析&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;采集土壤样本并通过实验室化学分析测试主要养分（氮、磷、钾等）、pH、有机质、CEC等。&lt;/td&gt;
      &lt;td&gt;提供准确的土壤化学成分、物理性质和有机质含量的详细信息。&lt;/td&gt;
      &lt;td&gt;高精度，标准化方法。&lt;/td&gt;
      &lt;td&gt;成本高，时间长，空间覆盖局限。&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;卫星遥感&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;通过卫星影像分析土壤反射率，推算土壤湿度、养分含量等，利用光谱反射特性分析土壤组成。&lt;/td&gt;
      &lt;td&gt;适用于大范围土壤监测，提供土壤湿度、养分分布等的空间分布数据。&lt;/td&gt;
      &lt;td&gt;大范围覆盖，实时监测。&lt;/td&gt;
      &lt;td&gt;精度较低，受环境影响较大，无法提供详细的土壤成分数据。&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;无人机遥感&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;利用高分辨率相机和光谱传感器搭载于无人机，获取农田土壤的详细影像和光谱数据。&lt;/td&gt;
      &lt;td&gt;提供农田的详细土壤信息，评估土壤湿度、肥力等。&lt;/td&gt;
      &lt;td&gt;高分辨率，快速获取数据。&lt;/td&gt;
      &lt;td&gt;高成本，需要技术支持，数据处理量大。&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;电磁探测&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;使用电磁感应仪（EMI）通过测量土壤电导率来推算土壤盐分、湿度等。&lt;/td&gt;
      &lt;td&gt;适用于评估土壤的盐分、含水量等。&lt;/td&gt;
      &lt;td&gt;非侵入性，快速获取大范围数据。&lt;/td&gt;
      &lt;td&gt;精度较低，无法直接测量详细的化学成分。&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;伽马射线探测&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;通过探测土壤中的自然放射性元素（如钾-40、铀、钍等）辐射推算土壤的矿物成分。&lt;/td&gt;
      &lt;td&gt;用于评估土壤中钾、铀、钍等元素的分布情况，间接推算土壤的矿物成分。&lt;/td&gt;
      &lt;td&gt;非侵入性，快速覆盖大面积区域。&lt;/td&gt;
      &lt;td&gt;只能推算某些矿物成分（如钾），不能测量氮、磷、pH等成分。&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;近红外光谱（NIR）分析&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;测量土壤样本的光谱反射特性，通过光谱数据推算土壤的有机质含量、水分和矿物成分。&lt;/td&gt;
      &lt;td&gt;用于快速分析土壤的有机质、湿度、矿物含量等。&lt;/td&gt;
      &lt;td&gt;高效、非破坏性，快速获取数据。&lt;/td&gt;
      &lt;td&gt;需与化学分析结合，且精度受限于光谱数据模型的准确性。&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;土壤传感器网络&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;在农田中布设土壤传感器，实时监测土壤的pH、湿度、温度、盐分等。&lt;/td&gt;
      &lt;td&gt;提供实时的土壤数据，帮助农民实时调整施肥、灌溉等管理措施。&lt;/td&gt;
      &lt;td&gt;实时监测，高精度，连续数据。&lt;/td&gt;
      &lt;td&gt;高成本，设备需要维护，数据处理复杂。&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;智能农业管理系统&lt;/strong&gt;&lt;/td&gt;
      &lt;td&gt;集成多种技术，如土壤传感器、遥感数据、电磁探测等，进行土壤监测和作物管理，结合数据分析提供精准管理建议。&lt;/td&gt;
      &lt;td&gt;用于精确管理农业生产，提供&lt;strong&gt;土壤处方图&lt;/strong&gt;和作物管理方案。&lt;/td&gt;
      &lt;td&gt;集成多种技术，提供全面、精准的农业管理方案。&lt;/td&gt;
      &lt;td&gt;需要高成本的设备和技术支持，系统复杂，数据分析需要强大的计算能力。&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;blockquote&gt;
  &lt;p&gt;使用传感器探测土壤成分时，需要结合土壤采样来分析。&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2 id=&quot;分辨率&quot;&gt;分辨率&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;原文：https://soiloptix.com/case_studies/a-clear-advantage-over-zone-sampling/#ftn7&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;SoilOptix提供高分辨率的数据采集方法：335个数据点/英亩。下面分别是SoilOptix方法和其他方法的钾元素分布图。高分辨率数据可以分析更加细微的小区域，同时避免将存在差异性的区域连接成一片。&lt;/p&gt;

&lt;div style=&quot;display: flex; justify-content: center; &quot;&gt;
  &lt;img src=&quot;https://soiloptix.com/wp-content/uploads/2024/04/Figure3_northeast-section.png&quot; alt=&quot;图片1&quot; style=&quot;margin-right: 10px;&quot; /&gt;
  &lt;img src=&quot;https://soiloptix.com/wp-content/uploads/2024/04/Figure4_Zone-Script_Muriate-of-Potash-219x300.png&quot; alt=&quot;图片2&quot; /&gt;
&lt;/div&gt;
</description>
        <pubDate>Wed, 29 Oct 2025 00:00:00 +0000</pubDate>
        <link>https://yucol.top/tech/%E5%9C%9F%E5%A3%A4%E5%A4%84%E6%96%B9%E5%9B%BE.html</link>
        <guid isPermaLink="true">https://yucol.top/tech/%E5%9C%9F%E5%A3%A4%E5%A4%84%E6%96%B9%E5%9B%BE.html</guid>
        
        <category>土壤处方图</category>
        
        <category>GIS</category>
        
        <category>智慧农业</category>
        
        
        <category>tech</category>
        
      </item>
    
  </channel>
</rss>
