<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>NotionNext BLOG</title>
        <link>https://blog.gusibi.mobi/</link>
        <description>这是一个由NotionNext生成的站点</description>
        <lastBuildDate>Sat, 04 Nov 2023 06:22:57 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>zh-CN</language>
        <copyright>All rights reserved 2023, Gusibi</copyright>
        <item>
            <title><![CDATA[Flutter完全指南:如何实现夜间模式、动态主题和主题切换]]></title>
            <link>https://blog.gusibi.mobi/article/flutter-theme-switching-guide</link>
            <guid>https://blog.gusibi.mobi/article/flutter-theme-switching-guide</guid>
            <pubDate>Sat, 02 Sep 2023 00:00:00 GMT</pubDate>
            <description><![CDATA[本文全方位介绍如何在Flutter App中实现夜间模式、动态切换主题颜色、以及跨页面主题切换。教你如何配置明暗两套主题,在夜间和白天模式间无缝切换。并使用Provider方式实现主题的动态配置,允许在不重写UI代码的情况下切换主题。学习掌握Flutter的主题机制,可以打造支持主题切换的优秀App。]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-c17c440d099c4e39be8605530a5c46e2"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-078d5e0f64454f89b8f8b51bf241b3da" data-id="078d5e0f64454f89b8f8b51bf241b3da"><span><div id="078d5e0f64454f89b8f8b51bf241b3da" class="notion-header-anchor"></div><a class="notion-hash-link" href="#078d5e0f64454f89b8f8b51bf241b3da" title="前言"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">前言</span></span></h3><div class="notion-text notion-block-0f0f9cff4eff419193b922a9a65d3b6e">最近在学习 Flutter 开发,其中主题切换是一个增强用户体验的重要方式,也是 Flutter 学习中不可忽略的一个主题。本文将详细介绍 Flutter 在主题切换方面的实现。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-b86490c8111e483a9aea500d16e02653" data-id="b86490c8111e483a9aea500d16e02653"><span><div id="b86490c8111e483a9aea500d16e02653" class="notion-header-anchor"></div><a class="notion-hash-link" href="#b86490c8111e483a9aea500d16e02653" title="主要内容"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">主要内容</span></span></h3><div class="notion-text notion-block-a48602a540a042d3b7fb531017f6ddad">这篇文章主要介绍以下几个模块的内容：</div><ul class="notion-list notion-list-disc notion-block-4c0985bbf5064bc0aa0bf33b36da5a00"><li>为什么 App 需要支持更换主题</li></ul><ul class="notion-list notion-list-disc notion-block-9996fea0968b4f968a60f8608237c3e0"><li>Flutter 如何设置主题</li></ul><ul class="notion-list notion-list-disc notion-block-63f10c2970ef4d8a9843c8768ad9a4b6"><li>Flutter 如何在夜间和白天模式之间切换</li></ul><ul class="notion-list notion-list-disc notion-block-857d8dfad3314e1f991b5e0ea722d09b"><li>Flutter 如何动态切换颜色主题</li><ul class="notion-list notion-list-disc notion-block-857d8dfad3314e1f991b5e0ea722d09b"><li>如何使用 provider 实现主题的动态切换</li></ul></ul><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-bfad034376054c81a1eff5b327681f21" data-id="bfad034376054c81a1eff5b327681f21"><span><div id="bfad034376054c81a1eff5b327681f21" class="notion-header-anchor"></div><a class="notion-hash-link" href="#bfad034376054c81a1eff5b327681f21" title="为什么 App 需要支持更换主题"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">为什么 App 需要支持更换主题</span></span></h2><ul class="notion-list notion-list-disc notion-block-a3f4ad97747442c4978b2056ef6b61a2"><li>提高用户体验: 不同用户有不同的审美偏好, 主题切换可以满足更多用户的视觉喜好。</li></ul><ul class="notion-list notion-list-disc notion-block-acccf2428b8945dcb202c2e63b7df241"><li>个性化体验:主题切换可以展现 App 的个性化特点,让用户自定义主题以个性化其使用体验。</li></ul><ul class="notion-list notion-list-disc notion-block-c8d7951e553f47e6a1acef64e79438c4"><li>辅助可访问性:对于视力障碍用户,切换到高对比度的主题可以提升 App 的可访问性。</li></ul><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-80c9a1ed2408455cb7609555495ee9da" data-id="80c9a1ed2408455cb7609555495ee9da"><span><div id="80c9a1ed2408455cb7609555495ee9da" class="notion-header-anchor"></div><a class="notion-hash-link" href="#80c9a1ed2408455cb7609555495ee9da" title="Flutter 如何设置主题"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Flutter 如何设置主题</span></span></h2><div class="notion-text notion-block-df8a7aec19374058bd55b151684bd8f9">Flutter 中设置主题非常简单, 只需要配置主题的参数即可。如果不设置, Flutter 也会使用默认主题。，就像这样。
</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-52f5277928e048c2ac6dd7c7a25cd718"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:490px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fb99f81dc-b10f-4161-b1e6-1b562952b358%2Fd0a31d7e-a113-407c-8f4c-17a4b08d51dd%2FUntitled.png?table=block&amp;id=52f52779-28e0-48c2-ac6d-d7c7a25cd718&amp;t=52f52779-28e0-48c2-ac6d-d7c7a25cd718" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-de82f7443dae4bbfa156587ed5f99e21">如果你不喜欢默认主题的颜色，只需要在 <code class="notion-inline-code">MaterialApp</code> 中编辑 theme 即可更新主题。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-841fd7e4e1d540a6ba14071f6e22384c"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:486px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fb99f81dc-b10f-4161-b1e6-1b562952b358%2F8f0381b2-6b39-457c-99c1-0fa6d2fe2b4b%2FUntitled.png?table=block&amp;id=841fd7e4-e1d5-40a6-ba14-071f6e22384c&amp;t=841fd7e4-e1d5-40a6-ba14-071f6e22384c" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-5f9e3d4cce09472e9193a9257243a2de">如果想使用夜间模式，只需要增加 <code class="notion-inline-code">darkTheme: ThemeData.dark()</code>。</div><div class="notion-text notion-block-45fb4c942ec24d0cbf9c0814455c6144">这样 app 会根据系统的设置自动变更主题模式。如果想要手动指定主题模式，可以在代码中设置 <code class="notion-inline-code">themeMode: ThemeMode.light</code>。这样会强制制定 app 的主题模式为白天模式。</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-c75bf2684e7f4a39adcfb5f34ff4ddab" data-id="c75bf2684e7f4a39adcfb5f34ff4ddab"><span><div id="c75bf2684e7f4a39adcfb5f34ff4ddab" class="notion-header-anchor"></div><a class="notion-hash-link" href="#c75bf2684e7f4a39adcfb5f34ff4ddab" title="Material 3 如何设置"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Material 3 如何设置</span></span></h4><div class="notion-text notion-block-5a7de67e85944e2db13e0f89d7be8a47">Material 3 的设置更简单一些，只需要指定使用 <code class="notion-inline-code">useMaterial3: true</code> 即可。</div><div class="notion-callout notion-gray_background_co notion-block-19627f50a4ac46f7a79086ba1fe9fa0c"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="💡">💡</span></div><div class="notion-callout-text">后续的所有示例代码都使用 Material3。</div></div><div class="notion-blank notion-block-2454056603c04290b04ea429a55c77d0"> </div><div class="notion-text notion-block-13c638530efc40359f06823dfb02bb94">Material 3的允许用户从单个种子颜色设置整个应用程序的颜色主题。在你的主题构造器中设置配色方案种子参数，Flutter 会从这个条目中为你的应用中的每个小部件生成一个和谐的配色方案。
比如下图是 <code class="notion-inline-code">colorSchemeSeed: const Color.fromARGB(86, 80, 14, 171),</code> 的配色方案：</div><div class="notion-blank notion-block-a7202abb911840bfade7d7836600cac7"> </div><div class="notion-blank notion-block-425d175779e748f6a1de7d7ec2964499"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-a4f9dc00cc66495c98f65417f9e1adc8"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:387px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fb99f81dc-b10f-4161-b1e6-1b562952b358%2F36b0e64e-2e04-4f4f-aa50-545b448f73ea%2FUntitled.png?table=block&amp;id=a4f9dc00-cc66-495c-98f6-5417f9e1adc8&amp;t=a4f9dc00-cc66-495c-98f6-5417f9e1adc8" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-f5a0b9a813a849039fb282d59924042e"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:386px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fb99f81dc-b10f-4161-b1e6-1b562952b358%2Fedbf18e4-48b5-414f-b23c-5f2737bdbf4f%2FUntitled.png?table=block&amp;id=f5a0b9a8-13a8-4903-9fb2-82d59924042e&amp;t=f5a0b9a8-13a8-4903-9fb2-82d59924042e" alt="notion image" loading="lazy" decoding="async"/></div></figure><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-37383a1ad31548cda6f6ef0825c7e924" data-id="37383a1ad31548cda6f6ef0825c7e924"><span><div id="37383a1ad31548cda6f6ef0825c7e924" class="notion-header-anchor"></div><a class="notion-hash-link" href="#37383a1ad31548cda6f6ef0825c7e924" title="Flutter 如何在夜间和白天模式之间切换"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Flutter 如何在夜间和白天模式之间切换</span></span></h2><div class="notion-text notion-block-c4200c699a964384aed0cd4adb4b202f">在应用程序中，白天模式和夜间模式是指应用程序的显示风格。白天模式通常使用明亮的颜色和高对比度，而夜间模式则使用深色背景和低对比度。</div><div class="notion-text notion-block-52497ee4f6e64d7d97e2079a448ddf8d">白天模式通常用于在明亮的环境下使用应用程序，因为明亮的颜色和高对比度可以帮助用户更好地查看内容。夜间模式通常用于在昏暗的环境下使用应用程序，因为深色背景和低对比度可以减少眼睛疲劳。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-58b208f086264dd88af88e3d2ef4d161"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:422px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fb99f81dc-b10f-4161-b1e6-1b562952b358%2Fa467e73d-5eba-4a0e-8ba6-d2b1840cc7dd%2FUntitled.gif?table=block&amp;id=58b208f0-8626-4dd8-8af8-8e3d2ef4d161&amp;t=58b208f0-8626-4dd8-8af8-8e3d2ef4d161" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-b2b08fb778524418a80f31201adba60b"> </div><div class="notion-text notion-block-c555c73eaa174b058531b20d8574fdb6">在 Flutter 中动态切换白天和夜间模式非常简单，只需要增加一个中间变量来存储主题的模式。</div><div class="notion-text notion-block-0865bc5941ab44aabca842b7bc7835bf">实现模式切换的步骤:</div><ol start="1" class="notion-list notion-list-numbered notion-block-e5381ab7145548b9bfef2213052e56f3"><li>定义白天和夜间两套主题;</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-eb81f921b7de4c1fa37ace1059e7fbb0"><li>添加一个 ThemeMode 变量来保存当前主题模式;</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-5db3172959cd4a6f8196eaffc8a0ad01"><li>通过设置该变量为 light/dark 来切换主题模式;</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-b25184f45eee428199f4bd0470362931"><li>切换后界面会自动build以应用新的主题。</li></ol><div class="notion-text notion-block-54a1a0679d9649f692c8d7ba5480b1e0">具体代码如下：</div><div class="notion-text notion-block-751f62ecd73e448f85a051b240721d3e">这段代码定义了一个简单的 Flutter 应用程序，有明暗两种主题。代码首先定义了一个 <code class="notion-inline-code">ThemeMode</code> 变量 <code class="notion-inline-code">themeMode</code>，并初始化为 <code class="notion-inline-code">ThemeMode.system</code>。这意味着应用程序将使用系统的默认主题，通常是 Android 上的明亮主题和 iOS 上的暗黑主题。</div><div class="notion-text notion-block-2d537715a4c2477487f135a1dee63287">接下来定义明暗两种主题。明亮主题使用 <code class="notion-inline-code">ThemeData</code> 类来定义。<code class="notion-inline-code">useMaterial3</code> 属性设置为 <code class="notion-inline-code">true</code> 以使用新的 Material 3 设计语言。<code class="notion-inline-code">colorSchemeSeed</code> 属性设置为特定颜色，该颜色将用作主题的基础色。</div><div class="notion-text notion-block-70fd170c50914074836826a85b5402ac">暗黑主题类似定义，只是 <code class="notion-inline-code">brightness</code> 属性设置为 <code class="notion-inline-code">Brightness.dark</code>。</div><div class="notion-text notion-block-9edfbc1d8a0644e7952712ae0928e121">最后，使用 <code class="notion-inline-code">MaterialApp</code> 小部件来创建应用程序。<code class="notion-inline-code">theme</code> 属性设置为明亮主题，<code class="notion-inline-code">themeMode</code> 属性设置为 <code class="notion-inline-code">themeMode</code> 变量。这意味着应用程序将以明亮主题启动，但用户可以通过单击相应的按钮将主题更改为暗黑。</div><div class="notion-text notion-block-43bbbfe729364b1bb497c9d8d7681d47"><code class="notion-inline-code">Scaffold</code> 小部件用于创建应用程序的基本布局。<code class="notion-inline-code">appBar</code> 属性用于创建应用栏，<code class="notion-inline-code">backgroundColor</code> 属性设置为当前主题的 primary container 颜色。<code class="notion-inline-code">body</code> 属性用于创建应用程序的主体，在本例中是一个简单的列表，其中包含两个按钮。</div><div class="notion-text notion-block-0c57177d596c40cd948498c895089320">两个按钮用于更改主题。当用户单击 &quot;light&quot; 按钮时，<code class="notion-inline-code">themeMode</code> 变量将设置为 <code class="notion-inline-code">ThemeMode.light</code>，应用程序将切换到明亮主题。当用户单击 &quot;dark&quot; 按钮时，<code class="notion-inline-code">themeMode</code> 变量将设置为 <code class="notion-inline-code">ThemeMode.dark</code>，应用程序将切换到暗黑主题。</div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-ef6894fd53b54998a2bec85e5e26409a" data-id="ef6894fd53b54998a2bec85e5e26409a"><span><div id="ef6894fd53b54998a2bec85e5e26409a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#ef6894fd53b54998a2bec85e5e26409a" title="Flutter 如何动态切换颜色主题"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Flutter 如何动态切换颜色主题</span></span></h2><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-23912794a49b4a648aca45404649fb54" data-id="23912794a49b4a648aca45404649fb54"><span><div id="23912794a49b4a648aca45404649fb54" class="notion-header-anchor"></div><a class="notion-hash-link" href="#23912794a49b4a648aca45404649fb54" title="如何设置颜色主题"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">如何设置颜色主题</span></span></h3><div class="notion-text notion-block-27f205109dee4620b2a9437aa1e5cb8a">对于 Flutter App 主题的颜色的配置，有两种方式：</div><ol start="1" class="notion-list notion-list-numbered notion-block-fbbd44709fd645b6a77b9bd1629f1c4c"><li>使用 token 设置主题色</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-316a91bd76f847f5bf4594d41a7f424a"><li>使用自定义配色方案</li></ol><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-89cfd51f737a4029912b013fd147c137" data-id="89cfd51f737a4029912b013fd147c137"><span><div id="89cfd51f737a4029912b013fd147c137" class="notion-header-anchor"></div><a class="notion-hash-link" href="#89cfd51f737a4029912b013fd147c137" title="使用 Token 设置主题色"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">使用 Token 设置主题色</span></span></h4><div class="notion-text notion-block-de259976f1de4457bae31d418c7d9766">在 Flutter 的 Material Design 中，&quot;token&quot; 是一个跟设计系统相关的概念，特别是在 Google 的 &quot;Material You&quot; 系统中。在这个系统中，token 是用于定义应用外观和感觉的一组参数。这些参数可以包含颜色、字体、形状等各种元素，用于在应用中创建一致的视觉体验。</div><div class="notion-text notion-block-0298bc1cf4d04b398f1368a91dd6da46">Token 是一种抽象的概念，可以被视为一个变量或者一个标识符，其表示了一种特定的视觉样式。例如，一个颜色 token 可以表示主题的主色，而一个字体 token 可以表示应用程序中的标题字体。
这样可以保证 App 中的视觉样式与 Material Design 的要求保持一致, 也使得不同页面和组件的样式协调统一。</div><div class="notion-text notion-block-dd2ba837eefe42b2a0298d22760cf3e1">在 Flutter 中，你可以通过 <code class="notion-inline-code">ThemeData</code> 来设置这些 token。例如，你可以通过 <code class="notion-inline-code">ThemeData</code> 的 <code class="notion-inline-code">primaryColor</code> 和 <code class="notion-inline-code">accentColor</code> 属性来设置你应用的主色和强调色。类似地，你也可以通过 <code class="notion-inline-code">textTheme</code> 来设置应用中的文字样式。</div><div class="notion-text notion-block-a9766253e20d4368aa8c38d345cd08b5">对于 Material 3 来说，可以使用以下方法设置颜色的 Token，可以在整个 App 中使用相同的主题色与背景色，而不需要重复定义。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-55b66d6f36074fc29a620bf22aee3e12" data-id="55b66d6f36074fc29a620bf22aee3e12"><span><div id="55b66d6f36074fc29a620bf22aee3e12" class="notion-header-anchor"></div><a class="notion-hash-link" href="#55b66d6f36074fc29a620bf22aee3e12" title="使用自定义配色方案"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">使用自定义配色方案</span></span></h4><div class="notion-text notion-block-51566cfea2f648a184486b9bf02e6be0">在 Flutter 中, 可以通过以下步骤自定义 Material 风格的色彩方案:</div><div class="notion-text notion-block-b71e082daba642b6b82f325f1b4e67a9">1、创建一个 colors. dart 文件, 在里面定义颜色变量, 比如:</div><div class="notion-text notion-block-a5456480456840fa87dc7a3d72a49b40">2、在主题中引用这些自定义颜色:</div><div class="notion-text notion-block-c51af5b74f4f456db01535c2186c9511">3、将 <code class="notion-inline-code">colors.dart</code> 导入要应用主题的页面, 并通过 <code class="notion-inline-code">Theme.of(context)</code> 获取主题设置组件样式:</div><div class="notion-text notion-block-36950b18b45f421490ce470fe8182766">4、也可以创建多个主题, 在切换主题时传入不同的 ThemeData 对象:</div><div class="notion-text notion-block-14e1332a5a6c41c38a379e40a9ece9bf">5、定制主题中的其他样式, 如字体、形状、阴影等。</div><div class="notion-text notion-block-b046809a485d4e84b571dbf6bab0645e">通过这种方式, 我们可以自由组合颜色、视觉效果, 而不需深入 Material 源码, 实现 Brand 化的自定义主题。</div><div class="notion-callout notion-gray_background_co notion-block-d139bf2867694fa7884c6710b8ef5fda"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="💡">💡</span></div><div class="notion-callout-text">一个简单生成配色的方法是使用 <a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://m3.material.io/theme-builder#/custom">material Theme Builder</a>，可以根据选定的颜色 token，自定义生成一整套配色方案。
https://m3.material.io/theme-builder#/custom</div></div><div class="notion-blank notion-block-2e3f4dc9139d4582be66b42bfdbe23e5"> </div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-83ad1b6acfe044fb9424db75720bdb18" data-id="83ad1b6acfe044fb9424db75720bdb18"><span><div id="83ad1b6acfe044fb9424db75720bdb18" class="notion-header-anchor"></div><a class="notion-hash-link" href="#83ad1b6acfe044fb9424db75720bdb18" title="如何动态切换主题配色"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">如何动态切换主题配色</span></span></h3><div class="notion-text notion-block-e563e0b8c17742ad8103a192d529916b">
</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-9c715c27a6714a5ba06ec5a45fcda934"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:400px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fb99f81dc-b10f-4161-b1e6-1b562952b358%2Fa182954d-79ac-460b-81f3-f5c247123abb%2FUntitled.gif?table=block&amp;id=9c715c27-a671-4a5b-a06e-c5a45fcda934&amp;t=9c715c27-a671-4a5b-a06e-c5a45fcda934" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-d4aa1b59806143b0ac50776b67066a6d"> </div><div class="notion-text notion-block-d81cbce58a064026ae92a178fba04fc3">实现 App 动态切换主题颜色的方法有很多, 今天我主要介绍一种比较推荐的方式——使用 Provider。</div><div class="notion-text notion-block-6999a97c22f74c5f9b227c6c9232461a">Provider 可以实现主题状态的集中管理, 使主题可以动态修改。</div><ol start="1" class="notion-list notion-list-numbered notion-block-3927b9010049479eb0f29429c5a91300"><li>创建 ThemeProvider 类负责状态管理;</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-56ce186ad270481283367ecf9dc30d87"><li>root page 设置 ThemeProvider;</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-abea5bc0fe6a44ed8a5bcb4b407f9a87"><li>页面中通过 Consumer 获取实例;</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-df1feac000224ed28ff6353d84d41321"><li>调用设置方法修改主题配置;</li></ol><ol start="5" class="notion-list notion-list-numbered notion-block-bc3082c2a55e4760a55a5343f35bce90"><li>主题变化触发界面更新。</li></ol><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-b41658aab02a4f8aae17801e2c5bad66" data-id="b41658aab02a4f8aae17801e2c5bad66"><span><div id="b41658aab02a4f8aae17801e2c5bad66" class="notion-header-anchor"></div><a class="notion-hash-link" href="#b41658aab02a4f8aae17801e2c5bad66" title="1. 创建主题提供者"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1. 创建主题提供者</span></span></h4><div class="notion-text notion-block-07d45d5c5ea9492ba566fa6c7fab77d3">首先我们创建一个ThemeProvider类来保存主题状态:</div><div class="notion-text notion-block-2699c3ac39b14ebf86919d4cb9192785">这段代码实现了一个 <code class="notion-inline-code">ThemeProvider</code>, 它能够动态修改 App 的明暗两种主题。</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-9c59577a0cb240d1b2c650054894b54b" data-id="9c59577a0cb240d1b2c650054894b54b"><span><div id="9c59577a0cb240d1b2c650054894b54b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#9c59577a0cb240d1b2c650054894b54b" title="2. 提供ThemeProvider"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2. 提供ThemeProvider</span></span></h4><div class="notion-text notion-block-4811bd76912e4e73b66638f65abaae75">然后在 root page 提供这个 ThemeProvider:</div><div class="notion-text notion-block-d9a297641a10456e810830790ea2b78d">这样实现有以下的优点：</div><ol start="1" class="notion-list notion-list-numbered notion-block-cfcbc8d3dc5845869e9092379560e96d"><li>在 MaterialApp 中, 通过 Consumer 获取 ThemeProvider 的实例。</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-182cf22a4fde49e4a483ff6dfdda4533"><li>lightTheme和darkTheme中的色彩方案(colorScheme)直接引用了ThemeProvider中的lightScheme和darkScheme。</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-dd635c14cf1442eb827e4dd41e196dff"><li>主题模式(themeMode)也是直接引用ThemeProvider的themeMode状态。</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-1f2bf5bb7f494de9be8d1904837c5c90"><li>当ThemeProvider中的状态发生变化时,通过notifyListeners会触发Consumer的重新build,来动态切换主题。</li></ol><ol start="5" class="notion-list notion-list-numbered notion-block-b244d68e23854b81bacb9166ff1d775d"><li>在首页或其他页面,可以通过context获取ThemeProvider实例,调用其设置方法来更改主题模式和主题色彩。</li></ol><ol start="6" class="notion-list notion-list-numbered notion-block-cd30001412b34b25af1e85edc9e56f24"><li>这样通过provider把主题数据和状态抽取出来,在UI层简单重用,实现了低耦合的动态主题切换。</li></ol><ol start="7" class="notion-list notion-list-numbered notion-block-45a68464510249849476e498e6e07322"><li>ThemeProvider负责主题状态管理,UI层负责显示,二者职责分离,符合设计原则。</li></ol><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-e5e3ea219dd74d8884664eff7d33cb76" data-id="e5e3ea219dd74d8884664eff7d33cb76"><span><div id="e5e3ea219dd74d8884664eff7d33cb76" class="notion-header-anchor"></div><a class="notion-hash-link" href="#e5e3ea219dd74d8884664eff7d33cb76" title="3. 获取ThemeProvider"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">3. 获取ThemeProvider</span></span></h4><div class="notion-text notion-block-48988f626148497b93c811aebf8be146">在需要的页面获取provider实例:</div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-4bb18df049634653bf9e8bbe4fa999a9" data-id="4bb18df049634653bf9e8bbe4fa999a9"><span><div id="4bb18df049634653bf9e8bbe4fa999a9" class="notion-header-anchor"></div><a class="notion-hash-link" href="#4bb18df049634653bf9e8bbe4fa999a9" title="4. 更改主题"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">4. 更改主题</span></span></h4><div class="notion-text notion-block-1f5cc2d0e6db4134a16dab968e1b0613">调用 setLightScheme 和 setDarkScheme 更改主题色:</div><div class="notion-text notion-block-92d4a5158e3147a4b3592a3a61991cef">这样就可以通过provider在不同页面共享和修改主题配置了。利用Provider进行主题管理,可以避免重复代码,提供了响应式的主题配置。这是Flutter中实现动态主题的灵活简洁的方式。</div><div class="notion-callout notion-gray_background_co notion-block-2dd844a142144642b5436c6afb02d0fa"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="💡">💡</span></div><div class="notion-callout-text">想要使用 provider 需要先添加 provider 依赖，具体代码如下，先在 `pubspec.yaml` 文件 `dev_dependencies` 部分添加 `provider: ^6.0.5`：
</div></div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-7afbc6f0e8fc481a9fbbd6da0e420b38" data-id="7afbc6f0e8fc481a9fbbd6da0e420b38"><span><div id="7afbc6f0e8fc481a9fbbd6da0e420b38" class="notion-header-anchor"></div><a class="notion-hash-link" href="#7afbc6f0e8fc481a9fbbd6da0e420b38" title="总结"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">总结</span></span></h2><div class="notion-text notion-block-0045f5d6f02c435f9e3f70d497dc967e">Flutter 通过主题系统提供了强大的主题定制功能。我们可以通过多种方式自由切换主题, 以丰富应用体验和可访问性。掌握 Flutter 的主题机制是开发高质量 App 的重要一环。</div><div class="notion-text notion-block-0920af89b74b481a8d6e1db93a092893">以上对 Flutter 主题切换的实现做了全面介绍。如还有疑问,欢迎留言讨论。</div><div class="notion-text notion-block-28f48b80d54d48899cffc3ef3427cbdc">比如主题按钮可以调用themeProvider的setter来切换主题模式,其他组件可以通过Provider获取themeProvider实例来修改样式。</div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-4a510f1a4c4744eab22b24d3f99613a4" data-id="4a510f1a4c4744eab22b24d3f99613a4"><span><div id="4a510f1a4c4744eab22b24d3f99613a4" class="notion-header-anchor"></div><a class="notion-hash-link" href="#4a510f1a4c4744eab22b24d3f99613a4" title="参考链接"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">参考链接</span></span></h2><ol start="1" class="notion-list notion-list-numbered notion-block-116422a7359c4c06b316f9e89605345b"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://m3.material.io/theme-builder#/custom">https://m3.material.io/theme-builder#/custom</a></li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-bc73be22295c46e4b42c01684b692626"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://juejin.cn/post/7078583859536723975">https://juejin.cn/post/7078583859536723975</a></li></ol></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[用 iPhone 备忘录 3 分钟创建个人网站]]></title>
            <link>https://blog.gusibi.mobi/article/d551b6f0-47d1-4a7b-96ea-662d6c3a30a2</link>
            <guid>https://blog.gusibi.mobi/article/d551b6f0-47d1-4a7b-96ea-662d6c3a30a2</guid>
            <pubDate>Sun, 27 Aug 2023 00:00:00 GMT</pubDate>
            <description><![CDATA[• 用 iPhone 备忘录轻松创建个人网站，零基础也能搞定。只需几分钟，即可拥有属于自己的个人网站。
• iPhone 备忘录变身网站，让你轻松拥有个人网站。只需简单操作，即可发布博客文章、建立个人品牌、分享想法、认识新朋友。
• iPhone 备忘录教你轻松建站。只需一个备忘录，即可创建个人网站。功能丰富，自定义性强，零基础也能搞定]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-d551b6f047d14a7b96ea662d6c3a30a2"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-callout notion-gray_background_co notion-block-6d05da6378fc495ba3ceba882d8b8d08"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="😀">😀</span></div><div class="notion-callout-text"> <b>用 iPhone 备忘录和 </b>Montaigne <b>轻松创建个人网站，零基础也能搞定。只需几分钟，即可拥有属于自己的个人网站。</b></div></div><div class="notion-blank notion-block-6b6d8ee5b63a4f969d2e8012e3709692"> </div><div class="notion-blank notion-block-0d8371674bd64fe59d686ae6ca8c6c1f"> </div><div class="notion-text notion-block-47762920d5bc400f90afbbb128f900a5">在这个数字化的时代,拥有自己的个人网站已经变得极为重要。它可以成为展示自我、分享见解、结交朋友的窗口。但是,建立一个个人网站通常需要专业的编程技能,这让许多对技术一窍不通的人望而却步。</div><div class="notion-text notion-block-8ad2720d598d4f3dbbf800270d734174">现在,我要向你分享一个世上最简单的建站法——仅需 iPhone 备忘录。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-8b964d093e914d2fa7a3be986f02a57c" data-id="8b964d093e914d2fa7a3be986f02a57c"><span><div id="8b964d093e914d2fa7a3be986f02a57c" class="notion-header-anchor"></div><a class="notion-hash-link" href="#8b964d093e914d2fa7a3be986f02a57c" title="操作步骤"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>操作步骤</b></span></span></h3><ol start="1" class="notion-list notion-list-numbered notion-block-1a05f6ec866440a7acbfec6904486e82"><li>在备忘录中新建一个文件夹,命名为你的心仪子域名,例如“xiaoming.montaigne.io”。</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-0f329587018441b1ad7a409b32aac205"><li>在这个文件夹里随意添加点内容。</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-44b49181f1a645728dd71b6805a60b89"><li>前往 Montaigne 官网注册账号。</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-4f461fa3149d413c903cb2d55c636150"><li>登录后点击“连接备忘录”。</li></ol><ol start="5" class="notion-list notion-list-numbered notion-block-f91cbf9401db47029eda54d0277db2f7"><li>根据提示设置子域名,选择分享的笔记本,输入分享链接。</li></ol><ol start="6" class="notion-list notion-list-numbered notion-block-ba45e35219d243b180742b53f529dc9b"><li>完成以上步骤,你的个人网站“xiaoming.montaigne.io”就建成了!</li></ol><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-6399c6643e4446ad9504bab047cdd145" data-id="6399c6643e4446ad9504bab047cdd145"><span><div id="6399c6643e4446ad9504bab047cdd145" class="notion-header-anchor"></div><a class="notion-hash-link" href="#6399c6643e4446ad9504bab047cdd145" title="功能一览"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>功能一览</b></span></span></h3><div class="notion-text notion-block-5904a6c70a3b4cec8b3aad3f360d5316">Montaigne 是一个完全免费的个人网站托管平台。它为用户提供了以下妙用:</div><ul class="notion-list notion-list-disc notion-block-a6e5203b27b0406a9d71bc2216404b23"><li>发布新页面 - 只需添加新笔记,即可创建崭新页面。</li></ul><ul class="notion-list notion-list-disc notion-block-c3808955480d4772a7307e4e8bd00498"><li>更新页面 - 编辑备忘录内的笔记,对应页面内容会实时更新。</li></ul><ul class="notion-list notion-list-disc notion-block-2be50b5faab24e3f9866b40ae6ba12e5"><li>自定义页面 - 可调整页面模板、主题、字体等参数。</li></ul><ul class="notion-list notion-list-disc notion-block-a85da898a81540fe9d89a73a3d345217"><li>输出 RSS - 立即拥有属于自己的 RSS 订阅源。</li></ul><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-28d879b0284b42faa80820f3a42eee69" data-id="28d879b0284b42faa80820f3a42eee69"><span><div id="28d879b0284b42faa80820f3a42eee69" class="notion-header-anchor"></div><a class="notion-hash-link" href="#28d879b0284b42faa80820f3a42eee69" title="终言"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>终言</b></span></span></h3><div class="notion-text notion-block-7517f6e242434beebb9afde80ebfb361">有了 Montaigne,建站门槛清零。只要你有 iPhone 和备忘录,便可轻松打造个人网站。</div><div class="notion-text notion-block-74a08c7afbe242a883e7f99e1cdea59c">希望这篇攻略对你有帮助。Go,开启你的个人品牌之旅吧!</div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-0c37fe95e1f24712bc7c879ec31cdef4" data-id="0c37fe95e1f24712bc7c879ec31cdef4"><span><div id="0c37fe95e1f24712bc7c879ec31cdef4" class="notion-header-anchor"></div><a class="notion-hash-link" href="#0c37fe95e1f24712bc7c879ec31cdef4" title="📎 参考文章"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">📎 参考文章</span></span></h2><ul class="notion-list notion-list-disc notion-block-256ef407183645a9b879691ca572875d"><li><code class="notion-inline-code">montaigne.io</code></li></ul><ul class="notion-list notion-list-disc notion-block-7a3a333baaf548728e59b84147caa741"><li>引用文章:<a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://twitter.com/nishuang/status/1695437840425914400">https://twitter.com/nishuang/status/1695437840425914400</a></li></ul><div class="notion-blank notion-block-b22bc4f55d204890a871a5a656fa79df"> </div><div class="notion-callout notion-gray_background_co notion-block-6ab9bc250a8f4c72a0e45b3d3411e896"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="💡">💡</span></div><div class="notion-callout-text">有关Notion安装或者使用上的问题，欢迎您在底部评论区留言，一起交流~</div></div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[chassis.Run 运行了什么？]]></title>
            <link>https://blog.gusibi.mobi/article/chassis.run</link>
            <guid>https://blog.gusibi.mobi/article/chassis.run</guid>
            <pubDate>Fri, 02 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[chassis.Run 运行了什么？]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-084baa7e9ef24a679957ce14d13be059"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-blank notion-block-08b87e8543a94387a98487397d370af4"> </div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-c43d9bf9d0f34feb9b8ebf70e7b79053" data-id="c43d9bf9d0f34feb9b8ebf70e7b79053"><span><div id="c43d9bf9d0f34feb9b8ebf70e7b79053" class="notion-header-anchor"></div><a class="notion-hash-link" href="#c43d9bf9d0f34feb9b8ebf70e7b79053" title="什么是 chassis?"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">什么是 chassis?</span></span></h3><div class="notion-text notion-block-bff51a7f399343159de35d470696c82f">Chassis，是一种微服务模式。在这种模式中，用户并不需要自己去处理构建微服务过程中外部配置、日志、健康检查、分布式追踪等，而是将他们交给专门的框架来处理。用户可以更聚焦业务逻辑本身，简单、快速的开发微服务。</div><div class="notion-text notion-block-159ed9f2346d4bbf86efa2acd54fd495"><b>阅读此文，你可以得到什么？</b></div><blockquote class="notion-quote notion-block-37c4355c2fe248788fc982850e3f652b"><div>chassis 运行时做了什么chassis 运行时的隐藏操作。chassis 设计思路的一些理解</div></blockquote><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-d97088d70ca3472aa4bb724c8a4c5773" data-id="d97088d70ca3472aa4bb724c8a4c5773"><span><div id="d97088d70ca3472aa4bb724c8a4c5773" class="notion-header-anchor"></div><a class="notion-hash-link" href="#d97088d70ca3472aa4bb724c8a4c5773" title="Go-Chassis 是什么？"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Go-Chassis 是什么？</span></span></h4><div class="notion-text notion-block-bc0f74259f0d4114a82c68c4759a3d51">Go-Chassis 是一个go语言的微服务开发框架，采用插件化设计，原生提供了可插拔的注册发现，加密解密，调用链追踪等组件。协议也是插件化的，支持http和grpc，也支持开发者定制私有协议， 开发者只需要专注于实现云原生应用即可。</div><blockquote class="notion-quote notion-block-d641dc41c4544c00b4dbddd742a5e42f"><div>云原生应用，基于云服务开发或者针对云服务开发部署的应用。</div></blockquote><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-dac070eca64b4eb2a3101738b8c8f438"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img src="http://media.gusibi.mobi/nOId8YPFqTTV2Ha8kEB9gVaSG9zAEIBgJe7rp2GK7ZsgyHd4vsX8OMrewCuUb3hs?t=dac070ec-a64b-4eb2-a310-1738b8c8f438" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-c69fccf93bf14955ab265de95376fce6">上图是go-chassis 的架构图，可以看出配置管理（Archaius）、服务注册（Registry）、Metrics、日志（Logger）都是独立的组件，分布式追踪、负载均衡、限流等都是以中间件（Handler Chain）的方式实现的。一个请求进来后会先通过server 转换成chassis invoker，然后经过Handler Chain，最后由Transport 转换成对应协议的response返回。</div><div class="notion-text notion-block-1cd6f8091e6244b7a43d22993c54cd07">此篇文章主要关注go-chassis 启动过程时做了什么，以及做这些事情的用途。</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-66bf965773b24170b604db0b8f4dda72" data-id="66bf965773b24170b604db0b8f4dda72"><span><div id="66bf965773b24170b604db0b8f4dda72" class="notion-header-anchor"></div><a class="notion-hash-link" href="#66bf965773b24170b604db0b8f4dda72" title="一个例子"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">一个例子</span></span></h4><div class="notion-text notion-block-1fd899c443a14637b3095781ff09b00b">首先从 hello world 开始， 目录结构如下：</div><div class="notion-text notion-block-033e76edc22e47a08c817abf4911e0a2">chassis.yaml 内容为：</div><div class="notion-text notion-block-3bdf5253f9df4ea08c588fa1f6158704">microservice.yaml 内容为：</div><div class="notion-text notion-block-efbf89953742465c928304daa68e1e20">main.go</div><div class="notion-text notion-block-58023e0c3fdf41f499790af52bc2d072">先来看一下这段代码具体做了什么。</div><ul class="notion-list notion-list-disc notion-block-f9df32c83f824f868be4935d5e893f1e"><li>11~27 声明了 一个 RestFulHello struct，这个struct 有两个方法 Sayhi 和 URLPatterns，其中URLPatterns 返回一个 Route 列表。 这段代码声明了一个http handler 和 对应的路由，那具体为什么这么写等下再做说明。</li></ul><ul class="notion-list notion-list-disc notion-block-80d1588ea06f4a7d9e7b5b8b9b167e54"><li>30行 <code class="notion-inline-code">chassis.RegisterSchema(&quot;rest&quot;, &amp;RestFulHello{})</code> 将前面声明的 RestFulHello 注册到 &quot;rest&quot; 服务。</li><ul class="notion-list notion-list-disc notion-block-80d1588ea06f4a7d9e7b5b8b9b167e54"><div class="notion-text notion-block-6bfd9e2f47964ef5bcc02c9b9414c3c6">这里内部只是简单的使用传入的参数创建一个 <code class="notion-inline-code">chassis.Schema</code> 然后append到 <code class="notion-inline-code">chassis.schemas</code> 中。</div></ul></ul><ul class="notion-list notion-list-disc notion-block-78596073173342f4a74caecc283ce91c"><li>31行 chassis运行前的初始化工作。</li></ul><ul class="notion-list notion-list-disc notion-block-49f89be5b4ad4c0ca2e833f382575a01"><li>35行 运行chassis 服务。</li></ul><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-534f80397e1b4900a5f9d6ffb6216b1b"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img src="http://media.gusibi.mobi/ti_WF2mI4lC_8F_aeZF7-FxgsBcSkcRMZBrjrKv_vAZ87MV0q3P0Uo7Ukk4d9PW_?t=534f8039-7e1b-4900-a5f9-d6ffb6216b1b" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-6890cfe7538f492caca8816fd974142b">执行 <code class="notion-inline-code">go run rest/main.go</code> 运行代码，会发现启动失败，日志输出内容为：</div><div class="notion-text notion-block-e80e327a48b044818b824976111fdd0d">通过日志可以看到两个问题：</div><ol start="1" class="notion-list notion-list-numbered notion-block-4b4241f8159d456684e62a95dea74861"><li>为什么添加了配置还会提示配置找不到？</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-9b68c2d2d0264e66abd44c0988101722"><li>为什么配置没有加载成功插件却可以安装成功？</li></ol><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-6c45102ba0dd40799cde53ca1a05f650" data-id="6c45102ba0dd40799cde53ca1a05f650"><span><div id="6c45102ba0dd40799cde53ca1a05f650" class="notion-header-anchor"></div><a class="notion-hash-link" href="#6c45102ba0dd40799cde53ca1a05f650" title="chassis init"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">chassis init</span></span></h3><div class="notion-text notion-block-0f638a397c9042bc8fd51d290d35d5aa">下图是chassis init 的执行流程：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-b8c1fc5dc5b447bdb0a82d3a44f1d8a2"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img src="http://media.gusibi.mobi/RWJvZfc7AZGccP6ML_wP80QLr1_OQVUCccAoGHpdY3RcD2xqeFTmso34HzIL1_iP?t=b8c1fc5d-c5b4-47bd-b0a8-2d3a44f1d8a2" alt="notion image" loading="lazy" decoding="async"/></div></figure><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-2aa5656121974e74b2b3ea6dbf0c8ccf" data-id="2aa5656121974e74b2b3ea6dbf0c8ccf"><span><div id="2aa5656121974e74b2b3ea6dbf0c8ccf" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2aa5656121974e74b2b3ea6dbf0c8ccf" title="配置初始化"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">配置初始化</span></span></h4><div class="notion-text notion-block-51a4918a72a24f64897fe69c89bb112b">首先看一下chassis 初始化的过程中配置是如何加载的。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-a766b27419f64aa4bbd5db42c78e9ba8"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img src="http://media.gusibi.mobi/BruF3mWEA0c2KEh5wqP92EU_c9d44RVFHfYEIkzb5f0IwJ05xYpM_dd6PKb7y-TG?t=a766b274-19f6-4aa4-bbd5-db42c78e9ba8" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-bc0b511bddc64f3bb0e7e8127747cffa">查看 config.Init() 代码可以看到 配置目录是通过 <code class="notion-inline-code">fileutil.RouterConfigPath()</code> 来获取的，目录初始化方法为：</div><blockquote class="notion-quote notion-block-709dc44ca24e4b1fbad469f48a30c29e"><div>如果使用  ChassisHome  环境变量指定应用目录，chassis 运行时，会从该目录下的 ChassisHome/conf/  目录中读取配置</div><div class="notion-text notion-block-8ebd9d48868b47dcb454613b2d682b8f">也可以使用 <code class="notion-inline-code">ChassisConfDir</code> 直接指定配置目录，ChassisConfDir 优先级高于 <code class="notion-inline-code">ChassisHome/conf</code></div></blockquote><div class="notion-text notion-block-486a214a7cd3469a94d953a608df60de">chassis 使用 archaius 来管理配置，<em>archaius</em> 初始化时，会从文件、环境变量、命令行、内存中初始化配置。</div><div class="notion-text notion-block-4c61fee8de2740dbbad2964400651da3">从代码可以看出，global config 和 microservice config 是必须要有的，</div><blockquote class="notion-quote notion-block-774af0b223a044a284e1796ea4a0072e"><div>global config 对应  conf_path/chassis.yaml</div><div class="notion-text notion-block-1e75da1ff71b4a919e2a771f88821689">microservice config 对应 conf_path/microservice.yaml</div></blockquote><div class="notion-text notion-block-420fdbbae4b340db90537cb744408a8d">接下来读出配置后，给初始化runtime 的值：</div><blockquote class="notion-quote notion-block-98d86a29ba7c44f2b1b5ff4008736698"><div>runtime 中的数据可以认为是运行时的全局变量</div></blockquote><div class="notion-text notion-block-7e7af0dc5eb34bf28e411041e91f04a5">archaius 也支持从配置中心读取配置，通过这种方式，chassis 也提供了运行时配置热加载的功能。</div><div class="notion-text notion-block-ae3cfa1d7af1499e88e38822e6a3b081"><b>对于第二个问题，为什么插件会先于配置安装？</b></div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-e3a8fb364c1e49d9bea9d9770d47abdb" data-id="e3a8fb364c1e49d9bea9d9770d47abdb"><span><div id="e3a8fb364c1e49d9bea9d9770d47abdb" class="notion-header-anchor"></div><a class="notion-hash-link" href="#e3a8fb364c1e49d9bea9d9770d47abdb" title="插件初始化"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">插件初始化</span></span></h4><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-517a39d55f1e43cca132e2cbaa229083"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img src="http://media.gusibi.mobi/Tx6hEjesBGf6eV5S9Yb-T5RCCqkTqNEllvVIUdOeVG73j6FLz_OFXCsFWHWpYGYA?t=517a39d5-5f1e-43cc-a132-e2cbaa229083" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-9b40620c4bf849119bdc233fd229e127">从图中可以看出init 做了预先初始化了很多的插件，比如 client、provider、server、log、router rule、register、load balance、service discover、treporter等，并且chassis init 方法中并没有做显式的初始化调用。通过查看代码会发现，这个步骤是使用各自的init 方法自动执行的，类似这样：</div><div class="notion-text notion-block-986b85ac3ca042c0a1da9c10b3108d4e">之所以隐式加载是因为 chassis 是插件式设计，使用 init 方式加载插件，可以做到对插件的即插即用，需要使用的插件只需要在代码中添加包的import 即可，比如加载grpc 插件，只需要在main.go 中添加</div><blockquote class="notion-quote notion-block-ba630c8d6227444c86322f4f93b6f4e7"><div>从这一系列插件安装方式也能看出，对于chassis 来说，注册中心，协议，负载均衡等都是插件，这也就意味着这些插件都是可替换的，方便二次开发。</div></blockquote><div class="notion-text notion-block-6aac5fb9539541b49669346d0dfee809">以上两个问题现在都解决了，现在执行以下命令运行服务：</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-032b983dcaf84e449394f655c208ddc7" data-id="032b983dcaf84e449394f655c208ddc7"><span><div id="032b983dcaf84e449394f655c208ddc7" class="notion-header-anchor"></div><a class="notion-hash-link" href="#032b983dcaf84e449394f655c208ddc7" title="初始化handler chain"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">初始化handler chain</span></span></h4><div class="notion-text notion-block-a4b4100b8cbf4932bc2ec4f4a47cc3f8">Handler是微服务在运行过程中在框架层面里的一个最小处理单元。go chassis通过handler和handler的组装实现组件化的运行模型架构。其基本的使用方式就是实现接口、注册逻辑：</div><div class="notion-text notion-block-0f4c9e297fe14f0d9413243b74552a9b">Handler 定义非常简单，实现了Handler 接口就可以认为创建了一个Handler。</div><div class="notion-text notion-block-8a7bfea5af51485f8172e3b41dfca218">使用RegisterHandler 函数将添加到HandlerFuncMap 中即可在CreateHandler 调用时使用。</div><div class="notion-text notion-block-00df8e4818fc4e8faa43d00f869b5ab2">对于chassis 来说，协议转换，权限验证，全链路追踪等都可以认为是一个handler（中间件），这里会从配置中读取声明的handler，并且初始化。请求调用时，会按照配置文件中的定义的顺序进入handler进行处理。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-c9a161f3eafd4fe0bf360568f58b4b25"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img src="http://media.gusibi.mobi/wxzssdKUklFg3Z1mY7QH_9cfBPIfBT3JwGb99ZwfBYcMQ_Rw_TILJWCD0rUPDh99?t=c9a161f3-eafd-4fe0-bf36-0568f58b4b25" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-e00ceed9ce334a8b816c794b83238fd9">在服务初始化的过程中，go-chassis 会根据配置文件中的定义加载需要的handler，handler 分为provider、consumer和 default 三种，配置内容示例如下：</div><blockquote class="notion-quote notion-block-6bfac2fdefd14803bfe297274e54e489"><div>如果配置了非default 的type，服务启动的时候只会执行此特定的handler，比如上述配置，handler 只会执行 jwt，而忽略tracing-provider</div></blockquote><div class="notion-text notion-block-f9e05a56b2c742698a2f03402feafc8d">这是因为chassis 使用map存储 handler chain，map 的key 为 chainType+chainName， <code class="notion-inline-code">default</code> 也是一种chainType，如果name(即chain type)有值则使用对应的 chain，否则使用default。</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-5d078e2ddf2f4af2bcb70f4f96ab264b" data-id="5d078e2ddf2f4af2bcb70f4f96ab264b"><span><div id="5d078e2ddf2f4af2bcb70f4f96ab264b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#5d078e2ddf2f4af2bcb70f4f96ab264b" title="初始化 server"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">初始化 server</span></span></h4><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-cd8553d288a34440af318dfaff66bcae"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img src="http://media.gusibi.mobi/ilHWFRDKFGZBxP7BCpvqHoDGaiYco4M6Rbzi5kDvyNQBtx5X7nRK1Hz9rv9fMulU?t=cd8553d2-88a3-4440-af31-8dfaff66bcae" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-1a7ad8c2bbc740b8acbbb169931396ef">初始化的前提是服务已经加载，加载的步骤在init 之前就已经通过 init 方法载入了。</div><div class="notion-text notion-block-e798049e990b40c79dba5bac15e57a32">这里初始化的是配置文件中 <code class="notion-inline-code">protocols</code> 指定的服务。</div><blockquote class="notion-quote notion-block-77b988fcd61949c8b3f4c23e6515660a"><div>这里会从 *var* serverPlugins = make(*map*[string]NewFunc)  读取server，所以在初始化时需要先安装server 对应的插件</div><div class="notion-text notion-block-69f7c739dced49e2a28c5dc64d30ba85">chassis 会 默认安装rest 插件，对于grpc 需要首先指定</div></blockquote><blockquote class="notion-quote notion-block-75a45431877f42bfa58696544bcef0ee"><div>服务的Listen Advertise 优先级最高，如果 Advertise 和 Listen 都没有配置，使用默认配置。</div></blockquote><div class="notion-text notion-block-45da596619ba4b2cad7507ee5e775a26">初始化 server options，其中chainName 如果Provider 配置了对应 protocol  name 的值，则使用protocol name。</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-0920ae40d3d64988834abb5ae3d3a377" data-id="0920ae40d3d64988834abb5ae3d3a377"><span><div id="0920ae40d3d64988834abb5ae3d3a377" class="notion-header-anchor"></div><a class="notion-hash-link" href="#0920ae40d3d64988834abb5ae3d3a377" title="其它"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">其它</span></span></h4><div class="notion-text notion-block-67f8c3a1d8c441189f19e9e1e5553052">几个初始化外，init 还包括 register、configcenter、router、contorl、tracing、metric、reporter、熔断器、事件监听等就不再细说了。</div><div class="notion-text notion-block-4d11f9c6d1144f04a6a59f19b21d6291">为止，chassis 所需要的初始化步骤已经结束，接下来就是 服务运行的步骤。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-c9acb83cccaf4e26876daf63eaa05b75" data-id="c9acb83cccaf4e26876daf63eaa05b75"><span><div id="c9acb83cccaf4e26876daf63eaa05b75" class="notion-header-anchor"></div><a class="notion-hash-link" href="#c9acb83cccaf4e26876daf63eaa05b75" title="chassis run"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">chassis run</span></span></h3><div class="notion-text notion-block-f147321f12b84e499edb780b57288963">首先看一下 chassis.Run() 启动的整体流程</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-ffb94ae8d4af4131b171a257902347a8"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img src="http://media.gusibi.mobi/DSd1K4nvCFlb-5U-hTfqby7OxsN_wf7uhOP6Xm1qb3zNAYa_Owp1C7YTotwlDW4q?t=ffb94ae8-d4af-4131-b171-a257902347a8" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-c46b1cbc0b474085b083adde2e3424a5"><b>chassis 运行</b>主要分为三个动作：</div><ol start="1" class="notion-list notion-list-numbered notion-block-e6e3b767196449438d7ef3ec13416c7d"><li>根据schema 找到服务，将对应的handle func 使用 handler chain 封装</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-609eeab8df07479e8be6bb3918256fdb"><li>启动服务，将服务注册到服务中心</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-31c771b47a594aa096205d1b0d79ec4d"><li>监听退出信号</li></ol><div class="notion-text notion-block-d2fc5591b4c84a00b9bc95a9e10af1e6"><b>这里使用rest 服务作为例子看一下 chassis 启动服务的时候做了哪些操作。</b></div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-43beaf991d4e42c1984c4c46465b5619" data-id="43beaf991d4e42c1984c4c46465b5619"><span><div id="43beaf991d4e42c1984c4c46465b5619" class="notion-header-anchor"></div><a class="notion-hash-link" href="#43beaf991d4e42c1984c4c46465b5619" title="服务注册"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">服务注册</span></span></h4><div class="notion-text notion-block-b5789fa3bb684668ba1cee4e38d580f0">首先回顾一下hello world 代码：</div><div class="notion-text notion-block-3567018b35654ba79ab187f0ff8504a6"><code class="notion-inline-code">RestFulHello</code> ，其中有一个 <code class="notion-inline-code">URLPatterns() []Route</code> 方法，实现了 <code class="notion-inline-code">Router </code> 接口。</div><div class="notion-text notion-block-7382fd9b99294602a877dba46e5e85b2"><b>Router 定义</b></div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-90b0a708d884486ab2b0e6db3411d6dd"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img src="http://media.gusibi.mobi/diDeLEpGlaS-hEyv60YQc2s6jb5AmxfMBLIqiAsAU7W72KQ94umSLJpr7U_sMH1n?t=90b0a708-d884-486a-b2b0-e6db3411d6dd" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-2a02a98e3dc54389b2f81859fe625c4f">启动的服务注册流程中包含了将schemas 中所有Router 取出遍历，调用 <code class="notion-inline-code">WrapHandlerChain()</code> 函数，这个函数主要做了以下工作：</div><ol start="1" class="notion-list notion-list-numbered notion-block-df5dec5b622f4ef697e50197e1564283"><li>取出 Route 中 ResourceFunc （即real handler func）</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-d15edb3517ad4ce087773b4a12e3e6bf"><li>将 HttpRequest 转换成 chassis Invocation，</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-836b65c72eb9429e85c519ebfebc496b"><li>将Invocation 再添加回 request 中添加到 handler chain 中</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-94fbbb75be8a49dc84392c9b5421dd10"><li>返回一个闭包函数。</li></ol><div class="notion-text notion-block-4f684756c17c4afbb5c115b23df11c5f">最后会把使用 <code class="notion-inline-code">WrapHandlerChain</code> 封装后的handler 注册到go-restful 框架中。</div><div class="notion-text notion-block-982ed56ee1b14c3e8689654c94efd7ba">响应请求时，调用关系类似以下操作:</div><div class="notion-text notion-block-4438d87bda6541e0b38ef3877c754eb6"><b>为什么需要转换成统一的invocation？</b></div><div class="notion-text notion-block-aad63d79a41740e2b7409b622a958872">不同协议请求进入到对应的Server，Server将具体的协议请求转换为Invocation统一抽象模型，并传入Handler chain，由于handler根据统一模型Invocation进行处理，不必每个协议开发出来都自己开发一套治理。处理链可通过配置更新，再进入Transport handler，使用目标微服务的协议客户端传输到目标。</div><div class="notion-text notion-block-d5a3929e23f642ccafec1985b73656d9">这种方式实际上真正提供业务处理的还是各个server 插件，chassis 只是中间商，可以对request 和 response 做它想要的处理，比如限流，熔断，路由更新等。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-885ee70fc9a94dc4a9cdef7ebb7cc50f"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img src="http://media.gusibi.mobi/5RO9xrwmzFuRH1wVtncbC4R3Z9FNr283opNevd5yCeAar0tFDIw_fsTeFUkud1xV?t=885ee70f-c9a9-4dc4-a9cd-ef7ebb7cc50f" alt="notion image" loading="lazy" decoding="async"/></div></figure><ol start="1" class="notion-list notion-list-numbered notion-block-d4c911829ac3469782c0b6abac604e98"><li>接收到协议请求后，由各协议Server转为统一的Invocation模型</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-3a059735b4a2480a8b6e02eb19f987a7"><li>Invocation进入处理链处理</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-56d631d6cdf047468a480c25e4f83d98"><li>处理结束后，进入具体的业务处理逻辑</li></ol><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-3a808fe4f55043e394db2905bc600a59" data-id="3a808fe4f55043e394db2905bc600a59"><span><div id="3a808fe4f55043e394db2905bc600a59" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3a808fe4f55043e394db2905bc600a59" title="信号监听"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">信号监听</span></span></h4><div class="notion-text notion-block-b4cdffcf076746f6906c376a14cf42b8">当服务需要关闭或重启时，应当处理完当前的请求或者设置为超时，而不是粗暴的断开链接，chassis 这里使用了信号监听的方式来处理关闭信号。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-0347d799943f4e8ea0d1b9ce41b3cc56"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column"><img src="http://media.gusibi.mobi/qipE63KL-Tjhy6DubK_iyF7W_Rjqae2HrsB3bUFy-FlNVnaAme5qjgyIBEZK1BlB?t=0347d799-943f-4e8e-a0d1-b9ce41b3cc56" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-231f28b82ae343958932f3163cbb2e66">这里使用go信号通知机制通过往一个channel中发送<code class="notion-inline-code">os.Signal</code>实现的。创建一个os.Signal channel，然后使用<code class="notion-inline-code">signal.Notify</code>注册要接收的信号，chassis 关注以下信号：</div><table class="notion-simple-table notion-block-65bf01dbc0ce4f31a23703e702dbc1df"><tbody><tr class="notion-simple-table-row notion-block-b3a1c0e3d1734641aaf512e18520d7a3"><td class="" style="width:120px"><div class="notion-simple-table-cell">信号</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">值</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">动作</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">说明</div></td></tr><tr class="notion-simple-table-row notion-block-0023bcd7c9a746deb40e791f40144a4d"><td class="" style="width:120px"><div class="notion-simple-table-cell">SIGHUP</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">1</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Term</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">终端控制进程结束(终端连接断开)</div></td></tr><tr class="notion-simple-table-row notion-block-064bd2fb923244c9a4b7cb084ac3c311"><td class="" style="width:120px"><div class="notion-simple-table-cell">SIGINT</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">2</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Term</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">用户发送INTR字符(Ctrl+C)触发</div></td></tr><tr class="notion-simple-table-row notion-block-c87472b7b9544d19befea41d27d05873"><td class="" style="width:120px"><div class="notion-simple-table-cell">SIGQUIT</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">3</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Core</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">用户发送QUIT字符(Ctrl+/)触发</div></td></tr><tr class="notion-simple-table-row notion-block-ac0f8d4aba9e4acab099b63b2b16610d"><td class="" style="width:120px"><div class="notion-simple-table-cell">SIGILL</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">4</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Core</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">非法指令(程序错误、试图执行数据段、栈溢出等)</div></td></tr><tr class="notion-simple-table-row notion-block-48196c89ec1f4fbd816a422f5b8c74fb"><td class="" style="width:120px"><div class="notion-simple-table-cell">SIGTRAP</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">5</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Core</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Trap指令触发(如断点，在调试器中使用)</div></td></tr><tr class="notion-simple-table-row notion-block-4171131ba7314584b250e4ba8d06e74c"><td class="" style="width:120px"><div class="notion-simple-table-cell">SIGABRT</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">6</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Core</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">调用abort函数触发</div></td></tr><tr class="notion-simple-table-row notion-block-0ecfd7f1f13f43bfa39f52ba7a5945f9"><td class="" style="width:120px"><div class="notion-simple-table-cell">SIGTERM</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">15</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Term</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">结束程序(可以被捕获、阻塞或忽略)</div></td></tr></tbody></table><div class="notion-text notion-block-3f38e42b119a4dedb425bd039d09db41">接收到信号后，首先判断是否注册到服务中心，如果注册，停掉心跳发送，退出注册，然后调用 server.Shutdown() 来优雅退出。</div><blockquote class="notion-quote notion-block-7c6e1efd8a5d476da41740a8a9122a38"><div>go http Server 从1.8 之后支持优雅退出。</div></blockquote><div class="notion-text notion-block-e22692ea1355471da239045981665d02">具体实现可以参考此文章：<a target="_blank" rel="noopener noreferrer" class="notion-link" href="http://xiaorui.cc/archives/5803">http://xiaorui.cc/archives/5803</a></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-59f785734b8f4242bd3b99b85cf6b6d0" data-id="59f785734b8f4242bd3b99b85cf6b6d0"><span><div id="59f785734b8f4242bd3b99b85cf6b6d0" class="notion-header-anchor"></div><a class="notion-hash-link" href="#59f785734b8f4242bd3b99b85cf6b6d0" title="总结"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">总结</span></span></h3><div class="notion-text notion-block-e3e485def0d94c609604e1377cfe75a5">这篇文章介绍了 chassis 服务启动的过程，主要介绍了init 中 配置 、插件、handler chain 、server 的初始化流程，然后分析了服务启动时做了哪些操作以及对服务退出的处理。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-fd01c4fd5ef8461dbb5fa3bec6f86b22" data-id="fd01c4fd5ef8461dbb5fa3bec6f86b22"><span><div id="fd01c4fd5ef8461dbb5fa3bec6f86b22" class="notion-header-anchor"></div><a class="notion-hash-link" href="#fd01c4fd5ef8461dbb5fa3bec6f86b22" title="参考链接"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">参考链接</span></span></h3><ol start="1" class="notion-list notion-list-numbered notion-block-74bef77f9e0e48c9b4dd063168163f0d"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://www.infoq.cn/article/ServiceComb-Go-chassis-micro-service">使用ServiceComb Go-chassis构建微服务</a></li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-ba088f30a7b8405b9683e576dfc07de2"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="http://microservices.io/patterns/microservice-chassis.html">Pattern: Microservice chassis</a></li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-6e854a7b12f24b8faa71cf36ffa29040"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://colobu.com/2015/10/09/Linux-Signals/">Linux Signal及Golang中的信号处理</a></li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-47331a1e9ab1426c9a02ec904baf417d"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="http://xiaorui.cc/archives/5803">源码分析golang http shutdown优雅退出的原理</a></li></ol><ol start="5" class="notion-list notion-list-numbered notion-block-49a9510947b345acb0102d40d67747fd"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://juejin.im/post/6844903682362834952">Go语言微服务开发框架实践-go chassis</a></li></ol></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[七十二堂写作课:夏丏尊叶圣陶教你写文章(读书笔记)]]></title>
            <link>https://blog.gusibi.mobi/article/example-7</link>
            <guid>https://blog.gusibi.mobi/article/example-7</guid>
            <pubDate>Mon, 03 May 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[七十二堂写作课:夏丏尊叶圣陶教你写文章(汉语写作的指导圣经)]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-e5c3b6856d034e708166323937ffb6ef"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-callout notion-gray_background_co notion-block-da020ca3b1ec4b8faf6eda47a632bacf"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="😀">😀</span></div><div class="notion-callout-text">作者：夏丏尊, 叶圣陶</div></div><div class="notion-blank notion-block-50f9b0bc99c24edba09e16020779f8f7"> </div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-bd259dccf66c44b3b0ff0d1f0ae849be" data-id="bd259dccf66c44b3b0ff0d1f0ae849be"><span><div id="bd259dccf66c44b3b0ff0d1f0ae849be" class="notion-header-anchor"></div><a class="notion-hash-link" href="#bd259dccf66c44b3b0ff0d1f0ae849be" title="第一讲 文章面面观"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第一讲 文章面面观</b></span></span></h3><div class="notion-text notion-block-ad51581afa7040ebb687b75246e4cb10">2021-05-02 19:49:19</div><div class="notion-text notion-block-08533f3d612c40f98a3b53df30bffedb">一、这篇文章属于哪一类？和哪一篇性质相似或互异？这类文章有什么特性和共通式样？（文章的体制）</div><div class="notion-text notion-block-f4260bfd102f43d893755667ef92878d">二、文章里用着的词类，有否你所未见的或和你所知道的某词大同小异的？（语汇的搜集）</div><div class="notion-text notion-block-8d1c5c6e524d40b18a9cc19d55a3990a">三、文章里词和词或句和句的结合方式有否特别的地方？你能否一一辨认，并且说出所以然的缘故？（文法）</div><div class="notion-text notion-block-3f7634ba882042bda0e4e39173b19b90">四、文章里对于某一个意思用着怎样的说法？那种说法有什么效力？和别种说法又有什么不同？（修辞）</div><div class="notion-text notion-block-702ee2aecad64b4cb82270e0b48a0c2f">五、文章里有什么好的部分？好在哪一点？有什么坏的部分？坏在哪一点？（鉴赏与批评）</div><div class="notion-text notion-block-afa8bbd52a1e4d26894c0bd16e300058">六、这篇文章和别人所写的同类的东西有什么不同？你读了起什么感觉？（风格）</div><div class="notion-text notion-block-d2dc1d68edf44496944a138ded56436a">七、从开端到结尾有什么脉络可寻？有否前后相关联的部分？哪一部分是主干？哪些部分是旁枝？（章法布局）</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-7a0cafe080a24f508d85ca4f0b6651d6" data-id="7a0cafe080a24f508d85ca4f0b6651d6"><span><div id="7a0cafe080a24f508d85ca4f0b6651d6" class="notion-header-anchor"></div><a class="notion-hash-link" href="#7a0cafe080a24f508d85ca4f0b6651d6" title="第二讲 文言体和语体（一）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第二讲 文言体和语体（一）</b></span></span></h3><div class="notion-text notion-block-301fbaf11f2942bea88b7403dc3bc2cc">2021-05-02 19:51:14</div><div class="notion-text notion-block-0bb54903d52a4193a16bf14ed800f5c7">曲剧里的词曲大都是文言体，而说白却大都是语体，白话的“白”字就是从这里来的。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-0efdb4266f214cb5bf743b6694abe63e" data-id="0efdb4266f214cb5bf743b6694abe63e"><span><div id="0efdb4266f214cb5bf743b6694abe63e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#0efdb4266f214cb5bf743b6694abe63e" title="第七讲 书信的体式"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第七讲 书信的体式</b></span></span></h3><div class="notion-text notion-block-af35051e1b8648379918cfffb931a768">2021-05-02 20:07:05</div><div class="notion-text notion-block-a86c99e95f1d4492bfc1a184e01bda19">有人说：“现代的厨子，书信来往比古代的大臣要多。”在现代生活中，我们差不多每天要写书信，书信的繁忙是现代生活的特征之一。</div><div class="notion-text notion-block-bacebc2ff6934e2a8533aa305c3e18eb">注 | 民国短信</div><div class="notion-blank notion-block-6a69cedef3a54d7a8803d7e538b66182"> </div><div class="notion-text notion-block-16f206d278754cf6ab4608a2acb02b59">2021-05-02 20:08:09</div><div class="notion-text notion-block-4330d38576c04dc786c386e2142168af">书信的构造通常可分为三部分：第一部分叫作“前文”，内容是寻常的招呼和寒暄；第二部分是事务，这是书信的最主要的部分；第三部分仍是寒暄和招呼，叫作“后文”</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-7ff9a6d65cb741609875d5af3db4ecc7" data-id="7ff9a6d65cb741609875d5af3db4ecc7"><span><div id="7ff9a6d65cb741609875d5af3db4ecc7" class="notion-header-anchor"></div><a class="notion-hash-link" href="#7ff9a6d65cb741609875d5af3db4ecc7" title="第十讲 记述和叙述"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第十讲 记述和叙述</b></span></span></h3><div class="notion-text notion-block-557f3bbe1bd04bff9a6d111236b460e0">2021-05-02 20:13:24</div><div class="notion-text notion-block-aa6d2b7a3ec24d01bcaf0cc1775fb8bb">我们对于外界事物有两种看法，一是从它的光景着眼，一是从它的变化着眼。对于某种事物，说述它的形状怎样，光景怎样，是记述；说述它的变迁怎样，经过情形怎样，是叙述。前者是空间的，静的；后者是时间的，动的。用比喻来说，记述文是静止的照片，叙述文是活动的电影。静止照片所表示的是事物一时的光景，电影所表示的是事物在许多时候中的经过情形</div><div class="notion-blank notion-block-b844897263ea4b488f6cdd5c9d89b05b"> </div><div class="notion-text notion-block-41478608a5be486f89a9d047e1157f12">2021-05-02 20:14:36</div><div class="notion-text notion-block-36f92269b6ca45aaa8071faa57513a5b">叙述其实是许多记述的连续。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-9a3b530b6f1d494284306903345d97d8" data-id="9a3b530b6f1d494284306903345d97d8"><span><div id="9a3b530b6f1d494284306903345d97d8" class="notion-header-anchor"></div><a class="notion-hash-link" href="#9a3b530b6f1d494284306903345d97d8" title="第十一讲 记述的顺序"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第十一讲 记述的顺序</b></span></span></h3><div class="notion-text notion-block-437215e3d5404623a37977575732f189">2021-05-03 10:07:33</div><div class="notion-text notion-block-1f40d5b9955340bb8184f7bcd39330a1">记述文是写事物的光景的，事物在空间的一切形状，就是记述文的材料</div><div class="notion-blank notion-block-791a8a629943474eaf0d5431e2708c30"> </div><div class="notion-text notion-block-eb5802df691d4fc2869dec1e4c06e2aa">2021-05-03 10:07:49</div><div class="notion-text notion-block-3399db2b732c4d5da19adb070200e843">记述文可以说是作者对于某事物观察的结果。观察的顺序就是记述的顺序。</div><div class="notion-blank notion-block-b0bbbee87f1a4c819ea1c001b40dac5f"> </div><div class="notion-text notion-block-957e07fd62d4448c8e836bd6e6f0cfee">2021-05-03 10:08:02</div><div class="notion-text notion-block-b5a3955cf9784dd59cdfaf191774cb96">有许多事物是有统属关系的，我们观察的时候要从全体看起，顺次再看各部分，否则就看不明白，说不清楚</div><div class="notion-blank notion-block-86408238616a4013bfc569dcb38a5b2d"> </div><div class="notion-text notion-block-a28824b1ae4c4b348470d8a987fd7423">2021-05-03 10:08:17</div><div class="notion-text notion-block-8535240d3a124c1386531f2d35f1ab6c">记述文里所写的是事物的光景，要想把事物的光景明白传出，有两个最重要的条件。一个是着眼在位次，把事物所包含的千头万绪的事项，依照了自然的顺序，分别述说。</div><div class="notion-blank notion-block-9f7e53e471b14ff4bcf2d32ec93e3fad"> </div><div class="notion-text notion-block-4107ac1f588d42728881e8f455f5c131">2021-05-03 10:08:33</div><div class="notion-text notion-block-f229ac6e6c2d4031ac6e7ccbcb64c261">顺序不乱、特色明显的，才是好的记述文</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-95e16ee17eab4f8483fd1aa6b095bd32" data-id="95e16ee17eab4f8483fd1aa6b095bd32"><span><div id="95e16ee17eab4f8483fd1aa6b095bd32" class="notion-header-anchor"></div><a class="notion-hash-link" href="#95e16ee17eab4f8483fd1aa6b095bd32" title="第十二讲 叙述的顺序"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第十二讲 叙述的顺序</b></span></span></h3><div class="notion-text notion-block-616edad92ede4cd8a07f2a894ecbd305">2021-05-03 10:08:48</div><div class="notion-text notion-block-52b5fbf397614b48978911b4058fc726">叙述文所写的是事物的变化</div><div class="notion-blank notion-block-9bdbed4358684a8786d91fd344f7ad09"> </div><div class="notion-text notion-block-ff6769179c1b4d97b9fa9fe0a72dd88b">2021-05-03 10:12:42</div><div class="notion-text notion-block-25596bc8dc304beea1351914b74b749d">变化、变迁、经过都是关于时间的事，所以时间是叙述文的重要原素</div><div class="notion-blank notion-block-d7600e8ef469425ab923e394b06066a2"> </div><div class="notion-text notion-block-c160543684114a2d83bed3d4addafc7a">2021-05-03 10:12:59</div><div class="notion-text notion-block-84e3989578f64b7495baabb99cc085f8">叙述文是事物在某时间中的经过的记录，时间的顺序，可以说就是叙述的顺序</div><div class="notion-blank notion-block-8128df926c614ca0a9badf01c50239dc"> </div><div class="notion-text notion-block-2894780abc004d2ca2989c517a1e8332">2021-05-03 10:13:34</div><div class="notion-text notion-block-ebfdcbfadaa84a60bac18afa59a5d49f">我们叙述一件事情，须用剪裁的功夫，从无限的时间中，切取与那件事情最有关系的一段，从那件事情开始的时候写起，写到那件事情完毕的时候为止。那前前后后的无大关系的时间，都可以不必放在眼里。</div><div class="notion-blank notion-block-e977ea0567f64c119cd3d390fcb1497d"> </div><div class="notion-text notion-block-f08f610d2d23455ba326578eaed868fa">2021-05-03 10:15:11</div><div class="notion-text notion-block-e9ec03592ab04228a5491ba9ceebe6b8">于切取来的一段时间的各部分，也不必平等看待。我们叙述事物变化、经过，目的在于把特点传出。</div><div class="notion-blank notion-block-913d73ddfdc4455e80c038e53ceebf7f"> </div><div class="notion-text notion-block-1664a3e78e5b44639e22b9fa0d6f3554">2021-05-03 10:15:39</div><div class="notion-text notion-block-8484d7942e794c16b28644688070d8ba">无关特色的材料越少，特色越能显露出来。这情形和记述文一样，不过记述文是空间的，叙述文是时间的罢了。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-260aed43e4954d398089382045ee2743" data-id="260aed43e4954d398089382045ee2743"><span><div id="260aed43e4954d398089382045ee2743" class="notion-header-anchor"></div><a class="notion-hash-link" href="#260aed43e4954d398089382045ee2743" title="第十三讲 记叙的题材"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第十三讲 记叙的题材</b></span></span></h3><div class="notion-text notion-block-6a530119b149472a815cd53ddd8cfcd4">2021-05-03 10:17:02</div><div class="notion-text notion-block-863249e24c2049e8b772fb93ee228e99">事物的新奇的意味，可分两方面来说。一是事物本身的不平凡，如远地的景物、风俗，奇巧的制作，国家的大事故，英雄、名人的事迹，复杂的故事等等，这些当然值得写。一是事物本身是平凡的，但是作者对于这平凡的事物却发见了一种新的意味，这也值得写。从来记叙文的题材不外这两种。其实，除应用文以外，一切文章的题材也就是这两种</div><div class="notion-blank notion-block-24d266bccac74e948da52d50edf97beb"> </div><div class="notion-text notion-block-b55bebfff72448539659ccf43d45c31f">2021-05-03 10:17:42</div><div class="notion-text notion-block-4249e12597f6462088931ce7d62e70dc">新的意味是记叙文的题材的生命。事物的新的意味，要观察、体会才能发见。所以观察、体会的修炼，是作记叙文的基本功夫</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-707c620fb71e4e73aeec412a12da7a31" data-id="707c620fb71e4e73aeec412a12da7a31"><span><div id="707c620fb71e4e73aeec412a12da7a31" class="notion-header-anchor"></div><a class="notion-hash-link" href="#707c620fb71e4e73aeec412a12da7a31" title="第十四讲 材料的判别和取舍"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第十四讲 材料的判别和取舍</b></span></span></h3><div class="notion-text notion-block-0cde8b098f5c46a5992fb0d45ec63773">2021-05-03 10:18:23</div><div class="notion-text notion-block-b1613923388b40c898a7b3c12ad0b707">作者对于某事物自以为发见了某种新的意味了，要写成文章告诉大家，这所谓新的意味，大概可归纳为三种性质：一是某种新的知识，二是某种新的情味，三是某种新的教训。</div><div class="notion-blank notion-block-5bfaada61fd54e10a268e01f96105be1"> </div><div class="notion-text notion-block-9f8a8779095141eeac145f77a6dce9d9">2021-05-03 10:19:24</div><div class="notion-text notion-block-cb218fbfb0be45efb0df87a8a9c4e284">材料的判别和取舍，完全要看文章本身的意味如何。文章本身的意味就是决定材料的标准</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1b6c8aacb7534ba5b2f5ff2f1ec423a9" data-id="1b6c8aacb7534ba5b2f5ff2f1ec423a9"><span><div id="1b6c8aacb7534ba5b2f5ff2f1ec423a9" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b6c8aacb7534ba5b2f5ff2f1ec423a9" title="第十五讲 叙述的快慢"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第十五讲 叙述的快慢</b></span></span></h3><div class="notion-text notion-block-a08fe5d6d9b7493abdeb2d6913a6d121">2021-05-03 10:22:00</div><div class="notion-text notion-block-6b69d22f50c84e0791348a493a8dec42">叙述文所写的是事物的变化、经过。一件事物先怎样，后来怎样，结果怎样，这里面有着一种流动。事物的变化、经过，是事物本身在时间上的流动，把这流动写记出来，就是叙述文。所以流动是叙述文的特性。</div><div class="notion-blank notion-block-96b9a7f8c146467baa03ea6a61526aa8"> </div><div class="notion-text notion-block-f3106dc3a0554439aba1596cca796a8e">2021-05-03 10:23:07</div><div class="notion-text notion-block-818a0feeb79344eead4ed13982d4aeab">写入文章里面，因为要使事件的特色显出，就得把不必要的材料删去，在流动上更分出人为的快慢来。</div><div class="notion-text notion-block-21d426125e154eb6a9b87677b156d407">注 | 把笔墨用在重要的点上，而不是平均分配</div><div class="notion-blank notion-block-3afd6a6bc816441c8f30b20093f85435"> </div><div class="notion-text notion-block-4a70f5847765484c99b69725653c5e50">2021-05-03 10:24:20</div><div class="notion-text notion-block-4fb2ed340ebc48fa83c8b924c3812ee2">同样叙述事物的一段经过，详细地写，流动就慢了，简略地写，流动就快了。</div><div class="notion-blank notion-block-ff3d7c364e6e423685b5ab02817fb796"> </div><div class="notion-text notion-block-f86f7458dafc489986715b617619393c">2021-05-03 10:24:12</div><div class="notion-text notion-block-54f1c6ca7754480892117f038386f584">快的叙述，便于报告事件进行的梗概；慢的叙述，便于表现事件进行时的状况。</div><div class="notion-blank notion-block-b6812f65954e4099aa367a2135f8fae8"> </div><div class="notion-text notion-block-0f9788ba087e42a0a9f565f4dbd665c1">2021-05-03 10:25:11</div><div class="notion-text notion-block-79fcfac30b8046afa2db1d42d09b9f75">快慢就是详略，把不重要的部分略写，重要的部分详写，都是为了想显出特色的缘故。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1c900f7941f14ff084b8c0048d03078e" data-id="1c900f7941f14ff084b8c0048d03078e"><span><div id="1c900f7941f14ff084b8c0048d03078e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1c900f7941f14ff084b8c0048d03078e" title="第十六讲 叙述的倒错"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第十六讲 叙述的倒错</b></span></span></h3><div class="notion-text notion-block-0bc10a47aa9846d485cf0132e9c15162">2021-05-03 10:26:20</div><div class="notion-text notion-block-f7102583871f4750afb5a6f547b031c4">叙述可以倒错，但倒错的说法究竟是变格，遇必要时才可以用，胡乱的倒错，那是徒乱秩序，毫无效果的</div><div class="notion-blank notion-block-bbcba371734b45fd95e6d3c2818bc2ab"> </div><div class="notion-text notion-block-63d65a51dd814af880fc0cf63e014a7c">2021-05-03 10:27:48</div><div class="notion-text notion-block-3196a81262264c38b390b3c6ff956849">我们叙述一件事，为要使事件的特色显出，必须淘汰无关紧要的闲话。倒错的叙述，无非是淘汰闲文，显出特色的一种方法。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-325a63591df34a79831c056bf10f35a5" data-id="325a63591df34a79831c056bf10f35a5"><span><div id="325a63591df34a79831c056bf10f35a5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#325a63591df34a79831c056bf10f35a5" title="第十七讲 过去的现在化"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第十七讲 过去的现在化</b></span></span></h3><div class="notion-text notion-block-185743d9a86640a5a2f28c2543bb198d">2021-05-03 10:28:11</div><div class="notion-text notion-block-6affc5d2f31549599f8b52e27c6c8592">记述文是看了事物的光景写记的，所写的是作者对于事物的观察、经验，是一时的</div><div class="notion-blank notion-block-67f059583f264a7e8ae3105d0d14e3f7"> </div><div class="notion-text notion-block-90c70d47fd3640138bfba89bea96f756">2021-05-03 10:28:17</div><div class="notion-text notion-block-9c07c2607c624dbbbdc933b3a6c90632">叙述文所写的是事物在某期间的经过、变化，这经过、变化大抵是既往的事情，是连续的，过去的</div><div class="notion-blank notion-block-fb8fc2e5683d46038e4356ab0b5fd634"> </div><div class="notion-text notion-block-187cb879a03e4193be843f73e7425fa7">2021-05-03 10:29:33</div><div class="notion-text notion-block-53413465b5674ad8bfc166f2873dcbf9">叙述文的目的无非要把事物的经过、变化传述给读者知道。人差不多有一种天性，对于过去的决定了的事件，不大感到兴味，对于亲眼看见的事件，常会注意它的进展，以浓厚的兴味去看它的结果如何。</div><div class="notion-blank notion-block-e65ea891ce0b438caef46a29d9eb3204"> </div><div class="notion-text notion-block-0a2a28a4c33a4d11850b2be086cf78b5">2021-05-03 10:30:58</div><div class="notion-text notion-block-42b6fd78e2a14aff8f656303d98e7781">过去的事件用现在的笔法叙述，读者读去的时候，就好像和作者同在看一件事的进展，事件的结果的发见，好像不只是由于作者的提示，读者自己也曾有发见的劳力在内。这样，读者的兴味就能增进了。</div><div class="notion-text notion-block-380136f1b99d4fe9a2dbb450804b74fb">注 | 让读者带入</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-399854155d724845a6231b21b349305b" data-id="399854155d724845a6231b21b349305b"><span><div id="399854155d724845a6231b21b349305b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#399854155d724845a6231b21b349305b" title="第十八讲 观点的一致与移动"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第十八讲 观点的一致与移动</b></span></span></h3><div class="notion-text notion-block-455f6a0065e248ed8062593dc8104051">2021-05-03 10:33:24</div><div class="notion-text notion-block-eda290d8269042a4b402470188537f05">所谓推移，换句话说，就是作者观点的移动。作者的眼睛或心意，好比照相机的镜头，是可以任意转动，更换方面的</div><div class="notion-blank notion-block-353da1195c964e1883df2109f14f9e16"> </div><div class="notion-text notion-block-2ae7efd9f12e4ba0a3ce4dfce0c1513e">2021-05-03 10:34:11</div><div class="notion-text notion-block-784cd38b1baa4454be9ed9f3aaaa514d">在复杂的叙述文里，一定要把观点放在一方面，强求一致，对于事件的表现也许不方便。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-66f5a435580d40ce8aafce5e0c1bb605" data-id="66f5a435580d40ce8aafce5e0c1bb605"><span><div id="66f5a435580d40ce8aafce5e0c1bb605" class="notion-header-anchor"></div><a class="notion-hash-link" href="#66f5a435580d40ce8aafce5e0c1bb605" title="第十九讲 日记"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第十九讲 日记</b></span></span></h3><div class="notion-text notion-block-d1140a13afba4320b7ae3e63e078439b">2021-05-03 10:35:57</div><div class="notion-text notion-block-cca28d8e151e4319881eace18f0b7a26">日记写作的目的，第一是备查检。某人关于某件事曾于某日来信，自己曾于某日怎样答复他，某日曾下过大雨，某一件东西从何处购得，价若干，钱是从哪里来的，诸如此类的事，只要写上日记，一查便可明白。第二是助修养。我们读历史，可以得到鉴戒。日记是自己的历史，赤裸裸地记着自己的行事，随时检阅，当然可以发觉自己的缺点所在。</div><div class="notion-blank notion-block-99a85602d50a438188a9fe57f49bf8a4"> </div><div class="notion-text notion-block-5499717ffdd946f3a0b94c7e858b2ea5">2021-05-03 10:36:57</div><div class="notion-text notion-block-9f46c413cc6043d9a128153fe7c0d5ac">日记是叙述文，该用叙述文的选材方法，并且要简洁地写。我们写日记，大概只在临睡前或次日清晨的几分钟，时间有限，写作的方法自不得不力求简洁；把认为值得记入的几件事扼要写记，把平板的例定的事件一律舍去。否则不但会把该记的要事反而漏掉，还会叫你不能保持每天记日记的好习惯。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-106c75d38e8445af95efa4415604780b" data-id="106c75d38e8445af95efa4415604780b"><span><div id="106c75d38e8445af95efa4415604780b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#106c75d38e8445af95efa4415604780b" title="第二十讲 游记"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第二十讲 游记</b></span></span></h3><div class="notion-text notion-block-fd4afc96b987469399a1d99c55ca0cae">2021-05-03 10:38:01</div><div class="notion-text notion-block-687a2ce87a8c42d88a865973d0532996">游记之中含有两种成分，就是作者自己的行动和所游境地的光景。游记和日记不同，是预想有读者的文章。读者所想知道的是所游境地的光景，不是作者自己的行动。</div><div class="notion-blank notion-block-a3448357620f4a85a407736af98ee771"> </div><div class="notion-text notion-block-c125f605feab4a08a9a791c3cf4558d3">2021-05-03 10:40:14</div><div class="notion-text notion-block-e512fbd609624aad875b3ac42bc0f79c">是从别一方面说，写作者自己的行动是动的，是叙述；写所游境地的光景是静的，是记述。游记在性质上属于叙述文，目的在借文字“引人入胜”，生命全在流动的一点上。死板地去写记所游境地的光景，结果会使流动随时停止，减少趣味。最好的方法是将作者的行动和所游境地的光景合在一处写；这就是说，写作者行动的时候要和境地的光景有关联，写境地的光景的时候也要和作者的行动有关联。</div><div class="notion-blank notion-block-ecd97666805b49148635194f9a2f1db7"> </div><div class="notion-text notion-block-b4b7fde2697b4113a47f08a1332f5796">2021-05-03 10:41:33</div><div class="notion-text notion-block-897c0ac5d55f4a7db715cf40a964ccf0">游记是记述和叙述两种成分揉合的文章，一切记述和叙述的法则，如写述的顺序、要点的把捉等等，都可应用。说明及议论，如非必要，可以不必加入</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-c831371920f1486d96db498217f64bc0" data-id="c831371920f1486d96db498217f64bc0"><span><div id="c831371920f1486d96db498217f64bc0" class="notion-header-anchor"></div><a class="notion-hash-link" href="#c831371920f1486d96db498217f64bc0" title="第二十一讲 随笔"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第二十一讲 随笔</b></span></span></h3><div class="notion-text notion-block-4b83d65d34fa40eb9473e06aafae5235">2021-05-03 10:43:48</div><div class="notion-text notion-block-71aca76b53a543f6b8edccef20b1fb31">日记和游记都是生活的记述，日记以时日为纲领，游记以地域为纲领，范围都比较有一定。文章中还有写述随时随地的片段的生活的，叫作随笔，或者叫作小品。</div><div class="notion-blank notion-block-e7683455a663409ba0785748cbb2cef0"> </div><div class="notion-text notion-block-951c5a010f1b42888ab3ed5e70ab143a">2021-05-03 10:43:27</div><div class="notion-text notion-block-5aa1faa882584ce0a3abb0d7c4a204df">随笔和别的文章的不同：（一）形式上在不必拘泥全篇的结构。一般的文章大概是有结构的，如传记须把人物的各方面按照时间先后大体叙述，游记须把游览的程序和游览的地方顺次写记，随笔却可以只写小小的一片段，不一定要涉及全体。（二）题材上在发端于实际生活。随笔中尽可发抒各种关于政治社会的大意见、关于宇宙人生的大道理，但往往并不预定了题目凭空立说，而只从自己实际生活上出发。</div><div class="notion-blank notion-block-138317d07eac417d841b1e2901244c72"> </div><div class="notion-text notion-block-dcbf2ea9b0b24ea58d322d177174841b">2021-05-03 10:44:33</div><div class="notion-text notion-block-12113a4a61244f4293b9483827db4ef7">随笔是文章上的速写；独立地看来，固然自成一体，但同时又可做写作长篇的基本练习。一般人要练习写作，每苦没有可写的材料；随笔是从日常生活出发的东西，只要能在生活方面留心去体察、玩味，就决不至于愁没有材料。所以写随笔和写日记一样，是练习写作的好方法。</div><div class="notion-blank notion-block-b9129b34101d4a52bfff2ed870edb2ec"> </div><div class="notion-text notion-block-aa9821db3a3a40768eb465d7b417ff50">2021-05-03 10:45:10</div><div class="notion-text notion-block-663b916cc4e24cebb389359ae1d477eb">平凡的生活中不知蕴藏着多少新鲜的东西，等待我们自己去发掘。学写随笔的第一步功夫，就是体察、玩味自己的生活，在自己的生活上作种种的发掘。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-057d0892d20d497587df017118200915" data-id="057d0892d20d497587df017118200915"><span><div id="057d0892d20d497587df017118200915" class="notion-header-anchor"></div><a class="notion-hash-link" href="#057d0892d20d497587df017118200915" title="第二十二讲 直接经验和间接经验"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第二十二讲 直接经验和间接经验</b></span></span></h3><div class="notion-text notion-block-f3d7e41a036c4f24827a674eb6b37934">2021-05-03 10:46:02</div><div class="notion-text notion-block-c962f252a10b4a0e963587ab360cc6ec">我们的经验有两种，一种是亲自经历得来的，一种是从书本上或旁人口头上得来的；普通所谓“见闻”，就把这两种都包括在内。前者叫作直接经验；后者叫作间接经验。直接经验当然最确实可靠，只是范围较狭；间接经验很广，只是有时不十分确实可靠，须仔细加以辨别。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-4f2fa0428f244f39a9db843eddbbe9a0" data-id="4f2fa0428f244f39a9db843eddbbe9a0"><span><div id="4f2fa0428f244f39a9db843eddbbe9a0" class="notion-header-anchor"></div><a class="notion-hash-link" href="#4f2fa0428f244f39a9db843eddbbe9a0" title="第二十三讲 间接经验的证明"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第二十三讲 间接经验的证明</b></span></span></h3><div class="notion-text notion-block-de5b951ade1748e8bc98fdd3229ef668">2021-05-03 10:48:56</div><div class="notion-text notion-block-603e4eae94064f4d8e0e87daa41eaf1d">间接经验可以和直接经验同等看待，写入文章去，但作者为取得读者的信用起见，也有时说明来历，证明他所说的事件是真实的。</div><div class="notion-blank notion-block-9743a47529be4edd954f733dfdf3ac72"> </div><div class="notion-text notion-block-4d8fc87a85ea4f68b53a71c5a0d57323">2021-05-03 10:50:35</div><div class="notion-text notion-block-fac7125ca41549b4ad9521b74904b27a">间接经验无法明了事件的微细部分，是很明白的。而作者在叙述文中为要传出真相，使读者领会，往往非凭了想象把事件的微细部分一并写述不可。本来无法明了的事，怎能写述呢？作者对于这一点，通常有两种办法。一是不顾一切，老老实实把间接经验当作自己的直接经验来写。二是在文章中表明经验的由来，说他所叙述的依据着某人的话或某书的记载，有时或仅在文章末尾加一“云”字（这常见于文言文），表示他的话有所依据，并非自己假造。这“云”字在语言是“据说”的意思，非常活动，不必明说这经验从何人或何书得来，总之表示有依据罢了。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-ef08468f713440589dba87593820a340" data-id="ef08468f713440589dba87593820a340"><span><div id="ef08468f713440589dba87593820a340" class="notion-header-anchor"></div><a class="notion-hash-link" href="#ef08468f713440589dba87593820a340" title="第二十四讲 第一人称的立脚点"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第二十四讲 第一人称的立脚点</b></span></span></h3><div class="notion-text notion-block-f64e44359e44405291d7b01ad97f28ea">2021-05-03 10:53:30</div><div class="notion-text notion-block-682e8097d73c4f5ea99130f01fa6ad88">从第一人称的立脚点写文章，全体都须统一，不可把立脚点更动。最该注意的是人和地方的称呼。人和地方的称呼是因了说话的人的立脚点而不同的。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-7df3a3fbf3b44048b9fdbd662dab51d9" data-id="7df3a3fbf3b44048b9fdbd662dab51d9"><span><div id="7df3a3fbf3b44048b9fdbd662dab51d9" class="notion-header-anchor"></div><a class="notion-hash-link" href="#7df3a3fbf3b44048b9fdbd662dab51d9" title="第二十五讲 第二人称的立脚点"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第二十五讲 第二人称的立脚点</b></span></span></h3><div class="notion-text notion-block-bfc19478ea7e49d8a8e53367a4ec3f8d">2021-05-03 10:54:43</div><div class="notion-text notion-block-addc5cc575a341afa8854622492467f7">第一人称的文章好比独白，第二人称的文章好比对话。用第二人称的立脚点写文章，是从“你”（或“君”“兄”“先生”等尊称）出发的，这所谓“你”就是读者。</div><div class="notion-text notion-block-2dad33a5960640be8c209c8de01602f7">这类文章最普通的是书信，其他为特定的对手写的文章像祭文、训辞、祝辞等也属于这一类。</div><div class="notion-text notion-block-7ff42f62dec34498b7b4fd9e250e567d">注 | 你怎么怎么 你应该如何如何 就好像对着读者说一样</div><div class="notion-blank notion-block-7936334fe871491284fcf93b66be097f"> </div><div class="notion-text notion-block-9daa7f93416c401e98b69ae99fc76044">2021-05-03 10:56:40</div><div class="notion-text notion-block-3e8d8232d87045f0bf1a23b413d75c5d">文章原是以读者为对象的，不拘任何人，当他和文章接触的时候，就是作者的对手了。因此，作者对读者不妨称“你”。这比较泛称“人”来得亲切，用在劝诱文、说明文中很适当</div><div class="notion-text notion-block-7d42568fc74948ae9821100cb9b38cdd">注 | 说明文 文档一类常用</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-2a6c099f41f4425092b920e6580e7f84" data-id="2a6c099f41f4425092b920e6580e7f84"><span><div id="2a6c099f41f4425092b920e6580e7f84" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2a6c099f41f4425092b920e6580e7f84" title="第二十六讲 第三人称的立脚点"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第二十六讲 第三人称的立脚点</b></span></span></h3><div class="notion-text notion-block-7cb996c26d3b44adbdb645f72acb9752">2021-05-03 10:58:15</div><div class="notion-text notion-block-a81108570df64883a96c6c1a05ca7de5">第一人称的立脚点便于写出自己，第二人称的立脚点便于告语特定的对手，都要受到种种的限制。比较自由的是第三人称的立脚点。第三人称的文章是从“他”或那人的真姓名出发的，普通以用真姓名的占多数</div><div class="notion-blank notion-block-13a6a16a73b74402b8a693cd1db21bf8"> </div><div class="notion-text notion-block-ff6afc83db0845c99c1bf85a08c0345e">2021-05-03 10:59:39</div><div class="notion-text notion-block-69ddd1f51065403188ea162af3bb9869">用第三人称的立脚点写文章，作者可取的有两种态度：一是客观的态度，一是全知的态度。</div><div class="notion-blank notion-block-19676991860c4e1c832a163904ecdf48"> </div><div class="notion-text notion-block-a50df10d035b4812b9128506d43b2977">2021-05-03 10:59:32</div><div class="notion-text notion-block-c4072151ad1648d291953b17a7bf4dac">客观的态度是知道什么写什么，看到什么写什么，作者对于所叙述的人物或事件，不说任何想象揣测的话。这适宜于事实的叙述，我们平常所写作的叙述文，都属于这一类。在这种态度之下，一切以作者的直接经验为基础，作者的叙述中如有非直接经验的事项（即间接经验），须说明来历，否则就不相应了。</div><div class="notion-blank notion-block-2a6aa65339d742388c3ae00ff14b3037"> </div><div class="notion-text notion-block-3a84c5e365c24893b6dc994a1732cff0">2021-05-03 10:59:50</div><div class="notion-text notion-block-fab5f361e9114296904f77c1bfcf1439">全知的态度是作者除写一些亲见亲闻的事物以外，更凭着想象的揣测立言，表示他无所不知。在这种态度之下，作者好似全知全能的神，从天上注视下界，一切人物的内心秘密，他无不知道。他不但能知道某一方面的人物的内心秘密，还能同时知道某方面的人物的各种情形。这常应用于小说、历史、传记等。</div><div class="notion-text notion-block-b8ecf652b11a433f973c1650b425c896">注 | 上帝视角</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-14b229b509f341ed9f713de1acbe1ac6" data-id="14b229b509f341ed9f713de1acbe1ac6"><span><div id="14b229b509f341ed9f713de1acbe1ac6" class="notion-header-anchor"></div><a class="notion-hash-link" href="#14b229b509f341ed9f713de1acbe1ac6" title="第二十七讲 叙述的场面"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第二十七讲 叙述的场面</b></span></span></h3><div class="notion-text notion-block-89836c1ed05e471cb5e22277f2b2b5d9">2021-05-03 11:06:25</div><div class="notion-text notion-block-c20877b57dee470087aa2fbd6bf1820d">在叙述文中，一段连续的时间和一个特定的空间为一个场面。这一个场面犹之戏剧里的一幕。时间、空间有变动了，就要另换场面。遇到复杂的事情，须要叙述的方面越多，场面也自然越要更换得多。</div><div class="notion-blank notion-block-03e74004dc724ad08ed09ada561211f7"> </div><div class="notion-text notion-block-a7be8f45e655409e9920605b1fa6ed07">2021-05-03 11:07:25</div><div class="notion-text notion-block-aaf548f17d6c4749915760f79e1a2c7a">选择场面的标准有二：一要看事件的全经过中，哪些是主要部分；二要看有关系的人物中，哪几个是主要人物。把场面配在事件的主要部分和主要人物上，就不致大错了。</div><div class="notion-blank notion-block-d05fd78d51494d41b7138c468bfc7411"> </div><div class="notion-text notion-block-ada4287642914d318f86e14bd331df4c">2021-05-03 11:08:03</div><div class="notion-text notion-block-f83dffb7829647799f2b44e2d0b7b846">文章遇到改换场面的时候，必须交代清楚，否则就难叫读者明了。戏剧中换场面的时候，是用闭幕的办法的。文章中换场面的表示法有两种：一是分段另写；一是用一句话来点明，如“武松在路上行了几日，来到阳谷县地面”“王冕自此在秦家放牛”之类</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-ac31405045f146acb40c9a2b3c601ff0" data-id="ac31405045f146acb40c9a2b3c601ff0"><span><div id="ac31405045f146acb40c9a2b3c601ff0" class="notion-header-anchor"></div><a class="notion-hash-link" href="#ac31405045f146acb40c9a2b3c601ff0" title="第二十八讲 事物与心情"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第二十八讲 事物与心情</b></span></span></h3><div class="notion-text notion-block-e7ca0574b286468cae400e1b2abde749">2021-05-03 11:09:31</div><div class="notion-text notion-block-8c660dfd854f4f41b3a5e0974314e008">第一，记叙的顺序不同，写成的文章就互异了。第二，对于材料的取舍，各人未必一致，因此，写成的文章就互异了。第三，对于同一材料，各人又有各人的看法，看法不一样，写成的文章也就互异了</div><div class="notion-text notion-block-6f5389c7eb4349d7a6971a0bfab5dac9">注 | 同一材料不同人写有不同的内容</div><div class="notion-blank notion-block-9a15fe05be3a4450a8189b37c08fbd7b"> </div><div class="notion-text notion-block-41b741a712484e11ad927a0a3426b582">2021-05-03 11:16:47</div><div class="notion-text notion-block-5a3dcd015d5144619667667bb56ced4b">心情是所谓主观方面的东西。客观的事物呈现在作者的面前，作者把主观的心情照射上去，然后写述出来。这虽不是发表什么意见，却也和呆板地照抄不同。正惟如此，所以两个作者记叙同一的题材，写成的文章总是彼此互异的。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-0e82c455402d40378b466b3d60a7de61" data-id="0e82c455402d40378b466b3d60a7de61"><span><div id="0e82c455402d40378b466b3d60a7de61" class="notion-header-anchor"></div><a class="notion-hash-link" href="#0e82c455402d40378b466b3d60a7de61" title="第二十九讲 情感的流露"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第二十九讲 情感的流露</b></span></span></h3><div class="notion-text notion-block-eabb76f577af479f9d2ba6a98344b60f">2021-05-03 11:18:14</div><div class="notion-text notion-block-3d163c3d666a403a95a9279e15676dc5">有一种记叙文，作者所以要写作的缘由并不在记叙他所写的事物，却在发抒他胸中的一段感情；感情不能凭空发抒，必须依托着事物，所以他用记叙事物的手段来达到发抒感情的目的，像这样的记叙文特称为抒情文</div><div class="notion-text notion-block-b2c8e80c29f4486180a014a350fdb1e8">注 | 抒情文</div><div class="notion-blank notion-block-99f39f39e7f24e2ea5dd8eb57f6abf59"> </div><div class="notion-text notion-block-7fb5733ba2784d2d85b4452ac0d03f98">2021-05-03 11:21:09</div><div class="notion-text notion-block-55b9bad7eb8741cfa4a6dd8c8f748073">你得把引起你的感情的事物记叙明白，教读者也具有你所有的经验，才能使读者知道并且感到你所怀的感情。能使读者知道并且感到，这才算真个把感情发抒了出来；否则只是郁而不宣，独感而没有传达给人家，虽然自以为写了抒情文，实际却等于没有写。</div><div class="notion-text notion-block-9ceb4de0b10142cf8f288faec910185a">注 | 抒情文必须依托着事物</div><div class="notion-blank notion-block-18d5064a0f5e4452b2cb2f6548f3ea05"> </div><div class="notion-text notion-block-92b4706d1a4d4480b1688c98a00727a8">2021-05-03 11:22:47</div><div class="notion-text notion-block-ff52de3e06b24da5a8091fea6693f12d">抒情文的材料的取舍以能否发抒感情为标准，大概使作者自己深深感动的事物都是适用的材料。依照着感情的情形记叙或者叙述，作者的感情就从这里头流露出来了</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-805c51e6d2b14d50a36bece51983e3fd" data-id="805c51e6d2b14d50a36bece51983e3fd"><span><div id="805c51e6d2b14d50a36bece51983e3fd" class="notion-header-anchor"></div><a class="notion-hash-link" href="#805c51e6d2b14d50a36bece51983e3fd" title="第三十讲 抒情的方式"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第三十讲 抒情的方式</b></span></span></h3><div class="notion-text notion-block-a807118eda9741acb778bfecbe183bc7">2021-05-03 11:23:12</div><div class="notion-text notion-block-ca1d17215ca44e0e8325c76d1c86ec5c">抒情大概有两种方式：一种是明显的；又一种是含蓄的。作者在记叙事物之后，情不自禁，附带写一些“快活极了”“好不悲伤啊”一类的话，教人一望而知作者在那里发抒他的感情，这是明显的方式。作者在记叙了事物之后，不再多说别的话，但读者只要能够吟味作者的记叙，也就会领悟作者所要发抒的感情，这是含蓄的方式</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-c6d724917fdc4ff387151459c9fc769f" data-id="c6d724917fdc4ff387151459c9fc769f"><span><div id="c6d724917fdc4ff387151459c9fc769f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#c6d724917fdc4ff387151459c9fc769f" title="第三十一讲 情绪与情操"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第三十一讲 情绪与情操</b></span></span></h3><div class="notion-text notion-block-8a5a09a4c75149a99627a5033317d961">2021-05-03 11:25:41</div><div class="notion-text notion-block-e4749928780a40639566afe2cf527fd9">这种感情在我们心里激荡的时候，好比江河里涌来了潮水；等到激荡的力量消退了，心境就仍旧回复到平静。通常把这种显然可辨的、渐归消退的感情叫作情绪。</div><div class="notion-text notion-block-3205667afdfe49108f2dc3c1fcdab0a9">注 | 情绪的定义</div><div class="notion-blank notion-block-8d3a879bb06243dc84e47537cd10433b"> </div><div class="notion-text notion-block-d75794ace5ad4d2f9d04682dfce522ca">2021-05-03 11:29:16</div><div class="notion-text notion-block-083ff1a9ead3472aa10a0204b0f61bc4">对于古昔的人物和事迹，我们往往有一种怀念的心情，这种心情和怀念一个相好的朋友并不相同；对于生死无常，我们往往有一种惆怅的心情，这种心情却说不上悲伤或是哀愁；当面对着高山或是大川的时候，我们总会起一种壮伟之感；当想到了时间的悠久和空间的广大的时候，我们总会起一种杳渺之思。这些都是情操而不是情绪。把这些作为基本调子，古往今来产生了不少的好文章</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-3fe1a7d36b5a4531828d72fe0786e1c2" data-id="3fe1a7d36b5a4531828d72fe0786e1c2"><span><div id="3fe1a7d36b5a4531828d72fe0786e1c2" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3fe1a7d36b5a4531828d72fe0786e1c2" title="第三十二讲 记叙与描写"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第三十二讲 记叙与描写</b></span></span></h3><div class="notion-text notion-block-5900c3774ef24c2da930d3daba34bcee">2021-05-03 11:30:12</div><div class="notion-text notion-block-f6c67d80631c4758b53c5f6263f9c020">详密的、生动的报告固然也是记叙，只因要与简略的、呆板的报告有一点分别起见，所以特称为描写。描写只是记叙的精深一步的工夫。描写的对象也是事物，离开了事物就无所谓描写，这是不待细说的</div><div class="notion-blank notion-block-62701180195243cc944469d56b43e627"> </div><div class="notion-text notion-block-c185f35eda934539b02315ef40eede1b">2021-05-03 11:31:59</div><div class="notion-text notion-block-85535529db984c78833dd8bfd455ca37">通常的记叙文好像用器画，看了用器画，可以知道事物的轮廓和解剖，但并不能引起对于那事物的实感。描写文章好像自在画，</div><div class="notion-text notion-block-2a98ac5477974f5b96ce89941b2a78a0">注 | 器画</div><div class="notion-text notion-block-3878934373be4df280c3cd338a782a53">自在画 素描 水彩画等</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-9b625d38e9a14c58bfbb5ff3751282fb" data-id="9b625d38e9a14c58bfbb5ff3751282fb"><span><div id="9b625d38e9a14c58bfbb5ff3751282fb" class="notion-header-anchor"></div><a class="notion-hash-link" href="#9b625d38e9a14c58bfbb5ff3751282fb" title="第三十三讲 印象"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第三十三讲 印象</b></span></span></h3><div class="notion-text notion-block-29a2dce6b4ee4b7ebca6e11d20f70f71">2021-05-03 11:36:00</div><div class="notion-text notion-block-443f0fe317bb42749f904725bd3aadf5">描写事物，目的在逼真与传神，所以最要紧的是捉住印象。什么叫作“印象”呢？这本是心理学上的一个名词，解释也不止一种。最普通的解释，就是从外界事物所受到的感觉形象，深印在我们脑里的</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-e9a4e108efed447cb37a5448254da532" data-id="e9a4e108efed447cb37a5448254da532"><span><div id="e9a4e108efed447cb37a5448254da532" class="notion-header-anchor"></div><a class="notion-hash-link" href="#e9a4e108efed447cb37a5448254da532" title="第三十四讲 景物描写"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第三十四讲 景物描写</b></span></span></h3><div class="notion-text notion-block-ff6a71b53ee6433c88c7a27e72e6ce17">2021-05-03 12:41:56</div><div class="notion-text notion-block-a4ae1903d2a4490d997b1119d94dbb73">我们把环绕着我们的境界都称为景物，自然的山水固然是景物，人为的房屋和市街也莫非景物。这当然不专指美丽的、赏心的而言，就是丑恶的、恼人的也包括在内。</div><div class="notion-text notion-block-eebfc66df90c4afca94f2e9d3f49287e">注 | 景物</div><div class="notion-blank notion-block-456605d09a8042229bb0d13049391cbb"> </div><div class="notion-text notion-block-543ca03a2e36410597126b47f6ce6bac">2021-05-03 12:42:38</div><div class="notion-text notion-block-09a57a81403d409682ab83b5f4ce4180">描写景物，第一要选定自己的观点。或者是始终固定的，就好比照相家站定在一个地位，向四周的景物拍许多照片；或者是逐渐移动的，就好比照相家步步前进，随时向周围的景物拍几张照片。观点不同，对于景物的方位、物像的形态、光线的明暗等等都有关系</div><div class="notion-blank notion-block-8bf6e51e40cd4376b8654ab2209c001a"> </div><div class="notion-text notion-block-a2d20904a31a4870aa5313297f50752b">2021-05-03 12:42:59</div><div class="notion-text notion-block-5f21b494a49149fd9351a6f3e7e60d6e">第二要捉住自己的印象。说得明白一点，就是眼睛怎样看见就怎样写，耳朵怎样听见就怎样写，内心怎样感念就怎样写。</div><div class="notion-blank notion-block-05af00f0c47143e19d63468ce15d04b6"> </div><div class="notion-text notion-block-6479586f1cdb45e992ee8f4a9488f681">2021-05-03 12:44:28</div><div class="notion-text notion-block-ffd7d9a12bec40619ee8c4962321db47">描写须要具体，不独对于景物，对于其他也如此。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-2507deb8cf844c128af2770591b3f609" data-id="2507deb8cf844c128af2770591b3f609"><span><div id="2507deb8cf844c128af2770591b3f609" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2507deb8cf844c128af2770591b3f609" title="第三十五讲 人物描写"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第三十五讲 人物描写</b></span></span></h3><div class="notion-text notion-block-ea20b5a840ce4df397522ae6ed992258">2021-05-03 12:45:09</div><div class="notion-text notion-block-8865ede6d1724ad099af4024546fe2f4">人物描写可以分外面、内面两部分来说。外面指见于外的一切而言，内面指不可见的心理状态而言</div><div class="notion-blank notion-block-f313dbc37196450fab1dbcd1e30becab"> </div><div class="notion-text notion-block-870c9a1decc94b069583544866b555b2">2021-05-03 12:45:19</div><div class="notion-text notion-block-e676a4a202d848f397d1445fe8d50de3">外面描写包含着状貌、服装、表情、动作、言语、行为、事业等等的描写</div><div class="notion-blank notion-block-c2838fffe6d94dbb9a3b45dd1310a544"> </div><div class="notion-text notion-block-db1019d11f354f50b1b74d49351868a6">2021-05-03 12:46:00</div><div class="notion-text notion-block-47899ec1865d4871be60130a4f55127d">状貌方面的某几点是其人的特点；服装方面的某几点足以表示其人的风度；在某一种情境中，哪一些表情和动作、哪几句言语正显出其人的品格；在一段或者全部生活中，哪一些行为和事业足以代表其人的生平。</div><div class="notion-blank notion-block-bb116fc509084840a294a8464b645bd3"> </div><div class="notion-text notion-block-734bf93bb64d4e0ea5542daf3c8fc26e">2021-05-03 12:47:35</div><div class="notion-text notion-block-b59c228a9a49445d8efc39a177e79b7e">内面描写就是所谓心理描写。心理和表现于外的一切实在是分不开来的：表现于外的一切都根源于内面的心理。他人内面的心理无从知道，我们只能知道自己内面的心理。但我们可以从自身省察，知道内面和外面的关系</div><div class="notion-blank notion-block-c46bc474ef99456d959b2b68c524dd9e"> </div><div class="notion-text notion-block-9dd4401a19154993a3b757aaf71ff154">2021-05-03 12:48:42</div><div class="notion-text notion-block-4bd5a3f7f6664f1ab63a2ef5ac49edcd">心理描写有时候就借用外面描写；换一句说，就是单就文字看，固然是外面描写，但仔细吟味起来，那些外面描写即所以描写其人的心理。如《背影》里的“扑扑衣上的泥土，心里很轻松似的。过一会说，‘我走了，到那边来信！’……他走了几步，回过头看见我，说，‘进去吧，里边没人’”，就是一个例子。这几句都是外面描写，可是把一位父亲舍不得和儿子分别的心理完全描写出来了。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-880d50b886384a7ba0a4557fe6128c0a" data-id="880d50b886384a7ba0a4557fe6128c0a"><span><div id="880d50b886384a7ba0a4557fe6128c0a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#880d50b886384a7ba0a4557fe6128c0a" title="第三十六讲 背景"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第三十六讲 背景</b></span></span></h3><div class="notion-text notion-block-e23bd923d60e47d68ec60db525381ae7">2021-05-03 12:49:29</div><div class="notion-text notion-block-316770becc004fdf9f2599a2c2a5f0d8">在抒情的、描写人物或事件的文章里，往往把周围的境界，如室内情形、市街情形、郊野情形、自然现象、时令特色等等，或简或繁地描写进去。这些项目统称为背景。</div><div class="notion-blank notion-block-980947120bc14930af7eb603bdd1a9ce"> </div><div class="notion-text notion-block-bcb54eea88e64d5481e6c7bd3e8755de">2021-05-03 12:49:44</div><div class="notion-text notion-block-22557a7836af43f3a3eeb4643dbea75a">文章里不需要和主人公无关的境界的描写</div><div class="notion-blank notion-block-982e3a06269c474da7424df06b0bf2cb"> </div><div class="notion-text notion-block-f82f9aa7768b452ebfc01adee7d51a3a">2021-05-03 12:50:21</div><div class="notion-text notion-block-e225903fc1824b4783d112397cc7a9db">凡是具有衬托的作用的就相称就有关，否则就不相称就无关</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-f15e2a9c271f4aaea3ac562e947386d6" data-id="f15e2a9c271f4aaea3ac562e947386d6"><span><div id="f15e2a9c271f4aaea3ac562e947386d6" class="notion-header-anchor"></div><a class="notion-hash-link" href="#f15e2a9c271f4aaea3ac562e947386d6" title="第三十七讲 记叙文与小说"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第三十七讲 记叙文与小说</b></span></span></h3><div class="notion-text notion-block-d7edbf1e15574d8bbf942808881b8868">2021-05-03 12:52:43</div><div class="notion-text notion-block-4ec056b66dcd4478b99dde6f4f699d15">作记叙文，必然先有可记叙的事物；换一句说，就是事物的存在或发生在先，而后作者提起笔来，给它作忠实的记录</div><div class="notion-blank notion-block-aa62c0f64b534954b0f3bd0fa1e142c2"> </div><div class="notion-text notion-block-cc85e1fb42cc4557a7304b4ae1e0a1b7">2021-05-03 12:55:25</div><div class="notion-text notion-block-5172ba8fe8f649cc8e877ff62f38c6b9">据实记录的记叙文以记叙为目的，只要把现成事物告诉人家，没有错误，没有遗漏，就完事了。出于创造的小说却以表出作者所看出来的一点意义为目的，而记叙只是它的手段。这是记叙文和小说的分别。</div><div class="notion-text notion-block-13bdbb124a8e4639b14ceaa3f168eee4">注 | 小说是作者凭空想象创造的东西，为的是表达作者的想法</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-dfa159ed92984eb8be405c9989c5ae88" data-id="dfa159ed92984eb8be405c9989c5ae88"><span><div id="dfa159ed92984eb8be405c9989c5ae88" class="notion-header-anchor"></div><a class="notion-hash-link" href="#dfa159ed92984eb8be405c9989c5ae88" title="第三十八讲 小说的真实性"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第三十八讲 小说的真实性</b></span></span></h3><div class="notion-text notion-block-caef78ee61cc4232ac1de754bb7a0654">2021-05-03 12:58:16</div><div class="notion-text notion-block-802c4ce735e34f41a920b1069cb0a8c1">小说只不过不是对于某人某事的记录而已；从它对于人生的社会的表现和描摹看来，那是真实的，而且比较对于某人某事的记录还要真实，因为它的材料不限于某人某事，可以容纳更多的真情真理的缘故。</div><div class="notion-text notion-block-44a1015a723544d485fdd5f74d94d1d3">注 | 小说的真实性</div><div class="notion-blank notion-block-94da8296a9604c598ecc9e5e675a739c"> </div><div class="notion-text notion-block-34884865a45a4212a1c8119a8b0063a9">2021-05-03 12:59:23</div><div class="notion-text notion-block-4651d852d5ec49dbb7aee6e592d69c84">小说是由作者创造出来的，决非依据事实写述的记叙文；可是小说是真实的，这真实系指对于人生和社会的表现和描摹而言。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-c71285e9173944a792d1f09accb66635" data-id="c71285e9173944a792d1f09accb66635"><span><div id="c71285e9173944a792d1f09accb66635" class="notion-header-anchor"></div><a class="notion-hash-link" href="#c71285e9173944a792d1f09accb66635" title="第三十九讲 韵文和散文"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第三十九讲 韵文和散文</b></span></span></h3><div class="notion-text notion-block-87c28f2ce73141e49efb66c369a5a138">2021-05-03 13:03:28</div><div class="notion-text notion-block-bc867c2873d046ef9f2f8029083b8bf6">凡是韵母相同的就叫作同韵字。例如楼（lóu）、州（zhōu）、流（liú）的韵母是“ou”和韵母“iu”，这三个就是同韵字，山（shān）、闲（xián）、间（jiàn）的韵母是“an”和韵母“ian”，这三个也是同韵字。把同韵字放在相当各句的末了，这就叫作叶韵。</div><div class="notion-blank notion-block-4b3e6d866a2345e4b50461a0fe357c9e"> </div><div class="notion-text notion-block-d412e4cb47cf4a0e899f37b2f6411f7a">2021-05-03 13:09:20</div><div class="notion-text notion-block-3b0094fd540847708c50abac998beb90">词也起于唐朝，原来是有曲谱可以歌唱的歌曲。譬如《虞美人》就是当初有人写了歌辞、填了曲谱预备歌唱的新歌。第二个人另写歌辞，曲谱却还用着旧的，也就叫作《虞美人》。所以“虞美人”“浪淘沙”“清平乐”“相见欢”都不是题目而是曲谱的名称。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-80513dd57f5244cbaaca788abdf43a97" data-id="80513dd57f5244cbaaca788abdf43a97"><span><div id="80513dd57f5244cbaaca788abdf43a97" class="notion-header-anchor"></div><a class="notion-hash-link" href="#80513dd57f5244cbaaca788abdf43a97" title="第四十讲 诗的本质"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第四十讲 诗的本质</b></span></span></h3><div class="notion-text notion-block-e461dc34fec44fb689c119edbd16e71a">2021-05-03 13:16:30</div><div class="notion-text notion-block-4372fac02fc444d3aad0007c7cdc8a5c">所以，诗的成立不专在叶韵、字数、平仄等形式方面，还靠着它的本质。</div><div class="notion-text notion-block-100b2e1d7b174d1d8763cdabe2bc7c75">注 | 可以知道含有情绪、情操、想象的语言、文字就含有诗的本质</div><div class="notion-blank notion-block-9fc508357c204f4ea713c16b7e725e61"> </div><div class="notion-text notion-block-5ba7f09cc67e42f4a1b42b9d02b5ac44">2021-05-03 13:16:12</div><div class="notion-text notion-block-4bbe9b9108cd4016b98bfaa3c4010920">可以知道含有情绪、情操、想象的语言、文字就含有诗的本质。</div><div class="notion-blank notion-block-28f8c7139e874a08888a5f4a963498b7"> </div><div class="notion-text notion-block-ec92c6d6c2d54e18b3c171474fd867ff">2021-05-03 13:20:21</div><div class="notion-text notion-block-bad019cdf0a84959a028ed8bdc56981e">必须是一个含有诗的本质的意思，用精粹的语言表达出来，那才是“诗”。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1e3966ffe8be44ae98df25a67a3b5d18" data-id="1e3966ffe8be44ae98df25a67a3b5d18"><span><div id="1e3966ffe8be44ae98df25a67a3b5d18" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1e3966ffe8be44ae98df25a67a3b5d18" title="第四十一讲 暗示"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>第四十一讲 暗示</b></span></span></h3><div class="notion-text notion-block-d831d8b8a3964f589d48707380ff0baf">2021-05-03 13:34:46</div><div class="notion-text notion-block-705b1857be134b6493d2cb8fade90ef4">我们说话、作文，常常有不把意思说尽、不把意思完全说明白的情形。在说着、写着的当儿，固然只求应合当前的情境，适可而止，并非故意要少说一些，可是仔细研究起来，不说尽和不完全说明白自有它的作用。这二者都给对方留着自己去玩味、自己去发见的余地，不致有损他的自负心。而他所玩味出来、发见出来的又和原意差不了什么，那就不说尽等于说尽，不说明白等于说明白了。这种作用叫作暗示。</div><div class="notion-blank notion-block-81b760cbb66d4eb58b3280d232605a71"> </div><div class="notion-text notion-block-b4e44eaf1c764070afa41203faf5cd8b">2021-05-03 13:34:16</div><div class="notion-text notion-block-078ea635e261476b826d466a6ec1393e">暗示还有一种好处：可以使语言、文章蕴蓄丰富，含有余味。</div><div class="notion-blank notion-block-6772dd1ce3d941f3be54a78c4bbf2b26"> </div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MoliAI]]></title>
            <link>https://blog.gusibi.mobi/article/moli-palm</link>
            <guid>https://blog.gusibi.mobi/article/moli-palm</guid>
            <pubDate>Thu, 15 Jun 2023 00:00:00 GMT</pubDate>
            <description><![CDATA[MoliAI - 基于Flutter的Google Palm AI聊天与日记助手]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-b67650029d5d4a58b1100406d65d7177"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-callout notion-gray_background_co notion-block-374d6edb17154b75a706ba7d20cbb85d"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="😀">😀</span></div><div class="notion-callout-text">MoliAI - 基于Flutter的Google Palm AI聊天与日记助手</div></div><div class="notion-blank notion-block-d05bd3df76ed44ed88de745e64ba08e3"> </div><div class="notion-text notion-brown notion-block-9b92a519470b4886ad80eecce460cc87">项目地址 <a target="_blank" rel="noopener noreferrer" href="https://github.com/gusibi/moli_ai_box" class="notion-external notion-external-mention"><div class="notion-external-image"><svg viewBox="0 0 260 260"><g><path d="M128.00106,0 C57.3172926,0 0,57.3066942 0,128.00106 C0,184.555281 36.6761997,232.535542 87.534937,249.460899 C93.9320223,250.645779 96.280588,246.684165 96.280588,243.303333 C96.280588,240.251045 96.1618878,230.167899 96.106777,219.472176 C60.4967585,227.215235 52.9826207,204.369712 52.9826207,204.369712 C47.1599584,189.574598 38.770408,185.640538 38.770408,185.640538 C27.1568785,177.696113 39.6458206,177.859325 39.6458206,177.859325 C52.4993419,178.762293 59.267365,191.04987 59.267365,191.04987 C70.6837675,210.618423 89.2115753,204.961093 96.5158685,201.690482 C97.6647155,193.417512 100.981959,187.77078 104.642583,184.574357 C76.211799,181.33766 46.324819,170.362144 46.324819,121.315702 C46.324819,107.340889 51.3250588,95.9223682 59.5132437,86.9583937 C58.1842268,83.7344152 53.8029229,70.715562 60.7532354,53.0843636 C60.7532354,53.0843636 71.5019501,49.6441813 95.9626412,66.2049595 C106.172967,63.368876 117.123047,61.9465949 128.00106,61.8978432 C138.879073,61.9465949 149.837632,63.368876 160.067033,66.2049595 C184.49805,49.6441813 195.231926,53.0843636 195.231926,53.0843636 C202.199197,70.715562 197.815773,83.7344152 196.486756,86.9583937 C204.694018,95.9223682 209.660343,107.340889 209.660343,121.315702 C209.660343,170.478725 179.716133,181.303747 151.213281,184.472614 C155.80443,188.444828 159.895342,196.234518 159.895342,208.176593 C159.895342,225.303317 159.746968,239.087361 159.746968,243.303333 C159.746968,246.709601 162.05102,250.70089 168.53925,249.443941 C219.370432,232.499507 256,184.536204 256,128.00106 C256,57.3066942 198.691187,0 128.00106,0 Z M47.9405593,182.340212 C47.6586465,182.976105 46.6581745,183.166873 45.7467277,182.730227 C44.8183235,182.312656 44.2968914,181.445722 44.5978808,180.80771 C44.8734344,180.152739 45.876026,179.97045 46.8023103,180.409216 C47.7328342,180.826786 48.2627451,181.702199 47.9405593,182.340212 Z M54.2367892,187.958254 C53.6263318,188.524199 52.4329723,188.261363 51.6232682,187.366874 C50.7860088,186.474504 50.6291553,185.281144 51.2480912,184.70672 C51.8776254,184.140775 53.0349512,184.405731 53.8743302,185.298101 C54.7115892,186.201069 54.8748019,187.38595 54.2367892,187.958254 Z M58.5562413,195.146347 C57.7719732,195.691096 56.4895886,195.180261 55.6968417,194.042013 C54.9125733,192.903764 54.9125733,191.538713 55.713799,190.991845 C56.5086651,190.444977 57.7719732,190.936735 58.5753181,192.066505 C59.3574669,193.22383 59.3574669,194.58888 58.5562413,195.146347 Z M65.8613592,203.471174 C65.1597571,204.244846 63.6654083,204.03712 62.5716717,202.981538 C61.4524999,201.94927 61.1409122,200.484596 61.8446341,199.710926 C62.5547146,198.935137 64.0575422,199.15346 65.1597571,200.200564 C66.2704506,201.230712 66.6095936,202.705984 65.8613592,203.471174 Z M75.3025151,206.281542 C74.9930474,207.284134 73.553809,207.739857 72.1039724,207.313809 C70.6562556,206.875043 69.7087748,205.700761 70.0012857,204.687571 C70.302275,203.678621 71.7478721,203.20382 73.2083069,203.659543 C74.6539041,204.09619 75.6035048,205.261994 75.3025151,206.281542 Z M86.046947,207.473627 C86.0829806,208.529209 84.8535871,209.404622 83.3316829,209.4237 C81.8013,209.457614 80.563428,208.603398 80.5464708,207.564772 C80.5464708,206.498591 81.7483088,205.631657 83.2786917,205.606221 C84.8005962,205.576546 86.046947,206.424403 86.046947,207.473627 Z M96.6021471,207.069023 C96.7844366,208.099171 95.7267341,209.156872 94.215428,209.438785 C92.7295577,209.710099 91.3539086,209.074206 91.1652603,208.052538 C90.9808515,206.996955 92.0576306,205.939253 93.5413813,205.66582 C95.054807,205.402984 96.4092596,206.021919 96.6021471,207.069023 Z" fill="#161614"></path></g></svg></div><div class="notion-external-description"><div class="notion-external-title">moli_ai</div><div class="notion-external-subtitle"><span>gusibi</span><span> • </span><span>Updated <!-- -->Jul 23, 2023</span></div></div></a></div><div class="notion-blank notion-block-f4082e03828c473095f3e386b6c9ee35"> </div><div class="notion-text notion-block-279039592d11455e86354d374651a2b3">随着人工智能技术的不断发展,聊天机器人已经成为许多App和网站的标准功能。最近我利用业余时间用Flutter开发了一个名字叫MoliAI的Google Palm聊天机器人App,它不仅可以与Google Palm进行自然语言交流,还具有日记小助手的功能,可以智能分析日记内容并提供建议。今天就给大家简单介绍一下这个小项目。</div><div class="notion-text notion-block-021b598141e0468c85bc9410cf4b20da">MoliAI的主界面非常简洁,主要是一个聊天窗口,可以直接与Google Palm对话。聊天内容会保存在本地数据库中,你可以随时回顾历史对话。另外还有一个日记页面,这里可以记录你的所见所想,MoliAI会根据文本内容自动生成一个总结,并给出一些智能化的建议或待办事项,帮助规划生活。</div><div class="notion-text notion-block-ebef76c232d34f5080c58b5e5e354078">这个项目主要使用了Flutter框架开发,采用了flex_color_scheme主题库实现夜间模式,用flutter_markdown渲染文字格式。数据存储在本地的SQLite数据库中。话不多说,直接上几张主界面截图。</div><div class="notion-text notion-block-8f4cded792d842c0b974c07633af6a1f">目前MoliAI只集成了Google Palm一个聊天机器人,后续计划接入更多知名的AI平台,打造成一个统一的多AI聊天平台。项目代码开源在GitHub上,欢迎大家Star支持,也非常欢迎提交Issue进行功能建议和代码贡献!</div><div class="notion-blank notion-block-0be7cedf7c504de7b40a7986466ad817"> </div><div class="notion-blank notion-block-616b20f7b7114e92b29eef4890411aa1"> </div><div class="notion-text notion-block-a18dcfd44e2b4c26b46352a9abf5ffff">支持的模型</div><blockquote class="notion-quote notion-block-365e0eece21e418db4c74fedc8580530"><div>The PaLM API offers different models optimized for specific use cases. The following table describes attributes of each.</div></blockquote><table class="notion-simple-table notion-block-6016d1abd99147bb98d288d6c3992e7c"><tbody><tr class="notion-simple-table-row notion-block-b676065323e14675876b69f0ef10d76c"><td class="" style="width:120px"><div class="notion-simple-table-cell">Variation</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Attribute</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Description</div></td></tr><tr class="notion-simple-table-row notion-block-15e551a8ba274fb6a14b29bce784a82d"><td class="" style="width:120px"><div class="notion-simple-table-cell">text-bison-001</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Model last updated</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">May 2023</div></td></tr><tr class="notion-simple-table-row notion-block-33759abd2136485fa78ca16cdaa2e532"><td class="" style="width:120px"><div class="notion-simple-table-cell">ㅤ</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Model size</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Bison</div></td></tr><tr class="notion-simple-table-row notion-block-516ca6e25a4f4b86a360fbd37e7f4c43"><td class="" style="width:120px"><div class="notion-simple-table-cell">ㅤ</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Model capabilities</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">• Generates text.
• Optimized for language tasks such as:
    ◦ Code generation
    ◦ Text generation
    ◦ Text editing
    ◦ Problem solving
    ◦ Recommendations generation
    ◦ Information extraction
    ◦ Data extraction or generation
    ◦ AI agent
• Can handle zero, one, and few-shot tasks.</div></td></tr><tr class="notion-simple-table-row notion-block-c5b04b777cdd433e94a9657e36d42475"><td class="" style="width:120px"><div class="notion-simple-table-cell">ㅤ</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Model safety</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Adjustable safety settings for 6 dimensions of harm available to developers. See the <a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://developers.generativeai.google/guide/safety_setting">safety settings</a> topic for details.</div></td></tr><tr class="notion-simple-table-row notion-block-8fd2fe2ac7fb42c8bdfa76f018b95391"><td class="" style="width:120px"><div class="notion-simple-table-cell">ㅤ</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Rate limit during preview</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">30 requests per minute</div></td></tr><tr class="notion-simple-table-row notion-block-f4d981a8cc214215bb36ab3109123168"><td class="" style="width:120px"><div class="notion-simple-table-cell">chat-bison-001</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Model last updated</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">May 2023</div></td></tr><tr class="notion-simple-table-row notion-block-982675ab5f8040c4886c7c661f321c48"><td class="" style="width:120px"><div class="notion-simple-table-cell">ㅤ</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Model size</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Bison</div></td></tr><tr class="notion-simple-table-row notion-block-0f165f67dc0a4d2299c0986c87a73dd5"><td class="" style="width:120px"><div class="notion-simple-table-cell">ㅤ</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Model capabilities</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">• Generates text in a conversational format.
• Optimized for dialog language tasks such as implementation of chat bots or AI agents.
• Can handle zero, one, and few-shot tasks.</div></td></tr><tr class="notion-simple-table-row notion-block-172bac8501d741b9b5e73dca7f7fa0fa"><td class="" style="width:120px"><div class="notion-simple-table-cell">ㅤ</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Model safety</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">No adjustable safety settings.</div></td></tr><tr class="notion-simple-table-row notion-block-b67afdee70624e2cbc0ebfd06ece9a43"><td class="" style="width:120px"><div class="notion-simple-table-cell">ㅤ</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Rate limit during preview</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">30 requests per minute</div></td></tr></tbody></table><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-f2d9edee73b041b2b8e986b3de168472" data-id="f2d9edee73b041b2b8e986b3de168472"><span><div id="f2d9edee73b041b2b8e986b3de168472" class="notion-header-anchor"></div><a class="notion-hash-link" href="#f2d9edee73b041b2b8e986b3de168472" title="📎 参考教程"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">📎 参考教程</span></span></h2><div class="notion-blank notion-block-100f263e0f0642ab95dc445b884c7ffc"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-video notion-block-785816d1559444e2abc396b561017382"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;padding-bottom:56.25%"><link rel="preload" href="https://i.ytimg.com/vi/BB59SwaQjrQ/hqdefault.jpg" as="image"/><div class="notion-yt-lite notion-asset-object-fit" style="object-fit:contain"><img src="https://i.ytimg.com/vi/BB59SwaQjrQ/hqdefault.jpg" class="notion-yt-thumbnail" alt="Video preview"/><div class="notion-yt-playbtn"></div></div></div></figure><div class="notion-blank notion-block-14186752dc1d4481b58345bc5d1e0fb8"> </div><div class="notion-blank notion-block-311616e2ffee4ea98416c39085977190"> </div><div class="notion-callout notion-gray_background_co notion-block-bca3470cc32a42ffbfe34a4897721460"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="💡">💡</span></div><div class="notion-callout-text">如果你有任何使用上的问题或对功能的建议，欢迎与我交流。<div class="notion-text notion-block-4e0d023bbb084d14b598c27c63297d77">除此之外，如果你对这个项目感兴趣，也欢迎你为其贡献代码。</div></div></div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[使用腾讯云 serverless 部署语雀飞书机器人]]></title>
            <link>https://blog.gusibi.mobi/article/example-6</link>
            <guid>https://blog.gusibi.mobi/article/example-6</guid>
            <pubDate>Sun, 22 Aug 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[使用腾讯云 serverless 部署语雀飞书机器人]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-8602da84de4944ed8ad69d1b0ce37334"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-callout notion-gray_background_co notion-block-4609514ebdbe47b18782cb10b8b5f6c4"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="💡">💡</span></div><div class="notion-callout-text">腾讯云函数可能收费，需要关注</div></div><div class="notion-blank notion-block-6e9cf148515c48b588156469b2c97811"> </div><blockquote class="notion-quote notion-block-c50fe5dfbadc4d009b2bad900081c2ff"><div>1. <!-- -->语雀很好用，但是没有App，无法通知<!-- -->
2. <!-- -->飞书群自定义机器人很方便，但是不知道用来干啥<!-- -->
3. <!-- -->腾讯云函数计算有免费额度，是不是可以利用一下？<!-- -->
4. <!-- -->那是不是可以把语雀的webhook 使用飞书通知，部署在腾讯云上呢？<!-- -->
5. <!-- -->好主意</div></blockquote><div class="notion-blank notion-block-2c1352fb2dd44e80abb9e95029a58951"> </div><div class="notion-text notion-block-f8866c882e504760b5f00ed8f5b2ea7d">代码地址：</div><a target="_blank" rel="noopener noreferrer" href="https://github.com/gusibi/yuque_webhook" class="notion-external notion-external-block notion-row notion-block-40303019e37e42e4a0f29b4275b4ac23"><div class="notion-external-image"><svg viewBox="0 0 260 260"><g><path d="M128.00106,0 C57.3172926,0 0,57.3066942 0,128.00106 C0,184.555281 36.6761997,232.535542 87.534937,249.460899 C93.9320223,250.645779 96.280588,246.684165 96.280588,243.303333 C96.280588,240.251045 96.1618878,230.167899 96.106777,219.472176 C60.4967585,227.215235 52.9826207,204.369712 52.9826207,204.369712 C47.1599584,189.574598 38.770408,185.640538 38.770408,185.640538 C27.1568785,177.696113 39.6458206,177.859325 39.6458206,177.859325 C52.4993419,178.762293 59.267365,191.04987 59.267365,191.04987 C70.6837675,210.618423 89.2115753,204.961093 96.5158685,201.690482 C97.6647155,193.417512 100.981959,187.77078 104.642583,184.574357 C76.211799,181.33766 46.324819,170.362144 46.324819,121.315702 C46.324819,107.340889 51.3250588,95.9223682 59.5132437,86.9583937 C58.1842268,83.7344152 53.8029229,70.715562 60.7532354,53.0843636 C60.7532354,53.0843636 71.5019501,49.6441813 95.9626412,66.2049595 C106.172967,63.368876 117.123047,61.9465949 128.00106,61.8978432 C138.879073,61.9465949 149.837632,63.368876 160.067033,66.2049595 C184.49805,49.6441813 195.231926,53.0843636 195.231926,53.0843636 C202.199197,70.715562 197.815773,83.7344152 196.486756,86.9583937 C204.694018,95.9223682 209.660343,107.340889 209.660343,121.315702 C209.660343,170.478725 179.716133,181.303747 151.213281,184.472614 C155.80443,188.444828 159.895342,196.234518 159.895342,208.176593 C159.895342,225.303317 159.746968,239.087361 159.746968,243.303333 C159.746968,246.709601 162.05102,250.70089 168.53925,249.443941 C219.370432,232.499507 256,184.536204 256,128.00106 C256,57.3066942 198.691187,0 128.00106,0 Z M47.9405593,182.340212 C47.6586465,182.976105 46.6581745,183.166873 45.7467277,182.730227 C44.8183235,182.312656 44.2968914,181.445722 44.5978808,180.80771 C44.8734344,180.152739 45.876026,179.97045 46.8023103,180.409216 C47.7328342,180.826786 48.2627451,181.702199 47.9405593,182.340212 Z M54.2367892,187.958254 C53.6263318,188.524199 52.4329723,188.261363 51.6232682,187.366874 C50.7860088,186.474504 50.6291553,185.281144 51.2480912,184.70672 C51.8776254,184.140775 53.0349512,184.405731 53.8743302,185.298101 C54.7115892,186.201069 54.8748019,187.38595 54.2367892,187.958254 Z M58.5562413,195.146347 C57.7719732,195.691096 56.4895886,195.180261 55.6968417,194.042013 C54.9125733,192.903764 54.9125733,191.538713 55.713799,190.991845 C56.5086651,190.444977 57.7719732,190.936735 58.5753181,192.066505 C59.3574669,193.22383 59.3574669,194.58888 58.5562413,195.146347 Z M65.8613592,203.471174 C65.1597571,204.244846 63.6654083,204.03712 62.5716717,202.981538 C61.4524999,201.94927 61.1409122,200.484596 61.8446341,199.710926 C62.5547146,198.935137 64.0575422,199.15346 65.1597571,200.200564 C66.2704506,201.230712 66.6095936,202.705984 65.8613592,203.471174 Z M75.3025151,206.281542 C74.9930474,207.284134 73.553809,207.739857 72.1039724,207.313809 C70.6562556,206.875043 69.7087748,205.700761 70.0012857,204.687571 C70.302275,203.678621 71.7478721,203.20382 73.2083069,203.659543 C74.6539041,204.09619 75.6035048,205.261994 75.3025151,206.281542 Z M86.046947,207.473627 C86.0829806,208.529209 84.8535871,209.404622 83.3316829,209.4237 C81.8013,209.457614 80.563428,208.603398 80.5464708,207.564772 C80.5464708,206.498591 81.7483088,205.631657 83.2786917,205.606221 C84.8005962,205.576546 86.046947,206.424403 86.046947,207.473627 Z M96.6021471,207.069023 C96.7844366,208.099171 95.7267341,209.156872 94.215428,209.438785 C92.7295577,209.710099 91.3539086,209.074206 91.1652603,208.052538 C90.9808515,206.996955 92.0576306,205.939253 93.5413813,205.66582 C95.054807,205.402984 96.4092596,206.021919 96.6021471,207.069023 Z" fill="#161614"></path></g></svg></div><div class="notion-external-description"><div class="notion-external-title">yuque_webhook</div><div class="notion-external-subtitle"><span>gusibi</span><span> • </span><span>Updated <!-- -->Dec 5, 2022</span></div></div></a><h4 class="notion-h notion-h3 notion-h-indent-0 notion-block-3a5ac2b865e54048917b1114c8cbd167" data-id="3a5ac2b865e54048917b1114c8cbd167"><span><div id="3a5ac2b865e54048917b1114c8cbd167" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3a5ac2b865e54048917b1114c8cbd167" title="视频版教程"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">视频版教程</span></span></h4><div class="notion-blank notion-block-addf7a31df934c9b866201eb059ac874"> </div><div class="notion-text notion-block-989ae813e0e041e68d68ed304997ac15"><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://cloud.tencent.com/developer/video/23558">https://cloud.tencent.com/developer/video/23558</a></div><h4 class="notion-h notion-h3 notion-h-indent-0 notion-block-3d0bb858c56f4bc9a61b96f3616df076" data-id="3d0bb858c56f4bc9a61b96f3616df076"><span><div id="3d0bb858c56f4bc9a61b96f3616df076" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3d0bb858c56f4bc9a61b96f3616df076" title="使用方式"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">使用方式</span></span></h4><ol start="1" class="notion-list notion-list-numbered notion-block-a105fe3dafad419ba039cbd5d44b5f92"><li>在飞书群中添加自定义机器人，复制webhook 地址，拿到其中的 hook_id</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-2939ca0e69504d1ca1d15432524c8fa4"><li>执行代码build 中 scf_build.sh 脚本，得到 api.zip 包</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-1711315d1f2b42619777408a8979ada9"><li>在腾讯云云函数中创建云函数，</li><ol class="notion-list notion-list-numbered notion-block-1711315d1f2b42619777408a8979ada9"><ul class="notion-list notion-list-disc notion-block-909d8df8f6e844f9956836f7c1cc09c6"><li>选择golang</li></ul><ul class="notion-list notion-list-disc notion-block-9e9b34c19ccd42ab813dd87bda425894"><li>选择本地zip 包</li></ul><ul class="notion-list notion-list-disc notion-block-b85f01045c01421ba5434bdf811b749a"><li>选择上一步生成的 api.zip</li></ul><ul class="notion-list notion-list-disc notion-block-a50140266cf541d7adfe14edd93774ea"><li>超时时间为3S</li></ul><ul class="notion-list notion-list-disc notion-block-85a9195d771b41b5a900f3d0363934ee"><li>创建云函数</li></ul></ol></ol><ol start="4" class="notion-list notion-list-numbered notion-block-4e78609db73349f8af7416efaf80f9cf"><li>新建API网关服务</li><ol class="notion-list notion-list-numbered notion-block-4e78609db73349f8af7416efaf80f9cf"><ul class="notion-list notion-list-disc notion-block-080ad148d00846b8b628b3dc2ea45b49"><li>新建API</li></ul><ul class="notion-list notion-list-disc notion-block-0f08fea9b16e43649e1fef93f81b6b00"><li>路径为 /api/lark_webhook</li></ul><ul class="notion-list notion-list-disc notion-block-6022819191db481d9aeaf936e2060eb8"><li>请求方法为POST</li></ul><ul class="notion-list notion-list-disc notion-block-bd93266f084b418a83519fbdb5f7b00f"><li>免鉴权</li></ul><ul class="notion-list notion-list-disc notion-block-edc55fc10f35463497d2bcb35fda6a92"><li>后端配置，后端类型为云函数SCF</li></ul><ul class="notion-list notion-list-disc notion-block-c4cfe1d470024e0e8229249c2dcd6819"><li>选择上一步创建的云函数</li></ul><ul class="notion-list notion-list-disc notion-block-689fd3d0aff14b6ea01a8488f2331631"><li>超时时间为3S</li></ul><ul class="notion-list notion-list-disc notion-block-b117ad5d45c0485ba8ec8a655eb88f87"><li>启用响应集成</li></ul><ul class="notion-list notion-list-disc notion-block-85d377c0416f44f6b2a54d400be1a667"><li>响应结果返回类型为JSON</li></ul><ul class="notion-list notion-list-disc notion-block-b64c588df2964ffd912ff14333216293"><li>完成选择发布</li></ul><ul class="notion-list notion-list-disc notion-block-481696fc65d242f79712f5f4e14e93e8"><li>从网关基础配置中拿到公网访问地址，host</li></ul></ol></ol><ol start="5" class="notion-list notion-list-numbered notion-block-ac9f824d472a462fbd979152683b140f"><li>打开想要添加webhook的语雀知识库</li><ol class="notion-list notion-list-numbered notion-block-ac9f824d472a462fbd979152683b140f"><ul class="notion-list notion-list-disc notion-block-95cd25cdaf3b495fb9bad68c55c5f65b"><li>知识库设置，开发者，添加webhook，命名为飞书机器人</li></ul><ul class="notion-list notion-list-disc notion-block-5ff1ffcd503a46e48a69a0e303c334c1"><li>URL为 host/api/webhook（这里host 为上一步得到的host</li></ul></ol></ol></main></div>]]></content:encoded>
        </item>
    </channel>
</rss>