create-packer 1.45.13 → 1.45.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 +1 -1
- package/template/web-app/react-rsbuild/domain/app/components/app-context.tsx +10 -1
- package/template/web-app/react-rsbuild/env.d.ts +14 -7
- package/template/web-app/react-rsbuild/eslint.config.js +1 -1
- package/template/web-app/react-rsbuild/main.tsx +0 -1
- package/template/web-app/react-rsbuild/package.json +4 -2
- package/template/web-app/react-rsbuild/pages/home/view.styled.ts +5 -0
- package/template/web-app/react-rsbuild/pages/home/view.tsx +2 -2
- package/template/web-app/react-rsbuild/postcss.config.cjs +0 -1
- package/template/web-app/react-rsbuild/rsbuild.config.ts +10 -0
- package/template/web-app/react-rsbuild/shared/styles/global.ts +7 -0
- package/template/web-app/react-rsbuild/shared/styles/index.ts +2 -0
- package/template/web-app/react-rsbuild/shared/styles/theme.ts +60 -0
- package/template/web-app/react-rsbuild/tsconfig.json +2 -1
- package/template/web-app/react-vite/domain/app/components/app-context.tsx +10 -1
- package/template/web-app/react-vite/eslint.config.js +0 -1
- package/template/web-app/react-vite/main.tsx +0 -1
- package/template/web-app/react-vite/package.json +4 -3
- package/template/web-app/react-vite/pages/home/view.styled.ts +5 -0
- package/template/web-app/react-vite/pages/home/view.tsx +2 -2
- package/template/web-app/react-vite/postcss.config.cjs +0 -1
- package/template/web-app/react-vite/shared/styles/global.ts +7 -0
- package/template/web-app/react-vite/shared/styles/index.ts +2 -0
- package/template/web-app/react-vite/shared/styles/theme.ts +60 -0
- package/template/web-app/react-vite/tsconfig.json +2 -1
- package/template/web-app/react-vite/vite-env.d.ts +14 -6
- package/template/web-app/react-vite/vite.config.ts +5 -1
- package/template/web-extension/entrypoints/content/domain/app/tools/insertApp.tsx +3 -1
- package/template/web-extension/entrypoints/content/modules/common/common.tsx +0 -2
- package/template/web-extension/entrypoints/popup/main.tsx +0 -1
- package/template/web-extension/package.json +3 -2
- package/template/web-extension/shared/components/app-context/view.tsx +11 -2
- package/template/web-extension/shared/styles/global.ts +9 -0
- package/template/web-extension/shared/styles/index.ts +2 -2
- package/template/web-extension/shared/styles/theme.ts +60 -0
- package/template/web-extension/tsconfig.json +1 -0
- package/template/web-extension/vite-env.d.ts +6 -0
- package/template/web-extension/wxt.config.ts +8 -2
- package/template/web-app/react-rsbuild/global.css.ts +0 -5
- package/template/web-app/react-rsbuild/main.css +0 -1
- package/template/web-app/react-rsbuild/pages/home/view.css.ts +0 -7
- package/template/web-app/react-rsbuild/panda.config.ts +0 -18
- package/template/web-app/react-vite/global.css.ts +0 -5
- package/template/web-app/react-vite/main.css +0 -1
- package/template/web-app/react-vite/pages/home/view.css.ts +0 -7
- package/template/web-app/react-vite/panda.config.ts +0 -18
- package/template/web-app/svelte/.env +0 -2
- package/template/web-app/svelte/.env.development +0 -2
- package/template/web-app/svelte/.gitignore +0 -27
- package/template/web-app/svelte/.husky/commit-msg +0 -4
- package/template/web-app/svelte/.husky/pre-commit +0 -4
- package/template/web-app/svelte/.prettierignore +0 -8
- package/template/web-app/svelte/.prettierrc +0 -21
- package/template/web-app/svelte/.svelte-kit/ambient.d.ts +0 -183
- package/template/web-app/svelte/.svelte-kit/generated/client/app.js +0 -28
- package/template/web-app/svelte/.svelte-kit/generated/client/matchers.js +0 -1
- package/template/web-app/svelte/.svelte-kit/generated/client/nodes/0.js +0 -1
- package/template/web-app/svelte/.svelte-kit/generated/client/nodes/1.js +0 -1
- package/template/web-app/svelte/.svelte-kit/generated/client/nodes/2.js +0 -1
- package/template/web-app/svelte/.svelte-kit/generated/root.js +0 -3
- package/template/web-app/svelte/.svelte-kit/generated/root.svelte +0 -66
- package/template/web-app/svelte/.svelte-kit/generated/server/internal.js +0 -49
- package/template/web-app/svelte/.svelte-kit/non-ambient.d.ts +0 -25
- package/template/web-app/svelte/.svelte-kit/tsconfig.json +0 -55
- package/template/web-app/svelte/.svelte-kit/types/route_meta_data.json +0 -3
- package/template/web-app/svelte/.svelte-kit/types/src/routes/$types.d.ts +0 -22
- package/template/web-app/svelte/.vscode/extensions.json +0 -8
- package/template/web-app/svelte/README.md +0 -38
- package/template/web-app/svelte/commitlint.config.cjs +0 -1
- package/template/web-app/svelte/eslint.config.js +0 -98
- package/template/web-app/svelte/package.json +0 -56
- package/template/web-app/svelte/scripts/createChunks.ts +0 -27
- package/template/web-app/svelte/scripts/index.ts +0 -1
- package/template/web-app/svelte/src/app.d.ts +0 -13
- package/template/web-app/svelte/src/app.html +0 -12
- package/template/web-app/svelte/src/lib/index.ts +0 -1
- package/template/web-app/svelte/src/routes/+page.svelte +0 -2
- package/template/web-app/svelte/static/favicon.png +0 -0
- package/template/web-app/svelte/svelte.config.js +0 -29
- package/template/web-app/svelte/tsconfig.json +0 -21
- package/template/web-app/svelte/vite-env.d.ts +0 -11
- package/template/web-app/svelte/vite.config.ts +0 -49
- package/template/web-extension/entrypoints/content/global.css.ts +0 -5
- package/template/web-extension/entrypoints/popup/global.css.ts +0 -4
- package/template/web-extension/shared/styles/global.css.ts +0 -7
- package/template/web-extension/shared/styles/theme.css.ts +0 -3
package/package.json
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { FunctionComponent, ReactNode } from 'react'
|
|
2
2
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
3
|
+
import { Global, ThemeProvider } from '@emotion/react'
|
|
3
4
|
import { request } from '@/shared/service'
|
|
5
|
+
import { globalCss, theme } from '@/shared/styles'
|
|
4
6
|
|
|
5
7
|
const queryClient = new QueryClient({
|
|
6
8
|
defaultOptions: {
|
|
@@ -18,5 +20,12 @@ export interface propsType {
|
|
|
18
20
|
children: ReactNode
|
|
19
21
|
}
|
|
20
22
|
export const Root: FunctionComponent<propsType> = props => {
|
|
21
|
-
return
|
|
23
|
+
return (
|
|
24
|
+
<ThemeProvider theme={theme}>
|
|
25
|
+
<QueryClientProvider client={queryClient}>
|
|
26
|
+
<Global styles={globalCss} />
|
|
27
|
+
{props.children}
|
|
28
|
+
</QueryClientProvider>
|
|
29
|
+
</ThemeProvider>
|
|
30
|
+
)
|
|
22
31
|
}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
/// <reference types="@rsbuild/core/types" />
|
|
2
|
+
import '@emotion/react'
|
|
3
|
+
import { type themeType } from '@/shared/styles'
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
declare global {
|
|
6
|
+
interface ImportMetaEnv {
|
|
7
|
+
readonly PUBLIC_BASE_URL: string
|
|
8
|
+
readonly PUBLIC_API_HOST: string
|
|
9
|
+
}
|
|
7
10
|
|
|
8
|
-
interface ImportMeta {
|
|
9
|
-
|
|
11
|
+
interface ImportMeta {
|
|
12
|
+
readonly env: ImportMetaEnv
|
|
13
|
+
}
|
|
10
14
|
}
|
|
11
|
-
|
|
12
15
|
declare module '*.svg' {
|
|
13
16
|
const content: string
|
|
14
17
|
export default content
|
|
@@ -18,3 +21,7 @@ declare module '*.svg?react' {
|
|
|
18
21
|
const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement>>
|
|
19
22
|
export default ReactComponent
|
|
20
23
|
}
|
|
24
|
+
|
|
25
|
+
declare module '@emotion/react' {
|
|
26
|
+
export interface Theme extends themeType {}
|
|
27
|
+
}
|
|
@@ -10,7 +10,7 @@ const files = scriptExtensions.map(ext => `**/*.${ext}`)
|
|
|
10
10
|
|
|
11
11
|
export default tseslint.config([
|
|
12
12
|
{
|
|
13
|
-
ignores: ['**/node_modules/', '**/dist/', '**/.history/', '**/.vscode/'
|
|
13
|
+
ignores: ['**/node_modules/', '**/dist/', '**/.history/', '**/.vscode/']
|
|
14
14
|
},
|
|
15
15
|
eslint.configs.recommended,
|
|
16
16
|
importPlugin.flatConfigs.recommended,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"version": "0.0.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"prepare": "
|
|
7
|
+
"prepare": "husky",
|
|
8
8
|
"dev": "rsbuild dev",
|
|
9
9
|
"build": "rsbuild build",
|
|
10
10
|
"build:analyse": "rsbuild build --env-mode analyse",
|
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
"commit": "git add . && npm run cz"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
+
"@emotion/react": "11.14.0",
|
|
23
|
+
"@emotion/styled": "11.14.1",
|
|
22
24
|
"@tanstack/react-query": "5.51.15",
|
|
23
25
|
"axios": "1.7.9",
|
|
24
26
|
"define-zustand": "3.4.0",
|
|
@@ -37,13 +39,13 @@
|
|
|
37
39
|
"@commitlint/config-conventional": "17.6.1",
|
|
38
40
|
"@commitlint/cz-commitlint": "17.5.0",
|
|
39
41
|
"@eslint/js": "9.15.0",
|
|
40
|
-
"@pandacss/dev": "1.2.0",
|
|
41
42
|
"@rsbuild/core": "1.5.2",
|
|
42
43
|
"@rsbuild/plugin-eslint": "1.1.2",
|
|
43
44
|
"@rsbuild/plugin-react": "1.4.0",
|
|
44
45
|
"@rsbuild/plugin-svgr": "1.2.2",
|
|
45
46
|
"@rsbuild/plugin-type-check": "1.2.4",
|
|
46
47
|
"@rsdoctor/rspack-plugin": "1.2.3",
|
|
48
|
+
"@swc/plugin-emotion": "11.1.0",
|
|
47
49
|
"@types/node": "18.16.0",
|
|
48
50
|
"@types/qs": "6.9.7",
|
|
49
51
|
"@types/react": "18.3.3",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { useHomeData } from '@/shared/service'
|
|
2
|
-
import {
|
|
2
|
+
import { StyledRoot } from './view.styled'
|
|
3
3
|
|
|
4
4
|
export default function Home() {
|
|
5
5
|
const { data } = useHomeData()
|
|
6
6
|
|
|
7
7
|
console.log('data', data)
|
|
8
8
|
|
|
9
|
-
return <
|
|
9
|
+
return <StyledRoot>sdfs</StyledRoot>
|
|
10
10
|
}
|
|
@@ -41,6 +41,13 @@ export default defineConfig(({ envMode, command }) => {
|
|
|
41
41
|
new StylelintWebpackPlugin(),
|
|
42
42
|
process.env.RSDOCTOR && new RsdoctorRspackPlugin()
|
|
43
43
|
]
|
|
44
|
+
},
|
|
45
|
+
swc: {
|
|
46
|
+
jsc: {
|
|
47
|
+
experimental: {
|
|
48
|
+
plugins: [['@swc/plugin-emotion', {}]]
|
|
49
|
+
}
|
|
50
|
+
}
|
|
44
51
|
}
|
|
45
52
|
},
|
|
46
53
|
plugins: [
|
|
@@ -55,6 +62,9 @@ export default defineConfig(({ envMode, command }) => {
|
|
|
55
62
|
pluginReact({
|
|
56
63
|
reactRefreshOptions: {
|
|
57
64
|
exclude: [/\.css\.ts$/]
|
|
65
|
+
},
|
|
66
|
+
swcReactOptions: {
|
|
67
|
+
importSource: '@emotion/react'
|
|
58
68
|
}
|
|
59
69
|
})
|
|
60
70
|
],
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { CSSProperties } from 'react'
|
|
2
|
+
import { isString } from 'es-toolkit'
|
|
3
|
+
import { isNumber } from 'es-toolkit/compat'
|
|
4
|
+
|
|
5
|
+
export const theme = {
|
|
6
|
+
text: {
|
|
7
|
+
xs: { fontSize: '12px', lineHeight: '20px' },
|
|
8
|
+
sm: { fontSize: '14px', lineHeight: '22px' },
|
|
9
|
+
base: { fontSize: '16px', lineHeight: '24px' },
|
|
10
|
+
lg: { fontSize: '18px', lineHeight: '26px' },
|
|
11
|
+
xl: { fontSize: '20px', lineHeight: '28px' },
|
|
12
|
+
'2xl': { fontSize: '24px', lineHeight: '32px' },
|
|
13
|
+
'3xl': { fontSize: '28px', lineHeight: '40px' },
|
|
14
|
+
'4xl': { fontSize: '32px', lineHeight: '44px' }
|
|
15
|
+
} satisfies Record<string, CSSProperties>,
|
|
16
|
+
tools: {
|
|
17
|
+
ellipsis: () => ({
|
|
18
|
+
overflow: 'hidden',
|
|
19
|
+
textOverflow: 'ellipsis',
|
|
20
|
+
whiteSpace: 'nowrap'
|
|
21
|
+
}),
|
|
22
|
+
lineClamp: (n: number) => ({
|
|
23
|
+
'-webkit-line-clamp': `${n}`,
|
|
24
|
+
'-webkit-box-orient': 'vertical',
|
|
25
|
+
overflow: 'hidden',
|
|
26
|
+
display: '-webkit-box'
|
|
27
|
+
}),
|
|
28
|
+
size: (s: string) => ({ width: s, height: s }),
|
|
29
|
+
py: (s: string) => ({ paddingTop: s, paddingBottom: s }),
|
|
30
|
+
px: (s: string) => ({ paddingLeft: s, paddingRight: s }),
|
|
31
|
+
my: (s: string) => ({ marginTop: s, marginBottom: s }),
|
|
32
|
+
mx: (s: string) => ({ marginLeft: s, marginRight: s }),
|
|
33
|
+
flex: (
|
|
34
|
+
align: CSSProperties['alignItems'],
|
|
35
|
+
justify: CSSProperties['justifyContent'],
|
|
36
|
+
vertical?: boolean
|
|
37
|
+
) => {
|
|
38
|
+
return {
|
|
39
|
+
display: 'flex',
|
|
40
|
+
alignItems: align,
|
|
41
|
+
justifyContent: justify,
|
|
42
|
+
flexDirection: vertical ? 'column' : 'row'
|
|
43
|
+
} satisfies CSSProperties
|
|
44
|
+
},
|
|
45
|
+
/** 数字为元素数量,字符串为对应css的值 */
|
|
46
|
+
grid: (
|
|
47
|
+
rows: number | CSSProperties['gridTemplateRows'],
|
|
48
|
+
cols: number | CSSProperties['gridTemplateColumns'],
|
|
49
|
+
gap?: number | string
|
|
50
|
+
) => {
|
|
51
|
+
return {
|
|
52
|
+
display: 'grid',
|
|
53
|
+
gridTemplateRows: isString(rows) ? rows : `repeat(${rows}, minmax(0, 1fr))`,
|
|
54
|
+
gridTemplateColumns: isString(cols) ? cols : `repeat(${cols}, minmax(0, 1fr))`,
|
|
55
|
+
gap: isNumber(gap) ? `${gap}px` : gap
|
|
56
|
+
} satisfies CSSProperties
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export type themeType = typeof theme
|
|
@@ -18,11 +18,12 @@
|
|
|
18
18
|
"isolatedModules": true,
|
|
19
19
|
"noEmit": true,
|
|
20
20
|
"jsx": "react-jsx",
|
|
21
|
+
"jsxImportSource": "@emotion/react",
|
|
21
22
|
"paths": {
|
|
22
23
|
"@/*": ["./*"]
|
|
23
24
|
}
|
|
24
25
|
},
|
|
25
|
-
"include": ["**/*.ts", "**/*.tsx"
|
|
26
|
+
"include": ["**/*.ts", "**/*.tsx"],
|
|
26
27
|
"exclude": ["scripts", "rsbuild.config.ts"],
|
|
27
28
|
"references": [
|
|
28
29
|
{
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { FunctionComponent, ReactNode } from 'react'
|
|
2
2
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
3
|
+
import { Global, ThemeProvider } from '@emotion/react'
|
|
3
4
|
import { request } from '@/shared/service'
|
|
5
|
+
import { globalCss, theme } from '@/shared/styles'
|
|
4
6
|
|
|
5
7
|
const queryClient = new QueryClient({
|
|
6
8
|
defaultOptions: {
|
|
@@ -18,5 +20,12 @@ export interface propsType {
|
|
|
18
20
|
children: ReactNode
|
|
19
21
|
}
|
|
20
22
|
export const Root: FunctionComponent<propsType> = props => {
|
|
21
|
-
return
|
|
23
|
+
return (
|
|
24
|
+
<ThemeProvider theme={theme}>
|
|
25
|
+
<QueryClientProvider client={queryClient}>
|
|
26
|
+
<Global styles={globalCss} />
|
|
27
|
+
{props.children}
|
|
28
|
+
</QueryClientProvider>
|
|
29
|
+
</ThemeProvider>
|
|
30
|
+
)
|
|
22
31
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"version": "0.0.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"prepare": "
|
|
7
|
+
"prepare": "husky",
|
|
8
8
|
"dev": "vite",
|
|
9
9
|
"build": "tsc --noEmit && vite build",
|
|
10
10
|
"build:analyse": "tsc --noEmit && vite build --mode analyse",
|
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
"commit": "git add . && npm run cz"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
+
"@emotion/react": "11.14.0",
|
|
22
|
+
"@emotion/styled": "11.14.1",
|
|
21
23
|
"@tanstack/react-query": "5.51.15",
|
|
22
24
|
"axios": "1.7.9",
|
|
23
25
|
"define-zustand": "3.4.0",
|
|
@@ -38,7 +40,6 @@
|
|
|
38
40
|
"@emotion/babel-plugin": "11.13.5",
|
|
39
41
|
"@eslint/js": "9.15.0",
|
|
40
42
|
"@faker-js/faker": "8.4.1",
|
|
41
|
-
"@pandacss/dev": "1.2.0",
|
|
42
43
|
"@types/node": "18.16.0",
|
|
43
44
|
"@types/qs": "6.9.7",
|
|
44
45
|
"@types/react": "18.3.3",
|
|
@@ -54,7 +55,7 @@
|
|
|
54
55
|
"eslint-plugin-react-hooks": "5.1.0",
|
|
55
56
|
"globals": "15.12.0",
|
|
56
57
|
"husky": "9.1.6",
|
|
57
|
-
"inquirer": "
|
|
58
|
+
"inquirer": "8.1.2",
|
|
58
59
|
"postcss": "8.4.35",
|
|
59
60
|
"postcss-import": "16.0.1",
|
|
60
61
|
"postcss-nesting": "12.0.3",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { useHomeData } from '@/shared/service'
|
|
2
|
-
import {
|
|
2
|
+
import { StyledRoot } from './view.styled'
|
|
3
3
|
|
|
4
4
|
export default function Home() {
|
|
5
5
|
const { data } = useHomeData()
|
|
6
6
|
|
|
7
7
|
console.log('data', data)
|
|
8
8
|
|
|
9
|
-
return <
|
|
9
|
+
return <StyledRoot>sdfs</StyledRoot>
|
|
10
10
|
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { CSSProperties } from 'react'
|
|
2
|
+
import { isString } from 'es-toolkit'
|
|
3
|
+
import { isNumber } from 'es-toolkit/compat'
|
|
4
|
+
|
|
5
|
+
export const theme = {
|
|
6
|
+
text: {
|
|
7
|
+
xs: { fontSize: '12px', lineHeight: '20px' },
|
|
8
|
+
sm: { fontSize: '14px', lineHeight: '22px' },
|
|
9
|
+
base: { fontSize: '16px', lineHeight: '24px' },
|
|
10
|
+
lg: { fontSize: '18px', lineHeight: '26px' },
|
|
11
|
+
xl: { fontSize: '20px', lineHeight: '28px' },
|
|
12
|
+
'2xl': { fontSize: '24px', lineHeight: '32px' },
|
|
13
|
+
'3xl': { fontSize: '28px', lineHeight: '40px' },
|
|
14
|
+
'4xl': { fontSize: '32px', lineHeight: '44px' }
|
|
15
|
+
} satisfies Record<string, CSSProperties>,
|
|
16
|
+
tools: {
|
|
17
|
+
ellipsis: () => ({
|
|
18
|
+
overflow: 'hidden',
|
|
19
|
+
textOverflow: 'ellipsis',
|
|
20
|
+
whiteSpace: 'nowrap'
|
|
21
|
+
}),
|
|
22
|
+
lineClamp: (n: number) => ({
|
|
23
|
+
'-webkit-line-clamp': `${n}`,
|
|
24
|
+
'-webkit-box-orient': 'vertical',
|
|
25
|
+
overflow: 'hidden',
|
|
26
|
+
display: '-webkit-box'
|
|
27
|
+
}),
|
|
28
|
+
size: (s: string) => ({ width: s, height: s }),
|
|
29
|
+
py: (s: string) => ({ paddingTop: s, paddingBottom: s }),
|
|
30
|
+
px: (s: string) => ({ paddingLeft: s, paddingRight: s }),
|
|
31
|
+
my: (s: string) => ({ marginTop: s, marginBottom: s }),
|
|
32
|
+
mx: (s: string) => ({ marginLeft: s, marginRight: s }),
|
|
33
|
+
flex: (
|
|
34
|
+
align: CSSProperties['alignItems'],
|
|
35
|
+
justify: CSSProperties['justifyContent'],
|
|
36
|
+
vertical?: boolean
|
|
37
|
+
) => {
|
|
38
|
+
return {
|
|
39
|
+
display: 'flex',
|
|
40
|
+
alignItems: align,
|
|
41
|
+
justifyContent: justify,
|
|
42
|
+
flexDirection: vertical ? 'column' : 'row'
|
|
43
|
+
} satisfies CSSProperties
|
|
44
|
+
},
|
|
45
|
+
/** 数字为元素数量,字符串为对应css的值 */
|
|
46
|
+
grid: (
|
|
47
|
+
rows: number | CSSProperties['gridTemplateRows'],
|
|
48
|
+
cols: number | CSSProperties['gridTemplateColumns'],
|
|
49
|
+
gap?: number | string
|
|
50
|
+
) => {
|
|
51
|
+
return {
|
|
52
|
+
display: 'grid',
|
|
53
|
+
gridTemplateRows: isString(rows) ? rows : `repeat(${rows}, minmax(0, 1fr))`,
|
|
54
|
+
gridTemplateColumns: isString(cols) ? cols : `repeat(${cols}, minmax(0, 1fr))`,
|
|
55
|
+
gap: isNumber(gap) ? `${gap}px` : gap
|
|
56
|
+
} satisfies CSSProperties
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export type themeType = typeof theme
|
|
@@ -18,11 +18,12 @@
|
|
|
18
18
|
"isolatedModules": true,
|
|
19
19
|
"noEmit": true,
|
|
20
20
|
"jsx": "react-jsx",
|
|
21
|
+
"jsxImportSource": "@emotion/react",
|
|
21
22
|
"paths": {
|
|
22
23
|
"@/*": ["./*"]
|
|
23
24
|
}
|
|
24
25
|
},
|
|
25
|
-
"include": ["**/*.ts", "**/*.tsx"
|
|
26
|
+
"include": ["**/*.ts", "**/*.tsx"],
|
|
26
27
|
"exclude": ["scripts", "vite.config.ts"],
|
|
27
28
|
"references": [
|
|
28
29
|
{
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
/// <reference types="vite/client" />
|
|
2
2
|
/// <reference types="vite-plugin-svgr/client" />
|
|
3
|
+
import '@emotion/react'
|
|
4
|
+
import { type themeType } from '@/shared/styles'
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
declare global {
|
|
7
|
+
interface ImportMetaEnv {
|
|
8
|
+
readonly VITE_BASE_URL: string
|
|
9
|
+
readonly VITE_API_HOST: string
|
|
10
|
+
// 更多环境变量...
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface ImportMeta {
|
|
14
|
+
readonly env: ImportMetaEnv
|
|
15
|
+
}
|
|
8
16
|
}
|
|
9
17
|
|
|
10
|
-
|
|
11
|
-
|
|
18
|
+
declare module '@emotion/react' {
|
|
19
|
+
export interface Theme extends themeType {}
|
|
12
20
|
}
|
|
@@ -20,7 +20,11 @@ export default defineConfig(({ mode }) => {
|
|
|
20
20
|
typescript: true,
|
|
21
21
|
eslint: { useFlatConfig: true, lintCommand: 'eslint', dev: { logLevel: ['error'] } }
|
|
22
22
|
}),
|
|
23
|
-
react(
|
|
23
|
+
react({
|
|
24
|
+
babel: {
|
|
25
|
+
plugins: ['@emotion']
|
|
26
|
+
}
|
|
27
|
+
})
|
|
24
28
|
]
|
|
25
29
|
|
|
26
30
|
if (mode === 'analyse') {
|
|
@@ -50,7 +50,9 @@ export function insertApp<T extends HTMLElement>(
|
|
|
50
50
|
target.appendChild(result.rootEle)
|
|
51
51
|
}
|
|
52
52
|
const root = createRoot(result.rootEle)
|
|
53
|
-
root.render(
|
|
53
|
+
root.render(
|
|
54
|
+
<AppContext.Root classNameSpace={classNameSpace}>{option.reactNode}</AppContext.Root>
|
|
55
|
+
)
|
|
54
56
|
result.result = true
|
|
55
57
|
return result
|
|
56
58
|
}
|
|
@@ -2,7 +2,6 @@ import { StrictMode } from 'react'
|
|
|
2
2
|
import { createRoot } from 'react-dom/client'
|
|
3
3
|
import { AppContext } from '@/shared/components'
|
|
4
4
|
import Popup from './popup'
|
|
5
|
-
import './global.css'
|
|
6
5
|
|
|
7
6
|
createRoot(document.getElementById('root') as HTMLElement).render(
|
|
8
7
|
<StrictMode>
|
|
@@ -25,8 +25,9 @@
|
|
|
25
25
|
"commit": "git add . && npm run cz"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
+
"@emotion/react": "11.14.0",
|
|
29
|
+
"@emotion/styled": "11.14.1",
|
|
28
30
|
"@tanstack/react-query": "5.51.15",
|
|
29
|
-
"@vanilla-extract/css": "1.17.4",
|
|
30
31
|
"@webext-core/messaging": "2.2.0",
|
|
31
32
|
"axios": "1.7.9",
|
|
32
33
|
"define-zustand": "3.4.0",
|
|
@@ -42,13 +43,13 @@
|
|
|
42
43
|
"@commitlint/cli": "17.6.1",
|
|
43
44
|
"@commitlint/config-conventional": "17.6.1",
|
|
44
45
|
"@commitlint/cz-commitlint": "17.5.0",
|
|
46
|
+
"@emotion/babel-plugin": "11.13.5",
|
|
45
47
|
"@eslint/js": "9.15.0",
|
|
46
48
|
"@types/chrome": "0.0.254",
|
|
47
49
|
"@types/node": "18.16.0",
|
|
48
50
|
"@types/qs": "6.9.7",
|
|
49
51
|
"@types/react": "18.3.3",
|
|
50
52
|
"@types/react-dom": "18.3.0",
|
|
51
|
-
"@vanilla-extract/vite-plugin": "5.1.1",
|
|
52
53
|
"@vitejs/plugin-react": "5.0.1",
|
|
53
54
|
"autoprefixer": "10.4.14",
|
|
54
55
|
"commitizen": "4.3.0",
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import { FunctionComponent, ReactNode } from 'react'
|
|
2
2
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
3
|
+
import { Global, ThemeProvider } from '@emotion/react'
|
|
4
|
+
import { createGlobalCss, theme } from '@/shared/styles'
|
|
3
5
|
|
|
4
6
|
const queryClient = new QueryClient()
|
|
5
7
|
|
|
6
|
-
const AppContext: FunctionComponent<{ children: ReactNode }> = props => {
|
|
7
|
-
return
|
|
8
|
+
const AppContext: FunctionComponent<{ children: ReactNode; classNameSpace?: string }> = props => {
|
|
9
|
+
return (
|
|
10
|
+
<ThemeProvider theme={theme}>
|
|
11
|
+
<QueryClientProvider client={queryClient}>
|
|
12
|
+
<Global styles={createGlobalCss(props.classNameSpace)} />
|
|
13
|
+
{props.children}
|
|
14
|
+
</QueryClientProvider>
|
|
15
|
+
</ThemeProvider>
|
|
16
|
+
)
|
|
8
17
|
}
|
|
9
18
|
|
|
10
19
|
export default AppContext
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './global
|
|
2
|
-
export * from './theme
|
|
1
|
+
export * from './global'
|
|
2
|
+
export * from './theme'
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { CSSProperties } from 'react'
|
|
2
|
+
import { isString } from 'es-toolkit'
|
|
3
|
+
import { isNumber } from 'es-toolkit/compat'
|
|
4
|
+
|
|
5
|
+
export const theme = {
|
|
6
|
+
text: {
|
|
7
|
+
xs: { fontSize: '12px', lineHeight: '20px' },
|
|
8
|
+
sm: { fontSize: '14px', lineHeight: '22px' },
|
|
9
|
+
base: { fontSize: '16px', lineHeight: '24px' },
|
|
10
|
+
lg: { fontSize: '18px', lineHeight: '26px' },
|
|
11
|
+
xl: { fontSize: '20px', lineHeight: '28px' },
|
|
12
|
+
'2xl': { fontSize: '24px', lineHeight: '32px' },
|
|
13
|
+
'3xl': { fontSize: '28px', lineHeight: '40px' },
|
|
14
|
+
'4xl': { fontSize: '32px', lineHeight: '44px' }
|
|
15
|
+
} satisfies Record<string, CSSProperties>,
|
|
16
|
+
tools: {
|
|
17
|
+
ellipsis: () => ({
|
|
18
|
+
overflow: 'hidden',
|
|
19
|
+
textOverflow: 'ellipsis',
|
|
20
|
+
whiteSpace: 'nowrap'
|
|
21
|
+
}),
|
|
22
|
+
lineClamp: (n: number) => ({
|
|
23
|
+
'-webkit-line-clamp': `${n}`,
|
|
24
|
+
'-webkit-box-orient': 'vertical',
|
|
25
|
+
overflow: 'hidden',
|
|
26
|
+
display: '-webkit-box'
|
|
27
|
+
}),
|
|
28
|
+
size: (s: string) => ({ width: s, height: s }),
|
|
29
|
+
py: (s: string) => ({ paddingTop: s, paddingBottom: s }),
|
|
30
|
+
px: (s: string) => ({ paddingLeft: s, paddingRight: s }),
|
|
31
|
+
my: (s: string) => ({ marginTop: s, marginBottom: s }),
|
|
32
|
+
mx: (s: string) => ({ marginLeft: s, marginRight: s }),
|
|
33
|
+
flex: (
|
|
34
|
+
align: CSSProperties['alignItems'],
|
|
35
|
+
justify: CSSProperties['justifyContent'],
|
|
36
|
+
vertical?: boolean
|
|
37
|
+
) => {
|
|
38
|
+
return {
|
|
39
|
+
display: 'flex',
|
|
40
|
+
alignItems: align,
|
|
41
|
+
justifyContent: justify,
|
|
42
|
+
flexDirection: vertical ? 'column' : 'row'
|
|
43
|
+
} satisfies CSSProperties
|
|
44
|
+
},
|
|
45
|
+
/** 数字为元素数量,字符串为对应css的值 */
|
|
46
|
+
grid: (
|
|
47
|
+
rows: number | CSSProperties['gridTemplateRows'],
|
|
48
|
+
cols: number | CSSProperties['gridTemplateColumns'],
|
|
49
|
+
gap?: number | string
|
|
50
|
+
) => {
|
|
51
|
+
return {
|
|
52
|
+
display: 'grid',
|
|
53
|
+
gridTemplateRows: isString(rows) ? rows : `repeat(${rows}, minmax(0, 1fr))`,
|
|
54
|
+
gridTemplateColumns: isString(cols) ? cols : `repeat(${cols}, minmax(0, 1fr))`,
|
|
55
|
+
gap: isNumber(gap) ? `${gap}px` : gap
|
|
56
|
+
} satisfies CSSProperties
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export type themeType = typeof theme
|