八维创作平台


推荐阅读

<p>[TOC]</p> <h5>简要描述</h5> <ul> <li>用户注册接口</li> </ul> <h5>请求URL</h5> <ul> <li><code>https://creationapi.shbwyz.com/api/article/recommend</code></li> </ul> <h5>请求方式</h5> <ul> <li>GET </li> </ul> <h5>参数</h5> <table> <thead> <tr> <th style="text-align: left;">参数名</th> <th style="text-align: left;">必选</th> <th style="text-align: left;">类型</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">username</td> <td style="text-align: left;">是</td> <td style="text-align: left;">string</td> <td>用户名</td> </tr> <tr> <td style="text-align: left;">password</td> <td style="text-align: left;">是</td> <td style="text-align: left;">string</td> <td>密码</td> </tr> <tr> <td style="text-align: left;">name</td> <td style="text-align: left;">否</td> <td style="text-align: left;">string</td> <td>昵称</td> </tr> </tbody> </table> <h5>返回示例</h5> <pre><code>{     "statusCode": 200,     "msg": null,     "success": true,     "data": [         {             "id": "07838fa6-1a88-448c-90ea-4b7ca61e6c98",             "title": "LeetCode 刷题",             "cover": "https://wipi.oss-cn-shanghai.aliyuncs.com/2020-04-19/1586003140-fdbe023474515aa.jpeg",             "summary": "✅ Solutions to LeetCode by JavaScript.",             "content": "# Leetcode\n\n✅ Solutions to LeetCode by JavaScript.\n\n## 简单\n\n- [两数之和](https://github.com/fantasticit/LeetCode/tree/master/Easy/0001.两数之和.js)\n- [整数反转](https://github.com/fantasticit/LeetCode/tree/master/Easy/0007.整数反转.js)\n- [回文数](https://github.com/fantasticit/LeetCode/tree/master/Easy/0009.回文数.js)\n- [有效的括号](https://github.com/fantasticit/LeetCode/tree/master/Easy/0020.有效的括号.js)\n- [合并两个有序链表](https://github.com/fantasticit/LeetCode/tree/master/Easy/0021.合并两个有序链表.js)\n- [删除排序数组中的重复项](https://github.com/fantasticit/LeetCode/tree/master/Easy/0026.删除排序数组中的重复项.js)\n- [移除元素](https://github.com/fantasticit/LeetCode/tree/master/Easy/0027.移除元素.js)\n- [实现-str-str](https://github.com/fantasticit/LeetCode/tree/master/Easy/0028.实现-str-str.js)\n- [搜索插入位置](https://github.com/fantasticit/LeetCode/tree/master/Easy/0035.搜索插入位置.js)\n- [最大子序和](https://github.com/fantasticit/LeetCode/tree/master/Easy/0053.最大子序和.js)\n- [最后一个单词的长度](https://github.com/fantasticit/LeetCode/tree/master/Easy/0058.最后一个单词的长度.js)\n- [加一](https://github.com/fantasticit/LeetCode/tree/master/Easy/0066.加一.js)\n- [二进制求和](https://github.com/fantasticit/LeetCode/tree/master/Easy/0067.二进制求和.js)\n- [爬楼梯](https://github.com/fantasticit/LeetCode/tree/master/Easy/0070.爬楼梯.js)\n- [删除排序链表中的重复元素](https://github.com/fantasticit/LeetCode/tree/master/Easy/0083.删除排序链表中的重复元素.js)\n- [合并两个有序数组](https://github.com/fantasticit/LeetCode/tree/master/Easy/0088.合并两个有序数组.js)\n- [相同的树](https://github.com/fantasticit/LeetCode/tree/master/Easy/0100.相同的树.js)\n- [对称二叉树](https://github.com/fantasticit/LeetCode/tree/master/Easy/0101.对称二叉树.js)\n- [二叉树的最大深度](https://github.com/fantasticit/LeetCode/tree/master/Easy/0104.二叉树的最大深度.js)\n- [二叉树的层次遍历-ii](https://github.com/fantasticit/LeetCode/tree/master/Easy/0107.二叉树的层次遍历-ii.js)\n- [平衡二叉树](https://github.com/fantasticit/LeetCode/tree/master/Easy/0110.平衡二叉树.js)\n- [二叉树的最小深度](https://github.com/fantasticit/LeetCode/tree/master/Easy/0111.二叉树的最小深度.js)\n- [只出现一次的数字](https://github.com/fantasticit/LeetCode/tree/master/Easy/0136.只出现一次的数字.js)\n- [环形链表](https://github.com/fantasticit/LeetCode/tree/master/Easy/0141.环形链表.js)\n- [反转链表](https://github.com/fantasticit/LeetCode/tree/master/Easy/0206.反转链表.js)\n- [最小栈](https://github.com/fantasticit/LeetCode/tree/master/Easy/0155.最小栈.js)\n- [移除链表元素](https://github.com/fantasticit/LeetCode/tree/master/Easy/0203.移除链表元素.js)\n- [存在重复元素](https://github.com/fantasticit/LeetCode/tree/master/Easy/0217.存在重复元素.js)\n- [回文链表](https://github.com/fantasticit/LeetCode/tree/master/Easy/0234.回文链表.js)\n- [各位相加](https://github.com/fantasticit/LeetCode/tree/master/Easy/0258.各位相加.js)\n- [反转字符串](https://github.com/fantasticit/LeetCode/tree/master/Easy/0344.反转字符串.js)\n- [找不同](https://github.com/fantasticit/LeetCode/tree/master/Easy/0389.找不同.js)\n- [用队列实现栈](https://github.com/fantasticit/LeetCode/tree/master/Easy/0225.用队列实现栈.js)\n- [斐波那契数](https://github.com/fantasticit/LeetCode/tree/master/Easy/0509.斐波那契数.js)\n- [二分查找](https://github.com/fantasticit/LeetCode/tree/master/Easy/0704.二分查找)\n- [反转字符串-ii](https://github.com/fantasticit/LeetCode/tree/master/Easy/0541.反转字符串-ii.js)\n\n## 中等\n\n- [两数相加](https://github.com/fantasticit/LeetCode/tree/master/Medium/0002.两数相加.js)\n- [字符串转换整数-atoi](https://github.com/fantasticit/LeetCode/tree/master/Medium/0008.字符串转换整数-atoi.js)\n- [盛最多水的容器](https://github.com/fantasticit/LeetCode/tree/master/Medium/0011.盛最多水的容器.js)\n- [三数之和](https://github.com/fantasticit/LeetCode/tree/master/Medium/0015.三数之和.js)\n- [最接近的三数之和](https://github.com/fantasticit/LeetCode/tree/master/Medium/0016.最接近的三数之和.js)\n- [四数之和](https://github.com/fantasticit/LeetCode/tree/master/Medium/0018.四数之和.js)\n- [删除链表的倒数第 n 个节点](https://github.com/fantasticit/LeetCode/tree/master/Medium/0019.删除链表的倒数第n个节点.js)\n- [括号生成](https://github.com/fantasticit/LeetCode/tree/master/Medium/0022.括号生成.js)\n- [两两交换链表中的节点](https://github.com/fantasticit/LeetCode/tree/master/Medium/0024.两两交换链表中的节点.js)\n- [两数相除](https://github.com/fantasticit/LeetCode/tree/master/Medium/0029.两数相除.js)\n- [在排序数组中查找元素的第一个和最后一个位置](https://github.com/fantasticit/LeetCode/tree/master/Medium/0034.在排序数组中查找元素的第一个和最后一个位置.js)\n- [有效的数独](https://github.com/fantasticit/LeetCode/tree/master/Medium/0036.有效的数独.js)\n- [字符串相乘](https://github.com/fantasticit/LeetCode/tree/master/Medium/0043.字符串相乘.js)\n- [字母异位词分组](https://github.com/fantasticit/LeetCode/tree/master/Medium/0049.字母异位词分组.js)\n- [pow-x-n](https://github.com/fantasticit/LeetCode/tree/master/Medium/0050.pow-x-n.js)\n- [二叉树的前序遍历](https://github.com/fantasticit/LeetCode/tree/master/Medium/0144.二叉树的前序遍历.js)\n- [lru 缓存机制](https://github.com/fantasticit/LeetCode/tree/master/Medium/0146.lru缓存机制.js)\n- [最长上升子序列](https://github.com/fantasticit/LeetCode/tree/master/Medium/0300.最长上升子序列)\n- [二叉树的中序遍历](https://github.com/fantasticit/LeetCode/tree/master/Medium/0094.二叉树的中序遍历)\n\n## 困难\n\n- [缺失的第一个正数](https://github.com/fantasticit/LeetCode/tree/master/Hard/0041.缺失的第一个正数.js)\n- [最小覆盖子串](https://github.com/fantasticit/LeetCode/tree/master/Hard/0076.最小覆盖子串)\n- [二叉树的后序遍历](https://github.com/fantasticit/LeetCode/tree/master/Hard/0145.二叉树的后序遍历)\n\n## LICENSE\n\nMIT\n",             "html": "&lt;h1 id=\"leetcode\"&gt;Leetcode&lt;/h1&gt;\n&lt;p&gt;✅ Solutions to LeetCode by JavaScript.&lt;/p&gt;\n&lt;h2 id=\"简单\"&gt;简单&lt;/h2&gt;\n&lt;ul&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0001.两数之和.js\"&gt;两数之和&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0007.整数反转.js\"&gt;整数反转&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0009.回文数.js\"&gt;回文数&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0020.有效的括号.js\"&gt;有效的括号&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0021.合并两个有序链表.js\"&gt;合并两个有序链表&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0026.删除排序数组中的重复项.js\"&gt;删除排序数组中的重复项&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0027.移除元素.js\"&gt;移除元素&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0028.实现-str-str.js\"&gt;实现-str-str&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0035.搜索插入位置.js\"&gt;搜索插入位置&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0053.最大子序和.js\"&gt;最大子序和&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0058.最后一个单词的长度.js\"&gt;最后一个单词的长度&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0066.加一.js\"&gt;加一&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0067.二进制求和.js\"&gt;二进制求和&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0070.爬楼梯.js\"&gt;爬楼梯&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0083.删除排序链表中的重复元素.js\"&gt;删除排序链表中的重复元素&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0088.合并两个有序数组.js\"&gt;合并两个有序数组&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0100.相同的树.js\"&gt;相同的树&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0101.对称二叉树.js\"&gt;对称二叉树&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0104.二叉树的最大深度.js\"&gt;二叉树的最大深度&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0107.二叉树的层次遍历-ii.js\"&gt;二叉树的层次遍历-ii&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0110.平衡二叉树.js\"&gt;平衡二叉树&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0111.二叉树的最小深度.js\"&gt;二叉树的最小深度&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0136.只出现一次的数字.js\"&gt;只出现一次的数字&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0141.环形链表.js\"&gt;环形链表&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0206.反转链表.js\"&gt;反转链表&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0155.最小栈.js\"&gt;最小栈&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0203.移除链表元素.js\"&gt;移除链表元素&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0217.存在重复元素.js\"&gt;存在重复元素&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0234.回文链表.js\"&gt;回文链表&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0258.各位相加.js\"&gt;各位相加&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0344.反转字符串.js\"&gt;反转字符串&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0389.找不同.js\"&gt;找不同&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0225.用队列实现栈.js\"&gt;用队列实现栈&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0509.斐波那契数.js\"&gt;斐波那契数&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0704.二分查找\"&gt;二分查找&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Easy/0541.反转字符串-ii.js\"&gt;反转字符串-ii&lt;/a&gt;&lt;/li&gt;\n&lt;/ul&gt;\n&lt;h2 id=\"中等\"&gt;中等&lt;/h2&gt;\n&lt;ul&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Medium/0002.两数相加.js\"&gt;两数相加&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Medium/0008.字符串转换整数-atoi.js\"&gt;字符串转换整数-atoi&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Medium/0011.盛最多水的容器.js\"&gt;盛最多水的容器&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Medium/0015.三数之和.js\"&gt;三数之和&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Medium/0016.最接近的三数之和.js\"&gt;最接近的三数之和&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Medium/0018.四数之和.js\"&gt;四数之和&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Medium/0019.删除链表的倒数第n个节点.js\"&gt;删除链表的倒数第 n 个节点&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Medium/0022.括号生成.js\"&gt;括号生成&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Medium/0024.两两交换链表中的节点.js\"&gt;两两交换链表中的节点&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Medium/0029.两数相除.js\"&gt;两数相除&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Medium/0034.在排序数组中查找元素的第一个和最后一个位置.js\"&gt;在排序数组中查找元素的第一个和最后一个位置&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Medium/0036.有效的数独.js\"&gt;有效的数独&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Medium/0043.字符串相乘.js\"&gt;字符串相乘&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Medium/0049.字母异位词分组.js\"&gt;字母异位词分组&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Medium/0050.pow-x-n.js\"&gt;pow-x-n&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Medium/0144.二叉树的前序遍历.js\"&gt;二叉树的前序遍历&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Medium/0146.lru缓存机制.js\"&gt;lru 缓存机制&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Medium/0300.最长上升子序列\"&gt;最长上升子序列&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Medium/0094.二叉树的中序遍历\"&gt;二叉树的中序遍历&lt;/a&gt;&lt;/li&gt;\n&lt;/ul&gt;\n&lt;h2 id=\"困难\"&gt;困难&lt;/h2&gt;\n&lt;ul&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Hard/0041.缺失的第一个正数.js\"&gt;缺失的第一个正数&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Hard/0076.最小覆盖子串\"&gt;最小覆盖子串&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/LeetCode/tree/master/Hard/0145.二叉树的后序遍历\"&gt;二叉树的后序遍历&lt;/a&gt;&lt;/li&gt;\n&lt;/ul&gt;\n&lt;h2 id=\"license\"&gt;LICENSE&lt;/h2&gt;\n&lt;p&gt;MIT&lt;/p&gt;",             "toc": "[{\"level\":\"1\",\"id\":\"leetcode\",\"text\":\"Leetcode\"},{\"level\":\"2\",\"id\":\"简单\",\"text\":\"简单\"},{\"level\":\"2\",\"id\":\"中等\",\"text\":\"中等\"},{\"level\":\"2\",\"id\":\"困难\",\"text\":\"困难\"},{\"level\":\"2\",\"id\":\"license\",\"text\":\"LICENSE\"}]",             "status": "publish",             "views": 364,             "likes": -2,             "isRecommended": false,             "needPassword": false,             "totalAmount": null,             "isPay": false,             "isCommentable": true,             "publishAt": "2022-01-06T08:59:30.000Z",             "createAt": "2022-01-06T08:59:30.412Z",             "updateAt": "2022-06-22T13:39:37.000Z",             "category": {                 "id": "2dfaaaa6-b9f1-4d0a-b307-534c477fa751",                 "label": "LeeCode",                 "value": "leetcode",                 "createAt": "2022-01-06T08:25:07.768Z",                 "updateAt": "2022-01-06T08:25:07.768Z"             },             "tags": [                 {                     "id": "85f9a1b0-20cf-4a12-8440-a50fcc935e14",                     "label": "JS",                     "value": "js",                     "createAt": "2022-01-06T08:29:21.772Z",                     "updateAt": "2022-01-06T08:29:21.772Z"                 },                 {                     "id": "b892adb9-4dab-4b84-9f47-7c5de5e65a33",                     "label": "LeetCode",                     "value": "leetcode",                     "createAt": "2022-01-06T08:30:07.131Z",                     "updateAt": "2022-01-06T08:30:07.131Z"                 }             ]         },         {             "id": "9a5bfb81-013f-4762-9485-2875a8a7150b",             "title": "Git 恢复被误删的本地分支",             "cover": "https://wipi.oss-cn-shanghai.aliyuncs.com/2020-02-10/TBRGIVFYPEAWW7M0AM6TU2/git-goodness.gif",             "summary": "本文介绍 Git 如何恢复被误删的本地分支。",             "content": "假设场景:\n\n在某个项目下,我新建了一个本地分支 `test`,并在该分支做出了一些改动,但是我在没有 `push` 该分支代码到远程仓库之前手滑删除了该分支,那么如何在本地恢复这个分支?该场景的相关操作如下:\n\n```shell\ngit branch test\ngit checkout test\n\n# 做了一些改动\n\ngit status\ngit add .\ngit commit -m \"some info\"\n\ngit chekout - # 切到上一个分支\ngit branch -D test # 手滑删了 test\n```\n\n经过以上操作,本地更改的代码是没有了的。但是 `git` 中有日志(因为 git commit 到本地了),通过 `git log -g` 查看 `commit` 的记录 `hash` 值,然后执行 `git branch test hash` 即可恢复。\n\n总结一下:\n\n```shell\ngit log -g # 查找本地提交记录 hash\ngit branch new_branch_name hash # 新建分支\n```\n\n",             "html": "&lt;p&gt;假设场景:&lt;/p&gt;\n&lt;p&gt;在某个项目下,我新建了一个本地分支 &lt;code&gt;test&lt;/code&gt;,并在该分支做出了一些改动,但是我在没有 &lt;code&gt;push&lt;/code&gt; 该分支代码到远程仓库之前手滑删除了该分支,那么如何在本地恢复这个分支?该场景的相关操作如下:&lt;/p&gt;\n&lt;pre&gt;&lt;code class=\"shell language-shell\"&gt;git branch test\ngit checkout test\n\n# 做了一些改动\n\ngit status\ngit add .\ngit commit -m \"some info\"\n\ngit chekout - # 切到上一个分支\ngit branch -D test # 手滑删了 test\n&lt;/code&gt;&lt;/pre&gt;\n&lt;p&gt;经过以上操作,本地更改的代码是没有了的。但是 &lt;code&gt;git&lt;/code&gt; 中有日志(因为 git commit 到本地了),通过 &lt;code&gt;git log -g&lt;/code&gt; 查看 &lt;code&gt;commit&lt;/code&gt; 的记录 &lt;code&gt;hash&lt;/code&gt; 值,然后执行 &lt;code&gt;git branch test hash&lt;/code&gt; 即可恢复。&lt;/p&gt;\n&lt;p&gt;总结一下:&lt;/p&gt;\n&lt;pre&gt;&lt;code class=\"shell language-shell\"&gt;git log -g # 查找本地提交记录 hash\ngit branch new_branch_name hash # 新建分支\n&lt;/code&gt;&lt;/pre&gt;",             "toc": "[]",             "status": "publish",             "views": 69,             "likes": 1,             "isRecommended": false,             "needPassword": false,             "totalAmount": null,             "isPay": false,             "isCommentable": true,             "publishAt": "2022-01-06T08:57:49.000Z",             "createAt": "2022-01-06T08:57:49.056Z",             "updateAt": "2022-06-22T13:00:56.000Z",             "category": {                 "id": "3938732d-4f78-460a-b51b-bd3d414811b8",                 "label": "后端",                 "value": "be",                 "createAt": "2021-12-31T00:32:58.400Z",                 "updateAt": "2022-01-06T08:56:16.000Z"             },             "tags": [                 {                     "id": "8934f86f-9a71-472f-a0b4-650124891a8d",                     "label": "Git",                     "value": "git",                     "createAt": "2022-01-06T08:26:46.146Z",                     "updateAt": "2022-01-06T08:28:46.000Z"                 }             ]         },         {             "id": "2636e861-d36f-4c4f-aac7-77fd3dab5198",             "title": "Docker 使用笔记(一)",             "cover": "https://wipi.oss-cn-shanghai.aliyuncs.com/2020-02-10/TBRGIVFYPEAWW7M0AM6TDG/16410734eb1ed373.png",             "summary": "Docker 使用笔记系列第一篇。",             "content": "## 安装 Docker\n\n\n在 [Docker](https://www.docker.com/get-started) 网站下载安装 Docker 。 安装完成后,打开命令行输入 `docker version`,如果有相关输出即安装成功。\n\n## 运行 container\n\n\ndocker 中与 `container` 相关的命令主要有:\n\n*   `docker container run ...`:运行容器\n*   `docker container ls`: 列出当前运行容器\n*   `docker container start [container_id | container_name]`: 开始运行指定 id(或名称) 的容器\n*   `docker container stop [container_id | container_name]`: 停止运行指定 id(或名称) 的容器\n*   `docker container rm [container_id| container_name]`: 删除指定 id(或名称) 的容器\n\n其中,也可以使用 `docker ps` 查看正在运行的容器。\n\n### 运行 nginx\n\n打开命令行,键入:\n\n    docker container run -it -p 8080:81 nginx\n    \n\n如果报错无法拉取,执行 `docker login` 输入账号密码登录 docker hub 账号后再执行。 在浏览器访问网站:`http://localhost:8080`,如果可以访问到 nginx 相关即表示运行成功。\n\n`-p 8080:81` 指定镜像在容器内运行的端口为:`81`,同时将端口映射到本地机器的 `8080` 端口,所以需要在浏览器访问 `http://localhost:8080` 才可。\n\n### 运行 mysql\n\n不同与 nginx ,运行 mysql 时可能需要设置一些变量,比如数据库密码之类的,这就需要用到 `--env` 参数。\n\n    docker container run -d -p 3006:3036 --env MYSQL_ROOT_PASSWORD=123456 mysql\n    \n\n## 进入 container\n\n\n使用 `docker container -it exec [container_id | container_name]` 可以运行指定的容器内的程序\n\n首先,运行一个名为 `mynginx` 的容器:\n\n    docker container run -d -p 8080:80 --name mynginx nginx\n    \n\n然后,调用 `mynginx` 的 `bash` 程序:\n\n    docker container exec -it mynginx bash\n    \n\n如此,便可以在 container 内部操作环境执行命令,就像是进入了这个 container 操作环境内一样。\n\n### 绑定挂载点\n\n\n在上一步中,可以知道 container mynginx 的文件路径为:`/usr/share/nginx/html`。如果想要修改这些文件,就需要进入 container 内部进行修改,这样便会很麻烦。docker 提供了绑定挂载点的功能,这样便可以把本地机器的文件映射到 container 内部。\n\n    docker container run -d -p 8080:81 -v ~/test:/usr/share/nginx/html --nmae mynginx nginx\n    \n\n在本地机器的 test 文件夹,新建一个 index.html 文件,然后浏览器访问 `http://localhost:8080`,便可以看到刚刚保存的内容。\n\n### 制作镜像\n\n\n`docker container run` 的过程是首先拉取镜像,然后运行这个镜像。如此便可以制作自己的镜像。例如:\n\n首先新建一个文件夹,然后新建一个 `index.html` 文件并写入内容,然后再编写 `Dockerfile` 文件。\n\n    FROM nginx:latest\n    \n    WORKDIR /usr/share/nginx/html\n    \n    COPY . .\n    \n\n然后运行 `docker image build . -t mynginx-web`(`.` 是指当前路径),便完成了镜像制作。\n\n运行这个镜像只需要:`docker container run -it -p 8080:80 mynginx-web`。",             "html": "&lt;h2 id=\"安装-docker\"&gt;安装 Docker&lt;/h2&gt;\n&lt;p&gt;在 &lt;a href=\"https://www.docker.com/get-started\"&gt;Docker&lt;/a&gt; 网站下载安装 Docker 。 安装完成后,打开命令行输入 &lt;code&gt;docker version&lt;/code&gt;,如果有相关输出即安装成功。&lt;/p&gt;\n&lt;h2 id=\"运行-container\"&gt;运行 container&lt;/h2&gt;\n&lt;p&gt;docker 中与 &lt;code&gt;container&lt;/code&gt; 相关的命令主要有:&lt;/p&gt;\n&lt;ul&gt;\n&lt;li&gt;&lt;code&gt;docker container run ...&lt;/code&gt;:运行容器&lt;/li&gt;\n&lt;li&gt;&lt;code&gt;docker container ls&lt;/code&gt;: 列出当前运行容器&lt;/li&gt;\n&lt;li&gt;&lt;code&gt;docker container start [container_id | container_name]&lt;/code&gt;: 开始运行指定 id(或名称) 的容器&lt;/li&gt;\n&lt;li&gt;&lt;code&gt;docker container stop [container_id | container_name]&lt;/code&gt;: 停止运行指定 id(或名称) 的容器&lt;/li&gt;\n&lt;li&gt;&lt;code&gt;docker container rm [container_id| container_name]&lt;/code&gt;: 删除指定 id(或名称) 的容器&lt;/li&gt;\n&lt;/ul&gt;\n&lt;p&gt;其中,也可以使用 &lt;code&gt;docker ps&lt;/code&gt; 查看正在运行的容器。&lt;/p&gt;\n&lt;h3 id=\"运行-nginx\"&gt;运行 nginx&lt;/h3&gt;\n&lt;p&gt;打开命令行,键入:&lt;/p&gt;\n&lt;pre&gt;&lt;code&gt;docker container run -it -p 8080:81 nginx\n&lt;/code&gt;&lt;/pre&gt;\n&lt;p&gt;如果报错无法拉取,执行 &lt;code&gt;docker login&lt;/code&gt; 输入账号密码登录 docker hub 账号后再执行。 在浏览器访问网站:&lt;code&gt;http://localhost:8080&lt;/code&gt;,如果可以访问到 nginx 相关即表示运行成功。&lt;/p&gt;\n&lt;p&gt;&lt;code&gt;-p 8080:81&lt;/code&gt; 指定镜像在容器内运行的端口为:&lt;code&gt;81&lt;/code&gt;,同时将端口映射到本地机器的 &lt;code&gt;8080&lt;/code&gt; 端口,所以需要在浏览器访问 &lt;code&gt;http://localhost:8080&lt;/code&gt; 才可。&lt;/p&gt;\n&lt;h3 id=\"运行-mysql\"&gt;运行 mysql&lt;/h3&gt;\n&lt;p&gt;不同与 nginx ,运行 mysql 时可能需要设置一些变量,比如数据库密码之类的,这就需要用到 &lt;code&gt;--env&lt;/code&gt; 参数。&lt;/p&gt;\n&lt;pre&gt;&lt;code&gt;docker container run -d -p 3006:3036 --env MYSQL_ROOT_PASSWORD=123456 mysql\n&lt;/code&gt;&lt;/pre&gt;\n&lt;h2 id=\"进入-container\"&gt;进入 container&lt;/h2&gt;\n&lt;p&gt;使用 &lt;code&gt;docker container -it exec [container_id | container_name]&lt;/code&gt; 可以运行指定的容器内的程序&lt;/p&gt;\n&lt;p&gt;首先,运行一个名为 &lt;code&gt;mynginx&lt;/code&gt; 的容器:&lt;/p&gt;\n&lt;pre&gt;&lt;code&gt;docker container run -d -p 8080:80 --name mynginx nginx\n&lt;/code&gt;&lt;/pre&gt;\n&lt;p&gt;然后,调用 &lt;code&gt;mynginx&lt;/code&gt; 的 &lt;code&gt;bash&lt;/code&gt; 程序:&lt;/p&gt;\n&lt;pre&gt;&lt;code&gt;docker container exec -it mynginx bash\n&lt;/code&gt;&lt;/pre&gt;\n&lt;p&gt;如此,便可以在 container 内部操作环境执行命令,就像是进入了这个 container 操作环境内一样。&lt;/p&gt;\n&lt;h3 id=\"绑定挂载点\"&gt;绑定挂载点&lt;/h3&gt;\n&lt;p&gt;在上一步中,可以知道 container mynginx 的文件路径为:&lt;code&gt;/usr/share/nginx/html&lt;/code&gt;。如果想要修改这些文件,就需要进入 container 内部进行修改,这样便会很麻烦。docker 提供了绑定挂载点的功能,这样便可以把本地机器的文件映射到 container 内部。&lt;/p&gt;\n&lt;pre&gt;&lt;code&gt;docker container run -d -p 8080:81 -v ~/test:/usr/share/nginx/html --nmae mynginx nginx\n&lt;/code&gt;&lt;/pre&gt;\n&lt;p&gt;在本地机器的 test 文件夹,新建一个 index.html 文件,然后浏览器访问 &lt;code&gt;http://localhost:8080&lt;/code&gt;,便可以看到刚刚保存的内容。&lt;/p&gt;\n&lt;h3 id=\"制作镜像\"&gt;制作镜像&lt;/h3&gt;\n&lt;p&gt;&lt;code&gt;docker container run&lt;/code&gt; 的过程是首先拉取镜像,然后运行这个镜像。如此便可以制作自己的镜像。例如:&lt;/p&gt;\n&lt;p&gt;首先新建一个文件夹,然后新建一个 &lt;code&gt;index.html&lt;/code&gt; 文件并写入内容,然后再编写 &lt;code&gt;Dockerfile&lt;/code&gt; 文件。&lt;/p&gt;\n&lt;pre&gt;&lt;code&gt;FROM nginx:latest\n\nWORKDIR /usr/share/nginx/html\n\nCOPY . .\n&lt;/code&gt;&lt;/pre&gt;\n&lt;p&gt;然后运行 &lt;code&gt;docker image build . -t mynginx-web&lt;/code&gt;(&lt;code&gt;.&lt;/code&gt; 是指当前路径),便完成了镜像制作。&lt;/p&gt;\n&lt;p&gt;运行这个镜像只需要:&lt;code&gt;docker container run -it -p 8080:80 mynginx-web&lt;/code&gt;。&lt;/p&gt;",             "toc": "[{\"level\":\"2\",\"id\":\"安装-docker\",\"text\":\"安装 Docker\"},{\"level\":\"2\",\"id\":\"运行-container\",\"text\":\"运行 container\"},{\"level\":\"3\",\"id\":\"运行-nginx\",\"text\":\"运行 nginx\"},{\"level\":\"3\",\"id\":\"运行-mysql\",\"text\":\"运行 mysql\"},{\"level\":\"2\",\"id\":\"进入-container\",\"text\":\"进入 container\"},{\"level\":\"3\",\"id\":\"绑定挂载点\",\"text\":\"绑定挂载点\"},{\"level\":\"3\",\"id\":\"制作镜像\",\"text\":\"制作镜像\"}]",             "status": "publish",             "views": 36,             "likes": 2,             "isRecommended": false,             "needPassword": false,             "totalAmount": null,             "isPay": false,             "isCommentable": true,             "publishAt": "2022-01-06T08:52:49.000Z",             "createAt": "2022-01-06T08:52:49.091Z",             "updateAt": "2022-06-22T11:30:59.000Z",             "category": {                 "id": "3938732d-4f78-460a-b51b-bd3d414811b8",                 "label": "后端",                 "value": "be",                 "createAt": "2021-12-31T00:32:58.400Z",                 "updateAt": "2022-01-06T08:56:16.000Z"             },             "tags": [                 {                     "id": "a035df43-309e-4ec4-8784-96b9a6f5fe03",                     "label": "Docker",                     "value": "docker",                     "createAt": "2022-01-06T08:27:12.686Z",                     "updateAt": "2022-01-06T08:28:41.000Z"                 }             ]         },         {             "id": "01192e24-99f1-436c-9122-073411e514c8",             "title": "bash 中的特殊字符(下)",             "cover": "https://wipi.oss-cn-shanghai.aliyuncs.com/2020-03-08/OXBA3L3HG6GJTIOTX8I7AH/LinuxUNIX-Certification-Training-Bundle.jpg",             "summary": "bash 脚本编程系列之:bash 中的特殊字符(下)。",             "content": "\n## 1 小括号(`()`)\n\n### 1.1 命令组\n\n在括号中的命令会作为一个子 shell 来运行。在括号中的变量,由于是在子 shell 中,所以对于脚本剩下的部分是不可用的。父进程,也就是脚本本身,将不能够读取在子进程中创建的变量,也就是在子 shell 中创建的变量。\n\n```shell\n#!/bin/bash\n\na=10\n( a=20; )\n\necho $a   # 10\n```\n\n### 1.2 初始化数组\n\n创建数组。\n\n```shell\n#!/bin/bash\n\narr=(1 2 3)   # 注意是以空格分割\necho ${arr[0]} # 1\n```\n\n## 2 大括号({})\n\n### 2.1 文件名扩展\n\n举个例子,复制 `t.txt` 内容到 `t.bak`中:\n\n```shell\n#!/bin/bash\n\nif [ ! -w 't.txt' ]; then\n  touch t.txt\nfi\n\necho 'hello t.txt' &gt; t.txt;\ncp t.{txt,bak}\n```\n\n注意: 在大括号中,不允许有空白,除非这个空白被引用或转义。\n\n### 2.2 代码块\n\n代码块,又称 _内部组_,这个结构实际上是创建了一个匿名函数,但是其中声明的变量,对于脚本其他部分可见。\n\n```shell\n#!/bin/bash\n\na=10\n{ a=20; }\n\necho $a # 20\n```\n\n## 3 中括号\n\n### 3.1 条件测试\n\n条件测试表达式放置于 `[]` 中。\n\n```shell\n#!/bin/bash\n\na=10\n\nif [ $a -lt 15 ]; then\n  echo \"$a &lt; 15\"\nelse\n  echo \"$a &gt; 15\"\nfi\n```\n\n### 3.2 数组元素\n\n```shell\n#!/bin/bash\n\narr=(10 11 12)\narr[0]=13\necho ${arr[0]} # 13\n```\n\n## 4 尖括号(&lt; &amp; &gt;)\n\n重定向。\n\n- test.sh &gt; filename:重定向 test.sh 的输出到文件 filename 中。如果 filename 存在的话,那么将会被覆盖。\n\n- test.sh &amp;&gt; filename:重定向 test.sh 的 stdout(标准输出)和 stderr(标准错误)到 filename 中。\n\n- test.sh &gt;&amp;2:重定向 test.sh 的 stdout 到 stderr 中。\n\n- test.sh &gt;&gt; filename:把 test.sh 的输出追加到文件 filename 中。如果 filename 不存在的话,将会被创建。\n\n## 5 管道(|)\n\n分析左侧命令的输出,并将该输出作为右侧命令的输入。\n\n```shell\nps -aux | grep 8080\n```\n\n## 6 波浪号(~)\n\n表示 `home` 目录。\n",             "html": "&lt;h2 id=\"1-小括号()\"&gt;1 小括号(&lt;code&gt;()&lt;/code&gt;)&lt;/h2&gt;\n&lt;h3 id=\"11-命令组\"&gt;1.1 命令组&lt;/h3&gt;\n&lt;p&gt;在括号中的命令会作为一个子 shell 来运行。在括号中的变量,由于是在子 shell 中,所以对于脚本剩下的部分是不可用的。父进程,也就是脚本本身,将不能够读取在子进程中创建的变量,也就是在子 shell 中创建的变量。&lt;/p&gt;\n&lt;pre&gt;&lt;code class=\"shell language-shell\"&gt;#!/bin/bash\n\na=10\n( a=20; )\n\necho $a   # 10\n&lt;/code&gt;&lt;/pre&gt;\n&lt;h3 id=\"12-初始化数组\"&gt;1.2 初始化数组&lt;/h3&gt;\n&lt;p&gt;创建数组。&lt;/p&gt;\n&lt;pre&gt;&lt;code class=\"shell language-shell\"&gt;#!/bin/bash\n\narr=(1 2 3)   # 注意是以空格分割\necho ${arr[0]} # 1\n&lt;/code&gt;&lt;/pre&gt;\n&lt;h2 id=\"2-大括号()\"&gt;2 大括号({})&lt;/h2&gt;\n&lt;h3 id=\"21-文件名扩展\"&gt;2.1 文件名扩展&lt;/h3&gt;\n&lt;p&gt;举个例子,复制 &lt;code&gt;t.txt&lt;/code&gt; 内容到 &lt;code&gt;t.bak&lt;/code&gt;中:&lt;/p&gt;\n&lt;pre&gt;&lt;code class=\"shell language-shell\"&gt;#!/bin/bash\n\nif [ ! -w 't.txt' ]; then\n  touch t.txt\nfi\n\necho 'hello t.txt' &gt; t.txt;\ncp t.{txt,bak}\n&lt;/code&gt;&lt;/pre&gt;\n&lt;p&gt;注意: 在大括号中,不允许有空白,除非这个空白被引用或转义。&lt;/p&gt;\n&lt;h3 id=\"22-代码块\"&gt;2.2 代码块&lt;/h3&gt;\n&lt;p&gt;代码块,又称 _内部组_,这个结构实际上是创建了一个匿名函数,但是其中声明的变量,对于脚本其他部分可见。&lt;/p&gt;\n&lt;pre&gt;&lt;code class=\"shell language-shell\"&gt;#!/bin/bash\n\na=10\n{ a=20; }\n\necho $a # 20\n&lt;/code&gt;&lt;/pre&gt;\n&lt;h2 id=\"3-中括号\"&gt;3 中括号&lt;/h2&gt;\n&lt;h3 id=\"31-条件测试\"&gt;3.1 条件测试&lt;/h3&gt;\n&lt;p&gt;条件测试表达式放置于 &lt;code&gt;[]&lt;/code&gt; 中。&lt;/p&gt;\n&lt;pre&gt;&lt;code class=\"shell language-shell\"&gt;#!/bin/bash\n\na=10\n\nif [ $a -lt 15 ]; then\n  echo \"$a &lt; 15\"\nelse\n  echo \"$a &gt; 15\"\nfi\n&lt;/code&gt;&lt;/pre&gt;\n&lt;h3 id=\"32-数组元素\"&gt;3.2 数组元素&lt;/h3&gt;\n&lt;pre&gt;&lt;code class=\"shell language-shell\"&gt;#!/bin/bash\n\narr=(10 11 12)\narr[0]=13\necho ${arr[0]} # 13\n&lt;/code&gt;&lt;/pre&gt;\n&lt;h2 id=\"4-尖括号(--)\"&gt;4 尖括号(&lt; &amp; &gt;)&lt;/h2&gt;\n&lt;p&gt;重定向。&lt;/p&gt;\n&lt;ul&gt;\n&lt;li&gt;&lt;p&gt;test.sh &gt; filename:重定向 test.sh 的输出到文件 filename 中。如果 filename 存在的话,那么将会被覆盖。&lt;/p&gt;&lt;/li&gt;\n&lt;li&gt;&lt;p&gt;test.sh &amp;&gt; filename:重定向 test.sh 的 stdout(标准输出)和 stderr(标准错误)到 filename 中。&lt;/p&gt;&lt;/li&gt;\n&lt;li&gt;&lt;p&gt;test.sh &gt;&amp;2:重定向 test.sh 的 stdout 到 stderr 中。&lt;/p&gt;&lt;/li&gt;\n&lt;li&gt;&lt;p&gt;test.sh &gt;&gt; filename:把 test.sh 的输出追加到文件 filename 中。如果 filename 不存在的话,将会被创建。&lt;/p&gt;&lt;/li&gt;\n&lt;/ul&gt;\n&lt;h2 id=\"5-管道()\"&gt;5 管道(|)&lt;/h2&gt;\n&lt;p&gt;分析左侧命令的输出,并将该输出作为右侧命令的输入。&lt;/p&gt;\n&lt;pre&gt;&lt;code class=\"shell language-shell\"&gt;ps -aux | grep 8080\n&lt;/code&gt;&lt;/pre&gt;\n&lt;h2 id=\"6-波浪号()\"&gt;6 波浪号(~)&lt;/h2&gt;\n&lt;p&gt;表示 &lt;code&gt;home&lt;/code&gt; 目录。&lt;/p&gt;",             "toc": "[{\"level\":\"3\",\"id\":\"11-命令组\",\"text\":\"1.1 命令组\"},{\"level\":\"3\",\"id\":\"12-初始化数组\",\"text\":\"1.2 初始化数组\"},{\"level\":\"2\",\"id\":\"2-大括号()\",\"text\":\"2 大括号({})\"},{\"level\":\"3\",\"id\":\"21-文件名扩展\",\"text\":\"2.1 文件名扩展\"},{\"level\":\"3\",\"id\":\"22-代码块\",\"text\":\"2.2 代码块\"},{\"level\":\"2\",\"id\":\"3-中括号\",\"text\":\"3 中括号\"},{\"level\":\"3\",\"id\":\"31-条件测试\",\"text\":\"3.1 条件测试\"},{\"level\":\"3\",\"id\":\"32-数组元素\",\"text\":\"3.2 数组元素\"},{\"level\":\"2\",\"id\":\"5-管道()\",\"text\":\"5 管道(|)\"},{\"level\":\"2\",\"id\":\"6-波浪号()\",\"text\":\"6 波浪号(~)\"}]",             "status": "publish",             "views": 26,             "likes": 0,             "isRecommended": false,             "needPassword": false,             "totalAmount": null,             "isPay": false,             "isCommentable": true,             "publishAt": "2022-01-06T08:47:14.000Z",             "createAt": "2022-01-06T08:47:14.732Z",             "updateAt": "2022-06-22T13:26:09.000Z",             "category": {                 "id": "0a28e23a-1889-4865-a154-3e1482043e56",                 "label": "Linux",                 "value": "linux",                 "createAt": "2022-01-06T08:23:59.560Z",                 "updateAt": "2022-01-06T08:23:59.560Z"             },             "tags": [                 {                     "id": "e2770db7-4614-4a08-a048-a32364dd8e54",                     "label": "bash",                     "value": "bash",                     "createAt": "2022-01-06T08:29:48.006Z",                     "updateAt": "2022-01-06T08:29:48.006Z"                 }             ]         },         {             "id": "5315a4bd-7266-43ec-99a1-dc1d5dfa7bbb",             "title": "全栈开发实践:使用 next.js + nest.js 开发完整前后端分离项目",             "cover": "https://wipi.oss-cn-shanghai.aliyuncs.com/2020-04-04/home-office-1867761_1280.jpg",             "summary": "本项目使用 next.js、nest.js 和 MySQL 从 0 到 1 搭建了一个完整的前后端分离项目。",             "content": "## 简介\n\nWipi 是一个面向个人的开源的集成文章发表、页面创建、知识小册等功能的 CMS 系统。涉及到的技术如下:\n\n- `MySQL`:数据存储\n- `next.js`:前端页面框架\n- `nest.js`:服务端框架\n- `AliyunOSS`:对象存储\n\n## 链接\n\n- [Github 源码](https://github.com/fantasticit/wipi)\n- [前台页面](https://blog.wipi.tech/)\n- [管理系统](https://admin.blog.wipi.tech/):支持访客注册\n- [接口文档](https://api.blog.wipi.tech/api/)\n\n## 功能点\n\n- 文章管理\n- 页面管理\n- 知识小册\n- 评论管理\n- 邮件管理\n- 访问统计\n- 文件管理\n- 系统设置\n\n更多功能,欢迎访问系统进行体验。\n\n## 预览\n\n&lt;ul&gt;\n  &lt;li&gt;&lt;img width=\"240\" alt=\"文章列表\" src=\"https://wipi.oss-cn-shanghai.aliyuncs.com/2021-06-13/3402/image.png\"/&gt;&lt;/li&gt;\n  &lt;li&gt;&lt;img width=\"240\" alt=\"文章详情\" src=\"https://wipi.oss-cn-shanghai.aliyuncs.com/2021-06-12/815/image.png\"/&gt;&lt;/li&gt;\n  &lt;li&gt;&lt;img width=\"240\" alt=\"动态页面\" src=\"https://wipi.oss-cn-shanghai.aliyuncs.com/2021-06-12/3124/image.png\"/&gt;&lt;/li&gt;\n  &lt;li&gt;&lt;img width=\"240\" alt=\"知识小册\" src=\"https://wipi.oss-cn-shanghai.aliyuncs.com/2021-06-12/6485/image.png\"/&gt;&lt;/li&gt;\n  &lt;li&gt;&lt;img width=\"240\" alt=\"后台管理\" src=\"https://wipi.oss-cn-shanghai.aliyuncs.com/2021-06-12/754/image.png\"/&gt;&lt;/li&gt;\n  &lt;li&gt;&lt;img width=\"240\" alt=\"文章编辑\" src=\"https://wipi.oss-cn-shanghai.aliyuncs.com/2021-06-12/6587/image.png\"/&gt;&lt;/li&gt;\n  &lt;li&gt;&lt;img width=\"240\" alt=\"小册编辑\" src=\"https://wipi.oss-cn-shanghai.aliyuncs.com/2021-06-12/1864/image.png\"/&gt;&lt;/li&gt;\n&lt;/ul&gt;\n\n## 项目运行\n\n### 数据库\n\n首先安装 `MySQL`,推荐使用 docker 进行安装。\n\n```bash\ndocker run -d --restart=always --name wipi -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root mysql:5.7\n```\n\n然后在 `MySQL` 中创建数据库。\n\n```bash\ndocker container exec -it wipi  bash;\nmysql -u root -p root;\nCREATE DATABASE  `wipi` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;\n```\n\n### 本地运行\n\n首先,clone 项目。\n\n```bash\ngit clone --depth=1 https://github.com/fantasticit/wipi.git your-project-name\n```\n\n然后,安装项目依赖。\n\n```bash\nyarn\n```\n\n- 启动项目\n\n```bash\nyarn dev\n```\n\n前台页面地址:`http://localhost:3000`。\n后台管理地址:`http://localhost:3001`。\n服务接口地址:`http://localhost:4000`。\n\n首次启动,默认创建管理员用户:admin,密码:admin(可在 `.env` 文件中进行修改)。\n[PS] 如服务端配置启动失败,请先确认 MySQL 的配置是否正确,配置文件在 `.env`。在生产环境中需要在后台正确设置系统的地址,否则二维码无法正确识别。本地开发环境中,如未填域名地址,默认为空。\n\n### 系统设置\n\n&lt;ul&gt;\n  &lt;li&gt;&lt;img width=\"240\" alt=\"系统设置\" src=\"https://wipi.oss-cn-shanghai.aliyuncs.com/2021-06-13/FURY8457EB0K41T6ABMBCSP1N9HUUFAB/image.png\"/&gt;&lt;/li&gt;\n  &lt;li&gt;&lt;img width=\"240\" alt=\"前台页面\" src=\"https://wipi.oss-cn-shanghai.aliyuncs.com/2021-06-13/ICS41W05E4XRKLEAF9YO99A48CWGRP9X/image.png\"/&gt;&lt;/li&gt;\n&lt;/ul&gt;\n\n项目初次启动时,需要在后台进行系统设置。随着内容的丰富,页面内容也会丰富起来。\n\n### 配置文件\n\n默认加载 `.env` 文件,生产环境会尝试加载 `.env.prod` 文件。\n\n```bash\nCLIENT_ASSET_PREFIX=/ # client 打包前缀地址(类似 webpack publicPath 配置)\nADMIN_ASSET_PREFIX=/ # admin 打包前缀地址\n\nADMIN_USER=admin # 默认管理员账户\nADMIN_PASSWD=admin # 默认管理员密码\nDB_HOST=127.0.0.1 # 数据库地址\nDB_PORT=3306 # 数据库端口\nDB_USER=root # 数据库用户名\nDB_PASSWD=root # 数据库密码\nDB_DATABASE=wipi # 数据库名称\n```\n\n### 项目部署\n\n生产环境部署的脚本如下:\n\n```bash\n\nnode -v\nnpm -v\n\nnpm config set registry http://registry.npmjs.org\n\nnpm i -g pm2 @nestjs/cli lerna yarn\n\nyarn\nyarn run build\nyarn run pm2\n\npm2 startup\npm2 save\n```\n\n### nginx 配置\n\n采用反向代理进行 `nginx` 配置,**同时设置 `proxy_set_header X-Real-IP $remote_addr;` 以便服务端获取到真实 ip 地址**。\n\n```bash\nupstream wipi_client {\n  server 127.0.0.1:3000;\n  keepalive 64;\n}\n\n# http -&gt; https 重定向\nserver {\n  listen  80;\n  server_name 域名;\n  rewrite ^(.*)$  https://$host$1 permanent;\n}\n\nserver {\n  listen 443 ssl;\n  server_name 域名;\n  ssl_certificate      证书存放路径;\n  ssl_certificate_key  证书存放路径;\n\n  location / {\n    proxy_http_version 1.1;\n    proxy_set_header Upgrade $http_upgrade;\n    proxy_set_header Connection \"upgrade\";\n    proxy_set_header Host $host;\n    proxy_set_header X-Nginx-Proxy true;\n    proxy_cache_bypass $http_upgrade;\n    proxy_pass http://wipi_client; #反向代理\n    proxy_set_header X-Real-IP $remote_addr;\n    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n  }\n}\n```\n\n## 资料\n\n- next.js 源码:https://github.com/vercel/next.js\n- next.js 文档:https://nextjs.org/\n- nest.js 源码:https://github.com/nestjs/nest\n- nest.js 文档:https://nestjs.com/\n",             "html": "&lt;h2 id=\"简介\"&gt;简介&lt;/h2&gt;\n&lt;p&gt;Wipi 是一个面向个人的开源的集成文章发表、页面创建、知识小册等功能的 CMS 系统。涉及到的技术如下:&lt;/p&gt;\n&lt;ul&gt;\n&lt;li&gt;&lt;code&gt;MySQL&lt;/code&gt;:数据存储&lt;/li&gt;\n&lt;li&gt;&lt;code&gt;next.js&lt;/code&gt;:前端页面框架&lt;/li&gt;\n&lt;li&gt;&lt;code&gt;nest.js&lt;/code&gt;:服务端框架&lt;/li&gt;\n&lt;li&gt;&lt;code&gt;AliyunOSS&lt;/code&gt;:对象存储&lt;/li&gt;\n&lt;/ul&gt;\n&lt;h2 id=\"链接\"&gt;链接&lt;/h2&gt;\n&lt;ul&gt;\n&lt;li&gt;&lt;a href=\"https://github.com/fantasticit/wipi\"&gt;Github 源码&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://blog.wipi.tech/\"&gt;前台页面&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://admin.blog.wipi.tech/\"&gt;管理系统&lt;/a&gt;:支持访客注册&lt;/li&gt;\n&lt;li&gt;&lt;a href=\"https://api.blog.wipi.tech/api/\"&gt;接口文档&lt;/a&gt;&lt;/li&gt;\n&lt;/ul&gt;\n&lt;h2 id=\"功能点\"&gt;功能点&lt;/h2&gt;\n&lt;ul&gt;\n&lt;li&gt;文章管理&lt;/li&gt;\n&lt;li&gt;页面管理&lt;/li&gt;\n&lt;li&gt;知识小册&lt;/li&gt;\n&lt;li&gt;评论管理&lt;/li&gt;\n&lt;li&gt;邮件管理&lt;/li&gt;\n&lt;li&gt;访问统计&lt;/li&gt;\n&lt;li&gt;文件管理&lt;/li&gt;\n&lt;li&gt;系统设置&lt;/li&gt;\n&lt;/ul&gt;\n&lt;p&gt;更多功能,欢迎访问系统进行体验。&lt;/p&gt;\n&lt;h2 id=\"预览\"&gt;预览&lt;/h2&gt;\n&lt;ul&gt;\n  &lt;li&gt;&lt;img width=\"240\" alt=\"文章列表\" src=\"https://wipi.oss-cn-shanghai.aliyuncs.com/2021-06-13/3402/image.png\"/&gt;&lt;/li&gt;\n  &lt;li&gt;&lt;img width=\"240\" alt=\"文章详情\" src=\"https://wipi.oss-cn-shanghai.aliyuncs.com/2021-06-12/815/image.png\"/&gt;&lt;/li&gt;\n  &lt;li&gt;&lt;img width=\"240\" alt=\"动态页面\" src=\"https://wipi.oss-cn-shanghai.aliyuncs.com/2021-06-12/3124/image.png\"/&gt;&lt;/li&gt;\n  &lt;li&gt;&lt;img width=\"240\" alt=\"知识小册\" src=\"https://wipi.oss-cn-shanghai.aliyuncs.com/2021-06-12/6485/image.png\"/&gt;&lt;/li&gt;\n  &lt;li&gt;&lt;img width=\"240\" alt=\"后台管理\" src=\"https://wipi.oss-cn-shanghai.aliyuncs.com/2021-06-12/754/image.png\"/&gt;&lt;/li&gt;\n  &lt;li&gt;&lt;img width=\"240\" alt=\"文章编辑\" src=\"https://wipi.oss-cn-shanghai.aliyuncs.com/2021-06-12/6587/image.png\"/&gt;&lt;/li&gt;\n  &lt;li&gt;&lt;img width=\"240\" alt=\"小册编辑\" src=\"https://wipi.oss-cn-shanghai.aliyuncs.com/2021-06-12/1864/image.png\"/&gt;&lt;/li&gt;\n&lt;/ul&gt;\n&lt;h2 id=\"项目运行\"&gt;项目运行&lt;/h2&gt;\n&lt;h3 id=\"数据库\"&gt;数据库&lt;/h3&gt;\n&lt;p&gt;首先安装 &lt;code&gt;MySQL&lt;/code&gt;,推荐使用 docker 进行安装。&lt;/p&gt;\n&lt;pre&gt;&lt;code class=\"bash language-bash\"&gt;docker run -d --restart=always --name wipi -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root mysql:5.7\n&lt;/code&gt;&lt;/pre&gt;\n&lt;p&gt;然后在 &lt;code&gt;MySQL&lt;/code&gt; 中创建数据库。&lt;/p&gt;\n&lt;pre&gt;&lt;code class=\"bash language-bash\"&gt;docker container exec -it wipi  bash;\nmysql -u root -p root;\nCREATE DATABASE  `wipi` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;\n&lt;/code&gt;&lt;/pre&gt;\n&lt;h3 id=\"本地运行\"&gt;本地运行&lt;/h3&gt;\n&lt;p&gt;首先,clone 项目。&lt;/p&gt;\n&lt;pre&gt;&lt;code class=\"bash language-bash\"&gt;git clone --depth=1 https://github.com/fantasticit/wipi.git your-project-name\n&lt;/code&gt;&lt;/pre&gt;\n&lt;p&gt;然后,安装项目依赖。&lt;/p&gt;\n&lt;pre&gt;&lt;code class=\"bash language-bash\"&gt;yarn\n&lt;/code&gt;&lt;/pre&gt;\n&lt;ul&gt;\n&lt;li&gt;启动项目&lt;/li&gt;\n&lt;/ul&gt;\n&lt;pre&gt;&lt;code class=\"bash language-bash\"&gt;yarn dev\n&lt;/code&gt;&lt;/pre&gt;\n&lt;p&gt;前台页面地址:&lt;code&gt;http://localhost:3000&lt;/code&gt;。&lt;br /&gt;\n后台管理地址:&lt;code&gt;http://localhost:3001&lt;/code&gt;。&lt;br /&gt;\n服务接口地址:&lt;code&gt;http://localhost:4000&lt;/code&gt;。&lt;/p&gt;\n&lt;p&gt;首次启动,默认创建管理员用户:admin,密码:admin(可在 &lt;code&gt;.env&lt;/code&gt; 文件中进行修改)。&lt;br /&gt;\n[PS] 如服务端配置启动失败,请先确认 MySQL 的配置是否正确,配置文件在 &lt;code&gt;.env&lt;/code&gt;。在生产环境中需要在后台正确设置系统的地址,否则二维码无法正确识别。本地开发环境中,如未填域名地址,默认为空。&lt;/p&gt;\n&lt;h3 id=\"系统设置\"&gt;系统设置&lt;/h3&gt;\n&lt;ul&gt;\n  &lt;li&gt;&lt;img width=\"240\" alt=\"系统设置\" src=\"https://wipi.oss-cn-shanghai.aliyuncs.com/2021-06-13/FURY8457EB0K41T6ABMBCSP1N9HUUFAB/image.png\"/&gt;&lt;/li&gt;\n  &lt;li&gt;&lt;img width=\"240\" alt=\"前台页面\" src=\"https://wipi.oss-cn-shanghai.aliyuncs.com/2021-06-13/ICS41W05E4XRKLEAF9YO99A48CWGRP9X/image.png\"/&gt;&lt;/li&gt;\n&lt;/ul&gt;\n&lt;p&gt;项目初次启动时,需要在后台进行系统设置。随着内容的丰富,页面内容也会丰富起来。&lt;/p&gt;\n&lt;h3 id=\"配置文件\"&gt;配置文件&lt;/h3&gt;\n&lt;p&gt;默认加载 &lt;code&gt;.env&lt;/code&gt; 文件,生产环境会尝试加载 &lt;code&gt;.env.prod&lt;/code&gt; 文件。&lt;/p&gt;\n&lt;pre&gt;&lt;code class=\"bash language-bash\"&gt;CLIENT_ASSET_PREFIX=/ # client 打包前缀地址(类似 webpack publicPath 配置)\nADMIN_ASSET_PREFIX=/ # admin 打包前缀地址\n\nADMIN_USER=admin # 默认管理员账户\nADMIN_PASSWD=admin # 默认管理员密码\nDB_HOST=127.0.0.1 # 数据库地址\nDB_PORT=3306 # 数据库端口\nDB_USER=root # 数据库用户名\nDB_PASSWD=root # 数据库密码\nDB_DATABASE=wipi # 数据库名称\n&lt;/code&gt;&lt;/pre&gt;\n&lt;h3 id=\"项目部署\"&gt;项目部署&lt;/h3&gt;\n&lt;p&gt;生产环境部署的脚本如下:&lt;/p&gt;\n&lt;pre&gt;&lt;code class=\"bash language-bash\"&gt;node -v\nnpm -v\n\nnpm config set registry http://registry.npmjs.org\n\nnpm i -g pm2 @nestjs/cli lerna yarn\n\nyarn\nyarn run build\nyarn run pm2\n\npm2 startup\npm2 save\n&lt;/code&gt;&lt;/pre&gt;\n&lt;h3 id=\"nginx-配置\"&gt;nginx 配置&lt;/h3&gt;\n&lt;p&gt;采用反向代理进行 &lt;code&gt;nginx&lt;/code&gt; 配置,&lt;strong&gt;同时设置 &lt;code&gt;proxy_set_header X-Real-IP $remote_addr;&lt;/code&gt; 以便服务端获取到真实 ip 地址&lt;/strong&gt;。&lt;/p&gt;\n&lt;pre&gt;&lt;code class=\"bash language-bash\"&gt;upstream wipi_client {\n  server 127.0.0.1:3000;\n  keepalive 64;\n}\n\n# http -&gt; https 重定向\nserver {\n  listen  80;\n  server_name 域名;\n  rewrite ^(.*)$  https://$host$1 permanent;\n}\n\nserver {\n  listen 443 ssl;\n  server_name 域名;\n  ssl_certificate      证书存放路径;\n  ssl_certificate_key  证书存放路径;\n\n  location / {\n    proxy_http_version 1.1;\n    proxy_set_header Upgrade $http_upgrade;\n    proxy_set_header Connection \"upgrade\";\n    proxy_set_header Host $host;\n    proxy_set_header X-Nginx-Proxy true;\n    proxy_cache_bypass $http_upgrade;\n    proxy_pass http://wipi_client; #反向代理\n    proxy_set_header X-Real-IP $remote_addr;\n    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n  }\n}\n&lt;/code&gt;&lt;/pre&gt;\n&lt;h2 id=\"资料\"&gt;资料&lt;/h2&gt;\n&lt;ul&gt;\n&lt;li&gt;next.js 源码:&lt;a href=\"https://github.com/vercel/next.js\"&gt;https://github.com/vercel/next.js&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;next.js 文档:&lt;a href=\"https://nextjs.org/\"&gt;https://nextjs.org/&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;nest.js 源码:&lt;a href=\"https://github.com/nestjs/nest\"&gt;https://github.com/nestjs/nest&lt;/a&gt;&lt;/li&gt;\n&lt;li&gt;nest.js 文档:&lt;a href=\"https://nestjs.com/\"&gt;https://nestjs.com/&lt;/a&gt;&lt;/li&gt;\n&lt;/ul&gt;",             "toc": "[{\"level\":\"2\",\"id\":\"简介\",\"text\":\"简介\"},{\"level\":\"2\",\"id\":\"链接\",\"text\":\"链接\"},{\"level\":\"2\",\"id\":\"功能点\",\"text\":\"功能点\"},{\"level\":\"2\",\"id\":\"预览\",\"text\":\"预览\"},{\"level\":\"2\",\"id\":\"项目运行\",\"text\":\"项目运行\"},{\"level\":\"3\",\"id\":\"数据库\",\"text\":\"数据库\"},{\"level\":\"3\",\"id\":\"本地运行\",\"text\":\"本地运行\"},{\"level\":\"3\",\"id\":\"系统设置\",\"text\":\"系统设置\"},{\"level\":\"3\",\"id\":\"配置文件\",\"text\":\"配置文件\"},{\"level\":\"3\",\"id\":\"项目部署\",\"text\":\"项目部署\"},{\"level\":\"3\",\"id\":\"nginx-配置\",\"text\":\"nginx 配置\"},{\"level\":\"2\",\"id\":\"资料\",\"text\":\"资料\"}]",             "status": "publish",             "views": 36,             "likes": 0,             "isRecommended": false,             "needPassword": false,             "totalAmount": null,             "isPay": false,             "isCommentable": true,             "publishAt": "2022-01-06T08:44:10.000Z",             "createAt": "2022-01-06T08:44:10.591Z",             "updateAt": "2022-06-22T13:09:52.000Z",             "category": {                 "id": "b76c093b-65ec-45e7-9218-071f17f33136",                 "label": "前端",                 "value": "front",                 "createAt": "2021-12-31T00:32:45.075Z",                 "updateAt": "2022-01-06T08:06:01.000Z"             },             "tags": []         },         {             "id": "ff96c0a7-d11f-486c-999a-b4fadfa0d10b",             "title": "bash 中的特殊字符(上)",             "cover": "https://wipi.oss-cn-shanghai.aliyuncs.com/2020-03-16/2XLH7SX1QZ7R4VTGSDVKR0/697719-637082269193623952-16x9.jpg",             "summary": "bash 脚本编程系列之:bash 中的特殊字符(上)。",             "content": "\n## 1 注释(#)\n\n行首以 `#` 开头(除 `#!` 之外)的是注释。`#!` 用于指定当前脚本的解释器。\n\n```shell\n#!/bin/bash\n\necho 'The # here is not comment'\necho The \\# here is not comment  # 注意转义字符\necho The # here is not comment\n```\n\n## 2 分号(;)\n\n### 2.1 命令分隔符\n\n使用分号(;)可以在同一行写多个命令。\n\n```shell\n#!/bin/bash\n\necho 'Now start...';\nfilename=semi.sh\nif [ -e \"$filename\" ]; then\n  echo \"File $filename exists.\"; cp $filename $filename.bak # cp 复制命令\nelse\n  echo \"File $filename not found\"; touch $filename          # touch 创建文件\nfi;\n  echo \"End\"\n```\n\n### 2.2 终止 `case` 选项\n\n使用双分号(;;)可以终止 `case` 选项(类似于其他语言中的 `break`)。\n\n```shell\n#!/bin/bash\n\nchar=b\n\ncase \"$char\" in\n  [a-z]) echo \"letter\";;\n  [0-9]) echo \"number\";;\nesac\n```\n\n## 3 点号(.)\n\n等价于 `source` 命令(bash 中的 `source` 命令用于在当前 `bash` 环境下读取并执行 指定的 sh 文件)。\n\n```shell\n$ source hello.sh\nhi\n$ . hello.sh\nhi\n```\n\n## 4 引号\n\n### 4.1 双引号(\")\n\n由双引号括起来的字符,除$(美元符号)、\\(反斜杠)、’(单引号)、和”(双引号)这几个字符仍是特殊字符并保留其特殊功能外,其余字符仍作为普通字符对待。\n\n### 4.2 单引号(')\n\n由单引号括起来的字符都作为普通字符出现。特殊字符用单引号括起来以后,也会失去原有意义,而只作为普通字符解释。\n\n### 4.3 区别\n\n举个例子:\n\n```shell\nname=difference\n\necho '$name' # name\necho \"$name\" # difference\n```\n\n同样是 `$name`,单引号则认为是字符串,而双引号则认为是一个变量。\n\n## 5 斜线和反斜线\n\n### 5.1 斜线(/)\n\n文件名路径分隔符。分隔文件名不同的部分(如`/home/repo`)。也可以用来作为除法算术操作符。在 linux 中表示路径的时候,许多个/跟一个/是一样的。`/home/repo` 等同于 `////home///repo`\n\n### 5.2 反斜线(\\)\n\n转义字符。\n\n## 6 反引号\n\n反引号(\\`)中的命令会优先执行(推荐使用`$()`代替`\\``)。\n\n```shell\ncp `mkdir temp` hello.sh temp  # 先创建 temp 文件夹,再将 hello.sh 复制到 temp 文件夹\ncp $(mkdir temp) hello.sh temp\n```\n\n## 7 冒号(:)\n\n### 7.1 空命令\n\n等价于 “NOP”(`no op`,该命令什么也不做)。`:` 命令是 bash 内建命令,退出码是 `0`。\n\n```shell\n#!/bin/bash\n\nnum=5\n\nif [ $num -gt 2 ] # gt 表示 greater than(大于)\n  then :          # 什么都不做,退出分支\nelse\n  echo \"$num\"\nfi\n```\n\n### 7.2 其他功能\n\n与 `&gt;` 重定向操作符结合使用时,可以清空一个文件,但是不会修改这个文件的权限。如果这个文件之前不存在,则先创建这个文件。\n\n```shell\n: &gt; null.sh\n```\n\n## 8 问号(?)\n\n在双括号中就是三元操作符。\n\n```shell\n#!/bin/bash\n\n((t=8&lt;10?15:5))\necho $t\n```\n\n## 9 美元符号($)\n\n变量替换。\n\n```shell\n#!/bin/bash\n\na=10\necho $a\n```\n",             "html": "&lt;h2 id=\"1-注释()\"&gt;1 注释(#)&lt;/h2&gt;\n&lt;p&gt;行首以 &lt;code&gt;#&lt;/code&gt; 开头(除 &lt;code&gt;#!&lt;/code&gt; 之外)的是注释。&lt;code&gt;#!&lt;/code&gt; 用于指定当前脚本的解释器。&lt;/p&gt;\n&lt;pre&gt;&lt;code class=\"shell language-shell\"&gt;#!/bin/bash\n\necho 'The # here is not comment'\necho The \\# here is not comment  # 注意转义字符\necho The # here is not comment\n&lt;/code&gt;&lt;/pre&gt;\n&lt;h2 id=\"2-分号()\"&gt;2 分号(;)&lt;/h2&gt;\n&lt;h3 id=\"21-命令分隔符\"&gt;2.1 命令分隔符&lt;/h3&gt;\n&lt;p&gt;使用分号(;)可以在同一行写多个命令。&lt;/p&gt;\n&lt;pre&gt;&lt;code class=\"shell language-shell\"&gt;#!/bin/bash\n\necho 'Now start...';\nfilename=semi.sh\nif [ -e \"$filename\" ]; then\n  echo \"File $filename exists.\"; cp $filename $filename.bak # cp 复制命令\nelse\n  echo \"File $filename not found\"; touch $filename          # touch 创建文件\nfi;\n  echo \"End\"\n&lt;/code&gt;&lt;/pre&gt;\n&lt;h3 id=\"22-终止-case-选项\"&gt;2.2 终止 &lt;code&gt;case&lt;/code&gt; 选项&lt;/h3&gt;\n&lt;p&gt;使用双分号(;;)可以终止 &lt;code&gt;case&lt;/code&gt; 选项(类似于其他语言中的 &lt;code&gt;break&lt;/code&gt;)。&lt;/p&gt;\n&lt;pre&gt;&lt;code class=\"shell language-shell\"&gt;#!/bin/bash\n\nchar=b\n\ncase \"$char\" in\n  [a-z]) echo \"letter\";;\n  [0-9]) echo \"number\";;\nesac\n&lt;/code&gt;&lt;/pre&gt;\n&lt;h2 id=\"3-点号()\"&gt;3 点号(.)&lt;/h2&gt;\n&lt;p&gt;等价于 &lt;code&gt;source&lt;/code&gt; 命令(bash 中的 &lt;code&gt;source&lt;/code&gt; 命令用于在当前 &lt;code&gt;bash&lt;/code&gt; 环境下读取并执行 指定的 sh 文件)。&lt;/p&gt;\n&lt;pre&gt;&lt;code class=\"shell language-shell\"&gt;$ source hello.sh\nhi\n$ . hello.sh\nhi\n&lt;/code&gt;&lt;/pre&gt;\n&lt;h2 id=\"4-引号\"&gt;4 引号&lt;/h2&gt;\n&lt;h3 id=\"41-双引号()\"&gt;4.1 双引号(\")&lt;/h3&gt;\n&lt;p&gt;由双引号括起来的字符,除$(美元符号)、\\(反斜杠)、’(单引号)、和”(双引号)这几个字符仍是特殊字符并保留其特殊功能外,其余字符仍作为普通字符对待。&lt;/p&gt;\n&lt;h3 id=\"42-单引号()\"&gt;4.2 单引号(')&lt;/h3&gt;\n&lt;p&gt;由单引号括起来的字符都作为普通字符出现。特殊字符用单引号括起来以后,也会失去原有意义,而只作为普通字符解释。&lt;/p&gt;\n&lt;h3 id=\"43-区别\"&gt;4.3 区别&lt;/h3&gt;\n&lt;p&gt;举个例子:&lt;/p&gt;\n&lt;pre&gt;&lt;code class=\"shell language-shell\"&gt;name=difference\n\necho '$name' # name\necho \"$name\" # difference\n&lt;/code&gt;&lt;/pre&gt;\n&lt;p&gt;同样是 &lt;code&gt;$name&lt;/code&gt;,单引号则认为是字符串,而双引号则认为是一个变量。&lt;/p&gt;\n&lt;h2 id=\"5-斜线和反斜线\"&gt;5 斜线和反斜线&lt;/h2&gt;\n&lt;h3 id=\"51-斜线()\"&gt;5.1 斜线(/)&lt;/h3&gt;\n&lt;p&gt;文件名路径分隔符。分隔文件名不同的部分(如&lt;code&gt;/home/repo&lt;/code&gt;)。也可以用来作为除法算术操作符。在 linux 中表示路径的时候,许多个/跟一个/是一样的。&lt;code&gt;/home/repo&lt;/code&gt; 等同于 &lt;code&gt;////home///repo&lt;/code&gt;&lt;/p&gt;\n&lt;h3 id=\"52-反斜线()\"&gt;5.2 反斜线(\\)&lt;/h3&gt;\n&lt;p&gt;转义字符。&lt;/p&gt;\n&lt;h2 id=\"6-反引号\"&gt;6 反引号&lt;/h2&gt;\n&lt;p&gt;反引号(`)中的命令会优先执行(推荐使用&lt;code&gt;$()&lt;/code&gt;代替```)。&lt;/p&gt;\n&lt;pre&gt;&lt;code class=\"shell language-shell\"&gt;cp `mkdir temp` hello.sh temp  # 先创建 temp 文件夹,再将 hello.sh 复制到 temp 文件夹\ncp $(mkdir temp) hello.sh temp\n&lt;/code&gt;&lt;/pre&gt;\n&lt;h2 id=\"7-冒号()\"&gt;7 冒号(:)&lt;/h2&gt;\n&lt;h3 id=\"71-空命令\"&gt;7.1 空命令&lt;/h3&gt;\n&lt;p&gt;等价于 “NOP”(&lt;code&gt;no op&lt;/code&gt;,该命令什么也不做)。&lt;code&gt;:&lt;/code&gt; 命令是 bash 内建命令,退出码是 &lt;code&gt;0&lt;/code&gt;。&lt;/p&gt;\n&lt;pre&gt;&lt;code class=\"shell language-shell\"&gt;#!/bin/bash\n\nnum=5\n\nif [ $num -gt 2 ] # gt 表示 greater than(大于)\n  then :          # 什么都不做,退出分支\nelse\n  echo \"$num\"\nfi\n&lt;/code&gt;&lt;/pre&gt;\n&lt;h3 id=\"72-其他功能\"&gt;7.2 其他功能&lt;/h3&gt;\n&lt;p&gt;与 &lt;code&gt;&gt;&lt;/code&gt; 重定向操作符结合使用时,可以清空一个文件,但是不会修改这个文件的权限。如果这个文件之前不存在,则先创建这个文件。&lt;/p&gt;\n&lt;pre&gt;&lt;code class=\"shell language-shell\"&gt;: &gt; null.sh\n&lt;/code&gt;&lt;/pre&gt;\n&lt;h2 id=\"8-问号()\"&gt;8 问号(?)&lt;/h2&gt;\n&lt;p&gt;在双括号中就是三元操作符。&lt;/p&gt;\n&lt;pre&gt;&lt;code class=\"shell language-shell\"&gt;#!/bin/bash\n\n((t=8&lt;10?15:5))\necho $t\n&lt;/code&gt;&lt;/pre&gt;\n&lt;h2 id=\"9-美元符号()\"&gt;9 美元符号($)&lt;/h2&gt;\n&lt;p&gt;变量替换。&lt;/p&gt;\n&lt;pre&gt;&lt;code class=\"shell language-shell\"&gt;#!/bin/bash\n\na=10\necho $a\n&lt;/code&gt;&lt;/pre&gt;",             "toc": "[{\"level\":\"2\",\"id\":\"1-注释()\",\"text\":\"1 注释(#)\"},{\"level\":\"2\",\"id\":\"2-分号()\",\"text\":\"2 分号(;)\"},{\"level\":\"3\",\"id\":\"21-命令分隔符\",\"text\":\"2.1 命令分隔符\"},{\"level\":\"2\",\"id\":\"3-点号()\",\"text\":\"3 点号(.)\"},{\"level\":\"2\",\"id\":\"4-引号\",\"text\":\"4 引号\"},{\"level\":\"3\",\"id\":\"41-双引号()\",\"text\":\"4.1 双引号(\\\")\"},{\"level\":\"3\",\"id\":\"42-单引号()\",\"text\":\"4.2 单引号(')\"},{\"level\":\"3\",\"id\":\"43-区别\",\"text\":\"4.3 区别\"},{\"level\":\"2\",\"id\":\"5-斜线和反斜线\",\"text\":\"5 斜线和反斜线\"},{\"level\":\"3\",\"id\":\"51-斜线()\",\"text\":\"5.1 斜线(/)\"},{\"level\":\"3\",\"id\":\"52-反斜线()\",\"text\":\"5.2 反斜线(\\\\)\"},{\"level\":\"2\",\"id\":\"6-反引号\",\"text\":\"6 反引号\"},{\"level\":\"2\",\"id\":\"7-冒号()\",\"text\":\"7 冒号(:)\"},{\"level\":\"3\",\"id\":\"71-空命令\",\"text\":\"7.1 空命令\"},{\"level\":\"3\",\"id\":\"72-其他功能\",\"text\":\"7.2 其他功能\"},{\"level\":\"2\",\"id\":\"8-问号()\",\"text\":\"8 问号(?)\"},{\"level\":\"2\",\"id\":\"9-美元符号()\",\"text\":\"9 美元符号($)\"}]",             "status": "publish",             "views": 22,             "likes": 0,             "isRecommended": false,             "needPassword": false,             "totalAmount": null,             "isPay": false,             "isCommentable": true,             "publishAt": "2022-01-06T08:38:03.000Z",             "createAt": "2022-01-06T08:38:03.373Z",             "updateAt": "2022-06-22T07:36:22.000Z",             "category": {                 "id": "0a28e23a-1889-4865-a154-3e1482043e56",                 "label": "Linux",                 "value": "linux",                 "createAt": "2022-01-06T08:23:59.560Z",                 "updateAt": "2022-01-06T08:23:59.560Z"             },             "tags": [                 {                     "id": "e2770db7-4614-4a08-a048-a32364dd8e54",                     "label": "bash",                     "value": "bash",                     "createAt": "2022-01-06T08:29:48.006Z",                     "updateAt": "2022-01-06T08:29:48.006Z"                 }             ]         }     ] }</code></pre> <h5>返回参数说明</h5> <table> <thead> <tr> <th style="text-align: left;">参数名</th> <th style="text-align: left;">类型</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">groupid</td> <td style="text-align: left;">int</td> <td>用户组id,1:超级管理员;2:普通用户</td> </tr> </tbody> </table> <h5>备注</h5> <ul> <li>更多返回错误代码请看首页的错误代码描述</li> </ul>

页面列表

ITEM_HTML