create-packer 1.38.2 → 1.39.1
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 +4 -5
- package/template/docusaurus/package.json +1 -1
- package/template/{web-app/react-vite/.eslintignore → lib/workspace/.stylelintignore} +2 -0
- package/template/lib/workspace/.stylelintrc +4 -9
- package/template/lib/workspace/eslint.config.mjs +116 -0
- package/template/lib/workspace/package.json +81 -73
- package/template/lib/workspace/packages/react/package.json +41 -41
- package/template/lib/workspace/packages/react/tsconfig.json +3 -8
- package/template/lib/workspace/packages/react/tsconfig.lint.json +21 -0
- package/template/lib/workspace/packages/ts/package.json +29 -29
- package/template/lib/workspace/packages/ts/tsconfig.json +9 -6
- package/template/lib/workspace/packages/ts/tsconfig.lint.json +21 -0
- package/template/nest/package.json +82 -84
- package/template/web-app/react-rsbuild/domain/app/components/app-context.tsx +17 -17
- package/template/web-app/react-rsbuild/domain/router/components/index.ts +2 -0
- package/template/web-app/react-rsbuild/domain/router/components/route-layout.tsx +19 -0
- package/template/web-app/react-rsbuild/domain/router/components/sub-route-outlet.tsx +22 -0
- package/template/web-app/react-rsbuild/domain/router/index.ts +4 -3
- package/template/web-app/react-rsbuild/eslint.config.js +104 -0
- package/template/web-app/react-rsbuild/package.json +78 -79
- package/template/web-app/react-rsbuild/pages/home/index.ts +1 -1
- package/template/web-app/react-rsbuild/pages/home/{home.styled.ts → view.styled.ts} +7 -7
- package/template/web-app/react-rsbuild/pages/home/{home.tsx → view.tsx} +10 -10
- package/template/web-app/{react-vite/shared/tools → react-rsbuild/shared/components}/componentInstance.tsx +80 -80
- package/template/web-app/react-rsbuild/shared/components/index.ts +1 -0
- package/template/web-app/react-rsbuild/shared/service/home.ts +8 -8
- package/template/web-app/react-rsbuild/shared/theme/theme.styled.ts +56 -56
- package/template/web-app/react-rsbuild/shared/tools/index.ts +0 -1
- package/template/web-app/react-vite/domain/router/components/index.ts +2 -0
- package/template/web-app/react-vite/domain/router/components/route-layout.tsx +19 -0
- package/template/web-app/react-vite/domain/router/components/sub-route-outlet.tsx +22 -0
- package/template/web-app/react-vite/domain/router/index.ts +4 -3
- package/template/web-app/react-vite/eslint.config.js +104 -0
- package/template/web-app/react-vite/package.json +79 -79
- package/template/web-app/react-vite/pages/home/index.ts +1 -1
- package/template/web-app/react-vite/pages/home/{home.mock.ts → view.mock.ts} +19 -19
- package/template/web-app/{react-webpack/pages/home/home.styled.ts → react-vite/pages/home/view.styled.ts} +7 -7
- package/template/web-app/react-vite/pages/home/{home.tsx → view.tsx} +10 -10
- package/template/web-app/{react-rsbuild/shared/tools → react-vite/shared/components}/componentInstance.tsx +80 -80
- package/template/web-app/react-vite/shared/components/index.ts +1 -0
- package/template/web-app/react-vite/shared/service/home.ts +10 -10
- package/template/web-app/react-vite/shared/theme/theme.styled.ts +55 -56
- package/template/web-app/react-vite/shared/tools/index.ts +0 -1
- package/template/web-app/react-vite/vite.config.ts +80 -76
- package/template/web-app/react-webpack/domain/router/components/index.ts +2 -0
- package/template/web-app/react-webpack/domain/router/components/route-layout.tsx +19 -0
- package/template/web-app/react-webpack/domain/router/components/sub-route-outlet.tsx +22 -0
- package/template/web-app/react-webpack/domain/router/index.ts +4 -3
- package/template/web-app/react-webpack/eslint.config.js +104 -0
- package/template/web-app/react-webpack/package.json +84 -87
- package/template/web-app/react-webpack/pages/home/index.ts +1 -1
- package/template/web-app/{react-vite/pages/home/home.styled.ts → react-webpack/pages/home/view.styled.ts} +7 -7
- package/template/web-app/react-webpack/pages/home/{home.tsx → view.tsx} +10 -10
- package/template/web-app/react-webpack/shared/{tools → components}/componentInstance.tsx +78 -78
- package/template/web-app/react-webpack/shared/components/index.ts +1 -0
- package/template/web-app/react-webpack/shared/theme/theme.styled.ts +56 -56
- package/template/web-app/react-webpack/shared/tools/index.ts +0 -1
- package/template/web-app/solid/package.json +53 -51
- package/template/web-app/solid/src/pages/home/index.ts +1 -1
- package/template/web-app/solid/src/pages/home/{home.container.tsx → view.tsx} +5 -5
- package/template/web-app/solid/src/pages/notFound/index.ts +1 -1
- package/template/web-app/solid/src/pages/notFound/{notFound.container.tsx → view.tsx} +3 -3
- package/template/web-app/svelte/.prettierrc +21 -14
- package/template/web-app/svelte/.svelte-kit/ambient.d.ts +181 -177
- package/template/web-app/svelte/.svelte-kit/generated/client/app.js +28 -23
- package/template/web-app/svelte/.svelte-kit/generated/client/matchers.js +1 -1
- package/template/web-app/svelte/.svelte-kit/generated/client/nodes/0.js +1 -1
- package/template/web-app/svelte/.svelte-kit/generated/client/nodes/1.js +1 -1
- package/template/web-app/svelte/.svelte-kit/generated/client/nodes/2.js +1 -1
- package/template/web-app/svelte/.svelte-kit/generated/root.js +3 -0
- package/template/web-app/svelte/.svelte-kit/generated/root.svelte +66 -62
- package/template/web-app/svelte/.svelte-kit/generated/server/internal.js +49 -61
- package/template/web-app/svelte/.svelte-kit/non-ambient.d.ts +25 -23
- package/template/web-app/svelte/.svelte-kit/tsconfig.json +49 -32
- package/template/web-app/svelte/.svelte-kit/types/route_meta_data.json +3 -3
- package/template/web-app/svelte/.svelte-kit/types/src/routes/$types.d.ts +22 -35
- package/template/web-app/svelte/eslint.config.js +95 -0
- package/template/web-app/svelte/package.json +55 -55
- package/template/web-app/svelte/src/app.d.ts +13 -12
- package/template/web-app/svelte/src/app.html +2 -2
- package/template/web-app/svelte/src/lib/index.ts +1 -0
- package/template/web-app/svelte/src/routes/+page.svelte +2 -2
- package/template/web-app/svelte/vite.config.ts +59 -55
- package/template/web-app/vue/eslint.config.js +109 -0
- package/template/web-app/vue/package.json +70 -70
- package/template/web-app/vue/pages/home/index.ts +1 -1
- package/template/web-app/vue/pages/home/{home.mock.ts → view.mock.ts} +19 -19
- package/template/web-app/vue/pages/home/{home.vue → view.vue} +16 -16
- package/template/web-app/vue/vite.config.ts +69 -65
- package/template/web-extension/.wxt/eslint-auto-imports.mjs +28 -0
- package/template/web-extension/.wxt/tsconfig.json +28 -25
- package/template/web-extension/.wxt/types/globals.d.ts +15 -15
- package/template/web-extension/.wxt/types/i18n.d.ts +81 -87
- package/template/web-extension/.wxt/types/imports.d.ts +22 -21
- package/template/web-extension/.wxt/types/paths.d.ts +16 -15
- package/template/web-extension/.wxt/wxt.d.ts +7 -6
- package/template/web-extension/entrypoints/content/domain/app/tools/insertApp.tsx +2 -3
- package/template/web-extension/entrypoints/content/index.tsx +10 -12
- package/template/web-extension/entrypoints/popup/main.tsx +14 -14
- package/template/web-extension/entrypoints/popup/{popup.container.tsx → popup.tsx} +3 -3
- package/template/web-extension/eslint.config.js +106 -0
- package/template/web-extension/package.json +84 -86
- package/template/web-extension/shared/content/constant.ts +1 -0
- package/template/web-extension/shared/content/index.ts +2 -1
- package/template/web-extension/shared/content/message.ts +25 -15
- package/template/web-extension/shared/styles/theme.styled.ts +56 -56
- package/template/web-extension/shared/tools/message.ts +70 -80
- package/template/web-extension/tsconfig.json +32 -32
- package/template/web-extension/vite-env.d.ts +20 -19
- package/template/web-extension/wxt.config.ts +43 -50
- package/template/lib/workspace/.eslintrc +0 -111
- package/template/lib/workspace/packages/react/.eslintrc +0 -111
- package/template/lib/workspace/packages/react/.stylelintrc +0 -29
- package/template/web-app/react-rsbuild/.eslintignore +0 -4
- package/template/web-app/react-rsbuild/.eslintrc +0 -111
- package/template/web-app/react-vite/.eslintrc +0 -110
- package/template/web-app/react-webpack/.eslintignore +0 -4
- package/template/web-app/react-webpack/.eslintrc +0 -110
- package/template/web-app/svelte/.eslintignore +0 -13
- package/template/web-app/svelte/.eslintrc +0 -76
- package/template/web-app/vue/.eslintignore +0 -4
- package/template/web-app/vue/.eslintrc +0 -97
- package/template/web-extension/.eslintignore +0 -4
- package/template/web-extension/.eslintrc +0 -110
- /package/template/web-app/solid/src/pages/home/{home.css → view.css} +0 -0
|
@@ -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 './
|
|
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 './view.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,80 +1,80 @@
|
|
|
1
|
-
import {
|
|
2
|
-
forwardRef,
|
|
3
|
-
ForwardRefExoticComponent,
|
|
4
|
-
FunctionComponent,
|
|
5
|
-
PropsWithChildren,
|
|
6
|
-
PropsWithoutRef,
|
|
7
|
-
RefAttributes,
|
|
8
|
-
useImperativeHandle,
|
|
9
|
-
useRef,
|
|
10
|
-
useState
|
|
11
|
-
} from 'react'
|
|
12
|
-
import { createRoot } from 'react-dom/client'
|
|
13
|
-
|
|
14
|
-
const instanceMap: Record<string, { pending: Promise<any>; instance: any }> = {}
|
|
15
|
-
|
|
16
|
-
export interface refsType<P> {
|
|
17
|
-
$setProps: (newProps: P) => void
|
|
18
|
-
$updateProps: (newProps: Partial<P>) => void
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function create(Context?: FunctionComponent<PropsWithChildren<any>>) {
|
|
22
|
-
return async function <P extends Record<string, any>, Refs extends Record<string, any>>(
|
|
23
|
-
key: string,
|
|
24
|
-
Component: ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<Refs>>,
|
|
25
|
-
props?: P
|
|
26
|
-
) {
|
|
27
|
-
let current = instanceMap[key]
|
|
28
|
-
if (!current) {
|
|
29
|
-
const div = document.createElement('div')
|
|
30
|
-
document.body.appendChild(div)
|
|
31
|
-
const ApiComponent = forwardRef<Refs & refsType<P>>((__, refs) => {
|
|
32
|
-
const ref = useRef<Refs>(null)
|
|
33
|
-
const [state, setState] = useState<Partial<P>>(props || {})
|
|
34
|
-
|
|
35
|
-
useImperativeHandle(refs, () => {
|
|
36
|
-
return {
|
|
37
|
-
$setProps: newProps => {
|
|
38
|
-
setState(() => newProps)
|
|
39
|
-
},
|
|
40
|
-
$updateProps: newProps => {
|
|
41
|
-
if (newProps) {
|
|
42
|
-
setState(state => ({ ...state, ...newProps }))
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
...ref.current
|
|
46
|
-
} as Refs & refsType<P>
|
|
47
|
-
})
|
|
48
|
-
if (Context) {
|
|
49
|
-
return (
|
|
50
|
-
<Context>
|
|
51
|
-
<Component ref={ref} {...(state as any)} />
|
|
52
|
-
</Context>
|
|
53
|
-
)
|
|
54
|
-
}
|
|
55
|
-
return <Component ref={ref} {...(state as any)} />
|
|
56
|
-
})
|
|
57
|
-
current = instanceMap[key] = {
|
|
58
|
-
instance: void 0,
|
|
59
|
-
pending: new Promise<void>(resolve => {
|
|
60
|
-
createRoot(div).render(
|
|
61
|
-
(
|
|
62
|
-
<ApiComponent
|
|
63
|
-
ref={instance => {
|
|
64
|
-
current.instance = instanceMap[key].instance = instance!
|
|
65
|
-
resolve()
|
|
66
|
-
}}
|
|
67
|
-
/>
|
|
68
|
-
) as never
|
|
69
|
-
)
|
|
70
|
-
})
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
await current.pending
|
|
74
|
-
|
|
75
|
-
// Delay return to avoid sync issue
|
|
76
|
-
// ------------------------------------------------------------------------
|
|
77
|
-
await new Promise(resolve => setTimeout(resolve))
|
|
78
|
-
return current.instance as Refs & refsType<P>
|
|
79
|
-
}
|
|
80
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
forwardRef,
|
|
3
|
+
ForwardRefExoticComponent,
|
|
4
|
+
FunctionComponent,
|
|
5
|
+
PropsWithChildren,
|
|
6
|
+
PropsWithoutRef,
|
|
7
|
+
RefAttributes,
|
|
8
|
+
useImperativeHandle,
|
|
9
|
+
useRef,
|
|
10
|
+
useState
|
|
11
|
+
} from 'react'
|
|
12
|
+
import { createRoot } from 'react-dom/client'
|
|
13
|
+
|
|
14
|
+
const instanceMap: Record<string, { pending: Promise<any>; instance: any }> = {}
|
|
15
|
+
|
|
16
|
+
export interface refsType<P> {
|
|
17
|
+
$setProps: (newProps: P) => void
|
|
18
|
+
$updateProps: (newProps: Partial<P>) => void
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function create(Context?: FunctionComponent<PropsWithChildren<any>>) {
|
|
22
|
+
return async function <P extends Record<string, any>, Refs extends Record<string, any>>(
|
|
23
|
+
key: string,
|
|
24
|
+
Component: ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<Refs>>,
|
|
25
|
+
props?: P
|
|
26
|
+
) {
|
|
27
|
+
let current = instanceMap[key]
|
|
28
|
+
if (!current) {
|
|
29
|
+
const div = document.createElement('div')
|
|
30
|
+
document.body.appendChild(div)
|
|
31
|
+
const ApiComponent = forwardRef<Refs & refsType<P>>((__, refs) => {
|
|
32
|
+
const ref = useRef<Refs>(null)
|
|
33
|
+
const [state, setState] = useState<Partial<P>>(props || {})
|
|
34
|
+
|
|
35
|
+
useImperativeHandle(refs, () => {
|
|
36
|
+
return {
|
|
37
|
+
$setProps: newProps => {
|
|
38
|
+
setState(() => newProps)
|
|
39
|
+
},
|
|
40
|
+
$updateProps: newProps => {
|
|
41
|
+
if (newProps) {
|
|
42
|
+
setState(state => ({ ...state, ...newProps }))
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
...ref.current
|
|
46
|
+
} as Refs & refsType<P>
|
|
47
|
+
})
|
|
48
|
+
if (Context) {
|
|
49
|
+
return (
|
|
50
|
+
<Context>
|
|
51
|
+
<Component ref={ref} {...(state as any)} />
|
|
52
|
+
</Context>
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
return <Component ref={ref} {...(state as any)} />
|
|
56
|
+
})
|
|
57
|
+
current = instanceMap[key] = {
|
|
58
|
+
instance: void 0,
|
|
59
|
+
pending: new Promise<void>(resolve => {
|
|
60
|
+
createRoot(div).render(
|
|
61
|
+
(
|
|
62
|
+
<ApiComponent
|
|
63
|
+
ref={instance => {
|
|
64
|
+
current.instance = instanceMap[key].instance = instance!
|
|
65
|
+
resolve()
|
|
66
|
+
}}
|
|
67
|
+
/>
|
|
68
|
+
) as never
|
|
69
|
+
)
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
await current.pending
|
|
74
|
+
current.instance.$setProps(props)
|
|
75
|
+
// Delay return to avoid sync issue
|
|
76
|
+
// ------------------------------------------------------------------------
|
|
77
|
+
await new Promise(resolve => setTimeout(resolve))
|
|
78
|
+
return current.instance as Refs & refsType<P>
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as componentInstance from './componentInstance'
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { useQuery } from '@tanstack/react-query'
|
|
2
|
-
import { request } from './request'
|
|
3
|
-
import { HOME_DATA } from './api'
|
|
4
|
-
|
|
5
|
-
export function useHomeQuery() {
|
|
6
|
-
return useQuery({
|
|
7
|
-
queryKey: ['home_data'],
|
|
8
|
-
queryFn: () => request.post(HOME_DATA)
|
|
9
|
-
})
|
|
10
|
-
}
|
|
1
|
+
import { useQuery } from '@tanstack/react-query'
|
|
2
|
+
import { request } from './request'
|
|
3
|
+
import { HOME_DATA } from './api'
|
|
4
|
+
|
|
5
|
+
export function useHomeQuery() {
|
|
6
|
+
return useQuery({
|
|
7
|
+
queryKey: ['home_data'],
|
|
8
|
+
queryFn: () => request.post(HOME_DATA)
|
|
9
|
+
})
|
|
10
|
+
}
|
|
@@ -1,56 +1,55 @@
|
|
|
1
|
-
import { CSSProperties } from 'react'
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
'-webkit-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}),
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
export type themeType = typeof theme
|
|
1
|
+
import { CSSProperties } from 'react'
|
|
2
|
+
import { isString } from 'lodash-es'
|
|
3
|
+
|
|
4
|
+
export const theme = {
|
|
5
|
+
tools: {
|
|
6
|
+
ellipsis: () => ({
|
|
7
|
+
overflow: 'hidden',
|
|
8
|
+
textOverflow: 'ellipsis',
|
|
9
|
+
whiteSpace: 'nowrap'
|
|
10
|
+
}),
|
|
11
|
+
lineClamp: (n: number) => ({
|
|
12
|
+
'-webkit-line-clamp': `${n}`,
|
|
13
|
+
'-webkit-box-orient': 'vertical',
|
|
14
|
+
overflow: 'hidden',
|
|
15
|
+
display: '-webkit-box'
|
|
16
|
+
}),
|
|
17
|
+
size: (s: string) => ({ width: s, height: s }),
|
|
18
|
+
py: (s: string) => ({ paddingTop: s, paddingBottom: s }),
|
|
19
|
+
px: (s: string) => ({ paddingLeft: s, paddingRight: s }),
|
|
20
|
+
my: (s: string) => ({ marginTop: s, marginBottom: s }),
|
|
21
|
+
mx: (s: string) => ({ marginLeft: s, marginRight: s }),
|
|
22
|
+
flex: (
|
|
23
|
+
align: CSSProperties['alignItems'],
|
|
24
|
+
justify: CSSProperties['justifyContent'],
|
|
25
|
+
vertical?: boolean
|
|
26
|
+
) => {
|
|
27
|
+
return {
|
|
28
|
+
display: 'flex',
|
|
29
|
+
alignItems: align,
|
|
30
|
+
justifyContent: justify,
|
|
31
|
+
flexDirection: vertical ? 'column' : 'row'
|
|
32
|
+
} satisfies CSSProperties
|
|
33
|
+
},
|
|
34
|
+
/** 数字为元素数量,字符串为对应css的值 */
|
|
35
|
+
grid: {
|
|
36
|
+
grid: (rows: number | string, cols: number | string, gap?: number) => ({
|
|
37
|
+
display: 'grid',
|
|
38
|
+
gridTemplateRows: isString(rows) ? rows : `repeat(${rows}, minmax(0, 1fr))`,
|
|
39
|
+
gridTemplateColumns: isString(cols) ? cols : `repeat(${cols}, minmax(0, 1fr))`,
|
|
40
|
+
gap: gap ? `${gap}px` : void 0
|
|
41
|
+
}),
|
|
42
|
+
rows: (rows: number | string, gap?: number) => ({
|
|
43
|
+
display: 'grid',
|
|
44
|
+
gridTemplateRows: isString(rows) ? rows : `repeat(${rows}, minmax(0, 1fr))`,
|
|
45
|
+
rowGap: gap ? `${gap}px` : void 0
|
|
46
|
+
}),
|
|
47
|
+
cols: (cols: number | string, gap?: number) => ({
|
|
48
|
+
display: 'grid',
|
|
49
|
+
gridTemplateColumns: isString(cols) ? cols : `repeat(${cols}, minmax(0, 1fr))`,
|
|
50
|
+
columnGap: gap ? `${gap}px` : void 0
|
|
51
|
+
})
|
|
52
|
+
} satisfies Record<string, (...args: any) => CSSProperties>
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export type themeType = typeof theme
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * as componentInstance from './componentInstance'
|
|
@@ -1,76 +1,80 @@
|
|
|
1
|
-
import { defineConfig, loadEnv } from 'vite'
|
|
2
|
-
import react from '@vitejs/plugin-react'
|
|
3
|
-
import svgr from 'vite-plugin-svgr'
|
|
4
|
-
import mockDevServer from 'vite-plugin-mock-dev-server'
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { visualizer } from 'rollup-plugin-visualizer'
|
|
8
|
-
import { includes } from 'lodash-es'
|
|
9
|
-
import { createChunks } from './scripts'
|
|
10
|
-
|
|
11
|
-
// https://vitejs.dev/config/
|
|
12
|
-
export default defineConfig(({ mode }) => {
|
|
13
|
-
const env = loadEnv(mode, process.cwd(), '')
|
|
14
|
-
const proxyBaseUrl = env.VITE_BASE_URL + env.VITE_API_HOST
|
|
15
|
-
const plugins: any[] = [
|
|
16
|
-
svgr(),
|
|
17
|
-
stylelint({ cache: false, include: ['**/*.{css,scss,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
1
|
+
import { defineConfig, loadEnv } from 'vite'
|
|
2
|
+
import react from '@vitejs/plugin-react'
|
|
3
|
+
import svgr from 'vite-plugin-svgr'
|
|
4
|
+
import mockDevServer from 'vite-plugin-mock-dev-server'
|
|
5
|
+
import checker from 'vite-plugin-checker'
|
|
6
|
+
import stylelint from 'vite-plugin-stylelint'
|
|
7
|
+
import { visualizer } from 'rollup-plugin-visualizer'
|
|
8
|
+
import { includes } from 'lodash-es'
|
|
9
|
+
import { createChunks } from './scripts'
|
|
10
|
+
|
|
11
|
+
// https://vitejs.dev/config/
|
|
12
|
+
export default defineConfig(({ mode }) => {
|
|
13
|
+
const env = loadEnv(mode, process.cwd(), '')
|
|
14
|
+
const proxyBaseUrl = env.VITE_BASE_URL + env.VITE_API_HOST
|
|
15
|
+
const plugins: any[] = [
|
|
16
|
+
svgr(),
|
|
17
|
+
stylelint({ cache: false, include: ['**/*.{css,scss,less,ts,tsx}'] }),
|
|
18
|
+
checker({
|
|
19
|
+
enableBuild: false,
|
|
20
|
+
typescript: true,
|
|
21
|
+
eslint: { useFlatConfig: true, lintCommand: 'eslint', dev: { logLevel: ['error'] } }
|
|
22
|
+
}),
|
|
23
|
+
react({
|
|
24
|
+
babel: {
|
|
25
|
+
plugins: [
|
|
26
|
+
[
|
|
27
|
+
'babel-plugin-styled-components',
|
|
28
|
+
{
|
|
29
|
+
ssr: false,
|
|
30
|
+
displayName: false,
|
|
31
|
+
fileName: false,
|
|
32
|
+
transpileTemplateLiterals: false
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
}),
|
|
38
|
+
mockDevServer({
|
|
39
|
+
include: ['**/*.mock.{ts,js}']
|
|
40
|
+
})
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
if (mode === 'analyse') {
|
|
44
|
+
plugins.push(visualizer({ open: true, sourcemap: true, brotliSize: true, gzipSize: true }))
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
base: env.VITE_BASE_URL,
|
|
49
|
+
plugins,
|
|
50
|
+
resolve: {
|
|
51
|
+
alias: {
|
|
52
|
+
'@': __dirname
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
esbuild: {
|
|
56
|
+
drop: includes(['production', 'analyse'], mode) ? ['console', 'debugger'] : []
|
|
57
|
+
},
|
|
58
|
+
build: {
|
|
59
|
+
sourcemap: mode === 'analyse',
|
|
60
|
+
reportCompressedSize: mode === 'analyse',
|
|
61
|
+
rollupOptions: {
|
|
62
|
+
output: {
|
|
63
|
+
manualChunks: createChunks({
|
|
64
|
+
react: ['react', 'react-dom']
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
server: {
|
|
70
|
+
host: '0.0.0.0',
|
|
71
|
+
proxy: {
|
|
72
|
+
[proxyBaseUrl]: {
|
|
73
|
+
target: 'http://127.0.0.1',
|
|
74
|
+
changeOrigin: true,
|
|
75
|
+
rewrite: path => path.replace(proxyBaseUrl, '')
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
})
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FunctionComponent } from 'react'
|
|
2
|
+
import { Outlet } from 'react-router-dom'
|
|
3
|
+
import { last } from 'lodash-es'
|
|
4
|
+
import { routeType, useMatchRoutes } from '@/domain/router'
|
|
5
|
+
|
|
6
|
+
export interface propsType {
|
|
7
|
+
Index: FunctionComponent
|
|
8
|
+
rootId: routeType['id']
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const Root: FunctionComponent<propsType> = ({ Index, rootId }) => {
|
|
12
|
+
const matchRoutes = useMatchRoutes()
|
|
13
|
+
|
|
14
|
+
if (last(matchRoutes)?.id === rootId) {
|
|
15
|
+
return <Index />
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return <Outlet />
|
|
19
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { FunctionComponent } from 'react'
|
|
2
|
+
import { Outlet } from 'react-router-dom'
|
|
3
|
+
import { useMount } from 'react-use'
|
|
4
|
+
import { last } from 'lodash-es'
|
|
5
|
+
import { useMatchRoutes, useRouter, routeType } from '@/domain/router'
|
|
6
|
+
|
|
7
|
+
export interface propsType {
|
|
8
|
+
rootId: routeType['id']
|
|
9
|
+
homeId: routeType['id']
|
|
10
|
+
}
|
|
11
|
+
export const Root: FunctionComponent<propsType> = props => {
|
|
12
|
+
const matchRoutes = useMatchRoutes()
|
|
13
|
+
const navigate = useRouter(state => state.navigate)
|
|
14
|
+
|
|
15
|
+
useMount(() => {
|
|
16
|
+
if (last(matchRoutes)?.id === props.rootId) {
|
|
17
|
+
navigate({ id: props.homeId })
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
return <Outlet />
|
|
22
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export { default as routerIds } from './ids'
|
|
2
|
-
export * from './router'
|
|
3
|
-
export * from './router.types'
|
|
1
|
+
export { default as routerIds } from './ids'
|
|
2
|
+
export * from './router'
|
|
3
|
+
export * from './router.types'
|
|
4
|
+
export * from './components'
|