下一个泡泡玛特工程师是谁呢?

收集一些自己用到的prompt

2023-04-05 · 1 min read

机械键盘相关参数

机械键盘相关参数记录

2023-04-05 · 1 min read

Web 前端性能优化

常用的web前端性能优化手段

2023-03-19 · 3 min read

Blender常用快捷键

自己经常用到的一些快捷键记录

2022-12-11 · 1 min read

Docker 常用命令

精简 Docker 常用命令

2022-11-06 · 1 min read

项目管理

项目管理相关知识

2022-11-06 · 1 min read

JS沙箱sandbox的各种实现

我们把Js隔离机制常常称作沙箱

2022-09-18 · 1 min read

Amazing!Solid 比react还react

今天来介绍2个amazing的东东

2022-09-12 · 1 min read

puppeteer应用

使用傀儡师来操作浏览器这个傀儡吧

2022-09-11 · 1 min read

做一个web termianl

前端react, 后端nodejs, 直接可用版web termianl

2022-07-17 · 1 min read

TypeScript里常用的工具类型

经常用到的工具类型,提取抽离出来,供以后复用

2022-06-26 · 1 min read

Vim大法好

想要丢掉鼠标,试试Vim

2022-06-26 · 1 min read

碧血丹心

无论时光如何沾染风霜,也永似红日光

2022-05-10 · 1 min read

chrome V8 引擎中的垃圾回收机制

V8引擎就是nodejs的发动机

2022-03-03 · 1 min read

如何开发一个cli

命令行交互界面是程序员必备的工具,如何开发一个呢?

2022-02-21 · 1 min read

Javascript中的哲学

道生一,一生二,二生三,三生万物

2022-02-20 · 1 min read

React Redux 实现 (Context 版)

React Redux 实现 (Context 版)

2022-02-16 · 1 min read

mobx-react 使用

虽然不常用,但是可以学一下

2022-02-16 · 1 min read

Less中的for和forEach循环

循环的使用是保持代码干燥和避免重复的好方法

2022-02-15 · 1 min read

Webpack Splitchunks 详解

webpack 优化

2022-02-15 · 1 min read

ssh-keygen命令详解

为ssh生成、管理和转换认证密钥

2022-02-15 · 1 min read

使用CURL发送POST请求

curl 是常用的命令行工具,用来请求 Web 服务器。

2022-02-15 · 1 min read

Webpack Plugin 开发

让我们来学一下如何开发一个webpack插件

2022-02-14 · 1 min read

JS 实现两个大数相加?

algo-adding-large-numbers

2022-02-10 · 1 min read

字典树 trie

字典树 trie

2022-02-09 · 1 min read

浏览器原理问题

浏览器原理问题

2022-01-11 · 1 min read

MacBook快速进入一个文件夹目录

mac如何快速进入一个文件夹

2021-10-26 · 1 min read

react合成事件

react-synthetic-event

2021-10-25 · 1 min read

mini webpack实现

通过babel核心来实现迷你版的webpack

2021-10-10 · 1 min read

设计模式

在程序设计中有很多实用的设计模式,而其中大部分语言的实现都是基于类

2021-10-10 · 1 min read

babel核心

babel核心介绍

2021-10-07 · 1 min read

React 15 和 React 16 的区别

react-15-16

2021-10-06 · 1 min read

React性能优化

浅谈react性能优化的方法

2021-10-05 · 1 min read

交通信号灯实现

如何用js来实现交通信号灯呢

2021-09-25 · 1 min read

内存管理

前端中的内存管理

2021-09-25 · 1 min read

前端安全

前端关于安全方面的知识

2021-09-25 · 2 min read

网络和并发

http各版本对于并发的支持,前端如何控制并发量?

2021-09-25 · 1 min read

跨域方法

总结了9种跨域方法

2021-09-24 · 1 min read

react virtualList 虚拟列表无限滚动实现

用react实现虚拟滚动

2021-09-16 · 1 min read

监控埋点方案

前端监控埋点方案

2021-09-16 · 1 min read

Mini useEffect实现

如何实现useEffect?

2021-09-11 · 1 min read

Mini useState 实现

我们来思考一下useState是怎么实现的呢?

2021-09-11 · 1 min read

React Fiber

react-fiber

2021-09-11 · 1 min read

React class组件和function组件异同

类组件和函数组件有何相同点有何不同点呢?

2021-09-11 · 1 min read

Lodash Get 实现

algo-lodash-get

2021-09-08 · 1 min read

手写reduce实现

algo-reduce

2021-09-08 · 1 min read

Hooks 原理概览

react-hooks

2021-09-05 · 1 min read

Hook原理——状态Hook

react-hook-state

2021-09-05 · 1 min read

手写Mini Redux实现

手写一个简易版的redux实现,包含了核心逻辑

2021-09-04 · 1 min read

legacy和concurrent模式

react-legacy-concurrent

2021-09-01 · 1 min read

react架构

总体 react 的核心可以用 ui=fn(state)来表示 3 大核心对象、3 大核心阶段、2 大工作循环 Scheduler(调度器): 排序优先级,让优先级高的任务先进行 reconcile Reconciler…

2021-09-01 · 2 min read

react核心api和jsx

为什么要有jsx,为什么会有虚拟bom

2021-09-01 · 1 min read

setState是同步的还是异步的

react-setstate-usestate

2021-08-31 · 1 min read

如何使用NodeJs创建HTTP服务?

如何使用NodeJs创建HTTP服务?

2021-08-17 · 1 min read

NodeJS 事件循环模型

nodejs-eventloop

2021-08-11 · 2 min read

Buffer

nodejs中的内存管理

2021-08-10 · 1 min read

微前端解决方案-qiankun

目前国内最好的微前端解决方案-qiankun

2021-08-10 · 1 min read

React Mini版实现(1)

学一门技术最好的方法就是做一个其玩具版的实现,我们来尝试实现一下react和react-dom最简单版本吧

2021-08-04 · 1 min read

brew安装

brew 是 MacOS 上的包管理工具,可以简化 macOS 和 Linux 操作系统上软件的安装。

2021-08-04 · 1 min read

CommonJS简易版实现

CommonJS我们经常用,如何实现一个简易版的commonJS呢?

2021-08-01 · 1 min read

极品透明Dashboard样式分享

一个极品透明Dashboard样式分享

2021-07-30 · 1 min read

Stream

nodejs中的流

2021-07-11 · 1 min read

NodeJS全局对象

JavaScript 中有一个特殊的对象,称为全局对象(Global Object),它及其所有属性都可以在程序的任何地方访问,即全局变量。

2021-05-18 · 1 min read

如何部署Nodejs服务

如何快速的部署一个Nodejs服务到公网呢?

2021-05-12 · 1 min read

Events

events模块是node的核心模块之一,几乎所有常用的node模块都继承了events模块,比如http、fs等。

2021-05-11 · 1 min read

用JS绘制背景,让CSS直接使用 'background:paint(xxx)'

CSS对象新特性,新的background设置方式

2021-04-30 · 1 min read

Block Formatting Context 块级格式化上下文

可以将BFC看成是元素的一种属性,拥有了这种属性的元素就会使他的子元素与世隔绝,不会影响到外部其他元素

2021-04-17 · 1 min read

如何使用Nodejs来创建一个TCP/UDP服务?

如何使用Nodejs来创建一个TCP/UDP服务?

2021-04-17 · 1 min read

Mac使用tree生成目录结构

程序员经常会有需求,需要列出项目的结构树。Mac或者Linux下可以使用tree列出项目结构

2021-04-04 · 1 min read

常见算法

一些比较常见算法

2021-03-20 · 1 min read

前端缓存

对于性能优化离不开缓存

2021-02-28 · 1 min read

前端答疑

一些比较常见的问题

2020-09-02 · 1 min read

Nodejs 网络 & HTTP

nodejs-network

2020-08-14 · 1 min read

JavaScript AST 抽象语法树

源代码的抽象语法结构的树状表现形式

2020-08-02 · 1 min read

nodejs里面向切面编程的一种范式

在一些场景下我们可能需要一种面向切面的编程方式

2020-08-01 · 1 min read

各种JS模块化特性

AMD、CMD、CJS、ESM

2020-05-30 · 1 min read

手写Ajax实现

使用HMR一步步实现Ajax

2020-05-30 · min read

手写PromiseA+实现

如何自己实现promiseA+规范,手写一个promise实现

2020-04-30 · 1 min read

debug和内存泄露

nodejs的debug方法

2020-04-08 · 1 min read

Javascript prototype 原型链

js-prototype

2019-09-07 · 1 min read

this指针、作用域

this是在执行时动态读取上下文决定的,不是在定义时决定

2019-06-14 · 1 min read

call、apply、bind的极简实现

使用symbol实

2019-06-03 · 1 min read

CSS联合选择器区分列表元素个数不同所要求的不同样式

对于列表,在有些时候针对于不同个数的item会有不同的显示,比如col份数,用js固然可以,是否可以用css更简便的实现呢?

2019-04-30 · 1 min read

TypeScript基础

介绍TypeScript基础知识

2019-04-30 · 1 min read

JS中的变量提升

为什么js当时要这样设计

2019-03-07 · 1 min read

ES6之Class

关于ES6里的class, 我们有什么不知道的事?

2019-03-01 · 1 min read

HTTP详解

HTTP协议(HyperText Transfer Protocol,超文本传输协议)是用于从WWW服务器传输超文本到本地浏览器的传输协议

2019-02-17 · 2 min read

极简代码实现节流Throttle和防抖Debounce

使用各9行代码实现节流和防抖函数

2019-01-30 · 1 min read

Javascript 事件循环 EventLoop

js-eventloop

2018-09-07 · 1 min read

POST和GET区别

POST和GET区别是什么呢?

2018-08-14 · 1 min read

正则表达式

正则表达式一锅端

2018-07-30 · 1 min read

cloneDeep 深克隆实现

algo-clonedeep

2017-09-07 · 1 min read

webpack

engin-webpack

2017-09-07 · 1 min read

http1.1和http2.0有什么区别

http1.1和http2.0有什么区别

2017-06-14 · 1 min read

手写EventEmitter事件巴士

咱们来手写实现一个EventEmitter事件巴士

2017-01-10 · 1 min read

OOP 面向对象编程

对象是什么?为什么要面向对象?

2016-05-08 · 1 min read
Stay hungry & Stay foolish
战歌
16
The Reluctant Warrior
Immediate Music
To Glory
Two Steps From Hell
Victory
Two Steps From Hell
Empire of Angels
Thomas Bergersen
Serenata Immortale
Immediate Music
Cornfield Chase
Hans Zimmer
Tennessee
Hans Zimmer
He's a Pirate
Martin Ermen
Rise
Hans Zimmer
On Thin Ice
Hans Zimmer
Angels Will Rise
Twisted Jukebo
When It All Falls Down
Audiomachine
Icarus
Ivan Torrent
Star Sky - Instrumental
Two Steps From Hell
亡灵序曲
L
Up Is Down
Hans Zimm
回到首页

Hook原理——状态Hook

袁官东
September 5th, 2021 · 1 min read
图:Nguyen Nhut
  1. function 类型的 fiber 节点, 它的处理函数是 updateFunctionComponent, 其中再通过 renderWithHooks 调用 function.

  2. 在 function 中, 通过 Hook Api(如: useState, useEffect)创建 Hook 对象.

    状态 Hook 实现了状态持久化(等同于 class 组件维护 fiber.memoizedState).

    副作用 Hook 则实现了维护 fiber.flags,并提供副作用回调(类似于 class 组件的生命周期回调)

  3. 多个 Hook 对象构成一个链表结构, 并挂载到 fiber.memoizedState 之上.

  4. fiber 树更新阶段, 把 current.memoizedState 链表上的所有 Hook 按照顺序克隆到 workInProgress.memoizedState 上, 实现数据的持久化.

创建 Hook

在 fiber 初次构造阶段, useState 对应源码 mountState, useReducer 对应源码 mountReducer

mountState:

1function mountState<S>(
2 initialState: (() => S) | S,
3): [S, Dispatch<BasicStateAction<S>>] {
4 // 1. 创建hook
5 const hook = mountWorkInProgressHook();
6 if (typeof initialState === 'function') {
7 initialState = initialState();
8 }
9 // 2. 初始化hook的属性
10 // 2.1 设置 hook.memoizedState/hook.baseState
11 // 2.2 设置 hook.queue
12 hook.memoizedState = hook.baseState = initialState;
13 const queue = (hook.queue = {
14 pending: null,
15 dispatch: null,
16 // queue.lastRenderedReducer是内置函数
17 lastRenderedReducer: basicStateReducer,
18 lastRenderedState: (initialState: any),
19 });
20 // 2.3 设置 hook.dispatch
21 const dispatch: Dispatch<
22 BasicStateAction<S>,
23 > = (queue.dispatch = (dispatchAction.bind(
24 null,
25 currentlyRenderingFiber,
26 queue,
27 ): any));
28
29 // 3. 返回[当前状态, dispatch函数]
30 return [hook.memoizedState, dispatch];
31}

mountReducer:

1function mountReducer<S, I, A>(
2 reducer: (S, A) => S,
3 initialArg: I,
4 init?: I => S,
5): [S, Dispatch<A>] {
6 // 1. 创建hook
7 const hook = mountWorkInProgressHook();
8 let initialState;
9 if (init !== undefined) {
10 initialState = init(initialArg);
11 } else {
12 initialState = ((initialArg: any): S);
13 }
14 // 2. 初始化hook的属性
15 // 2.1 设置 hook.memoizedState/hook.baseState
16 hook.memoizedState = hook.baseState = initialState;
17 // 2.2 设置 hook.queue
18 const queue = (hook.queue = {
19 pending: null,
20 dispatch: null,
21 // queue.lastRenderedReducer是由外传入
22 lastRenderedReducer: reducer,
23 lastRenderedState: (initialState: any),
24 });
25 // 2.3 设置 hook.dispatch
26 const dispatch: Dispatch<A> = (queue.dispatch = (dispatchAction.bind(
27 null,
28 currentlyRenderingFiber,
29 queue,
30 ): any));
31
32 // 3. 返回[当前状态, dispatch函数]
33 return [hook.memoizedState, dispatch];
34}

mountState 和 mountReducer 逻辑简单: 主要负责创建 hook, 初始化 hook 的属性, 最后返回[当前状态, dispatch 函数].

唯一的不同点是 hook.queue.lastRenderedReducer:

  • mountState 使用的是内置的 basicStateReducer
1function basicStateReducer<S>(state: S, action: BasicStateAction<S>): S {
2 return typeof action === "function" ? action(state) : action;
3}
  • mountReducer 使用的是外部传入自定义 reducer

可见 mountState 是 mountReducer 的一种特殊情况, 即 useState 也是 useReducer 的一种特殊情况, 也是最简单的情况.

useState 可以转换成 useReducer:

1const [state, dispatch] = useState({ count: 0 });
2
3// 等价于
4const [state, dispatch] = useReducer(
5 function basicStateReducer(state, action) {
6 return typeof action === "function" ? action(state) : action;
7 },
8 { count: 0 }
9);
10
11// 当需要更新state时, 有2种方式
12dispatch({ count: 1 }); // 1.直接设置
13dispatch((state) => ({ count: state.count + 1 })); // 2.通过回调函数设置

可见, useState 就是对 useReducer 的基本封装, 内置了一个特殊的 reducer(后文不再区分 useState, useReducer, 都以 useState 为例).创建 hook 之后返回值[hook.memoizedState, dispatch]中的 dispath 实际上会调用 reducer 函数.

状态初始化

useState(initialState)函数内部, 设置hook.memoizedState = hook.baseState = initialState;, 初始状态被同时保存到了hook.baseState,hook.memoizedState中.

  • hook.memoizedState: 当前状态
  • hook.baseState: 基础状态, 作为合并 hook.baseQueue 的初始值(下文介绍).

最后返回[hook.memoizedState, dispatch], 所以在 function 中使用的是 hook.memoizedState.

状态更新

有如下组件

1import { useState } from "react";
2export default function App() {
3 const [count, dispatch] = useState(0);
4 return (
5 <button
6 onClick={() => {
7 dispatch(1);
8 dispatch(3);
9 dispatch(2);
10 }}
11 >
12 {count}
13 </button>
14 );
15}

初次渲染时 count = 0, 这时 hook 对象的内存状态如下:

点击 button, 通过 dispatch 函数进行更新, dispatch 实际就是 dispatchAction:

1function dispatchAction<S, A>(
2 fiber: Fiber,
3 queue: UpdateQueue<S, A>,
4 action: A,
5) {
6 // 1. 创建update对象
7 const eventTime = requestEventTime();
8 const lane = requestUpdateLane(fiber); // Legacy模式返回SyncLane
9 const update: Update<S, A> = {
10 lane,
11 action,
12 eagerReducer: null,
13 eagerState: null,
14 next: (null: any),
15 };
16
17 // 2. 将update对象添加到hook.queue.pending队列
18 const pending = queue.pending;
19 if (pending === null) {
20 // 首个update, 创建一个环形链表
21 update.next = update;
22 } else {
23 update.next = pending.next;
24 pending.next = update;
25 }
26 queue.pending = update;
27
28 const alternate = fiber.alternate;
29 if (
30 fiber === currentlyRenderingFiber ||
31 (alternate !== null && alternate === currentlyRenderingFiber)
32 ) {
33 // 渲染时更新, 做好全局标记
34 didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = true;
35 } else {
36 // ...省略性能优化部分, 下文介绍
37
38 // 3. 发起调度更新, 进入`reconciler 运作流程`中的输入阶段.
39 scheduleUpdateOnFiber(fiber, lane, eventTime);
40 }
41}
  1. 创建 update 对象, 其中 update.lane 代表优先级(可回顾 fiber 树构造(基础准备)中的 update 优先级).

  2. 将 update 对象添加到 hook.queue.pending 环形链表. 环形链表的特征: 为了方便添加新元素和快速拿到队首元素(都是 O(1)), 所以 pending 指针指向了链表中最后一个元素.

  3. 发起调度更新: 调用 scheduleUpdateOnFiber, 进入 reconciler 运作流程中的输入阶段.

本示例中虽然同时执行了 3 次 dispatch, 会请求 3 次调度, 由于调度中心的节流优化, 最后只会执行一次渲染

在 fiber 树构造(对比更新)过程中, 再次调用 function, 这时 useState 对应的函数是 updateState

1function updateState<S>(
2 initialState: (() => S) | S,
3): [S, Dispatch<BasicStateAction<S>>] {
4 return updateReducer(basicStateReducer, (initialState: any));
5}

实际调用 updateReducer.

在执行 updateReducer 之前, hook 相关的内存结构如下:

执行:

1function updateReducer<S, I, A>(
2 reducer: (S, A) => S,
3 initialArg: I,
4 init?: I => S,
5): [S, Dispatch<A>] {
6 // 1. 获取workInProgressHook对象
7 const hook = updateWorkInProgressHook();
8 const queue = hook.queue;
9 queue.lastRenderedReducer = reducer;
10 const current: Hook = (currentHook: any);
11 let baseQueue = current.baseQueue;
12
13 // 2. 链表拼接: 将 hook.queue.pending 拼接到 current.baseQueue
14 const pendingQueue = queue.pending;
15 if (pendingQueue !== null) {
16 if (baseQueue !== null) {
17 const baseFirst = baseQueue.next;
18 const pendingFirst = pendingQueue.next;
19 baseQueue.next = pendingFirst;
20 pendingQueue.next = baseFirst;
21 }
22 current.baseQueue = baseQueue = pendingQueue;
23 queue.pending = null;
24 }
25 // 3. 状态计算
26 if (baseQueue !== null) {
27 const first = baseQueue.next;
28 let newState = current.baseState;
29
30 let newBaseState = null;
31 let newBaseQueueFirst = null;
32 let newBaseQueueLast = null;
33 let update = first;
34
35 do {
36 const updateLane = update.lane;
37 // 3.1 优先级提取update
38 if (!isSubsetOfLanes(renderLanes, updateLane)) {
39 // 优先级不够: 加入到baseQueue中, 等待下一次render
40 const clone: Update<S, A> = {
41 lane: updateLane,
42 action: update.action,
43 eagerReducer: update.eagerReducer,
44 eagerState: update.eagerState,
45 next: (null: any),
46 };
47 if (newBaseQueueLast === null) {
48 newBaseQueueFirst = newBaseQueueLast = clone;
49 newBaseState = newState;
50 } else {
51 newBaseQueueLast = newBaseQueueLast.next = clone;
52 }
53 currentlyRenderingFiber.lanes = mergeLanes(
54 currentlyRenderingFiber.lanes,
55 updateLane,
56 );
57 markSkippedUpdateLanes(updateLane);
58 } else {
59 // 优先级足够: 状态合并
60 if (newBaseQueueLast !== null) {
61 // 更新baseQueue
62 const clone: Update<S, A> = {
63 lane: NoLane,
64 action: update.action,
65 eagerReducer: update.eagerReducer,
66 eagerState: update.eagerState,
67 next: (null: any),
68 };
69 newBaseQueueLast = newBaseQueueLast.next = clone;
70 }
71 if (update.eagerReducer === reducer) {
72 // 性能优化: 如果存在 update.eagerReducer, 直接使用update.eagerState.避免重复调用reducer
73 newState = ((update.eagerState: any): S);
74 } else {
75 const action = update.action;
76 // 调用reducer获取最新状态
77 newState = reducer(newState, action);
78 }
79 }
80 update = update.next;
81 } while (update !== null && update !== first);
82
83 // 3.2. 更新属性
84 if (newBaseQueueLast === null) {
85 newBaseState = newState;
86 } else {
87 newBaseQueueLast.next = (newBaseQueueFirst: any);
88 }
89 if (!is(newState, hook.memoizedState)) {
90 markWorkInProgressReceivedUpdate();
91 }
92 // 把计算之后的结果更新到workInProgressHook上
93 hook.memoizedState = newState;
94 hook.baseState = newBaseState;
95 hook.baseQueue = newBaseQueueLast;
96 queue.lastRenderedState = newState;
97 }
98
99 const dispatch: Dispatch<A> = (queue.dispatch: any);
100 return [hook.memoizedState, dispatch];
101}
  1. 调用 updateWorkInProgressHook 获取 workInProgressHook 对象

  2. 链表拼接: 将 hook.queue.pending 拼接到 current.baseQueue

状态计算

  1. update 优先级不够: 加入到 baseQueue 中, 等待下一次 render

update 优先级足够: 状态合并

更新属性

性能优化

dispatchAction 函数中, 在调用 scheduleUpdateOnFiber 之前, 针对 update 对象做了性能优化.

  1. queue.pending 中只包含当前 update 时, 即当前 update 是 queue.pending 中的第一个 update
  2. 直接调用 queue.lastRenderedReducer,计算出 update 之后的 state, 记为 eagerState
  3. 如果 eagerState 与 currentState 相同, 则直接退出, 不用发起调度更新.
  4. 已经被挂载到 queue.pending 上的 update 会在下一次 render 时再次合并.
1function dispatchAction<S, A>(
2 fiber: Fiber,
3 queue: UpdateQueue<S, A>,
4 action: A,
5) {
6 // ...省略无关代码 ...只保留性能优化部分代码:
7
8 // 下面这个if判断, 能保证当前创建的update, 是`queue.pending`中第一个`update`. 为什么? 发起更新之后fiber.lanes会被改动(可以回顾`fiber 树构造(对比更新)`章节), 如果`fiber.lanes && alternate.lanes`没有被改动, 自然就是首个update
9 if (
10 fiber.lanes === NoLanes &&
11 (alternate === null || alternate.lanes === NoLanes)
12 ) {
13 const lastRenderedReducer = queue.lastRenderedReducer;
14 if (lastRenderedReducer !== null) {
15 let prevDispatcher;
16 const currentState: S = (queue.lastRenderedState: any);
17 const eagerState = lastRenderedReducer(currentState, action);
18 // 暂存`eagerReducer`和`eagerState`, 如果在render阶段reducer==update.eagerReducer, 则可以直接使用无需再次计算
19 update.eagerReducer = lastRenderedReducer;
20 update.eagerState = eagerState;
21 if (is(eagerState, currentState)) {
22 // 快速通道, eagerState与currentState相同, 无需调度更新
23 // 注: update已经被添加到了queue.pending, 并没有丢弃. 之后需要更新的时候, 此update还是会起作用
24 return;
25 }
26 }
27 }
28 // 发起调度更新, 进入`reconciler 运作流程`中的输入阶段.
29 scheduleUpdateOnFiber(fiber, lane, eventTime);
30}

验证demo

More articles from Favori 重剑

手写Mini Redux实现

手写一个简易版的redux实现,包含了核心逻辑

September 4th, 2021 · 1 min read

legacy和concurrent模式

react-legacy-concurrent

September 1st, 2021 · 1 min read
© 2016–2023 Favori 重剑
Link to $https://github.com/yuanguandongLink to $https://favori.zcool.com.cn/Link to $https://codepen.io/favori