Skip to content

Commit 8a05aa0

Browse files
committed
style: code formatter config
1 parent c332d40 commit 8a05aa0

21 files changed

+524
-183
lines changed

.eslintrc.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module.exports = {
2+
env: {
3+
browser: true,
4+
es2021: true,
5+
node: true
6+
},
7+
extends: ['plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended'],
8+
parser: '@typescript-eslint/parser',
9+
parserOptions: {
10+
ecmaVersion: 12,
11+
sourceType: 'module'
12+
},
13+
plugins: ['@typescript-eslint'],
14+
rules: {
15+
// 允许方法不设置参数类型以及返回值类型
16+
'@typescript-eslint/explicit-module-boundary-types': 0,
17+
allowArgumentsExplicitlyTypedAsAny: 0,
18+
'no-unused-vars': 'off',
19+
'@typescript-eslint/no-unused-vars': ['off']
20+
}
21+
}

.husky/commit-msg

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
yarn commitlint --edit $1

.husky/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
yarn lint-staged

.npmignore

+4
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ __tests__
1111
src
1212
tsconfig.json
1313
node_modules
14+
.eslintrc.js
15+
.prettierrc.js
16+
.husky
17+
commitlint.config.js

.prettierrc.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
printWidth: 120,
3+
semi: false,
4+
singleQuote: true,
5+
bracketSpacing: true,
6+
arrowParens: 'avoid',
7+
tabWidth: 2,
8+
useTabs: false,
9+
trailingComma: 'none'
10+
}

CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Change Log
2+
3+
All notable changes to this project will be documented in this file.
4+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5+
6+
## 0.0.2 (2021-09-14)
7+
8+
9+
### Bug Fixes
10+
11+
* number secret lead to encrypt failed ([f36df5b](https://github.com/alphawq/vuepress-plugin-posts-encrypt/commit/f36df5bd29524dd04d9ba6ce99fb7e3fafa30534))
12+
* **vuepress-plugin-posts-encrypt:** number secret lead to encrypt failed ([b893eb9](https://github.com/alphawq/vuepress-plugin-posts-encrypt/commit/b893eb9bbbb543b465edd192954e5ec29610ddcd))

README.md

+23-16
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ English | [简体中文](./README.zh-cn.md)
1414
```sh
1515
yarn add vuepress-plugin-posts-encrypt
1616
```
17+
1718
## Usage
1819

19-
### Step 1: Init configuration in vuepress config file
20+
### Step 1: Init configuration in vuepress config file
2021

21-
``` js
22+
```js
2223
// .vuepress/config.js
2324
module.exports = {
2425

@@ -35,11 +36,12 @@ module.exports = {
3536
]
3637
}
3738
```
39+
3840
👇[All configuration items](#Configs) can be seen at `Configs` part👇
3941

4042
### Step 2: Configure the posts that need to be encrypted access in the blog
4143

42-
- Set `secret: true` in the article [Front Matter](https://vuepress.vuejs.org/zh/guide/frontmatter.html#%E5%85%B6%E4%BB%96%E6%A0%BC%E5%BC%8F%E7%9A%84-front-matter)
44+
- Set `secret: true` in the article [Front Matter](https://vuepress.vuejs.org/zh/guide/frontmatter.html#%E5%85%B6%E4%BB%96%E6%A0%BC%E5%BC%8F%E7%9A%84-front-matter)
4345

4446
```yml
4547
---
@@ -72,12 +74,12 @@ passwd: 1233211234567
7274

7375
### Step3: Run it & See the effect
7476

75-
*BTW*: **Under dev mode `encryptInDev: true` also needs to be configured**
77+
_BTW_: **Under dev mode `encryptInDev: true` also needs to be configured**
7678

7779
Execute the following command to start the development service
7880

7981
```sh
80-
vuepress dev docs
82+
vuepress dev docs
8183
```
8284

8385
Click to enter a page that needs to verify the password, you can see the following effects:
@@ -88,27 +90,30 @@ Click to enter a page that needs to verify the password, you can see the followi
8890

8991
### Support custom templates
9092

91-
In the custom template scenario, the plugin needs to inject some logic into your template file, such as `the logic related to password verification`. So you need to provide a mark to inject this part of the code in the template.
93+
In the custom template scenario, the plugin needs to inject some logic into your template file, such as `the logic related to password verification`. So you need to provide a mark to inject this part of the code in the template.
9294

9395
The following marks except `<%crypto_inject_tag%>` & `<%validate_js_tag%>` are required, the others are optional. You are free to choose:
9496

95-
*BTW*: **The following marks are inserted into the template from top to bottom, so you need to pay attention to the writing position of the mark**
97+
_BTW_: **The following marks are inserted into the template from top to bottom, so you need to pay attention to the writing position of the mark**
9698

9799
The position markers for content injection in the template include the following
98100

99101
#### `<%iview_css_tag%>` [`Optional`]
100102

101-
> [`iView`](https://www.iviewui.com/docs/introduce) Component library's CSS injection location mark.
103+
> [`iView`](https://www.iviewui.com/docs/introduce) Component library's CSS injection location mark.
104+
102105
- Need to set `iview: true` in the `injectConfig` configuration
103106

104107
#### `<%animate_css_tag%>` [`Optional`]
105108

106109
> [`Animate.css`](https://animate.style/) injection location mark.
110+
107111
- Need to set `animate: true` in the `injectConfig` configuration
108112

109-
#### `<%iview_js_tag%>` [`Optional`]
113+
#### `<%iview_js_tag%>` [`Optional`]
110114

111115
> [`iView`](https://www.iviewui.com/docs/introduce) Component library's JS injection location mark.
116+
112117
- Need to set `iview: true` in the `injectConfig` configuration
113118

114119
#### `<%minified_css_tag%>` [`Optional`]
@@ -117,20 +122,21 @@ The position markers for content injection in the template include the following
117122
118123
- If you don't want to write `css` in the template, this configuration allows you to separate the style files that need to be used in the template into the `less` file. The plugin will help you `compile and insert` to the corresponding location. You only need Specify the absolute path of the style file in the `less` setting of `injectConfig`
119124

120-
121125
#### `<%crypto_inject_tag%>` [`Required`]
126+
122127
- [`CryptoJS`](https://github.com/brix/crypto-js) Script file insertion position
123128

124129
#### `<%validate_js_tag%>` [`Required`]
125-
> **Password verification** and **Verified routing storage** injection location mark of related logic
130+
131+
> **Password verification** and **Verified routing storage** injection location mark of related logic
126132
127133
### Support setting password expiration time
128134

129135
By default, if the verified route is on the same device and the same browser and the user does not clear the local cache, there is no need to verify again next time you come in, because it is stored in `localstorage`
130136

131137
If you don't want this, you can set `expires` for the password, the unit is `milliseconds (ms)`. This expiration time is for each route, not all routes.
132138

133-
*BTW*: **Do not set the expiration time too short, otherwise it may cause an endless loop of routing**
139+
_BTW_: **Do not set the expiration time too short, otherwise it may cause an endless loop of routing**
134140

135141
### The following are all supported configuration options:
136142

@@ -159,7 +165,7 @@ interface Options {
159165
injectConfig?: InjectConfig
160166
}
161167

162-
// The default options
168+
// The default options
163169
const options: Options = {
164170
route: '/auth',
165171
passwd: 'hello world',
@@ -169,12 +175,13 @@ const options: Options = {
169175
injectConfig: {
170176
less: '',
171177
iview: false,
172-
animate: false
173-
}
178+
animate: false,
179+
},
174180
}
175181
```
182+
176183
👏👏 **One key triple connection** 👏👏
177184

178185
## License
179186

180-
**[MIT](./LICENSE)**
187+
**[MIT](./LICENSE)**

README.zh-cn.md

+24-18
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@
99

1010
> **一个用于为你的博客添加 `访问验证` 功能的 `vuepress` 插件。**
1111
12-
13-
## 安装
12+
## 安装
1413

1514
```sh
1615
yarn add vuepress-plugin-posts-encrypt
1716
```
17+
1818
## Usage 使用
1919

20-
### Step 1: 在 `.vuepress/config.js` 中初始化配置
20+
### Step 1: 在 `.vuepress/config.js` 中初始化配置
2121

22-
``` js
22+
```js
2323
// .vuepress/config.js
2424
module.exports = {
2525

@@ -36,8 +36,8 @@ module.exports = {
3636
]
3737
}
3838
```
39-
> 👇[所有配置项](#配置项) 参见下方 `Configs` 部分👇
4039

40+
> 👇[所有配置项](#配置项) 参见下方 `Configs` 部分 👇
4141
4242
### Step 2: 配置博客中需要加密访问的文章
4343

@@ -74,12 +74,12 @@ passwd: 1233211234567
7474

7575
### Step3: 运行起来看下效果吧
7676

77-
*BTW***开发环境下,还需要配置 `encryptInDev: true`**
77+
_BTW_**开发环境下,还需要配置 `encryptInDev: true`**
7878

7979
执行如下命令,启动开发服务,
8080

8181
```sh
82-
vuepress dev docs
82+
vuepress dev docs
8383
```
8484

8585
点击进入一个需要验证密码的页面,就可以看到如下效果:
@@ -94,46 +94,50 @@ vuepress dev docs
9494

9595
以下标记除了 **`<%validate_js_tag%>` & `<%crypto_inject_tag%>`** 之外,其他都是可选的,你可以自由选择:
9696

97-
*BTW***以下标记都是自上而下依次插入到模板中的,所以需要额外注意标记的书写位置**
97+
_BTW_**以下标记都是自上而下依次插入到模板中的,所以需要额外注意标记的书写位置**
9898

9999
模板中内容注入的位置标记包括如下几种
100100

101101
#### `<%iview_css_tag%>` 【非必须】
102102

103-
> [`iView`](https://www.iviewui.com/docs/introduce) 组件库 `CSS` 资源注入位置标记
104-
- 需要在 `injectConfig` 配置中设置 `iview: true`
103+
> [`iView`](https://www.iviewui.com/docs/introduce) 组件库 `CSS` 资源注入位置标记
105104
105+
- 需要在 `injectConfig` 配置中设置 `iview: true`
106106

107107
#### `<%animate_css_tag%>` 【非必须】
108108

109109
> [`Animate.css`](https://animate.style/) 注入位置标记
110+
110111
- 需要在 `injectConfig` 配置中设置 `animate: true`
111112

112113
#### `<%iview_js_tag%>` 【非必须】
113114

114115
> [`iView`](https://www.iviewui.com/docs/introduce) 组件库 `JS` 注入位置标记
116+
115117
- 需要在 `injectConfig` 配置中设置 `iview: true`
116118

117119
#### `<%minified_css_tag%>` 【非必须】
118120

119121
> 外部 `less` 文件编译后的注入位置标记
122+
120123
- 如果你不想在模板里面写 `css`,这个配置可以允许你将模板中需要用到的样式文件单独抽离到 `less` 文件中,插件会帮你 `编译并插入` 到对应位置。
121-
你只需要在 `injectConfig``less` 设置中指定样式文件的绝对路径即可
124+
你只需要在 `injectConfig``less` 设置中指定样式文件的绝对路径即可
122125

123126
#### `<%crypto_inject_tag%>` 【必须】
124-
> [`CryptoJS`](https://github.com/brix/crypto-js) 脚本文件插入位置
127+
128+
> [`CryptoJS`](https://github.com/brix/crypto-js) 脚本文件插入位置
125129
126130
#### `<%validate_js_tag%>` 【必须】
127-
> **密码校验**以及**已验证路由的存储**相关逻辑的注入位置标记
128131

132+
> **密码校验**以及**已验证路由的存储**相关逻辑的注入位置标记
129133
130134
### 支持设置密码过期时间
131135

132136
默认情况下,已验证通过的路由在同一台设备同一个浏览器且用户没有清理本地缓存的情况下,下次进来是不需要再次进行验证的,因为是存储在 `localstorage` 中的
133137

134138
如果你不想这样的话,可以为密码设置 `expires`,单位是`毫秒(ms)`。这个过期时间是针对每个路由而言的,而不是所有路由。
135139

136-
*BTW*: **过期时间不要设置得过短,否则可能会造成路由死循环**
140+
_BTW_: **过期时间不要设置得过短,否则可能会造成路由死循环**
137141

138142
### 以下是支持的所有配置选项:
139143

@@ -168,15 +172,17 @@ const options: Options = {
168172
template: '', // 自定义模板的文件路径,不指定则使用默认模板
169173
encryptInDev: false, // 开发模式下是否开启文章加密(可用于预览), 默认 false
170174
expires: 0, // 密码过期时间,默认永不过期
171-
injectConfig: { // 自定义模板时,需要注入的外部资源配置
175+
injectConfig: {
176+
// 自定义模板时,需要注入的外部资源配置
172177
less: '',
173178
iview: false,
174-
animate: false
175-
}
179+
animate: false,
180+
},
176181
}
177182
```
183+
178184
👏👏 **One key triple connection** 👏👏
179185

180186
## License
181187

182-
**[MIT](./LICENSE)**
188+
**[MIT](./LICENSE)**

assets/enhanceAppFiles.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
module.exports = function genEnhanceAppFile (path, STORAGE_KEY) {
1+
module.exports = function genEnhanceAppFile(path, STORAGE_KEY) {
32
return `export default ({ Vue, router, siteData, isServer }) => {
43
// 获取所有需要加密的路由
54
if(!isServer) {
@@ -42,4 +41,4 @@ module.exports = function genEnhanceAppFile (path, STORAGE_KEY) {
4241
})
4342
}
4443
}`
45-
}
44+
}

0 commit comments

Comments
 (0)