mirror of
https://github.com/jaywcjlove/reference.git
synced 2025-06-18 05:01:21 +08:00
Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
fc04f53b36 | |||
2303f3143f | |||
6e10f42d0d | |||
d6a7ca3d7f | |||
90e7f14e78 | |||
bc0868020a | |||
2175ce6241 | |||
46fb45e643 | |||
3ec4dc496a | |||
19caaad574 | |||
4122b48f76 |
@ -18,8 +18,10 @@ Quick Reference
|
||||
[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));-->
|
||||
[Golang](./docs/golang.md)<!--rehype:style=background: rgb(39 160 193/var(\-\-bg\-opacity));-->
|
||||
[JSON](./docs/json.md)<!--rehype:style=background: rgb(57 59 60/var(\-\-bg\-opacity));-->
|
||||
[Markdown](./docs/markdown.md)<!--rehype:style=background: rgb(103 61 156/var(\-\-bg\-opacity));-->
|
||||
[Swift](./docs/swift.md)<!--rehype:style=background: rgb(240 81 57/var(\-\-bg\-opacity));-->
|
||||
[TOML](./docs/toml.md)<!--rehype:style=background: rgb(132 132 132/var(\-\-bg\-opacity));-->
|
||||
[YAML](./docs/yaml.md)<!--rehype:style=background: rgb(91 163 230/var(\-\-bg\-opacity));-->
|
||||
<!--rehype:class=home-card-->
|
||||
@ -42,7 +44,7 @@ Quick Reference
|
||||
[Vue 2](./docs/vue2.md)<!--rehype:style=background: rgb(64 184 131/var(\-\-bg\-opacity));-->
|
||||
<!--rehype:class=home-card-->
|
||||
|
||||
## 工具包
|
||||
## 工具
|
||||
|
||||
[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));-->
|
||||
@ -50,6 +52,7 @@ Quick Reference
|
||||
[Sublime Text](./docs/sublime-text.md)<!--rehype:style=background: rgb(223 148 0/var(\-\-bg\-opacity));-->
|
||||
[VSCode](./docs/vscode.md)<!--rehype:style=background: rgb(91 163 230/var(\-\-bg\-opacity));-->
|
||||
[Vim](./docs/vim.md)<!--rehype:style=background: rgb(9 150 8/var(\-\-bg\-opacity));-->
|
||||
[WebStorm](./docs/webstorm.md)<!--rehype:style=background: rgb(91 163 230/var(\-\-bg\-opacity));-->
|
||||
[XPath](./docs/xpath.md)<!--rehype:style=background: rgb(91 163 230/var(\-\-bg\-opacity));-->
|
||||
<!--rehype:class=home-card-->
|
||||
|
||||
@ -69,6 +72,7 @@ Quick Reference
|
||||
## 其它
|
||||
|
||||
[Quick Reference](./docs/quickreference.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[Colors Named](./docs/colors-named.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[HTTP 状态码](./docs/http-status-code.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[HTML 字符实体](./docs/html-char.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
[Emoji](./docs/emoji.md)<!--rehype:style=background: rgb(16 185 129/var(\-\-bg\-opacity));-->
|
||||
|
1608
docs/colors-named.md
Normal file
1608
docs/colors-named.md
Normal file
File diff suppressed because it is too large
Load Diff
12
docs/css.md
12
docs/css.md
@ -251,12 +251,12 @@ p:first-child {
|
||||
|
||||
选择器 | 说明
|
||||
:- | :-
|
||||
`div.classname` | 具有特定类名的 Div
|
||||
`div#idname` | 具有特定 ID 的 Div
|
||||
`div p` | div中的段落
|
||||
`div > p` | 所有 p 个标签<br>_div 深处的一层_
|
||||
`div + p` | div 之后的 P 标签
|
||||
`div ~ p` | div 前面的 P 标签
|
||||
`div.classname` | 具有特定类名的 div
|
||||
`div#idname` | 具有特定 ID 的 div
|
||||
`div p` | div 中的段落
|
||||
`div > p` | div 子节点中的所有 `P` 标签
|
||||
`div + p` | div 之后的 `P` 标签
|
||||
`div ~ p` | div 前面的 `P` 标签
|
||||
|
||||
另见: [相邻兄弟](https://developer.mozilla.org/zh-CN/docs/Web/CSS/Adjacent_sibling_combinator) / [通用兄弟](https://developer.mozilla.org/zh-CN/docs/Web/CSS/General_sibling_combinator) / [子](https://developer.mozilla.org/zh-CN/docs/Web/CSS/Child_combinator) 选择器
|
||||
|
||||
|
966
docs/golang.md
Normal file
966
docs/golang.md
Normal file
@ -0,0 +1,966 @@
|
||||
Golang 备忘清单
|
||||
===
|
||||
|
||||
该备忘单提供了帮助您使用 [Golang](https://golang.org) 的基本语法和方法。
|
||||
|
||||
入门
|
||||
--------
|
||||
|
||||
### hello.go
|
||||
|
||||
```go
|
||||
package main
|
||||
import "fmt"
|
||||
func main() {
|
||||
fmt.Println("Hello, world!")
|
||||
}
|
||||
```
|
||||
|
||||
直接运行
|
||||
|
||||
```shell
|
||||
$ go run hello.go
|
||||
Hello, world!
|
||||
```
|
||||
|
||||
或者在 [Go repl](https://repl.it/languages/go) 中尝试一下
|
||||
|
||||
### 变量
|
||||
|
||||
```go
|
||||
var s1 string
|
||||
s1 = "Learn Go!"
|
||||
// 一次声明多个变量
|
||||
var b, c int = 1, 2
|
||||
var d = true
|
||||
```
|
||||
|
||||
简短声明
|
||||
|
||||
```go
|
||||
s1 := "Learn Go!" // string
|
||||
b, c := 1, 2 // int
|
||||
d := true // bool
|
||||
```
|
||||
|
||||
参见:[基本类型](#golang-基本类型)
|
||||
|
||||
### 函数
|
||||
|
||||
```go
|
||||
package main
|
||||
import "fmt"
|
||||
// 程序的入口点
|
||||
func main() {
|
||||
fmt.Println("Hello world!")
|
||||
say("Hello Go!")
|
||||
}
|
||||
func say(message string) {
|
||||
fmt.Println("You said: ", message)
|
||||
}
|
||||
```
|
||||
|
||||
参见:[函数(Functions)](#golang-函数)
|
||||
|
||||
### 注释
|
||||
|
||||
```go
|
||||
// 单行注释
|
||||
/* 这是
|
||||
多行注释 */
|
||||
```
|
||||
|
||||
### 如果语句
|
||||
|
||||
```go
|
||||
if true {
|
||||
fmt.Println("Yes!")
|
||||
}
|
||||
```
|
||||
|
||||
参见:[条件控制](#golang-条件控制)
|
||||
|
||||
Golang 基本类型
|
||||
--------
|
||||
|
||||
### 字符串 Strings
|
||||
|
||||
```go
|
||||
s1 := "Hello" + "World"
|
||||
s2 := `A "raw" string literal
|
||||
can include line breaks.`
|
||||
// 输出:11
|
||||
fmt.Println(len(s1))
|
||||
// 输出:Hello
|
||||
fmt.Println(string(s1[0:5]))
|
||||
```
|
||||
|
||||
字符串的类型为 `字符串`
|
||||
|
||||
### 数字 Numbers
|
||||
|
||||
```go
|
||||
num := 3 // int
|
||||
num := 3. // float64
|
||||
num := 3 + 4i // complex128
|
||||
num := byte('a') // byte (alias: uint8)
|
||||
var u uint = 7 // uint (unsigned)
|
||||
var p float32 = 22.7 // 32-bit float
|
||||
```
|
||||
|
||||
#### 操作符 Operators
|
||||
|
||||
```go
|
||||
x := 5
|
||||
x++
|
||||
fmt.Println("x + 4 =", x + 4)
|
||||
fmt.Println("x * 4 =", x * 4)
|
||||
```
|
||||
|
||||
参见:[更多操作符](#运算符和标点符号)
|
||||
|
||||
### 布尔值 Booleans
|
||||
|
||||
```go
|
||||
isTrue := true
|
||||
isFalse := false
|
||||
```
|
||||
|
||||
#### 操作符
|
||||
|
||||
```go
|
||||
fmt.Println(true && true) // true
|
||||
fmt.Println(true && false) // false
|
||||
fmt.Println(true || true) // true
|
||||
fmt.Println(true || false) // true
|
||||
fmt.Println(!true) // false
|
||||
```
|
||||
|
||||
参见:[更多操作符](#运算符和标点符号)
|
||||
|
||||
### 数组 Arrays
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```go
|
||||
┌────┬────┬────┬────┬─────┬─────┐
|
||||
| 2 | 3 | 5 | 7 | 11 | 13 |
|
||||
└────┴────┴────┴────┴─────┴─────┘
|
||||
0 1 2 3 4 5
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```go
|
||||
primes := [...]int{2, 3, 5, 7, 11, 13}
|
||||
fmt.Println(len(primes)) // => 6
|
||||
// 输出:[2 3 5 7 11 13]
|
||||
fmt.Println(primes)
|
||||
// 与 [:3] 相同,输出:[2 3 5]
|
||||
fmt.Println(primes[0:3])
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```go
|
||||
var a [2]string
|
||||
a[0] = "Hello"
|
||||
a[1] = "World"
|
||||
fmt.Println(a[0], a[1]) //=> Hello World
|
||||
fmt.Println(a) // => [Hello World]
|
||||
```
|
||||
|
||||
#### 2d array
|
||||
|
||||
```go
|
||||
var twoDimension [2][3]int
|
||||
for i := 0; i < 2; i++ {
|
||||
for j := 0; j < 3; j++ {
|
||||
twoDimension[i][j] = i + j
|
||||
}
|
||||
}
|
||||
// => 2d: [[0 1 2] [1 2 3]]
|
||||
fmt.Println("2d: ", twoDimension)
|
||||
```
|
||||
|
||||
### 指针(Pointers)
|
||||
|
||||
```go
|
||||
func main () {
|
||||
b := *getPointer()
|
||||
fmt.Println("Value is", b)
|
||||
}
|
||||
|
||||
func getPointer () (myPointer *int) {
|
||||
a := 234
|
||||
return &a
|
||||
}
|
||||
|
||||
a := new(int)
|
||||
*a = 234
|
||||
```
|
||||
|
||||
参见:[指针(Pointers)](https://tour.golang.org/moretypes/1)
|
||||
|
||||
### 切片(Slices)
|
||||
|
||||
```go
|
||||
s := make([]string, 3)
|
||||
s[0] = "a"
|
||||
s[1] = "b"
|
||||
s = append(s, "d")
|
||||
s = append(s, "e", "f")
|
||||
fmt.Println(s)
|
||||
fmt.Println(s[1])
|
||||
fmt.Println(len(s))
|
||||
fmt.Println(s[1:3])
|
||||
slice := []int{2, 3, 4}
|
||||
```
|
||||
|
||||
另见:[切片示例](https://gobyexample.com/slices)
|
||||
|
||||
### 常量(Constants)
|
||||
|
||||
```go
|
||||
const s string = "constant"
|
||||
const Phi = 1.618
|
||||
const n = 500000000
|
||||
const d = 3e20 / n
|
||||
fmt.Println(d)
|
||||
```
|
||||
|
||||
### 类型转换
|
||||
|
||||
```go
|
||||
i := 90
|
||||
f := float64(i)
|
||||
u := uint(i)
|
||||
// 将等于字符Z
|
||||
s := string(i)
|
||||
```
|
||||
|
||||
#### 如何获取int字符串?
|
||||
|
||||
```go
|
||||
i := 90
|
||||
// 需要导入“strconv”
|
||||
s := strconv.Itoa(i)
|
||||
fmt.Println(s) // Outputs: 90
|
||||
```
|
||||
|
||||
|
||||
Golang 字符串
|
||||
--------
|
||||
|
||||
### 字符串函数
|
||||
|
||||
```go
|
||||
package main
|
||||
import (
|
||||
"fmt"
|
||||
s "strings"
|
||||
)
|
||||
func main() {
|
||||
/* 需要将字符串导入为 s */
|
||||
fmt.Println(s.Contains("test", "e"))
|
||||
/* 内置 */
|
||||
fmt.Println(len("hello")) // => 5
|
||||
// 输出: 101
|
||||
fmt.Println("hello"[1])
|
||||
// 输出: e
|
||||
fmt.Println(string("hello"[1]))
|
||||
}
|
||||
```
|
||||
|
||||
### fmt.Printf
|
||||
<!--rehype:wrap-class=row-span-2 col-span-2-->
|
||||
|
||||
```go
|
||||
package main
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
type point struct {
|
||||
x, y int
|
||||
}
|
||||
func main() {
|
||||
p := point{1, 2}
|
||||
fmt.Printf("%v\n", p) // => {1 2}
|
||||
fmt.Printf("%+v\n", p) // => {x:1 y:2}
|
||||
fmt.Printf("%#v\n", p) // => main.point{x:1, y:2}
|
||||
fmt.Printf("%T\n", p) // => main.point
|
||||
fmt.Printf("%t\n", true) // => TRUE
|
||||
fmt.Printf("%d\n", 123) // => 123
|
||||
fmt.Printf("%b\n", 14) // => 1110
|
||||
fmt.Printf("%c\n", 33) // => !
|
||||
fmt.Printf("%x\n", 456) // => 1c8
|
||||
fmt.Printf("%f\n", 78.9) // => 78.9
|
||||
fmt.Printf("%e\n", 123400000.0) // => 1.23E+08
|
||||
fmt.Printf("%E\n", 123400000.0) // => 1.23E+08
|
||||
fmt.Printf("%s\n", "\"string\"") // => "string"
|
||||
fmt.Printf("%q\n", "\"string\"") // => "\"string\""
|
||||
fmt.Printf("%x\n", "hex this") // => 6.86578E+15
|
||||
fmt.Printf("%p\n", &p) // => 0xc00002c040
|
||||
fmt.Printf("|%6d|%6d|\n", 12, 345) // => | 12| 345|
|
||||
fmt.Printf("|%6.2f|%6.2f|\n", 1.2, 3.45) // => | 1.20| 3.45|
|
||||
fmt.Printf("|%-6.2f|%-6.2f|\n", 1.2, 3.45) // => |1.20 |3.45 |
|
||||
fmt.Printf("|%6s|%6s|\n", "foo", "b") // => | foo| b|
|
||||
fmt.Printf("|%-6s|%-6s|\n", "foo", "b") // => |foo |b |
|
||||
s := fmt.Sprintf("a %s", "string")
|
||||
fmt.Println(s)
|
||||
fmt.Fprintf(os.Stderr, "an %s\n", "error")
|
||||
}
|
||||
```
|
||||
|
||||
另见:[fmt](https://golang.org/pkg/fmt/)
|
||||
|
||||
### 函数实例
|
||||
|
||||
| 实例 | Result |
|
||||
|-------------------------------|-------------|
|
||||
| Contains("test", "es") | true |
|
||||
| Count("test", "t") | 2 |
|
||||
| HasPrefix("test", "te") | true |
|
||||
| HasSuffix("test", "st") | true |
|
||||
| Index("test", "e") | 1 |
|
||||
| Join([]string{"a", "b"}, "-") | a-b |
|
||||
| Repeat("a", 5) | aaaaa |
|
||||
| Replace("foo", "o", "0", -1) | f00 |
|
||||
| Replace("foo", "o", "0", 1) | f0o |
|
||||
| Split("a-b-c-d-e", "-") | [a b c d e] |
|
||||
| ToLower("TEST") | test |
|
||||
| ToUpper("test") | TEST |
|
||||
|
||||
Golang 条件控制
|
||||
--------
|
||||
|
||||
### 有条件的
|
||||
|
||||
```go
|
||||
a := 10
|
||||
if a > 20 {
|
||||
fmt.Println(">")
|
||||
} else if a < 20 {
|
||||
fmt.Println("<")
|
||||
} else {
|
||||
fmt.Println("=")
|
||||
}
|
||||
```
|
||||
|
||||
### if 中的语句
|
||||
|
||||
```go
|
||||
x := "hello go!"
|
||||
if count := len(x); count > 0 {
|
||||
fmt.Println("Yes")
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```go
|
||||
if _, err := doThing(); err != nil {
|
||||
fmt.Println("Uh oh")
|
||||
}
|
||||
```
|
||||
|
||||
### Switch
|
||||
|
||||
```go
|
||||
x := 42.0
|
||||
switch x {
|
||||
case 0:
|
||||
case 1, 2:
|
||||
fmt.Println("Multiple matches")
|
||||
case 42: // Don't "fall through".
|
||||
fmt.Println("reached")
|
||||
case 43:
|
||||
fmt.Println("Unreached")
|
||||
default:
|
||||
fmt.Println("Optional")
|
||||
}
|
||||
```
|
||||
|
||||
参见:[Switch](https://github.com/golang/go/wiki/Switch)
|
||||
|
||||
### For loop
|
||||
|
||||
```go
|
||||
for i := 0; i <= 10; i++ {
|
||||
fmt.Println("i: ", i)
|
||||
}
|
||||
```
|
||||
|
||||
### 对于 Range 循环
|
||||
|
||||
```go
|
||||
nums := []int{2, 3, 4}
|
||||
sum := 0
|
||||
for _, num := range nums {
|
||||
sum += num
|
||||
}
|
||||
fmt.Println("sum:", sum)
|
||||
```
|
||||
|
||||
### While 循环
|
||||
|
||||
```go
|
||||
i := 1
|
||||
for i <= 3 {
|
||||
fmt.Println(i)
|
||||
i++
|
||||
}
|
||||
```
|
||||
|
||||
### Continue 关键字
|
||||
|
||||
```go
|
||||
for i := 0; i <= 5; i++ {
|
||||
if i % 2 == 0 {
|
||||
continue
|
||||
}
|
||||
fmt.Println(i)
|
||||
}
|
||||
```
|
||||
|
||||
### Break 关键字
|
||||
|
||||
```go
|
||||
for {
|
||||
fmt.Println("loop")
|
||||
break
|
||||
}
|
||||
```
|
||||
|
||||
Golang 结构和映射
|
||||
--------
|
||||
|
||||
### 定义
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```go
|
||||
package main
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
type Vertex struct {
|
||||
X int
|
||||
Y int
|
||||
}
|
||||
func main() {
|
||||
v := Vertex{1, 2}
|
||||
v.X = 4
|
||||
fmt.Println(v.X, v.Y) // => 4 2
|
||||
}
|
||||
```
|
||||
|
||||
参见:[结构(Structs)](https://tour.golang.org/moretypes/2)
|
||||
|
||||
### 字面量
|
||||
|
||||
```go
|
||||
v := Vertex{X: 1, Y: 2}
|
||||
// Field names can be omitted
|
||||
v := Vertex{1, 2}
|
||||
// Y is implicit
|
||||
v := Vertex{X: 1}
|
||||
```
|
||||
|
||||
您还可以输入字段名
|
||||
|
||||
### 映射
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```go
|
||||
m := make(map[string]int)
|
||||
m["k1"] = 7
|
||||
m["k2"] = 13
|
||||
fmt.Println(m) // => map[k1:7 k2:13]
|
||||
v1 := m["k1"]
|
||||
fmt.Println(v1) // => 7
|
||||
fmt.Println(len(m)) // => 2
|
||||
delete(m, "k2")
|
||||
fmt.Println(m) // => map[k1:7]
|
||||
_, prs := m["k2"]
|
||||
fmt.Println(prs) // => false
|
||||
n := map[string]int{"foo": 1, "bar": 2}
|
||||
fmt.Println(n) // => map[bar:2 foo:1]
|
||||
```
|
||||
|
||||
### 指向结构的指针
|
||||
|
||||
```go
|
||||
v := &Vertex{1, 2}
|
||||
v.X = 2
|
||||
```
|
||||
|
||||
Doing `v.X` is the same as doing `(*v).X`, when `v` is a pointer.
|
||||
|
||||
Golang 函数
|
||||
--------
|
||||
|
||||
### 多个参数
|
||||
|
||||
```go
|
||||
func plus(a int, b int) int {
|
||||
return a + b
|
||||
}
|
||||
func plusPlus(a, b, c int) int {
|
||||
return a + b + c
|
||||
}
|
||||
fmt.Println(plus(1, 2))
|
||||
fmt.Println(plusPlus(1, 2, 3))
|
||||
```
|
||||
|
||||
### 多次返回
|
||||
|
||||
```go
|
||||
func vals() (int, int) {
|
||||
return 3, 7
|
||||
}
|
||||
a, b := vals()
|
||||
fmt.Println(a) // => 3
|
||||
fmt.Println(b) // => 7
|
||||
```
|
||||
|
||||
### 匿名函数
|
||||
|
||||
```go
|
||||
r1, r2 := func() (string, string) {
|
||||
x := []string{"hello", "world"}
|
||||
return x[0], x[1]
|
||||
}()
|
||||
// => hello world
|
||||
fmt.Println(r1, r2)
|
||||
```
|
||||
|
||||
### 命名返回
|
||||
|
||||
```go
|
||||
func split(sum int) (x, y int) {
|
||||
x = sum * 4 / 9
|
||||
y = sum - x
|
||||
return
|
||||
}
|
||||
x, y := split(17)
|
||||
fmt.Println(x) // => 7
|
||||
fmt.Println(y) // => 10
|
||||
```
|
||||
|
||||
### 变量函数
|
||||
|
||||
```go
|
||||
func sum(nums ...int) {
|
||||
fmt.Print(nums, " ")
|
||||
total := 0
|
||||
for _, num := range nums {
|
||||
total += num
|
||||
}
|
||||
fmt.Println(total)
|
||||
}
|
||||
sum(1, 2) //=> [1 2] 3
|
||||
sum(1, 2, 3) // => [1 2 3] 6
|
||||
nums := []int{1, 2, 3, 4}
|
||||
sum(nums...) // => [1 2 3 4] 10
|
||||
```
|
||||
|
||||
### 初始化函数
|
||||
|
||||
```go
|
||||
import --> const --> var --> init()
|
||||
```
|
||||
---
|
||||
|
||||
```go
|
||||
var num = setNumber()
|
||||
func setNumber() int {
|
||||
return 42
|
||||
}
|
||||
func init() {
|
||||
num = 0
|
||||
}
|
||||
func main() {
|
||||
fmt.Println(num) // => 0
|
||||
}
|
||||
```
|
||||
|
||||
### 作为值的函数
|
||||
|
||||
```go
|
||||
func main() {
|
||||
// 将函数赋给名称
|
||||
add := func(a, b int) int {
|
||||
return a + b
|
||||
}
|
||||
// 使用名称调用函数
|
||||
fmt.Println(add(3, 4)) // => 7
|
||||
}
|
||||
```
|
||||
|
||||
### 关闭 1
|
||||
|
||||
```go
|
||||
func scope() func() int{
|
||||
outer_var := 2
|
||||
foo := func() int {return outer_var}
|
||||
return foo
|
||||
}
|
||||
// Outpus: 2
|
||||
fmt.Println(scope()())
|
||||
```
|
||||
|
||||
### 关闭 2
|
||||
|
||||
```go
|
||||
func outer() (func() int, int) {
|
||||
outer_var := 2
|
||||
inner := func() int {
|
||||
outer_var += 99
|
||||
return outer_var
|
||||
}
|
||||
inner()
|
||||
return inner, outer_var
|
||||
}
|
||||
inner, val := outer()
|
||||
fmt.Println(inner()) // => 200
|
||||
fmt.Println(val) // => 101
|
||||
```
|
||||
|
||||
Golang 包(Packages)
|
||||
--------
|
||||
|
||||
### 导入
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```go
|
||||
import "fmt"
|
||||
import "math/rand"
|
||||
```
|
||||
|
||||
#### 等同于
|
||||
|
||||
```go
|
||||
import (
|
||||
"fmt" // 给 fmt.Println
|
||||
"math/rand" // 给 rand.Intn
|
||||
)
|
||||
```
|
||||
|
||||
另见:[导入](https://tour.golang.org/basics/1)
|
||||
|
||||
### 别名
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```go
|
||||
import r "math/rand"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```go
|
||||
import (
|
||||
"fmt"
|
||||
r "math/rand"
|
||||
)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```go
|
||||
r.Intn()
|
||||
```
|
||||
|
||||
### Packages
|
||||
|
||||
```go
|
||||
package main
|
||||
// 一个内部包只能被另一个包导入
|
||||
// 那是在以内部目录的父级为根的树内
|
||||
package internal
|
||||
```
|
||||
|
||||
另见:[内部包](https://go.dev/doc/go1.4#internalpackages)
|
||||
|
||||
### 导出名称
|
||||
|
||||
```go
|
||||
// 以大写字母开头
|
||||
func Hello () {
|
||||
···
|
||||
}
|
||||
```
|
||||
|
||||
另见:[导出的名称](https://tour.golang.org/basics/3)
|
||||
|
||||
Golang 并发
|
||||
--------
|
||||
|
||||
### 协程
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```go
|
||||
package main
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
func f(from string) {
|
||||
for i := 0; i < 3; i++ {
|
||||
fmt.Println(from, ":", i)
|
||||
}
|
||||
}
|
||||
func main() {
|
||||
f("direct")
|
||||
go f("goroutine")
|
||||
go func(msg string) {
|
||||
fmt.Println(msg)
|
||||
}("going")
|
||||
time.Sleep(time.Second)
|
||||
fmt.Println("done")
|
||||
}
|
||||
```
|
||||
|
||||
参见:[Goroutines](https://tour.golang.org/concurrency/1), [Channels](https://tour.golang.org/concurrency/2)
|
||||
|
||||
### WaitGroup
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
|
||||
```golang
|
||||
package main
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
func w(id int, wg *sync.WaitGroup) {
|
||||
defer wg.Done()
|
||||
fmt.Printf("%d starting\n", id)
|
||||
time.Sleep(time.Second)
|
||||
fmt.Printf("%d done\n", id)
|
||||
}
|
||||
func main() {
|
||||
var wg sync.WaitGroup
|
||||
for i := 1; i <= 5; i++ {
|
||||
wg.Add(1)
|
||||
go w(i, &wg)
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
||||
```
|
||||
|
||||
参见:[WaitGroup](https://golang.org/pkg/sync/#WaitGroup)
|
||||
|
||||
### Closing channels
|
||||
|
||||
```go
|
||||
ch <- 1
|
||||
ch <- 2
|
||||
ch <- 3
|
||||
close(ch) // 关闭频道
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```go
|
||||
// 迭代通道直到关闭
|
||||
for i := range ch {
|
||||
···
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```go
|
||||
// Closed if `ok == false`
|
||||
v, ok := <- ch
|
||||
```
|
||||
|
||||
参见:[范围和关闭](https://tour.golang.org/concurrency/4)
|
||||
|
||||
### 缓冲通道
|
||||
|
||||
```go
|
||||
ch := make(chan int, 2)
|
||||
ch <- 1
|
||||
ch <- 2
|
||||
ch <- 3
|
||||
// 致命错误:
|
||||
// 所有 goroutine 都处于休眠状态 - 死锁
|
||||
```
|
||||
|
||||
参见:[缓冲通道](https://tour.golang.org/concurrency/3)
|
||||
|
||||
Golang 错误控制
|
||||
--------
|
||||
|
||||
### 延迟函数
|
||||
|
||||
```go
|
||||
func main() {
|
||||
defer func() {
|
||||
fmt.Println("Done")
|
||||
}()
|
||||
fmt.Println("Working...")
|
||||
}
|
||||
```
|
||||
|
||||
### Lambda defer
|
||||
|
||||
```go
|
||||
func main() {
|
||||
var d = int64(0)
|
||||
defer func(d *int64) {
|
||||
fmt.Printf("& %v Unix Sec\n", *d)
|
||||
}(&d)
|
||||
fmt.Print("Done ")
|
||||
d = time.Now().Unix()
|
||||
}
|
||||
```
|
||||
|
||||
`defer` 函数使用当前值`d`,除非我们使用指针在 `main` 末尾获取最终值
|
||||
|
||||
### Defer
|
||||
|
||||
```go
|
||||
func main() {
|
||||
defer fmt.Println("Done")
|
||||
fmt.Println("Working...")
|
||||
}
|
||||
```
|
||||
|
||||
参见:[Defer, panic and recover](https://blog.golang.org/defer-panic-and-recover)
|
||||
|
||||
Golang 方法(Methods)
|
||||
--------
|
||||
<!--rehype:body-class=cols-2-->
|
||||
|
||||
### 接收器
|
||||
|
||||
```go
|
||||
type Vertex struct {
|
||||
X, Y float64
|
||||
}
|
||||
|
||||
func (v Vertex) Abs() float64 {
|
||||
return math.Sqrt(v.X * v.X + v.Y * v.Y)
|
||||
}
|
||||
|
||||
v := Vertex{1, 2}
|
||||
v.Abs()
|
||||
```
|
||||
|
||||
参见:[Methods](https://tour.golang.org/methods/1)
|
||||
|
||||
### Mutation
|
||||
|
||||
```go
|
||||
func (v *Vertex) Scale(f float64) {
|
||||
v.X = v.X * f
|
||||
v.Y = v.Y * f
|
||||
}
|
||||
|
||||
v := Vertex{6, 12}
|
||||
v.Scale(0.5)
|
||||
// `v` 已更新
|
||||
```
|
||||
|
||||
参见:[指针接收器](https://tour.golang.org/methods/4)
|
||||
|
||||
Golang 接口(Interfaces)
|
||||
--------
|
||||
<!--rehype:body-class=cols-2-->
|
||||
|
||||
### 基本接口(Interfaces)
|
||||
|
||||
```go
|
||||
type Shape interface {
|
||||
Area() float64
|
||||
Perimeter() float64
|
||||
}
|
||||
```
|
||||
|
||||
### 结构(Struct)
|
||||
|
||||
```go
|
||||
type Rectangle struct {
|
||||
Length, Width float64
|
||||
}
|
||||
```
|
||||
|
||||
结构 `Rectangle` 通过实现其所有方法隐式实现接口 `Shape`
|
||||
|
||||
### 方法(Methods)
|
||||
|
||||
```go
|
||||
func (r Rectangle) Area() float64 {
|
||||
return r.Length * r.Width
|
||||
}
|
||||
func (r Rectangle) Perimeter() float64 {
|
||||
return 2 * (r.Length + r.Width)
|
||||
}
|
||||
```
|
||||
|
||||
在 `Shape` 中定义的方法在`Rectangle`中实现
|
||||
|
||||
### 接口实例
|
||||
|
||||
```go
|
||||
func main() {
|
||||
var r Shape = Rectangle{Length: 3, Width: 4}
|
||||
fmt.Printf("Type of r: %T, Area: %v, Perimeter: %v.", r, r.Area(), r.Perimeter())
|
||||
}
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
杂项
|
||||
-------------
|
||||
|
||||
### 关键字(Keywords)
|
||||
- break
|
||||
- default
|
||||
- func
|
||||
- interface
|
||||
- select
|
||||
- case
|
||||
- defer
|
||||
- go
|
||||
- map
|
||||
- struct
|
||||
- chan
|
||||
- else
|
||||
- goto
|
||||
- package
|
||||
- switch
|
||||
- const
|
||||
- fallthrough
|
||||
- if
|
||||
- range
|
||||
- type
|
||||
- continue
|
||||
- for
|
||||
- import
|
||||
- return
|
||||
- var
|
||||
<!--rehype:className=cols-3 style-none-->
|
||||
|
||||
### 运算符和标点符号
|
||||
|
||||
| | | | | | | | | |
|
||||
|---|----|-----|-----|------|----|-----|---|---|
|
||||
| `+` | & | += | &= | && | == | != | ( | ) |
|
||||
| `-` | \| | -= | \|= | \|\| | < | <= | [ | ] |
|
||||
| `*` | ^ | *= | ^= | <- | > | >= | { | } |
|
||||
| `/` | << | /= | <<= | ++ | = | := | , | ; |
|
||||
| `%` | >> | %= | >>= | -- | ! | ... | . | : |
|
||||
| | &^ | &^= | | | | | | |
|
||||
|
||||
另见
|
||||
--------
|
||||
- [Devhints](https://devhints.io/go) _(devhints.io)_
|
||||
- [A tour of Go](https://tour.golang.org/welcome/1) _(tour.golang.org)_
|
||||
- [Golang wiki](https://github.com/golang/go/wiki/) _(github.com)_
|
||||
- [Effective Go](https://golang.org/doc/effective_go.html) _(golang.org)_
|
||||
- [Go by Example](https://gobyexample.com/) _(gobyexample.com)_
|
||||
- [Awesome Go](https://awesome-go.com/) _(awesome-go.com)_
|
||||
- [JustForFunc Youtube](https://www.youtube.com/channel/UC_BzFbxG2za3bp5NRRRXJSw) _(youtube.com)_
|
||||
- [Style Guide](https://github.com/golang/go/wiki/CodeReviewComments) _(github.com)_
|
@ -386,18 +386,18 @@ sum(3, 6); // 9
|
||||
### 匿名函数
|
||||
|
||||
```javascript
|
||||
// Named function
|
||||
// 命名函数
|
||||
function rocketToMars() {
|
||||
return 'BOOM!';
|
||||
}
|
||||
// Anonymous function
|
||||
// 匿名函数
|
||||
const rocketToMars = function() {
|
||||
return 'BOOM!';
|
||||
}
|
||||
```
|
||||
|
||||
### 箭头函数 (ES6)
|
||||
<!--rehype:wrap-class=row-span-2-->
|
||||
<!--rehype:wrap-class=row-span-3-->
|
||||
|
||||
#### 有两个参数
|
||||
|
||||
@ -590,6 +590,48 @@ for (let j = 0; j < 3; j++) {
|
||||
JavaScript Arrays
|
||||
----
|
||||
|
||||
### 方法
|
||||
<!--rehype:wrap-class=row-span-6-->
|
||||
|
||||
:- | :-
|
||||
:- | :-
|
||||
`Array.from()` | 类似数组对象创建一个新的 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/from)
|
||||
`Array.isArray()` | 值是否是一个 Array [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray)
|
||||
`Array.of()` | 创建一个新数组示例 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/of)
|
||||
`.at()` | 返回值索引对应的元素 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/at)
|
||||
`.concat()` | 合并两个或多个数组 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/concat)
|
||||
`.copyWithin()` | 浅复制替换某个位置 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin)
|
||||
`.entries()` | 新的 Array Iterator 对象 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/entries)
|
||||
`.every()` | 是否能通过回调函数的测试 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/every)
|
||||
`.fill()` | 固定值填充一个数组中 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/fill)
|
||||
`.filter()` | 返回过滤后的数组 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)
|
||||
`.find()` | 第一个元素的值 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/find)
|
||||
`.findIndex()` | 第一个元素的索引 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex)
|
||||
`.findLast()` | 最后一个元素的值 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast)
|
||||
`.findLastIndex()` | 最后一个元素的索引 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/findLastIndex)
|
||||
`.flat()` | 扁平化嵌套数组 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/flat)
|
||||
`.flatMap()` | 与 flat 相同 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap)
|
||||
`.forEach()` | 升序循环执行 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)
|
||||
`.includes()` | 是否包含一个指定的值 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/includes)
|
||||
`.indexOf()` | 找到给定元素的第一个索引 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf)
|
||||
`.join()` | 数组链接成一个字符串 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/join)
|
||||
`.keys()` | 每个索引键 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/keys)
|
||||
`.lastIndexOf()` | 给定元素的最后一个索引 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf)
|
||||
`.map()` | 循环返回一个新数组 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
|
||||
`.pop()` | `删除`最后一个元素 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/pop)
|
||||
`.push()` | 元素`添加`到数组的末尾 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/push)
|
||||
`.reduce()` | 循环函数传递当前和上一个值 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce)
|
||||
`.reduceRight()` | 类似 `reduce` 从右往左循环 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/ReduceRight)
|
||||
`.reverse()` | 数组元素的位置颠倒 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse)
|
||||
`.shift()` | `删除`第一个元素 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/shift)
|
||||
`.slice()` | `提取`元素 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/slice)
|
||||
`.some()` | 至少有一个通过测试函数 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/some)
|
||||
`.sort()` | 元素进行排序 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)
|
||||
`.splice()` | `删除`或`替换`或`添加`元素 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/splice)
|
||||
`.toLocaleString()` | 字符串表示数组中的元素 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/toLocaleString)
|
||||
`.toString()` | 返回字符串 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/toString)
|
||||
`.unshift()` | 元素`添加`到数组的`开头` [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift)
|
||||
`.values()` | 返回新的 ArrayIterator 对象 [#](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/values)
|
||||
|
||||
### 数组
|
||||
|
||||
@ -652,24 +694,24 @@ console.log(fruits); // ["apple", "dew"]
|
||||
### 方法 .shift()
|
||||
|
||||
```javascript
|
||||
let cats = ['Bob', 'Willy', 'Mini'];
|
||||
cats.shift(); // ['Willy', 'Mini']
|
||||
const array1 = [1, 2, 3];
|
||||
const firstElement = array1.shift();
|
||||
console.log(array1); // 输出: Array [2, 3]
|
||||
console.log(firstElement); // 输出: 1
|
||||
```
|
||||
|
||||
**从头删除**一个项目并返回已删除的项目。
|
||||
|
||||
### 方法 .unshift()
|
||||
### 方法 .some()
|
||||
|
||||
```javascript
|
||||
let cats = ['Bob'];
|
||||
// => ['Willy', 'Bob']
|
||||
cats.unshift('Willy');
|
||||
// => ['Puff', 'George', 'Willy', 'Bob']
|
||||
cats.unshift('Puff', 'George');
|
||||
```js
|
||||
const array = [1, 2, 3, 4, 5];
|
||||
// 检查元素是否为偶数
|
||||
const even = (element) => element % 2 === 0;
|
||||
console.log(array.some(even));
|
||||
// 预期输出: true
|
||||
```
|
||||
|
||||
将项目**添加到开头**并返回新的数组长度。
|
||||
|
||||
### 方法 .concat()
|
||||
|
||||
```javascript
|
||||
@ -685,6 +727,45 @@ numbers.concat(newFirstNumber)
|
||||
|
||||
如果你想避免改变你的原始数组,你可以使用 concat。
|
||||
|
||||
|
||||
### 方法 .splice()
|
||||
|
||||
```javascript
|
||||
const months = ['Jan', 'March'];
|
||||
months.splice(1, 0, 'Feb');
|
||||
// 在索引 1 处插入
|
||||
console.log(months);
|
||||
// 预期输出: Array ["Jan", "Feb", "March"]
|
||||
|
||||
months.splice(2, 1, 'May');
|
||||
// 替换索引 2 处的 1 个元素
|
||||
console.log(months);
|
||||
// 预期输出: Array ["Jan", "Feb", "May"]
|
||||
```
|
||||
|
||||
### 方法 .unshift()
|
||||
|
||||
```javascript
|
||||
let cats = ['Bob'];
|
||||
// => ['Willy', 'Bob']
|
||||
cats.unshift('Willy');
|
||||
// => ['Puff', 'George', 'Willy', 'Bob']
|
||||
cats.unshift('Puff', 'George');
|
||||
```
|
||||
|
||||
将项目**添加到开头**并返回新的数组长度。
|
||||
|
||||
### 方法 .filter()
|
||||
|
||||
```javascript
|
||||
const words = ['js', 'java', 'golang'];
|
||||
const result = words.filter(word => {
|
||||
return word.length > 3
|
||||
});
|
||||
console.log(result);
|
||||
// 预期输出: Array ["java", "golang"]
|
||||
```
|
||||
|
||||
JavaScript 循环
|
||||
----
|
||||
|
||||
@ -998,19 +1079,16 @@ console.log(age); // '22'
|
||||
```javascript
|
||||
const person = {
|
||||
firstName: "Matilda",
|
||||
age: 27,
|
||||
hobby: "knitting",
|
||||
goal: "learning JavaScript"
|
||||
};
|
||||
delete person.hobby; // or delete person[hobby];
|
||||
delete person.hobby; // 或 delete person['hobby'];
|
||||
console.log(person);
|
||||
/*
|
||||
{
|
||||
firstName: "Matilda"
|
||||
age: 27
|
||||
goal: "learning JavaScript"
|
||||
}
|
||||
*/
|
||||
} */
|
||||
```
|
||||
|
||||
### 对象作为参数
|
||||
|
@ -215,6 +215,20 @@ const school = <div>学校</div>;
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
|
||||
### 隐藏卡片标题
|
||||
<!--rehype:style=display:none;&wrap-style=padding-top: 0;-->
|
||||
|
||||
```
|
||||
隐藏卡片标题,在 H3 标题下面添加注释样式
|
||||
```
|
||||
|
||||
```markdown
|
||||
### 隐藏卡片标题
|
||||
<!--rehype:style=display:none;&wrap-style=padding-top: 0;-->
|
||||
```
|
||||
<!--rehype:className=wrap-text -->
|
||||
|
||||
|
||||
布局
|
||||
---
|
||||
|
||||
@ -273,7 +287,6 @@ H2 部分
|
||||
|
||||
放在 `## H2 部分` 下面的注释配置,与 `<!--rehype:body-class=cols-2-->` 相同,设置 2 栏布局。
|
||||
|
||||
|
||||
### H3 部分
|
||||
|
||||
```markdown
|
||||
|
1537
docs/swift.md
Normal file
1537
docs/swift.md
Normal file
File diff suppressed because it is too large
Load Diff
191
docs/webstorm.md
Normal file
191
docs/webstorm.md
Normal file
@ -0,0 +1,191 @@
|
||||
WebStorm 备忘清单
|
||||
===
|
||||
|
||||
此快速参考备忘单列出了在 Windows/Linux 或 Mac 上运行的 [WebStorm](https://www.jetbrains.com/webstorm/) 的默认键盘快捷键
|
||||
|
||||
Webstorm Windows & Linux 键盘映射
|
||||
--------
|
||||
|
||||
### 编辑
|
||||
<!--rehype:wrap-class=row-span-5-->
|
||||
|
||||
快捷键 | 说明
|
||||
:-|:-
|
||||
`Ctrl` `Space`| 基本代码完成
|
||||
`Alt` `Enter`| 显示意图操作,快速修复
|
||||
`Ctrl` `P`| 参数信息
|
||||
`Ctrl` `Q`| 快速文档查找
|
||||
`Ctrl` `mouse over`| 简要信息
|
||||
`Ctrl` `F1`| 插入符号处的错误或警告
|
||||
`Alt` `Insert`| 生成代码...
|
||||
`Ctrl` `Alt` `T`| 环绕...
|
||||
`Ctrl` `J`| 插入实时模板
|
||||
`Ctrl` `/`| 用行注释/取消注释
|
||||
`Ctrl` `Shift` `/`| 用块评论/取消评论
|
||||
`Ctrl` `W`| 选择连续增加的代码块
|
||||
`Ctrl` `Shift` `W`| 将当前选择减少到以前的状态
|
||||
`Alt+Q`| 上下文信息
|
||||
`Ctrl` `Alt` `L`| 重新格式化代码
|
||||
`Ctrl` `Alt` `I`| 自动缩进行
|
||||
`Tab`| 缩进选定的行
|
||||
`Shift` `Tab`| 取消缩进选定的行
|
||||
`Ctrl` `Shift` `V`| 从最近的缓冲区粘贴...
|
||||
`Ctrl` `D`| 复制当前行或选定块
|
||||
`Ctrl` `Y`| 删除插入符号处的行
|
||||
`Alt` `Shift` `Up`| 向上移动队列
|
||||
`Alt` `Shift` `Down`| 下移线
|
||||
`Ctrl` `Shift` `J`| 连接线
|
||||
`Ctrl` `Enter`| 分割线
|
||||
`Shift` `Enter`| 开始新行
|
||||
`Ctrl` `Shift` `U`| 在插入符号或选定块中切换单词的大小写
|
||||
`Ctrl` `Shift` `]`| 选择直到代码块结束
|
||||
`Ctrl` `Shift` `[`| 选择直到代码块开始
|
||||
`Ctrl` `Delete`| 删除到词尾
|
||||
`Ctrl` `Backspace`| 删除到单词开头
|
||||
`Ctrl` `+`| 展开代码块
|
||||
`Ctrl` `-`| 折叠代码块
|
||||
`Ctrl` `Shift` `+`| 展开全部
|
||||
`Ctrl` `Shift` `-`| 全部收缩
|
||||
`Ctrl` `F4`| 关闭活动编辑器选项卡
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 一般的
|
||||
|
||||
快捷键 | 说明
|
||||
:-|:-
|
||||
`Double Shift`| 到处搜索
|
||||
`Ctrl` `Shift` `A`| 寻找行动
|
||||
`Alt` `0...9`| 打开相应的工具窗口
|
||||
`Ctrl` `Shift` `F12`| 切换最大化编辑器
|
||||
`Alt` `Shift` `F`| 添加到收藏夹
|
||||
`Alt` `Shift` `I`| 检查当前文件
|
||||
`Ctrl` <kbd>\`</kbd>| 快速切换电流方案
|
||||
`Ctrl` `Alt` `S`| 打开设置对话框
|
||||
`Ctrl` `Tab`| 在工具和选项卡之间切换
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 导航
|
||||
<!--rehype:wrap-class=row-span-4-->
|
||||
|
||||
快捷键 | 说明
|
||||
:-|:-
|
||||
`Ctrl` `B` _\|_ `Ctrl + Click` | 前往 declaration
|
||||
`Ctrl` `N` | 前往 class
|
||||
`Ctrl` `Shift` `N` | 转到文件
|
||||
`Ctrl` `Alt` `Shift` `N` | 转到符号
|
||||
`Alt` `Right` | 转到下一个编辑器选项卡
|
||||
`Alt` `Left` | 转到上一个编辑器选项卡
|
||||
`F12` | 返回上一个工具窗口
|
||||
`Esc` | 转到编辑器
|
||||
`Ctrl` `G` | 去行
|
||||
`Ctrl` `E` | 最近的文件弹出
|
||||
`Ctrl` `Alt` `Right` | 向前导航
|
||||
`Ctrl` `Alt` `Left` | 向后导航
|
||||
`Ctrl` `Shift` `Backspace` | 导航到最后一个编辑位置
|
||||
`Alt` `F1` | 在任何视图中选择当前文件或符号
|
||||
`Ctrl` `Alt` `B` | 转到实施
|
||||
`Ctrl` `Shift` `I` | 打开快速定义查找
|
||||
`Ctrl` `Shift` `B` | 转到类型声明
|
||||
`Ctrl` `U` | 转到超方法/超类
|
||||
`Alt` `Up` | 转到上一个方法
|
||||
`Alt` `Down` | 转到下一个方法
|
||||
`Ctrl` `]` _/_ `[` | 移动到代码块结束/开始
|
||||
`Cltrl` `Shift` `M` | 将插入符号移动到匹配的大括号
|
||||
`Ctrl` `F12` | 文件结构弹出
|
||||
`Ctrl` `H` | 类型层次结构
|
||||
`Ctrl` `Alt` `H` | 调用层次结构
|
||||
`F2` _/_ `Shift` `F2` | 下/上一个突出显示的错误
|
||||
`F4` _/_ `Ctrl` `Enter` | 跳转到源
|
||||
`Alt` `Home` | 跳转到导航栏
|
||||
`F11` | 切换书签
|
||||
`Ctrl` `Shift` `F11` | 使用助记符切换书签
|
||||
`Ctrl` `0...9` | 转到编号的书签
|
||||
`Shift` `F11` | 显示书签
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 多个插入符号和选择
|
||||
|
||||
快捷键 | 说明
|
||||
:-|:-
|
||||
`Alt` `Click`| 添加或删除插入符号
|
||||
`Shift` `Ctrl + Alt-J`| 选择所有出现
|
||||
`Alt` `J`| 选择下一个出现
|
||||
`Alt` `Shift` `J`| 取消选择事件
|
||||
`Esc`| 取消选择所有出现或插入符号
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 调试
|
||||
|
||||
快捷键 | 说明
|
||||
:-|:-
|
||||
`F8`| 跨过去
|
||||
`F7`| 踏入
|
||||
`Shift` `F7`| 智能步入
|
||||
`Shift` `F8`| 走出去
|
||||
`Alt` `F9`| 运行到光标
|
||||
`Alt` `F8`| 评估表达式
|
||||
`F9`| 简历计划
|
||||
`Ctrl` `F8`| 切换断点
|
||||
`Ctrl` `Shift` `F8`| 查看断点
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 运行
|
||||
|
||||
快捷键 | 说明
|
||||
:-|:-
|
||||
`Alt` `Shift` `F10`| 选择配置并运行
|
||||
`Alt` `Shift` `F9`| 选择配置和调试
|
||||
`Shift` `F10`| 运行
|
||||
`Shift` `F9`| 调试
|
||||
`Ctrl` `Shift` `F10`| 从编辑器运行上下文配置
|
||||
`Alt` `Shift` `R`| 重新运行测试
|
||||
`Alt` `F11`| 运行 Gulp/Grunt/npm 任务
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 使用搜索
|
||||
|
||||
快捷键 | 说明
|
||||
:-|:-
|
||||
`Alt` `F7`| 查找用法
|
||||
`Ctrl` `F7`| 在文件中查找用法
|
||||
`Ctrl` `Shift` `F7`| 突出显示文件中的用法
|
||||
`Ctrl` `Alt` `F7`| 显示用法
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### VCS/本地历史
|
||||
|
||||
快捷键 | 说明
|
||||
:-|:-
|
||||
`Alt` <kbd>\`</kbd>| VCS 快速弹出窗口
|
||||
`Ctrl` `K`| 将项目提交到 VCS
|
||||
`Ctrl` `T`| 从 VCS 更新项目
|
||||
`Alt` `Shift` `C`| 查看最近的更改
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 搜索/替换
|
||||
|
||||
快捷键 | 说明
|
||||
:-|:-
|
||||
`Ctrl` `F`| 寻找
|
||||
`F3`| 找下一个
|
||||
`Shift` `F3`| 查找上一个
|
||||
`Ctrl` `Shift` `F`| 在路径中查找
|
||||
`Ctrl` `R`| 代替
|
||||
`Ctrl` `Shift` `R`| 在路径中替换
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 重构
|
||||
|
||||
快捷键 | 说明
|
||||
:-|:-
|
||||
`Ctrl` `Alt` `Shift +T`| 重构这个
|
||||
`F5` _/_ `F6`| 复制/移动
|
||||
`Alt` `Delete`| 安全删除
|
||||
`Shift` `F6`| 改名
|
||||
`Ctrl` `F6`| 更改函数签名
|
||||
`Ctrl` `Alt` `N`| 内联变量
|
||||
`Ctrl` `Alt` `M`| 提取方法
|
||||
`Ctrl` `Alt` `V`| 提取变量
|
||||
`Ctrl` `Alt` `C`| 提取常数
|
||||
`Ctrl` `Alt` `P`| 提取参数
|
||||
<!--rehype:className=shortcuts-->
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wcj/reference",
|
||||
"version": "1.3.0",
|
||||
"version": "1.5.0",
|
||||
"description": "为开发人员分享快速参考备忘单(主要是方便自己)。",
|
||||
"author": "jaywcjlove",
|
||||
"license": "MIT",
|
||||
|
1
scripts/assets/golang.svg
Normal file
1
scripts/assets/golang.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 120 120"><path fill="currentColor" d="M60,0 C93.137085,-6.08718376e-15 120,26.862915 120,60 C120,93.137085 93.137085,120 60,120 C26.862915,120 4.05812251e-15,93.137085 0,60 C-4.05812251e-15,26.862915 26.862915,6.08718376e-15 60,0 Z M66.9375,44.8284375 C63.140625,42.2503125 58.921875,41.7346875 54.515625,42.5315625 C49.125,43.5159375 44.71875,46.2815625 41.390625,50.6409375 C38.296875,54.6721875 36.796875,59.2659375 37.40625,64.3753125 C37.921875,68.6878125 39.890625,72.1565625 43.359375,74.7815625 C47.109375,77.5940625 51.375,78.4846875 55.96875,77.8753125 C61.546875,77.1253125 65.953125,74.3596875 69.328125,69.9065625 C70.0941964,68.8967411 70.7503316,67.8351849 71.2989326,66.7266981 C72.0855742,69.5828677 73.6756442,72.0358799 75.984375,74.0315625 C79.265625,76.8440625 83.15625,78.0628125 87.421875,78.1565625 C88.640625,78.0159375 89.90625,77.9690625 91.171875,77.7346875 C95.53125,76.8440625 99.328125,74.8753125 102.421875,71.7346875 C106.78125,67.3284375 108.609375,62.1721875 107.8125,55.8440625 C107.203125,51.3440625 104.90625,47.9221875 101.203125,45.3909375 C97.125,42.6253125 92.625,42.1565625 87.84375,43.0003125 C82.265625,43.9846875 78.140625,46.3284375 74.71875,50.8284375 C73.2524636,52.7475477 72.1531891,54.7757695 71.4756823,56.9222289 L56.390625,56.9221875 C55.6875,56.9221875 55.359375,57.3909375 55.21875,57.6721875 C54.5625,58.8909375 53.4375,61.3284375 52.828125,62.7815625 C52.5,63.5784375 52.734375,64.1878125 53.71875,64.1878125 L62.765625,64.1878125 C62.296875,64.8440625 61.921875,65.4065625 61.5,65.9221875 C59.390625,68.3128125 56.71875,69.4378125 53.53125,69.0159375 C49.828125,68.5003125 47.25,65.4065625 47.203125,61.6565625 C47.15625,57.8596875 48.796875,54.8128125 51.984375,52.7503125 C54.65625,51.0159375 57.515625,50.5940625 60.46875,52.0471875 C61.453125,52.5159375 61.96875,53.0315625 62.671875,53.8284375 C63.28125,54.5315625 63.328125,54.4846875 64.03125,54.2971875 C66.9375,53.5471875 68.953125,52.9846875 71.90625,52.2346875 C72.46875,52.0940625 72.65625,51.8596875 72.375,51.4378125 C71.203125,48.7190625 69.421875,46.4690625 66.9375,44.8284375 Z M88.875,51.4378125 C93.328125,50.4065625 97.59375,53.0315625 98.4375,57.6721875 C98.53125,58.1409375 98.53125,58.6096875 98.578125,59.2190625 C98.34375,63.2503125 96.328125,66.2503125 92.625,68.1721875 C90.140625,69.4378125 87.5625,69.5784375 84.984375,68.4534375 C81.609375,66.9534375 79.828125,63.2503125 80.671875,59.5940625 C81.703125,55.1878125 84.515625,52.4221875 88.875,51.4378125 Z M33.609375,59.9690625 L24.234375,59.9690625 C24.046875,59.9690625 23.859375,60.1096875 23.765625,60.2503125 L23.109375,61.4221875 C23.015625,61.5628125 23.0625,61.7034375 23.25,61.7034375 L33.46875,61.7503125 C33.609375,61.7503125 33.796875,61.6096875 33.796875,61.4221875 L33.890625,60.2971875 C33.890625,60.1096875 33.796875,59.9690625 33.609375,59.9690625 Z M34.640625,55.6565625 L13.265625,55.6565625 C13.078125,55.6565625 12.84375,55.7503125 12.75,55.8909375 L11.765625,57.1565625 C11.671875,57.2971875 11.71875,57.3909375 11.90625,57.3909375 L34.078125,57.3440625 C34.265625,57.3440625 34.453125,57.2503125 34.5,57.0628125 L34.875,55.9378125 C34.921875,55.7971875 34.828125,55.6565625 34.640625,55.6565625 Z M37.078125,51.3440625 L20.34375,51.3440625 C20.15625,51.3440625 19.921875,51.4378125 19.828125,51.5784375 L18.84375,52.8440625 C18.75,52.9846875 18.796875,53.0784375 18.984375,53.0784375 L35.953125,53.1253125 C36.09375,53.1253125 36.328125,52.9846875 36.421875,52.8440625 L37.21875,51.6253125 C37.3125,51.4846875 37.265625,51.3440625 37.078125,51.3440625 Z"/></svg>
|
After Width: | Height: | Size: 3.6 KiB |
3
scripts/assets/swift.svg
Normal file
3
scripts/assets/swift.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="1em" height="1em" viewBox="0 0 150 150">
|
||||
<path d="M149.996652,41.5504118 C149.996652,40.0404009 149.969865,38.5370862 149.929684,37.0237271 C149.889479,33.7232863 149.600703,30.4305622 149.065807,27.1735006 C148.507382,23.9127729 147.466929,20.7532587 145.978615,17.7987099 C142.956518,11.8649909 138.1316,7.04156844 132.19675,4.0211156 C129.242865,2.53082012 126.082821,1.49033249 122.821331,0.934130935 C119.563242,0.396319522 116.269046,0.106431705 112.967097,0.066962791 C111.456985,0.0267851164 109.953569,0.0100444187 108.440109,0 L41.5565427,0 C40.0464306,0 38.5430153,0.0267851164 37.0295549,0.066962791 C36.2092058,0.0903997679 35.3855083,0.117184884 34.5618108,0.157362559 C32.0854761,0.256798914 29.6181641,0.516263128 27.1753203,0.934130935 C24.7417426,1.35877149 22.3608012,2.04348485 20.0734408,2.97649606 C19.3010849,3.30014955 18.5410063,3.64835606 17.7932051,4.0211156 C15.5863952,5.15055914 13.519722,6.53499141 11.6355641,8.14602353 C11.0060717,8.68507399 10.4000179,9.2442133 9.81740256,9.8200933 C7.47219368,12.1591083 5.51152349,14.8541431 4.00799143,17.8054061 C2.51889323,20.7596305 1.47840127,23.9192644 0.920800036,27.1801969 C0.390726031,30.4353902 0.106428217,33.7258611 0.0703156391,37.0237271 C0.0267869101,38.5337381 0.0100450913,40.0370527 0,41.5504118 L0,108.456284 C0,109.966295 0.0267869101,111.46961 0.0703156391,112.979621 C0.110229315,116.280076 0.39900748,119.572822 0.934193491,122.829848 C1.49106583,126.090961 2.53159273,129.250701 4.02138488,132.204638 C7.04518753,138.133686 11.8652306,142.95575 17.7932051,145.982233 C20.747852,147.46998 23.9076759,148.509267 27.1686236,149.065869 C30.4267126,149.60368 33.7209094,149.893568 37.0228582,149.933037 C38.5296219,149.973215 40.0363856,149.989956 41.549846,150 L108.446806,150 C109.956918,150 111.460333,149.973215 112.973793,149.933037 C116.276759,149.891708 119.571929,149.601833 122.831376,149.065869 C126.092204,148.508782 129.251957,147.469519 132.206795,145.982233 C138.136507,142.956565 142.95707,138.132809 145.978615,132.20129 C147.468407,129.247353 148.508934,126.087613 149.065807,122.826499 C149.603754,119.569766 149.893662,116.276895 149.933033,112.976273 C149.973213,111.46961 149.989955,109.962947 150,108.452936 L150,46.9241758 C149.996652,45.1329211 149.996652,43.3416665 149.996652,41.5504118 Z M126.598286,122.240575 C119.901558,109.206268 107.4356,112.440571 101.046922,115.721747 C100.471003,116.056561 99.8816911,116.391375 99.2890308,116.726189 L99.1483995,116.809893 C85.9223626,123.840986 68.1659896,124.356599 50.312514,116.682663 C35.779112,110.381458 23.4900254,99.8344883 15.0575919,86.4255262 C19.1601349,89.4606647 23.5534617,92.08168 28.1731327,94.2501283 C47.0445109,103.089217 66.0096433,102.449722 79.4030984,94.2501283 C60.3174249,79.5685364 44.3792134,60.4339189 32.161034,44.9588179 C29.8334165,42.2434232 27.7304143,39.3433109 25.8728068,36.2871364 C40.5051565,49.6796946 63.6088665,66.4940515 71.9061119,71.1479654 C54.3037636,52.5691391 38.7941426,29.6511239 39.5207375,30.3877146 C67.2418412,58.3178947 92.819992,74.1110689 92.819992,74.1110689 C93.7843207,74.640075 94.4941738,75.0652887 95.0734408,75.4503248 C95.6092689,74.0835027 96.0741937,72.6899392 96.4663601,71.2751948 C100.892897,55.0936363 95.9105317,36.5951653 84.6432876,21.3209527 C110.355373,36.7491797 125.553596,66.075534 119.32564,90.8785518 C119.178312,91.45778 119.007545,92.0169193 118.843475,92.5827548 C131.741372,108.452936 128.232287,125.451441 126.588241,122.243923 L126.598286,122.240575 Z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 3.5 KiB |
3
scripts/assets/webstorm.svg
Normal file
3
scripts/assets/webstorm.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 14 14" height="1em" width="1em">
|
||||
<path d="m13 5.065-.96-2.378-.6-1.44L8.65 1l-.435.42-.555-.21-1.763.938L4 1.022l-3 1.23 1.612 9.586L9.25 13l.42-2.13.075-.045h-6.57v-7.65h7.65v7.013L13 8.898l-1.313-2.46m-8.362 4.238h7.35V3.325h-7.35v7.35zm3.45-.863H3.963V9.34h2.812v.473zm2.063-5.648c.412 0 .824.15 1.14.398l-.353.525a1.383 1.383 0 0 0-.787-.3c-.248 0-.398.112-.398.284 0 .202.136.278.66.405.615.173.975.398.975.938 0 .622-.473.975-1.125.975a2.16 2.16 0 0 1-1.312-.502l.389-.489c.285.225.563.375.923.375.278 0 .45-.112.45-.3 0-.173-.114-.262-.615-.397-.623-.165-1.02-.338-1.02-.952v-.022c0-.563.45-.938 1.073-.938Zm-4.313.06.472 1.8.525-1.8h.525l.526 1.8.464-1.8h.736l-.9 3.112h-.586l-.502-1.8-.51 1.8h-.577l-.9-3.112h.728z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 828 B |
@ -11,6 +11,7 @@ import { tooltips } from './utils/tooltips.mjs';
|
||||
import { homeCardIcons } from './utils/homeCardIcons.mjs';
|
||||
import { getTocsTree } from './utils/getTocsTree.mjs';
|
||||
import { rehypeTitle } from './utils/rehypeTitle.mjs';
|
||||
import { anchorPoint } from './utils/anchorPoint.mjs';
|
||||
|
||||
const favicon = `data:image/svg+xml,%3Csvg%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20height%3D%221em%22%20width%3D%221em%22%3E%20%3Cpath%20d%3D%22m21.66%2010.44-.98%204.18c-.84%203.61-2.5%205.07-5.62%204.77-.5-.04-1.04-.13-1.62-.27l-1.68-.4c-4.17-.99-5.46-3.05-4.48-7.23l.98-4.19c.2-.85.44-1.59.74-2.2%201.17-2.42%203.16-3.07%206.5-2.28l1.67.39c4.19.98%205.47%203.05%204.49%207.23Z%22%20fill%3D%22%23c9d1d9%22%2F%3E%20%3Cpath%20d%3D%22M15.06%2019.39c-.62.42-1.4.77-2.35%201.08l-1.58.52c-3.97%201.28-6.06.21-7.35-3.76L2.5%2013.28c-1.28-3.97-.22-6.07%203.75-7.35l1.58-.52c.41-.13.8-.24%201.17-.31-.3.61-.54%201.35-.74%202.2l-.98%204.19c-.98%204.18.31%206.24%204.48%207.23l1.68.4c.58.14%201.12.23%201.62.27Zm2.43-8.88c-.06%200-.12-.01-.19-.02l-4.85-1.23a.75.75%200%200%201%20.37-1.45l4.85%201.23a.748.748%200%200%201-.18%201.47Z%22%20fill%3D%22%23228e6c%22%20%2F%3E%20%3Cpath%20d%3D%22M14.56%2013.89c-.06%200-.12-.01-.19-.02l-2.91-.74a.75.75%200%200%201%20.37-1.45l2.91.74c.4.1.64.51.54.91-.08.34-.38.56-.72.56Z%22%20fill%3D%22%23228e6c%22%20%2F%3E%20%3C%2Fsvg%3E`;
|
||||
|
||||
@ -49,6 +50,7 @@ export function create(str = '', options = {}) {
|
||||
node.children = getTocsTree([ ...node.children ]);
|
||||
node.children.unshift(header(options));
|
||||
node.children.push(footer());
|
||||
node.children.push(anchorPoint());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -303,6 +303,7 @@ body.home .h1wrap .wrap-body p {
|
||||
|
||||
body:not(.home) .h2wrap > .wrap-body > ul {
|
||||
list-style: initial;
|
||||
margin-left: 1.2rem;
|
||||
}
|
||||
|
||||
body.home .h1wrap p {
|
||||
@ -428,7 +429,6 @@ a.text-grey {
|
||||
font-size: 100%;
|
||||
font-weight: inherit;
|
||||
line-height: inherit;
|
||||
-webkit-appearance: button;
|
||||
background-color: transparent;
|
||||
background-image: none;
|
||||
color: var(--color-fg-default);
|
||||
@ -592,6 +592,10 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
|
||||
grid-template-columns: repeat(1,minmax(0,1fr));
|
||||
}
|
||||
|
||||
.h4wrap > .wrap-body ul + hr {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.h3wrap > .wrap-body ul:not(:last-child),
|
||||
.h3wrap > .wrap-body ol,
|
||||
.h3wrap > .wrap-body dl {
|
||||
@ -719,53 +723,44 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
|
||||
border-radius: 0 0 0.5rem 0.5rem;
|
||||
}
|
||||
|
||||
.h2wrap-body > .wrap.active {
|
||||
box-shadow: 0 0 0 1.6pt #10b981;
|
||||
transition: box-shadow 0.5s ease-in-out;
|
||||
}
|
||||
|
||||
.code-highlight {
|
||||
display: block;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.cols-1 {
|
||||
grid-template-columns: repeat(1,minmax(0,1fr)) !important;
|
||||
}
|
||||
.cols-2 {
|
||||
grid-template-columns: repeat(2,minmax(0,1fr)) !important;
|
||||
}
|
||||
.cols-3 {
|
||||
grid-template-columns: repeat(3,minmax(0,1fr)) !important;
|
||||
}
|
||||
.cols-4 {
|
||||
grid-template-columns: repeat(4,minmax(0,1fr)) !important;
|
||||
}
|
||||
.cols-5 {
|
||||
grid-template-columns: repeat(5,minmax(0,1fr)) !important;
|
||||
}
|
||||
.cols-6 {
|
||||
grid-template-columns: repeat(6,minmax(0,1fr)) !important;
|
||||
}
|
||||
.col-span-2 {
|
||||
grid-column: span 2/span 2;
|
||||
}
|
||||
.col-span-3 {
|
||||
grid-column: span 3/span 3;
|
||||
}
|
||||
.col-span-4 {
|
||||
grid-column: span 4/span 4;
|
||||
}
|
||||
.col-span-5 {
|
||||
grid-column: span 5/span 5;
|
||||
}
|
||||
.row-span-2 {
|
||||
grid-row: span 2/span 2;
|
||||
}
|
||||
.row-span-3 {
|
||||
grid-row: span 3/span 3;
|
||||
}
|
||||
.row-span-4 {
|
||||
grid-row: span 4/span 4;
|
||||
}
|
||||
.row-span-5 {
|
||||
grid-row: span 5/span 5;
|
||||
}
|
||||
.cols-1 { grid-template-columns: repeat(1,minmax(0,1fr)) !important; }
|
||||
.cols-2 { grid-template-columns: repeat(2,minmax(0,1fr)) !important; }
|
||||
.cols-3 { grid-template-columns: repeat(3,minmax(0,1fr)) !important; }
|
||||
.cols-4 { grid-template-columns: repeat(4,minmax(0,1fr)) !important; }
|
||||
.cols-5 { grid-template-columns: repeat(5,minmax(0,1fr)) !important; }
|
||||
.cols-6 { grid-template-columns: repeat(6,minmax(0,1fr)) !important; }
|
||||
.cols-7 { grid-template-columns: repeat(7,minmax(0,1fr)) !important; }
|
||||
.cols-8 { grid-template-columns: repeat(8,minmax(0,1fr)) !important; }
|
||||
.cols-9 { grid-template-columns: repeat(9,minmax(0,1fr)) !important; }
|
||||
.col-span-2 { grid-column: span 2/span 2; }
|
||||
.col-span-3 { grid-column: span 3/span 3; }
|
||||
.col-span-4 { grid-column: span 4/span 4; }
|
||||
.col-span-5 { grid-column: span 5/span 5; }
|
||||
.col-span-6 { grid-column: span 6/span 6; }
|
||||
.col-span-7 { grid-column: span 7/span 7; }
|
||||
.col-span-8 { grid-column: span 8/span 8; }
|
||||
.col-span-9 { grid-column: span 9/span 9; }
|
||||
.col-span-10 { grid-column: span 10/span 10; }
|
||||
.row-span-2 { grid-row: span 2/span 2; }
|
||||
.row-span-3 { grid-row: span 3/span 3; }
|
||||
.row-span-4 { grid-row: span 4/span 4; }
|
||||
.row-span-5 { grid-row: span 5/span 5; }
|
||||
.row-span-6 { grid-row: span 6/span 6; }
|
||||
.row-span-7 { grid-row: span 7/span 7; }
|
||||
.row-span-8 { grid-row: span 8/span 8; }
|
||||
.row-span-9 { grid-row: span 9/span 9; }
|
||||
.row-span-10 { grid-row: span 10/span 10; }
|
||||
|
||||
.wrap-text {
|
||||
white-space: pre-wrap !important;
|
||||
overflow-wrap: break-word !important;
|
||||
@ -907,7 +902,7 @@ body:not(.home) .h2wrap-body > .wrap:hover .h3wrap > h3 a::after {
|
||||
@media (min-width: 1024px) {
|
||||
.h2wrap-body {
|
||||
display: grid;
|
||||
gap: 1.75rem;
|
||||
gap: 0.95rem;
|
||||
}
|
||||
.h2wrap-body > .wrap {
|
||||
margin-bottom: 0;
|
||||
|
30
scripts/utils/anchorPoint.mjs
Normal file
30
scripts/utils/anchorPoint.mjs
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
const scripts = `
|
||||
if(('onhashchange' in window) && ((typeof document.documentMode==='undefined') || document.documentMode==8)) {
|
||||
window.onhashchange = function () {
|
||||
anchorPoint()
|
||||
};
|
||||
}
|
||||
function anchorPoint() {
|
||||
const hash = window.location.hash?.replace(/^#/, '') || '';
|
||||
const elm = document.getElementById(decodeURIComponent(hash));
|
||||
Array.from(document.querySelectorAll('.h2wrap-body .wrap')).forEach((elm) => elm.classList.remove('active'))
|
||||
if (elm?.tagName === 'H3') {
|
||||
elm?.parentElement?.parentElement?.classList.add('active');
|
||||
const box = elm?.parentElement?.parentElement;
|
||||
console.log('elm:2', box, document.querySelectorAll('.h2wrap-body .wrap'))
|
||||
}
|
||||
}
|
||||
anchorPoint();
|
||||
`;
|
||||
|
||||
export function anchorPoint() {
|
||||
return {
|
||||
type: 'element',
|
||||
tagName: 'script',
|
||||
children: [{
|
||||
type: 'text',
|
||||
value: scripts,
|
||||
}]
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user