create-alistt69-kit 0.3.5 → 0.3.6
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 +20 -20
- package/README.md +189 -189
- package/bin/index.js +24 -24
- package/package.json +44 -44
- package/src/core/apply-features.js +14 -14
- package/src/core/collect-project-info.js +170 -170
- package/src/core/copy-base-template.js +11 -11
- package/src/core/create-project.js +99 -99
- package/src/core/install-dependencies.js +27 -27
- package/src/core/parse-cli-args.js +122 -122
- package/src/core/prepare-target-directory.js +69 -69
- package/src/core/render-project-readme.js +278 -278
- package/src/core/replace-tokens.js +45 -45
- package/src/core/restore-special-files.js +18 -18
- package/src/features/agents-md/files/AGENTS.md +36 -36
- package/src/features/agents-md/index.js +13 -13
- package/src/features/autoprefixer/files/postcss.config.cjs +4 -4
- package/src/features/autoprefixer/index.js +31 -31
- package/src/features/define-feature.js +32 -32
- package/src/features/eslint/files/eslint.config.mjs +135 -135
- package/src/features/eslint/index.js +43 -43
- package/src/features/index.js +28 -28
- package/src/features/prerender/files/prerender.routes.mjs +5 -5
- package/src/features/prerender/files/scripts/prerender.mjs +114 -114
- package/src/features/prerender/index.js +40 -40
- package/src/features/react-router/files/scripts/generate/page.mjs +366 -366
- package/src/features/react-router/files/src/app/App.tsx +18 -18
- package/src/features/react-router/files/src/app/providers/error-boundary/lib/provider/index.tsx +44 -44
- package/src/features/react-router/files/src/app/providers/error-boundary/ui/error-screen/index.tsx +151 -151
- package/src/features/react-router/files/src/app/providers/index.ts +17 -17
- package/src/features/react-router/files/src/app/providers/router/lib/provider/index.tsx +21 -21
- package/src/features/react-router/files/src/app/providers/router/model/router/index.tsx +24 -24
- package/src/features/react-router/files/src/app/providers/router/types/index.ts +10 -10
- package/src/features/react-router/files/src/app/providers/router/ui/app/index.tsx +36 -36
- package/src/features/react-router/files/src/index.tsx +23 -23
- package/src/features/react-router/files/src/pages/error/index.ts +1 -1
- package/src/features/react-router/files/src/pages/error/lazy.ts +3 -3
- package/src/features/react-router/files/src/pages/error/page.tsx +7 -7
- package/src/features/react-router/files/src/pages/main/index.ts +1 -1
- package/src/features/react-router/files/src/pages/main/lazy.ts +3 -3
- package/src/features/react-router/files/src/pages/main/page.tsx +7 -7
- package/src/features/react-router/index.js +36 -36
- package/src/features/stylelint/files/stylelint.config.mjs +13 -13
- package/src/features/stylelint/index.js +37 -37
- package/src/templates/base/.editorconfig +11 -11
- package/src/templates/base/README.md +2 -2
- package/src/templates/base/babel.config.json +12 -12
- package/src/templates/base/gitignore +27 -27
- package/src/templates/base/package.json +48 -48
- package/src/templates/base/public/index.html +12 -12
- package/src/templates/base/src/app/App.tsx +12 -12
- package/src/templates/base/src/app/providers/error-boundary/lib/provider/index.tsx +44 -44
- package/src/templates/base/src/app/providers/error-boundary/ui/error-screen/index.tsx +150 -150
- package/src/templates/base/src/app/providers/index.ts +5 -5
- package/src/templates/base/src/index.tsx +19 -19
- package/src/templates/base/src/styles/index.scss +13 -13
- package/src/templates/base/src/styles/normalize.scss +36 -36
- package/src/templates/base/src/widgets/created-by/index.tsx +1 -1
- package/src/templates/base/tsconfig.json +25 -25
- package/src/utils/agents-md.js +52 -52
- package/src/utils/console-format.js +11 -11
- package/src/utils/package-json.js +96 -96
- package/src/utils/package-manager.js +22 -22
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import CreatedBy from '@/widgets/created-by';
|
|
3
|
-
import styles from './styles.module.scss';
|
|
4
|
-
|
|
5
|
-
interface AppProps {
|
|
6
|
-
router: ReactNode;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function App({ router }: AppProps) {
|
|
10
|
-
return (
|
|
11
|
-
<div className={styles.app_wrapper}>
|
|
12
|
-
{router}
|
|
13
|
-
<CreatedBy />
|
|
14
|
-
</div>
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export default App;
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import CreatedBy from '@/widgets/created-by';
|
|
3
|
+
import styles from './styles.module.scss';
|
|
4
|
+
|
|
5
|
+
interface AppProps {
|
|
6
|
+
router: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function App({ router }: AppProps) {
|
|
10
|
+
return (
|
|
11
|
+
<div className={styles.app_wrapper}>
|
|
12
|
+
{router}
|
|
13
|
+
<CreatedBy />
|
|
14
|
+
</div>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default App;
|
package/src/features/react-router/files/src/app/providers/error-boundary/lib/provider/index.tsx
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import { Component, ErrorInfo, ReactNode } from 'react';
|
|
2
|
-
import ErrorScreen from '../../ui/error-screen';
|
|
3
|
-
|
|
4
|
-
interface ErrorBoundaryProps {
|
|
5
|
-
children: ReactNode;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
interface ErrorBoundaryState {
|
|
9
|
-
hasError: boolean;
|
|
10
|
-
error: Error | null;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
14
|
-
constructor(props: ErrorBoundaryProps) {
|
|
15
|
-
super(props);
|
|
16
|
-
this.state = { hasError: false, error: null };
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
static getDerivedStateFromError(error: Error) {
|
|
20
|
-
return {
|
|
21
|
-
hasError: true,
|
|
22
|
-
error,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
componentDidCatch(error: Error, errorInfo: ErrorInfo) {
|
|
27
|
-
console.error('ErrorBoundary caught:', error, errorInfo);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
public render(): ReactNode {
|
|
31
|
-
if (this.state.hasError) {
|
|
32
|
-
return (
|
|
33
|
-
<ErrorScreen
|
|
34
|
-
errorMessage={this.state.error?.message}
|
|
35
|
-
onRetry={() => window.location.reload()}
|
|
36
|
-
/>
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return this.props.children;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export default ErrorBoundary;
|
|
1
|
+
import { Component, ErrorInfo, ReactNode } from 'react';
|
|
2
|
+
import ErrorScreen from '../../ui/error-screen';
|
|
3
|
+
|
|
4
|
+
interface ErrorBoundaryProps {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface ErrorBoundaryState {
|
|
9
|
+
hasError: boolean;
|
|
10
|
+
error: Error | null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
14
|
+
constructor(props: ErrorBoundaryProps) {
|
|
15
|
+
super(props);
|
|
16
|
+
this.state = { hasError: false, error: null };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static getDerivedStateFromError(error: Error) {
|
|
20
|
+
return {
|
|
21
|
+
hasError: true,
|
|
22
|
+
error,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo) {
|
|
27
|
+
console.error('ErrorBoundary caught:', error, errorInfo);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public render(): ReactNode {
|
|
31
|
+
if (this.state.hasError) {
|
|
32
|
+
return (
|
|
33
|
+
<ErrorScreen
|
|
34
|
+
errorMessage={this.state.error?.message}
|
|
35
|
+
onRetry={() => window.location.reload()}
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return this.props.children;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default ErrorBoundary;
|
package/src/features/react-router/files/src/app/providers/error-boundary/ui/error-screen/index.tsx
CHANGED
|
@@ -1,151 +1,151 @@
|
|
|
1
|
-
interface ErrorScreenProps {
|
|
2
|
-
title?: string;
|
|
3
|
-
description?: string;
|
|
4
|
-
errorMessage?: string;
|
|
5
|
-
onRetry?: () => void;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
function ErrorScreen({
|
|
9
|
-
title = 'Something went wrong',
|
|
10
|
-
description = 'An unexpected error occurred. Try again or reload the page.',
|
|
11
|
-
errorMessage,
|
|
12
|
-
onRetry,
|
|
13
|
-
}: ErrorScreenProps) {
|
|
14
|
-
return (
|
|
15
|
-
<main
|
|
16
|
-
style={{
|
|
17
|
-
minHeight: '100vh',
|
|
18
|
-
display: 'grid',
|
|
19
|
-
placeItems: 'center',
|
|
20
|
-
padding: '24px',
|
|
21
|
-
background:
|
|
22
|
-
'radial-gradient(circle at top, rgba(255,255,255,0.06), transparent 40%), #0b0d12',
|
|
23
|
-
color: '#f5f7fa',
|
|
24
|
-
}}
|
|
25
|
-
>
|
|
26
|
-
<section
|
|
27
|
-
style={{
|
|
28
|
-
width: '100%',
|
|
29
|
-
maxWidth: '560px',
|
|
30
|
-
padding: '32px',
|
|
31
|
-
borderRadius: '24px',
|
|
32
|
-
border: '1px solid rgba(255,255,255,0.08)',
|
|
33
|
-
background: 'rgba(255,255,255,0.04)',
|
|
34
|
-
backdropFilter: 'blur(12px)',
|
|
35
|
-
boxShadow: '0 20px 80px rgba(0,0,0,0.35)',
|
|
36
|
-
}}
|
|
37
|
-
>
|
|
38
|
-
<div
|
|
39
|
-
style={{
|
|
40
|
-
width: '56px',
|
|
41
|
-
height: '56px',
|
|
42
|
-
borderRadius: '16px',
|
|
43
|
-
display: 'grid',
|
|
44
|
-
placeItems: 'center',
|
|
45
|
-
fontSize: '28px',
|
|
46
|
-
background: 'rgba(255,255,255,0.08)',
|
|
47
|
-
marginBottom: '20px',
|
|
48
|
-
}}
|
|
49
|
-
>
|
|
50
|
-
⚠️
|
|
51
|
-
</div>
|
|
52
|
-
|
|
53
|
-
<h1
|
|
54
|
-
style={{
|
|
55
|
-
margin: 0,
|
|
56
|
-
fontSize: '32px',
|
|
57
|
-
lineHeight: 1.1,
|
|
58
|
-
fontWeight: 700,
|
|
59
|
-
}}
|
|
60
|
-
>
|
|
61
|
-
{title}
|
|
62
|
-
</h1>
|
|
63
|
-
|
|
64
|
-
<p
|
|
65
|
-
style={{
|
|
66
|
-
marginTop: '12px',
|
|
67
|
-
marginBottom: 0,
|
|
68
|
-
fontSize: '16px',
|
|
69
|
-
lineHeight: 1.6,
|
|
70
|
-
color: 'rgba(245,247,250,0.78)',
|
|
71
|
-
}}
|
|
72
|
-
>
|
|
73
|
-
{description}
|
|
74
|
-
</p>
|
|
75
|
-
|
|
76
|
-
{errorMessage ? (
|
|
77
|
-
<pre
|
|
78
|
-
style={{
|
|
79
|
-
marginTop: '20px',
|
|
80
|
-
padding: '16px',
|
|
81
|
-
overflowX: 'auto',
|
|
82
|
-
borderRadius: '16px',
|
|
83
|
-
background: 'rgba(0,0,0,0.28)',
|
|
84
|
-
border: '1px solid rgba(255,255,255,0.08)',
|
|
85
|
-
color: '#ffb4b4',
|
|
86
|
-
fontSize: '13px',
|
|
87
|
-
lineHeight: 1.5,
|
|
88
|
-
whiteSpace: 'pre-wrap',
|
|
89
|
-
wordBreak: 'break-word',
|
|
90
|
-
}}
|
|
91
|
-
>
|
|
92
|
-
{errorMessage}
|
|
93
|
-
</pre>
|
|
94
|
-
) : null}
|
|
95
|
-
|
|
96
|
-
<div
|
|
97
|
-
style={{
|
|
98
|
-
display: 'flex',
|
|
99
|
-
gap: '12px',
|
|
100
|
-
flexWrap: 'wrap',
|
|
101
|
-
marginTop: '24px',
|
|
102
|
-
}}
|
|
103
|
-
>
|
|
104
|
-
{onRetry ? (
|
|
105
|
-
<button
|
|
106
|
-
type="button"
|
|
107
|
-
onClick={onRetry}
|
|
108
|
-
style={buttonPrimaryStyle}
|
|
109
|
-
>
|
|
110
|
-
Try again
|
|
111
|
-
</button>
|
|
112
|
-
) : null}
|
|
113
|
-
|
|
114
|
-
<button
|
|
115
|
-
type="button"
|
|
116
|
-
onClick={() => window.location.reload()}
|
|
117
|
-
style={buttonSecondaryStyle}
|
|
118
|
-
>
|
|
119
|
-
Reload page
|
|
120
|
-
</button>
|
|
121
|
-
</div>
|
|
122
|
-
</section>
|
|
123
|
-
</main>
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const buttonBaseStyle: React.CSSProperties = {
|
|
128
|
-
appearance: 'none',
|
|
129
|
-
border: 'none',
|
|
130
|
-
cursor: 'pointer',
|
|
131
|
-
borderRadius: '14px',
|
|
132
|
-
padding: '12px 16px',
|
|
133
|
-
fontSize: '14px',
|
|
134
|
-
fontWeight: 600,
|
|
135
|
-
transition: 'transform 0.15s ease, opacity 0.15s ease',
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
const buttonPrimaryStyle: React.CSSProperties = {
|
|
139
|
-
...buttonBaseStyle,
|
|
140
|
-
background: '#ffffff',
|
|
141
|
-
color: '#0b0d12',
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
const buttonSecondaryStyle: React.CSSProperties = {
|
|
145
|
-
...buttonBaseStyle,
|
|
146
|
-
background: 'rgba(255,255,255,0.08)',
|
|
147
|
-
color: '#f5f7fa',
|
|
148
|
-
border: '1px solid rgba(255,255,255,0.1)',
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
export default ErrorScreen;
|
|
1
|
+
interface ErrorScreenProps {
|
|
2
|
+
title?: string;
|
|
3
|
+
description?: string;
|
|
4
|
+
errorMessage?: string;
|
|
5
|
+
onRetry?: () => void;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function ErrorScreen({
|
|
9
|
+
title = 'Something went wrong',
|
|
10
|
+
description = 'An unexpected error occurred. Try again or reload the page.',
|
|
11
|
+
errorMessage,
|
|
12
|
+
onRetry,
|
|
13
|
+
}: ErrorScreenProps) {
|
|
14
|
+
return (
|
|
15
|
+
<main
|
|
16
|
+
style={{
|
|
17
|
+
minHeight: '100vh',
|
|
18
|
+
display: 'grid',
|
|
19
|
+
placeItems: 'center',
|
|
20
|
+
padding: '24px',
|
|
21
|
+
background:
|
|
22
|
+
'radial-gradient(circle at top, rgba(255,255,255,0.06), transparent 40%), #0b0d12',
|
|
23
|
+
color: '#f5f7fa',
|
|
24
|
+
}}
|
|
25
|
+
>
|
|
26
|
+
<section
|
|
27
|
+
style={{
|
|
28
|
+
width: '100%',
|
|
29
|
+
maxWidth: '560px',
|
|
30
|
+
padding: '32px',
|
|
31
|
+
borderRadius: '24px',
|
|
32
|
+
border: '1px solid rgba(255,255,255,0.08)',
|
|
33
|
+
background: 'rgba(255,255,255,0.04)',
|
|
34
|
+
backdropFilter: 'blur(12px)',
|
|
35
|
+
boxShadow: '0 20px 80px rgba(0,0,0,0.35)',
|
|
36
|
+
}}
|
|
37
|
+
>
|
|
38
|
+
<div
|
|
39
|
+
style={{
|
|
40
|
+
width: '56px',
|
|
41
|
+
height: '56px',
|
|
42
|
+
borderRadius: '16px',
|
|
43
|
+
display: 'grid',
|
|
44
|
+
placeItems: 'center',
|
|
45
|
+
fontSize: '28px',
|
|
46
|
+
background: 'rgba(255,255,255,0.08)',
|
|
47
|
+
marginBottom: '20px',
|
|
48
|
+
}}
|
|
49
|
+
>
|
|
50
|
+
⚠️
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
<h1
|
|
54
|
+
style={{
|
|
55
|
+
margin: 0,
|
|
56
|
+
fontSize: '32px',
|
|
57
|
+
lineHeight: 1.1,
|
|
58
|
+
fontWeight: 700,
|
|
59
|
+
}}
|
|
60
|
+
>
|
|
61
|
+
{title}
|
|
62
|
+
</h1>
|
|
63
|
+
|
|
64
|
+
<p
|
|
65
|
+
style={{
|
|
66
|
+
marginTop: '12px',
|
|
67
|
+
marginBottom: 0,
|
|
68
|
+
fontSize: '16px',
|
|
69
|
+
lineHeight: 1.6,
|
|
70
|
+
color: 'rgba(245,247,250,0.78)',
|
|
71
|
+
}}
|
|
72
|
+
>
|
|
73
|
+
{description}
|
|
74
|
+
</p>
|
|
75
|
+
|
|
76
|
+
{errorMessage ? (
|
|
77
|
+
<pre
|
|
78
|
+
style={{
|
|
79
|
+
marginTop: '20px',
|
|
80
|
+
padding: '16px',
|
|
81
|
+
overflowX: 'auto',
|
|
82
|
+
borderRadius: '16px',
|
|
83
|
+
background: 'rgba(0,0,0,0.28)',
|
|
84
|
+
border: '1px solid rgba(255,255,255,0.08)',
|
|
85
|
+
color: '#ffb4b4',
|
|
86
|
+
fontSize: '13px',
|
|
87
|
+
lineHeight: 1.5,
|
|
88
|
+
whiteSpace: 'pre-wrap',
|
|
89
|
+
wordBreak: 'break-word',
|
|
90
|
+
}}
|
|
91
|
+
>
|
|
92
|
+
{errorMessage}
|
|
93
|
+
</pre>
|
|
94
|
+
) : null}
|
|
95
|
+
|
|
96
|
+
<div
|
|
97
|
+
style={{
|
|
98
|
+
display: 'flex',
|
|
99
|
+
gap: '12px',
|
|
100
|
+
flexWrap: 'wrap',
|
|
101
|
+
marginTop: '24px',
|
|
102
|
+
}}
|
|
103
|
+
>
|
|
104
|
+
{onRetry ? (
|
|
105
|
+
<button
|
|
106
|
+
type="button"
|
|
107
|
+
onClick={onRetry}
|
|
108
|
+
style={buttonPrimaryStyle}
|
|
109
|
+
>
|
|
110
|
+
Try again
|
|
111
|
+
</button>
|
|
112
|
+
) : null}
|
|
113
|
+
|
|
114
|
+
<button
|
|
115
|
+
type="button"
|
|
116
|
+
onClick={() => window.location.reload()}
|
|
117
|
+
style={buttonSecondaryStyle}
|
|
118
|
+
>
|
|
119
|
+
Reload page
|
|
120
|
+
</button>
|
|
121
|
+
</div>
|
|
122
|
+
</section>
|
|
123
|
+
</main>
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const buttonBaseStyle: React.CSSProperties = {
|
|
128
|
+
appearance: 'none',
|
|
129
|
+
border: 'none',
|
|
130
|
+
cursor: 'pointer',
|
|
131
|
+
borderRadius: '14px',
|
|
132
|
+
padding: '12px 16px',
|
|
133
|
+
fontSize: '14px',
|
|
134
|
+
fontWeight: 600,
|
|
135
|
+
transition: 'transform 0.15s ease, opacity 0.15s ease',
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const buttonPrimaryStyle: React.CSSProperties = {
|
|
139
|
+
...buttonBaseStyle,
|
|
140
|
+
background: '#ffffff',
|
|
141
|
+
color: '#0b0d12',
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const buttonSecondaryStyle: React.CSSProperties = {
|
|
145
|
+
...buttonBaseStyle,
|
|
146
|
+
background: 'rgba(255,255,255,0.08)',
|
|
147
|
+
color: '#f5f7fa',
|
|
148
|
+
border: '1px solid rgba(255,255,255,0.1)',
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export default ErrorScreen;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import ErrorBoundary from './error-boundary/lib/provider';
|
|
2
|
-
import { useGetCurrentRouteConfig } from './router/lib/hooks/useGetCurrentRouteConfig';
|
|
3
|
-
import RouterProvider from './router/lib/provider';
|
|
4
|
-
import { routesConfig } from './router/model/config';
|
|
5
|
-
import { ERoutePath, IRouteConfig } from './router/types';
|
|
6
|
-
|
|
7
|
-
export {
|
|
8
|
-
// Router
|
|
9
|
-
ERoutePath,
|
|
10
|
-
IRouteConfig,
|
|
11
|
-
routesConfig,
|
|
12
|
-
RouterProvider,
|
|
13
|
-
useGetCurrentRouteConfig,
|
|
14
|
-
|
|
15
|
-
// Error Boundary
|
|
16
|
-
ErrorBoundary,
|
|
17
|
-
};
|
|
1
|
+
import ErrorBoundary from './error-boundary/lib/provider';
|
|
2
|
+
import { useGetCurrentRouteConfig } from './router/lib/hooks/useGetCurrentRouteConfig';
|
|
3
|
+
import RouterProvider from './router/lib/provider';
|
|
4
|
+
import { routesConfig } from './router/model/config';
|
|
5
|
+
import { ERoutePath, IRouteConfig } from './router/types';
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
// Router
|
|
9
|
+
ERoutePath,
|
|
10
|
+
IRouteConfig,
|
|
11
|
+
routesConfig,
|
|
12
|
+
RouterProvider,
|
|
13
|
+
useGetCurrentRouteConfig,
|
|
14
|
+
|
|
15
|
+
// Error Boundary
|
|
16
|
+
ErrorBoundary,
|
|
17
|
+
};
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { ComponentType, ReactNode, useMemo } from 'react';
|
|
2
|
-
import { RouterProvider as RouterDomProvider } from 'react-router-dom';
|
|
3
|
-
import { getRouter } from '../../model/router';
|
|
4
|
-
|
|
5
|
-
interface RouterProviderProps {
|
|
6
|
-
errorBoundary: ComponentType<{ children: ReactNode }>;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function RouterProvider({ errorBoundary }: RouterProviderProps) {
|
|
10
|
-
const router = useMemo(() => (
|
|
11
|
-
getRouter(errorBoundary)
|
|
12
|
-
), [errorBoundary]);
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<RouterDomProvider
|
|
16
|
-
router={router}
|
|
17
|
-
/>
|
|
18
|
-
);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export default RouterProvider;
|
|
1
|
+
import { ComponentType, ReactNode, useMemo } from 'react';
|
|
2
|
+
import { RouterProvider as RouterDomProvider } from 'react-router-dom';
|
|
3
|
+
import { getRouter } from '../../model/router';
|
|
4
|
+
|
|
5
|
+
interface RouterProviderProps {
|
|
6
|
+
errorBoundary: ComponentType<{ children: ReactNode }>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function RouterProvider({ errorBoundary }: RouterProviderProps) {
|
|
10
|
+
const router = useMemo(() => (
|
|
11
|
+
getRouter(errorBoundary)
|
|
12
|
+
), [errorBoundary]);
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<RouterDomProvider
|
|
16
|
+
router={router}
|
|
17
|
+
/>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default RouterProvider;
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { ComponentType, ReactNode } from 'react';
|
|
2
|
-
import { createBrowserRouter, createRoutesFromElements, Route } from 'react-router-dom';
|
|
3
|
-
import { ERoutePath } from '../../types';
|
|
4
|
-
import { Error } from '../../../../../pages/error';
|
|
5
|
-
import { Main } from '../../../../../pages/main'; // todo: @
|
|
6
|
-
/* @route-imports */
|
|
7
|
-
import AppLayout from '../../ui/app';
|
|
8
|
-
|
|
9
|
-
export const getRouter = (ErrorBoundary: ComponentType<{ children: ReactNode }>) => createBrowserRouter(
|
|
10
|
-
createRoutesFromElements(
|
|
11
|
-
<Route
|
|
12
|
-
path="/"
|
|
13
|
-
element={(
|
|
14
|
-
<ErrorBoundary>
|
|
15
|
-
<AppLayout />
|
|
16
|
-
</ErrorBoundary>
|
|
17
|
-
)}
|
|
18
|
-
>
|
|
19
|
-
<Route index element={<Main />} />
|
|
20
|
-
{/* @route-routes */}
|
|
21
|
-
<Route path={ERoutePath.ERROR} element={<Error />} />
|
|
22
|
-
</Route>,
|
|
23
|
-
),
|
|
24
|
-
);
|
|
1
|
+
import { ComponentType, ReactNode } from 'react';
|
|
2
|
+
import { createBrowserRouter, createRoutesFromElements, Route } from 'react-router-dom';
|
|
3
|
+
import { ERoutePath } from '../../types';
|
|
4
|
+
import { Error } from '../../../../../pages/error';
|
|
5
|
+
import { Main } from '../../../../../pages/main'; // todo: @
|
|
6
|
+
/* @route-imports */
|
|
7
|
+
import AppLayout from '../../ui/app';
|
|
8
|
+
|
|
9
|
+
export const getRouter = (ErrorBoundary: ComponentType<{ children: ReactNode }>) => createBrowserRouter(
|
|
10
|
+
createRoutesFromElements(
|
|
11
|
+
<Route
|
|
12
|
+
path="/"
|
|
13
|
+
element={(
|
|
14
|
+
<ErrorBoundary>
|
|
15
|
+
<AppLayout />
|
|
16
|
+
</ErrorBoundary>
|
|
17
|
+
)}
|
|
18
|
+
>
|
|
19
|
+
<Route index element={<Main />} />
|
|
20
|
+
{/* @route-routes */}
|
|
21
|
+
<Route path={ERoutePath.ERROR} element={<Error />} />
|
|
22
|
+
</Route>,
|
|
23
|
+
),
|
|
24
|
+
);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export enum ERoutePath {
|
|
2
|
-
MAIN = '',
|
|
3
|
-
// @route-enum
|
|
4
|
-
ERROR = '*',
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface IRouteConfig {
|
|
8
|
-
path: ERoutePath;
|
|
9
|
-
title: string;
|
|
10
|
-
}
|
|
1
|
+
export enum ERoutePath {
|
|
2
|
+
MAIN = '',
|
|
3
|
+
// @route-enum
|
|
4
|
+
ERROR = '*',
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface IRouteConfig {
|
|
8
|
+
path: ERoutePath;
|
|
9
|
+
title: string;
|
|
10
|
+
}
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import clsx from 'clsx';
|
|
2
|
-
import { NavLink, Outlet } from 'react-router-dom';
|
|
3
|
-
import styles from './styles.module.scss';
|
|
4
|
-
|
|
5
|
-
export default function AppLayout() {
|
|
6
|
-
return (
|
|
7
|
-
<div className={styles.layout_wrapper}>
|
|
8
|
-
<aside className={styles.sidebar}>
|
|
9
|
-
<nav>
|
|
10
|
-
<NavLink
|
|
11
|
-
className={({ isActive }) => clsx({
|
|
12
|
-
[styles.active]: isActive,
|
|
13
|
-
})}
|
|
14
|
-
to="/"
|
|
15
|
-
>
|
|
16
|
-
Main
|
|
17
|
-
</NavLink>
|
|
18
|
-
</nav>
|
|
19
|
-
<nav>
|
|
20
|
-
<NavLink
|
|
21
|
-
className={({ isActive }) => clsx({
|
|
22
|
-
[styles.active]: isActive,
|
|
23
|
-
})}
|
|
24
|
-
to="/error-route"
|
|
25
|
-
>
|
|
26
|
-
Error
|
|
27
|
-
</NavLink>
|
|
28
|
-
</nav>
|
|
29
|
-
</aside>
|
|
30
|
-
|
|
31
|
-
<main>
|
|
32
|
-
<Outlet />
|
|
33
|
-
</main>
|
|
34
|
-
</div>
|
|
35
|
-
);
|
|
36
|
-
}
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import { NavLink, Outlet } from 'react-router-dom';
|
|
3
|
+
import styles from './styles.module.scss';
|
|
4
|
+
|
|
5
|
+
export default function AppLayout() {
|
|
6
|
+
return (
|
|
7
|
+
<div className={styles.layout_wrapper}>
|
|
8
|
+
<aside className={styles.sidebar}>
|
|
9
|
+
<nav>
|
|
10
|
+
<NavLink
|
|
11
|
+
className={({ isActive }) => clsx({
|
|
12
|
+
[styles.active]: isActive,
|
|
13
|
+
})}
|
|
14
|
+
to="/"
|
|
15
|
+
>
|
|
16
|
+
Main
|
|
17
|
+
</NavLink>
|
|
18
|
+
</nav>
|
|
19
|
+
<nav>
|
|
20
|
+
<NavLink
|
|
21
|
+
className={({ isActive }) => clsx({
|
|
22
|
+
[styles.active]: isActive,
|
|
23
|
+
})}
|
|
24
|
+
to="/error-route"
|
|
25
|
+
>
|
|
26
|
+
Error
|
|
27
|
+
</NavLink>
|
|
28
|
+
</nav>
|
|
29
|
+
</aside>
|
|
30
|
+
|
|
31
|
+
<main>
|
|
32
|
+
<Outlet />
|
|
33
|
+
</main>
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
}
|