@rsdoctor/docs 0.0.0-next-20240620044732
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/docs/404.mdx +7 -0
- package/docs/en/_meta.json +17 -0
- package/docs/en/blog/_meta.json +12 -0
- package/docs/en/blog/release/_meta.json +1 -0
- package/docs/en/blog/release/release-note-1.mdx +129 -0
- package/docs/en/blog/topic/_meta.json +1 -0
- package/docs/en/blog/topic/duplicate-pkg-problem.mdx +141 -0
- package/docs/en/blog/topic/loader-optimization.mdx +80 -0
- package/docs/en/config/_meta.json +7 -0
- package/docs/en/config/options/_meta.json +1 -0
- package/docs/en/config/options/options-shared.mdx +67 -0
- package/docs/en/config/options/options.mdx +195 -0
- package/docs/en/config/options/term.mdx +10 -0
- package/docs/en/guide/_meta.json +17 -0
- package/docs/en/guide/more/_meta.json +1 -0
- package/docs/en/guide/more/faq.mdx +104 -0
- package/docs/en/guide/more/rules.mdx +5 -0
- package/docs/en/guide/start/_meta.json +1 -0
- package/docs/en/guide/start/cli.mdx +94 -0
- package/docs/en/guide/start/features.mdx +36 -0
- package/docs/en/guide/start/intro.mdx +115 -0
- package/docs/en/guide/start/quick-start-shared.mdx +184 -0
- package/docs/en/guide/start/quick-start.mdx +29 -0
- package/docs/en/guide/usage/_meta.json +14 -0
- package/docs/en/guide/usage/bundle-alerts.mdx +47 -0
- package/docs/en/guide/usage/bundle-overall.mdx +55 -0
- package/docs/en/guide/usage/bundle-size.mdx +148 -0
- package/docs/en/guide/usage/compile-alerts.mdx +18 -0
- package/docs/en/guide/usage/compile-overall.mdx +115 -0
- package/docs/en/guide/usage/loaders-analysis.mdx +72 -0
- package/docs/en/guide/usage/loaders-timeline.mdx +68 -0
- package/docs/en/guide/usage/module-analysis.mdx +58 -0
- package/docs/en/guide/usage/plugins-analysis.mdx +43 -0
- package/docs/en/guide/usage/project-overall.mdx +51 -0
- package/docs/en/guide/usage/resolver.mdx +32 -0
- package/docs/en/guide/usage/rule-config.mdx +85 -0
- package/docs/en/index.md +38 -0
- package/docs/public/netlify.toml +4 -0
- package/docs/public/og-image.png +0 -0
- package/docs/zh/_meta.json +17 -0
- package/docs/zh/blog/_meta.json +12 -0
- package/docs/zh/blog/release/_meta.json +1 -0
- package/docs/zh/blog/release/release-note-1.mdx +128 -0
- package/docs/zh/blog/topic/_meta.json +1 -0
- package/docs/zh/blog/topic/duplicate-pkg-problem.mdx +138 -0
- package/docs/zh/blog/topic/loader-optimization.mdx +80 -0
- package/docs/zh/config/_meta.json +7 -0
- package/docs/zh/config/options/_meta.json +1 -0
- package/docs/zh/config/options/options-shared.mdx +70 -0
- package/docs/zh/config/options/options.mdx +170 -0
- package/docs/zh/config/options/term.mdx +10 -0
- package/docs/zh/guide/_meta.json +17 -0
- package/docs/zh/guide/more/_meta.json +1 -0
- package/docs/zh/guide/more/faq.mdx +102 -0
- package/docs/zh/guide/more/rules.mdx +5 -0
- package/docs/zh/guide/start/_meta.json +1 -0
- package/docs/zh/guide/start/cli.mdx +94 -0
- package/docs/zh/guide/start/features.mdx +36 -0
- package/docs/zh/guide/start/intro.mdx +116 -0
- package/docs/zh/guide/start/quick-start-shared.mdx +183 -0
- package/docs/zh/guide/start/quick-start.mdx +29 -0
- package/docs/zh/guide/usage/_meta.json +14 -0
- package/docs/zh/guide/usage/bundle-alerts.mdx +49 -0
- package/docs/zh/guide/usage/bundle-overall.mdx +57 -0
- package/docs/zh/guide/usage/bundle-size.mdx +148 -0
- package/docs/zh/guide/usage/compile-alerts.mdx +18 -0
- package/docs/zh/guide/usage/compile-overall.mdx +115 -0
- package/docs/zh/guide/usage/loaders-analysis.mdx +73 -0
- package/docs/zh/guide/usage/loaders-timeline.mdx +68 -0
- package/docs/zh/guide/usage/module-analysis.mdx +59 -0
- package/docs/zh/guide/usage/plugins-analysis.mdx +43 -0
- package/docs/zh/guide/usage/project-overall.mdx +51 -0
- package/docs/zh/guide/usage/resolver.mdx +32 -0
- package/docs/zh/guide/usage/rule-config.mdx +86 -0
- package/docs/zh/index.md +38 -0
- package/docs/zh/shared/features-rspack.md +24 -0
- package/docs/zh/shared/features.md +29 -0
- package/package.json +45 -0
- package/src/components/NextSteps.module.scss +6 -0
- package/src/components/NextSteps.tsx +7 -0
- package/src/components/Overview.module.scss +61 -0
- package/src/components/Overview.tsx +40 -0
- package/src/components/RuleIndex.module.scss +57 -0
- package/src/components/RuleIndex.tsx +75 -0
- package/src/components/Step.module.scss +32 -0
- package/src/components/Step.tsx +13 -0
- package/src/global.d.ts +4 -0
- package/src/utils.ts +9 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# 编译诊断规则
|
|
2
|
+
|
|
3
|
+
构建诊断规则是类似于 `ESLint` 的 lint 工具,但是与其不同之处在于,`ESLint` 是在静态情况下进行代码扫描和构建流程无关。而这里的代码诊断是和 `Rspack 或 Webpack` 的构建流程紧密相关的,其中会加入许许多多构建中产生的内部参数用于辅助判断,比如 ModuleGraph,比如 Webpack 对每个模块的内部标记,比如代码经过转换之后加入的 runtime 等等……
|
|
4
|
+
|
|
5
|
+
在构建过程中发现了问题,会在 CLI 和最后弹出的诊断汇总网页中看到,如下图:
|
|
6
|
+
|
|
7
|
+
<img
|
|
8
|
+
width="700"
|
|
9
|
+
style={{ margin: '10px auto' }}
|
|
10
|
+
src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/bundle/rule-config-cli.png"
|
|
11
|
+
/>
|
|
12
|
+
|
|
13
|
+
<img
|
|
14
|
+
width="700"
|
|
15
|
+
style={{ margin: '10px auto' }}
|
|
16
|
+
src="https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/bundle/rule-config-1.png"
|
|
17
|
+
/>
|
|
18
|
+
|
|
19
|
+
## 如何使用
|
|
20
|
+
|
|
21
|
+
诊断规则的使用很简单,它配置在整个插件的`linter`选项下,如下用例:
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { RsdoctorWebpackPlugin } from '@rsdoctor/webpack-plugin';
|
|
25
|
+
|
|
26
|
+
export default {
|
|
27
|
+
plugin: [
|
|
28
|
+
new RsdoctorWebpackPlugin({
|
|
29
|
+
linter: {
|
|
30
|
+
level: 'Error',
|
|
31
|
+
extends: [],
|
|
32
|
+
rules: {
|
|
33
|
+
'default-import-check': 'off',
|
|
34
|
+
'duplicate-package': [
|
|
35
|
+
'Error',
|
|
36
|
+
{
|
|
37
|
+
checkVersion: 'minor',
|
|
38
|
+
ignore: ['chalk', '@bable/runtime'],
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
}),
|
|
44
|
+
],
|
|
45
|
+
};
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
`linter`字段的类型为:
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
/** 校验器选项 */
|
|
52
|
+
interface Options {
|
|
53
|
+
rules?: RulesMap;
|
|
54
|
+
level?: SeverityString;
|
|
55
|
+
extends?: ExtendRuleData[];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* 校验等级
|
|
60
|
+
* - `'Warn'`时只运行类别为`'Warn'`的规则
|
|
61
|
+
* - `'Error'`时运行全部规则
|
|
62
|
+
*/
|
|
63
|
+
type SeverityString = 'Warn' | 'Error';
|
|
64
|
+
|
|
65
|
+
/** 规则等级 */
|
|
66
|
+
type SeverityInput = SeverityString | 'off' | 'on';
|
|
67
|
+
|
|
68
|
+
/** 规则配置 */
|
|
69
|
+
type RulesMap = Record<string, RuleConfigItem>;
|
|
70
|
+
|
|
71
|
+
/** 单规则配置 */
|
|
72
|
+
type RuleConfigItem =
|
|
73
|
+
// 仅有报错等级,此等级优先级高于规则自身配置
|
|
74
|
+
| SeverityInput
|
|
75
|
+
// 数组情况下,第一项为报错等级,后一项是规则配置
|
|
76
|
+
| [SeverityInput, unknown];
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## 内部已有规则
|
|
80
|
+
|
|
81
|
+
在现有的诊断器中已经包含了三个规则,它们分别是:
|
|
82
|
+
|
|
83
|
+
1. [[E1001] Duplicate Packages](./bundle-alerts#%E9%87%8D%E5%A4%8D%E7%AC%AC%E4%B8%89%E6%96%B9%E5%8C%85)
|
|
84
|
+
2. [[E1002] Default Import Check](../more/rules)
|
|
85
|
+
3. [[E1003] Loader Performance Optimization](../more/rules)
|
|
86
|
+
4. [[E1004] ECMA Version Check](../more/rules)
|
package/docs/zh/index.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
pageType: home
|
|
3
|
+
|
|
4
|
+
hero:
|
|
5
|
+
name: Rsdoctor
|
|
6
|
+
text: Rspack & Webpack 构建分析工具
|
|
7
|
+
tagline: 让构建过程可视化
|
|
8
|
+
actions:
|
|
9
|
+
- theme: brand
|
|
10
|
+
text: 介绍
|
|
11
|
+
link: /zh/guide/start/intro
|
|
12
|
+
- theme: alt
|
|
13
|
+
text: 快速开始
|
|
14
|
+
link: /zh/guide/start/quick-start
|
|
15
|
+
image:
|
|
16
|
+
src: https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/logo/rsdoctor.png
|
|
17
|
+
alt: Rsdoctor Logo
|
|
18
|
+
|
|
19
|
+
features:
|
|
20
|
+
- title: 框架无关
|
|
21
|
+
details: Rsdoctor 支持分析用 Webpack 和 Rspack 构建的项目。
|
|
22
|
+
icon: 🛠️
|
|
23
|
+
- title: 构建时分析
|
|
24
|
+
details: 以时序图的形式显示编译执行时间和过程。
|
|
25
|
+
icon: 🚀
|
|
26
|
+
- title: 构建行为分析
|
|
27
|
+
details: 可视化的查看每个 loader 对每个文件的编译更改。
|
|
28
|
+
icon: 🦄
|
|
29
|
+
- title: 构建产物分析
|
|
30
|
+
details: 直观地详细查看 Bundle 和模块关系、模块引用关系和重复包等产物详情。
|
|
31
|
+
icon: 🎯
|
|
32
|
+
- title: 产物对比
|
|
33
|
+
details: 通过对比发现产物劣化及变动。
|
|
34
|
+
icon: 🎨
|
|
35
|
+
- title: 构建扫描
|
|
36
|
+
details: 内置构建规则扫描,同时支持自定义规则。
|
|
37
|
+
icon: 🔍
|
|
38
|
+
---
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
```ts
|
|
2
|
+
interface RsdoctorRspackPluginFeatures {
|
|
3
|
+
/**
|
|
4
|
+
* turn off it if you need not to analyze the executions of webpack loaders.
|
|
5
|
+
* @default true
|
|
6
|
+
*/
|
|
7
|
+
loader?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* turn off it if you need not to analyze the executions of webpack plugins.
|
|
10
|
+
* @default true
|
|
11
|
+
*/
|
|
12
|
+
plugins?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* turn off it if you need not to analyze the output bundle.
|
|
15
|
+
* @default true
|
|
16
|
+
*/
|
|
17
|
+
bundle?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* turn on it if you just use lite mode. This mode do not have source codes.
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
lite?: boolean;
|
|
23
|
+
}
|
|
24
|
+
```
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
```ts
|
|
2
|
+
interface RsdoctorWebpackPluginFeatures {
|
|
3
|
+
/**
|
|
4
|
+
* turn off it if you need not to analyze the executions of webpack loaders.
|
|
5
|
+
* @default true
|
|
6
|
+
*/
|
|
7
|
+
loader?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* turn off it if you need not to analyze the executions of webpack plugins.
|
|
10
|
+
* @default true
|
|
11
|
+
*/
|
|
12
|
+
plugins?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* turn off it if you need not to analyze the executions of resolver.
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
resolver?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* turn off it if you need not to analyze the output bundle.
|
|
20
|
+
* @default true
|
|
21
|
+
*/
|
|
22
|
+
bundle?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* turn on it if you just use lite mode. This mode do not have source codes.
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
lite?: boolean;
|
|
28
|
+
}
|
|
29
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rsdoctor/docs",
|
|
3
|
+
"version": "0.0.0-next-20240620044732",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/web-infra-dev/rsdoctor",
|
|
7
|
+
"directory": "packages/document"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"main": "dist/index.js",
|
|
11
|
+
"types": "dist/index.d.ts",
|
|
12
|
+
"files": [
|
|
13
|
+
"docs",
|
|
14
|
+
"src"
|
|
15
|
+
],
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public",
|
|
18
|
+
"provenance": true,
|
|
19
|
+
"registry": "https://registry.npmjs.org/"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@types/node": "^16",
|
|
23
|
+
"@types/react": "^18",
|
|
24
|
+
"@types/react-dom": "^18",
|
|
25
|
+
"react": "18.2.0",
|
|
26
|
+
"react-dom": "18.2.0",
|
|
27
|
+
"rsbuild-plugin-google-analytics": "^1.0.0",
|
|
28
|
+
"rsbuild-plugin-open-graph": "1.0.0",
|
|
29
|
+
"rspress-plugin-font-open-sans": "^1.0.0",
|
|
30
|
+
"typescript": "^5.2.2",
|
|
31
|
+
"@rsdoctor/types": "0.0.0-next-20240620044732"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"framer-motion": "^10.18.0",
|
|
35
|
+
"react-markdown": "^9.0.1",
|
|
36
|
+
"rsfamily-nav-icon": "^1.0.3",
|
|
37
|
+
"rspress": "^1.21.0",
|
|
38
|
+
"tailwindcss": "^3.4.0"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"dev": "rspress dev",
|
|
42
|
+
"build": "rspress build",
|
|
43
|
+
"preview": "rspress preview"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
margin-top: 64px;
|
|
3
|
+
|
|
4
|
+
h2 {
|
|
5
|
+
font-size: 23px;
|
|
6
|
+
font-weight: 600;
|
|
7
|
+
line-height: 1;
|
|
8
|
+
margin: 0 0 20px;
|
|
9
|
+
color: var(--rp-c-text-1);
|
|
10
|
+
transition: color 0.5s;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
a {
|
|
14
|
+
letter-spacing: -0.01em;
|
|
15
|
+
margin-bottom: 1em;
|
|
16
|
+
transition: color 0.5s;
|
|
17
|
+
margin: 0;
|
|
18
|
+
font-size: 15px;
|
|
19
|
+
font-weight: 500;
|
|
20
|
+
line-height: 2.2;
|
|
21
|
+
margin-top: 8px;
|
|
22
|
+
color: var(--rp-c-text-code);
|
|
23
|
+
opacity: 0.9;
|
|
24
|
+
transition: color 0.5s;
|
|
25
|
+
word-break: break-all;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
a:hover {
|
|
29
|
+
transition: color 0.5s;
|
|
30
|
+
color: var(--rp-c-brand-dark);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.group {
|
|
35
|
+
break-inside: avoid;
|
|
36
|
+
margin-bottom: 28px;
|
|
37
|
+
background-color: var(--rp-c-bg-soft);
|
|
38
|
+
border-radius: 12px;
|
|
39
|
+
padding: 28px 32px;
|
|
40
|
+
transition: background-color 0.5s;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@media (max-width: 768px) {
|
|
44
|
+
.root a {
|
|
45
|
+
font-size: 14px;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@media (min-width: 768px) {
|
|
50
|
+
.root {
|
|
51
|
+
columns: 2;
|
|
52
|
+
min-width: 648px;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@media (min-width: 1024px) {
|
|
57
|
+
.root {
|
|
58
|
+
columns: 3;
|
|
59
|
+
min-width: 904px;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { NoSSR } from 'rspress/runtime';
|
|
2
|
+
import { useUrl } from '../utils';
|
|
3
|
+
import styles from './Overview.module.scss';
|
|
4
|
+
|
|
5
|
+
export interface GroupItem {
|
|
6
|
+
text: string;
|
|
7
|
+
link: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface Group {
|
|
11
|
+
name: string;
|
|
12
|
+
items: GroupItem[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare const OVERVIEW_GROUPS: Group[];
|
|
16
|
+
|
|
17
|
+
export default function Overview() {
|
|
18
|
+
const Nodes = OVERVIEW_GROUPS.map((group) => (
|
|
19
|
+
<>
|
|
20
|
+
<div className={styles.overviewGroups}>
|
|
21
|
+
<div className={styles.group}>
|
|
22
|
+
<h2>{group.name}</h2>
|
|
23
|
+
<ul>
|
|
24
|
+
{group.items.map((item) => (
|
|
25
|
+
<li key={item.text}>
|
|
26
|
+
<a href={useUrl(item.link)}>{item.text}</a>
|
|
27
|
+
</li>
|
|
28
|
+
))}
|
|
29
|
+
</ul>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
</>
|
|
33
|
+
));
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<NoSSR>
|
|
37
|
+
<div className={styles.root}>{Nodes}</div>
|
|
38
|
+
</NoSSR>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
display: flex;
|
|
3
|
+
justify-content: center;
|
|
4
|
+
align-items: flex-start;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.card {
|
|
8
|
+
box-sizing: border-box;
|
|
9
|
+
margin: 0;
|
|
10
|
+
padding: 0;
|
|
11
|
+
position: relative;
|
|
12
|
+
border-radius: 8px;
|
|
13
|
+
border: 1px solid var(--rp-c-divider-light);
|
|
14
|
+
margin-right: 24px;
|
|
15
|
+
font-size: 14px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.card-header {
|
|
19
|
+
display: flex;
|
|
20
|
+
justify-content: space-between;
|
|
21
|
+
align-items: center;
|
|
22
|
+
padding: 24px;
|
|
23
|
+
border-bottom: 1px solid var(--rp-c-divider-light);
|
|
24
|
+
height: 55.5px;
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
font-weight: bold;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.card-body {
|
|
30
|
+
padding: 24px;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.list {
|
|
34
|
+
width: 320px;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.item {
|
|
38
|
+
margin-bottom: 12px;
|
|
39
|
+
font-size: 14px;
|
|
40
|
+
cursor: pointer;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.content {
|
|
44
|
+
margin-right: 0;
|
|
45
|
+
min-width: 500px;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.tag {
|
|
49
|
+
margin: 0 0.2em;
|
|
50
|
+
padding-inline: 0.4em;
|
|
51
|
+
padding-block: 0.2em 0.1em;
|
|
52
|
+
font-size: 85%;
|
|
53
|
+
background: rgba(150, 150, 150, 0.1);
|
|
54
|
+
border: 1px solid rgba(100, 100, 100, 0.2);
|
|
55
|
+
border-radius: 3px;
|
|
56
|
+
font-weight: bold;
|
|
57
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import ReactMarkdown from 'react-markdown';
|
|
3
|
+
import { Rule } from '@rsdoctor/types';
|
|
4
|
+
import styles from './RuleIndex.module.scss';
|
|
5
|
+
const themeDefault = require('@rspress/core/theme');
|
|
6
|
+
|
|
7
|
+
const RuleIndex = () => {
|
|
8
|
+
const rules = Object.values(Rule.RuleErrorMap);
|
|
9
|
+
const [ruleMessage, setRuleMessage] = useState(rules[0] as Rule.RuleMessage);
|
|
10
|
+
|
|
11
|
+
const selectRuleMessage = (message: Rule.RuleMessage) => {
|
|
12
|
+
setRuleMessage(message);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<div className={styles.container}>
|
|
17
|
+
<div className={`${styles.card} ${styles.list}`}>
|
|
18
|
+
<div className={styles['card-header']}>List of the error codes</div>
|
|
19
|
+
<div className={styles['card-body']}>
|
|
20
|
+
{rules.map((item) => (
|
|
21
|
+
<div
|
|
22
|
+
className={styles.item}
|
|
23
|
+
key={item.code}
|
|
24
|
+
onClick={() => selectRuleMessage(item)}
|
|
25
|
+
style={{
|
|
26
|
+
color:
|
|
27
|
+
ruleMessage && item.code === ruleMessage.code
|
|
28
|
+
? 'rgb(24, 144, 255)'
|
|
29
|
+
: undefined,
|
|
30
|
+
}}
|
|
31
|
+
>
|
|
32
|
+
<span className={styles.tag}>
|
|
33
|
+
<a>{item.code}</a>
|
|
34
|
+
</span>
|
|
35
|
+
<span>{item.title}</span>
|
|
36
|
+
</div>
|
|
37
|
+
))}
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
{ruleMessage ? (
|
|
42
|
+
<div className={`${styles.card} ${styles.content}`}>
|
|
43
|
+
<div className={styles['card-header']}>
|
|
44
|
+
<div>
|
|
45
|
+
<span className={styles.tag}>{ruleMessage.code}</span>
|
|
46
|
+
<span>{ruleMessage.title}</span>
|
|
47
|
+
</div>
|
|
48
|
+
<span className={styles.tag}>{ruleMessage.category}</span>
|
|
49
|
+
</div>
|
|
50
|
+
<div className={styles['card-body']} style={{ paddingTop: 0 }}>
|
|
51
|
+
<ReactMarkdown
|
|
52
|
+
components={{
|
|
53
|
+
...themeDefault.getCustomMDXComponent(),
|
|
54
|
+
code: (props) => <code {...props} />,
|
|
55
|
+
}}
|
|
56
|
+
>
|
|
57
|
+
{ruleMessage.description}
|
|
58
|
+
</ReactMarkdown>
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
) : (
|
|
62
|
+
<div className={`${styles.card} ${styles.content}`}>
|
|
63
|
+
<div className={styles['card-header']}>
|
|
64
|
+
This page lists all the error codes emitted by the Rsdoctor.
|
|
65
|
+
</div>
|
|
66
|
+
<div className={styles['card-body']}>
|
|
67
|
+
click the error code in left bar to show more details.
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
)}
|
|
71
|
+
</div>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export default RuleIndex;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
.step {
|
|
2
|
+
border: 1px solid var(--rp-c-bg-soft);
|
|
3
|
+
background-color: var(--rp-c-bg-soft);
|
|
4
|
+
transition:
|
|
5
|
+
color 0.5s,
|
|
6
|
+
background-color 0.5s;
|
|
7
|
+
padding: 28px 36px;
|
|
8
|
+
border-radius: 8px;
|
|
9
|
+
flex: 0 32%;
|
|
10
|
+
font-size: 14px;
|
|
11
|
+
font-weight: 500;
|
|
12
|
+
|
|
13
|
+
&:hover {
|
|
14
|
+
border-color: var(--rp-c-brand);
|
|
15
|
+
transition: border-color 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.title {
|
|
20
|
+
font-size: 20px;
|
|
21
|
+
line-height: 1.4;
|
|
22
|
+
letter-spacing: -0.02em;
|
|
23
|
+
margin: 0 0 0.75em !important;
|
|
24
|
+
display: block;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.description {
|
|
28
|
+
margin: 0 !important;
|
|
29
|
+
line-height: 1.7 !important;
|
|
30
|
+
color: var(--rp-c-text-2);
|
|
31
|
+
transition: color 0.5s;
|
|
32
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useUrl } from '../utils';
|
|
2
|
+
import styles from './Step.module.scss';
|
|
3
|
+
|
|
4
|
+
const Step = (props: { href: string; title: string; description: string }) => {
|
|
5
|
+
return (
|
|
6
|
+
<a className={styles.step} href={useUrl(props.href)}>
|
|
7
|
+
<p className={styles.title}>{props.title}</p>
|
|
8
|
+
<p className={styles.description}>{props.description}</p>
|
|
9
|
+
</a>
|
|
10
|
+
);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default Step;
|
package/src/global.d.ts
ADDED
package/src/utils.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useLang, withBase, usePageData } from 'rspress/runtime';
|
|
2
|
+
|
|
3
|
+
export function useUrl(url: string) {
|
|
4
|
+
const lang = useLang();
|
|
5
|
+
const {
|
|
6
|
+
siteData: { lang: defaultLang },
|
|
7
|
+
} = usePageData();
|
|
8
|
+
return withBase(lang === defaultLang ? url : `/${lang}${url}`);
|
|
9
|
+
}
|