Compare commits

...

48 Commits

Author SHA1 Message Date
599215755f released v1.22.0 2022-11-17 14:06:56 +08:00
bce9b67afb doc: update quickreference.md 2022-11-17 14:05:00 +08:00
50e82b11b6 doc: update git.md 2022-11-17 14:04:41 +08:00
e36abdee8b website: update linenumber style. 2022-11-17 13:58:33 +08:00
7fe648c170 doc: update cpp.md #77 2022-11-17 13:44:11 +08:00
76e8c1bdc6 chore: update issue template. 2022-11-17 13:40:32 +08:00
9fe2674c6c chore: update issue template. 2022-11-17 13:38:31 +08:00
5c8b11767f website: update footer. #102 2022-11-17 13:28:01 +08:00
709aef66fb website: update footer. #102 2022-11-17 13:26:30 +08:00
13e67d63ac doc: modify README.md. 2022-11-17 05:05:24 +00:00
f9a31e40ca doc: modify CONTRIBUTING.md. 2022-11-17 05:05:23 +00:00
effa2500ed doc: Update cs.md #106 2022-11-17 13:04:15 +08:00
1d1f8778dd doc: update git.md #109 2022-11-17 12:30:14 +08:00
74afc52463 doc: Update bash.md 修复部分翻译错误 (#112) 2022-11-17 12:29:44 +08:00
d9ed56a390 doc: Update git.md (#109)
补充.gitignore规则说明和例子
2022-11-17 11:40:16 +08:00
f9461ac0c3 doc: update (#111)
Co-authored-by: 小弟调调™ <kennyiseeyou@gmail.com>
2022-11-17 11:37:30 +08:00
1bda7de8c4 doc: modify README.md. 2022-11-17 03:34:06 +00:00
067e5d6d16 doc: modify CONTRIBUTING.md. 2022-11-17 03:34:05 +00:00
76b1e5b41f doc: update c.md, fix typo (#110) 2022-11-17 11:33:08 +08:00
fe10fbe8bb doc: modify README.md. 2022-11-17 03:17:19 +00:00
2c07547c83 doc: modify CONTRIBUTING.md. 2022-11-17 03:17:18 +00:00
390eaa2e1b doc: change docs/cmake.md (#108)
- add some common commands
2022-11-17 11:17:01 +08:00
d7688f90bb doc: update cs.md (#106) 2022-11-17 11:16:23 +08:00
38453c5e31 doc: 添加 java反射 (#103) 2022-11-17 08:54:47 +08:00
fda783c165 doc: optimize translation in python doc (#104)
Co-authored-by: chyok <ichenhaoyuan@qq.com>
2022-11-17 08:53:13 +08:00
152dc14279 doc: Update README.md 2022-11-16 22:49:35 +08:00
e4d6ddecca doc: Update README.md 2022-11-16 21:39:00 +08:00
51bd7303d1 feat: add cpp.md #77 2022-11-16 20:23:14 +08:00
7d26adb7a6 doc: update npm.md 2022-11-16 16:03:48 +08:00
769d75e8bf doc: modify README.md. 2022-11-16 07:47:29 +00:00
7c6e2270b8 doc: modify CONTRIBUTING.md. 2022-11-16 07:47:28 +00:00
db647aaf35 doc: update npm.md 2022-11-16 15:46:16 +08:00
fbbbd00a9c doc: Update java.md (#100)
Random -> SecureRandom
2022-11-16 14:53:54 +08:00
6f7affffdd doc: modify README.md. 2022-11-16 06:11:00 +00:00
464c49645d doc: modify CONTRIBUTING.md. 2022-11-16 06:10:59 +00:00
c20d19c976 doc: add this and string methods in this js (#99)
* feat: add this and string methods in this js

* Update docs/javascript.md
2022-11-16 14:09:57 +08:00
0f199d2ff5 doc: modify README.md. 2022-11-16 04:58:14 +00:00
57f25fc10a doc: modify CONTRIBUTING.md. 2022-11-16 04:58:14 +00:00
d8a37d084f doc: mysql.md modify column (#98) 2022-11-16 12:57:08 +08:00
03cc3cf5c3 doc: Modified java.md (#96)
Co-authored-by: Pengcc <pcc_pengcc@163.com>
2022-11-16 11:32:48 +08:00
bf49b5f9a5 doc: modify README.md. 2022-11-16 03:18:51 +00:00
adebf47812 doc: modify CONTRIBUTING.md. 2022-11-16 03:18:50 +00:00
f5c9b232b5 doc: udpate npm.md (#94) 2022-11-16 11:17:45 +08:00
d6504023d5 doc: modify README.md. 2022-11-16 03:08:07 +00:00
3bade1d5a5 doc: modify CONTRIBUTING.md. 2022-11-16 03:08:06 +00:00
0ad14d89a0 doc: Update bash.md for a translation error (#92)
关于空间 -> 关于空格
2022-11-16 11:07:01 +08:00
5ee649ae9b doc: udpate typescript.md 2022-11-16 01:41:26 +08:00
ef680890ce feat: add kotlin.md #73 2022-11-15 22:43:20 +08:00
23 changed files with 2220 additions and 75 deletions

View File

@ -6,13 +6,25 @@ labels: request
assignees: jaywcjlove
---
🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧
注意:请求太多,参考【优先级】快速添加内容
🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧
#### 优先级
- [ ] 提交 PR 优先合并(优先处理)
- [ ] 提供可复制的[中文/英文]备忘清单资料,优先添加
- [ ] 大众化的内容(java/python),优先搬运(小众内容请提供资料)
#### 说明项目
您可以在这里简单的提供一些资料,方便我们在 Quick Reference 中添加您想添加的备忘清单(速查表)。
【请您在这里介绍一下工具或者语言,这很重要】
- [ ] 如果你有一张不错的备忘清单(速查表) [`参考这里`](https://github.com/jaywcjlove/reference/blob/main/CONTRIBUTING.md) 为仓库贡献。
- [ ] 如果您不方便贡献,请在下方参考资料中提供链接地址,方便共建备忘清单(速查表)
- [x] 这里为您提供了 Markdown 排版[示例教程](https://jaywcjlove.github.io/reference/docs/quickreference.html)
- 如果你有一张不错的备忘清单(速查表) [`参考这里`](https://github.com/jaywcjlove/reference/blob/main/CONTRIBUTING.md) 为仓库贡献。
- 如果您不方便贡献,请在下方参考资料中提供链接地址,方便共建备忘清单(速查表)
- 这里为您提供了 Markdown 排版[示例教程](https://jaywcjlove.github.io/reference/docs/quickreference.html)
#### 提供参考资料地址

View File

@ -96,9 +96,18 @@ npm run start # 监听 md 文件编译输出 HTML
<a href="https://github.com/Jack-Zhang-1314" title="fw_qaq">
<img src="https://avatars.githubusercontent.com/u/82551626?v=4" width="42;" alt="fw_qaq"/>
</a>
<a href="https://github.com/partoneplay" title="partoneplay">
<img src="https://avatars.githubusercontent.com/u/5189132?v=4" width="42;" alt="partoneplay"/>
</a>
<a href="https://github.com/catcto" title="喵仙人">
<img src="https://avatars.githubusercontent.com/u/5467932?v=4" width="42;" alt="喵仙人"/>
</a>
<a href="https://github.com/13812700839" title="花殇">
<img src="https://avatars.githubusercontent.com/u/58072506?v=4" width="42;" alt="花殇"/>
</a>
<a href="https://github.com/Smartdousha" title="Anko">
<img src="https://avatars.githubusercontent.com/u/52566311?v=4" width="42;" alt="Anko"/>
</a>
<a href="https://github.com/CharlotteZeng" title="Chart">
<img src="https://avatars.githubusercontent.com/u/19461184?v=4" width="42;" alt="Chart"/>
</a>
@ -114,32 +123,59 @@ npm run start # 监听 md 文件编译输出 HTML
<a href="https://github.com/HanaNoryu" title="Noryu">
<img src="https://avatars.githubusercontent.com/u/109856546?v=4" width="42;" alt="Noryu"/>
</a>
<a href="https://github.com/chyok" title="chyok">
<img src="https://avatars.githubusercontent.com/u/32629225?v=4" width="42;" alt="chyok"/>
</a>
<a href="https://github.com/gaoxiaoduan" title="coderduan">
<img src="https://avatars.githubusercontent.com/u/69953511?v=4" width="42;" alt="coderduan"/>
</a>
<a href="https://github.com/cool9203" title="cool9203">
<img src="https://avatars.githubusercontent.com/u/29609607?v=4" width="42;" alt="cool9203"/>
</a>
<a href="https://github.com/godotc" title="godotc">
<img src="https://avatars.githubusercontent.com/u/79260851?v=4" width="42;" alt="godotc"/>
</a>
<a href="https://github.com/greyhao" title="greyhao">
<img src="https://avatars.githubusercontent.com/u/107107440?v=4" width="42;" alt="greyhao"/>
</a>
<a href="https://github.com/hua03" title="hua03">
<img src="https://avatars.githubusercontent.com/u/19561959?v=4" width="42;" alt="hua03"/>
</a>
<a href="https://github.com/hweining" title="hweining">
<img src="https://avatars.githubusercontent.com/u/8973985?v=4" width="42;" alt="hweining"/>
</a>
<a href="https://github.com/kdxcxs" title="kdxcxs">
<img src="https://avatars.githubusercontent.com/u/18746192?v=4" width="42;" alt="kdxcxs"/>
</a>
<a href="https://github.com/larry-xue" title="larry">
<img src="https://avatars.githubusercontent.com/u/48818060?v=4" width="42;" alt="larry"/>
</a>
<a href="https://github.com/liliangrong777" title="liliangrong777">
<img src="https://avatars.githubusercontent.com/u/58727146?v=4" width="42;" alt="liliangrong777"/>
</a>
<a href="https://github.com/mofelee" title="mofelee">
<img src="https://avatars.githubusercontent.com/u/5069410?v=4" width="42;" alt="mofelee"/>
</a>
<a href="https://github.com/onewesong" title="onewesong">
<img src="https://avatars.githubusercontent.com/u/17920822?v=4" width="42;" alt="onewesong"/>
</a>
<a href="https://github.com/ryanhex53" title="ryanhex53">
<img src="https://avatars.githubusercontent.com/u/360426?v=4" width="42;" alt="ryanhex53"/>
</a>
<a href="https://github.com/wjjwkwindy" title="wjjwkwindy">
<img src="https://avatars.githubusercontent.com/u/9508591?v=4" width="42;" alt="wjjwkwindy"/>
</a>
<a href="https://github.com/xing133" title="xing133">
<img src="https://avatars.githubusercontent.com/u/5336490?v=4" width="42;" alt="xing133"/>
</a>
<a href="https://github.com/zxx-457" title="zxx-457">
<img src="https://avatars.githubusercontent.com/u/114141362?v=4" width="42;" alt="zxx-457"/>
</a>
<a href="https://github.com/lvzhenbo" title="吕振波">
<img src="https://avatars.githubusercontent.com/u/32427677?v=4" width="42;" alt="吕振波"/>
</a>
<a href="https://github.com/lisheng741" title="芦荟柚子茶">
<img src="https://avatars.githubusercontent.com/u/53617305?v=4" width="42;" alt="芦荟柚子茶"/>
</a><!--GAMFC-END-->
上图贡献者列表,由 [contributors](https://github.com/jaywcjlove/github-action-contributors) 自动生成贡献者图片。

View File

@ -9,7 +9,7 @@ Quick Reference
<!--rehype:ignore:end-->
<!--rehype:ignore:start-->
[![Quick Reference](https://user-images.githubusercontent.com/1680273/200623638-280ac85b-0cfa-4c60-bae3-ae14231acc6f.png)](https://jaywcjlove.github.io/reference)
[![Quick Reference](https://user-images.githubusercontent.com/1680273/201931931-d8559417-0a15-46af-a009-ec1e56e5b778.png)](https://jaywcjlove.github.io/reference)
<!--rehype:ignore:end-->
为开发人员分享快速参考备忘清单【速查表】。在看到 [Reference](https://github.com/Randy8080/reference) 快速参考备忘单,感觉非常简单,造中文版本的轮子使命感突然来了,为了方便自己的技术栈查阅,如果您提供一个清单,我将抽空搬运,立即撸起来 :)。如果您发现此处的备忘单不合适,您可以通过提交 [PR](https://github.com/jaywcjlove/reference/blob/main/CONTRIBUTING.md) 来修复它或提供更好的备忘清单,只针对【中文】用户。以下是开源天使提供的一些备忘清单和快速参考 :)。
@ -34,6 +34,7 @@ Quick Reference
[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));-->
[C#](./docs/cs.md)<!--rehype:style=background: rgb(6 147 13/var(\-\-bg\-opacity));&class=contributing-->
[CPP](./docs/cpp.md)<!--rehype:style=background: rgb(6 147 13/var(\-\-bg\-opacity));&class=contributing-->
[Dart](./docs/dart.md)<!--rehype:style=background: rgb(64 196 255/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-->
@ -44,6 +45,7 @@ Quick Reference
[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&data-info=👆看看还缺点儿什么?-->
[Julia](./docs/julia.md)<!--rehype:style=background: rgb(211 55 49/var(\-\-bg\-opacity));&class=contributing&data-info=👆看看还缺点儿什么?-->
[Kotlin](./docs/kotlin.md)<!--rehype:style=background: rgb(211 55 49/var(\-\-bg\-opacity));&class=contributing&data-info=👆看看还缺点儿什么?-->
[LaTeX](./docs/latex.md)<!--rehype:style=background: rgb(0 128 128/var(\-\-bg\-opacity));&class=contributing-->
[Markdown](./docs/markdown.md)<!--rehype:style=background: rgb(103 61 156/var(\-\-bg\-opacity));-->
[MySQL](./docs/mysql.md)<!--rehype:style=background: rgb(1 117 143/var(\-\-bg\-opacity));&class=tag&data-lang=SQL-->
@ -167,9 +169,18 @@ Quick Reference
<a href="https://github.com/Jack-Zhang-1314" title="fw_qaq">
<img src="https://avatars.githubusercontent.com/u/82551626?v=4" width="42;" alt="fw_qaq"/>
</a>
<a href="https://github.com/partoneplay" title="partoneplay">
<img src="https://avatars.githubusercontent.com/u/5189132?v=4" width="42;" alt="partoneplay"/>
</a>
<a href="https://github.com/catcto" title="喵仙人">
<img src="https://avatars.githubusercontent.com/u/5467932?v=4" width="42;" alt="喵仙人"/>
</a>
<a href="https://github.com/13812700839" title="花殇">
<img src="https://avatars.githubusercontent.com/u/58072506?v=4" width="42;" alt="花殇"/>
</a>
<a href="https://github.com/Smartdousha" title="Anko">
<img src="https://avatars.githubusercontent.com/u/52566311?v=4" width="42;" alt="Anko"/>
</a>
<a href="https://github.com/CharlotteZeng" title="Chart">
<img src="https://avatars.githubusercontent.com/u/19461184?v=4" width="42;" alt="Chart"/>
</a>
@ -185,37 +196,76 @@ Quick Reference
<a href="https://github.com/HanaNoryu" title="Noryu">
<img src="https://avatars.githubusercontent.com/u/109856546?v=4" width="42;" alt="Noryu"/>
</a>
<a href="https://github.com/chyok" title="chyok">
<img src="https://avatars.githubusercontent.com/u/32629225?v=4" width="42;" alt="chyok"/>
</a>
<a href="https://github.com/gaoxiaoduan" title="coderduan">
<img src="https://avatars.githubusercontent.com/u/69953511?v=4" width="42;" alt="coderduan"/>
</a>
<a href="https://github.com/cool9203" title="cool9203">
<img src="https://avatars.githubusercontent.com/u/29609607?v=4" width="42;" alt="cool9203"/>
</a>
<a href="https://github.com/godotc" title="godotc">
<img src="https://avatars.githubusercontent.com/u/79260851?v=4" width="42;" alt="godotc"/>
</a>
<a href="https://github.com/greyhao" title="greyhao">
<img src="https://avatars.githubusercontent.com/u/107107440?v=4" width="42;" alt="greyhao"/>
</a>
<a href="https://github.com/hua03" title="hua03">
<img src="https://avatars.githubusercontent.com/u/19561959?v=4" width="42;" alt="hua03"/>
</a>
<a href="https://github.com/hweining" title="hweining">
<img src="https://avatars.githubusercontent.com/u/8973985?v=4" width="42;" alt="hweining"/>
</a>
<a href="https://github.com/kdxcxs" title="kdxcxs">
<img src="https://avatars.githubusercontent.com/u/18746192?v=4" width="42;" alt="kdxcxs"/>
</a>
<a href="https://github.com/larry-xue" title="larry">
<img src="https://avatars.githubusercontent.com/u/48818060?v=4" width="42;" alt="larry"/>
</a>
<a href="https://github.com/liliangrong777" title="liliangrong777">
<img src="https://avatars.githubusercontent.com/u/58727146?v=4" width="42;" alt="liliangrong777"/>
</a>
<a href="https://github.com/mofelee" title="mofelee">
<img src="https://avatars.githubusercontent.com/u/5069410?v=4" width="42;" alt="mofelee"/>
</a>
<a href="https://github.com/onewesong" title="onewesong">
<img src="https://avatars.githubusercontent.com/u/17920822?v=4" width="42;" alt="onewesong"/>
</a>
<a href="https://github.com/ryanhex53" title="ryanhex53">
<img src="https://avatars.githubusercontent.com/u/360426?v=4" width="42;" alt="ryanhex53"/>
</a>
<a href="https://github.com/wjjwkwindy" title="wjjwkwindy">
<img src="https://avatars.githubusercontent.com/u/9508591?v=4" width="42;" alt="wjjwkwindy"/>
</a>
<a href="https://github.com/xing133" title="xing133">
<img src="https://avatars.githubusercontent.com/u/5336490?v=4" width="42;" alt="xing133"/>
</a>
<a href="https://github.com/zxx-457" title="zxx-457">
<img src="https://avatars.githubusercontent.com/u/114141362?v=4" width="42;" alt="zxx-457"/>
</a>
<a href="https://github.com/lvzhenbo" title="吕振波">
<img src="https://avatars.githubusercontent.com/u/32427677?v=4" width="42;" alt="吕振波"/>
</a>
<a href="https://github.com/lisheng741" title="芦荟柚子茶">
<img src="https://avatars.githubusercontent.com/u/53617305?v=4" width="42;" alt="芦荟柚子茶"/>
</a><!--GAMFC-END-->
贡献者列表,由 [contributors](https://github.com/jaywcjlove/github-action-contributors) 自动生成
<!--rehype:style=padding-top:1rem;-->
## 国内镜像网站
<!--rehype:wrap-style=text-align: center;max-width: 650px;margin: 0 auto;&class=home-title-reset-->
由于中国国内访问,时常打不开,你可以访问下面镜像网站。推荐我的[镜像网站](https://github.com/jaywcjlove/reference/issues/102#issue-1451649637)
[ecdata.cn](http://ref.ecdata.cn/)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));height: 3rem;-->
[mofe.io](http://quickref.mofe.io)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));height: 3rem;-->
<!--rehype:class=home-card&style=margin:1.2rem 0;display: flex;justify-content: center;-->
如果你有资源,可以很方便部署 web 版,这非常简单,只需要克隆 gh-pages 分支代码到你的静态服务就可以了,还可以使用 [docker](https://hub.docker.com/r/wcjiang/reference) 快捷部署 web 版。
<!--rehype:ignore:start-->
## License

View File

@ -27,9 +27,9 @@ NAME="John"
echo ${NAME} # => John (变量)
echo $NAME # => John (变量)
echo "$NAME" # => John (变量)
echo '$NAME' # => $NAME (确切的字符串)
echo '$NAME' # => $NAME (字符串原样输出)
echo "${NAME}!" # => John! (变量)
NAME = "John" # => Error (关于空间)
NAME = "John" # => Error (注意不能有空格)
```
### 注释
@ -39,8 +39,8 @@ NAME = "John" # => Error (关于空间)
: '
这是一个
非常整洁的评论
bash
非常整洁的
bash 注释
'
```
@ -53,11 +53,11 @@ NAME = "John" # => Error (关于空间)
:-|-
`$1``$9` | 参数 1 ... 9
`$0` | 脚本本身的名称
`$1` | 第一个论点
`$1` | 第一个参数
`${10}` | 位置参数 10
`$#` | 参数数量
`$$` | shell 的进程 id
`$*` | 所有论据
`$*` | 所有参数
`$@` | 所有参数,从第一个开始
`$-` | 当前选项
`$_` | 上一个命令的最后一个参数
@ -277,8 +277,8 @@ done
<!--rehype:wrap-class=col-span-2-->
```bash
Fruits=("${Fruits[@]}" "Watermelon") #
Fruits+=('Watermelon') # 也
Fruits=("${Fruits[@]}" "Watermelon") # 添加
Fruits+=('Watermelon') # 也是添加
Fruits=( ${Fruits[@]/Ap*/} ) # 通过正则表达式匹配删除
unset Fruits[2] # 删除一项
Fruits=("${Fruits[@]}") # 复制
@ -350,14 +350,14 @@ Bash 条件句
:- | -
`[[ NUM -eq NUM ]]` | 等于 <yel>Eq</yel>ual |
`[[ NUM -ne NUM ]]` | 不等于 <yel>N</yel>ot <yel>e</yel>qual |
`[[ NUM -lt NUM ]]` | <yel>L</yel>ess <yel>t</yel>han |
`[[ NUM -le NUM ]]` | 小于等于 <yel>L</yel>ess than or <yel>e</yel>qual |
`[[ NUM -lt NUM ]]` | <yel>L</yel>ess <yel>t</yel>han |
`[[ NUM -le NUM ]]` | 小于等于 <yel>L</yel>ess than or <yel>e</yel>qual |
`[[ NUM -gt NUM ]]` | 大于 <yel>G</yel>reater <yel>t</yel>han |
`[[ NUM -ge NUM ]]` | 大于等于 <yel>G</yel>reater than or <yel>e</yel>qual |
`(( NUM < NUM ))` |
`[[ NUM -ge NUM ]]` | 大于等于 <yel>G</yel>reater than or <yel>e</yel>qual |
`(( NUM < NUM ))` |
`(( NUM <= NUM ))` | 小于或等于
`(( NUM > NUM ))` | 比...更
`(( NUM >= NUM ))` | 大于等于
`(( NUM > NUM ))` | 比...更
`(( NUM >= NUM ))` | 大于等于
### 字符串条件
@ -365,7 +365,7 @@ Bash 条件句
:- | -
`[[ -z STR ]]` | 空字符串
`[[ -n STR ]]` | <yel></yel>空字符串
`[[ STR == STR ]]` | 平等的
`[[ STR == STR ]]` | 相等
`[[ STR = STR ]]` | 相等(同上)
`[[ STR < STR ]]` | 小于 _(ASCII)_
`[[ STR > STR ]]` | 大于 _(ASCII)_
@ -411,7 +411,7 @@ if [[ '1. abc' =~ ([a-z]+) ]]; then
fi
```
####
#### 小
```bash
if (( $a < $b )); then
@ -441,7 +441,7 @@ fi
`[[ -w FILE ]]` | 可写
`[[ -x FILE ]]` | 可执行文件
`[[ f1 -nt f2 ]]` | f1 比 f2 新
`[[ f1 -ot f2 ]]` | f2 早于 f1
`[[ f1 -ot f2 ]]` | f2 f1
`[[ f1 -ef f2 ]]` | 相同的文件
### 更多条件
@ -492,7 +492,7 @@ for i in {1..5}; do
done
```
#### 具有步长
#### 步长
```bash
for i in {5..50..5}; do
@ -510,7 +510,7 @@ while [[ $i -lt 4 ]]; do
done
```
### 自动递
### 自动递
```bash
i=3
@ -554,7 +554,7 @@ until [ $count -gt 10 ]; do
done
```
### 永远
### 死循环
```bash
while true; do
@ -562,7 +562,7 @@ while true; do
done
```
### 永远(简写)
### 死循环(简写)
```bash
while :; do
@ -570,7 +570,7 @@ while :; do
done
```
### 正在读取行
### 读取文件的每一
```bash
cat file.txt | while read line; do
@ -613,7 +613,7 @@ myfunc() {
result="$(myfunc)"
```
### 正在引发错误
### 抛出错误
```bash
myfunc() {
@ -719,7 +719,7 @@ Bash 历史
`!!` 可以替换为任何有效的扩展,即 `!cat`、`!-2`、`!42` 等。
各种各样的
杂项
-------------
### 数值计算

View File

@ -44,7 +44,7 @@ int myNum3 = 15; // myNum3 值为 15
myNum3 = 10; // 现在 myNum3 值为 10
float myFloatNum = 5.99; // 浮点数
char myLetter = 'D'; // 字符
char myLetter = 'D'; // 字符
int x = 5;
int y = 6;

View File

@ -11,8 +11,13 @@ CMake 备忘清单
CMake 是一个用于配置跨平台源代码项目应该如何配置的工具建立在给定的平台上。
```bash
CMakeLists.txt # 希望运行的 CMake 命令
╰┈ main.cpp # 带有 main 的源文件
── CMakeLists.txt # 希望运行的 CMake命令
├── main.cpp # 带有main 的源文件
├── include # 头文件目录
│   └── header.h
└── src # 源代码目录
├── a.c
└── b.c
```
在此项目上运行 `CMake` 时,系统会要求您提供二进制目录,运行 `CMake` 不会创建最终的可执行文件,而是会为 `Visual Studio``XCode``makefile` 生成项目文件。 使用这些工具构建该项目
@ -26,6 +31,18 @@ cmake_minimum_required(VERSION 3.5)
project (hello_cmake)
# 添加可执行文件
add_executable(hello_cmake main.cpp)
# 添加头文件目录
target_include_directories(hello_cmake PRIVATE ./include)
# 批量添加源文件
file(GLOB SRCS CONFIGURE_DEPENDS ./src/*.cpp)
target_sources(hello_cmake PUBLIC ${SRCS})
# 添加第三方库
find_package(OpenGL CONFIG REQUIRED)
# 链接第三方库
target_link_libraries(hello_cmake PRIVATE OpenGL)
# 指定输出路径
set_property(TARGET hello_cmake ${CMAKE_SOURCE_DIR}/bin)
```
#### main.cpp
@ -46,6 +63,7 @@ int main(int argc, char *argv[])
$ mkdir build # 创建 build 目录
$ cd build # 进入目录
$ cmake .. # 目录的上一级目录运行命令
$ make # 使用对应的编译工具
$ ./hello_cmake # 运行生成的 hello_cmake
Hello CMake!
```
@ -72,6 +90,12 @@ $ cmake --build <dir> [<options>] [-- <build-tool-options>]
$ cmake --install <dir> [<options>]
```
运行指定项目
```bash
cmake --build <dir> --target <project>
```
打开一个项目
```bash
@ -108,6 +132,30 @@ $ cmake --workflow [<options>]
$ cmake --help[-<topic>]
```
#### 常用参数
- 方式一: 在`CMakeLists.txt`中使用`set(KEY VAL)`函数
- 方式二: 在执行`cmake ...` -D<arg> 指定(只需一次,推荐)
```cmake
# 指定编译参数(Debug/Release/MinSizeRel/RelWithDebInfo)
$ cmake ... -D CMAKE_BUILD_TYPE=DEBUG
# 指定编译链工具(windows下vcpkg需要)
$ cmake ... -D CMAKE_TOOLCHAIN_FILE=<vcpkg_path>/scripts/buildsystems/vcpkg.cmake
# 指定编译器
$ cmake ... -D CAMKE_C_COMPILER=...
$ cmake ... -D CAMKE_CXX_COMPILER=...
# 指定生成器
$ cmake .. -G "Unix Makefile"
$ cmake .. -G "Ninja"
$ cmake .. -G "Visual Studio 17 2022"
# 设置Cpp标准
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON) # 在检测到不支持时出错
set(CMAKE_CXX_EXTENSIONS ON) #一般设为off否则在msvc上没有特性会出错
```
另见
----

792
docs/cpp.md Normal file
View File

@ -0,0 +1,792 @@
C++ 备忘清单
===
提供基本语法和方法的 [C++](https://zh.cppreference.com/) 快速参考备忘单
入门
--------
### hello.cpp
```cpp
#include <iostream>
int main() {
std::cout << "Hello Quick Reference\n";
return 0;
}
```
编译运行
```shell
$ g++ hello.cpp -o hello
$ ./hello
Hello Quick Reference
```
### 变量
```cpp
int number = 5; // 整数
float f = 0.95; // 浮点数
double PI = 3.14159; // 浮点数
char yes = 'Y'; // 特点
std::string s = "ME"; // 字符串(文本)
bool isRight = true; // 布尔值
// 常量
const float RATE = 0.8;
```
----
```cpp
int age {25}; // 自 C++11
std::cout << age; // 打印 25
```
### 原始数据类型
数据类型 | 大小 | 范围
:- | -- | --
`int` | 4 bytes | -2<sup>31</sup> 到 2<sup>31</sup>-1
`float` | 4 bytes | _N/A_
`double` | 8 bytes | _N/A_
`char` | 1 byte | -128 到 127
`bool` | 1 byte | `true` / `false`
`void` | _N/A_ | _N/A_
`wchar_t` | 2 到 4 bytes | 1 个宽字符
<!--rehype:className=show-header-->
### 用户输入
```cpp
int num;
std::cout << "Type a number: ";
std::cin >> num;
std::cout << "You entered " << num;
```
### 交换
```cpp
int a = 5, b = 10;
std::swap(a, b);
// 输出: a=10, b=5
std::cout << "a=" << a << ", b=" << b;
```
### 注释
```cpp
// C++中的单行注释
/* 这是一个多行注释
在 C++ 中 */
```
### If 语句
```cpp
if (a == 10) {
// do something
}
```
查看: [条件](#c-条件)
### 循环
```cpp
for (int i = 0; i < 10; i++) {
std::cout << i << "\n";
}
```
查看: [循环 Loops](#c-循环)
### 函数
<!--rehype:wrap-class=row-span-2-->
```cpp
#include <iostream>
void hello(); // 声明
int main() { // 主函数
hello(); // 执行函数
}
void hello() { // 定义
std::cout << "Hello Quick Reference!\n";
}
```
查看: [函数 Functions](#c-函数)
### 引用
```cpp
int i = 1;
int& ri = i; // ri 是对 i 的引用
ri = 2; // i 现在改为 2
std::cout << "i=" << i;
i = 3; // i 现在改为 3
std::cout << "ri=" << ri;
```
`ri``i` 指的是相同的内存位置
### 命名空间
```cpp
#include <iostream>
namespace ns1 {int val(){return 5;}}
int main()
{
std::cout << ns1::val();
}
```
----
```cpp
#include <iostream>
namespace ns1 {int val(){return 5;}}
using namespace ns1;
using namespace std;
int main()
{
cout << val();
}
```
名称空间允许名称下的全局标识符
C++ 数组
------
### 定义
```cpp
std::array<int, 3> marks; // 定义
marks[0] = 92;
marks[1] = 97;
marks[2] = 98;
// 定义和初始化
std::array<int, 3> = {92, 97, 98};
// 有空成员
std::array<int, 3> marks = {92, 97};
std::cout << marks[2]; // 输出: 0
```
### 操控
```cpp
┌─────┬─────┬─────┬─────┬─────┬─────┐
| 92 | 97 | 98 | 99 | 98 | 94 |
└─────┴─────┴─────┴─────┴─────┴─────┘
0 1 2 3 4 5
```
----
```cpp
std::array<int, 6> marks = {
92, 97, 98, 99, 98, 94
};
// 打印第一个元素
std::cout << marks[0];
// 将第 2 个元素更改为 99
marks[1] = 99;
// 从用户那里获取输入
std::cin >> marks[2];
```
### 展示
```cpp
char ref[5] = {'R', 'e', 'f'};
// 基于范围的for循环
for (const int &n : ref) {
std::cout << std::string(1, n);
}
// 传统的for循环
for (int i = 0; i < sizeof(ref); ++i) {
std::cout << ref[i];
}
```
### 多维
```cpp
j0 j1 j2 j3 j4 j5
┌────┬────┬────┬────┬────┬────┐
i0 | 1 | 2 | 3 | 4 | 5 | 6 |
├────┼────┼────┼────┼────┼────┤
i1 | 6 | 5 | 4 | 3 | 2 | 1 |
└────┴────┴────┴────┴────┴────┘
```
----
```cpp
int x[2][6] = {
{1,2,3,4,5,6}, {6,5,4,3,2,1}
};
for (int i = 0; i < 2; ++i) {
for (int j = 0; j < 6; ++j) {
std::cout << x[i][j] << " ";
}
}
// 输出: 1 2 3 4 5 6 6 5 4 3 2 1
```
C++ 条件
------------
### If Clause
```cpp
if (a == 10) {
// do something
}
```
----
```cpp
int number = 16;
if (number % 2 == 0)
{
std::cout << "even";
}
else
{
std::cout << "odd";
}
// 输出: even
```
### Else if 语句
```cpp
int score = 99;
if (score == 100) {
std::cout << "Superb";
}
else if (score >= 90) {
std::cout << "Excellent";
}
else if (score >= 80) {
std::cout << "Very Good";
}
else if (score >= 70) {
std::cout << "Good";
}
else if (score >= 60)
std::cout << "OK";
else
std::cout << "What?";
```
### 运算符
<!--rehype:wrap-class=row-span-2-->
#### 关系运算符
:--|--
:--|--
`a == b` | a 等于 b
`a != b` | a 不等于 b
`a < b` | a 小于 b
`a > b` | a 大于 b
`a <= b` | a 小于或等于 b
`a >= b` | a 大于或等于 b
#### 赋值运算符
范例 | 相当于
:--|--
`a += b` | _Aka_ `a = a + b`
`a -= b` | _Aka_ `a = a - b`
`a *= b` | _Aka_ `a = a * b`
`a /= b` | _Aka_ `a = a / b`
`a %= b` | _Aka_ `a = a % b`
#### 逻辑运算符
| Example | Meaning |
|----------------|------------------------|
| `exp1 && exp2` | Both are true _(AND)_ |
| `exp1 || exp2` | Either is true _(OR)_ |
| `!exp` | `exp` is false _(NOT)_ |
#### 位运算符
| Operator | Description |
|----------|-------------------------|
| `a & b` | Binary AND |
| `a | b` | Binary OR |
| `a ^ b` | Binary XOR |
| `a ~ b` | Binary One's Complement |
| `a << b` | Binary Shift Left |
| `a >> b` | Binary Shift Right |
### 三元运算符
```
┌── True ──┐
Result = Condition ? Exp1 : Exp2;
└───── False ─────┘
```
----
```cpp
int x = 3, y = 5, max;
max = (x > y) ? x : y;
// 输出: 5
std::cout << max << std::endl;
```
----
```cpp
int x = 3, y = 5, max;
if (x > y) {
max = x;
} else {
max = y;
}
// 输出: 5
std::cout << max << std::endl;
```
### switch 语句
```cpp
int num = 2;
switch (num) {
case 0:
std::cout << "Zero";
break;
case 1:
std::cout << "One";
break;
case 2:
std::cout << "Two";
break;
case 3:
std::cout << "Three";
break;
default:
std::cout << "What?";
break;
}
```
C++ 循环
------------
### While
```cpp
int i = 0;
while (i < 6) {
std::cout << i++;
}
// 输出: 012345
```
### Do-while
```cpp
int i = 1;
do {
std::cout << i++;
} while (i <= 5);
// 输出: 12345
```
### Continue 语句
```cpp
for (int i = 0; i < 10; i++) {
if (i % 2 == 0) {
continue;
}
std::cout << i;
} // 输出: 13579
```
### 无限循环
```cpp
while (true) { // true or 1
std::cout << "无限循环";
}
```
----
```cpp
for (;;) {
std::cout << "无限循环";
}
```
----
```cpp
for(int i = 1; i > 0; i++) {
std::cout << "infinite loop";
}
```
### for_each (C++11 起)
```cpp
#include <iostream>
int main()
{
auto print = [](int num) {
std::cout << num << std::endl;
};
std::array<int, 4> arr = {1, 2, 3, 4};
std::for_each(arr.begin(), arr.end(), print);
return 0;
}
```
<!--rehype:className=wrap-text-->
### 基于范围 (C++11 起)
```cpp
for (int n : {1, 2, 3, 4, 5}) {
std::cout << n << " ";
}
// 输出: 1 2 3 4 5
```
----
```cpp
std::string hello = "Quick Reference.ME";
for (char c: hello)
{
std::cout << c << " ";
}
// 输出: Q u i c k R e f . M E
```
### 中断语句
```cpp
int password, times = 0;
while (password != 1234) {
if (times++ >= 3) {
std::cout << "Locked!\n";
break;
}
std::cout << "Password: ";
std::cin >> password; // input
}
```
### Several variations
```cpp
for (int i = 0, j = 2; i < 3; i++, j--){
std::cout << "i=" << i << ",";
std::cout << "j=" << j << ";";
}
// 输出: i=0,j=2;i=1,j=1;i=2,j=0;
```
C++ 函数
------------
### 参数和返回
```cpp
#include <iostream>
int add(int a, int b) {
return a + b;
}
int main() {
std::cout << add(10, 20);
}
```
`add` 是一个接受 2 个整数并返回整数的函数
### 重载
```cpp
void fun(string a, string b) {
std::cout << a + " " + b;
}
void fun(string a) {
std::cout << a;
}
void fun(int a) {
std::cout << a;
}
```
### 内置函数
```cpp
#include <iostream>
#include <cmath> // 导入库
int main() {
// sqrt() 来自 cmath
std::cout << sqrt(9);
}
```
C++ 预处理器
------------
### 预处理器
<!--rehype:wrap-class=row-span-3-->
- [if](https://zh.cppreference.com/w/cpp/preprocessor/conditional)
- [elif](https://zh.cppreference.com/w/cpp/preprocessor/conditional)
- [else](https://zh.cppreference.com/w/cpp/preprocessor/conditional)
- [endif](https://zh.cppreference.com/w/cpp/preprocessor/conditional)
- [ifdef](https://zh.cppreference.com/w/cpp/preprocessor/conditional)
- [ifndef](https://zh.cppreference.com/w/cpp/preprocessor/conditional)
- [define](https://zh.cppreference.com/w/cpp/preprocessor/replace)
- [undef](https://zh.cppreference.com/w/cpp/preprocessor/replace)
- [include](https://zh.cppreference.com/w/cpp/preprocessor/include)
- [line](https://zh.cppreference.com/w/cpp/preprocessor/line)
- [error](https://zh.cppreference.com/w/cpp/preprocessor/error)
- [pragma](https://zh.cppreference.com/w/cpp/preprocessor/impl)
- [defined](https://zh.cppreference.com/w/cpp/preprocessor/conditional)
- [__has_include](https://zh.cppreference.com/w/cpp/feature_test)
- [__has_cpp_attribute](https://zh.cppreference.com/w/cpp/feature_test)
- [export](https://zh.cppreference.com/w/cpp/keyword/export)
- [import](https://zh.cppreference.com/mwiki/index.php?title=cpp/keyword/import&amp;action=edit&amp;redlink=1)
- [module](https://zh.cppreference.com/mwiki/index.php?title=cpp/keyword/module&amp;action=edit&amp;redlink=1)
<!--rehype:className=style-none cols-2-->
### Includes
```cpp
#include "iostream"
#include <iostream>
```
### Defines
```cpp
#define FOO
#define FOO "hello"
#undef FOO
```
### If
<!--rehype:wrap-class=row-span-2-->
```cpp
#ifdef DEBUG
console.log('hi');
#elif defined VERBOSE
...
#else
...
#endif
```
### Error
```cpp
#if VERSION == 2.0
#error Unsupported
#warning Not really supported
#endif
```
### 宏
```cpp
#define DEG(x) ((x) * 57.29)
```
### 令牌连接
```cpp
#define DST(name) name##_s name##_t
DST(object); #=> object_s object_t;
```
### 字符串化
```cpp
#define STR(name) #name
char * a = STR(object); #=> char * a = "object";
```
<!--rehype:className=wrap-text-->
### 文件和行
```cpp
#define LOG(msg) console.log(__FILE__, __LINE__, msg)
#=> console.log("file.txt", 3, "hey")
```
<!--rehype:className=wrap-text-->
各种各样的
-------------
### 转义序列
转义序列 | 说明
:--|--
`\b` | 退格键
`\f` | 换页
`\n` | 换行
`\r` | 返回
`\t` | 水平制表符
`\v` | 垂直制表符
`\\` | 反斜杠
`\'` | 单引号
`\"` | 双引号
`\?` | 问号
`\0` | 空字符
### 关键字
<!--rehype:wrap-class=row-span-2 col-span-2-->
- [alignas](https://zh.cppreference.com/w/cpp/keyword/alignas)
- [alignof](https://zh.cppreference.com/w/cpp/keyword/alignof)
- [and](https://zh.cppreference.com/w/cpp/keyword/and)
- [and_eq](https://zh.cppreference.com/w/cpp/keyword/and_eq)
- [asm](https://zh.cppreference.com/w/cpp/keyword/asm)
- [atomic_cancel](https://zh.cppreference.com/w/cpp/keyword/atomic_cancel)
- [atomic_commit](https://zh.cppreference.com/w/cpp/keyword/atomic_commit)
- [atomic_noexcept](https://zh.cppreference.com/w/cpp/keyword/atomic_noexcept)
- [auto](https://zh.cppreference.com/w/cpp/keyword/auto)
- [bitand](https://zh.cppreference.com/w/cpp/keyword/bitand)
- [bitor](https://zh.cppreference.com/w/cpp/keyword/bitor)
- [bool](https://zh.cppreference.com/w/cpp/keyword/bool)
- [break](https://zh.cppreference.com/w/cpp/keyword/break)
- [case](https://zh.cppreference.com/w/cpp/keyword/case)
- [catch](https://zh.cppreference.com/w/cpp/keyword/catch)
- [char](https://zh.cppreference.com/w/cpp/keyword/char)
- [char8_t](https://zh.cppreference.com/w/cpp/keyword/char8_t)
- [char16_t](https://zh.cppreference.com/w/cpp/keyword/char16_t)
- [char32_t](https://zh.cppreference.com/w/cpp/keyword/char32_t)
- [class](https://zh.cppreference.com/w/cpp/keyword/class)
- [compl](https://zh.cppreference.com/w/cpp/keyword/compl)
- [concept](https://zh.cppreference.com/w/cpp/keyword/concept)
- [const](https://zh.cppreference.com/w/cpp/keyword/const)
- [consteval](https://zh.cppreference.com/w/cpp/keyword/consteval)
- [constexpr](https://zh.cppreference.com/w/cpp/keyword/constexpr)
- [constinit](https://zh.cppreference.com/w/cpp/keyword/constinit)
- [const_cast](https://zh.cppreference.com/w/cpp/keyword/const_cast)
- [continue](https://zh.cppreference.com/w/cpp/keyword/continue)
- [co_await](https://zh.cppreference.com/w/cpp/keyword/co_await)
- [co_return](https://zh.cppreference.com/w/cpp/keyword/co_return)
- [co_yield](https://zh.cppreference.com/w/cpp/keyword/co_yield)
- [decltype](https://zh.cppreference.com/w/cpp/keyword/decltype)
- [default](https://zh.cppreference.com/w/cpp/keyword/default)
- [delete](https://zh.cppreference.com/w/cpp/keyword/delete)
- [do](https://zh.cppreference.com/w/cpp/keyword/do)
- [double](https://zh.cppreference.com/w/cpp/keyword/double)
- [dynamic_cast](https://zh.cppreference.com/w/cpp/keyword/dynamic_cast)
- [else](https://zh.cppreference.com/w/cpp/keyword/else)
- [enum](https://zh.cppreference.com/w/cpp/keyword/enum)
- [explicit](https://zh.cppreference.com/w/cpp/keyword/explicit)
- [export](https://zh.cppreference.com/w/cpp/keyword/export)
- [extern](https://zh.cppreference.com/w/cpp/keyword/extern)
- [false](https://zh.cppreference.com/w/cpp/keyword/false)
- [float](https://zh.cppreference.com/w/cpp/keyword/float)
- [for](https://zh.cppreference.com/w/cpp/keyword/for)
- [friend](https://zh.cppreference.com/w/cpp/keyword/friend)
- [goto](https://zh.cppreference.com/w/cpp/keyword/goto)
- [if](https://zh.cppreference.com/w/cpp/keyword/if)
- [inline](https://zh.cppreference.com/w/cpp/keyword/inline)
- [int](https://zh.cppreference.com/w/cpp/keyword/int)
- [long](https://zh.cppreference.com/w/cpp/keyword/long)
- [mutable](https://zh.cppreference.com/w/cpp/keyword/mutable)
- [namespace](https://zh.cppreference.com/w/cpp/keyword/namespace)
- [new](https://zh.cppreference.com/w/cpp/keyword/new)
- [noexcept](https://zh.cppreference.com/w/cpp/keyword/noexcept)
- [not](https://zh.cppreference.com/w/cpp/keyword/not)
- [not_eq](https://zh.cppreference.com/w/cpp/keyword/not_eq)
- [nullptr](https://zh.cppreference.com/w/cpp/keyword/nullptr)
- [operator](https://zh.cppreference.com/w/cpp/keyword/operator)
- [or](https://zh.cppreference.com/w/cpp/keyword/or)
- [or_eq](https://zh.cppreference.com/w/cpp/keyword/or_eq)
- [private](https://zh.cppreference.com/w/cpp/keyword/private)
- [protected](https://zh.cppreference.com/w/cpp/keyword/protected)
- [public](https://zh.cppreference.com/w/cpp/keyword/public)
- [reflexpr](https://zh.cppreference.com/w/cpp/keyword/reflexpr)
- [register](https://zh.cppreference.com/w/cpp/keyword/register)
- [reinterpret_cast](https://zh.cppreference.com/w/cpp/keyword/reinterpret_cast)
- [requires](https://zh.cppreference.com/w/cpp/keyword/requires)
- [return](https://zh.cppreference.com/w/cpp/language/return)
- [short](https://zh.cppreference.com/w/cpp/keyword/short)
- [signed](https://zh.cppreference.com/w/cpp/keyword/signed)
- [sizeof](https://zh.cppreference.com/w/cpp/keyword/sizeof)
- [static](https://zh.cppreference.com/w/cpp/keyword/static)
- [static_assert](https://zh.cppreference.com/w/cpp/keyword/static_assert)
- [static_cast](https://zh.cppreference.com/w/cpp/keyword/static_cast)
- [struct](https://zh.cppreference.com/w/cpp/keyword/struct)
- [switch](https://zh.cppreference.com/w/cpp/keyword/switch)
- [synchronized](https://zh.cppreference.com/w/cpp/keyword/synchronized)
- [template](https://zh.cppreference.com/w/cpp/keyword/template)
- [this](https://zh.cppreference.com/w/cpp/keyword/this)
- [thread_local](https://zh.cppreference.com/w/cpp/keyword/thread_local)
- [throw](https://zh.cppreference.com/w/cpp/keyword/throw)
- [true](https://zh.cppreference.com/w/cpp/keyword/true)
- [try](https://zh.cppreference.com/w/cpp/keyword/try)
- [typedef](https://zh.cppreference.com/w/cpp/keyword/typedef)
- [typeid](https://zh.cppreference.com/w/cpp/keyword/typeid)
- [typename](https://zh.cppreference.com/w/cpp/keyword/typename)
- [union](https://zh.cppreference.com/w/cpp/keyword/union)
- [unsigned](https://zh.cppreference.com/w/cpp/keyword/unsigned)
- [using](https://zh.cppreference.com/w/cpp/keyword/using)
- [virtual](https://zh.cppreference.com/w/cpp/keyword/virtual)
- [void](https://zh.cppreference.com/w/cpp/keyword/void)
- [volatile](https://zh.cppreference.com/w/cpp/keyword/volatile)
- [wchar_t](https://zh.cppreference.com/w/cpp/keyword/wchar_t)
- [while](https://zh.cppreference.com/w/cpp/keyword/while)
- [xor](https://zh.cppreference.com/w/cpp/keyword/xor)
- [xor_eq](https://zh.cppreference.com/w/cpp/keyword/xor_eq)
- [final](https://zh.cppreference.com/w/cpp/language/final)
- [override](https://zh.cppreference.com/w/cpp/language/override)
- [transaction_safe](https://zh.cppreference.com/w/cpp/language/transactional_memory)
- [transaction_safe_dynamic](https://zh.cppreference.com/w/cpp/language/transactional_memory)
<!--rehype:className=style-none cols-5-->
### 预处理器
- [if](https://zh.cppreference.com/w/cpp/preprocessor/conditional)
- [elif](https://zh.cppreference.com/w/cpp/preprocessor/conditional)
- [else](https://zh.cppreference.com/w/cpp/preprocessor/conditional)
- [endif](https://zh.cppreference.com/w/cpp/preprocessor/conditional)
- [ifdef](https://zh.cppreference.com/w/cpp/preprocessor/conditional)
- [ifndef](https://zh.cppreference.com/w/cpp/preprocessor/conditional)
- [define](https://zh.cppreference.com/w/cpp/preprocessor/replace)
- [undef](https://zh.cppreference.com/w/cpp/preprocessor/replace)
- [include](https://zh.cppreference.com/w/cpp/preprocessor/include)
- [line](https://zh.cppreference.com/w/cpp/preprocessor/line)
- [error](https://zh.cppreference.com/w/cpp/preprocessor/error)
- [pragma](https://zh.cppreference.com/w/cpp/preprocessor/impl)
- [defined](https://zh.cppreference.com/w/cpp/preprocessor/conditional)
- [__has_include](https://zh.cppreference.com/w/cpp/feature_test)
- [__has_cpp_attribute](https://zh.cppreference.com/w/cpp/feature_test)
- [export](https://zh.cppreference.com/w/cpp/keyword/export)
- [import](https://zh.cppreference.com/mwiki/index.php?title=cpp/keyword/import&amp;action=edit&amp;redlink=1)
- [module](https://zh.cppreference.com/mwiki/index.php?title=cpp/keyword/module&amp;action=edit&amp;redlink=1)
<!--rehype:className=style-none cols-2-->
另见
----
- [C++ Infographics & Cheat Sheets](https://hackingcpp.com/cpp/cheat_sheets.html) _(hackingcpp.com)_
- [C++ reference](https://zh.cppreference.com/w/) _(cppreference.com)_
- [C++ Language Tutorials](http://www.cplusplus.com/doc/tutorial/) _(cplusplus.com)_

View File

@ -185,6 +185,40 @@ lengthOfString.Length // => 9
lengthOfString.Contains("How"); // => true
```
### 频繁字符串拼接
```cs
var sb = new StringBuilder();
for (int i = 0; i < 100; i++)
{
sb.Append(i.ToString());
}
Console.WriteLine(sb.ToString());
// => 123456789....
```
对于频繁拼接字符串的场景(如:成百上千次循环),使用 `System.Text.StringBuilder` 提升性能
<!--rehype:className=wrap-text-->
### 原始字符串文本
<!--rehype:wrap-class=col-span-2-->
```cs
// C#11 语法, 至少3个双引号(""")开头和结尾,内容可以输入任何原始字符
// 单行: 左引号,右引号,内容 三者同行
string singleLine = """Content begin "Hello World!" end.""";
// 多行:左引号,右引号各一行,内容需与右引号缩进对齐
string multiLine = """
Content begin "Hello World!" /\n<>"" end.
""";
Console.WriteLine(multiLine); // => Content begin "Hello World!" /\n<>"" end.
```
<!--rehype:className=wrap-text-->
杂项
-----------

View File

@ -185,6 +185,7 @@ $ git tag my_tag
```shell
$ git checkout -b <branch-name> origin/<branch-name>
```
<!--rehype:className=wrap-text-->
### 临时提交
@ -236,6 +237,55 @@ $ git diff branchB...branchA
$ git show [SHA]
```
### 忽略文件
<!--rehype:wrap-class=row-span-4-->
文件 `.gitignore` 指定了 `Git` 应该忽略的 **未跟踪的** 文件
:- | :-
:- | :-
行首 `#` | 全行注释,不支持行尾类注释 _(转义 `\#`)_
行首 **`!`** | 否定模式 _(转义 `\!`)_
`**` | 匹配任意路径
`*` | 匹配任意多个字符
`?` | 匹配任意一个字符
`doc/**` | 匹配 `doc` 文件夹下的全部内容
`doc/**/a` | 匹配任意深度路径下的 `a` 文件或文件夹
`/` | 表示路径分隔符,不区分操作系统
`/` 结尾 | 仅会匹配文件夹,否则会匹配文件和文件夹
空行 | 不匹配任何文件
行尾空格 | 默认被忽略,可使用`\`进行转义
行首空格 | 被正常处理,不会被忽略
当前 `.gitignore` 文件定义规则的优先级高于上级路径 `.gitignore` 定义规则的优先级;后定义的规则优先级高于前面定义规则的优先级
```gitignore showLineNumbers
# 忽略当前目录logs文件夹下的全部内容
/logs/
/logs/*
/logs/**
# 上述几条规则等效
# 忽略 Mac 系统文件,包括任意子路径下的同名文件(夹)
.DS_store
# 忽略 node_modules 文件夹,包括任意子路径下的同名文件夹
node_modules/
# 忽略任意子路径下build、target文件夹
# 但不忽略src/main、src/test下的build、target文件夹
build/
!**/src/main/**/build/
!**/src/test/**/build/
target/
!**/src/main/**/target/
!**/src/test/**/target/
# 使用 ! 重新包含指定文件(夹)
!logs/.gitkeep
```
<!--rehype:className=wrap-text-->
### 重构文件名
```bash
@ -339,23 +389,8 @@ $ git mv [existing-path] [new-path]
$ git log --stat -M
```
### 忽略文件
```gitignore showLineNumbers
/logs/*
# “!” 意思是不要忽视
!logs/.gitkeep
# 忽略 Mac 系统文件
.DS_store
# 忽略 node_modules 文件夹
node_modules
# 忽略 SASS 配置文件
.sass-cache
```
`.gitignore` 文件指定了 Git 应该忽略的未跟踪的文件
### git 配置 ssh 代理
<!--rehype:wrap-class=col-span-2-->
```bash
$ cat ~/.ssh/config
@ -679,6 +714,7 @@ $ git blame <file-name>
```bash
$ git commit --amend --author='Author Name <email@address.com>'
```
<!--rehype:className=wrap-text-->
### 修改远程仓库的 url
@ -758,6 +794,7 @@ $ git rebase --autostash
```bash
$ git fetch origin pull/<id>/head:<branch-name>
```
<!--rehype:className=wrap-text-->
### 详细展示一行中的修改

View File

@ -301,7 +301,7 @@ System.out.println(concat);
Java 数组
-------
### 明 Declare
### 明 Declare
```java
int[] a1;
@ -783,6 +783,26 @@ try {
}
```
### 反射
```java
/**
* 利用反射动态加载依赖库
* java9及以上版本可用
* @param jar jar文件
*/
Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
method.setAccessible(true);
MethodHandle addURL = lookup.unreflect(method);
URL url = jar.toURI().toURL();
URLClassLoader urlClassLoader = new URLClassLoader(new URL[] {url});
addURL.invoke(urlClassLoader, url);
//java8
Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
method.setAccessible(true);
method.invoke(classLoader, url);
```
### util工具类
- `ArrayDeque` 提供 resizable-array 并实现 Deque 接
@ -793,7 +813,7 @@ try {
- `EnumMap` 一个专门用于枚举键的 Map 实现
- `EnumSet` 一个专门用于枚举键的 Set 实现
- `Formatter` 提供对布局对齐和对齐、数字、字符串和日期/时间数据的常用格式以及特定于语言环境的输出的支持
- `Random` 实例用于生成伪随机数流
- `SecureRandom` 实例用于生成安全的伪随机数流
- `UUID` 表示一个不可变的通用唯一标识符
- `Vector` 实现了一个可增长的对象数组

View File

@ -42,6 +42,7 @@ function potentiallyBuggyCode() {
let amount = 6;
let price = 4.99;
let home = 1e2;
let num = 1_000_000; // 位数过多可以用 _ 分割
let m = 0644; // 八进制数字 420
```
@ -147,8 +148,19 @@ abc.charCodeAt(2);
abc.split(",");
// 分割字符
abc.split("");
// 匹配开头字符串,如果忽略第二个参数,则从索引 0 开始匹配
abc.startsWith("bc", 1);
// 匹配结尾的字符串,如果忽略第二个参数,则默认是原字符串长度
abc.endsWith("wxy", abc.length - 1);
// padEnd 和 padStart 都用于填充长度,默认填充对象是空格
"200".padEnd(5); // "200 "
"200".padEnd(5, "."); // "200.."
// 重复字符
"abc".repeat(2); // "abcabc"
// trim、trimEnd 和 trimStart 用于去除首尾空格
" ab c ".trim(); // "ab c"
// 数字转为十六进制 (16)、八进制 (8) 或二进制 (2)
128.toString(16);
(128).toString(16);
```
### 数字
@ -1178,6 +1190,100 @@ console.log(myCat.name);
myCat.name = 'Yankee';
```
JavaScript this 绑定
----
### 隐式绑定
```js
function foo() {
console.log(this)
}
let obj1 = {
name: "obj1",
foo: foo
}
let obj2 = {
name: "obj2",
obj1: obj1
}
obj2.obj1.foo() // [Object obj1]
```
#### 隐式丢失
```js
let a = obj2.obj1.foo()
a() // Window
```
- 指定隐式绑定:必须在调用的对象内部有一个对函数的引用(比如一个属性)
- 将以上调用赋值给一个变量,结果最终会是 Window
- 在 a 被调用的位置没有进行过任何显示绑定,最终全局对象 window 会调用它(`Window.a`
<!--rehype:className=style-round-->
### 显示绑定
```js
function getName(a1, a2) {
console.log("此人" + this.name, "岁数" + (a1 + a2))
}
let person = {
name: "zhangsan"
}
```
#### call
call 第一个参数接受 this 作用域,剩余参数传递给其调用的函数
```js
getName.call(person, 18, 12)
```
#### apply
apply 第一个参数与 call 相同,第二个参数是其调用函数的参数数组
```js
getName.apply(person, [18, 12])
```
#### bind
bind 函数会返回一个新函数
```js
getName.bind(person,18,12)()
//或者可以这样
getName.bind(person)(18, 12)
//或者这样
getName.bind(person).bind(null, 18)(12)
```
### 内置函数中的 this
数组中的一些方法,类似于 map、forEach 等,可以自己设置绑定 this
```js
const obj = {
name: "zhangsan"
}
const array = [1, 2, 3];
array.map(function(value){
console.log(this.name)
}, obj)
// zhangsan x3
```
其中一些全局对象,如 setTimeout 等,它们和未显示绑定 this 的部分数组方法一样,都会指向全局对象(`Window`
```js
setTimeout(function(){
console.log(this)
}, 1000) // Window
```
JavaScript Classes
----

718
docs/kotlin.md Normal file
View File

@ -0,0 +1,718 @@
Kotlin 备忘清单
===
Kotlin 备忘清单是 [Kotlin](https://kotlinlang.org) 编程语言的单页参考表
Kotlin 简介
----
### main() 函数
```kotlin
fun main() {
// Code goes here
}
```
main() 函数是每个 Kotlin 程序的起点,在执行之前必须包含在代码中
### 打印声明
```kotlin
println("Greetings, earthling!")
print("Take me to ")
print("your leader.")
/*
打印:
Greetings, earthling!
Take me to your leader.
*/
```
### 注释
```kotlin
// 这是单行注释
/*
这个
注释
用于
*/
```
### 执行顺序
```kotlin
fun main() {
println("I will be printed first.")
println("I will be printed second.")
println("I will be printed third.")
}
```
数据类型和变量
---
### 可变变量
```kotlin
var age = 25
age = 26
```
### 不可变变量
```kotlin
val goldenRatio = 1.618
```
### 类型推断
```kotlin
// 以下变量在双引号内分配了一个文本值
// 因此推断的类型是 String
var color = "Purple"
```
### 字符串连接
```kotlin
var streetAddress = "123 Main St."
var cityState = "Brooklyn, NY"
println(streetAddress + " " + cityState)
// 打印: 123 Main St. Brooklyn, NY
```
### 字符串模板
```kotlin
var address = "123 Main St."
println("The address is $address")
// 打印: The address is 123 Main St.
```
### 内置属性和函数
```kotlin
var monument = "the Statue of Liberty"
println(monument.capitalize())
// 打印: The Statue of Liberty
println(monument.length)
// 打印: 21
```
### 字符转义序列
<!--rehype:wrap-class=row-span-2-->
```kotlin
print("\"Excellent!\" I cried. \"Elementary,\" said he.")
// 打印: "Excellent!" I cried. "Elementary," said he.
```
<!--rehype:className=wrap-text-->
- `\n` 插入新行
- `\t` 插入标签
- `\r` 插入回车
- `\'` 插入单引号
- `\"` 插入双引号
- `\\` 插入反斜杠
- `\$` 插入美元符号
### 算术运算符
```kotlin
5 + 7 // 12
9 - 2 // 7
8 * 4 // 32
25 / 5 // 5
31 % 2 // 1
```
`+` 加法、`-` 减法、`*` 乘法、`/` 除法和 `%` 模数
### 操作顺序
```kotlin
5 + 8 * 2 / 4 - 3 // 6
3 + (4 + 4) / 2 // 7
4 * 2 + 1 * 7 // 15
3 + 18 / 2 * 1 // 12
6 - 3 % 2 + 2 // 7
```
### 增强赋值运算符
```kotlin
var batteryPercentage = 80
// 长语法
batteryPercentage = batteryPercantage + 10
// 带有增广赋值运算符的短句法
batteryPercentage += 10
```
### 递增和递减运算符
```kotlin
var year = 2019
year++ // 2020
year-- // 2019
```
### 数学库
```kotlin
Math.pow(2.0, 3.0) // 8.0
Math.min(6, 9) // 6
Math.max(10, 12) // 12
Math.round(13.7) // 14
```
条件表达式
----
### if 表达式
```kotlin
var morning = true
if (morning) {
println("Rise and shine!")
}
// 打印: Rise and shine!
```
### else 表达式
```kotlin
var rained = false
if (rained) {
println("今天不需要给植物浇水。")
} else {
println("植物需要浇水!")
}
// 打印: 植物需要浇水!
```
### Else-If 表达式
```kotlin
var age = 65
if (age < 18 ) {
println("您被视为未成年人")
} else if (age < 60) {
println("您被视为成年人")
} else {
println("你被认为是高级")
}
// 打印: 你被认为是高级
```
### 比较运算符
```kotlin
var myAge = 19
var sisterAge = 11
var cousinAge = 11
myAge > sisterAge // true
myAge < cousinAge // false
myAge >= cousinAge // true
myAge <= sisterAge // false
```
### 逻辑运算符
```kotlin
var humid = true
var raining = true
var jacket = false
println(!humid)
// 打印: false
println(jacket && raining)
// 打印: true
println(humid || raining)
// 打印: true
```
### AND 运算符: &&
```kotlin
var humid = true
var raining = true
var shorts = false
var sunny = false
// true AND true
println(humid && raining) // true
// true AND false
println(humid && shorts) // false
// false AND true
println(sunny && raining) // false
// false AND false
println(shorts && sunny) // false
```
### 或运算符:||
```kotlin
var late = true
var skipBreakfast = true
var underslept = false
var checkEmails = false
// true OR true
println(skipBreakfast || late) // true
// true OR false
println(late || checkEmails) // true
// false OR true
println(underslept || late) // true
// false OR false
println(checkEmails || underslept) // false
```
### NOT 运算符
```kotlin
var hungry = true
var full = false
println(!hungry) // false
println(!full) // true
```
### 评估顺序
```kotlin
!true && (false || true) // false
/*
(false || true) 被评估首先返回 true。
然后,评估 !true && true 并返回最终结果 false
*/
!false && true || false // true
/*
!false 被评估首先返回 true。
然后评估 true && true返回 true。
那么,真|| 评估 false 最终返回 true
*/
```
### 嵌套条件
```kotlin
var studied = true
var wellRested = true
if (wellRested) {
println("祝你今天好运!")
if (studied) {
println("你应该为考试做好准备!")
} else {
println("考试前花几个小时学习!")
}
}
// 打印: 祝你今天好运!
// 打印: 你应该为考试做好准备!
```
### 当表达式
```kotlin
var grade = "A"
when(grade) {
"A" -> println("很棒的工作!")
"B" -> println("做得太好了!")
"C" -> println("你通过了!")
else -> println("关!下次一定要多准备!")
}
// 打印: 很棒的工作!
```
### 范围运算符
```kotlin
var height = 46 // inches
if (height in 1..53) {
println("抱歉,您必须至少 54 英寸才能乘坐过山车"
}
// Prints: 抱歉,您必须至少 54 英寸才能乘坐过山车
```
<!--rehype:className=wrap-text-->
### 等式运算符
```kotlin
var myAge = 22
var sisterAge = 21
myAge == sisterAge // false
myAge !== sisterAge // true
```
Collections
---
### 不可变列表
```kotlin
var programmingLanguages = listOf("C#", "Java", "Kotlin", "Ruby")
```
<!--rehype:className=wrap-text-->
### 可变列表
```kotlin
var fruits = mutableListOf("Orange", "Apple", "Banana", "Mango")
```
<!--rehype:className=wrap-text-->
### 访问列表元素
```kotlin
var cars = listOf("BMW", "Ferrari", "Volvo", "Tesla")
println(cars[2]) // Prints: Volvo
```
<!--rehype:className=wrap-text-->
### 大小属性
```kotlin
var worldContinents = listOf("Asia", "Africa", "North America", "South America", "Antarctica", "Europe", "Australia")
println(worldContinents.size) // Prints: 7
```
<!--rehype:className=wrap-text-->
### 列表操作
<!--rehype:wrap-class=row-span-2-->
```kotlin
var seas = listOf("Black Sea", "Caribbean Sea", "North Sea")
println(seas.contains("North Sea")) // Prints: true
// contains() 函数对任何列表执行读取操作并确定元素是否存在
seas.add("Baltic Sea") // 错误:无法对不可变列表执行写操作
// add() 函数只能在可变列表上调用,因此上面的代码会引发错误
```
<!--rehype:className=wrap-text-->
### 不可变集
```kotlin
var primaryColors = setOf("Red", "Blue", "Yellow")
```
<!--rehype:className=wrap-text-->
### 可变集
```kotlin
var womenInTech = mutableSetOf("Ada Lovelace", "Grace Hopper", "Radia Perlman", "Sister Mary Kenneth Keller")
```
<!--rehype:className=wrap-text-->
### 访问集合元素
<!--rehype:wrap-class=row-span-2-->
```kotlin
var companies = setOf("Facebook", "Apple", "Netflix", "Google")
println(companies.elementAt(3))
// Prints: Google
println(companies.elementAt(4))
// Returns and Error
println(companies.elementAtOrNull(4))
// Prints: null
```
<!--rehype:className=wrap-text-->
### 不可变映射
```kotlin
var averageTemp = mapOf("winter" to 35, "spring" to 60, "summer" to 85, "fall" to 55)
```
<!--rehype:className=wrap-text-->
### 可变映射
```kotlin
var europeanDomains = mutableMapOf("Germany" to "de", "Slovakia" to "sk", "Hungary" to "hu", "Norway" to "no")
```
<!--rehype:className=wrap-text-->
### 检索映射键和值
```kotlin
var oscarWinners = mutableMapOf("Parasite" to "Bong Joon-ho", "Green Book" to "Jim Burke", "The Shape Of Water" to "Guillermo del Toro")
println(oscarWinners.keys)
// Prints: [Parasite, Green Book, The Shape Of Water]
println(oscarWinners.values)
// Prints: [Bong Joon-ho, Jim Burke, Guillermo del Toro]
println(oscarWinners["Parasite"])
// Prints: Bong Joon-ho
```
<!--rehype:className=wrap-text-->
### 添加和删除地图条目
```kotlin
var worldCapitals = mutableMapOf("United States" to "Washington D.C.", "Germany" to "Berlin", "Mexico" to "Mexico City", "France" to "Paris")
worldCapitals.put("Brazil", "Brasilia")
println(worldCapitals)
// Prints: {United States=Washington D.C., Germany=Berlin, Mexico=Mexico City, France=Paris, Brazil=Brasilia}
worldCapitals.remove("Germany")
println(worldCapitals)
// Prints: {United States=Washington D.C., Mexico=Mexico City, France=Paris, Brazil=Brasilia}
```
<!--rehype:className=wrap-text-->
函数
---
### 函数
```kotlin
fun greet() {
println("Hey there!")
}
fun main() {
// Function call
greet() // Prints: Hey there!
}
```
### 函数参数
```kotlin
fun birthday(name: String, age: Int) {
println("Happy birthday $name! You turn $age today!")
}
fun main() {
birthday("Oscar", 26)
// Prints: Happy birthday Oscar! You turn 25 today!
birthday("Amarah", 30)
// Prints: Happy birthday Amarah! You turn 30 today!
}
```
<!--rehype:className=wrap-text-->
### 默认参数
```kotlin
fun favoriteLanguage(name, language = "Kotlin") {
println("Hello, $name. Your favorite programming language is $language")
}
fun main() {
favoriteLanguage("Manon")
// Prints: Hello, Manon. Your favorite programming language is Kotlin
favoriteLanguage("Lee", "Java")
// Prints: Hello, Lee. Your favorite programming language is Java
}
```
<!--rehype:className=wrap-text-->
### 命名参数
```kotlin
fun findMyAge(currentYear: Int, birthYear: Int) {
var myAge = currentYear - birthYear
println("I am $myAge years old.")
}
fun main() {
findMyAge(currentYear = 2020, birthYear = 1995)
// Prints: I am 25 years old.
findMyAge(birthYear = 1920, currentYear = 2020)
// Prints: I am 100 years old.
}
```
<!--rehype:className=wrap-text-->
### 返回声明
```kotlin
// Return type is declared outside the parentheses
fun getArea(length: Int, width: Int): Int {
var area = length * width
// return statement
return area
}
fun main() {
var myArea = getArea(10, 8)
println("The area is $myArea.")
// Prints: The area is 80.
}
```
<!--rehype:className=wrap-text-->
### 单表达式函数
```kotlin
fun fullName(firstName: String, lastName: String) = "$firstName $lastName"
fun main() {
println(fullName("Ariana", "Ortega"))
// Prints: Ariana Ortega
println(fullName("Kai", "Gittens"))
// Prints: Kai Gittens
}
```
<!--rehype:className=wrap-text-->
### 函数字面量
```kotlin
fun main() {
// Anonymous Function:
var getProduct = fun(num1: Int, num2: Int): Int {
return num1 * num2
}
println(getProduct(8, 3))
// Prints: 24
// Lambda Expression
var getDifference = { num1: Int, num2: Int -> num1 - num2 }
println(getDifference(10, 3))
// Prints: 7
}
```
<!--rehype:className=wrap-text-->
---
### 类示例
```kotlin
// 具有包含默认值的属性的类
class Student {
var name = "Lucia"
var semester = "Fall"
var gpa = 3.95
}
// 没有类体的简写语法
class Student
```
### 类实例
```kotlin
// Class
class Student {
var name = "Lucia"
var semester = "Fall"
var gpa = 3.95
}
fun main() {
var student = Student()
// Instance
println(student.name)
// Prints: Lucia
println(student.semester)
// Prints: Fall
println(student.gpa)
// Prints: 3.95
}
```
### 主构造函数
```kotlin
class Student(val name: String, val gpa: Double, val semester: String, val estimatedGraduationYear: Int)
fun main() {
var student = Student("Lucia", 3.95, "Fall", 2022)
println(student.name)
// Prints: Lucia
println(student.gpa)
// Prints: 3.95
println(student.semester)
// Prints: Fall
println(student.estimatedGraduationYear)
// Prints: 2022
}
```
<!--rehype:className=wrap-text-->
### 初始化块
```kotlin
class Student(val name: String, val gpa: Double, val semester: String, val estimatedGraduationYear: Int) {
init {
println("$name has ${estimatedGraduationYear - 2020} years left in college.")
}
}
fun main() {
var student = Student("Lucia", 3.95, "Fall", 2022)
// Prints: Lucia has 2 years left in college.
}
```
<!--rehype:className=wrap-text-->
### 成员函数
<!--rehype:wrap-class=col-span-2-->
```kotlin
class Student(val name: String, val gpa: Double, val semester: String, val estimatedGraduationYear: Int) {
init {
println("$name has ${estimatedGraduationYear - 2020} years left in college.")
}
// 成员函数
fun calculateLetterGrade(): String {
return when {
gpa >= 3.0 -> "A"
gpa >= 2.7 -> "B"
gpa >= 1.7 -> "C"
gpa >= 1.0 -> "D"
else -> "E"
}
}
}
// 创建实例并调用函数时,将执行 when 表达式并返回字母等级
fun main() {
var student = Student("Lucia", 3.95, "Fall", 2022)
// Prints: Lucia has 2 years left in college.
println("${student.name}'s letter grade is ${student.calculateLetterGrade()}.")
// Prints: Lucia's letter grade is A.
}
```
<!--rehype:className=wrap-text-->
另见
---
- [Kotlin 语言官方文档](https://kotlinlang.org/) _(kotlinlang.org)_

View File

@ -173,6 +173,12 @@ ALTER TABLE t1 RENAME TO t2;
ALTER TABLE t1 RENAME c1 TO c2 ;
```
将列c1的数据类型改为datatype
```sql
ALTER TABLE t1 MODIFY c1 datatype;
```
删除表中的所有数据
```sql

View File

@ -21,6 +21,7 @@ npm 备忘清单
`npm install <package_name>@<tag>` | 使用 `dist-tags` 安装包
`npm install -g <package_name>` | 全局安装包
`npm uninstall <package_name>` | 卸载包
`npm uninstall -g <package_name>` | 全局卸载包
<!--rehype:class=auto-wrap-->
### 安装
@ -154,6 +155,47 @@ $ nrm ls
$ nrm use cnpm
```
### init
用于设置新的或现有的 `npm`
```bash
$ npm init <package-spec> # (如同 `npx <package-spec>)
$ npm init <@scope> # (如同 `npx <@scope>/create`)
```
别名: `create`, `innit`
:- | --
:- | --
`npm init foo` | `npm exec create-foo`
`npm init @usr/foo` | `npm exec @usr/create-foo`
`npm init @usr` | `npm exec @usr/create`
`npm init @usr@2.0.0` | `npm exec @usr/create@2.0.0`
`npm init @usr/foo@2.0.0` | `npm exec @usr/create-foo@2.0.0`
<!--rehype:className=left-align-->
### exec
命令允许您在与通过 `npm run` 运行它类似的上下文中从 npm 包
```bash
$ npm exec -- <pkg>[@<version>] [args...]
$ npm exec --package=<pkg>[@<version>] -- <cmd> [args...]
$ npm exec -c '<cmd> [args...]'
$ npm exec --package=foo -c '<cmd> [args...]'
```
别名: x
```bash
$ npm exec --package yo --package generator-node --call "yo node"
$ npm exec --package=foo -- bar --bar-argument
# ~ or ~
$ npx --package=foo bar --bar-argument
```
npx
---
@ -248,7 +290,7 @@ $ npx react-native init AwesomeTSProject --template react-native-template-typesc
```
<!--rehype:className=wrap-text-->
使用 `npx` 直接创建一个 [React Native]((https://reactnative.dev/docs/environment-setup#creating-a-new-application)) 应用
使用 `npx` 直接创建一个 [React Native](https://reactnative.dev/docs/environment-setup#creating-a-new-application) 应用
### 创建一个 React 应用
@ -398,4 +440,4 @@ ELECTRON_BUILDER_BINARIES_MIRROR=https://npmmirror.com/mirrors/electron-builder-
- [npm 仓库、网站和命令行界面的文档](https://docs.npmjs.com/) _(npmjs.com)_
- [npmmirror 中国镜像站](https://npmmirror.com/) _(npmmirror.com)_
- [](https://michaelcurrin.github.io/dev-cheatsheets/cheatsheets/package-managers/javascript/npm/commands/npx.html) _(michaelcurrin.github.io)_
- [Dev Cheatsheets npx](https://michaelcurrin.github.io/dev-cheatsheets/cheatsheets/package-managers/javascript/npm/commands/npx.html) _(michaelcurrin.github.io)_

View File

@ -336,7 +336,7 @@ o
'baco'
```
#### 迈着大
#### 步
```python
>>> s = '12345' * 5
@ -1224,7 +1224,7 @@ try:
# 使用“raise”来引发错误
raise IndexError("这是一个索引错误")
except IndexError as e:
pass # 通行证只是一个空操作。 通常你会在这里做恢复。
pass # pass只是一个空操作。 通常你会在这里做恢复。
except (TypeError, NameError):
pass # 如果需要,可以一起处理多个异常。
else: # try/except 块的可选子句。 必须遵循除块之外的所有内容

View File

@ -337,16 +337,16 @@ const school = <div>学校</div>;
类 | 说明
---- | ----
`<!--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: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-->` | `箭头`标记
### KaTeX 数学渲染

View File

@ -1316,6 +1316,7 @@ type Data = Point[];
type PointDetail = Data[number];
// type PointDetail = { x: number; y: number; }
```
<!--rehype:className=wrap-text-->
### 只读元组类型
@ -1324,6 +1325,239 @@ const point = [3, 4] as const
// type 'readonly [3, 4]'
```
TSConfig Ref
---
### 顶层配置
:- | --
:- | --
`files` [#](https://www.typescriptlang.org/zh/tsconfig#files) | 指定要`包含`在程序中的文件的允许列表
`extends` [#](https://www.typescriptlang.org/zh/tsconfig#extends) | 包含要`继承`的另一个配置文件的路径
`include` [#](https://www.typescriptlang.org/zh/tsconfig#include) | 指定要`包含`在程序中的文件名或模式数组
`exclude` [#](https://www.typescriptlang.org/zh/tsconfig#exclude) | 指定解析包含时应`跳过`的文件名或模式数组
`references` [#](https://www.typescriptlang.org/zh/tsconfig#references) | 项目引用是一种将 TypeScript 程序构造成更小部分的方法
<!--rehype:className=style-list-arrow-->
---
```js
{
"extends": "./tsconfig",
"compilerOptions": {
"strictNullChecks": false
}
}
```
### 类型检查(compilerOptions)
<!--rehype:wrap-class=row-span-3-->
:- | --
:- | --
`allowUnreachableCode` [#](https://www.typescriptlang.org/zh/tsconfig#allowUnreachableCode) | 允许无法访问的代码
`allowUnusedLabels` [#](https://www.typescriptlang.org/zh/tsconfig#allowUnusedLabels) | 允许未使用的标签
`alwaysStrict` [#](https://www.typescriptlang.org/zh/tsconfig#alwaysStrict) | 始终严格
`exactOptionalPropertyTypes` [#](https://www.typescriptlang.org/zh/tsconfig#exactOptionalPropertyTypes) | 启用后TypeScript 应用更严格的规则来处理它如何处理类型或具有 ? 字首
`noFallthroughCasesInSwitch` [#](https://www.typescriptlang.org/zh/tsconfig#noFallthroughCasesInSwitch) | 在 switch 语句中报告失败案例的错误
`noImplicitAny` [#](https://www.typescriptlang.org/zh/tsconfig#noImplicitAny) | 在某些不存在类型注释的情况下TypeScript 将在无法推断类型时回退到变量的任何类型
`noImplicitOverride` [#](https://www.typescriptlang.org/zh/tsconfig#noImplicitOverride) | 当处理使用继承的类时,子类可能与在基类中重命名时重载的函数“不同步”
`noImplicitReturns` [#](https://www.typescriptlang.org/zh/tsconfig#noImplicitReturns) | 没有隐式返回
`noImplicitThis` [#](https://www.typescriptlang.org/zh/tsconfig#noImplicitThis) | 使用隐含的“any”类型在“this”表达式上引发错误
`noPropertyAccessFromIndexSignature` [#](https://www.typescriptlang.org/zh/tsconfig#noPropertyAccessFromIndexSignature) | 此设置确保通过“点”obj.key语法访问字段和“索引”obj[“key”])以及在类型中声明属性的方式之间的一致性
`noUncheckedIndexedAccess` [#](https://www.typescriptlang.org/zh/tsconfig#noUncheckedIndexedAccess) | TypeScript 有一种方法可以通过索引签名来描述对象上具有未知键但已知值的对象
`noUnusedLocals` [#](https://www.typescriptlang.org/zh/tsconfig#noUnusedLocals) | 报告未使用的局部变量的错误
`noUnusedParameters` [#](https://www.typescriptlang.org/zh/tsconfig#noUnusedParameters) | 报告函数中未使用参数的错误
`strict` [#](https://www.typescriptlang.org/zh/tsconfig#strict) | 严格标志启用了范围广泛的类型检查行为,从而更有效地保证了程序的正确性
`strictBindCallApply` [#](https://www.typescriptlang.org/zh/tsconfig#strictBindCallApply) | TypeScript 将检查函数调用、绑定和应用的内置方法是否使用底层函数的正确参数调用
`strictFunctionTypes` [#](https://www.typescriptlang.org/zh/tsconfig#strictFunctionTypes) | 此标志会导致更正确地检查函数参数
`strictNullChecks` [#](https://www.typescriptlang.org/zh/tsconfig#strictNullChecks) | 严格的空检查
`strictPropertyInitialization` [#](https://www.typescriptlang.org/zh/tsconfig#strictPropertyInitialization) | 严格的属性初始化
`useUnknownInCatchVariables` [#](https://www.typescriptlang.org/zh/tsconfig#useUnknownInCatchVariables) | 在 TypeScript 4.0 中,添加了支持以允许将 catch 子句中的变量类型从 any 更改为 unknown
<!--rehype:className=style-list-arrow-->
### 模块(compilerOptions)
<!--rehype:wrap-class=row-span-2-->
:- | --
:- | --
`allowUmdGlobalAccess` [#](https://www.typescriptlang.org/zh/tsconfig#allowUmdGlobalAccess) | 为 true 时,将允许你在模块文件中以全局变量的形式访问 UMD 的导出
`baseUrl` [#](https://www.typescriptlang.org/zh/tsconfig#baseUrl) | 可以让您设置解析非绝对路径模块名时的基准目录
`module` [#](https://www.typescriptlang.org/zh/tsconfig#module) | 设置程序的模块系统
`moduleResolution` [#](https://www.typescriptlang.org/zh/tsconfig#moduleResolution) | 指定模块解析策略:'node'Node.js或 'classic'
`moduleSuffixes` [#](https://www.typescriptlang.org/zh/tsconfig#moduleSuffixes) | 提供一种在解析模块时覆盖要搜索的默认文件名后缀列表的方法
`noResolve` [#](https://www.typescriptlang.org/zh/tsconfig#noResolve) | 默认情况下TypeScript 将检查导入和 `<reference` 指令的初始文件集,并将这些解析的文件添加到您的程序中
`paths` [#](https://www.typescriptlang.org/zh/tsconfig#paths) | 一些将模块导入重新映射到相对于 baseUrl 路径的配置
`resolveJsonModule` [#](https://www.typescriptlang.org/zh/tsconfig#resolveJsonModule) | 允许导入带有“.json”扩展名的模块这是 node 项目中的常见做法
`rootDir` [#](https://www.typescriptlang.org/zh/tsconfig#rootDir) | 默认: 所有输入的非声明文件中的最长公共路径
`rootDirs` [#](https://www.typescriptlang.org/zh/tsconfig#rootDirs) | 通过 rootDirs你可以告诉编译器有许多“虚拟”的目录作为一个根目录
`typeRoots` [#](https://www.typescriptlang.org/zh/tsconfig#typeRoots) | 默认情况下,所有 可见 的 ”@types” 包都将包含在你的编译过程中
`types` [#](https://www.typescriptlang.org/zh/tsconfig#types) | 默认情况下,所有 可见 的 ”@types” 包都将包含在你的编译过程中
<!--rehype:className=style-list-arrow-->
### Emit(compilerOptions)
<!--rehype:wrap-class=row-span-2-->
:- | --
:- | --
`declaration` [#](https://www.typescriptlang.org/zh/tsconfig#declaration) |
`declarationDir` [#](https://www.typescriptlang.org/zh/tsconfig#declarationDir) |
`declarationMap` [#](https://www.typescriptlang.org/zh/tsconfig#declarationMap) |
`downlevelIteration` [#](https://www.typescriptlang.org/zh/tsconfig#downlevelIteration) |
`emitBOM` [#](https://www.typescriptlang.org/zh/tsconfig#emitBOM) |
`emitDeclarationOnly` [#](https://www.typescriptlang.org/zh/tsconfig#emitDeclarationOnly) |
`importHelpers` [#](https://www.typescriptlang.org/zh/tsconfig#importHelpers) |
`importsNotUsedAsValues` [#](https://www.typescriptlang.org/zh/tsconfig#importsNotUsedAsValues) |
`inlineSourceMap` [#](https://www.typescriptlang.org/zh/tsconfig#inlineSourceMap) |
`inlineSources` [#](https://www.typescriptlang.org/zh/tsconfig#inlineSources) |
`mapRoot` [#](https://www.typescriptlang.org/zh/tsconfig#mapRoot) |
`newLine` [#](https://www.typescriptlang.org/zh/tsconfig#newLine) |
`noEmit` [#](https://www.typescriptlang.org/zh/tsconfig#noEmit) |
`noEmitHelpers` [#](https://www.typescriptlang.org/zh/tsconfig#noEmitHelpers) |
`noEmitOnError` [#](https://www.typescriptlang.org/zh/tsconfig#noEmitOnError) |
`outDir` [#](https://www.typescriptlang.org/zh/tsconfig#outDir) |
`outFile` [#](https://www.typescriptlang.org/zh/tsconfig#outFile) |
`preserveConstEnums` [#](https://www.typescriptlang.org/zh/tsconfig#preserveConstEnums) |
`preserveValueImports` [#](https://www.typescriptlang.org/zh/tsconfig#preserveValueImports) |
`removeComments` [#](https://www.typescriptlang.org/zh/tsconfig#removeComments) |
`sourceMap` [#](https://www.typescriptlang.org/zh/tsconfig#sourceMap) |
`sourceRoot` [#](https://www.typescriptlang.org/zh/tsconfig#sourceRoot) |
`stripInternal` [#](https://www.typescriptlang.org/zh/tsconfig#stripInternal) |
### JavaScript 支持(compilerOptions)
:- | --
:- | --
`allowJs` [#](https://www.typescriptlang.org/zh/tsconfig#allowJs) | 允许 JavaScript 文件在你的工程中被引入,而不是仅仅允许 .ts 和 .tsx 文件
`checkJs` [#](https://www.typescriptlang.org/zh/tsconfig#checkJs) | 与 allowJs 配合使用,当 checkJs 被启用时JavaScript 文件中会报告错误
`maxNodeModuleJsDepth` [#](https://www.typescriptlang.org/zh/tsconfig#maxNodeModuleJsDepth) | 在 node_modules 下搜索和加载 JavaScript 文件的最大依赖深度
<!--rehype:className=style-list-arrow-->
### 编辑器支持(compilerOptions)
:- | --
:- | --
`disableSizeLimit` [#](https://www.typescriptlang.org/zh/tsconfig#disableSizeLimit) | 分配的内存量有一个上限。打开此标志将删除限制
`plugins` [#](https://www.typescriptlang.org/zh/tsconfig#plugins) | 可在编辑器内运行的语言服务插件列表
<!--rehype:className=style-list-arrow-->
### 互操作约束(compilerOptions)
:- | --
:- | --
`allowSyntheticDefaultImports` [#](https://www.typescriptlang.org/zh/tsconfig#allowSyntheticDefaultImports) |
`esModuleInterop` [#](https://www.typescriptlang.org/zh/tsconfig#esModuleInterop) |
`forceConsistentCasingInFileNames` [#](https://www.typescriptlang.org/zh/tsconfig#forceConsistentCasingInFileNames) |
`isolatedModules` [#](https://www.typescriptlang.org/zh/tsconfig#isolatedModules) |
`preserveSymlinks` [#](https://www.typescriptlang.org/zh/tsconfig#preserveSymlinks) |
### 向后兼容性(compilerOptions)
:- | --
:- | --
`charset` [#](https://www.typescriptlang.org/zh/tsconfig#charset) |
`keyofStringsOnly` [#](https://www.typescriptlang.org/zh/tsconfig#keyofStringsOnly) |
`noImplicitUseStrict` [#](https://www.typescriptlang.org/zh/tsconfig#noImplicitUseStrict) |
`noStrictGenericChecks` [#](https://www.typescriptlang.org/zh/tsconfig#noStrictGenericChecks) |
`out` [#](https://www.typescriptlang.org/zh/tsconfig#out) |
`suppressExcessPropertyErrors` [#](https://www.typescriptlang.org/zh/tsconfig#suppressExcessPropertyErrors) |
`suppressImplicitAnyIndexErrors` [#](https://www.typescriptlang.org/zh/tsconfig#suppressImplicitAnyIndexErrors) |
### 语言与环境(compilerOptions)
:- | --
:- | --
`emitDecoratorMetadata` [#](https://www.typescriptlang.org/zh/tsconfig#emitDecoratorMetadata) |
`experimentalDecorators` [#](https://www.typescriptlang.org/zh/tsconfig#experimentalDecorators) |
`jsx` [#](https://www.typescriptlang.org/zh/tsconfig#jsx) |
`jsxFactory` [#](https://www.typescriptlang.org/zh/tsconfig#jsxFactory) |
`jsxFragmentFactory` [#](https://www.typescriptlang.org/zh/tsconfig#jsxFragmentFactory) |
`jsxImportSource` [#](https://www.typescriptlang.org/zh/tsconfig#jsxImportSource) |
`lib` [#](https://www.typescriptlang.org/zh/tsconfig#lib) |
`moduleDetection` [#](https://www.typescriptlang.org/zh/tsconfig#moduleDetection) |
`noLib` [#](https://www.typescriptlang.org/zh/tsconfig#noLib) |
`reactNamespace` [#](https://www.typescriptlang.org/zh/tsconfig#reactNamespace) |
`target` [#](https://www.typescriptlang.org/zh/tsconfig#target) |
`useDefineForClassFields` [#](https://www.typescriptlang.org/zh/tsconfig#useDefineForClassFields) |
### 编译器诊断(compilerOptions)
:- | --
:- | --
`diagnostics` [#](https://www.typescriptlang.org/zh/tsconfig#diagnostics) |
`explainFiles` [#](https://www.typescriptlang.org/zh/tsconfig#explainFiles) |
`extendedDiagnostics` [#](https://www.typescriptlang.org/zh/tsconfig#extendedDiagnostics) |
`generateCpuProfile` [#](https://www.typescriptlang.org/zh/tsconfig#generateCpuProfile) |
`listEmittedFiles` [#](https://www.typescriptlang.org/zh/tsconfig#listEmittedFiles) |
`listFiles` [#](https://www.typescriptlang.org/zh/tsconfig#listFiles) |
`traceResolution` [#](https://www.typescriptlang.org/zh/tsconfig#traceResolution) |
### 项目(compilerOptions)
:- | --
:- | --
`composite` [#](https://www.typescriptlang.org/zh/tsconfig#composite) |
`disableReferencedProjectLoad` [#](https://www.typescriptlang.org/zh/tsconfig#disableReferencedProjectLoad) |
`disableSolutionSearching` [#](https://www.typescriptlang.org/zh/tsconfig#disableSolutionSearching) |
`disableSourceOfProjectReferenceRedirect` [#](https://www.typescriptlang.org/zh/tsconfig#disableSourceOfProjectReferenceRedirect) |
`incremental` [#](https://www.typescriptlang.org/zh/tsconfig#incremental) |
`tsBuildInfoFile` [#](https://www.typescriptlang.org/zh/tsconfig#tsBuildInfoFile) |
### 输出格式(compilerOptions)
:- | --
:- | --
`noErrorTruncation` [#](https://www.typescriptlang.org/zh/tsconfig#noErrorTruncation) |
`preserveWatchOutput` [#](https://www.typescriptlang.org/zh/tsconfig#preserveWatchOutput) |
`pretty` [#](https://www.typescriptlang.org/zh/tsconfig#pretty) |
### 完整性(compilerOptions)
:- | --
:- | --
`skipDefaultLibCheck` [#](https://www.typescriptlang.org/zh/tsconfig#skipDefaultLibCheck) |
`skipLibCheck` [#](https://www.typescriptlang.org/zh/tsconfig#skipLibCheck) |
### 监听选项(watchOptions)
:- | --
:- | --
`watchFile` [#](https://www.typescriptlang.org/zh/tsconfig#watch-watchFile) |
`watchDirectory` [#](https://www.typescriptlang.org/zh/tsconfig#watch-watchDirectory) |
`fallbackPolling` [#](https://www.typescriptlang.org/zh/tsconfig#watch-fallbackPolling) |
`synchronousWatchDirectory` [#](https://www.typescriptlang.org/zh/tsconfig#watch-synchronousWatchDirectory) |
`excludeDirectories` [#](https://www.typescriptlang.org/zh/tsconfig#watch-excludeDirectories) |
`excludeFiles` [#](https://www.typescriptlang.org/zh/tsconfig#watch-excludeFiles) |
---
```js
{
"watchOptions": {
"synchronousWatchDirectory": true
}
}
```
### 类型采集(typeAcquisition)
:- | --
:- | --
`enable` [#](https://www.typescriptlang.org/zh/tsconfig#type-enable) |
`include` [#](https://www.typescriptlang.org/zh/tsconfig#type-include) |
`exclude` [#](https://www.typescriptlang.org/zh/tsconfig#type-exclude) |
`disableFilenameBasedTypeAcquisition` [#](https://www.typescriptlang.org/zh/tsconfig#type-disableFilenameBasedTypeAcquisition) |
---
```js
{
"typeAcquisition": {
"enable": false
}
}
```
另见
----

View File

@ -1,6 +1,6 @@
{
"name": "@wcj/reference",
"version": "1.21.0",
"version": "1.22.0",
"description": "为开发人员分享快速参考备忘单(主要是方便自己)。",
"author": "jaywcjlove",
"license": "MIT",
@ -22,6 +22,7 @@
},
"keywords": [],
"devDependencies": {
"@uiw/formatter": "^1.3.3",
"@wcj/markdown-to-html": "^2.1.2",
"chokidar": "^3.5.3",
"fs-extra": "^10.1.0",

2
scripts/assets/cpp.svg Normal file
View File

@ -0,0 +1,2 @@
<svg xmlns="http://www.w3.org/2000/svg" height="1em" width="1em" viewBox="0 0 187 155">
<path fill="currentColor" d="M77.4039102,0.01171875 C104.893578,0.01171875 130.532863,14.8054453 144.312707,38.6186211 L110.875113,57.9682852 C103.978656,46.0481602 91.1520117,38.6428945 77.4039102,38.6428945 C56.1021016,38.6428945 38.7718008,55.9731953 38.7718008,77.2750039 C38.7718008,98.5758789 56.1021016,115.90618 77.4039102,115.90618 C91.1529453,115.90618 103.97959,108.500914 110.87698,96.5789219 L144.314574,115.927652 C130.53473,139.743629 104.895445,154.537355 77.4039102,154.537355 C34.800293,154.537355 0.140625,119.877688 0.140625,77.2750039 C0.140625,34.6713867 34.800293,0.01171875 77.4039102,0.01171875 Z M146.080934,64.3970117 L146.080934,72.9823398 L154.666262,72.9823398 L154.666262,81.5667344 L146.080934,81.5667344 L146.080934,90.1520625 L137.497473,90.1520625 L137.497473,81.5667344 L128.912145,81.5667344 L128.912145,72.9823398 L137.497473,72.9823398 L137.497473,64.3970117 L146.080934,64.3970117 Z M178.274047,64.3970117 L178.274047,72.9823398 L186.859375,72.9823398 L186.859375,81.5667344 L178.274047,81.5667344 L178.274047,90.1520625 L169.690586,90.1520625 L169.690586,81.5667344 L161.105258,81.5667344 L161.105258,72.9823398 L169.690586,72.9823398 L169.690586,64.3970117 L178.274047,64.3970117 Z"/></svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 32 32" height="1em" width="1em">
<path d="m1.734 32 15.068-15.333L32 32zM0 0h16L0 16.667zm17.865 0L0 18.667V32L32 0z"/>
</svg>

After

Width:  |  Height:  |  Size: 202 B

View File

@ -81,7 +81,7 @@ export function create(str = '', options = {}) {
node.children = tocsData;
}
node.children.unshift(header(options));
node.children.push(footer());
node.children.push(footer(options));
node.children.push(anchorPoint());
}
}

View File

@ -1,5 +1,10 @@
import formatter from '@uiw/formatter';
export function footer() {
export function footer(options = {}) {
let footerText = '© 2022 Kenny Wang.';
if (options.isHome) {
footerText += ` Updated on ${formatter('YYYY/MM/DD HH:mm:ss', new Date())}`;
}
return {
type: 'element',
tagName: 'footer',
@ -13,10 +18,8 @@ export function footer() {
properties: {
class: ['max-container'],
},
children: [
{ type: 'text', value: '© 2022 Kenny Wang, All rights reserved.' }
],
}
children: [{ type: 'text', value: footerText }],
},
],
};
}

View File

@ -1185,9 +1185,9 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
width: 1rem;
text-align: right;
margin-right: 16px;
margin-left: -8px;
color: var(--color-fg-subtle);
content: attr(line);
white-space: nowrap;
}
/* 代码高亮 End */
@ -1196,6 +1196,7 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
color: rgb(100 116 139/1);
background-color: var(--color-canvas-subtle);
text-align: center;
font-size: 0.75rem;
}
@media (min-width: 1024px) {