mirror of
https://github.com/jaywcjlove/reference.git
synced 2025-06-19 13:41:21 +08:00
Compare commits
24 Commits
Author | SHA1 | Date | |
---|---|---|---|
bafc15d17e | |||
68069fbf01 | |||
ca3cf85666 | |||
040af8095f | |||
d1dea83330 | |||
4503b28837 | |||
02d0a495a6 | |||
c66d1c0294 | |||
f2d43d65df | |||
009c50760c | |||
f683ca5294 | |||
04369f05d3 | |||
ae04c01eb4 | |||
e66c1c57fd | |||
c7df917009 | |||
a5744c23b7 | |||
d8ab87b0e0 | |||
e87ce59a88 | |||
428d8488f3 | |||
e84c69f8b9 | |||
3cdc2685e6 | |||
df3e04ba92 | |||
4662fb8071 | |||
600dbc6fef |
25
.dockerignore
Normal file
25
.dockerignore
Normal file
@ -0,0 +1,25 @@
|
||||
.github
|
||||
.husky
|
||||
docs
|
||||
scripts
|
||||
node_modules
|
||||
package-lock.json
|
||||
|
||||
.DS_Store
|
||||
.cache
|
||||
.vscode
|
||||
.idea
|
||||
.snap
|
||||
.env
|
||||
|
||||
*.bak
|
||||
*.tem
|
||||
*.temp
|
||||
#.swp
|
||||
*.*~
|
||||
~*.*
|
||||
|
||||
# IDEA
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
@ -67,7 +67,7 @@ Contributing 贡献
|
||||
[Django](./docs/djiango.md)<!--rehype:style=background: rgb(12 75 51/var(\-\-bg\-opacity));&class=contributing-->
|
||||
```
|
||||
|
||||
添加 `contributing` 类名,会在卡片下方添加 _`👆待完善需要您的参与`_
|
||||
添加 `contributing` 类名,会在卡片下方添加 _`👆待完善需要您的参与`_,添加 `data-info=👆看看还缺点儿什么?`,更换默认提示文本。
|
||||
|
||||
|
||||
```markdown
|
||||
|
32
README.md
32
README.md
@ -14,20 +14,32 @@ Quick Reference
|
||||
|
||||
为开发人员分享快速参考备忘清单【速查表】 _(主要是方便自己)_,在看到 [Reference](https://github.com/Randy8080/reference) 快速参考备忘单,感觉非常简单,造轮子使命感突然来了,造个中文版本的,为了方便自己的技术栈查阅,立马撸起来 :)。如果您发现此处的备忘单不合适,您可以通过提交 [PR](https://github.com/jaywcjlove/reference/blob/main/CONTRIBUTING.md) 来修复它或提供更好的备忘清单,只针对【中文】用户。以下是开源天使提供的一些备忘清单和快速参考 :)。
|
||||
|
||||
## 正在建设中...
|
||||
|
||||
坑已挖,需要您的参与完善和贡献!🙏
|
||||
<!--rehype:style=padding-bottom: 23px;-->
|
||||
|
||||
[CMake](./docs/cmake.md)<!--rehype:style=background: rgb(92 107 192/var(\-\-bg\-opacity));&class=contributing-->
|
||||
[Django](./docs/djiango.md)<!--rehype:style=background: rgb(12 75 51/var(\-\-bg\-opacity));&class=contributing tag&data-lang=Python-->
|
||||
[FFmpeg](./docs/ffmpeg.md)<!--rehype:style=background: rgb(0 193 9/var(\-\-bg\-opacity));&class=contributing-->
|
||||
[MATLAB](./docs/matlab.md)<!--rehype:style=background: rgb(0 118 168/var(\-\-bg\-opacity));&class=contributing-->
|
||||
[Vue 3 ](./docs/vue.md)<!--rehype:style=background: rgb(64 184 131/var(\-\-bg\-opacity));&class=contributing-->
|
||||
<!--rehype:class=home-card-->
|
||||
|
||||
## 编程
|
||||
|
||||
[Bash](./docs/bash.md)<!--rehype:style=background: rgb(72 143 223/var(\-\-bg\-opacity));-->
|
||||
[C](./docs/c.md)<!--rehype:style=background: rgb(92 107 192/var(\-\-bg\-opacity));-->
|
||||
[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));&class=tag&data-lang=Docker-->
|
||||
[Django](./docs/djiango.md)<!--rehype:style=background: rgb(12 75 51/var(\-\-bg\-opacity));&class=contributing tag&data-lang=Python-->
|
||||
[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-->
|
||||
[Java](./docs/java.md)<!--rehype:style=background: rgb(211 55 49/var(\-\-bg\-opacity));&class=contributing&data-info=👆看看还缺点儿什么?-->
|
||||
[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));&class=tag&data-lang=SQL-->
|
||||
[Python](./docs/python.md)<!--rehype:style=background: rgb(240 81 57/var(\-\-bg\-opacity));-->
|
||||
[Rust](./docs/rust.md)<!--rehype:style=background: rgb(71 71 71/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));&class=tag&data-lang=swift-->
|
||||
[TOML](./docs/toml.md)<!--rehype:style=background: rgb(132 132 132/var(\-\-bg\-opacity));-->
|
||||
@ -45,29 +57,28 @@ Quick Reference
|
||||
[Sass](./docs/sass.md)<!--rehype:style=background: rgb(207 100 154/var(\-\-bg\-opacity));&class=tag&data-lang=CSS-->
|
||||
[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));-->
|
||||
[Lerna](./docs/lerna.md)<!--rehype:style=background: rgb(192 132 252/var(\-\-bg\-opacity));-->
|
||||
[Less.js](./docs/lessjs.md)<!--rehype:style=background: rgb(29 54 93/var(\-\-bg\-opacity));&class=tag&data-lang=CSS-->
|
||||
[npm](./docs/npm.md)<!--rehype:style=background: rgb(203 2 0/var(\-\-bg\-opacity));-->
|
||||
[package.json](./docs/package.json.md)<!--rehype:style=background: rgb(132 132 132/var(\-\-bg\-opacity));-->
|
||||
[React](./docs/react.md)<!--rehype:style=background: rgb(34 143 173/var(\-\-bg\-opacity));-->
|
||||
[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-->
|
||||
[Yarn](./docs/yarn.md)<!--rehype:style=background: rgb(64 184 131/var(\-\-bg\-opacity));-->
|
||||
<!--rehype:class=home-card-->
|
||||
|
||||
## Nodejs
|
||||
|
||||
[Express.js](./docs/expressjs.md)<!--rehype:style=background: rgb(95 151 206/var(\-\-bg\-opacity));-->
|
||||
[Jest](./docs/jest.md)<!--rehype:style=background: rgb(153 66 91/var(\-\-bg\-opacity));-->
|
||||
[Koa.js](./docs/koajs.md)<!--rehype:style=background: rgb(95 151 206/var(\-\-bg\-opacity));-->
|
||||
[Lerna](./docs/lerna.md)<!--rehype:style=background: rgb(192 132 252/var(\-\-bg\-opacity));-->
|
||||
[npm](./docs/npm.md)<!--rehype:style=background: rgb(203 2 0/var(\-\-bg\-opacity));-->
|
||||
[package.json](./docs/package.json.md)<!--rehype:style=background: rgb(132 132 132/var(\-\-bg\-opacity));-->
|
||||
[Yarn](./docs/yarn.md)<!--rehype:style=background: rgb(64 184 131/var(\-\-bg\-opacity));-->
|
||||
<!--rehype:class=home-card-->
|
||||
|
||||
## 工具
|
||||
|
||||
[Emacs](./docs/emacs.md)<!--rehype:style=background: rgb(0 193 9/var(\-\-bg\-opacity));-->
|
||||
[FFmpeg](./docs/ffmpeg.md)<!--rehype:style=background: rgb(0 193 9/var(\-\-bg\-opacity));&class=contributing-->
|
||||
[Gmail](./docs/gmail.md)<!--rehype:style=background: rgb(0 193 9/var(\-\-bg\-opacity));-->
|
||||
[nginx](./docs/nginx.md)<!--rehype:style=background: rgb(0 193 9/var(\-\-bg\-opacity));-->
|
||||
[Semver](./docs/semver.md)<!--rehype:style=background: rgb(106 111 141/var(\-\-bg\-opacity));-->
|
||||
[Sketch](./docs/sketch.md)<!--rehype:style=background: rgb(223 148 0/var(\-\-bg\-opacity));-->
|
||||
@ -80,7 +91,10 @@ Quick Reference
|
||||
|
||||
## Linux 命令
|
||||
|
||||
[Ansible](./docs/ansible.md)<!--rehype:style=background: rgb(99 99 99/var(\-\-bg\-opacity));&class=contributing&data-info=👆看看还缺点儿什么?-->
|
||||
[Awk](./docs/awk.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[Conan](./docs/conan.md)<!--rehype:style=background: rgb(0 193 9/var(\-\-bg\-opacity));&class=tag&data-lang=C/C++-->
|
||||
[Cargo](./docs/cargo.md)<!--rehype:style=background: rgb(71 71 71/var(\-\-bg\-opacity));&class=tag&data-lang=Rust-->
|
||||
[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));-->
|
||||
|
366
docs/ansible.md
Normal file
366
docs/ansible.md
Normal file
@ -0,0 +1,366 @@
|
||||
Ansible 备忘清单
|
||||
====
|
||||
|
||||
此快速参考备忘单提供了使用 [Ansible](https://ansible.com) 的各种方法。
|
||||
|
||||
入门
|
||||
---
|
||||
|
||||
### 安装
|
||||
|
||||
安装命令 | 环境
|
||||
:-|-
|
||||
`brew install ansible` | macos
|
||||
`yum install -y ansible` | centos
|
||||
`pip install ansible` | python
|
||||
|
||||
---
|
||||
|
||||
- [Ansible 官方文档](https://docs.ansible.com)
|
||||
|
||||
|
||||
### 配置位置
|
||||
|
||||
文件路径 | 说明
|
||||
:-|-
|
||||
`/etc/ansible/ansible.cfg` | 系统范围的配置
|
||||
`~/ansible.cfg` | 用户特定的配置
|
||||
`$pwd/ansible.cfg` | 当前目录下的配置
|
||||
|
||||
|
||||
### Inventory文件(hosts列表)
|
||||
|
||||
#### 静态Inventory
|
||||
|
||||
`/etc/ansible/hosts`
|
||||
```INI
|
||||
mail.example.com
|
||||
|
||||
[webservers]
|
||||
foo.example.com
|
||||
bar.example.com
|
||||
```
|
||||
|
||||
## 命令行(ad-hoc)
|
||||
|
||||
### ansible
|
||||
|
||||
检查Inventory是否生效
|
||||
|
||||
```shell
|
||||
ansible all --list-hosts
|
||||
```
|
||||
ping所有目标
|
||||
|
||||
```shell
|
||||
$ ansible all -m ping
|
||||
```
|
||||
|
||||
ping本地(不使用SSH连接)
|
||||
|
||||
```shell
|
||||
$ ansible all -i localhost, -e '{"ansible_connection": "local"}' -m ping
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
本地执行命令
|
||||
|
||||
```shell
|
||||
$ ansible all -i localhost, -e '{"ansible_connection": "local"}' -a 'hostname'
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
获取本地主机的信息
|
||||
|
||||
```shell
|
||||
$ ansible all -i localhost, -e '{"ansible_connection": "local"}' -m setup
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
获取远程到本地
|
||||
|
||||
```shell
|
||||
$ ansible target -m fetch -a "src=/tmp/seq dest=/tmp/seq"
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
拷贝本地到远程
|
||||
|
||||
```shell
|
||||
$ ansible target -m copy -a "src=/tmp/seq dest=/tmp/seq"
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### Ansible 命令帮助
|
||||
<!--rehype:wrap-class=col-span-2 row-span-3-->
|
||||
|
||||
```bash
|
||||
$ ansible
|
||||
$ ansible <host-pattern> [options]
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`-a MODULE_ARGS`, `--args=MODULE_ARGS` | 模块参数
|
||||
`--ask-vault-pass` | 询问保险库密码
|
||||
`-B SECONDS`, `--background=SECONDS` | 异步运行,X 秒后失败 (默认=N/A)
|
||||
`-C`, `--check` | 不要做任何改变;相反,尝试预测可能发生的一些变化
|
||||
`-D`, `--diff` | 更改(小)文件和模板时,显示这些文件中的差异; 与 `--check` 配合使用效果很好
|
||||
`-e EXTRA_VARS`, `--extra-vars=EXTRA_VARS` | 将附加变量设置为 key=value 或 YAML/JSON
|
||||
`-f FORKS`, `--forks=FORKS` | 指定要使用的并行进程数 (default=5)
|
||||
`-h`, `--help` | 显示此帮助信息并退出
|
||||
`-i INVENTORY`, `--inventory-file=INVENTORY` | 指定清单主机路径(默认=/etc/ansible/hosts)或逗号分隔的主机列表
|
||||
`-l SUBSET`, `--limit=SUBSET` | 进一步将选定主机限制为其他模式
|
||||
`--list-hosts` | 输出匹配主机列表;不执行任何其他操作
|
||||
`-m MODULE_NAME`, `--module-name=MODULE_NAME` | 要执行的模块名称 (default=command)
|
||||
`-M MODULE_PATH`, `--module-path=MODULE_PATH` | 指定模块库的路径 (default=None)
|
||||
`--new-vault-password-file=NEW_VAULT_PASSWORD_FILE` | 用于重新生成密钥的新保管库密码文件
|
||||
`-o`, `--one-line` | 压缩输出
|
||||
`--output=OUTPUT_FILE` | 用于加密或解密的输出文件名; 使用 - 用于标准输出
|
||||
`-P POLL_INTERVAL`, `--poll=POLL_INTERVAL` | 如果使用 -B 则设置轮询间隔(default=15)
|
||||
`--syntax-check` | 对 playbook 执行语法检查,但不要执行它
|
||||
`-t TREE`, `--tree=TREE` | 将输出记录到此目录
|
||||
`--vault-password-file=VAULT_PASSWORD_FILE` | 保险库密码文件
|
||||
`-v`, `--verbose` | 详细模式(-vvv 更多,-vvvv 启用连接调试)
|
||||
`--version` | 显示程序的版本号并退出
|
||||
|
||||
控制谁以及如何连接到主机,连接选项:
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`-k`, `--ask-pass` | 询问连接密码
|
||||
`--private-key=PRIVATE_KEY_FILE`, `--key-file=PRIVATE_KEY_FILE` | 使用此文件来验证连接
|
||||
`-u REMOTE_USER`, `--user=REMOTE_USER` | 以此用户身份连接(default=None)
|
||||
`-c CONNECTION`, `--connection=CONNECTION` | 要使用的连接类型 (default=smart)
|
||||
`-T TIMEOUT`, `--timeout=TIMEOUT` | 以秒为单位覆盖连接超时 (default=10)
|
||||
`--ssh-common-args=SSH_COMMON_ARGS` | 指定要传递给 sftp/scp/ssh 的常用参数 (e.g. ProxyCommand)
|
||||
`--sftp-extra-args=SFTP_EXTRA_ARGS` | 指定仅传递给 sftp 的额外参数 (e.g. -f, -l)
|
||||
`--scp-extra-args=SCP_EXTRA_ARGS` | 指定仅传递给 `scp` 的额外参数 (e.g. -l)
|
||||
`--ssh-extra-args=SSH_EXTRA_ARGS` | 指定仅传递给 `ssh` 的额外参数 (e.g. -R)
|
||||
|
||||
控制您成为目标主机上的用户的方式和用户,特权升级选项:
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`-s`, `--sudo` | 使用 sudo (nopasswd) 运行操作(已弃用,使用 become)
|
||||
`-U SUDO_USER`, `--sudo-user=SUDO_USER` | 所需的 sudo 用户(默认=root)(已弃用,使用 become)
|
||||
`-S`, `--su` | 使用 su 运行操作(已弃用,使用 become)
|
||||
`-R SU_USER`, `--su-user=SU_USER` | 以该用户身份使用 su 运行操作(默认 = root)(已弃用,使用 become)
|
||||
`-b`, `--become` | 使用 become 运行操作(不暗示密码提示)
|
||||
`--become-method=BECOME_METHOD` | 要使用的权限提升方法(默认=sudo),有效选择:[ sudo | su | pbrun | pfexec | runas | doas | dzdo ]
|
||||
`--become-user=BECOME_USER` | 以该用户身份运行操作(默认=root)
|
||||
`--ask-sudo-pass` | 询问 sudo 密码(已弃用,使用 become)
|
||||
`--ask-su-pass` | 询问 su 密码(已弃用,使用 become)
|
||||
`-K`, `--ask-become-pass` | 要求提权密码
|
||||
|
||||
### Ansible Galaxy 工具
|
||||
|
||||
```bash
|
||||
$ ansible-galaxy [delete|import|info|init|install|list|login|remove|search|setup] [--help] [options] ...
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
---
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`-h`, `--help` | 显示此帮助信息并退出
|
||||
`-v`, `--verbose` | 详细模式(-vvv 更多,-vvvv 启用连接调试)
|
||||
`--version` | 显示程序的版本号并退出
|
||||
<!--rehype:className=style-list-->
|
||||
|
||||
---
|
||||
|
||||
```bash
|
||||
$ ansible-galaxy search --author <AUTHOR>
|
||||
$ ansible-galaxy search --platforms <PLATFORM>
|
||||
$ ansible-galaxy search --galaxy-tags <TAG>
|
||||
$ ansible-galaxy info <ROLE>
|
||||
$ ansible-galaxy install <ROLE> -p <ROLE_DIRECTORY>
|
||||
$ ansible-galaxy install -r <ROLE1> <ROLE2> <ROLE3> ...
|
||||
$ ansible-galaxy list
|
||||
$ ansible-galaxy remove <ROLE>
|
||||
$ ansible-galaxy init <ROLE>
|
||||
$ ansible-galaxy init --offline <ROLE>
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
|
||||
### ansible-doc
|
||||
|
||||
在本地访问文档
|
||||
|
||||
```bash
|
||||
$ ansible-doc
|
||||
$ ansible-doc [options] [module...]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`-h`, `--help` | 显示此帮助信息并退出
|
||||
`-l`, `--list` | 列出可用模块
|
||||
`-M MODULE_PATH`, `--module-path=MODULE_PATH` | 指定模块库的路径 (default=None)
|
||||
`-s`, `--snippet` | 显示指定模块的剧本片段
|
||||
`-v`, `--verbose` | 详细模式(-vvv 更多,-vvvv 启用连接调试)
|
||||
`--version` | 显示程序的版本号并退出
|
||||
<!--rehype:className=style-list-->
|
||||
|
||||
|
||||
### ansible-vault
|
||||
|
||||
```bash
|
||||
$ ansible-vault
|
||||
$ ansible-vault [create|decrypt|edit|encrypt|rekey|view] [--help] [options] vaultfile.yml
|
||||
```
|
||||
---
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`--ask-vault-pass` | 询问保险库密码
|
||||
`-h`, `--help` | 显示此帮助信息并退出
|
||||
`--new-vault-password-file=NEW_VAULT_PASSWORD_FILE` | 用于重新生成密钥的新保管库密码文件
|
||||
`--output=OUTPUT_FILE` | 用于加密或解密的输出文件名; 使用 - 用于标准输出
|
||||
`--vault-password-file=VAULT_PASSWORD_FILE` | 保险库密码文件
|
||||
`-v`, `--verbose` | 详细模式(-vvv 更多,-vvvv 启用连接调试)
|
||||
`--version` | 显示程序的版本号并退出
|
||||
<!--rehype:className=style-list-->
|
||||
|
||||
### ansible-playbook
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```bash
|
||||
$ ansible-playbook
|
||||
$ ansible-playbook playbook.yml
|
||||
```
|
||||
---
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`--ask-vault-pass` | 询问保险库密码
|
||||
`-C`, `--check` | 不要做任何改变;相反,尝试预测可能发生的一些变化
|
||||
`-D`, `--diff` | 更改(小)文件和模板时,显示这些文件中的差异;与 `--check` 配合使用效果很好
|
||||
`-e EXTRA_VARS`, `--extra-vars=EXTRA_VARS` | 将附加变量设置为 key=value 或 YAML/JSON
|
||||
`--flush-cache` | 清除事实缓存
|
||||
`--force-handlers` | 即使任务失败也运行处理程序
|
||||
`-f FORKS`, `--forks=FORKS` | 指定要使用的并行进程数(默认值=5)
|
||||
`-h`, `--help` | 显示此帮助信息并退出
|
||||
`-i INVENTORY`, `--inventory-file=INVENTORY` | 指定清单主机路径(默认=/etc/ansible/hosts)或逗号分隔的主机列表
|
||||
`-l SUBSET`, `--limit=SUBSET` | 进一步将选定主机限制为其他模式
|
||||
`--list-hosts` | 输出匹配主机列表;不执行任何其他操作
|
||||
`--list-tags` | 列出所有可用的标签
|
||||
`--list-tasks` | 列出所有将要执行的任务
|
||||
`-M MODULE_PATH`, `--module-path=MODULE_PATH` | 指定模块库的路径(默认=无)
|
||||
`--new-vault-password-file=NEW_VAULT_PASSWORD_FILE` | 用于重新生成密钥的新保管库密码文件
|
||||
`--output=OUTPUT_FILE` | 用于加密或解密的输出文件名;使用 - 用于标准输出
|
||||
`--skip-tags=SKIP_TAGS` | 只运行标签与这些值不匹配的播放和任务
|
||||
`--start-at-task=START_AT_TASK` | 在匹配此名称的任务处启动剧本
|
||||
`--step` | 一步一步:在运行前确认每个任务
|
||||
`--syntax-check` | 对 playbook 执行语法检查,但不要执行它
|
||||
`-t TAGS`, `--tags=TAGS` | 只运行带有这些值标记的播放和任务
|
||||
`--vault-password-file=VAULT_PASSWORD_FILE` | 保险库密码文件
|
||||
`-v`, `--verbose` | 详细模式(-vvv 更多,-vvvv 启用连接调试)
|
||||
`--version` | 显示程序的版本号并退出
|
||||
<!--rehype:className=style-list-->
|
||||
|
||||
连接选项:
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`-k`, `--ask-pass` | 询问连接密码
|
||||
`--private-key=PRIVATE_KEY_FILE`, `--key-file=PRIVATE_KEY_FILE` | 使用此文件来验证连接
|
||||
`-u REMOTE_USER`, `--user=REMOTE_USER` | 以此用户身份连接(默认=None)
|
||||
`-c CONNECTION`, `--connection=CONNECTION` | 要使用的连接类型(默认=smart)
|
||||
`-T TIMEOUT`, `--timeout=TIMEOUT` | 以秒为单位覆盖连接超时(默认值 = 10)
|
||||
`--ssh-common-args=SSH_COMMON_ARGS` | 指定要传递给 sftp/scp/ssh 的常用参数(例如 ProxyCommand)
|
||||
`--sftp-extra-args=SFTP_EXTRA_ARGS` | 指定仅传递给 sftp 的额外参数(例如 -f、-l)
|
||||
`--scp-extra-args=SCP_EXTRA_ARGS` | 指定仅传递给 scp 的额外参数(例如 -l)
|
||||
`--ssh-extra-args=SSH_EXTRA_ARGS` | 指定仅传递给 ssh 的额外参数(例如 -R)
|
||||
<!--rehype:className=style-list-->
|
||||
|
||||
特权升级选项:
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`-s`, `--sudo` | 使用 sudo (nopasswd) 运行操作(已弃用,使用 become)
|
||||
`-U SUDO_USER`, `--sudo-user=SUDO_USER` | 所需的 sudo 用户(默认=root)(已弃用,使用become)
|
||||
`-S`, `--su` | 使用 su 运行操作(已弃用,使用 become)
|
||||
`-R SU_USER`, `--su-user=SU_USER` | 以该用户身份使用 su 运行操作(默认 = root)(已弃用,使用become)
|
||||
`-b`, `--become` | 使用 become 运行操作(不暗示密码提示)
|
||||
`--become-method=BECOME_METHOD` | 要使用的权限提升方法(默认=sudo),有效选择:[ sudo \| su \| pbrun \| pfexec \| runas \| doas \| dzdo ]
|
||||
`--become-user=BECOME_USER` | 以该用户身份运行操作(默认=root)
|
||||
`--ask-sudo-pass` | 询问 sudo 密码(已弃用,使用 become)
|
||||
`--ask-su-pass` | 询问 su 密码(已弃用,使用 become)
|
||||
`-K`, `--ask-become-pass` | 要求提权密码
|
||||
<!--rehype:className=style-list-->
|
||||
|
||||
### ansible-pull
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```bash
|
||||
$ ansible-pull
|
||||
$ ansible-pull -U <repository> [options]
|
||||
```
|
||||
---
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`--accept-host-key` | 如果尚未添加,则添加 repo url 的主机密钥
|
||||
`--ask-vault-pass` | 询问保险库密码
|
||||
`-C CHECKOUT`, `--checkout=CHECKOUT` | 分支/标签/提交结帐。默认为存储库模块的行为。
|
||||
`-d DEST`, `--directory=DEST` | 签出存储库的目录
|
||||
`-e EXTRA_VARS`, `--extra-vars=EXTRA_VARS` | 将附加变量设置为 key=value 或 YAML/JSON
|
||||
`-f`, `--force` | 即使无法更新存储库也运行 playbook
|
||||
`--full` | 做一个完整的克隆,而不是一个浅的
|
||||
`-h`, `--help` | 显示此帮助信息并退出
|
||||
`-i INVENTORY`, `--inventory-file=INVENTORY` | 指定清单主机路径(默认=/etc/ansible/hosts)或逗号分隔的主机列表
|
||||
`-l SUBSET`, `--limit=SUBSET` | 进一步将选定主机限制为其他模式
|
||||
`--list-hosts` | 输出匹配主机列表;不执行任何其他操作
|
||||
`-m MODULE_NAME`, `--module-name=MODULE_NAME` | 存储库模块名称,ansible 将使用它来签出 repo。默认是 git
|
||||
`-M MODULE_PATH`, `--module-path=MODULE_PATH` | 指定模块库的路径(默认=无)
|
||||
`--new-vault-password-file=NEW_VAULT_PASSWORD_FILE` | 用于重新生成密钥的新保管库密码文件
|
||||
`-o`, `--only-if-changed` | 仅在存储库已更新时才运行 playbook
|
||||
`--output=OUTPUT_FILE` | 用于加密或解密的输出文件名;使用 - 用于标准输出
|
||||
`--purge` | 剧本运行后清除结帐
|
||||
`--skip-tags=SKIP_TAGS` | 只运行标签与这些值不匹配的播放和任务
|
||||
`-s SLEEP`, `--sleep=SLEEP` | 在开始之前休眠随机间隔(在 0 到 n 秒之间)。这是分散 git 请求的有用方法
|
||||
`-t TAGS`, `--tags=TAGS` | 只运行带有这些值标记的播放和任务
|
||||
`-U URL`, `--url=URL` | 剧本存储库的 URL
|
||||
`--vault-password-file=VAULT_PASSWORD_FILE` | 保险库密码文件
|
||||
`-v`, `--verbose` | 详细模式(-vvv 更多,-vvvv 启用连接调试)
|
||||
`--verify-commit` | 验证签出提交的 GPG 签名,如果失败则中止运行 playbook。这就需要对应的VCS模块来支持这样的操作
|
||||
`--version` | 显示程序的版本号并退出
|
||||
<!--rehype:className=style-list-->
|
||||
|
||||
连接选项:
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`-k`, `--ask-pass` | 询问连接密码
|
||||
`--private-key=PRIVATE_KEY_FILE`, `--key-file=PRIVATE_KEY_FILE` | 使用此文件来验证连接
|
||||
`-u REMOTE_USER`, `--user=REMOTE_USER` | 以此用户身份连接(默认=无)
|
||||
`-c CONNECTION`, `--connection=CONNECTION` | 要使用的连接类型(默认=智能)
|
||||
`-T TIMEOUT`, `--timeout=TIMEOUT` | 以秒为单位覆盖连接超时(默认值 = 10)
|
||||
`--ssh-common-args=SSH_COMMON_ARGS` | 指定要传递给 sftp/scp/ssh 的常用参数(例如 ProxyCommand)
|
||||
`--sftp-extra-args=SFTP_EXTRA_ARGS` | 指定仅传递给 sftp 的额外参数(例如 -f、-l)
|
||||
`--scp-extra-args=SCP_EXTRA_ARGS` | 指定仅传递给 scp 的额外参数(例如 -l)
|
||||
`--ssh-extra-args=SSH_EXTRA_ARGS` | 指定仅传递给 ssh 的额外参数(例如 -R)
|
||||
<!--rehype:className=style-list-->
|
||||
|
||||
特权升级选项:
|
||||
|
||||
:- | -
|
||||
:- | -
|
||||
`--ask-sudo-pass` | 询问 sudo 密码(已弃用,使用become)
|
||||
`--ask-su-pass` | 询问 su 密码(已弃用,使用become)
|
||||
`-K`, `--ask-become-pass` | 要求提权密码
|
||||
<!--rehype:className=style-list-->
|
||||
|
||||
<!-- ### ansible-playbook -->
|
||||
<!-- todo -->
|
||||
|
||||
|
||||
|
||||
另见
|
||||
---
|
||||
[Getting started with Ansible](https://docs.ansible.com/ansible/latest/getting_started/index.html)
|
||||
[Introduction to ad hoc commands](https://docs.ansible.com/ansible/latest/user_guide/intro_adhoc.html)
|
404
docs/cargo.md
Normal file
404
docs/cargo.md
Normal file
@ -0,0 +1,404 @@
|
||||
Cargo 备忘清单
|
||||
===
|
||||
|
||||
此快速参考备忘清单 [Cargo](https://conan.io/) 提供了编译 [Rust](./rust.md) 常用命令和示例
|
||||
|
||||
入门
|
||||
--------
|
||||
|
||||
### 安装 Rust 和 Cargo
|
||||
|
||||
|
||||
```bash
|
||||
$ curl -sSf https://static.rust-lang.org/rustup.sh | sh
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
在 Linux 和 macOS 系统上,这可以通过以上方命令完成
|
||||
|
||||
- [Cargo 开源仓库](https://github.com/rust-lang/cargo) _(github.com)_
|
||||
- [Cargo 官网](https://doc.rust-lang.org/cargo) _(doc.rust-lang.org)_
|
||||
- [Cargo 官网(中文)](https://www.rustwiki.org.cn/zh-CN/cargo/index.html) _(rustwiki.org.cn)_
|
||||
- [Rust 社区的 crate 仓库](https://crates.io/) _(crates.io)_
|
||||
|
||||
### 命令说明
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`cargo version` | 显示版本信息以确认 Cargo 已安装
|
||||
`cargo new` | 创建一个新项目
|
||||
`cargo test` | 在项目中运行单元测试
|
||||
`cargo check` | 快速编译项目,无需生成二进制文件来检查错误
|
||||
`cargo fmt` | 自动格式化代码
|
||||
`cargo build` | 编译一个项目
|
||||
`cargo run` | 一步编译和运行项目
|
||||
`cargo clippy --all-targets -- --D warnings` | Linter 检查错误
|
||||
`cargo tarpaulin --ignore-tests` | 检查代码覆盖率
|
||||
|
||||
### 创建新项目
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
```bash
|
||||
$ cargo new hello_world --bin
|
||||
```
|
||||
|
||||
- `--bin` 正在制作一个二进制程序
|
||||
- `--lib` 正在创建一个库(lib)
|
||||
|
||||
得到如下目录:
|
||||
|
||||
```bash
|
||||
$ cd hello_world
|
||||
$ tree .
|
||||
.
|
||||
├── Cargo.toml
|
||||
└── src
|
||||
└── main.rs
|
||||
```
|
||||
|
||||
`Cargo.toml` 被称为一个 `manifest` 元清单,它包含了 `Cargo` 编译项目所需的所有元数据
|
||||
|
||||
```toml
|
||||
[package]
|
||||
name = "hello_world"
|
||||
version = "0.1.0"
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
```
|
||||
|
||||
入口文件 `src/main.rs`
|
||||
|
||||
```rust
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
```
|
||||
|
||||
运行编译生成 `hello_world` 二进制文件
|
||||
|
||||
```bash
|
||||
$ cargo build
|
||||
# 文件放入 `target/release` 目录
|
||||
$ cargo build --release
|
||||
```
|
||||
|
||||
然后运行它:
|
||||
|
||||
```bash
|
||||
$ ./target/debug/hello_world
|
||||
Hello, world!
|
||||
```
|
||||
|
||||
也可以直接使用 `cargo run`,它会自行`编译`并`运行`它:
|
||||
|
||||
```bash
|
||||
$ cargo run
|
||||
Running `target/hello_world`
|
||||
Hello, world!
|
||||
```
|
||||
|
||||
### 项目目录
|
||||
|
||||
```bash
|
||||
.
|
||||
├── Cargo.lock
|
||||
├── Cargo.toml
|
||||
├── benches # 基准目录
|
||||
│ └── large-input.rs
|
||||
├── examples # 示例
|
||||
│ └── simple.rs
|
||||
├── src # 源代码
|
||||
│ ├── bin
|
||||
│ │ └── another_executable.rs
|
||||
│ ├── lib.rs # 默认库
|
||||
│ └── main.rs # 入口文件
|
||||
└── tests # 集成测试
|
||||
└── some-integration-tests.rs
|
||||
```
|
||||
|
||||
### 编译测试
|
||||
|
||||
```bash
|
||||
# 编译输出二进制文件,放入 `target/debug` 目录
|
||||
$ cargo build
|
||||
# 输出二进制文件,放入 `target/release` 目录
|
||||
$ cargo build --release
|
||||
$ cargo run # 编译并运行
|
||||
$ cargo test # 运行您的测试
|
||||
$ cargo test foo # 传递过滤器,来运行特定测试
|
||||
```
|
||||
|
||||
### 配置目标
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```toml
|
||||
[package]
|
||||
# ...
|
||||
[lib]
|
||||
# 生成目标与库的名称. 本该默认是包名, 替换所有破折号为 下划线. (Rust `extern crate` 声明会参考该名;因此,该值必须是可用的有效Rust标识符)
|
||||
name = "foo"
|
||||
# 该字段,指向 crate 的入口(位置), 路径相对于 `Cargo.toml`.
|
||||
path = "src/lib.rs"
|
||||
# 一个给目标启用单元测试 的 标志. 会被 `cargo test`使用.
|
||||
test = true
|
||||
# 一个给目标启用文档测试 的 标志. 只与库相关, 不会影响其他部分。会被 `cargo test`使用.
|
||||
doctest = true
|
||||
# 一个给目标启用基准 的 标志. 会被 `cargo bench`使用.
|
||||
bench = true
|
||||
# 一个给目标启用文档 的 标志. 会被 `cargo doc`使用.
|
||||
doc = true
|
||||
# 若该目标为 编译器扩展, 那要把该字段设为 true,以让 Cargo 正确编译和,可用于所有依赖项.
|
||||
plugin = false
|
||||
# 若该目标为 "macros 1.1" 程序宏, 那要把该字段设为 true
|
||||
proc-macro = false
|
||||
# 若设为 false, `cargo test` 会为 rustc 省略 `--test` 标志, 这阻止它生成测试工具 这在二进制存在,构建管理测试运行器本身的情况下,有用.
|
||||
harness = true
|
||||
# 若设置了,那 目标会使用一个与`[package]`配置不同的版本, 也许是,编译一个库 2018年版本或,编译单元测试的2015年版本. 默认情况下所有目标都使用`[package]`中指定的版本进行编译。
|
||||
edition = '2015'
|
||||
```
|
||||
<!--rehype:className=wrap-text-->
|
||||
|
||||
### 来源配置
|
||||
|
||||
```toml
|
||||
# `source` 表下,就是存储有关要更换的来源名称
|
||||
[source]
|
||||
|
||||
# 在`source` 表格之下的,可为一定数量的有关来源名称. 示例下面就# 定义了一个新源, 叫 `my-awesome-source`, 其内容来自本地 # `vendor`目录 ,其相对于包含`.cargo/config`文件的目录
|
||||
[source.my-awesome-source]
|
||||
directory = "vendor"
|
||||
|
||||
# Git sources 也指定一个 branch/tag/rev
|
||||
git = "https://example.com/path/to/repo"
|
||||
# branch = "master"
|
||||
# tag = "v1.0.1"
|
||||
# rev = "313f44e8"
|
||||
|
||||
# The crates.io 默认源 在"crates-io"名称下, 且在这里我们使用 `replace-with` 字段指明 默认源更换成"my-awesome-source"源
|
||||
[source.crates-io]
|
||||
replace-with = "my-awesome-source"
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 配置
|
||||
|
||||
```toml
|
||||
# 每个源都有自己的表格,名称即是表名
|
||||
[source.the-source-name]
|
||||
|
||||
# 命令 `the-source-name` 会被 `another-source`取代
|
||||
replace-with = "another-source"
|
||||
|
||||
# 有几种可用的源定义(接下来有所描述)
|
||||
registry = "https://example.com/path/to/index"
|
||||
local-registry = "path/to/registry"
|
||||
directory = "path/to/vendor"
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
更换源的配置通过完成 `.cargo/config`,下面为全套可用字段是
|
||||
|
||||
包相关命令
|
||||
---
|
||||
|
||||
### init/new
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
创建一个新的 `cargo` 包
|
||||
|
||||
```bash
|
||||
$ cargo init [options] [path]
|
||||
$ cargo new [options] [path]
|
||||
```
|
||||
|
||||
- `--bin` 创建具有二进制目标 (src/main.rs) 的包(默认行为)
|
||||
- `--lib` 使用库目标 (src/lib.rs) 创建一个包
|
||||
- `--edition edition` 指定要使用的 Rust 版本。默认值为 `2021`。可能的值:2015、2018、2021
|
||||
- `--name name` 设置包名。默认为目录名称
|
||||
- `--vcs vcs` 为给定的版本控制系统(git、hg、pijul 或fossil)初始化一个新的 VCS 存储库,或者根本不初始化任何版本控制(无)
|
||||
- `--registry registry` 限制仅发布到该注册表
|
||||
<!--rehype:className=style-arrow-->
|
||||
|
||||
```bash
|
||||
$ cargo new foo
|
||||
```
|
||||
|
||||
### 安装包
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```bash
|
||||
# 从 crates.io 安装或升级软件包:
|
||||
$ cargo install ripgrep
|
||||
# 在当前目录安装或重新安装包:
|
||||
$ cargo install --path .
|
||||
# 查看已安装包的列表:
|
||||
$ cargo install --list
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
- `--vers version`
|
||||
- `--version version` 指定要安装的版本
|
||||
- `--git url` 用于安装指定 crate 的 Git URL
|
||||
- `--branch branch` 从 git 安装时要使用的分支
|
||||
- `--tag tag` 从 git 安装时使用的标记
|
||||
- `--rev sha` 从 git 安装时使用的特定提交
|
||||
- `--path path` 要安装的本地 crate 的文件系统路径
|
||||
- `--list` 列出所有已安装的软件包及其版本
|
||||
- `-f`, `--force` 强制覆盖现有的 crate 或二进制文件
|
||||
|
||||
### 搜索包
|
||||
|
||||
```bash
|
||||
$ cargo search [options] [query...]
|
||||
```
|
||||
|
||||
- `--limit limit` 限制结果数量(默认值:10,最大值:100)
|
||||
- `--index index` 要使用的注册表索引的 URL
|
||||
- `--registry registry` 要使用的注册表的名称
|
||||
|
||||
```bash
|
||||
$ cargo search serde
|
||||
```
|
||||
|
||||
### 卸载包
|
||||
|
||||
```bash
|
||||
$ cargo uninstall [options] [spec...]
|
||||
```
|
||||
|
||||
- `-p`, `--package spec...` 要卸载的软件包
|
||||
- `--bin name...` 仅卸载二进制名称
|
||||
- `--root dir` 从中卸载软件包的目录
|
||||
|
||||
```bash
|
||||
$ cargo uninstall ripgrep
|
||||
```
|
||||
|
||||
发布命令
|
||||
---
|
||||
|
||||
### 登录
|
||||
|
||||
```bash
|
||||
$ cargo login [options] [token]
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
:-|:-
|
||||
:-|:-
|
||||
`--registry` | 要使用的注册表的名称
|
||||
|
||||
----
|
||||
|
||||
:-|:-
|
||||
:-|:-
|
||||
`-v`, `--verbose` | 启用更加详细的输出
|
||||
`-q`, `--quiet` | 不输出Cargo的日志信息
|
||||
`--color when` | 输出内容的颜色 `auto`, `always`, `never`
|
||||
|
||||
### 所有者
|
||||
|
||||
```bash
|
||||
# 列出包的所有者:
|
||||
$ cargo owner --list foo
|
||||
# 邀请所有者加入包:
|
||||
$ cargo owner --add username foo
|
||||
# 从包中删除所有者:
|
||||
$ cargo owner --remove username foo
|
||||
```
|
||||
----
|
||||
|
||||
:-|:-
|
||||
:-|:-
|
||||
`--token token` | 身份验证时使用的 API 令牌
|
||||
`--index index` | 要使用的注册表索引的 URL
|
||||
|
||||
### 打包 & 发布公共选项
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
选择包
|
||||
|
||||
- `-p spec...`, `--package spec...` Package 指定包
|
||||
- `--workspace` Package 工作区中的全体成员
|
||||
- `--exclude SPEC...` 排除指定包
|
||||
|
||||
编译选项
|
||||
|
||||
- `--target triple` 为指定架构执行 Package
|
||||
- `--target-dir directory` 用于存放生成的工件以及中间文件的目录
|
||||
|
||||
特性选择
|
||||
|
||||
- `--features features` 传递以空格或者逗号分隔的列表,其中给出要启用的特性
|
||||
- `--all-features` 为给定的包启用全部可用特性
|
||||
- `--no-default-features` 不启用给定包的default特性
|
||||
|
||||
清单选项
|
||||
|
||||
- `--manifest-path path` 用于指定 Cargo.toml 文件的路径
|
||||
- `--frozen`, `--locked` 这两个选项用于保证Cargo.lock文件是最新的
|
||||
- `--offline` 禁止Cargo访问网络
|
||||
|
||||
混杂选项
|
||||
|
||||
- `-j N`, `--jobs N` 要并行运行的作业数量
|
||||
|
||||
### 打包
|
||||
|
||||
将本地包打包为可分发的压缩文件
|
||||
|
||||
```bash
|
||||
$ cargo package [options]
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
- `-l`, `--list` 输出包中包含的文件(不实际进行打包)。
|
||||
- `--no-verify` 构建包时不进行校验。
|
||||
- `--no-metadata` 忽略 缺少可读的元信息(如描述信息或采用的授权协议) 时产生的警告。
|
||||
- `--allow-dirty` 允许打包 在版本控制系统中仍有未提交内容 的包。
|
||||
|
||||
### 发布
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```bash
|
||||
$ cargo publish [options]
|
||||
```
|
||||
|
||||
发布选项
|
||||
|
||||
- `--dry-run` 在不上传的情况下执行所有检查
|
||||
- `--token token` 身份验证时使用的 API 令牌
|
||||
- `--no-verify` 不要通过构建内容来验证内容
|
||||
- `--allow-dirty` 允许打包具有未提交的 VCS 更改的工作目录
|
||||
- `--index index` 要使用的注册表索引的 URL
|
||||
- `--registry registry` 要发布到的注册表的名称
|
||||
|
||||
打包选择
|
||||
|
||||
- `-p spec`, `--package spec` 要发布的包
|
||||
|
||||
### yank
|
||||
|
||||
从服务器的索引中删除以前发布的 crate 版本
|
||||
|
||||
```bash
|
||||
$ cargo yank --vers 1.0.7 foo
|
||||
```
|
||||
|
||||
- `--vers version` 要 yank 或 un-yank 的版本
|
||||
- `--undo` 撤消 yank,将版本放回索引中
|
||||
- `--token token` 身份验证时使用的 API 令牌
|
||||
- `--index index` 要使用的注册表索引的 URL
|
||||
- `--registry registry` 要使用的注册表名称
|
||||
|
||||
另见
|
||||
---
|
||||
|
||||
- [The Cargo Book](https://doc.rust-lang.org/stable/cargo/) _(doc.rust-lang.org)_
|
||||
- [Cargo 手册 中文版](https://www.rustwiki.org.cn/zh-CN/cargo/index.html) _(rustwiki.org.cn)_
|
114
docs/cmake.md
Normal file
114
docs/cmake.md
Normal file
@ -0,0 +1,114 @@
|
||||
CMake 备忘清单
|
||||
===
|
||||
|
||||
本清单提供了对 CMake 的入门简要概述,以及 CMake 常用示例
|
||||
|
||||
入门
|
||||
---
|
||||
|
||||
### Hello CMake
|
||||
|
||||
CMake 是一个用于配置跨平台源代码项目应该如何配置的工具建立在给定的平台上。
|
||||
|
||||
```bash
|
||||
├┈ CMakeLists.txt # 希望运行的 CMake 命令
|
||||
╰┈ main.cpp # 带有 main 的源文件
|
||||
```
|
||||
|
||||
在此项目上运行 `CMake` 时,系统会要求您提供二进制目录,运行 `CMake` 不会创建最终的可执行文件,而是会为 `Visual Studio`、`XCode` 或 `makefile` 生成项目文件。 使用这些工具构建该项目
|
||||
|
||||
#### CMakeLists.txt
|
||||
|
||||
```cmake
|
||||
# 设置可以使用的最低 CMake 版本
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
# 设置项目名称
|
||||
project (hello_cmake)
|
||||
# 添加可执行文件
|
||||
add_executable(hello_cmake main.cpp)
|
||||
```
|
||||
|
||||
#### main.cpp
|
||||
|
||||
```c
|
||||
#include <iostream>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
std::cout << "Hello CMake!" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
#### 编译示例
|
||||
|
||||
```bash
|
||||
$ mkdir build # 创建 build 目录
|
||||
$ cd build # 进入目录
|
||||
$ cmake .. # 目录的上一级目录运行命令
|
||||
$ ./hello_cmake # 运行生成的 hello_cmake
|
||||
Hello CMake!
|
||||
```
|
||||
|
||||
### cmake
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
生成项目构建系统
|
||||
|
||||
```bash
|
||||
$ cmake [<options>] <path-to-source | path-to-existing-build>bash
|
||||
$ cmake [<options>] -S <path-to-source> -B <path-to-build>
|
||||
```
|
||||
|
||||
建立一个项目
|
||||
|
||||
```bash
|
||||
$ cmake --build <dir> [<options>] [-- <build-tool-options>]
|
||||
```
|
||||
|
||||
安装项目
|
||||
|
||||
```bash
|
||||
$ cmake --install <dir> [<options>]
|
||||
```
|
||||
|
||||
打开一个项目
|
||||
|
||||
```bash
|
||||
$ cmake --open <dir>
|
||||
```
|
||||
|
||||
运行脚本
|
||||
|
||||
```bash
|
||||
$ cmake [-D <var>=<value>]... -P <cmake-script-file>
|
||||
```
|
||||
|
||||
运行命令行工具
|
||||
|
||||
```bash
|
||||
$ cmake -E <command> [<options>]
|
||||
```
|
||||
|
||||
运行查找包工具
|
||||
|
||||
```bash
|
||||
$ cmake --find-package [<options>]
|
||||
```
|
||||
|
||||
运行工作流预设
|
||||
|
||||
```bash
|
||||
$ cmake --workflow [<options>]
|
||||
```
|
||||
|
||||
查看帮助
|
||||
|
||||
```bash
|
||||
$ cmake --help[-<topic>]
|
||||
```
|
||||
|
||||
另见
|
||||
----
|
||||
|
||||
- [CMake Examples](http://ttroy50.github.io/cmake-examples/) _(ttroy50.github.io)_
|
228
docs/conan.md
Normal file
228
docs/conan.md
Normal file
@ -0,0 +1,228 @@
|
||||
Conan 备忘清单
|
||||
===
|
||||
|
||||
这个 [Conan](https://conan.io/) 快速参考备忘清单显示了它的常用命令使用清单
|
||||
|
||||
入门
|
||||
---
|
||||
|
||||
### 介绍
|
||||
|
||||
Conan 是开源、去中心化和多平台的软件包,管理器来创建和共享您的所有本机二进制文件
|
||||
|
||||
- [Conan 官网](https://conan.io/)
|
||||
|
||||
#### 安装
|
||||
|
||||
```bash
|
||||
$ pip install conan
|
||||
$ pip install conan --upgrade
|
||||
```
|
||||
|
||||
初始化配置文件
|
||||
|
||||
```bash
|
||||
$ conan config init
|
||||
```
|
||||
|
||||
### 显示本地客户端配置
|
||||
|
||||
Conan 应用配置
|
||||
|
||||
```bash
|
||||
# 查看 Conan 主目录
|
||||
$ conan config home
|
||||
# 显示部分或全部配置项
|
||||
$ conan config get [<section>.<config>]
|
||||
# 显示完整的 conan.conf 文件
|
||||
$ conan config get
|
||||
# 在“日志”部分显示“级别”项
|
||||
$ conan config get log.level
|
||||
```
|
||||
|
||||
配置文件的内容(例如默认值)
|
||||
|
||||
```bash
|
||||
$ conan profile show default
|
||||
```
|
||||
|
||||
远程存储库
|
||||
|
||||
```bash
|
||||
$ conan remote list
|
||||
```
|
||||
|
||||
### 添加和修改配置
|
||||
|
||||
安装配置集合
|
||||
|
||||
```bash
|
||||
$ conan config install <url>
|
||||
$ conan config install ./my_config.conf
|
||||
```
|
||||
|
||||
更改单个配置值
|
||||
|
||||
```bash
|
||||
$ conan config set general.revisions_enabled=1
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
添加遥控器
|
||||
|
||||
```bash
|
||||
$ conan remote add my_remote <url>
|
||||
```
|
||||
|
||||
提供远程凭据
|
||||
|
||||
```bash
|
||||
$ conan user -p <password> -r my_remote <username>
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 显示来自 inspect 或 reference 的信息
|
||||
|
||||
显示 `conanfile.py` 的属性
|
||||
|
||||
```bash
|
||||
$ conan inspect <path> -a <attribute>
|
||||
```
|
||||
|
||||
显示 `conanfile.py` 的内容以供参考
|
||||
|
||||
```bash
|
||||
$ conan get <reference>
|
||||
```
|
||||
|
||||
显示 `recipe` 的依赖关系图信息
|
||||
|
||||
```bash
|
||||
$ conan info <path_or_reference>
|
||||
```
|
||||
|
||||
### 搜索包
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
在远程搜索包
|
||||
|
||||
```bash
|
||||
# 列出本地缓存中的包名称
|
||||
$ conan search
|
||||
$ conan search <package>/<revision>@<user>/<channel> # 输出取决于给出了多少包引用。
|
||||
# 支持通配符
|
||||
[--table=file.html] # 将输出保存在 HTML 文件中
|
||||
[-r=<remote>] # 查看远程存储库(默认为本地缓存)
|
||||
|
||||
$ conan search mylib/1.0@user/channel # 显示本地缓存中 mylib/1.0@user/channel 的所有包
|
||||
$ conan search "zlib/*" -r=all # 在所有远程中显示所有版本的 zlib
|
||||
|
||||
$ conan search zlib -r conan-center
|
||||
|
||||
# 显示包的修订:
|
||||
$ conan search <package>/<revision>@<user>/<channel> --revisions
|
||||
```
|
||||
|
||||
### 安装包
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
仅使用参考安装包
|
||||
|
||||
```bash
|
||||
$ conan install <package_reference>
|
||||
```
|
||||
|
||||
从 conanfile 安装软件包列表
|
||||
|
||||
```bash
|
||||
$ cat conanfile.txt
|
||||
[requires]
|
||||
zlib/1.2.11
|
||||
$ conan install <path_to_conanfile>
|
||||
```
|
||||
|
||||
通过生成器在构建系统中使用包
|
||||
|
||||
```bash
|
||||
$ cat conanfile.txt
|
||||
[requires]
|
||||
zlib/1.2.11
|
||||
[generators]
|
||||
cmake_find_package
|
||||
msbuild
|
||||
make
|
||||
```
|
||||
|
||||
安装需求并生成文件
|
||||
|
||||
```bash
|
||||
$ mkdir build && cd build
|
||||
$ conan install ..
|
||||
```
|
||||
|
||||
运行您的构建系统(以下之一)
|
||||
|
||||
```bash
|
||||
$ cmake .. && cmake --build .
|
||||
$ msbuild myproject.sln
|
||||
$ make
|
||||
```
|
||||
|
||||
### 创建一个包
|
||||
|
||||
从模板创建配方 (conanfile.py)
|
||||
|
||||
```bash
|
||||
$ conan new <reference> -m <template>
|
||||
```
|
||||
|
||||
只需将配方导出到本地缓存
|
||||
|
||||
```bash
|
||||
$ conan export <path_to_conanfile>
|
||||
```
|
||||
|
||||
从 recipe 为一种配置创建包
|
||||
也隐含地安装和导出步骤
|
||||
|
||||
```bash
|
||||
$ conan create . -pr <profile>
|
||||
```
|
||||
|
||||
### 检查包裹
|
||||
|
||||
完整打印包装配方:
|
||||
|
||||
```bash
|
||||
$ conan get <package>/<revision>@<user>/<channel>
|
||||
$ conan get boost/1.74.0
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
包装配方的打印属性:
|
||||
|
||||
```bash
|
||||
$ conan inspect <package>/<revision>@<user>/<channel>
|
||||
$ conan inspect boost/1.74.0
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
请参阅 [conan get](https://docs.conan.io/en/latest/reference/commands/consumer/get.html) 和 [conan inspect](https://docs.conan.io/en/latest/reference/commands/misc/inspect.html) 参考
|
||||
|
||||
|
||||
### Lockfiles
|
||||
|
||||
创建一个锁文件:
|
||||
|
||||
```bash
|
||||
$ conan lock create <package>/conanfile.py --user=<user> --channel=<channel>
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
在 `conan create` 或 `conan install` 期间使用 lockfile:
|
||||
|
||||
```bash
|
||||
$ conan <command> --lockfile conan.lock
|
||||
```
|
||||
|
||||
查看 [conan lock](https://docs.conan.io/en/latest/reference/commands/misc/lock.html) 参考
|
@ -1116,7 +1116,7 @@ grid-row-gap: length;
|
||||
### minmax() 函数
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
```css {.wrap}
|
||||
```css
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: 100px minmax(100px, 500px) 100px;
|
||||
|
@ -74,7 +74,7 @@ a{Click me}
|
||||
|
||||
p>{Click }+a{here}+{ 继续}
|
||||
|
||||
```html {.wrap}
|
||||
```html
|
||||
<p>Click <a href="">here</a> 继续</p>
|
||||
```
|
||||
|
||||
|
129
docs/gmail.md
Normal file
129
docs/gmail.md
Normal file
@ -0,0 +1,129 @@
|
||||
Gmail 备忘清单
|
||||
===
|
||||
|
||||
本备忘单总结了常用的 [Gmail](https://gmail.com/) 快捷键,以供快速参考。
|
||||
|
||||
Gmail 快捷键
|
||||
---
|
||||
|
||||
### Gmail 导航
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`u` | 返回话题列表(或刷新话题列表)
|
||||
`k` / `j` | 较新/较旧的对话
|
||||
`o` or `Enter` | 打开对话; 折叠/展开
|
||||
`p` / `n` | 阅读上一条/下一条消息
|
||||
<code>\`</code> | 转到下一个收件箱部分
|
||||
`~` | 转到上一个收件箱部分
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### Gmail 应用程序
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`c` | 撰写
|
||||
`d` | 添加 cc 撰写
|
||||
`b` | 添加 cc 和 bcc 撰写
|
||||
`/` | 搜索
|
||||
`q` | 焦点聊天联系人搜索
|
||||
`?` | 打开快捷方式帮助
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### Gmail 操作
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`,` | 将焦点移至工具栏
|
||||
`x` | 选择对话
|
||||
`s` | 旋转超级巨星
|
||||
`y` | 删除标签
|
||||
`e` | 档案
|
||||
`m` | 忽略对话
|
||||
`!` | 报告为垃圾邮件
|
||||
`v` | 打开移动到菜单
|
||||
`#` | 移到废纸篓
|
||||
`r` | 回复
|
||||
`Shift+r` | 在新窗口中回复
|
||||
`a` | 全部回复
|
||||
`Shift+a` | 在新窗口中回复所有
|
||||
`f` | 向前
|
||||
`Shift+f` | 在新窗口中转发
|
||||
`Shift+n` | 更新对话
|
||||
`Tab` 然后 `Enter` | 发邮件
|
||||
`Esc` | 焦点最后聊天痣
|
||||
`]` / `[` | 删除并转到上一个/下一个
|
||||
`}` / `{` | 存档并转到上一个/下一个
|
||||
`z` | 撤消上一个操作
|
||||
`.` | 打开更多操作菜单
|
||||
`l` | 打开标签菜单
|
||||
`Shift+i` | 标记为已读
|
||||
`Shift+u` | 标记为未读
|
||||
`_` | 将所选邮件标记为未读
|
||||
`Ctrl+s` | 保存草稿
|
||||
`+` 或 `=` | 标记为重要
|
||||
`-` | 标记为不重要
|
||||
`Shift+l` | 喜欢/不喜欢嗡嗡声
|
||||
`h` | 抢先看
|
||||
`g` 然后 `p` | 打个电话
|
||||
`&` | 启动老蛇
|
||||
`Shift+t` | 将对话添加到任务
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### Gmail 跳转
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`g` 然后 `i` | 打开收件箱
|
||||
`g` 然后 `s` | 打开已加星标的对话
|
||||
`g` 然后 `t` | 打开已发送消息
|
||||
`g` 然后 `d` | 打开草稿
|
||||
`g` 然后 `a` | 打开所有消息
|
||||
`g` 然后 `c` | 打开联系人
|
||||
`g` 然后 `b` | 去嗡嗡声
|
||||
`g` 然后 `l` | 转到标签
|
||||
`g` 然后 `k` | 前往任务
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
|
||||
### Gmail 主题列表选择
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`*` 然后 `a` | 选择所有对话
|
||||
`*` 然后 `n` | 取消选择所有对话
|
||||
`*` 然后 `r` | 选择阅读对话
|
||||
`*` 然后 `u` | 选择未读对话
|
||||
`*` 然后 `s` | 选择加星标的对话
|
||||
`*` 然后 `t` | 选择未加星标的对话
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### Gmail 搜索语法
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`from:[arg]` | 从
|
||||
`to:[arg]` | 至
|
||||
`label:[arg]` | 标签
|
||||
`subject:[arg]` | 主题
|
||||
`-[arg]` | 不包含
|
||||
`has:attachment` | 有附件
|
||||
`filename:[filename]` | 附件文件名
|
||||
`before:2011/11/20` | 之前(日期)
|
||||
`after:2011/11/20` | 之后(日期)
|
||||
`from:annie` 或 `from:david` | 或运算符
|
||||
`list:[arg]` | 邮件列表
|
||||
`subject:(word1 word2)` | 组词
|
||||
`in:anywhere` | 在所有框中搜索(垃圾邮件和垃圾邮件除外)
|
||||
`in:trash in:inbox in:spam` | 在特定框中搜索
|
||||
`is:starred is:read is:unread` | 搜索特定消息
|
||||
`is:chat` | 在聊天中搜索
|
||||
`cc:[arg] bcc:[arg]` | 搜索副本收件人
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### Gmail 提示和技巧
|
||||
|
||||
- 按 `u` 刷新话题列表
|
||||
- 对于多选,选择一个对话,然后 `shift+单击`另一个对话以选择其间的所有对话
|
||||
- 在主题中添加 `EOM`(消息结尾)以避免 `no-text-in-body` 警告
|
1409
docs/matlab.md
Normal file
1409
docs/matlab.md
Normal file
File diff suppressed because it is too large
Load Diff
@ -192,7 +192,7 @@ $ cat video.avi | nc -l 8000
|
||||
|
||||
客户端 Client
|
||||
|
||||
```shell {.wrap}
|
||||
```shell
|
||||
$ nc 192.168.1.9 8000 | mplayer -vo x11 -cache 3000 -
|
||||
```
|
||||
|
||||
|
@ -214,6 +214,22 @@ const school = <div>学校</div>;
|
||||
`<del>` 或 `~~删除~~` | <del>~~红色~~</del>
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 注释类配置
|
||||
<!--rehype:wrap-class=col-span-2 row-span-2-->
|
||||
|
||||
类 | 说明
|
||||
---- | ----
|
||||
`<!--rehype:className=wrap-text-->` | 强制换行
|
||||
`<!--rehype:className=show-header-->` | 展示表格表头
|
||||
`<!--rehype:className=shortcuts-->` | 快捷键样式
|
||||
`<!--rehype:className=auto-wrap-->` | 隐藏表头强制小尺寸自动换行
|
||||
`<!--rehype:className=style-list-arrow-->` | 列表箭头样式展示表格
|
||||
`<!--rehype:className=style-list-->` | 列表样式展示表格
|
||||
`<!--rehype:className=left-align-->` | 表格末尾列左对齐
|
||||
`<!--rehype:className=style-none-->` | \<li> 没有标记
|
||||
`<!--rehype:className=style-timeline-->` | 时间轴样式
|
||||
`<!--rehype:className=style-arrow-->` | 箭头标记
|
||||
|
||||
|
||||
### 隐藏卡片标题
|
||||
<!--rehype:style=display:none;&wrap-style=padding-top: 0;-->
|
||||
@ -244,6 +260,22 @@ const school = <div>学校</div>;
|
||||
|
||||
上面的 `markdown` 代码在 `meta` 位置添加 `preview` 标识,HTML 代码将被执行预览
|
||||
|
||||
### KaTeX 数学渲染
|
||||
|
||||
```KaTeX
|
||||
c = \pm\sqrt{a^2 + b^2}
|
||||
L = \frac{1}{2} \rho v^2 S C_L
|
||||
```
|
||||
|
||||
上面示例 `Markdown` 代码源码
|
||||
|
||||
```markdown {1}
|
||||
```KaTeX
|
||||
c = \pm\sqrt{a^2 + b^2}
|
||||
L = \frac{1}{2} \rho v^2 S C_L
|
||||
```
|
||||
|
||||
还可以单行展示 `KaTeX:c = \pm\sqrt{a^2 + b^2}`,需要标记 \`KaTeX:数学公式\` 将被显示成数学公式,这是基于 [KaTeX](https://katex.org/) 生成
|
||||
|
||||
布局
|
||||
---
|
||||
|
@ -855,7 +855,7 @@ console.log(array[1]);
|
||||
|
||||
### replace()
|
||||
|
||||
```javascript {.wrap}
|
||||
```javascript
|
||||
let text = 'Do you like aPPles?';
|
||||
let regex = /apples/i
|
||||
|
||||
@ -1091,7 +1091,7 @@ MySQL中的正则表达式
|
||||
|
||||
|
||||
### REGEXP
|
||||
```sql {.wrap}
|
||||
```sql
|
||||
expr REGEXP pat
|
||||
```
|
||||
|
||||
@ -1164,7 +1164,7 @@ mysql> SELECT regexp_like('a\nb\nc', '^b$', 'm');
|
||||
|
||||
### REGEXP_INSTR
|
||||
|
||||
``` {.wrap}
|
||||
```
|
||||
REGEXP_INSTR(expr, pat[, pos[, occurrence[, return_option[, match_type]]]])
|
||||
```
|
||||
|
||||
|
807
docs/rust.md
Normal file
807
docs/rust.md
Normal file
@ -0,0 +1,807 @@
|
||||
Rust 备忘清单
|
||||
====
|
||||
|
||||
Rust 快速参考备忘单,旨在为编写基本语法和方法提供帮助。
|
||||
|
||||
入门
|
||||
---
|
||||
|
||||
### Hello_World.rs
|
||||
|
||||
```rust
|
||||
fn main() {
|
||||
println!("Hello, World!");
|
||||
}
|
||||
```
|
||||
#### 编译运行
|
||||
|
||||
```shell
|
||||
$ rustc Hello_World.rs
|
||||
$ ./Hello_World
|
||||
Hello, World!
|
||||
```
|
||||
|
||||
### 原始类型
|
||||
|
||||
:-| :-
|
||||
:-| :-
|
||||
`bool` | 布尔值 (`true` _/_ `false`)
|
||||
`char` | 字符
|
||||
`f32`, `f64` | 32 位、64 位浮点数
|
||||
`i64`, `i32`, `i16`, `i8` | 有符号 16- ... 整数
|
||||
`u64`, `u32`, `u16`, `u8` | 无符号 16 位,... 整数
|
||||
`isize` | 指针大小的有符号整数
|
||||
`usize` | 指针大小的无符号整数
|
||||
|
||||
查看: [Rust 类型](#rust-类型)
|
||||
|
||||
### 格式化
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```rust
|
||||
// 单个占位符
|
||||
println!("{}", 1);
|
||||
// 多个占位符
|
||||
println!("{} {}", 1, 3);
|
||||
// 位置参数
|
||||
println!("{0} 是 {1} {2},{0} 也是 {3} 编程语言", "Rust", "cool", "language", "safe");
|
||||
// 命名参数
|
||||
println!("{country} 是一个团结的国家", country = "China");
|
||||
// 占位符特征 :b 表示二进制, :0x 表示十六进制, :o 表示八进制
|
||||
println!("让我们打印 76 是二进制的 {:b} ,十六进制等价物是 {:0x} 八进制等价物是 {:o}", 76, 76, 76);
|
||||
// 调试特征
|
||||
println!("使用调试特征 {:?} 在此处打印我们想要的任何内容", (76, 'A', 90));
|
||||
|
||||
// 1.58 中的新格式字符串
|
||||
let x = "world";
|
||||
println!("Hello {x}!");
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 打印风格
|
||||
|
||||
```rust
|
||||
// 打印输出
|
||||
print!("Hello World\n");
|
||||
// 打印后追加新行
|
||||
println!("追加新行");
|
||||
// 打印为错误
|
||||
eprint!("这是一个错误\n");
|
||||
// 打印为新行错误
|
||||
eprintln!("这是新行的错误");
|
||||
```
|
||||
|
||||
### 变量
|
||||
|
||||
```rust
|
||||
// 初始化和声明变量
|
||||
let some_variable = "This_is_a_variable";
|
||||
// 使变量可变
|
||||
let mut mutable_variable = "Mutable";
|
||||
// 分配多个变量
|
||||
let (name, age) = ("ElementalX", 20);
|
||||
// (全局)常量
|
||||
const SCREAMING_SNAKE_CASE:i64 = 9;
|
||||
```
|
||||
|
||||
### 注释
|
||||
|
||||
```rust
|
||||
// 行注释
|
||||
/*.............块注释 */
|
||||
/// 外部文档注释
|
||||
//! 内部文档评论
|
||||
```
|
||||
|
||||
另见: [注释](https://doc.rust-lang.org/reference/comments.html) _(doc.rust-lang.org)_
|
||||
|
||||
### 函数
|
||||
|
||||
```rust
|
||||
fn test(){
|
||||
println!("这是一个函数!");
|
||||
}
|
||||
fn main(){
|
||||
test();
|
||||
}
|
||||
```
|
||||
|
||||
查看: [Functions](#rust-函数)
|
||||
|
||||
### 声明宏
|
||||
|
||||
```rust
|
||||
macro_rules! foo {
|
||||
($l:tt) => { bar!($l); }
|
||||
}
|
||||
macro_rules! bar {
|
||||
(3) => {}
|
||||
}
|
||||
foo!(3);
|
||||
```
|
||||
|
||||
### 元变量
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`item` | 程序项
|
||||
`block` | 块表达式
|
||||
`stmt` | 语句<br/> _(注意此选择器不匹配句尾的分号)_
|
||||
`pat` | 模式
|
||||
`expr` | 表达式
|
||||
`ty` | 类型
|
||||
`ident` | 标识符或关键字
|
||||
`path` | 类型表达式 形式的路径
|
||||
`tt` | `token` 树<br/> _(单个 `token` 或宏匹配定界符 `()`、`[]` 或 `{}` 中的标记)_
|
||||
`meta` | 属性,属性中的内容
|
||||
`lifetime` | 生存期 `token`
|
||||
`vis` | 可能为空的可见性限定符
|
||||
`literal` | 匹配 `-?` 字面量表达式
|
||||
|
||||
### 结构体
|
||||
|
||||
```rust
|
||||
struct Point { x: i32, y: i32 }
|
||||
let p = Point { x: 10, y: 11 };
|
||||
let px: i32 = p.x;
|
||||
```
|
||||
|
||||
结构体是一个使用关键字 `struct` 定义的标称型(nominal)结构体类型
|
||||
|
||||
### 枚举
|
||||
|
||||
```rust
|
||||
enum Foo {
|
||||
Bar, // 0
|
||||
Baz = 123, // 123
|
||||
Quux, // 124
|
||||
}
|
||||
|
||||
let baz_discriminant = Foo::Baz as u32;
|
||||
assert_eq!(baz_discriminant, 123);
|
||||
```
|
||||
|
||||
Rust 类型
|
||||
--------
|
||||
|
||||
### 类型别名
|
||||
|
||||
```rust
|
||||
type Point = (u8, u8);
|
||||
let p: Point = (41, 68);
|
||||
```
|
||||
|
||||
### 整数
|
||||
|
||||
```rust
|
||||
let mut a: u32 = 8;
|
||||
let b: u64 = 877;
|
||||
let c: i64 = 8999;
|
||||
let d = -90;
|
||||
```
|
||||
|
||||
### 浮点数
|
||||
|
||||
```rust
|
||||
let mut sixty_bit_float: f64 = 89.90;
|
||||
let thirty_two_bit_float: f32 = 7.90;
|
||||
let just_a_float = 69.69;
|
||||
```
|
||||
|
||||
### 布尔值
|
||||
|
||||
```rust
|
||||
let true_val: bool = true;
|
||||
let false_val: bool = false;
|
||||
let just_a_bool = true;
|
||||
let is_true = 8 < 5; // => false
|
||||
```
|
||||
|
||||
### 字符
|
||||
|
||||
```rust
|
||||
let first_letter_of_alphabet = 'a';
|
||||
let explicit_char: char = 'F';
|
||||
let implicit_char = '8';
|
||||
let emoji = "\u{1f600}"; // => 😀
|
||||
```
|
||||
|
||||
### 字符串字面量
|
||||
|
||||
```rust
|
||||
let community_name = "AXIAL";
|
||||
let no_of_members: &str = "ten";
|
||||
println!("社区的名称是 {community_name},它有 {no_of_members} 个成员");
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
查看: [字符串](#rust-字符串)
|
||||
|
||||
### 数组
|
||||
|
||||
```rust
|
||||
┌─────┬─────┬─────┬─────┬─────┬─────┐
|
||||
| 92 | 97 | 98 | 99 | 98 | 94 |
|
||||
└─────┴─────┴─────┴─────┴─────┴─────┘
|
||||
0 1 2 3 4 5
|
||||
```
|
||||
----
|
||||
|
||||
```rust
|
||||
let array: [i64; 6] = [92,97,98,99,98,94];
|
||||
```
|
||||
|
||||
### 多维数组
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```rust
|
||||
j0 j1 j2 j3 j4 j5
|
||||
┌────┬────┬────┬────┬────┬────┐
|
||||
i0 | 1 | 2 | 3 | 4 | 5 | 6 |
|
||||
├────┼────┼────┼────┼────┼────┤
|
||||
i1 | 6 | 5 | 4 | 3 | 2 | 1 |
|
||||
└────┴────┴────┴────┴────┴────┘
|
||||
```
|
||||
----
|
||||
|
||||
```rust
|
||||
let array: [[i64; 6] ;2] = [
|
||||
[1,2,3,4,5,6],
|
||||
[6,5,4,3,2,1]];
|
||||
```
|
||||
|
||||
### 可变数组
|
||||
|
||||
```rust
|
||||
let mut array: [i32 ; 3] = [2,6,10];
|
||||
array[1] = 4;
|
||||
array[2] = 6;
|
||||
```
|
||||
|
||||
使用 `mut` 关键字使其可变
|
||||
|
||||
### 切片
|
||||
|
||||
```rust
|
||||
let mut array: [ i64; 4] = [1,2,3,4];
|
||||
// 下限包括在内,上限不包括在内
|
||||
let mut slices: &[i64] = &array[0..3]
|
||||
println!("切片的元素是:{slices:?}");
|
||||
```
|
||||
|
||||
### 向量
|
||||
|
||||
```rust
|
||||
let some_vector = vec![1,2,3,4,5];
|
||||
```
|
||||
|
||||
使用 `vec!` 宏声明向量
|
||||
|
||||
### 元组
|
||||
|
||||
```rust
|
||||
let tuple = (1, 'A' , "Cool", 78, true);
|
||||
```
|
||||
|
||||
Rust 字符串
|
||||
--------------
|
||||
|
||||
### 字符串字面量
|
||||
|
||||
```rust
|
||||
let cs:&str = "备忘清单";
|
||||
// => 为开发者分享备忘单
|
||||
println!("为开发者分享 {cs}");
|
||||
```
|
||||
|
||||
### 字符串对象
|
||||
|
||||
```rust
|
||||
// 创建一个空字符串对象
|
||||
let my_string = String::new;
|
||||
// 转换为字符串对象
|
||||
let S_string = a_string.to_string()
|
||||
// 创建一个初始化的字符串对象
|
||||
let lang = String::from("Rust");
|
||||
println!("First language is {lang}");
|
||||
```
|
||||
|
||||
### .capacity()
|
||||
|
||||
```rust
|
||||
let rand = String::from("Random String");
|
||||
rand.capacity() // => 13
|
||||
```
|
||||
|
||||
以字节为单位计算字符串的容量
|
||||
|
||||
### .contains()
|
||||
|
||||
```rust
|
||||
let name = String::from("ElementalX");
|
||||
name.contains("Element") // => true
|
||||
```
|
||||
|
||||
检查子字符串是否包含在原始字符串中
|
||||
|
||||
### 添加单个字符
|
||||
|
||||
```rust
|
||||
let mut half_text = String::from("Hal");
|
||||
half_text.push('f'); // => Half
|
||||
```
|
||||
|
||||
### 添加整个字符串
|
||||
|
||||
```rust
|
||||
let mut hi = String::from("Hey there...");
|
||||
hi.push_str("How are you doing??");
|
||||
// => Hey there...How are you doing??
|
||||
println!("{hi}");
|
||||
```
|
||||
|
||||
Rust 运算符
|
||||
-----------
|
||||
|
||||
### 比较运算符
|
||||
|
||||
:-|:-
|
||||
:-|:-
|
||||
`e == f` | `e` 等于 `f`
|
||||
`e != f` | `e` 不等于 `f`
|
||||
`e < f` | `e` 小于 `f`
|
||||
`e > f` | `e` 大于 `f`
|
||||
`e <= f` | `e` 小于或等于 `f`
|
||||
`e >= f` | `e` 大于或等于 `f`
|
||||
|
||||
---------
|
||||
|
||||
```rust
|
||||
let (e, f) = (1, 100);
|
||||
let greater = f > e; // => true
|
||||
let less = f < e; // => false
|
||||
let greater_equal = f >= e; // => true
|
||||
let less_equal = e <= f; // => true
|
||||
let equal_to = e == f; // => false
|
||||
let not_equal_to = e != f; // => true
|
||||
```
|
||||
|
||||
### 算术运算符
|
||||
|
||||
:-|:-
|
||||
:-|:-
|
||||
`a + b` | `a` 被添加到 `b`
|
||||
`a - b` | 从 `a` 中减去`b`
|
||||
`a / b` | `a` 除以 `b`
|
||||
`a % b` | 通过与 `b` 相除得到 `a` 的余数
|
||||
`a * b` | `a` 与 `b` 相乘
|
||||
|
||||
------
|
||||
|
||||
```rust
|
||||
let (a, b) = (4, 5);
|
||||
let sum: i32 = a + b; // => 9
|
||||
let subtractions: i32 = a - b; // => -1
|
||||
let multiplication: i32 = a * b; // => 20
|
||||
let division: i32 = a / b; // => 0
|
||||
let modulus: i32 = a % b; // => 4
|
||||
```
|
||||
|
||||
### 位运算符
|
||||
|
||||
运算符 | 描述
|
||||
:- | :-
|
||||
`g & h` | 二进制与
|
||||
`g | h` | 二进制或
|
||||
`g ^ h` | 二进制异或
|
||||
`g ~ h` | 二进制补码
|
||||
`g << h` | 二进制左移
|
||||
`g >> h` | 二进制右移
|
||||
|
||||
-----
|
||||
|
||||
```rust
|
||||
let (g, h) = (0x1, 0x2);
|
||||
let bitwise_and = g & h; // => 0
|
||||
let bitwise_or = g | h; // => 3
|
||||
let bitwise_xor = g ^ h; // => 3
|
||||
let right_shift = g >> 2; // => 0
|
||||
let left_shift = h << 4; // => 32
|
||||
```
|
||||
|
||||
### 逻辑运算符
|
||||
|
||||
示例 | 意义
|
||||
:- | :-
|
||||
`c && d` | 两者都是真的_(AND)_
|
||||
`c || d` | 要么是真的_(OR)_
|
||||
`!c` | `c` 为假 _(NOT)_
|
||||
|
||||
------
|
||||
|
||||
```rust
|
||||
let (c, d) = (true, false);
|
||||
let and = c && d; // => false
|
||||
let or = c || d; // => true
|
||||
let not = !c; // => false
|
||||
```
|
||||
|
||||
### 复合赋值运算符
|
||||
|
||||
```rust
|
||||
let mut k = 9;
|
||||
let mut l = k;
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
运算符 | 描述
|
||||
:- | :-
|
||||
`k += l` | 添加一个值并赋值,然后 `k=9`
|
||||
`k -= l` | `Substrate` 一个值并赋值,然后 `k=18`
|
||||
`k /= l` | 除以一个值并赋值,然后 `k=9`
|
||||
`k *= l` | 乘一个值并赋值,然后 `k=81`
|
||||
`k \|= l` | 按位或并赋值,则 `k=89`
|
||||
|
||||
Rust 流程控制
|
||||
------------
|
||||
|
||||
### If表达式
|
||||
|
||||
```rust
|
||||
let case1: i32 = 81;
|
||||
let case2: i32 = 82;
|
||||
if case1 < case2 {
|
||||
println!("case1 大于 case2");
|
||||
}
|
||||
```
|
||||
|
||||
### If...Else 表达式
|
||||
|
||||
```rust
|
||||
let case3 = 8;
|
||||
let case4 = 9;
|
||||
if case3 >= case4 {
|
||||
println!("case3 优于 case4");
|
||||
} else {
|
||||
println!("case4 大于 case3");
|
||||
}
|
||||
```
|
||||
|
||||
### If...Else...if...Else 表达式
|
||||
|
||||
```rust
|
||||
let foo = 12;
|
||||
let bar = 13;
|
||||
if foo == bar {
|
||||
println!("foo 等于 bar");
|
||||
} else if foo < bar {
|
||||
println!("foo 小于 bar");
|
||||
} else if foo != bar {
|
||||
println!("foo 不等于 bar");
|
||||
} else {
|
||||
println!("Nothing");
|
||||
}
|
||||
```
|
||||
|
||||
### If...let 表达式
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
```rust
|
||||
let mut arr1:[i64 ; 3] = [1,2,3];
|
||||
if let[1,2,_] = arr1{
|
||||
println!("与数组一起使用");
|
||||
}
|
||||
let mut arr2:[&str; 2] = ["one", "two"];
|
||||
if let["Apple", _] = arr2{
|
||||
println!("也适用于 str 数组");
|
||||
}
|
||||
```
|
||||
----
|
||||
```rust
|
||||
let tuple_1 = ("India", 7, 90, 90.432);
|
||||
if let(_, 7, 9, 78.99) = tuple_1{
|
||||
println!("也适用于元组");
|
||||
}
|
||||
let tuple_2 = ( 9, 7, 89, 12, "Okay");
|
||||
if let(9, 7,89, 12, blank) = tuple_2 {
|
||||
println!("一切{blank}伴侣?");
|
||||
}
|
||||
let tuple_3 = (89, 90, "Yes");
|
||||
if let(9, 89, "Yes") = tuple_3{
|
||||
println!("模式确实匹配");
|
||||
}
|
||||
else {
|
||||
println!("模式不匹配");
|
||||
}
|
||||
```
|
||||
|
||||
### 匹配表达式
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
```rust
|
||||
let day_of_week = 2;
|
||||
match day_of_week {
|
||||
1 => {
|
||||
println!("兄弟们今天是星期一");
|
||||
},
|
||||
2 => {
|
||||
println!("兄弟们今天是星期二");
|
||||
},
|
||||
3 => {
|
||||
println!("兄弟们今天是星期三");
|
||||
},
|
||||
4 => {
|
||||
println!("兄弟们今天是星期四");
|
||||
},
|
||||
5 => {
|
||||
println!("兄弟们今天是星期五");
|
||||
},
|
||||
6 => {
|
||||
println!("兄弟们今天是星期六");
|
||||
},
|
||||
7 => {
|
||||
println!("兄弟们今天是星期天");
|
||||
},
|
||||
_ => {
|
||||
println!("默认!")
|
||||
}
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
### 嵌套...If 表达式
|
||||
|
||||
```rust
|
||||
let nested_conditions = 89;
|
||||
if nested_conditions == 89 {
|
||||
let just_a_value = 98;
|
||||
if just_a_value >= 97 {
|
||||
println!("大于 97");
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### For 循环
|
||||
|
||||
```rust
|
||||
for mut i in 0..15 {
|
||||
i-=1;
|
||||
println!("i 的值为:{i}");
|
||||
}
|
||||
```
|
||||
|
||||
### While 循环
|
||||
|
||||
```rust
|
||||
let mut check = 0;
|
||||
while check < 11{
|
||||
println!("check 是:{check}");
|
||||
check+=1;
|
||||
println!("递增后:{check}");
|
||||
if check == 10{
|
||||
break; // 停止 while
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Loop 关键字
|
||||
|
||||
```rust
|
||||
loop {
|
||||
println!("你好,世界永远!");
|
||||
}
|
||||
```
|
||||
|
||||
无限循环表示
|
||||
|
||||
### Break 中断语句
|
||||
|
||||
```rust
|
||||
let mut i = 1;
|
||||
loop {
|
||||
println!("i 是 {i}");
|
||||
if i > 100 {
|
||||
break;
|
||||
}
|
||||
i *= 2;
|
||||
}
|
||||
```
|
||||
|
||||
### Continue 继续声明
|
||||
|
||||
```rust
|
||||
for (v, c) in (0..10+1).enumerate(){
|
||||
println!("{c} 数字循环");
|
||||
if v == 9{
|
||||
println!("我们继续?");
|
||||
continue;
|
||||
}
|
||||
println!{"v 的值为:{v}"};
|
||||
}
|
||||
```
|
||||
|
||||
Rust 函数
|
||||
--------
|
||||
|
||||
### 基本函数
|
||||
|
||||
```rust
|
||||
fn print_message(){
|
||||
println!("Hello, Quick Reference!");
|
||||
}
|
||||
fn main(){
|
||||
// 在 Rust 中调用函数
|
||||
print_message();
|
||||
}
|
||||
```
|
||||
|
||||
### 按值传递
|
||||
|
||||
```rust
|
||||
fn main()
|
||||
{
|
||||
let x:u32 = 10;
|
||||
let y:u32 = 20;
|
||||
|
||||
// => 200
|
||||
println!("计算: {}", cal_rect(x, y));
|
||||
}
|
||||
fn cal_rect(x:u32, y:u32) -> u32
|
||||
{
|
||||
x * y
|
||||
}
|
||||
```
|
||||
|
||||
### 通过引用传递
|
||||
|
||||
```rust
|
||||
fn main(){
|
||||
let mut by_ref = 3; // => 3
|
||||
power_of_three(&mut by_ref);
|
||||
println!("{by_ref}"); // => 9
|
||||
}
|
||||
fn power_of_three(by_ref: &mut i32){
|
||||
// 取消引用很重要
|
||||
*by_ref = *by_ref * *by_ref;
|
||||
println!("{by_ref}"); // => 9
|
||||
}
|
||||
```
|
||||
|
||||
### 返回
|
||||
|
||||
```rust
|
||||
fn main(){
|
||||
let (mut radius, mut pi) = (3.0, 3.14);
|
||||
let(area, _perimeter) = calculate (
|
||||
&mut radius,
|
||||
&mut pi
|
||||
);
|
||||
println!("圆的面积和周长为:{area} & {_perimeter}");
|
||||
}
|
||||
fn calculate(radius : &mut f64, pi: &mut f64) -> (f64, f64){
|
||||
let perimeter = 2.0 * *pi * *radius;
|
||||
let area = *pi * *radius * *radius;
|
||||
return (area, perimeter);
|
||||
}
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 数组作为参数
|
||||
|
||||
```rust
|
||||
fn main(){
|
||||
let mut array: [i32 ; 5] = [1,2,3,4,6];
|
||||
print_arrays(array);
|
||||
println!("元素:{array:?}");
|
||||
}
|
||||
fn print_arrays(mut array:[i32; 5]) {
|
||||
array[0] = 89;
|
||||
array[1] = 90;
|
||||
array[2] = 91;
|
||||
array[3] = 92;
|
||||
array[4] = 93;
|
||||
println!("元素:{array:?}");
|
||||
}
|
||||
```
|
||||
|
||||
### 返回数组
|
||||
|
||||
```rust
|
||||
fn main(){
|
||||
let mut arr:[i32; 5] = [2,4,6,8,10];
|
||||
multiply(arr);
|
||||
println!("数组是:{:?}", multiply(arr));
|
||||
}
|
||||
fn multiply (mut arr: [i32 ; 5]) -> [i32 ; 5]{
|
||||
arr[2] = 90;
|
||||
for mut i in 0..5 {
|
||||
arr[i] = arr[i] * arr[2];
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
### 泛型函数
|
||||
|
||||
```rust
|
||||
use std::fmt::Debug;
|
||||
fn foo<T>(x: &[T]) where T: Debug {
|
||||
// 省略细节
|
||||
}
|
||||
foo(&[1, 2]);
|
||||
```
|
||||
|
||||
杂项
|
||||
-----
|
||||
|
||||
### 类型断言 type-casting
|
||||
|
||||
```rust
|
||||
let a_int = 90; // int
|
||||
// int 到 float
|
||||
let mut type_cast = (a_int as f64);
|
||||
```
|
||||
------
|
||||
```rust
|
||||
let orginal: char = 'I';
|
||||
// char 到 int => 73
|
||||
let type_casted: i64 = orginal as i64;
|
||||
```
|
||||
|
||||
要在 `Rust` 中执行类型转换,必须使用 `as` 关键字
|
||||
|
||||
### 借用
|
||||
|
||||
```rust
|
||||
let mut foo = 4;
|
||||
let mut borrowed_foo = &foo;
|
||||
println!("{borrowed_foo}");
|
||||
```
|
||||
------
|
||||
```rust
|
||||
let mut bar = 3;
|
||||
let mut mutable_borrowed_bar = &mut bar;
|
||||
println!("{mutable_borrowed_bar}");
|
||||
```
|
||||
|
||||
这里借用的值使用 `&` 运算符从值一中借用值
|
||||
|
||||
### 取消引用
|
||||
|
||||
```rust
|
||||
let mut borrow = 10;
|
||||
let deref = &mut borrow;
|
||||
println!("{}", *deref);
|
||||
```
|
||||
|
||||
可以使用 `*` 操作符在 rust 中取消引用
|
||||
|
||||
### 变量范围
|
||||
|
||||
```rust
|
||||
{
|
||||
// 范围仅限于此大括号
|
||||
let a_number = 1;
|
||||
}
|
||||
println!("{a_number}");
|
||||
```
|
||||
|
||||
这将产生错误,因为变量 `a_number` 的范围在大括号处结束
|
||||
|
||||
|
||||
另见
|
||||
--------
|
||||
|
||||
- [Cargo 备忘清单](./cargo.md) _(jaywcjlove.github.io)_
|
||||
- [The Rust Document](https://doc.rust-lang.org/book/ch00-00-introduction.html) _(doc.rust-lang.org)_
|
||||
- [The Rust Reference](https://doc.rust-lang.org/reference/introduction.html) _(doc.rust-lang.org)_
|
||||
- [Rust Cheatsheet](https://phaiax.github.io/rust-cheatsheet/) _(phaiax.github.io)_
|
||||
- [Rust 标准库文档中文版](https://jaywcjlove.github.io/rust-cn-document-for-docker/std/std/) _(jaywcjlove.github.io)_
|
||||
- [Rust 程序设计语言 中文版](https://jaywcjlove.github.io/rust-cn-document-for-docker/book/) _(jaywcjlove.github.io)_
|
||||
- [Rust By Example 中文版](https://jaywcjlove.github.io/rust-cn-document-for-docker/rust-by-example-cn/) _(jaywcjlove.github.io)_
|
||||
- [Rust 参考手册中文版](https://jaywcjlove.github.io/rust-cn-document-for-docker/reference/) _(jaywcjlove.github.io)_
|
||||
- [RustDoc 手册中文版](https://jaywcjlove.github.io/rust-cn-document-for-docker/rustdoc/) _(jaywcjlove.github.io)_
|
||||
- [Rust Cookbook 中文版](https://jaywcjlove.github.io/rust-cn-document-for-docker/rust-cookbook/) _(jaywcjlove.github.io)_
|
32
docs/sed.md
32
docs/sed.md
@ -71,26 +71,26 @@ Sed 命令
|
||||
### 命令
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
| Command | Example | Description |
|
||||
|---------|----------------------------------------|-----------------------------|
|
||||
| `p` | sed -n '1,4 p' input.txt | Print lines 1-4 |
|
||||
| `p` | sed -n -e '1,4 p' -e '6,7 p' input.txt | Print lines 1-4 and 6-7 |
|
||||
| `d` | sed '1,4 d' input.txt | Print lines except 1-4 |
|
||||
| `w` | sed -n '1,4 w output.txt' input.txt | Write pattern space to file |
|
||||
| `a` | sed '2 a new-line' input.txt | Append line after |
|
||||
| `i` | sed '2 i new-line' input.txt | Insert line before |
|
||||
命令 | 示例 | 描述
|
||||
:- | :- |:-
|
||||
`p` | sed -n '1,4 p' input.txt | 打印第 1-4 行
|
||||
`p` | sed -n -e '1,4 p' -e '6,7 p' input.txt | 打印第 1-4 行和第 6-7 行
|
||||
`d` | sed '1,4 d' input.txt | 打印除 1-4 之外的行
|
||||
`w` | sed -n '1,4 w output.txt' input.txt | 将模式空间写入文件
|
||||
`a` | sed '2 a new-line' input.txt | 在后面追加一行
|
||||
`i` | sed '2 i new-line' input.txt | 在前面插入行
|
||||
<!--rehype:className=show-header-->
|
||||
|
||||
### 空间命令
|
||||
|
||||
| Command | Description |
|
||||
|---------|--------------------------------------------------------------|
|
||||
| `n` | 打印模式空间,空模式空间,读取下一行 |
|
||||
| `x` | 用保持空间交换模式空间 |
|
||||
| `h` | 复制模式空间以保持空间 |
|
||||
| `H` | 追加模式空间以保持空间 |
|
||||
| `g` | 将保持空间复制到模式空间 |
|
||||
| `G` | 将保持空间附加到模式空间 |
|
||||
命令 | 描述
|
||||
:- | :-
|
||||
`n` | 打印模式空间,空模式空间,读取下一行
|
||||
`x` | 用保持空间交换模式空间
|
||||
`h` | 复制模式空间以保持空间
|
||||
`H` | 追加模式空间以保持空间
|
||||
`g` | 将保持空间复制到模式空间
|
||||
`G` | 将保持空间附加到模式空间
|
||||
|
||||
### Flags
|
||||
|
||||
|
379
docs/vue.md
379
docs/vue.md
@ -11,8 +11,9 @@ Vue 3 备忘清单
|
||||
|
||||
Vue 是一套用于构建用户界面的渐进式框架
|
||||
|
||||
- [Vue 3.x 官方文档](https://cn.vuejs.org/)
|
||||
- [Vue Router 4.x 官方文档](https://router.vuejs.org/zh/)
|
||||
- [Vue 3.x 官方文档](https://cn.vuejs.org/) _(cn.vuejs.org)_
|
||||
- [Vue Router 4.x 官方文档](https://router.vuejs.org/zh/) _(router.vuejs.org)_
|
||||
- [Vue 2 备忘清单](./vue2.md)
|
||||
<!--rehype:className=style-round-->
|
||||
|
||||
注意:Vue 3.x 版本对应 Vue Router 4.x 路由版本
|
||||
@ -268,4 +269,376 @@ v-on:submit.prevent="onSubmit"
|
||||
┆ ┆ ╰─ Modifiers 由前导点表示
|
||||
┆ ╰─ Argument 跟随冒号或速记符号
|
||||
╰─ Name 以 v- 开头使用速记时可以省略
|
||||
```
|
||||
```
|
||||
|
||||
响应式基础
|
||||
---
|
||||
|
||||
### 声明状态
|
||||
|
||||
```html
|
||||
<div>{{ count }}</div>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```js {2,4}
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
count: 0
|
||||
}
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
### 声明方法
|
||||
|
||||
```html
|
||||
<button @click="increment">
|
||||
{{ count }}
|
||||
</button>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```js {8-10}
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
count: 0
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
increment() {
|
||||
this.count++
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 有状态方法
|
||||
|
||||
```js
|
||||
import { debounce } from 'lodash-es'
|
||||
export default {
|
||||
created() {
|
||||
// 每个实例都有了自己的预置防抖的处理函数
|
||||
this.debouncedClick = debounce(this.click, 500)
|
||||
},
|
||||
unmounted() {
|
||||
// 最好是在组件卸载时
|
||||
// 清除掉防抖计时器
|
||||
this.debouncedClick.cancel()
|
||||
},
|
||||
methods: {
|
||||
click() {
|
||||
// ... 对点击的响应 ...
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
API 参考
|
||||
---
|
||||
|
||||
### 全局 API - 应用实例
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`createApp()` | [#](https://cn.vuejs.org/api/application.html#create-app)
|
||||
`createSSRApp()` | [#](https://cn.vuejs.org/api/application.html#create-ssr-app)
|
||||
`app.mount()` | [#](https://cn.vuejs.org/api/application.html#app-mount)
|
||||
`app.unmount()` | [#](https://cn.vuejs.org/api/application.html#app-unmount)
|
||||
`app.provide()` | [#](https://cn.vuejs.org/api/application.html#app-provide)
|
||||
`app.component()` | [#](https://cn.vuejs.org/api/application.html#app-component)
|
||||
`app.directive()` | [#](https://cn.vuejs.org/api/application.html#app-directive)
|
||||
`app.use()` | [#](https://cn.vuejs.org/api/application.html#app-use)
|
||||
`app.mixin()` | [#](https://cn.vuejs.org/api/application.html#app-mixin)
|
||||
`app.version` | [#](https://cn.vuejs.org/api/application.html#app-version)
|
||||
`app.config` | [#](https://cn.vuejs.org/api/application.html#app-config)
|
||||
`app.config.errorHandler` | [#](https://cn.vuejs.org/api/application.html#app-config-errorhandler)
|
||||
`app.config.warnHandler` | [#](https://cn.vuejs.org/api/application.html#app-config-warnhandler)
|
||||
`app.config.performance` | [#](https://cn.vuejs.org/api/application.html#app-config-performance)
|
||||
`app.config.compilerOptions` | [#](https://cn.vuejs.org/api/application.html#app-config-compileroptions)
|
||||
`app.config.globalProperties` | [#](https://cn.vuejs.org/api/application.html#app-config-globalproperties)
|
||||
`app.config.optionMergeStrategies` | [#](https://cn.vuejs.org/api/application.html#app-config-optionmergestrategies)
|
||||
|
||||
### 全局 API - 通用
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`version` | [#](https://cn.vuejs.org/api/general.html#version)
|
||||
`nextTick()` | [#](https://cn.vuejs.org/api/general.html#nexttick)
|
||||
`defineComponent()` | [#](https://cn.vuejs.org/api/general.html#definecomponent)
|
||||
`defineAsyncComponent()` | [#](https://cn.vuejs.org/api/general.html#defineasynccomponent)
|
||||
`defineCustomElement()` | [#](https://cn.vuejs.org/api/general.html#definecustomelement)
|
||||
|
||||
### 组合式 API - setup()
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`基本使用` | [#](https://cn.vuejs.org/api/composition-api-setup.html#basic-usage)
|
||||
`访问 Props` | [#](https://cn.vuejs.org/api/composition-api-setup.html#accessing-props)
|
||||
`Setup 上下文` | [#](https://cn.vuejs.org/api/composition-api-setup.html#setup-context)
|
||||
`与渲染函数一起使用` | [#](https://cn.vuejs.org/api/composition-api-setup.html#usage-with-render-functions)
|
||||
|
||||
### 组合式 API - 响应式: 工具
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`isRef()` | [#](https://cn.vuejs.org/api/reactivity-utilities.html#isref)
|
||||
`unref()` | [#](https://cn.vuejs.org/api/reactivity-utilities.html#unref)
|
||||
`toRef()` | [#](https://cn.vuejs.org/api/reactivity-utilities.html#toref)
|
||||
`toRefs()` | [#](https://cn.vuejs.org/api/reactivity-utilities.html#torefs)
|
||||
`isProxy()` | [#](https://cn.vuejs.org/api/reactivity-utilities.html#isproxy)
|
||||
`isReactive()` | [#](https://cn.vuejs.org/api/reactivity-utilities.html#isreactive)
|
||||
`isReadonly()` | [#](https://cn.vuejs.org/api/reactivity-utilities.html#isreadonly)
|
||||
|
||||
### 组合式 API - 生命周期钩子
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`onMounted()` | 组件挂载完成后执行 [#](https://cn.vuejs.org/api/composition-api-lifecycle.html#onmounted)
|
||||
`onUpdated()` | 状态变更而更新其 DOM 树之后调用 [#](https://cn.vuejs.org/api/composition-api-lifecycle.html#onupdated)
|
||||
`onUnmounted()` | 组件实例被卸载之后调用 [#](https://cn.vuejs.org/api/composition-api-lifecycle.html#onunmounted)
|
||||
`onBeforeMount()` | 组件被挂载之前被调用 [#](https://cn.vuejs.org/api/composition-api-lifecycle.html#onbeforemount)
|
||||
`onBeforeUpdate()` | 状态变更而更新其 DOM 树之前调用 [#](https://cn.vuejs.org/api/composition-api-lifecycle.html#onbeforeupdate)
|
||||
`onBeforeUnmount()` | 组件实例被卸载之前调用 [#](https://cn.vuejs.org/api/composition-api-lifecycle.html#onbeforeunmount)
|
||||
`onErrorCaptured()` | 捕获了后代组件传递的错误时调用 [#](https://cn.vuejs.org/api/composition-api-lifecycle.html#onerrorcaptured)
|
||||
`onRenderTracked()` | 组件渲染过程中追踪到响应式依赖时调用 [#](https://cn.vuejs.org/api/composition-api-lifecycle.html#onrendertracked)
|
||||
`onRenderTriggered()` | 响应式依赖的变更触发了组件渲染时调用 [#](https://cn.vuejs.org/api/composition-api-lifecycle.html#onrendertriggered)
|
||||
`onActivated()` | 若组件实例是 \<KeepAlive> 缓存树的一部分,当组件被插入到 DOM 中时调用 [#](https://cn.vuejs.org/api/composition-api-lifecycle.html#onactivated)
|
||||
`onDeactivated()` | 若组件实例是 \<KeepAlive> 缓存树的一部分,当组件从 DOM 中被移除时调用 [#](https://cn.vuejs.org/api/composition-api-lifecycle.html#ondeactivated)
|
||||
`onServerPrefetch()` | 组件实例在服务器上被渲染之前调用 [#](https://cn.vuejs.org/api/composition-api-lifecycle.html#onserverprefetch)
|
||||
<!--rehype:className=style-list-->
|
||||
|
||||
### 组合式 API - 依赖注入
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`provide()` | [#](https://cn.vuejs.org/api/composition-api-dependency-injection.html#provide)
|
||||
`inject()` | [#](https://cn.vuejs.org/api/composition-api-dependency-injection.html#inject)
|
||||
|
||||
### 组合式 API - 响应式: 核心
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`ref()` | [#](https://cn.vuejs.org/api/reactivity-core.html#ref)
|
||||
`computed ()` | [#](https://cn.vuejs.org/api/reactivity-core.html#computed)
|
||||
`reactive()` | [#](https://cn.vuejs.org/api/reactivity-core.html#reactive)
|
||||
`readonly()` | [#](https://cn.vuejs.org/api/reactivity-core.html#readonly)
|
||||
`watchEffect()` | [#](https://cn.vuejs.org/api/reactivity-core.html#watcheffect)
|
||||
`watchPostEffect()` | [#](https://cn.vuejs.org/api/reactivity-core.html#watchposteffect)
|
||||
`watchSyncEffect()` | [#](https://cn.vuejs.org/api/reactivity-core.html#watchsynceffect)
|
||||
`watch()` | [#](https://cn.vuejs.org/api/reactivity-core.html#watch)
|
||||
|
||||
### 选项式 API - 状态选项
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`data` | [#](https://cn.vuejs.org/api/options-state.html#data)
|
||||
`props` | [#](https://cn.vuejs.org/api/options-state.html#props)
|
||||
`computed` | [#](https://cn.vuejs.org/api/options-state.html#computed)
|
||||
`methods` | [#](https://cn.vuejs.org/api/options-state.html#methods)
|
||||
`watch` | [#](https://cn.vuejs.org/api/options-state.html#watch)
|
||||
`emits` | [#](https://cn.vuejs.org/api/options-state.html#emits)
|
||||
`expose` | [#](https://cn.vuejs.org/api/options-state.html#expose)
|
||||
|
||||
### 选项式 API - 生命周期选项
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`beforeCreate` | [#](https://cn.vuejs.org/api/options-lifecycle.html#beforecreate)
|
||||
`created` | [#](https://cn.vuejs.org/api/options-lifecycle.html#created)
|
||||
`beforeMount` | [#](https://cn.vuejs.org/api/options-lifecycle.html#beforemount)
|
||||
`mounted` | [#](https://cn.vuejs.org/api/options-lifecycle.html#mounted)
|
||||
`beforeUpdate` | [#](https://cn.vuejs.org/api/options-lifecycle.html#beforeupdate)
|
||||
`updated` | [#](https://cn.vuejs.org/api/options-lifecycle.html#updated)
|
||||
`beforeUnmount` | [#](https://cn.vuejs.org/api/options-lifecycle.html#beforeunmount)
|
||||
`unmounted` | [#](https://cn.vuejs.org/api/options-lifecycle.html#unmounted)
|
||||
`errorCaptured` | [#](https://cn.vuejs.org/api/options-lifecycle.html#errorcaptured)
|
||||
`renderTracked` | [#](https://cn.vuejs.org/api/options-lifecycle.html#rendertracked)
|
||||
`renderTriggered` | [#](https://cn.vuejs.org/api/options-lifecycle.html#rendertriggered-sup-classvt-badge-dev-only)
|
||||
`activated` | [#](https://cn.vuejs.org/api/options-lifecycle.html#activated)
|
||||
`deactivated` | [#](https://cn.vuejs.org/api/options-lifecycle.html#deactivated)
|
||||
`serverPrefetch` | [#](https://cn.vuejs.org/api/options-lifecycle.html#serverprefetch)
|
||||
|
||||
### 选项式 API - 其他杂项
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`name` | 显式声明组件展示时的名称 [#](https://cn.vuejs.org/api/options-misc.html#name)
|
||||
`inheritAttrs` | 默认的组件 `attribute` 透传行为 [#](https://cn.vuejs.org/api/options-misc.html#inheritattrs)
|
||||
`components` | [#](https://cn.vuejs.org/api/options-misc.html#components)
|
||||
`directives` | [#](https://cn.vuejs.org/api/options-misc.html#directives)
|
||||
|
||||
### 选项式 API - 渲染选项
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`template` | [#](https://cn.vuejs.org/api/options-rendering.html#template)
|
||||
`render` | [#](https://cn.vuejs.org/api/options-rendering.html#render)
|
||||
`compilerOptions` | [#](https://cn.vuejs.org/api/options-rendering.html#compileroptions)
|
||||
|
||||
### 选项式 API - 组件实例
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`$data` | [#](https://cn.vuejs.org/api/component-instance.html#data)
|
||||
`$props` | [#](https://cn.vuejs.org/api/component-instance.html#props)
|
||||
`$el` | [#](https://cn.vuejs.org/api/component-instance.html#el)
|
||||
`$options` | [#](https://cn.vuejs.org/api/component-instance.html#options)
|
||||
`$parent` | [#](https://cn.vuejs.org/api/component-instance.html#parent)
|
||||
`$root` | [#](https://cn.vuejs.org/api/component-instance.html#root)
|
||||
`$slots` | [#](https://cn.vuejs.org/api/component-instance.html#slots)
|
||||
`$refs` | [#](https://cn.vuejs.org/api/component-instance.html#refs)
|
||||
`$attrs` | [#](https://cn.vuejs.org/api/component-instance.html#attrs)
|
||||
`$watch()` | [#](https://cn.vuejs.org/api/component-instance.html#watch)
|
||||
`$emit()` | [#](https://cn.vuejs.org/api/component-instance.html#emit)
|
||||
`$forceUpdate()` | [#](https://cn.vuejs.org/api/component-instance.html#forceupdate)
|
||||
`$nextTick()` | [#](https://cn.vuejs.org/api/component-instance.html#nexttick)
|
||||
|
||||
### 选项式 API - 组合选项
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`provide` | [#](https://cn.vuejs.org/api/options-composition.html#provide)
|
||||
`inject` | [#](https://cn.vuejs.org/api/options-composition.html#inject)
|
||||
`mixins` | [#](https://cn.vuejs.org/api/options-composition.html#mixins)
|
||||
`extends` | [#](https://cn.vuejs.org/api/options-composition.html#extends)
|
||||
|
||||
### 内置内容 - 指令
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`v-text` | [#](https://cn.vuejs.org/api/built-in-directives.html#v-text)
|
||||
`v-html` | [#](https://cn.vuejs.org/api/built-in-directives.html#v-html)
|
||||
`v-show` | [#](https://cn.vuejs.org/api/built-in-directives.html#v-show)
|
||||
`v-if` | [#](https://cn.vuejs.org/api/built-in-directives.html#v-if)
|
||||
`v-else` | [#](https://cn.vuejs.org/api/built-in-directives.html#v-else)
|
||||
`v-else-if` | [#](https://cn.vuejs.org/api/built-in-directives.html#v-else-if)
|
||||
`v-for` | [#](https://cn.vuejs.org/api/built-in-directives.html#v-for)
|
||||
`v-on` | [#](https://cn.vuejs.org/api/built-in-directives.html#v-on)
|
||||
`v-bind` | [#](https://cn.vuejs.org/api/built-in-directives.html#v-bind)
|
||||
`v-model` | [#](https://cn.vuejs.org/api/built-in-directives.html#v-model)
|
||||
`v-slot` | [#](https://cn.vuejs.org/api/built-in-directives.html#v-slot)
|
||||
`v-pre` | [#](https://cn.vuejs.org/api/built-in-directives.html#v-pre)
|
||||
`v-once` | [#](https://cn.vuejs.org/api/built-in-directives.html#v-once)
|
||||
`v-memo` | [#](https://cn.vuejs.org/api/built-in-directives.html#v-memo)
|
||||
`v-cloak` | [#](https://cn.vuejs.org/api/built-in-directives.html#v-cloak)
|
||||
|
||||
### 内置内容 - 组件
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`<Transition>` | [#](https://cn.vuejs.org/api/built-in-components.html#transition)
|
||||
`<TransitionGroup>` | [#](https://cn.vuejs.org/api/built-in-components.html#transitiongroup)
|
||||
`<KeepAlive>` | [#](https://cn.vuejs.org/api/built-in-components.html#keepalive)
|
||||
`<Teleport>` | [#](https://cn.vuejs.org/api/built-in-components.html#teleport)
|
||||
`<Suspense>` | [#](https://cn.vuejs.org/api/built-in-components.html#suspense)
|
||||
|
||||
### 内置内容 - 特殊 Attributes
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`key` | [#](https://cn.vuejs.org/api/built-in-special-attributes.html#key)
|
||||
`ref` | [#](https://cn.vuejs.org/api/built-in-special-attributes.html#ref)
|
||||
`is` | [#](https://cn.vuejs.org/api/built-in-special-attributes.html#is)
|
||||
|
||||
### 内置内容 - 特殊元素
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`<component>` | [#](https://cn.vuejs.org/api/built-in-special-elements.html#component)
|
||||
`<slot>` | [#](https://cn.vuejs.org/api/built-in-special-elements.html#slot)
|
||||
|
||||
### 单文件组件 - 语法定义
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`总览` | [#](https://cn.vuejs.org/api/sfc-spec.html#overview)
|
||||
`相应语言块` | [#](https://cn.vuejs.org/api/sfc-spec.html#language-blocks)
|
||||
`自动名称推导` | [#](https://cn.vuejs.org/api/sfc-spec.html#automatic-name-inference)
|
||||
`预处理器` | [#](https://cn.vuejs.org/api/sfc-spec.html#pre-processors)
|
||||
`Src 导入` | [#](https://cn.vuejs.org/api/sfc-spec.html#src-imports)
|
||||
`注释` | [#](https://cn.vuejs.org/api/sfc-spec.html#comments)
|
||||
|
||||
### 单文件组件 - \<script setup>
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`基本语法` | [#](https://cn.vuejs.org/api/sfc-script-setup.html#basic-syntax)
|
||||
`响应式` | [#](https://cn.vuejs.org/api/sfc-script-setup.html#reactivity)
|
||||
`使用组件` | [#](https://cn.vuejs.org/api/sfc-script-setup.html#using-components)
|
||||
`使用自定义指令` | [#](https://cn.vuejs.org/api/sfc-script-setup.html#using-custom-directives)
|
||||
`defineProps() 和 defineEmits()` | [#](https://cn.vuejs.org/api/sfc-script-setup.html#defineprops-defineemits)
|
||||
`defineExpose` | [#](https://cn.vuejs.org/api/sfc-script-setup.html#defineexpose)
|
||||
`useSlots() 和 useAttrs()` | [#](https://cn.vuejs.org/api/sfc-script-setup.html#useslots-useattrs)
|
||||
`与普通的 <script> 一起使用` | [#](https://cn.vuejs.org/api/sfc-script-setup.html#usage-alongside-normal-script)
|
||||
`顶层 await` | [#](https://cn.vuejs.org/api/sfc-script-setup.html#top-level-await)
|
||||
`针对 TypeScript 的功能` | [#](https://cn.vuejs.org/api/sfc-script-setup.html#typescript-only-features)
|
||||
`限制` | [#](https://cn.vuejs.org/api/sfc-script-setup.html#restrictions)
|
||||
|
||||
### 单文件组件 - CSS 功能
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`组件作用域 CSS` | [#](https://cn.vuejs.org/api/sfc-css-features.html#scoped-css)
|
||||
`CSS Modules` | [#](https://cn.vuejs.org/api/sfc-css-features.html#css-modules)
|
||||
`CSS 中的 v-bind()` | [#](https://cn.vuejs.org/api/sfc-css-features.html#v-bind-in-css)
|
||||
|
||||
### 进阶 API - 渲染函数
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`h()` | [#](https://cn.vuejs.org/api/render-function.html#h)
|
||||
`mergeProps()` | [#](https://cn.vuejs.org/api/render-function.html#mergeprops)
|
||||
`cloneVNode()` | [#](https://cn.vuejs.org/api/render-function.html#clonevnode)
|
||||
`isVNode()` | [#](https://cn.vuejs.org/api/render-function.html#isvnode)
|
||||
`resolveComponent()` | [#](https://cn.vuejs.org/api/render-function.html#resolvecomponent)
|
||||
`resolveDirective()` | [#](https://cn.vuejs.org/api/render-function.html#resolvedirective)
|
||||
`withDirectives()` | [#](https://cn.vuejs.org/api/render-function.html#withdirectives)
|
||||
`withModifiers()` | [#](https://cn.vuejs.org/api/render-function.html#withmodifiers)
|
||||
|
||||
### 进阶 API - 服务端渲染
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`renderToString()` | [#](https://cn.vuejs.org/api/ssr.html#rendertostring)
|
||||
`renderToNodeStream()` | [#](https://cn.vuejs.org/api/ssr.html#rendertonodestream)
|
||||
`pipeToNodeWritable()` | [#](https://cn.vuejs.org/api/ssr.html#pipetonodewritable)
|
||||
`renderToWebStream()` | [#](https://cn.vuejs.org/api/ssr.html#rendertowebstream)
|
||||
`pipeToWebWritable()` | [#](https://cn.vuejs.org/api/ssr.html#pipetowebwritable)
|
||||
`renderToSimpleStream()` | [#](https://cn.vuejs.org/api/ssr.html#rendertosimplestream)
|
||||
`useSSRContext()` | [#](https://cn.vuejs.org/api/ssr.html#usessrcontext)
|
||||
|
||||
### 进阶 API - TypeScript 工具类型
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`PropType<T>` | [#](https://cn.vuejs.org/api/utility-types.html#proptypet)
|
||||
`ComponentCustomProperties` | [#](https://cn.vuejs.org/api/utility-types.html#componentcustomproperties)
|
||||
`ComponentCustomOptions` | [#](https://cn.vuejs.org/api/utility-types.html#componentcustomoptions)
|
||||
`ComponentCustomProps` | [#](https://cn.vuejs.org/api/utility-types.html#componentcustomprops)
|
||||
`CSSProperties` | [#](https://cn.vuejs.org/api/utility-types.html#cssproperties)
|
||||
|
||||
### 进阶 API - 自定义渲染
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`createRenderer()` | [#](https://cn.vuejs.org/api/custom-renderer.html#create-renderer)
|
||||
|
||||
另见
|
||||
---
|
||||
|
||||
- [Vue 3.x 官方文档](https://cn.vuejs.org/)
|
||||
- [Vue Router 4.x 官方文档](https://router.vuejs.org/zh/)
|
@ -1,4 +1,4 @@
|
||||
Vue2 备忘清单
|
||||
Vue 2 备忘清单
|
||||
===
|
||||
|
||||
渐进式 JavaScript 框架 [Vue 2](https://v2.cn.vuejs.org/) 备忘清单的快速参考列表,包含常用 API 和示例。
|
||||
@ -10,8 +10,9 @@ Vue2 备忘清单
|
||||
|
||||
Vue 是一套用于构建用户界面的渐进式框架
|
||||
|
||||
- [Vue 2.x 官方文档](https://v2.cn.vuejs.org/)
|
||||
- [Vue Router 3.x 官方文档](https://v3.router.vuejs.org/)
|
||||
- [Vue 2.x 官方文档](https://v2.cn.vuejs.org/) _(v2.cn.vuejs.org)_
|
||||
- [Vue Router 3.x 官方文档](https://v3.router.vuejs.org/) _(v3.router.vuejs.org)_
|
||||
- [Vue 3 备忘清单](./vue.md)
|
||||
<!--rehype:className=style-round-->
|
||||
|
||||
注意:Vue 2.x 版本对应 Vue Router 3.x 路由版本
|
||||
|
10
docs/yaml.md
10
docs/yaml.md
@ -57,7 +57,7 @@ other_thing: *VAR_NAME
|
||||
|
||||
#### ↓ 等效的 JSON
|
||||
|
||||
```json {.wrap}
|
||||
```json
|
||||
{
|
||||
"some_thing": "foobar",
|
||||
"other_thing": "foobar"
|
||||
@ -84,7 +84,7 @@ description: |
|
||||
|
||||
#### ↓ 等效的 JSON
|
||||
|
||||
```json {.wrap}
|
||||
```json
|
||||
{"description": "hello\nworld\n"}
|
||||
```
|
||||
|
||||
@ -102,7 +102,7 @@ child:
|
||||
|
||||
#### ↓ 等效的 JSON
|
||||
|
||||
```json {.wrap}
|
||||
```json
|
||||
{
|
||||
"parent": {
|
||||
"a": 2,
|
||||
@ -129,7 +129,7 @@ other_values:
|
||||
|
||||
#### ↓ 等效的 JSON
|
||||
|
||||
```json {.wrap}
|
||||
```json
|
||||
{
|
||||
"values": [
|
||||
"Will be",
|
||||
@ -154,7 +154,7 @@ description: >
|
||||
|
||||
#### ↓ 等效的 JSON
|
||||
|
||||
```json {.wrap}
|
||||
```json
|
||||
{"description": "hello world\n"}
|
||||
```
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wcj/reference",
|
||||
"version": "1.15.0",
|
||||
"version": "1.16.0",
|
||||
"description": "为开发人员分享快速参考备忘单(主要是方便自己)。",
|
||||
"author": "jaywcjlove",
|
||||
"license": "MIT",
|
||||
|
3
scripts/assets/ansible.svg
Normal file
3
scripts/assets/ansible.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" height="1em" width="1em" viewBox="0 0 65 65">
|
||||
<path fill="currentColor" d="M32,0 C49.672,0 64,14.328 64,32 C64,49.674 49.674,64 32,64 C14.326,64 0,49.674 0,32 C0,14.326 14.328,0 32,0 Z M32.539,12.688 C31.666,12.688 30.875,13.156 30.511,14.04 L16.52,47.664 L21.303,47.664 L26.837,33.801 L43.352,47.144 C44.016,47.681 44.496,47.924 45.119,47.924 C46.367,47.924 47.457,46.988 47.457,45.638 C47.457,45.418 47.379,45.068 47.239,44.694 L34.512,14.04 C34.148,13.156 33.412,12.688 32.539,12.688 Z M32.54,19.548 L40.82,39.986 L28.312,30.133 L32.54,19.548 Z" transform="translate(.38 .76)"/>
|
||||
</svg>
|
After Width: | Height: | Size: 648 B |
3
scripts/assets/cargo.svg
Normal file
3
scripts/assets/cargo.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="1em" height="1em" viewBox="0 0 32 32">
|
||||
<path d="M15 3.77a.951.951 0 1 1 1.902 0 .951.951 0 0 1-1.902 0M3.654 12.38a.951.951 0 1 1 1.902 0 .951.951 0 0 1-1.902 0m22.692.044a.951.951 0 0 1 1.902 0 .951.951 0 0 1-1.902 0M6.406 13.73a.87.87 0 0 0 .441-1.146l-.422-.954h1.66v7.48H4.736a11.71 11.71 0 0 1-.379-4.47zm6.942.184v-2.205H17.3c.204 0 1.44.236 1.44 1.16 0 .768-.95 1.044-1.73 1.044zM7.952 25.785a.951.951 0 1 1 1.902 0 .951.951 0 0 1-1.902 0m14.093.044a.951.951 0 0 1 1.902 0 .951.951 0 0 1-1.902 0m.294-2.157a.867.867 0 0 0-1.03.667l-.477 2.228a11.71 11.71 0 0 1-9.765-.047l-.477-2.228a.865.865 0 0 0-1.03-.667l-1.967.422a11.71 11.71 0 0 1-1.017-1.199h9.57c.108 0 .18-.02.18-.118v-3.385c0-.1-.072-.118-.18-.118h-2.8v-2.146h3.027c.276 0 1.477.08 1.862 1.614l.565 2.5c.18.55.913 1.653 1.693 1.653h4.94a11.71 11.71 0 0 1-1.085 1.255zm5.314-8.938a11.71 11.71 0 0 1 .025 2.033h-1.2c-.12 0-.17.08-.17.197v.552c0 1.3-.732 1.58-1.374 1.653-.61.07-1.29-.256-1.372-.63-.36-2.028-.96-2.46-1.9-3.21 1.177-.748 2.402-1.85 2.402-3.327 0-1.594-1.093-2.598-1.838-3.09-1.045-.69-2.202-.827-2.514-.827H7.277a11.71 11.71 0 0 1 6.551-3.697l1.465 1.537c.33.347.88.36 1.226.028l1.64-1.567a11.71 11.71 0 0 1 8.017 5.709l-1.122 2.534a.87.87 0 0 0 .441 1.146zm2.798.04-.038-.392 1.156-1.078c.235-.22.147-.66-.153-.772l-1.477-.552-.116-.38.92-1.28c.188-.26.015-.675-.3-.727l-1.558-.253-.187-.35.655-1.437c.134-.293-.115-.667-.437-.655l-1.58.055-.25-.303.363-1.54c.073-.313-.244-.63-.557-.557l-1.54.363-.304-.25.055-1.58c.012-.32-.362-.57-.654-.437l-1.436.655-.35-.188-.254-1.558c-.05-.316-.467-.488-.727-.3l-1.28.92-.38-.115L19.47.586c-.112-.3-.553-.388-.772-.154L17.62 1.588l-.392-.038-.832-1.345c-.168-.272-.62-.272-.787 0l-.832 1.345-.392.038L13.305.43c-.22-.234-.66-.147-.772.154l-.552 1.477-.38.115-1.28-.92c-.26-.188-.676-.015-.727.3L9.34 3.114l-.35.188-1.436-.655c-.292-.133-.667.117-.654.437l.055 1.58-.304.25-1.54-.363c-.313-.073-.63.244-.557.557l.363 1.54-.25.303-1.58-.055c-.32-.01-.57.362-.437.655l.655 1.437-.188.35-1.558.253c-.316.05-.488.467-.3.727l.92 1.28-.116.38-1.477.552c-.3.112-.388.553-.153.772l1.156 1.078-.038.392-1.345.832c-.272.168-.272.62 0 .787l1.345.832.038.392L.43 18.697c-.234.22-.147.66.153.772l1.477.552.116.38-.92 1.28c-.187.26-.015.676.3.727l1.557.253.188.35-.655 1.436c-.133.292.118.667.437.655l1.58-.055.25.304-.363 1.54c-.073.312.244.63.557.556l1.54-.363.304.25-.055 1.58c-.012.32.362.57.654.437l1.436-.655.35.188.254 1.557c.05.317.467.488.727.302l1.28-.922.38.116.552 1.477c.112.3.553.388.772.153l1.078-1.156.392.04.832 1.345c.168.27.618.272.787 0l.832-1.345.392-.04 1.078 1.156c.22.235.66.147.772-.153l.552-1.477.38-.116 1.28.922c.26.187.676.015.727-.302l.254-1.557.35-.188 1.436.655c.292.133.666-.116.654-.437l-.055-1.58.303-.25 1.54.363c.313.073.63-.244.557-.556l-.363-1.54.25-.304 1.58.055c.32.013.57-.363.437-.655l-.655-1.436.187-.35 1.558-.253c.317-.05.49-.466.3-.727l-.92-1.28.116-.38 1.477-.552c.3-.113.388-.553.153-.772l-1.156-1.078.038-.392 1.345-.832c.272-.168.273-.618 0-.787z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 3.0 KiB |
3
scripts/assets/cmake.svg
Normal file
3
scripts/assets/cmake.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg" height="1em" width="1em">
|
||||
<path d="M11.769.066.067 23.206l12.76-10.843zm11.438 23.868L7.471 17.587 0 23.934zm.793-.198L12.298.463l1.719 19.24zM12.893 12.959l-5.025 4.298 5.62 2.248z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 274 B |
3
scripts/assets/conan.svg
Normal file
3
scripts/assets/conan.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg" height="1em" width="1em">
|
||||
<path d="M11.709 0 0 5.534V16.76L11.984 24l4.857-2.706V9.998c.13-.084.275-.196.399-.27l.032-.017c.197-.11.329-.102.23.33v10.884l6.466-3.603V6.11L24 6.093Zm.915 2.83c.932.02 1.855.191 2.706.552a9.106 9.106 0 0 1 3.45 2.429 62.814 62.814 0 0 1-3.044 1.616c.56-.853.14-2.009-.76-2.455-.93-.648-2.093-.73-3.205-.674-1.064.175-2.258.51-2.893 1.474-.722.862-.084 2.11.914 2.408 1.2.509 2.543.38 3.806.413-.975.457-1.931.97-2.927 1.358-1.701-.176-3.585-.917-4.374-2.51-.574-1.178.215-2.572 1.319-3.14a11.426 11.426 0 0 1 3.336-1.348 9.212 9.212 0 0 1 1.672-.123Z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 674 B |
3
scripts/assets/gmail.svg
Normal file
3
scripts/assets/gmail.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg" height="1em" width="1em">
|
||||
<path d="M24 5.457v13.909c0 .904-.732 1.636-1.636 1.636h-3.819V11.73L12 16.64l-6.545-4.91v9.273H1.636A1.636 1.636 0 0 1 0 19.366V5.457c0-2.023 2.309-3.178 3.927-1.964L5.455 4.64 12 9.548l6.545-4.91 1.528-1.145C21.69 2.28 24 3.434 24 5.457z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 358 B |
3
scripts/assets/rust.svg
Normal file
3
scripts/assets/rust.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="1em" height="1em" viewBox="0 0 32 32">
|
||||
<path d="M15 3.77a.951.951 0 1 1 1.902 0 .951.951 0 0 1-1.902 0M3.654 12.38a.951.951 0 1 1 1.902 0 .951.951 0 0 1-1.902 0m22.692.044a.951.951 0 0 1 1.902 0 .951.951 0 0 1-1.902 0M6.406 13.73a.87.87 0 0 0 .441-1.146l-.422-.954h1.66v7.48H4.736a11.71 11.71 0 0 1-.379-4.47zm6.942.184v-2.205H17.3c.204 0 1.44.236 1.44 1.16 0 .768-.95 1.044-1.73 1.044zM7.952 25.785a.951.951 0 1 1 1.902 0 .951.951 0 0 1-1.902 0m14.093.044a.951.951 0 0 1 1.902 0 .951.951 0 0 1-1.902 0m.294-2.157a.867.867 0 0 0-1.03.667l-.477 2.228a11.71 11.71 0 0 1-9.765-.047l-.477-2.228a.865.865 0 0 0-1.03-.667l-1.967.422a11.71 11.71 0 0 1-1.017-1.199h9.57c.108 0 .18-.02.18-.118v-3.385c0-.1-.072-.118-.18-.118h-2.8v-2.146h3.027c.276 0 1.477.08 1.862 1.614l.565 2.5c.18.55.913 1.653 1.693 1.653h4.94a11.71 11.71 0 0 1-1.085 1.255zm5.314-8.938a11.71 11.71 0 0 1 .025 2.033h-1.2c-.12 0-.17.08-.17.197v.552c0 1.3-.732 1.58-1.374 1.653-.61.07-1.29-.256-1.372-.63-.36-2.028-.96-2.46-1.9-3.21 1.177-.748 2.402-1.85 2.402-3.327 0-1.594-1.093-2.598-1.838-3.09-1.045-.69-2.202-.827-2.514-.827H7.277a11.71 11.71 0 0 1 6.551-3.697l1.465 1.537c.33.347.88.36 1.226.028l1.64-1.567a11.71 11.71 0 0 1 8.017 5.709l-1.122 2.534a.87.87 0 0 0 .441 1.146zm2.798.04-.038-.392 1.156-1.078c.235-.22.147-.66-.153-.772l-1.477-.552-.116-.38.92-1.28c.188-.26.015-.675-.3-.727l-1.558-.253-.187-.35.655-1.437c.134-.293-.115-.667-.437-.655l-1.58.055-.25-.303.363-1.54c.073-.313-.244-.63-.557-.557l-1.54.363-.304-.25.055-1.58c.012-.32-.362-.57-.654-.437l-1.436.655-.35-.188-.254-1.558c-.05-.316-.467-.488-.727-.3l-1.28.92-.38-.115L19.47.586c-.112-.3-.553-.388-.772-.154L17.62 1.588l-.392-.038-.832-1.345c-.168-.272-.62-.272-.787 0l-.832 1.345-.392.038L13.305.43c-.22-.234-.66-.147-.772.154l-.552 1.477-.38.115-1.28-.92c-.26-.188-.676-.015-.727.3L9.34 3.114l-.35.188-1.436-.655c-.292-.133-.667.117-.654.437l.055 1.58-.304.25-1.54-.363c-.313-.073-.63.244-.557.557l.363 1.54-.25.303-1.58-.055c-.32-.01-.57.362-.437.655l.655 1.437-.188.35-1.558.253c-.316.05-.488.467-.3.727l.92 1.28-.116.38-1.477.552c-.3.112-.388.553-.153.772l1.156 1.078-.038.392-1.345.832c-.272.168-.272.62 0 .787l1.345.832.038.392L.43 18.697c-.234.22-.147.66.153.772l1.477.552.116.38-.92 1.28c-.187.26-.015.676.3.727l1.557.253.188.35-.655 1.436c-.133.292.118.667.437.655l1.58-.055.25.304-.363 1.54c-.073.312.244.63.557.556l1.54-.363.304.25-.055 1.58c-.012.32.362.57.654.437l1.436-.655.35.188.254 1.557c.05.317.467.488.727.302l1.28-.922.38.116.552 1.477c.112.3.553.388.772.153l1.078-1.156.392.04.832 1.345c.168.27.618.272.787 0l.832-1.345.392-.04 1.078 1.156c.22.235.66.147.772-.153l.552-1.477.38-.116 1.28.922c.26.187.676.015.727-.302l.254-1.557.35-.188 1.436.655c.292.133.666-.116.654-.437l-.055-1.58.303-.25 1.54.363c.313.073.63-.244.557-.556l-.363-1.54.25-.304 1.58.055c.32.013.57-.363.437-.655l-.655-1.436.187-.35 1.558-.253c.317-.05.49-.466.3-.727l-.92-1.28.116-.38 1.477-.552c.3-.113.388-.553.153-.772l-1.156-1.078.038-.392 1.345-.832c.272-.168.273-.618 0-.787z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 3.0 KiB |
@ -5,8 +5,6 @@ import { create } from './create.mjs';
|
||||
|
||||
export const OUTOUT = path.resolve(process.cwd(), 'dist');
|
||||
export const DOCS = path.resolve(process.cwd(), 'docs');
|
||||
export const CSSPATH = path.resolve(process.cwd(), 'scripts/style.css');
|
||||
export const CSS_OUTPUT_PATH = path.resolve(OUTOUT, 'style/style.css');
|
||||
|
||||
export async function createHTML(files = [], num = 0) {
|
||||
const dataFile = files[num];
|
||||
@ -33,7 +31,10 @@ 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), path.resolve(OUTOUT, 'style/style.css')),
|
||||
path.relative(path.dirname(outputHTMLPath), path.resolve(OUTOUT, 'style/katex.css')),
|
||||
],
|
||||
});
|
||||
await fs.writeFile(outputHTMLPath, html);
|
||||
console.log(`♻️ \x1b[32;1m ${path.relative(OUTOUT, outputHTMLPath)} \x1b[0m`);
|
||||
@ -43,8 +44,8 @@ export async function createHTML(files = [], num = 0) {
|
||||
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.ensureDir(path.resolve(OUTOUT, 'style'));
|
||||
await fs.copy(path.resolve(process.cwd(), 'scripts/style'), path.resolve(OUTOUT, 'style'));
|
||||
const files = await recursiveReaddirFiles(process.cwd(), {
|
||||
ignored: /\/(node_modules|\.git)/,
|
||||
exclude: /(\.json|\.mjs|CONTRIBUTING\.md)$/,
|
||||
|
BIN
scripts/style/fonts/KaTeX_AMS-Regular.ttf
Normal file
BIN
scripts/style/fonts/KaTeX_AMS-Regular.ttf
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_AMS-Regular.woff
Normal file
BIN
scripts/style/fonts/KaTeX_AMS-Regular.woff
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_AMS-Regular.woff2
Normal file
BIN
scripts/style/fonts/KaTeX_AMS-Regular.woff2
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Caligraphic-Bold.ttf
Normal file
BIN
scripts/style/fonts/KaTeX_Caligraphic-Bold.ttf
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Caligraphic-Bold.woff
Normal file
BIN
scripts/style/fonts/KaTeX_Caligraphic-Bold.woff
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Caligraphic-Bold.woff2
Normal file
BIN
scripts/style/fonts/KaTeX_Caligraphic-Bold.woff2
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Caligraphic-Regular.ttf
Normal file
BIN
scripts/style/fonts/KaTeX_Caligraphic-Regular.ttf
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Caligraphic-Regular.woff
Normal file
BIN
scripts/style/fonts/KaTeX_Caligraphic-Regular.woff
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Caligraphic-Regular.woff2
Normal file
BIN
scripts/style/fonts/KaTeX_Caligraphic-Regular.woff2
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Fraktur-Bold.ttf
Normal file
BIN
scripts/style/fonts/KaTeX_Fraktur-Bold.ttf
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Fraktur-Bold.woff
Normal file
BIN
scripts/style/fonts/KaTeX_Fraktur-Bold.woff
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Fraktur-Bold.woff2
Normal file
BIN
scripts/style/fonts/KaTeX_Fraktur-Bold.woff2
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Fraktur-Regular.ttf
Normal file
BIN
scripts/style/fonts/KaTeX_Fraktur-Regular.ttf
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Fraktur-Regular.woff
Normal file
BIN
scripts/style/fonts/KaTeX_Fraktur-Regular.woff
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Fraktur-Regular.woff2
Normal file
BIN
scripts/style/fonts/KaTeX_Fraktur-Regular.woff2
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Main-Bold.ttf
Normal file
BIN
scripts/style/fonts/KaTeX_Main-Bold.ttf
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Main-Bold.woff
Normal file
BIN
scripts/style/fonts/KaTeX_Main-Bold.woff
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Main-Bold.woff2
Normal file
BIN
scripts/style/fonts/KaTeX_Main-Bold.woff2
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Main-BoldItalic.ttf
Normal file
BIN
scripts/style/fonts/KaTeX_Main-BoldItalic.ttf
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Main-BoldItalic.woff
Normal file
BIN
scripts/style/fonts/KaTeX_Main-BoldItalic.woff
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Main-BoldItalic.woff2
Normal file
BIN
scripts/style/fonts/KaTeX_Main-BoldItalic.woff2
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Main-Italic.ttf
Normal file
BIN
scripts/style/fonts/KaTeX_Main-Italic.ttf
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Main-Italic.woff
Normal file
BIN
scripts/style/fonts/KaTeX_Main-Italic.woff
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Main-Italic.woff2
Normal file
BIN
scripts/style/fonts/KaTeX_Main-Italic.woff2
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Main-Regular.ttf
Normal file
BIN
scripts/style/fonts/KaTeX_Main-Regular.ttf
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Main-Regular.woff
Normal file
BIN
scripts/style/fonts/KaTeX_Main-Regular.woff
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Main-Regular.woff2
Normal file
BIN
scripts/style/fonts/KaTeX_Main-Regular.woff2
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Math-BoldItalic.ttf
Normal file
BIN
scripts/style/fonts/KaTeX_Math-BoldItalic.ttf
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Math-BoldItalic.woff
Normal file
BIN
scripts/style/fonts/KaTeX_Math-BoldItalic.woff
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Math-BoldItalic.woff2
Normal file
BIN
scripts/style/fonts/KaTeX_Math-BoldItalic.woff2
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Math-Italic.ttf
Normal file
BIN
scripts/style/fonts/KaTeX_Math-Italic.ttf
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Math-Italic.woff
Normal file
BIN
scripts/style/fonts/KaTeX_Math-Italic.woff
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Math-Italic.woff2
Normal file
BIN
scripts/style/fonts/KaTeX_Math-Italic.woff2
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_SansSerif-Bold.ttf
Normal file
BIN
scripts/style/fonts/KaTeX_SansSerif-Bold.ttf
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_SansSerif-Bold.woff
Normal file
BIN
scripts/style/fonts/KaTeX_SansSerif-Bold.woff
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_SansSerif-Bold.woff2
Normal file
BIN
scripts/style/fonts/KaTeX_SansSerif-Bold.woff2
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_SansSerif-Italic.ttf
Normal file
BIN
scripts/style/fonts/KaTeX_SansSerif-Italic.ttf
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_SansSerif-Italic.woff
Normal file
BIN
scripts/style/fonts/KaTeX_SansSerif-Italic.woff
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_SansSerif-Italic.woff2
Normal file
BIN
scripts/style/fonts/KaTeX_SansSerif-Italic.woff2
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_SansSerif-Regular.ttf
Normal file
BIN
scripts/style/fonts/KaTeX_SansSerif-Regular.ttf
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_SansSerif-Regular.woff
Normal file
BIN
scripts/style/fonts/KaTeX_SansSerif-Regular.woff
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_SansSerif-Regular.woff2
Normal file
BIN
scripts/style/fonts/KaTeX_SansSerif-Regular.woff2
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Script-Regular.ttf
Normal file
BIN
scripts/style/fonts/KaTeX_Script-Regular.ttf
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Script-Regular.woff
Normal file
BIN
scripts/style/fonts/KaTeX_Script-Regular.woff
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Script-Regular.woff2
Normal file
BIN
scripts/style/fonts/KaTeX_Script-Regular.woff2
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Size1-Regular.ttf
Normal file
BIN
scripts/style/fonts/KaTeX_Size1-Regular.ttf
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Size1-Regular.woff
Normal file
BIN
scripts/style/fonts/KaTeX_Size1-Regular.woff
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Size1-Regular.woff2
Normal file
BIN
scripts/style/fonts/KaTeX_Size1-Regular.woff2
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Size2-Regular.ttf
Normal file
BIN
scripts/style/fonts/KaTeX_Size2-Regular.ttf
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Size2-Regular.woff
Normal file
BIN
scripts/style/fonts/KaTeX_Size2-Regular.woff
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Size2-Regular.woff2
Normal file
BIN
scripts/style/fonts/KaTeX_Size2-Regular.woff2
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Size3-Regular.ttf
Normal file
BIN
scripts/style/fonts/KaTeX_Size3-Regular.ttf
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Size3-Regular.woff
Normal file
BIN
scripts/style/fonts/KaTeX_Size3-Regular.woff
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Size3-Regular.woff2
Normal file
BIN
scripts/style/fonts/KaTeX_Size3-Regular.woff2
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Size4-Regular.ttf
Normal file
BIN
scripts/style/fonts/KaTeX_Size4-Regular.ttf
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Size4-Regular.woff
Normal file
BIN
scripts/style/fonts/KaTeX_Size4-Regular.woff
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Size4-Regular.woff2
Normal file
BIN
scripts/style/fonts/KaTeX_Size4-Regular.woff2
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Typewriter-Regular.ttf
Normal file
BIN
scripts/style/fonts/KaTeX_Typewriter-Regular.ttf
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Typewriter-Regular.woff
Normal file
BIN
scripts/style/fonts/KaTeX_Typewriter-Regular.woff
Normal file
Binary file not shown.
BIN
scripts/style/fonts/KaTeX_Typewriter-Regular.woff2
Normal file
BIN
scripts/style/fonts/KaTeX_Typewriter-Regular.woff2
Normal file
Binary file not shown.
1086
scripts/style/katex.css
Normal file
1086
scripts/style/katex.css
Normal file
File diff suppressed because it is too large
Load Diff
@ -237,6 +237,7 @@ table thead {
|
||||
table td:first-child > code {
|
||||
--text-opacity: 1;
|
||||
color: rgb(5 150 105 / var(--text-opacity));
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
table td > del,
|
||||
table td:first-child > del > code,
|
||||
@ -370,7 +371,7 @@ body.home .max-container a.home-button:visited:hover {
|
||||
}
|
||||
.home-card a.contributing::after {
|
||||
color: var(--color-fg-muted);
|
||||
content: '👆待完善需要您的参与';
|
||||
content: attr(data-info);
|
||||
display: block;
|
||||
position: absolute;
|
||||
font-size: 10px;
|
||||
@ -379,7 +380,20 @@ body.home .max-container a.home-button:visited:hover {
|
||||
}
|
||||
.home-card a.contributing:hover:after {
|
||||
color: var(--color-fg-muted);
|
||||
animation: contributing-move 0.1s infinite;
|
||||
}
|
||||
@keyframes contributing-move {
|
||||
0% {
|
||||
transform: translate(0px, 0px);
|
||||
}
|
||||
50% {
|
||||
transform: translate(0px, -3px);
|
||||
}
|
||||
100% {
|
||||
transform: translate(0px, 0px);
|
||||
}
|
||||
}
|
||||
|
||||
.home-card a.tag::before {
|
||||
content: attr(data-lang);
|
||||
display: block;
|
||||
@ -602,6 +616,8 @@ a.text-grey {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
padding: 0.3rem 0.5rem;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.menu-tocs > .menu-modal a.leve2 {
|
||||
@ -727,9 +743,9 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.h3wrap-body > h4,
|
||||
.h3wrap-body > h5,
|
||||
.h3wrap-body > h6 {
|
||||
.wrap-body > h4,
|
||||
.wrap-body > h5,
|
||||
.wrap-body > h6 {
|
||||
border-color: transparent;
|
||||
background-color: var(--color-neutral-muted);
|
||||
color: var(--color-fg-default);
|
||||
@ -745,10 +761,7 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
|
||||
|
||||
.h3wrap .wrap-body > ul,
|
||||
.h3wrap .wrap-body > ol,
|
||||
.h3wrap .wrap-body > dl,
|
||||
.h3wrap-body > ul,
|
||||
.h3wrap-body > ol,
|
||||
.h3wrap-body > dl {
|
||||
.h3wrap .wrap-body > dl {
|
||||
margin-top: 0.5rem;
|
||||
margin-bottom: 0.5rem;
|
||||
display: grid;
|
@ -117,7 +117,7 @@ export function getTocsTree(arr = [], result = []) {
|
||||
if (titleNum(toc.tagName) > 3) {
|
||||
panle = [toc, ...header];
|
||||
}
|
||||
if (resultChilds.length > 0) {
|
||||
if (resultChilds.length > -1) {
|
||||
const bodyStyle = toc.properties['body-style'];
|
||||
delete toc.properties['body-style'];
|
||||
const bodyClass = toc.properties['body-class'];
|
||||
@ -125,12 +125,16 @@ export function getTocsTree(arr = [], result = []) {
|
||||
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 (titleNum(toc.tagName) < 3) {
|
||||
panle.children = panle.children.concat({
|
||||
type: 'element',
|
||||
tagName: 'div',
|
||||
properties: { class: [`h${level}wrap-body`, bodyClass], style: bodyStyle },
|
||||
children: [...resultChilds],
|
||||
});
|
||||
} else {
|
||||
panle.children[0].children[1].children = panle.children[0].children[1].children.concat(resultChilds);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Array.isArray(panle)) {
|
||||
|
@ -3,7 +3,23 @@ import path from 'path';
|
||||
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')) {
|
||||
if (
|
||||
isHome &&
|
||||
node &&
|
||||
node.type === 'element' &&
|
||||
(node.properties?.class || node.properties?.className)?.includes('contributing')
|
||||
) {
|
||||
const info = node.properties['data-info'];
|
||||
if (!info) {
|
||||
node.properties['data-info'] = '👆待完善需要您的参与';
|
||||
}
|
||||
}
|
||||
if (
|
||||
isHome &&
|
||||
node &&
|
||||
node.type === 'element' &&
|
||||
(node.properties?.class || node.properties?.className)?.includes('home-card')
|
||||
) {
|
||||
node.children = node.children.map((child) => {
|
||||
const href = child.properties?.href;
|
||||
if (href) {
|
||||
|
Reference in New Issue
Block a user