create-packer 1.35.13 → 1.35.15
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/package.json +2 -1
- package/template/cli/biome.json +37 -0
- package/template/cli/package.json +1 -0
- package/template/lib/workspace/.eslintrc +1 -7
- package/template/lib/workspace/biome.json +37 -0
- package/template/lib/workspace/package.json +1 -2
- package/template/lib/workspace/packages/react/.eslintrc +1 -7
- package/template/lib/workspace/packages/react/package.json +0 -2
- package/template/lib/workspace/packages/ts/.eslintrc +1 -7
- package/template/lib/workspace/packages/ts/package.json +0 -1
- package/template/web-app/react-rspack/.env.development +1 -1
- package/template/web-app/react-rspack/.eslintrc +1 -10
- package/template/web-app/react-rspack/.vscode/extensions.json +2 -2
- package/template/web-app/react-rspack/biome.json +37 -0
- package/template/web-app/react-rspack/package.json +2 -3
- package/template/web-app/react-rspack/tsconfig.json +1 -1
- package/template/web-app/react-vite/.eslintrc +1 -10
- package/template/web-app/react-vite/.vscode/extensions.json +8 -8
- package/template/web-app/react-vite/.vscode/settings.json +4 -18
- package/template/web-app/react-vite/biome.json +37 -0
- package/template/web-app/react-vite/domain/app/app.model.ts +7 -7
- package/template/web-app/react-vite/domain/app/app.styled.ts +3 -3
- package/template/web-app/react-vite/domain/app/components/app-context.tsx +17 -17
- package/template/web-app/react-vite/domain/app/components/app.tsx +24 -24
- package/template/web-app/react-vite/domain/app/components/index.ts +1 -1
- package/template/web-app/react-vite/domain/app/index.ts +2 -2
- package/template/web-app/react-vite/domain/router/home/ids.ts +3 -3
- package/template/web-app/react-vite/domain/router/home/index.ts +2 -2
- package/template/web-app/react-vite/domain/router/home/routes.tsx +13 -13
- package/template/web-app/react-vite/domain/router/ids.ts +6 -6
- package/template/web-app/react-vite/domain/router/index.ts +3 -3
- package/template/web-app/react-vite/domain/router/router.tsx +28 -28
- package/template/web-app/react-vite/domain/router/router.types.ts +3 -3
- package/template/web-app/react-vite/main.tsx +4 -4
- package/template/web-app/react-vite/mockUtils.ts +6 -6
- package/template/web-app/react-vite/package.json +79 -80
- package/template/web-app/react-vite/pages/home/home.mock.ts +19 -19
- package/template/web-app/react-vite/pages/home/home.styled.ts +7 -7
- package/template/web-app/react-vite/pages/home/home.tsx +10 -10
- package/template/web-app/react-vite/pages/home/index.ts +1 -1
- package/template/web-app/react-vite/pages/index.tsx +18 -18
- package/template/web-app/react-vite/pages/not-found.tsx +3 -3
- package/template/web-app/react-vite/scripts/createChunks.ts +26 -26
- package/template/web-app/react-vite/scripts/index.ts +1 -1
- package/template/web-app/react-vite/shared/hooks/defineRouter/defineRouter.types.ts +33 -33
- package/template/web-app/react-vite/shared/hooks/defineRouter/index.ts +2 -2
- package/template/web-app/react-vite/shared/hooks/index.ts +6 -6
- package/template/web-app/react-vite/shared/hooks/useInterval.ts +26 -26
- package/template/web-app/react-vite/shared/hooks/useLoadingAction.ts +27 -27
- package/template/web-app/react-vite/shared/hooks/useLowPriorityState.ts +26 -26
- package/template/web-app/react-vite/shared/hooks/useSyncState.ts +15 -15
- package/template/web-app/react-vite/shared/hooks/useVisible.ts +27 -27
- package/template/web-app/react-vite/shared/service/api.ts +1 -1
- package/template/web-app/react-vite/shared/service/home.ts +10 -10
- package/template/web-app/react-vite/shared/service/index.ts +3 -3
- package/template/web-app/react-vite/shared/service/request.ts +5 -5
- package/template/web-app/react-vite/shared/theme/index.ts +1 -1
- package/template/web-app/react-vite/shared/theme/theme.styled.ts +56 -56
- package/template/web-app/react-vite/shared/tools/componentInstance.tsx +80 -80
- package/template/web-app/react-vite/shared/tools/index.ts +1 -1
- package/template/web-app/react-vite/shared/types/index.ts +1 -1
- package/template/web-app/react-vite/shared/types/utils.ts +2 -2
- package/template/web-app/react-vite/tsconfig.json +32 -44
- package/template/web-app/react-vite/tsconfig.node.json +10 -10
- package/template/web-app/react-vite/vite-env.d.ts +18 -18
- package/template/web-app/react-vite/vite.config.ts +76 -76
- package/template/web-app/react-webpack/.eslintrc +1 -10
- package/template/web-app/react-webpack/.vscode/extensions.json +2 -2
- package/template/web-app/react-webpack/biome.json +37 -0
- package/template/web-app/react-webpack/package.json +2 -3
- package/template/web-app/vue/.eslintrc +0 -7
- package/template/web-app/vue/.vscode/extensions.json +9 -9
- package/template/web-app/vue/biome.json +37 -0
- package/template/web-app/vue/domain/app/app.ts +4 -4
- package/template/web-app/vue/domain/app/components/index.ts +1 -1
- package/template/web-app/vue/domain/app/createComponentInstance.ts +44 -44
- package/template/web-app/vue/domain/app/index.ts +3 -3
- package/template/web-app/vue/main.ts +7 -7
- package/template/web-app/vue/mockUtils.ts +6 -6
- package/template/web-app/vue/package.json +2 -3
- package/template/web-app/vue/pages/home/home.mock.ts +19 -19
- package/template/web-app/vue/pages/home/index.ts +1 -1
- package/template/web-app/vue/pages/index.ts +1 -1
- package/template/web-app/vue/router/home/index.ts +2 -2
- package/template/web-app/vue/router/home/names.ts +3 -3
- package/template/web-app/vue/router/home/routes.ts +8 -8
- package/template/web-app/vue/router/index.ts +26 -26
- package/template/web-app/vue/router/names.ts +5 -5
- package/template/web-app/vue/scripts/createChunks.ts +26 -26
- package/template/web-app/vue/scripts/index.ts +1 -1
- package/template/web-app/vue/shared/hooks/index.ts +2 -2
- package/template/web-app/vue/shared/hooks/useList.ts +104 -104
- package/template/web-app/vue/shared/hooks/useVisible.ts +27 -27
- package/template/web-app/vue/shared/service/api.ts +1 -1
- package/template/web-app/vue/shared/service/home.ts +10 -10
- package/template/web-app/vue/shared/service/index.ts +3 -3
- package/template/web-app/vue/shared/service/request.ts +5 -5
- package/template/web-app/vue/style.css +3 -3
- package/template/web-app/vue/tsconfig.json +24 -24
- package/template/web-app/vue/tsconfig.node.json +10 -10
- package/template/web-app/vue/vite-env.d.ts +18 -18
- package/template/web-app/vue/vite.config.ts +65 -65
- package/template/web-extension/.eslintrc +0 -9
- package/template/web-extension/biome.json +37 -0
- package/template/web-extension/package.json +2 -3
- package/template/cli/.prettierignore +0 -6
- package/template/cli/.prettierrc.js +0 -20
- package/template/lib/workspace/.prettierignore +0 -4
- package/template/lib/workspace/.prettierrc +0 -18
- package/template/lib/workspace/packages/react/.prettierignore +0 -4
- package/template/lib/workspace/packages/react/.prettierrc +0 -18
- package/template/lib/workspace/packages/ts/.prettierrc +0 -12
- package/template/web-app/react-rspack/.prettierignore +0 -6
- package/template/web-app/react-rspack/.prettierrc +0 -12
- package/template/web-app/react-vite/.prettierignore +0 -6
- package/template/web-app/react-vite/.prettierrc +0 -12
- package/template/web-app/vue/.prettierignore +0 -6
- package/template/web-app/vue/.prettierrc +0 -12
- package/template/web-extension/.prettierignore +0 -6
- package/template/web-extension/.prettierrc +0 -12
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { lazy } from 'react'
|
|
2
|
-
import { createBrowserRouter } from 'react-router-dom'
|
|
3
|
-
import { defineRouter, routeType } from '@/shared/hooks'
|
|
4
|
-
import ids from './ids'
|
|
5
|
-
import * as home from './home'
|
|
6
|
-
|
|
7
|
-
const routes: routeType[] = [
|
|
8
|
-
{
|
|
9
|
-
path: '/',
|
|
10
|
-
id: ids.root,
|
|
11
|
-
Component: lazy(() => import('@/pages')),
|
|
12
|
-
children: [
|
|
13
|
-
...home.routes,
|
|
14
|
-
{
|
|
15
|
-
path: '*',
|
|
16
|
-
id: ids.notFound,
|
|
17
|
-
Component: lazy(() => import('@/pages/not-found'))
|
|
18
|
-
}
|
|
19
|
-
]
|
|
20
|
-
}
|
|
21
|
-
]
|
|
22
|
-
|
|
23
|
-
export const routerInstance = createBrowserRouter(routes as never, {
|
|
24
|
-
basename: import.meta.env.VITE_BASE_URL
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
export const { useMatchRoutes, useQuery, useRouter, useRoutePermission } =
|
|
28
|
-
defineRouter(routerInstance)
|
|
1
|
+
import { lazy } from 'react'
|
|
2
|
+
import { createBrowserRouter } from 'react-router-dom'
|
|
3
|
+
import { defineRouter, routeType } from '@/shared/hooks'
|
|
4
|
+
import ids from './ids'
|
|
5
|
+
import * as home from './home'
|
|
6
|
+
|
|
7
|
+
const routes: routeType[] = [
|
|
8
|
+
{
|
|
9
|
+
path: '/',
|
|
10
|
+
id: ids.root,
|
|
11
|
+
Component: lazy(() => import('@/pages')),
|
|
12
|
+
children: [
|
|
13
|
+
...home.routes,
|
|
14
|
+
{
|
|
15
|
+
path: '*',
|
|
16
|
+
id: ids.notFound,
|
|
17
|
+
Component: lazy(() => import('@/pages/not-found'))
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
export const routerInstance = createBrowserRouter(routes as never, {
|
|
24
|
+
basename: import.meta.env.VITE_BASE_URL
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
export const { useMatchRoutes, useQuery, useRouter, useRoutePermission } =
|
|
28
|
+
defineRouter(routerInstance)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { routeType as $routeType } from '@/shared/hooks'
|
|
2
|
-
|
|
3
|
-
export type routeType = $routeType
|
|
1
|
+
import { routeType as $routeType } from '@/shared/hooks'
|
|
2
|
+
|
|
3
|
+
export type routeType = $routeType
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createRoot } from 'react-dom/client'
|
|
2
|
-
import { App } from '@/domain/app'
|
|
3
|
-
|
|
4
|
-
createRoot(document.getElementById('root') as HTMLElement).render(<App.Root />)
|
|
1
|
+
import { createRoot } from 'react-dom/client'
|
|
2
|
+
import { App } from '@/domain/app'
|
|
3
|
+
|
|
4
|
+
createRoot(document.getElementById('root') as HTMLElement).render(<App.Root />)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import path from 'node:path'
|
|
2
|
-
import { createDefineMock } from 'vite-plugin-mock-dev-server'
|
|
3
|
-
|
|
4
|
-
export const defineMock = createDefineMock(mock => {
|
|
5
|
-
mock.url = path.join(import.meta.env.VITE_BASE_URL + import.meta.env.VITE_API_HOST, mock.url)
|
|
6
|
-
})
|
|
1
|
+
import path from 'node:path'
|
|
2
|
+
import { createDefineMock } from 'vite-plugin-mock-dev-server'
|
|
3
|
+
|
|
4
|
+
export const defineMock = createDefineMock(mock => {
|
|
5
|
+
mock.url = path.join(import.meta.env.VITE_BASE_URL + import.meta.env.VITE_API_HOST, mock.url)
|
|
6
|
+
})
|
|
@@ -1,80 +1,79 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "react-vite",
|
|
3
|
-
"private": true,
|
|
4
|
-
"version": "0.0.0",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"prepare": "husky install",
|
|
8
|
-
"dev": "vite",
|
|
9
|
-
"build": "tsc --noEmit && vite build",
|
|
10
|
-
"build:analyse": "tsc --noEmit && vite build --mode analyse",
|
|
11
|
-
"preview": "vite preview",
|
|
12
|
-
"up:vite": "pnpm up vite @vitejs/* vite-plugin-* -L",
|
|
13
|
-
"format": "
|
|
14
|
-
"lint": "tsc --noEmit && eslint **/*.{tsx,ts,jsx,js} --no-error-on-unmatched-pattern && stylelint **/*.{css,scss,less,ts,tsx}",
|
|
15
|
-
"lint:fix": "eslint **/*.{tsx,ts,jsx,js} --fix && stylelint **/*.{css,scss,less,ts,tsx} --fix",
|
|
16
|
-
"cz": "cz",
|
|
17
|
-
"push": "npm run commit && git push",
|
|
18
|
-
"commit": "git add . && npm run cz"
|
|
19
|
-
},
|
|
20
|
-
"dependencies": {
|
|
21
|
-
"1k-types": "1.2.0",
|
|
22
|
-
"@tanstack/react-query": "5.51.15",
|
|
23
|
-
"axios": "1.3.6",
|
|
24
|
-
"define-zustand": "3.1.1",
|
|
25
|
-
"immer": "10.0.1",
|
|
26
|
-
"lodash-es": "4.17.21",
|
|
27
|
-
"qs": "6.11.2",
|
|
28
|
-
"react": "18.3.1",
|
|
29
|
-
"react-dom": "18.3.1",
|
|
30
|
-
"react-router-dom": "6.14.0",
|
|
31
|
-
"react-use": "17.5.0",
|
|
32
|
-
"styled-components": "6.1.11",
|
|
33
|
-
"zustand": "4.4.1"
|
|
34
|
-
},
|
|
35
|
-
"devDependencies": {
|
|
36
|
-
"@
|
|
37
|
-
"@commitlint/
|
|
38
|
-
"@commitlint/
|
|
39
|
-
"@
|
|
40
|
-
"@
|
|
41
|
-
"@
|
|
42
|
-
"@types/
|
|
43
|
-
"@types/
|
|
44
|
-
"@types/
|
|
45
|
-
"@types/react
|
|
46
|
-
"@
|
|
47
|
-
"@typescript-eslint/
|
|
48
|
-
"@
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"eslint
|
|
55
|
-
"eslint-
|
|
56
|
-
"eslint-plugin-
|
|
57
|
-
"eslint-plugin-react": "7.33.2",
|
|
58
|
-
"eslint-plugin-react-hooks": "4.6.0",
|
|
59
|
-
"husky": "8.0.3",
|
|
60
|
-
"inquirer": "^8.1.2",
|
|
61
|
-
"postcss": "8.4.35",
|
|
62
|
-
"postcss-import": "16.0.1",
|
|
63
|
-
"postcss-nesting": "12.0.3",
|
|
64
|
-
"postcss-styled-syntax": "0.6.4",
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"stylelint": "
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"vite": "5.
|
|
71
|
-
"vite-plugin-
|
|
72
|
-
"vite-plugin-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "react-vite",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"prepare": "husky install",
|
|
8
|
+
"dev": "vite",
|
|
9
|
+
"build": "tsc --noEmit && vite build",
|
|
10
|
+
"build:analyse": "tsc --noEmit && vite build --mode analyse",
|
|
11
|
+
"preview": "vite preview",
|
|
12
|
+
"up:vite": "pnpm up vite @vitejs/* vite-plugin-* -L",
|
|
13
|
+
"format": "biome format --write",
|
|
14
|
+
"lint": "tsc --noEmit && eslint **/*.{tsx,ts,jsx,js} --no-error-on-unmatched-pattern && stylelint **/*.{css,scss,less,ts,tsx}",
|
|
15
|
+
"lint:fix": "eslint **/*.{tsx,ts,jsx,js} --fix && stylelint **/*.{css,scss,less,ts,tsx} --fix",
|
|
16
|
+
"cz": "cz",
|
|
17
|
+
"push": "npm run commit && git push",
|
|
18
|
+
"commit": "git add . && npm run cz"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"1k-types": "1.2.0",
|
|
22
|
+
"@tanstack/react-query": "5.51.15",
|
|
23
|
+
"axios": "1.3.6",
|
|
24
|
+
"define-zustand": "3.1.1",
|
|
25
|
+
"immer": "10.0.1",
|
|
26
|
+
"lodash-es": "4.17.21",
|
|
27
|
+
"qs": "6.11.2",
|
|
28
|
+
"react": "18.3.1",
|
|
29
|
+
"react-dom": "18.3.1",
|
|
30
|
+
"react-router-dom": "6.14.0",
|
|
31
|
+
"react-use": "17.5.0",
|
|
32
|
+
"styled-components": "6.1.11",
|
|
33
|
+
"zustand": "4.4.1"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@biomejs/biome": "1.9.2",
|
|
37
|
+
"@commitlint/cli": "17.6.1",
|
|
38
|
+
"@commitlint/config-conventional": "17.6.1",
|
|
39
|
+
"@commitlint/cz-commitlint": "17.5.0",
|
|
40
|
+
"@faker-js/faker": "8.4.1",
|
|
41
|
+
"@rollup/plugin-eslint": "9.0.5",
|
|
42
|
+
"@types/lodash-es": "4.17.7",
|
|
43
|
+
"@types/node": "18.16.0",
|
|
44
|
+
"@types/qs": "6.9.7",
|
|
45
|
+
"@types/react": "18.3.3",
|
|
46
|
+
"@types/react-dom": "18.3.0",
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "7.0.2",
|
|
48
|
+
"@typescript-eslint/parser": "7.0.2",
|
|
49
|
+
"@vitejs/plugin-react": "4.3.1",
|
|
50
|
+
"autoprefixer": "10.4.14",
|
|
51
|
+
"babel-plugin-styled-components": "2.1.4",
|
|
52
|
+
"commitizen": "4.3.0",
|
|
53
|
+
"cssnano": "6.0.0",
|
|
54
|
+
"eslint": "8.56.0",
|
|
55
|
+
"eslint-import-resolver-typescript": "3.6.1",
|
|
56
|
+
"eslint-plugin-import": "2.29.1",
|
|
57
|
+
"eslint-plugin-react": "7.33.2",
|
|
58
|
+
"eslint-plugin-react-hooks": "4.6.0",
|
|
59
|
+
"husky": "8.0.3",
|
|
60
|
+
"inquirer": "^8.1.2",
|
|
61
|
+
"postcss": "8.4.35",
|
|
62
|
+
"postcss-import": "16.0.1",
|
|
63
|
+
"postcss-nesting": "12.0.3",
|
|
64
|
+
"postcss-styled-syntax": "0.6.4",
|
|
65
|
+
"rollup-plugin-visualizer": "5.12.0",
|
|
66
|
+
"stylelint": "16.2.1",
|
|
67
|
+
"stylelint-config-standard": "36.0.1",
|
|
68
|
+
"typescript": "5.5.2",
|
|
69
|
+
"vite": "5.3.3",
|
|
70
|
+
"vite-plugin-mock-dev-server": "1.5.1",
|
|
71
|
+
"vite-plugin-stylelint": "5.3.1",
|
|
72
|
+
"vite-plugin-svgr": "4.2.0"
|
|
73
|
+
},
|
|
74
|
+
"config": {
|
|
75
|
+
"commitizen": {
|
|
76
|
+
"path": "@commitlint/cz-commitlint"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { faker } from '@faker-js/faker'
|
|
2
|
-
import { defineMock } from '@/mockUtils'
|
|
3
|
-
import { API } from '@/shared/service'
|
|
4
|
-
|
|
5
|
-
export default defineMock([
|
|
6
|
-
{
|
|
7
|
-
url: API.HOME_DATA,
|
|
8
|
-
body: faker.helpers.multiple(
|
|
9
|
-
() => ({
|
|
10
|
-
id: faker.string.uuid(),
|
|
11
|
-
name: faker.person.fullName(),
|
|
12
|
-
age: faker.number.int({ max: 110 })
|
|
13
|
-
}),
|
|
14
|
-
{
|
|
15
|
-
count: 10
|
|
16
|
-
}
|
|
17
|
-
)
|
|
18
|
-
}
|
|
19
|
-
])
|
|
1
|
+
import { faker } from '@faker-js/faker'
|
|
2
|
+
import { defineMock } from '@/mockUtils'
|
|
3
|
+
import { API } from '@/shared/service'
|
|
4
|
+
|
|
5
|
+
export default defineMock([
|
|
6
|
+
{
|
|
7
|
+
url: API.HOME_DATA,
|
|
8
|
+
body: faker.helpers.multiple(
|
|
9
|
+
() => ({
|
|
10
|
+
id: faker.string.uuid(),
|
|
11
|
+
name: faker.person.fullName(),
|
|
12
|
+
age: faker.number.int({ max: 110 })
|
|
13
|
+
}),
|
|
14
|
+
{
|
|
15
|
+
count: 10
|
|
16
|
+
}
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
])
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import styled, { css } from 'styled-components'
|
|
2
|
-
|
|
3
|
-
export const StyledRoot = styled.div(({ theme }) => {
|
|
4
|
-
return css`
|
|
5
|
-
${theme.tools.flex('center', 'center')};
|
|
6
|
-
`
|
|
7
|
-
})
|
|
1
|
+
import styled, { css } from 'styled-components'
|
|
2
|
+
|
|
3
|
+
export const StyledRoot = styled.div(({ theme }) => {
|
|
4
|
+
return css`
|
|
5
|
+
${theme.tools.flex('center', 'center')};
|
|
6
|
+
`
|
|
7
|
+
})
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { useHomeQuery } from '@/shared/service'
|
|
2
|
-
import { StyledRoot } from './home.styled'
|
|
3
|
-
|
|
4
|
-
export default function Home() {
|
|
5
|
-
const query = useHomeQuery()
|
|
6
|
-
|
|
7
|
-
console.log('data', query.data)
|
|
8
|
-
|
|
9
|
-
return <StyledRoot>sdfs</StyledRoot>
|
|
10
|
-
}
|
|
1
|
+
import { useHomeQuery } from '@/shared/service'
|
|
2
|
+
import { StyledRoot } from './home.styled'
|
|
3
|
+
|
|
4
|
+
export default function Home() {
|
|
5
|
+
const query = useHomeQuery()
|
|
6
|
+
|
|
7
|
+
console.log('data', query.data)
|
|
8
|
+
|
|
9
|
+
return <StyledRoot>sdfs</StyledRoot>
|
|
10
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from './home'
|
|
1
|
+
export { default } from './home'
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { useEffect } from 'react'
|
|
2
|
-
import { Outlet, useLocation } from 'react-router-dom'
|
|
3
|
-
import { useRouter, routerIds } from '@/domain/router'
|
|
4
|
-
|
|
5
|
-
const Layout = () => {
|
|
6
|
-
const location = useLocation()
|
|
7
|
-
const navigate = useRouter(state => state.navigate)
|
|
8
|
-
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
if (location.pathname === '/') {
|
|
11
|
-
navigate({ id: routerIds.home })
|
|
12
|
-
}
|
|
13
|
-
}, [location])
|
|
14
|
-
|
|
15
|
-
return <Outlet />
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export default Layout
|
|
1
|
+
import { useEffect } from 'react'
|
|
2
|
+
import { Outlet, useLocation } from 'react-router-dom'
|
|
3
|
+
import { useRouter, routerIds } from '@/domain/router'
|
|
4
|
+
|
|
5
|
+
const Layout = () => {
|
|
6
|
+
const location = useLocation()
|
|
7
|
+
const navigate = useRouter(state => state.navigate)
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (location.pathname === '/') {
|
|
11
|
+
navigate({ id: routerIds.home })
|
|
12
|
+
}
|
|
13
|
+
}, [location])
|
|
14
|
+
|
|
15
|
+
return <Outlet />
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default Layout
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export default function NotFound() {
|
|
2
|
-
return <div>404</div>
|
|
3
|
-
}
|
|
1
|
+
export default function NotFound() {
|
|
2
|
+
return <div>404</div>
|
|
3
|
+
}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { concat, forEach, isArray, isRegExp, keys, remove, size } from 'lodash-es'
|
|
2
|
-
import pkg from '../package.json'
|
|
3
|
-
|
|
4
|
-
export function createChunks(chunks: { [key: string]: Array<string | RegExp> }) {
|
|
5
|
-
const vendor = keys(pkg.dependencies)
|
|
6
|
-
const result: { [key: string]: string[] } = {}
|
|
7
|
-
|
|
8
|
-
forEach(chunks, (values, key) => {
|
|
9
|
-
if (!isArray(result[key])) {
|
|
10
|
-
result[key] = []
|
|
11
|
-
}
|
|
12
|
-
forEach(values, value => {
|
|
13
|
-
let modules: string[] = []
|
|
14
|
-
if (isRegExp(value)) {
|
|
15
|
-
modules = remove(vendor, name => value.test(name))
|
|
16
|
-
} else {
|
|
17
|
-
modules = remove(vendor, name => name === value)
|
|
18
|
-
}
|
|
19
|
-
if (size(modules) > 0) {
|
|
20
|
-
result[key] = concat(result[key], modules)
|
|
21
|
-
}
|
|
22
|
-
})
|
|
23
|
-
})
|
|
24
|
-
result.vendor = vendor
|
|
25
|
-
return result
|
|
26
|
-
}
|
|
1
|
+
import { concat, forEach, isArray, isRegExp, keys, remove, size } from 'lodash-es'
|
|
2
|
+
import pkg from '../package.json'
|
|
3
|
+
|
|
4
|
+
export function createChunks(chunks: { [key: string]: Array<string | RegExp> }) {
|
|
5
|
+
const vendor = keys(pkg.dependencies)
|
|
6
|
+
const result: { [key: string]: string[] } = {}
|
|
7
|
+
|
|
8
|
+
forEach(chunks, (values, key) => {
|
|
9
|
+
if (!isArray(result[key])) {
|
|
10
|
+
result[key] = []
|
|
11
|
+
}
|
|
12
|
+
forEach(values, value => {
|
|
13
|
+
let modules: string[] = []
|
|
14
|
+
if (isRegExp(value)) {
|
|
15
|
+
modules = remove(vendor, name => value.test(name))
|
|
16
|
+
} else {
|
|
17
|
+
modules = remove(vendor, name => name === value)
|
|
18
|
+
}
|
|
19
|
+
if (size(modules) > 0) {
|
|
20
|
+
result[key] = concat(result[key], modules)
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
})
|
|
24
|
+
result.vendor = vendor
|
|
25
|
+
return result
|
|
26
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './createChunks'
|
|
1
|
+
export * from './createChunks'
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { FunctionComponent, ReactNode } from 'react'
|
|
2
|
-
import { RouteObject } from 'react-router-dom'
|
|
3
|
-
|
|
4
|
-
export type routeType = Omit<RouteObject, 'children' | 'id'> & {
|
|
5
|
-
id: string
|
|
6
|
-
meta?: {
|
|
7
|
-
title?: string
|
|
8
|
-
/** 只在当前路由才显示的小提示 */
|
|
9
|
-
tip?: string
|
|
10
|
-
}
|
|
11
|
-
/** 静态配置,便于回退 */
|
|
12
|
-
unauthorizedOrigin?: boolean
|
|
13
|
-
/** 动态使用,用于程序校验 */
|
|
14
|
-
unauthorized?: boolean
|
|
15
|
-
query?: () => Record<string, any>
|
|
16
|
-
menu?: {
|
|
17
|
-
hidden?: boolean
|
|
18
|
-
icon?: FunctionComponent
|
|
19
|
-
label?: ReactNode
|
|
20
|
-
}
|
|
21
|
-
children?: routeType[]
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export type editableRouteType = Omit<routeType, 'element' | 'errorElement' | 'children'>
|
|
25
|
-
|
|
26
|
-
export interface routerFactoryArgType {
|
|
27
|
-
basename: string
|
|
28
|
-
routes: routeType[]
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export type routeByIdType = Omit<routeType, 'children'> & {
|
|
32
|
-
pos: string
|
|
33
|
-
}
|
|
1
|
+
import { FunctionComponent, ReactNode } from 'react'
|
|
2
|
+
import { RouteObject } from 'react-router-dom'
|
|
3
|
+
|
|
4
|
+
export type routeType = Omit<RouteObject, 'children' | 'id'> & {
|
|
5
|
+
id: string
|
|
6
|
+
meta?: {
|
|
7
|
+
title?: string
|
|
8
|
+
/** 只在当前路由才显示的小提示 */
|
|
9
|
+
tip?: string
|
|
10
|
+
}
|
|
11
|
+
/** 静态配置,便于回退 */
|
|
12
|
+
unauthorizedOrigin?: boolean
|
|
13
|
+
/** 动态使用,用于程序校验 */
|
|
14
|
+
unauthorized?: boolean
|
|
15
|
+
query?: () => Record<string, any>
|
|
16
|
+
menu?: {
|
|
17
|
+
hidden?: boolean
|
|
18
|
+
icon?: FunctionComponent
|
|
19
|
+
label?: ReactNode
|
|
20
|
+
}
|
|
21
|
+
children?: routeType[]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type editableRouteType = Omit<routeType, 'element' | 'errorElement' | 'children'>
|
|
25
|
+
|
|
26
|
+
export interface routerFactoryArgType {
|
|
27
|
+
basename: string
|
|
28
|
+
routes: routeType[]
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type routeByIdType = Omit<routeType, 'children'> & {
|
|
32
|
+
pos: string
|
|
33
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as defineRouter } from './deineRouter'
|
|
2
|
-
export * from './defineRouter.types'
|
|
1
|
+
export { default as defineRouter } from './deineRouter'
|
|
2
|
+
export * from './defineRouter.types'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { default as useLoadingAction } from './useLoadingAction'
|
|
2
|
-
export { default as useInterval } from './useInterval'
|
|
3
|
-
export { default as useVisible } from './useVisible'
|
|
4
|
-
export { default as useLowPriorityState } from './useLowPriorityState'
|
|
5
|
-
export * from './useSyncState'
|
|
6
|
-
export * from './defineRouter'
|
|
1
|
+
export { default as useLoadingAction } from './useLoadingAction'
|
|
2
|
+
export { default as useInterval } from './useInterval'
|
|
3
|
+
export { default as useVisible } from './useVisible'
|
|
4
|
+
export { default as useLowPriorityState } from './useLowPriorityState'
|
|
5
|
+
export * from './useSyncState'
|
|
6
|
+
export * from './defineRouter'
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { useState } from 'react'
|
|
2
|
-
import { useInterval as useRUInterval } from 'react-use'
|
|
3
|
-
|
|
4
|
-
interface actionsType {
|
|
5
|
-
start: () => void
|
|
6
|
-
stop: () => void
|
|
7
|
-
}
|
|
8
|
-
export default function useInterval(
|
|
9
|
-
cb: (actions: actionsType) => Promise<void> | void,
|
|
10
|
-
delay: number
|
|
11
|
-
): actionsType {
|
|
12
|
-
const [startInterval, setStartInterval] = useState(false)
|
|
13
|
-
const start: actionsType['start'] = () => {
|
|
14
|
-
setStartInterval(true)
|
|
15
|
-
}
|
|
16
|
-
const stop: actionsType['stop'] = () => {
|
|
17
|
-
setStartInterval(false)
|
|
18
|
-
}
|
|
19
|
-
useRUInterval(
|
|
20
|
-
async () => {
|
|
21
|
-
cb({ start, stop })
|
|
22
|
-
},
|
|
23
|
-
startInterval ? delay : null
|
|
24
|
-
)
|
|
25
|
-
return { start, stop }
|
|
26
|
-
}
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import { useInterval as useRUInterval } from 'react-use'
|
|
3
|
+
|
|
4
|
+
interface actionsType {
|
|
5
|
+
start: () => void
|
|
6
|
+
stop: () => void
|
|
7
|
+
}
|
|
8
|
+
export default function useInterval(
|
|
9
|
+
cb: (actions: actionsType) => Promise<void> | void,
|
|
10
|
+
delay: number
|
|
11
|
+
): actionsType {
|
|
12
|
+
const [startInterval, setStartInterval] = useState(false)
|
|
13
|
+
const start: actionsType['start'] = () => {
|
|
14
|
+
setStartInterval(true)
|
|
15
|
+
}
|
|
16
|
+
const stop: actionsType['stop'] = () => {
|
|
17
|
+
setStartInterval(false)
|
|
18
|
+
}
|
|
19
|
+
useRUInterval(
|
|
20
|
+
async () => {
|
|
21
|
+
cb({ start, stop })
|
|
22
|
+
},
|
|
23
|
+
startInterval ? delay : null
|
|
24
|
+
)
|
|
25
|
+
return { start, stop }
|
|
26
|
+
}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { useCallback, useState, DependencyList, useRef } from 'react'
|
|
2
|
-
|
|
3
|
-
export default function useLoadingAction<C extends (...arg: any) => Promise<any> | any>(
|
|
4
|
-
callback: C,
|
|
5
|
-
deps: DependencyList,
|
|
6
|
-
debounce = true
|
|
7
|
-
) {
|
|
8
|
-
const [loading, setLoading] = useState(false)
|
|
9
|
-
const loadingSync = useRef(loading)
|
|
10
|
-
function $setLoading(loading: boolean) {
|
|
11
|
-
setLoading(loading)
|
|
12
|
-
loadingSync.current = loading
|
|
13
|
-
}
|
|
14
|
-
const action = useCallback(async (...arg: any) => {
|
|
15
|
-
if (debounce && loadingSync.current) {
|
|
16
|
-
return
|
|
17
|
-
}
|
|
18
|
-
try {
|
|
19
|
-
$setLoading(true)
|
|
20
|
-
return await callback(...arg)
|
|
21
|
-
} finally {
|
|
22
|
-
$setLoading(false)
|
|
23
|
-
}
|
|
24
|
-
}, deps) as C
|
|
25
|
-
|
|
26
|
-
return [loading, action] as const
|
|
27
|
-
}
|
|
1
|
+
import { useCallback, useState, DependencyList, useRef } from 'react'
|
|
2
|
+
|
|
3
|
+
export default function useLoadingAction<C extends (...arg: any) => Promise<any> | any>(
|
|
4
|
+
callback: C,
|
|
5
|
+
deps: DependencyList,
|
|
6
|
+
debounce = true
|
|
7
|
+
) {
|
|
8
|
+
const [loading, setLoading] = useState(false)
|
|
9
|
+
const loadingSync = useRef(loading)
|
|
10
|
+
function $setLoading(loading: boolean) {
|
|
11
|
+
setLoading(loading)
|
|
12
|
+
loadingSync.current = loading
|
|
13
|
+
}
|
|
14
|
+
const action = useCallback(async (...arg: any) => {
|
|
15
|
+
if (debounce && loadingSync.current) {
|
|
16
|
+
return
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
$setLoading(true)
|
|
20
|
+
return await callback(...arg)
|
|
21
|
+
} finally {
|
|
22
|
+
$setLoading(false)
|
|
23
|
+
}
|
|
24
|
+
}, deps) as C
|
|
25
|
+
|
|
26
|
+
return [loading, action] as const
|
|
27
|
+
}
|