Skip to content

Commit

Permalink
second commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jiatianzhi committed Jan 19, 2024
1 parent 0ae6677 commit 9c3fe00
Show file tree
Hide file tree
Showing 440 changed files with 58,976 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# http://editorconfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
max_line_length = 80
trim_trailing_whitespace = true

[*.md]
insert_final_newline = false
trim_trailing_whitespace = false
14 changes: 14 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
__fixtures__
__mocks__
dist
node_modules
.yarn
.history
build
coverage
jest.config.js
jest.transform.js
docusaurus.config.ts
sidebars.js
*.md
lib
15 changes: 15 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
parserOptions: {
ecmaVersion: 7,
sourceType: 'module',
},
plugins: ['@docusaurus', '@typescript-eslint'],
extends: [
'plugin:@docusaurus/recommended',
'plugin:@typescript-eslint/recommended',
],
rules: {
'@typescript-eslint/no-unused-vars': 'off',
"@typescript-eslint/no-explicit-any": "error"
}
}
44 changes: 44 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: CI

on:
push:
branches:
- main

jobs:
build-and-deploy:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest] # macos-latest, windows-latest
node: [18]

steps:
- uses: actions/checkout@v4

- name: Set node version to ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- run: corepack enable

- name: Setup
run: npm i -g @antfu/ni

- name: Install
run: nci

- name: Build
run: nr build

- name: SSH Deploy
uses: easingthemes/[email protected]
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
ARGS: "-avzr --delete"
SOURCE: "build"
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
REMOTE_USER: "root"
TARGET: "/opt/1panel/apps/openresty/openresty/www/sites/kuizuo.cn/index"
28 changes: 28 additions & 0 deletions .github/workflows/docsearch.yml.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: docsearch

on:
push:
branches:
- main

jobs:
algolia:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Get the content of docsearch.json as config
id: algolia_config
run: echo "::set-output name=config::$(cat docsearch.json | jq -r tostring)"

- name: Run algolia/docsearch-scraper image
env:
ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }}
ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
CONFIG: ${{ steps.algolia_config.outputs.config }}
run: |
docker run \
--env APPLICATION_ID=${ALGOLIA_APP_ID} \
--env API_KEY=${ALGOLIA_API_KEY} \
--env "CONFIG=${CONFIG}" \
algolia/docsearch-scraper
26 changes: 26 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Dependencies
node_modules

# Production
/build
/drafts
/tmp
cloudbaserc.json

# Generated files
.docusaurus
.cache-loader

# Misc
.DS_Store
.env

# Packages
/packages

npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-error.log*

.vercel
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
shamefully-hoist=true
strict-peer-dependencies=false
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lib
14 changes: 14 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"singleQuote": true,
"quoteProps": "as-needed",
"jsxSingleQuote": false,
"trailingComma": "all",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"arrowParens": "avoid",
"proseWrap": "never"
}
19 changes: 19 additions & 0 deletions .stylelintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
extends: ['stylelint-config-standard-scss', 'stylelint-config-prettier-scss'],
rules: {
'selector-pseudo-class-no-unknown': [
true,
{
// :global is a CSS modules feature to escape from class name hashing
ignorePseudoClasses: ['global'],
},
],
'selector-class-pattern': null,
'custom-property-empty-line-before': null,
'selector-id-pattern': null,
'declaration-empty-line-before': null,
'no-descending-specificity': null,
'comment-empty-line-before': null,
'value-keyword-case': ['lower', { camelCaseSvgKeywords: true }],
},
}
14 changes: 14 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"prettier.enable": true,
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.organizeImports": "never"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"stylelint.validate": ["css", "less", "postcss", "scss", "sass"]
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 kuizuo

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
5 changes: 5 additions & 0 deletions blog/authors.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kuizuo:
name: 愧怍
title: 全栈 typescripter / 即将毕业的学生
url: https://github.com/kuizuo
image_url: /img/logo.webp
49 changes: 49 additions & 0 deletions blog/develop/AutoHotkey键盘映射.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
slug: autohotkey
title: AutoHotkey键盘映射
date: 2022-07-08
authors: kuizuo
tags: [工具, keyMap]
keywords: [工具, keyMap]
---

当我使用笔记本的时候,每次移动光标,都要大费周章,同时由于笔记本的缘故,导致键入Home与End都需要搭配Fn功能键来实现。所以我希望在任何情况下(敲代码,写文章)都可以将某些组合键绑定为上下左右键,在代码编辑器上有键盘映射可以设置,但脱离代码编辑器就不起作用了,在window下有个神器 [AutoHotkey](https://www.autohotkey.com/) 可以实现我想要的功能。

<!-- truncate -->

## 安装

打开[官网](https://www.autohotkey.com/),点击Download,安装即可。

## 使用

安装完成后,右键新建会AutoHotKey Srcipt后缀为ahk。例如创建demo.ahk,其内容如下

```ahk
<+<!I::Send {Up}
<+<!K::Send {Down}
<+<!J::Send {Left}
<+<!L::Send {Right}
<+<!H::Send {Home}
<+<!;::Send {End}
```

然后保存双击该文件,即可运行autohotkey,此时打开任意文本,键入<kbd>Shift</kbd> + <kbd>Ctrl</kbd> + [HIJKL;] 就可以看到光标上下左右移动。

这里对上面语法进行讲解

| 键名 | 热键标识 |
| ----- | -------- |
| Ctrl | ^ |
| Shift | + |
| Alt | ! |
| Win | # |

如果要针对左右Ctrl或Shfit只需要在前面添加`<` `>``::`则作为映射关系,左边的按键作用于何种指令,而右侧则是左侧按键所对应的指令,这里的指令相对简单,只是发送键盘上下左右的关系,指令还可以实现信息框MsgBox 启动应用等等。具体还有更多键盘与鼠标热键详情可在AutoHotkey Help手册中查看,非常详细,不过是英文。

具体要映射的快捷键可自行发挥,但要切记不建议与常用快捷键冲突,例如上面为何是IJKL而不是WASD,其原因会导致快捷键冲突。

此外AutoHotkey不仅能做键盘映射,实现宏定义,一键启动任务也不成问题,篇幅有限,就不做过多演示,有兴趣可自行研究。



109 changes: 109 additions & 0 deletions blog/develop/HTTP请求之Content-Type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
---
slug: content-type-of-http-request
title: HTTP请求之Content-Type
date: 2020-12-12
authors: kuizuo
tags: [http]
keywords: [http]
---

<!-- truncate -->

## Content-type

先看一条 HTTP 请求

```http
POST https://xxx.kuizuo.cn/v2/login HTTP/1.1
Host: xxx.kuizuo.cn
Connection: keep-alive
Content-Length: 121
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36
// Content-Type: application/json;charset=UTF-8
Accept: application/json, text/plain, */*
{"username":"kuizuo","password":"a12345678"}
```

上面那个请求发送到我的服务器,服务器却接收到的是这样一串值

```json
{ "{\"username\":\"kuizuo\",\"password\":\"a12345678\"}": "" }
```

很显然,它把 json 格式解析成了 x-www-form-urlencoded。

一个很简单的登录请求,注意一个协议头`Content-Type`,它决定了你的数据发送到服务端上会是什么格式。

```
类型格式:type/subtype(;parameter)?
type 主类型,任意的字符串,如text,如果是*号代表所有;
subtype 子类型,任意的字符串,如html,如果是*号代表所有;
parameter 可选,一些参数,如Accept请求头的q参数, Content-Type的charset参数。
```

常见的媒体格式类型如下:

- text/html : HTML 格式

- text/plain :纯文本格式

- text/xml : XML 格式

- image/gif :gif 图片格式

- image/jpeg :jpg 图片格式

- image/png:png 图片格式

以 application 开头的媒体格式类型:

- application/xhtml+xml :XHTML 格式

- application/xml : XML 数据格式

- application/atom+xml :Atom XML 聚合格式

- application/json : JSON 数据格式

- application/pdf :pdf 格式

- application/msword : Word 文档格式

- application/octet-stream : 二进制流数据(如常见的文件下载)

- application/x-www-form-urlencoded : form 表单数据被编码为 key/value 格式(通过=与&拼接)发送到服务器(表单默认的提交数据的格式)格式如: username=kuizuo&password=a12345678

另外一种常见的媒体格式是上传文件之时使用的:

- multipart/form-data : 需要在表单中进行文件上传时,就需要使用该格式

实际上遇到最多的也就是 text/html,text/plain,application/json,application/x-www-form-urlencoded 这几个。

> 参考资料 [Http 请求中 Content-Type](https://www.cnblogs.com/klb561/p/10090540.html)
### 说说我那时候的情况

这是在我帮别人分析登录算法的时候,由于协议头中少添加了一个`Content-Type`,导致我发送的数据,服务端解析不了,收到了这样的响应

```json
{
"code": 500001,
"message": "亲,我们的系统目前忙碌中或无法回应,请将此问题回报给我们的客服人员。 错误代碼(68523)",
"data": null
}
```

然而实际响应应该是这样的

```json
{ "code": 400020, "message": "密码错误", "data": "验证码错误" }
```

原因就是因为协议头没有添加`Content-Type: application/json;charset=UTF-8`所导致的。因为这个,坑了我近一个小时,还一直以为是数据错误,没想到仅仅只是少加了一些协议头导致的请求数据格式错误。

一个印象很深刻的教训,模拟 HTTP 请求的时候,一定不要吝啬补全协议头,不然坑的就是自己了。我已经给坑过两次了,所以在特意想借此记录一下,免得下次又是一番折腾。写个注意,醒目一点。

:::danger 发送的是 JSON 格式数据,切记一定要添加上协议头`Content-Type: application/json;charset=UTF-8`

:::
Loading

0 comments on commit 9c3fe00

Please sign in to comment.