-
Notifications
You must be signed in to change notification settings - Fork 0
/
6e201f64d36b.html
460 lines (347 loc) · 24.6 KB
/
6e201f64d36b.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222" media="(prefers-color-scheme: light)">
<meta name="theme-color" content="#222" media="(prefers-color-scheme: dark)"><meta name="generator" content="Hexo 7.3.0">
<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon.ico">
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon.ico">
<link rel="stylesheet" href="/css/main.css">
<link rel="stylesheet" href="https://fastly.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.5.2/css/all.min.css" integrity="sha256-XOqroi11tY4EFQMR9ZYwZWKj5ZXiftSx36RRuC3anlA=" crossorigin="anonymous">
<link rel="stylesheet" href="https://fastly.jsdelivr.net/npm/animate.css@3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
<link rel="stylesheet" href="https://fastly.jsdelivr.net/npm/@fancyapps/ui@5.0.31/dist/fancybox/fancybox.css" integrity="sha256-gkQVf8UKZgQ0HyuxL/VnacadJ+D2Kox2TCEBuNQg5+w=" crossorigin="anonymous">
<script class="next-config" data-name="main" type="application/json">{"hostname":"prohibitorum.top","root":"/","images":"/images","scheme":"Gemini","darkmode":true,"version":"8.20.0","exturl":false,"sidebar":{"position":"left","width_expanded":320,"width_dual_column":240,"display":"post","padding":18,"offset":12},"copycode":{"enable":true,"style":"flat"},"fold":{"enable":false,"height":500},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":true,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":false,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果:${query}","hits_time":"找到 ${hits} 个搜索结果(用时 ${time} 毫秒)","hits":"找到 ${hits} 个搜索结果"},"algolia":{"appID":"T3MJ56EZKX","apiKey":"d231b9edc85683ea50e37ff0bdc95d43","indexName":"blog","hits":{"per_page":10}}}</script><script src="/js/config.js"></script>
<meta name="description" content="手写Promise笔记">
<meta property="og:type" content="article">
<meta property="og:title" content="手写Promise笔记">
<meta property="og:url" content="https://prohibitorum.top/6e201f64d36b">
<meta property="og:site_name" content="恋の歌">
<meta property="og:description" content="手写Promise笔记">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2020-06-12T10:34:51.000Z">
<meta property="article:modified_time" content="2023-02-13T18:28:45.000Z">
<meta property="article:author" content="Dedicatus545">
<meta property="article:tag" content="JavaScript">
<meta property="article:tag" content="Promise">
<meta name="twitter:card" content="summary">
<link rel="canonical" href="https://prohibitorum.top/6e201f64d36b.html">
<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"https://prohibitorum.top/6e201f64d36b","path":"6e201f64d36b.html","title":"手写Promise笔记"}</script>
<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>手写Promise笔记 | 恋の歌</title>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-TDBJV1DQ49"></script>
<script class="next-config" data-name="google_analytics" type="application/json">{"tracking_id":"G-TDBJV1DQ49","only_pageview":false,"measure_protocol_api_secret":null}</script>
<script src="/js/third-party/analytics/google-analytics.js"></script>
<noscript>
<link rel="stylesheet" href="/css/noscript.css">
</noscript>
</head>
<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
<div class="headband"></div>
<main class="main">
<div class="column">
<header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
<div class="site-nav-toggle">
<div class="toggle" aria-label="切换导航栏" role="button">
</div>
</div>
<div class="site-meta">
<a href="/" class="brand" rel="start">
<i class="logo-line"></i>
<p class="site-title">恋の歌</p>
<i class="logo-line"></i>
</a>
<p class="site-subtitle" itemprop="description">koi-no-uta</p>
</div>
<div class="site-nav-right">
<div class="toggle popup-trigger" aria-label="搜索" role="button">
<i class="fa fa-search fa-fw fa-lg"></i>
</div>
</div>
</div>
<nav class="site-nav">
<ul class="main-menu menu">
<li class="menu-item menu-item-search">
<a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
</a>
</li>
</ul>
</nav>
<div class="search-pop-overlay">
<div class="popup search-popup"><div class="search-header">
<span class="search-icon">
<i class="fa fa-search"></i>
</span>
<div class="search-input-container"></div>
<span class="popup-btn-close" role="button">
<i class="fa fa-times-circle"></i>
</span>
</div>
<div class="search-result-container">
<div class="algolia-stats"><hr></div>
<div class="algolia-hits"></div>
<div class="algolia-pagination"></div>
</div>
</div>
</div>
</header>
<aside class="sidebar">
<div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
<ul class="sidebar-nav">
<li class="sidebar-nav-toc">
文章目录
</li>
<li class="sidebar-nav-overview">
站点概览
</li>
</ul>
<div class="sidebar-panel-container">
<!--noindex-->
<div class="post-toc-wrap sidebar-panel">
<div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#Promise"><span class="nav-number">1.</span> <span class="nav-text">Promise</span></a></li></ol></div>
</div>
<!--/noindex-->
<div class="site-overview-wrap sidebar-panel">
<div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
<img class="site-author-image" itemprop="image" alt="Dedicatus545"
src="https://avatars.githubusercontent.com/u/48575405?v=4">
<p class="site-author-name" itemprop="name">Dedicatus545</p>
<div class="site-description" itemprop="description">Index-Librorum-Prohibitorum</div>
</div>
<div class="site-state-wrap animated">
<nav class="site-state">
<div class="site-state-item site-state-posts">
<a href="/archives/">
<span class="site-state-item-count">173</span>
<span class="site-state-item-name">日志</span>
</a>
</div>
<div class="site-state-item site-state-categories">
<a href="/categories/">
<span class="site-state-item-count">9</span>
<span class="site-state-item-name">分类</span></a>
</div>
<div class="site-state-item site-state-tags">
<a href="/tags/">
<span class="site-state-item-count">141</span>
<span class="site-state-item-name">标签</span></a>
</div>
</nav>
</div>
<div class="links-of-author animated">
<span class="links-of-author-item">
<a href="https://github.com/Dedicatus546" title="GitHub → https://github.com/Dedicatus546" rel="noopener me" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
</span>
<span class="links-of-author-item">
<a href="mailto:1607611087@qq.com" title="E-Mail → mailto:1607611087@qq.com" rel="noopener me" target="_blank"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
</span>
</div>
<div class="cc-license animated" itemprop="license">
<a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh-hans" class="cc-opacity" rel="noopener" target="_blank"><img src="https://fastly.jsdelivr.net/npm/@creativecommons/vocabulary@2020.11.3/assets/license_badges/small/by_nc_sa.svg" alt="Creative Commons"></a>
</div>
</div>
</div>
</div>
</aside>
</div>
<div class="main-inner post posts-expand">
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
<link itemprop="mainEntityOfPage" href="https://prohibitorum.top/6e201f64d36b">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="https://avatars.githubusercontent.com/u/48575405?v=4">
<meta itemprop="name" content="Dedicatus545">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="恋の歌">
<meta itemprop="description" content="Index-Librorum-Prohibitorum">
</span>
<span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
<meta itemprop="name" content="手写Promise笔记 | 恋の歌">
<meta itemprop="description" content="">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
手写Promise笔记
</h1>
<div class="post-meta-container">
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2020-06-12 10:34:51" itemprop="dateCreated datePublished" datetime="2020-06-12T10:34:51+00:00">2020-06-12</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2023-02-13 18:28:45" itemprop="dateModified" datetime="2023-02-13T18:28:45+00:00">2023-02-13</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-folder"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/%E7%BC%96%E7%A8%8B/" itemprop="url" rel="index"><span itemprop="name">编程</span></a>
</span>
</span>
<span class="post-meta-break"></span>
<span class="post-meta-item" title="本文字数">
<span class="post-meta-item-icon">
<i class="far fa-file-word"></i>
</span>
<span class="post-meta-item-text">本文字数:</span>
<span>589</span>
</span>
<span class="post-meta-item" title="阅读时长">
<span class="post-meta-item-icon">
<i class="far fa-clock"></i>
</span>
<span class="post-meta-item-text">阅读时长 ≈</span>
<span>2 分钟</span>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody"><p>手写<code>Promise</code>笔记</p>
<span id="more"></span>
<p>掘金上看见一个<code>20</code>行的<code>Promise</code>实现,主要是链式调用,感觉很不错,学习学习。</p>
<p>原文出处:<a target="_blank" rel="noopener" href="https://juejin.im/post/5e6f4579f265da576429a907">最简实现Promise,支持异步链式调用(20行)</a></p>
<h1 id="Promise"><a href="#Promise" class="headerlink" title="Promise"></a><code>Promise</code></h1><p>直接上代码吧。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// Promise构造函数</span></span><br><span class="line"><span class="keyword">function</span> <span class="title function_">Promise</span>(<span class="params">excutor</span>) {</span><br><span class="line"> <span class="keyword">var</span> self = <span class="variable language_">this</span>;</span><br><span class="line"> self.<span class="property">onResolvedCallback</span> = [];</span><br><span class="line"> <span class="keyword">function</span> <span class="title function_">resolve</span>(<span class="params">value</span>) {</span><br><span class="line"> <span class="built_in">setTimeout</span>(<span class="function">() =></span> {</span><br><span class="line"> self.<span class="property">data</span> = value;</span><br><span class="line"> self.<span class="property">onResolvedCallback</span>.<span class="title function_">forEach</span>(<span class="function"><span class="params">callback</span> =></span> <span class="title function_">callback</span>(value));</span><br><span class="line"> },<span class="number">0</span>);</span><br><span class="line"> }</span><br><span class="line"> <span class="title function_">excutor</span>(resolve.<span class="title function_">bind</span>(self));</span><br><span class="line">}</span><br><span class="line"><span class="comment">// Promise的then调用函数</span></span><br><span class="line"><span class="title class_">Promise</span>.<span class="property"><span class="keyword">prototype</span></span>.<span class="property">then</span> = <span class="keyword">function</span>(<span class="params">onResolved</span>) {</span><br><span class="line"> <span class="keyword">var</span> self = <span class="variable language_">this</span>;</span><br><span class="line"> <span class="keyword">return</span> <span class="keyword">new</span> <span class="title class_">Promise</span>(<span class="function"><span class="params">resolve</span> =></span> {</span><br><span class="line"> self.<span class="property">onResolvedCallback</span>.<span class="title function_">push</span>(<span class="keyword">function</span>(<span class="params"></span>) {</span><br><span class="line"> <span class="keyword">var</span> result = <span class="title function_">onResolved</span>(self.<span class="property">data</span>);</span><br><span class="line"> <span class="keyword">if</span> (result <span class="keyword">instanceof</span> <span class="title class_">Promise</span>) {</span><br><span class="line"> result.<span class="title function_">then</span>(resolve);</span><br><span class="line"> } <span class="keyword">else</span> {</span><br><span class="line"> <span class="title function_">resolve</span>(result);</span><br><span class="line"> }</span><br><span class="line"> });</span><br><span class="line"> })</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>参数<code>excutor</code>为一个函数,这个函数有两个参数。</p>
<p>一个是<code>resolve</code>,一个是<code>reject</code>,这个实现为简单实现,所以没有第二个参数,主要为实现链式调用。</p>
<p><code>Promise</code>构造函数中的<code>onResolvedCallback</code>为一个待调用的函数数组。</p>
<p>当通过<code>then</code>函数注册回调的时候,会把回调函数存在<code>onResolvedCallback</code>数组中。</p>
<p><code>then</code>函数规范中有提到,必须返回一个新的<code>Promise</code>对象,基于这个可以实现链式调用。</p>
<p><code>then</code>如何返回也在规范中有提及,如果回调函数返回了一个<code>Promise</code>,那么<code>then</code>返回的<code>Promise</code>就要使用函数返回的<code>Promise</code>的值(<code>value</code>)。</p>
<p>如果不是函数返回的不是<code>Promise</code>,那么<code>then</code>返回的<code>Promise</code>就直接以这个值来解决。</p>
<p><code>resolve</code>函数是一个完成函数,会把<code>Promise</code>的状态从<code>pending</code>转为<code>resolved</code>,并且调用全部注册的回调。</p>
<p><code>resolve</code>为啥要通过<code>setTimeout</code>调用呢?可以看下面的代码。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> promise = <span class="keyword">new</span> <span class="title class_">Promise</span>(<span class="keyword">function</span>(<span class="params">resolve,reject</span>) {</span><br><span class="line"> <span class="title function_">resolve</span>(<span class="string">'success'</span>);</span><br><span class="line">});</span><br><span class="line"><span class="comment">// 上面的操作就已经调用了数组中的回调</span></span><br><span class="line"><span class="comment">// 下面的注册的回调就会无效了</span></span><br><span class="line">promise.<span class="title function_">then</span>(<span class="function"><span class="params">res</span>=></span>{</span><br><span class="line"> <span class="variable language_">console</span>.<span class="title function_">log</span>(res);</span><br><span class="line">});</span><br></pre></td></tr></table></figure>
<p>我们构建了一个<code>promise</code>,直接的将这个<code>promise</code>解决掉(调用<code>resolve</code>)。</p>
<p><code>resolve</code>会把<code>onResolvedCallback</code>的函数逐一地执行。</p>
<p>注意,这时候的操作都是同步的,也就是这时的<code>then</code>注册回调还没有执行,导致了<code>then</code>方法没有被执行。</p>
<p>使用了<code>setTimeout</code>,使得更改状态以一个新的任务执行,也就是在当前代码执行完之后再执行,使得回调函数可以注册到<code>onResolvedCallback</code>里面。使得<code>then</code>的表现正常。</p>
<p>需要注意,<code>Promise</code>应该是以微任务的形式来进行<code>resolve</code>的,而不是以任务,这个在之前的关于<code>task</code>,<code>microtask</code>的文章中有说到。</p>
</div>
<footer class="post-footer">
<div class="post-copyright">
<ul>
<li class="post-copyright-author">
<strong>本文作者: </strong>Dedicatus545
</li>
<li class="post-copyright-link">
<strong>本文链接:</strong>
<a href="https://prohibitorum.top/6e201f64d36b" title="手写Promise笔记">https://prohibitorum.top/6e201f64d36b</a>
</li>
<li class="post-copyright-license">
<strong>版权声明: </strong>本博客所有文章除特别声明外,均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh-hans" rel="noopener" target="_blank"><i class="fab fa-fw fa-creative-commons"></i>BY-NC-SA</a> 许可协议。转载请注明出处!
</li>
</ul>
</div>
<div class="post-tags">
<a href="/tags/JavaScript/" rel="tag"># JavaScript</a>
<a href="/tags/Promise/" rel="tag"># Promise</a>
</div>
<div class="post-nav">
<div class="post-nav-item">
<a href="/6da281009a11" rel="prev" title="JavaScript中的Tasks, microtasks, queues and schedules(译)">
<i class="fa fa-angle-left"></i> JavaScript中的Tasks, microtasks, queues and schedules(译)
</a>
</div>
<div class="post-nav-item">
<a href="/03b18c8b2974" rel="next" title="手写一个Promise并通过Promise A+规范测试">
手写一个Promise并通过Promise A+规范测试 <i class="fa fa-angle-right"></i>
</a>
</div>
</div>
</footer>
</article>
</div>
<div class="comments gitalk-container"></div>
</div>
</main>
<footer class="footer">
<div class="footer-inner">
<div class="copyright">
©
<span itemprop="copyrightYear">2024</span>
<span class="with-love">
<i class="fa fa-heart"></i>
</span>
<span class="author" itemprop="copyrightHolder">Dedicatus545</span>
</div>
<div class="wordcount">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-chart-line"></i>
</span>
<span>站点总字数:</span>
<span title="站点总字数">393k</span>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="fa fa-coffee"></i>
</span>
<span>站点阅读时长 ≈</span>
<span title="站点阅读时长">23:50</span>
</span>
</div>
<div class="site_sign">
<span class="post-meta-item">
<span>
如果我和狗一样有尾巴的话,一定会藏不住这份喜悦,而尾巴一直摇个不停吧。
</span>
</span>
</div>
</div>
</footer>
<div class="toggle sidebar-toggle" role="button">
<span class="toggle-line"></span>
<span class="toggle-line"></span>
<span class="toggle-line"></span>
</div>
<div class="sidebar-dimmer"></div>
<div class="back-to-top" role="button" aria-label="返回顶部">
<i class="fa fa-arrow-up fa-lg"></i>
<span>0%</span>
</div>
<noscript>
<div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>
<script src="https://fastly.jsdelivr.net/npm/animejs@3.2.1/lib/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
<script src="https://fastly.jsdelivr.net/npm/@fancyapps/ui@5.0.31/dist/fancybox/fancybox.umd.js" integrity="sha256-a+H7FYzJv6oU2hfsfDGM2Ohw/cR9v+hPfxHCLdmCrE8=" crossorigin="anonymous"></script>
<script src="https://fastly.jsdelivr.net/npm/lozad@1.16.0/dist/lozad.min.js" integrity="sha256-mOFREFhqmHeQbXpK2lp4nA3qooVgACfh88fpJftLBbc=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/sidebar.js"></script><script src="/js/next-boot.js"></script>
<script src="https://fastly.jsdelivr.net/npm/algoliasearch@4.23.3/dist/algoliasearch-lite.umd.js" integrity="sha256-1QNshz86RqXe/qsCBldsUu13eAX6n/O98uubKQs87UI=" crossorigin="anonymous"></script>
<script src="https://fastly.jsdelivr.net/npm/instantsearch.js@4.67.0/dist/instantsearch.production.min.js" integrity="sha256-TW7D3X/i/W+RUgEeDppEnFT2ixv5lzplKH0c58D92dY=" crossorigin="anonymous"></script><script src="/js/third-party/search/algolia-search.js"></script>
<script src="/js/third-party/fancybox.js"></script>
<link rel="stylesheet" href="https://fastly.jsdelivr.net/npm/gitalk@1.8.0/dist/gitalk.css" integrity="sha256-AJnUHL7dBv6PGaeyPQJcgQPDjt/Hn/PvYZde1iqfp8U=" crossorigin="anonymous">
<script class="next-config" data-name="gitalk" type="application/json">{"enable":true,"github_id":"Dedicatus546","repo":"gitalk","client_id":"f7dc1ebbf18fc0fd3a5c","client_secret":"0893318788a1b62f883bdace8c12e6c42d76b402","admin_user":"Dedicatus546","distraction_free_mode":true,"proxy":"https://strong-caramel-969805.netlify.app/github_access_token","language":"zh-CN","js":{"url":"https://fastly.jsdelivr.net/npm/gitalk@1.8.0/dist/gitalk.min.js","integrity":"sha256-MVK9MGD/XJaGyIghSVrONSnoXoGh3IFxLw0zfvzpxR4="},"path_md5":"1591929291"}</script>
<script src="/js/third-party/comments/gitalk.js"></script>
<!-- hexo injector body_end start -->
<script src="https://cdn.jsdelivr.net/npm/swiper@11.1.9/swiper-bundle.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@11.1.9/swiper-bundle.min.css">
<style>
:root {
--swiper-theme-color: var(--theme-color);
--swiper-pagination-bottom: 0;
}
.swiper {
padding-bottom: 32px;
margin-bottom: 20px;
}
.swiper .swiper-slide .swiper-slide-img {
display: block;
width: 100%;
object-fit: contain;
background: var(--body-bg-color);
margin: 0;
}
</style><!-- hexo injector body_end end --></body>
</html>