create-packer 1.44.1 → 1.45.0
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/app.model.ts +1 -1
- package/template/web-app/react-rsbuild/domain/router/components/route-layout.tsx +1 -1
- package/template/web-app/react-rsbuild/domain/router/components/sub-route-outlet.tsx +1 -1
- package/template/web-app/react-rsbuild/package.json +2 -3
- package/template/web-app/react-rsbuild/shared/hooks/defineRouter/deineRouter.tsx +5 -4
- package/template/web-app/react-rsbuild/shared/hooks/useSyncState.ts +2 -2
- package/template/web-app/react-rsbuild/shared/hooks/useVisible.ts +1 -1
- package/template/web-app/react-rsbuild/shared/service/home.ts +2 -2
- package/template/web-app/react-vite/domain/app/app.model.ts +1 -1
- package/template/web-app/react-vite/domain/app/components/app-context.tsx +22 -22
- package/template/web-app/react-vite/domain/app/components/app.tsx +24 -24
- package/template/web-app/react-vite/domain/router/components/route-layout.tsx +19 -19
- package/template/web-app/react-vite/domain/router/components/sub-route-outlet.tsx +22 -22
- package/template/web-app/react-vite/package.json +2 -3
- package/template/web-app/react-vite/scripts/createChunks.ts +4 -3
- package/template/web-app/react-vite/shared/hooks/defineRouter/deineRouter.tsx +5 -4
- package/template/web-app/react-vite/shared/hooks/useSyncState.ts +2 -2
- package/template/web-app/react-vite/shared/hooks/useVisible.ts +1 -1
- package/template/web-app/react-vite/shared/service/home.ts +2 -2
- package/template/web-app/react-vite/vite-env.d.ts +12 -12
- package/template/web-app/react-vite/vite.config.ts +1 -2
- package/template/web-app/svelte/package.json +1 -2
- package/template/web-app/svelte/scripts/createChunks.ts +4 -3
- package/template/web-app/svelte/vite.config.ts +1 -5
- package/template/web-app/vue/domain/app/createComponentInstance.ts +2 -3
- package/template/web-app/vue/package.json +1 -2
- package/template/web-app/vue/scripts/createChunks.ts +4 -3
- package/template/web-app/vue/shared/hooks/useList.ts +2 -1
- package/template/web-app/vue/shared/hooks/useVisible.ts +1 -1
- package/template/web-app/vue/vite.config.ts +68 -69
- package/template/web-app/vue-rsbuild/domain/app/createComponentInstance.ts +2 -3
- package/template/web-app/vue-rsbuild/package.json +1 -2
- package/template/web-app/vue-rsbuild/shared/hooks/useList.ts +2 -1
- package/template/web-app/vue-rsbuild/shared/hooks/useVisible.ts +1 -1
- package/template/web-extension/entrypoints/content/domain/app/tools/insertApp.tsx +56 -58
- package/template/web-extension/package.json +2 -3
- package/template/web-extension/shared/hooks/useSyncState.ts +2 -2
- package/template/web-extension/shared/hooks/useVisible.ts +1 -1
- package/template/web-extension/shared/styles/theme.styled.ts +47 -47
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FunctionComponent } from 'react'
|
|
2
2
|
import { Outlet } from 'react-router'
|
|
3
3
|
import { useMount } from 'react-use'
|
|
4
|
-
import { last } from '
|
|
4
|
+
import { last } from 'es-toolkit'
|
|
5
5
|
import { useMatchRoutes, useRouter, routeType } from '@/domain/router'
|
|
6
6
|
|
|
7
7
|
export interface propsType {
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@tanstack/react-query": "5.51.15",
|
|
23
23
|
"axios": "1.7.9",
|
|
24
|
-
"define-zustand": "3.
|
|
24
|
+
"define-zustand": "3.4.0",
|
|
25
|
+
"es-toolkit": "1.37.2",
|
|
25
26
|
"immer": "10.0.1",
|
|
26
|
-
"lodash-es": "4.17.21",
|
|
27
27
|
"qs": "6.11.2",
|
|
28
28
|
"react": "18.3.1",
|
|
29
29
|
"react-dom": "18.3.1",
|
|
@@ -45,7 +45,6 @@
|
|
|
45
45
|
"@rsbuild/plugin-type-check": "1.2.1",
|
|
46
46
|
"@rsdoctor/rspack-plugin": "0.4.13",
|
|
47
47
|
"@tailwindcss/postcss": "4.1.4",
|
|
48
|
-
"@types/lodash-es": "4.17.12",
|
|
49
48
|
"@types/node": "18.16.0",
|
|
50
49
|
"@types/qs": "6.9.7",
|
|
51
50
|
"@types/react": "18.3.3",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DependencyList, useEffect, useMemo } from 'react'
|
|
2
2
|
import { useMatches, useSearchParams, NavigateOptions, createBrowserRouter } from 'react-router'
|
|
3
|
-
import {
|
|
3
|
+
import { omit, cloneDeep, last } from 'es-toolkit'
|
|
4
|
+
import { assign, isArray, reduce, get, map, split, forEach } from 'es-toolkit/compat'
|
|
4
5
|
import { stringify, parse } from 'qs'
|
|
5
6
|
import { defineStore } from 'define-zustand'
|
|
6
7
|
import { routeByIdType, routeType, editableRouteType } from './defineRouter.types'
|
|
@@ -10,7 +11,7 @@ export default function defineRouter(router: ReturnType<typeof createBrowserRout
|
|
|
10
11
|
state: () => ({
|
|
11
12
|
routes: cloneDeep(router.routes) as routeType[]
|
|
12
13
|
}),
|
|
13
|
-
|
|
14
|
+
getters: {
|
|
14
15
|
routesById: state => {
|
|
15
16
|
return (function flat(routes: routeType[], parentRoute?: routeByIdType) {
|
|
16
17
|
return reduce(
|
|
@@ -36,7 +37,7 @@ export default function defineRouter(router: ReturnType<typeof createBrowserRout
|
|
|
36
37
|
})(state.routes)
|
|
37
38
|
}
|
|
38
39
|
},
|
|
39
|
-
actions: (
|
|
40
|
+
actions: (setState, getState) => {
|
|
40
41
|
function posToLodashPath(pos: string) {
|
|
41
42
|
if (pos) {
|
|
42
43
|
return `[${split(pos, '-').join('].children[')}]`
|
|
@@ -52,7 +53,7 @@ export default function defineRouter(router: ReturnType<typeof createBrowserRout
|
|
|
52
53
|
const newRoute = cloneDeep(omit(route, ['element', 'errorElement', 'children']))
|
|
53
54
|
updator(newRoute)
|
|
54
55
|
assign(route, newRoute)
|
|
55
|
-
|
|
56
|
+
setState({ routes: newRoutes })
|
|
56
57
|
}
|
|
57
58
|
function getRoute(id: routeType['id'], path?: string | string[]) {
|
|
58
59
|
const { routesById } = getState()
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { useRef, useState, Dispatch, SetStateAction } from 'react'
|
|
2
|
-
import { isFunction } from '
|
|
2
|
+
import { isFunction } from 'es-toolkit'
|
|
3
3
|
|
|
4
4
|
export function useSyncState<S>(initialState: S | (() => S)) {
|
|
5
5
|
const [state, setState] = useState(initialState)
|
|
6
6
|
const syncState = useRef<S>(state)
|
|
7
7
|
|
|
8
8
|
const $setState: Dispatch<SetStateAction<S>> = newState => {
|
|
9
|
-
const $newState = isFunction(newState) ? newState(state) : newState
|
|
9
|
+
const $newState = (isFunction(newState) ? newState(state) : newState) as S
|
|
10
10
|
setState($newState)
|
|
11
11
|
syncState.current = $newState
|
|
12
12
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { useQuery,
|
|
1
|
+
import { useQuery, QueryOptions } from '@tanstack/react-query'
|
|
2
2
|
import { HOME_DATA } from './api'
|
|
3
3
|
|
|
4
|
-
export const useHomeData = (options?:
|
|
4
|
+
export const useHomeData = (options?: QueryOptions) => {
|
|
5
5
|
return useQuery({
|
|
6
6
|
...options,
|
|
7
7
|
queryKey: [HOME_DATA, ...(options?.queryKey || [])]
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { FunctionComponent, ReactNode } from 'react'
|
|
2
|
-
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
3
|
-
import { request } from '@/shared/service'
|
|
4
|
-
|
|
5
|
-
const queryClient = new QueryClient({
|
|
6
|
-
defaultOptions: {
|
|
7
|
-
queries: {
|
|
8
|
-
queryFn: async ({ queryKey }) => {
|
|
9
|
-
const { data } = await request.get(queryKey[0] as string, {
|
|
10
|
-
params: queryKey[1]
|
|
11
|
-
})
|
|
12
|
-
return data
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
})
|
|
17
|
-
export interface propsType {
|
|
18
|
-
children: ReactNode
|
|
19
|
-
}
|
|
20
|
-
export const Root: FunctionComponent<propsType> = props => {
|
|
21
|
-
return <QueryClientProvider client={queryClient}>{props.children}</QueryClientProvider>
|
|
22
|
-
}
|
|
1
|
+
import { FunctionComponent, ReactNode } from 'react'
|
|
2
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
3
|
+
import { request } from '@/shared/service'
|
|
4
|
+
|
|
5
|
+
const queryClient = new QueryClient({
|
|
6
|
+
defaultOptions: {
|
|
7
|
+
queries: {
|
|
8
|
+
queryFn: async ({ queryKey }) => {
|
|
9
|
+
const { data } = await request.get(queryKey[0] as string, {
|
|
10
|
+
params: queryKey[1]
|
|
11
|
+
})
|
|
12
|
+
return data
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
export interface propsType {
|
|
18
|
+
children: ReactNode
|
|
19
|
+
}
|
|
20
|
+
export const Root: FunctionComponent<propsType> = props => {
|
|
21
|
+
return <QueryClientProvider client={queryClient}>{props.children}</QueryClientProvider>
|
|
22
|
+
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { useLayoutEffect, Suspense } from 'react'
|
|
2
|
-
import { RouterProvider } from 'react-router/dom'
|
|
3
|
-
import { request } from '@/shared/service'
|
|
4
|
-
import { routerInstance } from '@/domain/router'
|
|
5
|
-
import * as AppContext from './app-context'
|
|
6
|
-
|
|
7
|
-
export const Root = () => {
|
|
8
|
-
useLayoutEffect(() => {
|
|
9
|
-
request.interceptors.response.use(
|
|
10
|
-
res => res,
|
|
11
|
-
error => {
|
|
12
|
-
console.log(error)
|
|
13
|
-
}
|
|
14
|
-
)
|
|
15
|
-
}, [])
|
|
16
|
-
|
|
17
|
-
return (
|
|
18
|
-
<AppContext.Root>
|
|
19
|
-
<Suspense fallback={<>loading...</>}>
|
|
20
|
-
<RouterProvider router={routerInstance} />
|
|
21
|
-
</Suspense>
|
|
22
|
-
</AppContext.Root>
|
|
23
|
-
)
|
|
24
|
-
}
|
|
1
|
+
import { useLayoutEffect, Suspense } from 'react'
|
|
2
|
+
import { RouterProvider } from 'react-router/dom'
|
|
3
|
+
import { request } from '@/shared/service'
|
|
4
|
+
import { routerInstance } from '@/domain/router'
|
|
5
|
+
import * as AppContext from './app-context'
|
|
6
|
+
|
|
7
|
+
export const Root = () => {
|
|
8
|
+
useLayoutEffect(() => {
|
|
9
|
+
request.interceptors.response.use(
|
|
10
|
+
res => res,
|
|
11
|
+
error => {
|
|
12
|
+
console.log(error)
|
|
13
|
+
}
|
|
14
|
+
)
|
|
15
|
+
}, [])
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<AppContext.Root>
|
|
19
|
+
<Suspense fallback={<>loading...</>}>
|
|
20
|
+
<RouterProvider router={routerInstance} />
|
|
21
|
+
</Suspense>
|
|
22
|
+
</AppContext.Root>
|
|
23
|
+
)
|
|
24
|
+
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { FunctionComponent } from 'react'
|
|
2
|
-
import { Outlet } from 'react-router'
|
|
3
|
-
import { last } from '
|
|
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
|
-
}
|
|
1
|
+
import { FunctionComponent } from 'react'
|
|
2
|
+
import { Outlet } from 'react-router'
|
|
3
|
+
import { last } from 'es-toolkit'
|
|
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
|
+
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { FunctionComponent } from 'react'
|
|
2
|
-
import { Outlet } from 'react-router'
|
|
3
|
-
import { useMount } from 'react-use'
|
|
4
|
-
import { last } from '
|
|
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
|
+
import { FunctionComponent } from 'react'
|
|
2
|
+
import { Outlet } from 'react-router'
|
|
3
|
+
import { useMount } from 'react-use'
|
|
4
|
+
import { last } from 'es-toolkit'
|
|
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
|
+
}
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@tanstack/react-query": "5.51.15",
|
|
22
22
|
"axios": "1.7.9",
|
|
23
|
-
"define-zustand": "3.
|
|
23
|
+
"define-zustand": "3.4.0",
|
|
24
|
+
"es-toolkit": "1.37.2",
|
|
24
25
|
"immer": "10.0.1",
|
|
25
|
-
"lodash-es": "4.17.21",
|
|
26
26
|
"qs": "6.11.2",
|
|
27
27
|
"react": "18.3.1",
|
|
28
28
|
"react-dom": "18.3.1",
|
|
@@ -40,7 +40,6 @@
|
|
|
40
40
|
"@eslint/js": "9.15.0",
|
|
41
41
|
"@faker-js/faker": "8.4.1",
|
|
42
42
|
"@tailwindcss/vite": "4.1.4",
|
|
43
|
-
"@types/lodash-es": "4.17.12",
|
|
44
43
|
"@types/node": "18.16.0",
|
|
45
44
|
"@types/qs": "6.9.7",
|
|
46
45
|
"@types/react": "18.3.3",
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isRegExp, remove } from 'es-toolkit'
|
|
2
|
+
import { concat, forEach, forOwn, isArray, size } from 'es-toolkit/compat'
|
|
2
3
|
import pkg from '../package.json'
|
|
3
4
|
|
|
4
5
|
export function createChunks(chunks: { [key: string]: Array<string | RegExp> }) {
|
|
5
|
-
const vendor = keys(pkg.dependencies)
|
|
6
|
+
const vendor = Object.keys(pkg.dependencies)
|
|
6
7
|
const result: { [key: string]: string[] } = {}
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
forOwn(chunks, (values, key) => {
|
|
9
10
|
if (!isArray(result[key])) {
|
|
10
11
|
result[key] = []
|
|
11
12
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DependencyList, useEffect, useMemo } from 'react'
|
|
2
2
|
import { useMatches, useSearchParams, NavigateOptions, createBrowserRouter } from 'react-router'
|
|
3
|
-
import {
|
|
3
|
+
import { omit, cloneDeep, last } from 'es-toolkit'
|
|
4
|
+
import { assign, isArray, reduce, get, map, split, forEach } from 'es-toolkit/compat'
|
|
4
5
|
import { stringify, parse } from 'qs'
|
|
5
6
|
import { defineStore } from 'define-zustand'
|
|
6
7
|
import { routeByIdType, routeType, editableRouteType } from './defineRouter.types'
|
|
@@ -10,7 +11,7 @@ export default function defineRouter(router: ReturnType<typeof createBrowserRout
|
|
|
10
11
|
state: () => ({
|
|
11
12
|
routes: cloneDeep(router.routes) as routeType[]
|
|
12
13
|
}),
|
|
13
|
-
|
|
14
|
+
getters: {
|
|
14
15
|
routesById: state => {
|
|
15
16
|
return (function flat(routes: routeType[], parentRoute?: routeByIdType) {
|
|
16
17
|
return reduce(
|
|
@@ -36,7 +37,7 @@ export default function defineRouter(router: ReturnType<typeof createBrowserRout
|
|
|
36
37
|
})(state.routes)
|
|
37
38
|
}
|
|
38
39
|
},
|
|
39
|
-
actions: (
|
|
40
|
+
actions: (setState, getState) => {
|
|
40
41
|
function posToLodashPath(pos: string) {
|
|
41
42
|
if (pos) {
|
|
42
43
|
return `[${split(pos, '-').join('].children[')}]`
|
|
@@ -52,7 +53,7 @@ export default function defineRouter(router: ReturnType<typeof createBrowserRout
|
|
|
52
53
|
const newRoute = cloneDeep(omit(route, ['element', 'errorElement', 'children']))
|
|
53
54
|
updator(newRoute)
|
|
54
55
|
assign(route, newRoute)
|
|
55
|
-
|
|
56
|
+
setState({ routes: newRoutes })
|
|
56
57
|
}
|
|
57
58
|
function getRoute(id: routeType['id'], path?: string | string[]) {
|
|
58
59
|
const { routesById } = getState()
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { useRef, useState, Dispatch, SetStateAction } from 'react'
|
|
2
|
-
import { isFunction } from '
|
|
2
|
+
import { isFunction } from 'es-toolkit'
|
|
3
3
|
|
|
4
4
|
export function useSyncState<S>(initialState: S | (() => S)) {
|
|
5
5
|
const [state, setState] = useState(initialState)
|
|
6
6
|
const syncState = useRef<S>(state)
|
|
7
7
|
|
|
8
8
|
const $setState: Dispatch<SetStateAction<S>> = newState => {
|
|
9
|
-
const $newState = isFunction(newState) ? newState(state) : newState
|
|
9
|
+
const $newState = (isFunction(newState) ? newState(state) : newState) as S
|
|
10
10
|
setState($newState)
|
|
11
11
|
syncState.current = $newState
|
|
12
12
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { useQuery,
|
|
1
|
+
import { useQuery, QueryOptions } from '@tanstack/react-query'
|
|
2
2
|
import { HOME_DATA } from './api'
|
|
3
3
|
|
|
4
|
-
export const useHomeData = (options?:
|
|
4
|
+
export const useHomeData = (options?: QueryOptions) => {
|
|
5
5
|
return useQuery({
|
|
6
6
|
...options,
|
|
7
7
|
queryKey: [HOME_DATA, ...(options?.queryKey || [])]
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
|
2
|
-
/// <reference types="vite-plugin-svgr/client" />
|
|
3
|
-
|
|
4
|
-
interface ImportMetaEnv {
|
|
5
|
-
readonly VITE_BASE_URL: string
|
|
6
|
-
readonly VITE_API_HOST: string
|
|
7
|
-
// 更多环境变量...
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
interface ImportMeta {
|
|
11
|
-
readonly env: ImportMetaEnv
|
|
12
|
-
}
|
|
1
|
+
/// <reference types="vite/client" />
|
|
2
|
+
/// <reference types="vite-plugin-svgr/client" />
|
|
3
|
+
|
|
4
|
+
interface ImportMetaEnv {
|
|
5
|
+
readonly VITE_BASE_URL: string
|
|
6
|
+
readonly VITE_API_HOST: string
|
|
7
|
+
// 更多环境变量...
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface ImportMeta {
|
|
11
|
+
readonly env: ImportMetaEnv
|
|
12
|
+
}
|
|
@@ -4,7 +4,6 @@ import svgr from 'vite-plugin-svgr'
|
|
|
4
4
|
import mockDevServer from 'vite-plugin-mock-dev-server'
|
|
5
5
|
import checker from 'vite-plugin-checker'
|
|
6
6
|
import { visualizer } from 'rollup-plugin-visualizer'
|
|
7
|
-
import { includes } from 'lodash-es'
|
|
8
7
|
import tailwindcss from '@tailwindcss/vite'
|
|
9
8
|
import { createChunks } from './scripts'
|
|
10
9
|
|
|
@@ -53,7 +52,7 @@ export default defineConfig(({ mode }) => {
|
|
|
53
52
|
}
|
|
54
53
|
},
|
|
55
54
|
esbuild: {
|
|
56
|
-
drop:
|
|
55
|
+
drop: ['production', 'analyse'].includes(mode) ? ['console', 'debugger'] : []
|
|
57
56
|
},
|
|
58
57
|
build: {
|
|
59
58
|
sourcemap: mode === 'analyse',
|
|
@@ -26,7 +26,6 @@
|
|
|
26
26
|
"@sveltejs/adapter-auto": "3.3.1",
|
|
27
27
|
"@sveltejs/kit": "2.15.0",
|
|
28
28
|
"@sveltejs/vite-plugin-svelte": "5.0.3",
|
|
29
|
-
"@types/lodash-es": "4.17.12",
|
|
30
29
|
"commitizen": "4.3.0",
|
|
31
30
|
"cross-env": "7.0.3",
|
|
32
31
|
"cssnano": "6.0.1",
|
|
@@ -51,7 +50,7 @@
|
|
|
51
50
|
"vite-plugin-checker": "0.9.0"
|
|
52
51
|
},
|
|
53
52
|
"dependencies": {
|
|
54
|
-
"
|
|
53
|
+
"es-toolkit": "1.37.2",
|
|
55
54
|
"svelte": "5.16.0"
|
|
56
55
|
}
|
|
57
56
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isRegExp, remove } from 'es-toolkit'
|
|
2
|
+
import { concat, forEach, forOwn, isArray, size } from 'es-toolkit/compat'
|
|
2
3
|
import pkg from '../package.json'
|
|
3
4
|
|
|
4
5
|
export function createChunks(chunks: { [key: string]: Array<string | RegExp> }) {
|
|
5
|
-
const vendor = keys(pkg.dependencies)
|
|
6
|
+
const vendor = Object.keys(pkg.dependencies)
|
|
6
7
|
const result: { [key: string]: string[] } = {}
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
forOwn(chunks, (values, key) => {
|
|
9
10
|
if (!isArray(result[key])) {
|
|
10
11
|
result[key] = []
|
|
11
12
|
}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import path from 'path'
|
|
2
1
|
import { defineConfig, loadEnv } from 'vite'
|
|
3
2
|
import { sveltekit } from '@sveltejs/kit/vite'
|
|
4
|
-
import stylelint from 'vite-plugin-stylelint'
|
|
5
3
|
import checker from 'vite-plugin-checker'
|
|
6
4
|
import { visualizer } from 'rollup-plugin-visualizer'
|
|
7
|
-
import { includes } from 'lodash-es'
|
|
8
5
|
import { createChunks } from './scripts'
|
|
9
6
|
|
|
10
7
|
export default defineConfig(({ mode }) => {
|
|
11
8
|
const env = loadEnv(mode, process.cwd(), '')
|
|
12
9
|
const plugins: any[] = [
|
|
13
|
-
stylelint({ cache: false, include: ['**/*.{css,scss,sass,less,styl,ts,tsx}'] }),
|
|
14
10
|
checker({
|
|
15
11
|
enableBuild: false,
|
|
16
12
|
typescript: true,
|
|
@@ -26,7 +22,7 @@ export default defineConfig(({ mode }) => {
|
|
|
26
22
|
return {
|
|
27
23
|
plugins,
|
|
28
24
|
esbuild: {
|
|
29
|
-
drop:
|
|
25
|
+
drop: ['production', 'analyse'].includes(mode) ? ['console', 'debugger'] : []
|
|
30
26
|
},
|
|
31
27
|
build: {
|
|
32
28
|
sourcemap: mode === 'analyse',
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { createVNode, render, VNodeChild } from 'vue'
|
|
2
|
-
import { assign, keys } from 'lodash-es'
|
|
3
2
|
import app from './app'
|
|
4
3
|
|
|
5
4
|
const store = new Map()
|
|
6
5
|
|
|
7
6
|
function reset(oldObj: Record<string, any>, newObj: Record<string, any>) {
|
|
8
|
-
keys(oldObj).forEach(k => {
|
|
7
|
+
Object.keys(oldObj).forEach(k => {
|
|
9
8
|
oldObj[k] = void 0
|
|
10
9
|
})
|
|
11
|
-
assign(oldObj, newObj)
|
|
10
|
+
Object.assign(oldObj, newObj)
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
export function createComponentInstance<
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"axios": "1.7.9",
|
|
23
|
-
"
|
|
23
|
+
"es-toolkit": "1.37.2",
|
|
24
24
|
"pinia": "2.3.1",
|
|
25
25
|
"tailwindcss": "4.1.4",
|
|
26
26
|
"type-fest": "4.33.0",
|
|
@@ -34,7 +34,6 @@
|
|
|
34
34
|
"@eslint/js": "9.15.0",
|
|
35
35
|
"@faker-js/faker": "8.4.1",
|
|
36
36
|
"@tailwindcss/vite": "4.1.4",
|
|
37
|
-
"@types/lodash-es": "4.17.12",
|
|
38
37
|
"@types/mockjs": "1.0.10",
|
|
39
38
|
"@vitejs/plugin-vue": "5.2.1",
|
|
40
39
|
"@vitejs/plugin-vue-jsx": "4.1.1",
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isRegExp, remove } from 'es-toolkit'
|
|
2
|
+
import { concat, forEach, forOwn, isArray, size } from 'es-toolkit/compat'
|
|
2
3
|
import pkg from '../package.json'
|
|
3
4
|
|
|
4
5
|
export function createChunks(chunks: { [key: string]: Array<string | RegExp> }) {
|
|
5
|
-
const vendor = keys(pkg.dependencies)
|
|
6
|
+
const vendor = Object.keys(pkg.dependencies)
|
|
6
7
|
const result: { [key: string]: string[] } = {}
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
forOwn(chunks, (values, key) => {
|
|
9
10
|
if (!isArray(result[key])) {
|
|
10
11
|
result[key] = []
|
|
11
12
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ref, reactive, computed, unref } from 'vue'
|
|
2
|
-
import { cloneDeep,
|
|
2
|
+
import { cloneDeep, pick, isNil } from 'es-toolkit'
|
|
3
|
+
import { assign, size, max } from 'es-toolkit/compat'
|
|
3
4
|
|
|
4
5
|
export interface configType<ListItem, P> {
|
|
5
6
|
/**
|
|
@@ -1,69 +1,68 @@
|
|
|
1
|
-
import { defineConfig, loadEnv } from 'vite'
|
|
2
|
-
import vue from '@vitejs/plugin-vue'
|
|
3
|
-
import vueJsx from '@vitejs/plugin-vue-jsx'
|
|
4
|
-
import svgLoader from 'vite-svg-loader'
|
|
5
|
-
import mockDevServer from 'vite-plugin-mock-dev-server'
|
|
6
|
-
import checker from 'vite-plugin-checker'
|
|
7
|
-
import tailwindcss from '@tailwindcss/vite'
|
|
8
|
-
import { visualizer } from 'rollup-plugin-visualizer'
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
const
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
})
|
|
1
|
+
import { defineConfig, loadEnv } from 'vite'
|
|
2
|
+
import vue from '@vitejs/plugin-vue'
|
|
3
|
+
import vueJsx from '@vitejs/plugin-vue-jsx'
|
|
4
|
+
import svgLoader from 'vite-svg-loader'
|
|
5
|
+
import mockDevServer from 'vite-plugin-mock-dev-server'
|
|
6
|
+
import checker from 'vite-plugin-checker'
|
|
7
|
+
import tailwindcss from '@tailwindcss/vite'
|
|
8
|
+
import { visualizer } from 'rollup-plugin-visualizer'
|
|
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
|
+
tailwindcss(),
|
|
17
|
+
mockDevServer({
|
|
18
|
+
include: ['**/*.mock.{ts,js}']
|
|
19
|
+
}),
|
|
20
|
+
vueJsx({
|
|
21
|
+
enableObjectSlots: false
|
|
22
|
+
}),
|
|
23
|
+
vue(),
|
|
24
|
+
checker({
|
|
25
|
+
enableBuild: false,
|
|
26
|
+
typescript: true,
|
|
27
|
+
eslint: { useFlatConfig: true, lintCommand: 'eslint', dev: { logLevel: ['error'] } }
|
|
28
|
+
}),
|
|
29
|
+
svgLoader()
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
if (mode === 'analyse') {
|
|
33
|
+
plugins.push(visualizer({ open: true, sourcemap: true, brotliSize: true, gzipSize: true }))
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
base: env.VITE_BASE_URL,
|
|
37
|
+
plugins,
|
|
38
|
+
resolve: {
|
|
39
|
+
alias: {
|
|
40
|
+
'@': __dirname
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
esbuild: {
|
|
44
|
+
drop: ['production', 'analyse'].includes(mode) ? ['console', 'debugger'] : []
|
|
45
|
+
},
|
|
46
|
+
build: {
|
|
47
|
+
sourcemap: mode === 'analyse',
|
|
48
|
+
reportCompressedSize: mode === 'analyse',
|
|
49
|
+
rollupOptions: {
|
|
50
|
+
output: {
|
|
51
|
+
manualChunks: createChunks({
|
|
52
|
+
vue: ['vue', 'vue-router']
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
server: {
|
|
58
|
+
host: '0.0.0.0',
|
|
59
|
+
proxy: {
|
|
60
|
+
[proxyBaseUrl]: {
|
|
61
|
+
target: 'http://127.0.0.1',
|
|
62
|
+
changeOrigin: true,
|
|
63
|
+
rewrite: path => path.replace(proxyBaseUrl, '')
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
})
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { createVNode, render, VNodeChild } from 'vue'
|
|
2
|
-
import { assign, keys } from 'lodash-es'
|
|
3
2
|
import app from './app'
|
|
4
3
|
|
|
5
4
|
const store = new Map()
|
|
6
5
|
|
|
7
6
|
function reset(oldObj: Record<string, any>, newObj: Record<string, any>) {
|
|
8
|
-
keys(oldObj).forEach(k => {
|
|
7
|
+
Object.keys(oldObj).forEach(k => {
|
|
9
8
|
oldObj[k] = void 0
|
|
10
9
|
})
|
|
11
|
-
assign(oldObj, newObj)
|
|
10
|
+
Object.assign(oldObj, newObj)
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
export function createComponentInstance<
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"axios": "1.7.9",
|
|
24
|
-
"
|
|
24
|
+
"es-toolkit": "1.37.2",
|
|
25
25
|
"pinia": "2.3.1",
|
|
26
26
|
"tailwindcss": "4.1.4",
|
|
27
27
|
"type-fest": "4.33.0",
|
|
@@ -40,7 +40,6 @@
|
|
|
40
40
|
"@rsbuild/plugin-vue": "1.0.7",
|
|
41
41
|
"@rsdoctor/rspack-plugin": "0.4.13",
|
|
42
42
|
"@tailwindcss/postcss": "4.1.4",
|
|
43
|
-
"@types/lodash-es": "4.17.12",
|
|
44
43
|
"@types/mockjs": "1.0.10",
|
|
45
44
|
"autoprefixer": "10.4.14",
|
|
46
45
|
"commitizen": "4.3.0",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ref, reactive, computed, unref } from 'vue'
|
|
2
|
-
import { cloneDeep,
|
|
2
|
+
import { cloneDeep, pick, isNil } from 'es-toolkit'
|
|
3
|
+
import { assign, size, max } from 'es-toolkit/compat'
|
|
3
4
|
|
|
4
5
|
export interface configType<ListItem, P> {
|
|
5
6
|
/**
|
|
@@ -1,58 +1,56 @@
|
|
|
1
|
-
import { CSSProperties, ReactNode } from 'react'
|
|
2
|
-
import { createRoot } from 'react-dom/client'
|
|
3
|
-
import {
|
|
4
|
-
import { AppContext } from '@/shared/components'
|
|
5
|
-
import { classNameSpace } from '@/entrypoints/content/constants'
|
|
6
|
-
|
|
7
|
-
export enum insertAppStatus {
|
|
8
|
-
success,
|
|
9
|
-
target_not_exist,
|
|
10
|
-
root_existed
|
|
11
|
-
}
|
|
12
|
-
export interface insertAppResultType {
|
|
13
|
-
rootEle: HTMLElement | undefined | null
|
|
14
|
-
result: boolean
|
|
15
|
-
status: insertAppStatus
|
|
16
|
-
}
|
|
17
|
-
export function insertApp<T extends HTMLElement>(
|
|
18
|
-
target: T | null | undefined,
|
|
19
|
-
option: {
|
|
20
|
-
insert?: (rootEle: HTMLElement, target: T) => void
|
|
21
|
-
reactNode: ReactNode
|
|
22
|
-
isReplace?: boolean
|
|
23
|
-
rootId: string
|
|
24
|
-
rootStyle?: CSSProperties
|
|
25
|
-
}
|
|
26
|
-
) {
|
|
27
|
-
const result: insertAppResultType = {
|
|
28
|
-
result: false,
|
|
29
|
-
rootEle: void 0,
|
|
30
|
-
status: insertAppStatus.success
|
|
31
|
-
}
|
|
32
|
-
const rootId = `${import.meta.env.VITE_APP_ID}_${option.rootId}`
|
|
33
|
-
if (!target) {
|
|
34
|
-
result.status = insertAppStatus.target_not_exist
|
|
35
|
-
return result
|
|
36
|
-
}
|
|
37
|
-
result.rootEle = document.createElement('div')
|
|
38
|
-
result.rootEle.className = classNameSpace
|
|
39
|
-
result.rootEle.id = rootId
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return result
|
|
58
|
-
}
|
|
1
|
+
import { CSSProperties, ReactNode } from 'react'
|
|
2
|
+
import { createRoot } from 'react-dom/client'
|
|
3
|
+
import { isFunction } from 'es-toolkit'
|
|
4
|
+
import { AppContext } from '@/shared/components'
|
|
5
|
+
import { classNameSpace } from '@/entrypoints/content/constants'
|
|
6
|
+
|
|
7
|
+
export enum insertAppStatus {
|
|
8
|
+
success,
|
|
9
|
+
target_not_exist,
|
|
10
|
+
root_existed
|
|
11
|
+
}
|
|
12
|
+
export interface insertAppResultType {
|
|
13
|
+
rootEle: HTMLElement | undefined | null
|
|
14
|
+
result: boolean
|
|
15
|
+
status: insertAppStatus
|
|
16
|
+
}
|
|
17
|
+
export function insertApp<T extends HTMLElement>(
|
|
18
|
+
target: T | null | undefined,
|
|
19
|
+
option: {
|
|
20
|
+
insert?: (rootEle: HTMLElement, target: T) => void
|
|
21
|
+
reactNode: ReactNode
|
|
22
|
+
isReplace?: boolean
|
|
23
|
+
rootId: string
|
|
24
|
+
rootStyle?: CSSProperties
|
|
25
|
+
}
|
|
26
|
+
) {
|
|
27
|
+
const result: insertAppResultType = {
|
|
28
|
+
result: false,
|
|
29
|
+
rootEle: void 0,
|
|
30
|
+
status: insertAppStatus.success
|
|
31
|
+
}
|
|
32
|
+
const rootId = `${import.meta.env.VITE_APP_ID}_${option.rootId}`
|
|
33
|
+
if (!target) {
|
|
34
|
+
result.status = insertAppStatus.target_not_exist
|
|
35
|
+
return result
|
|
36
|
+
}
|
|
37
|
+
result.rootEle = document.createElement('div')
|
|
38
|
+
result.rootEle.className = classNameSpace
|
|
39
|
+
result.rootEle.id = rootId
|
|
40
|
+
Object.assign(result.rootEle!.style, option.rootStyle)
|
|
41
|
+
const oldRootEle = target.querySelector?.(`#${rootId}`)
|
|
42
|
+
if (!option.isReplace && oldRootEle) {
|
|
43
|
+
result.status = insertAppStatus.root_existed
|
|
44
|
+
return result
|
|
45
|
+
}
|
|
46
|
+
oldRootEle?.remove()
|
|
47
|
+
if (isFunction(option.insert)) {
|
|
48
|
+
option.insert(result.rootEle, target)
|
|
49
|
+
} else {
|
|
50
|
+
target.appendChild(result.rootEle)
|
|
51
|
+
}
|
|
52
|
+
const root = createRoot(result.rootEle)
|
|
53
|
+
root.render(<AppContext.Root>{option.reactNode}</AppContext.Root>)
|
|
54
|
+
result.result = true
|
|
55
|
+
return result
|
|
56
|
+
}
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"@tanstack/react-query": "5.51.15",
|
|
29
29
|
"@webext-core/messaging": "2.2.0",
|
|
30
30
|
"axios": "1.7.9",
|
|
31
|
-
"define-zustand": "3.
|
|
31
|
+
"define-zustand": "3.4.0",
|
|
32
|
+
"es-toolkit": "1.37.2",
|
|
32
33
|
"immer": "10.0.1",
|
|
33
|
-
"lodash-es": "4.17.21",
|
|
34
34
|
"qs": "6.11.2",
|
|
35
35
|
"react": "18.3.1",
|
|
36
36
|
"react-dom": "18.3.1",
|
|
@@ -44,7 +44,6 @@
|
|
|
44
44
|
"@commitlint/cz-commitlint": "17.5.0",
|
|
45
45
|
"@eslint/js": "9.15.0",
|
|
46
46
|
"@types/chrome": "0.0.254",
|
|
47
|
-
"@types/lodash-es": "4.17.12",
|
|
48
47
|
"@types/node": "18.16.0",
|
|
49
48
|
"@types/qs": "6.9.7",
|
|
50
49
|
"@types/react": "18.3.3",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { useRef, useState, Dispatch, SetStateAction } from 'react'
|
|
2
|
-
import { isFunction } from '
|
|
2
|
+
import { isFunction } from 'es-toolkit'
|
|
3
3
|
|
|
4
4
|
export function useSyncState<S>(initialState: S | (() => S)) {
|
|
5
5
|
const [state, setState] = useState(initialState)
|
|
6
6
|
const syncState = useRef<S>(state)
|
|
7
7
|
|
|
8
8
|
const $setState: Dispatch<SetStateAction<S>> = newState => {
|
|
9
|
-
const $newState = isFunction(newState) ? newState(state) : newState
|
|
9
|
+
const $newState = (isFunction(newState) ? newState(state) : newState) as S
|
|
10
10
|
setState($newState)
|
|
11
11
|
syncState.current = $newState
|
|
12
12
|
}
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import { CSSProperties } from 'react'
|
|
2
|
-
import { isString } from '
|
|
3
|
-
|
|
4
|
-
export const theme = {
|
|
5
|
-
tools: {
|
|
6
|
-
ellipsis: () => ({
|
|
7
|
-
overflow: 'hidden',
|
|
8
|
-
textOverflow: 'ellipsis',
|
|
9
|
-
whiteSpace: 'nowrap'
|
|
10
|
-
}),
|
|
11
|
-
lineClamp: (n: number) => {
|
|
12
|
-
return {
|
|
13
|
-
WebkitLineClamp: `${n}`,
|
|
14
|
-
WebkitBoxOrient: 'vertical',
|
|
15
|
-
overflow: 'hidden',
|
|
16
|
-
display: '-webkit-box'
|
|
17
|
-
} satisfies CSSProperties
|
|
18
|
-
},
|
|
19
|
-
size: (s: string) => ({ width: s, height: s }),
|
|
20
|
-
py: (s: string) => ({ paddingTop: s, paddingBottom: s }),
|
|
21
|
-
px: (s: string) => ({ paddingLeft: s, paddingRight: s }),
|
|
22
|
-
my: (s: string) => ({ marginTop: s, marginBottom: s }),
|
|
23
|
-
mx: (s: string) => ({ marginLeft: s, marginRight: s }),
|
|
24
|
-
flex: (
|
|
25
|
-
align: CSSProperties['alignItems'],
|
|
26
|
-
justify: CSSProperties['justifyContent'],
|
|
27
|
-
vertical?: boolean
|
|
28
|
-
) => {
|
|
29
|
-
return {
|
|
30
|
-
display: 'flex',
|
|
31
|
-
alignItems: align,
|
|
32
|
-
justifyContent: justify,
|
|
33
|
-
flexDirection: vertical ? 'column' : 'row'
|
|
34
|
-
} satisfies CSSProperties
|
|
35
|
-
},
|
|
36
|
-
/** 数字为元素数量,字符串为对应css的值 */
|
|
37
|
-
grid: (rows: number | string, cols: number | string, gap?: number) => {
|
|
38
|
-
return {
|
|
39
|
-
display: 'grid',
|
|
40
|
-
gridTemplateRows: isString(rows) ? rows : `repeat(${rows}, minmax(0, 1fr))`,
|
|
41
|
-
gridTemplateColumns: isString(cols) ? cols : `repeat(${cols}, minmax(0, 1fr))`,
|
|
42
|
-
gap: gap ? `${gap}px` : void 0
|
|
43
|
-
} satisfies CSSProperties
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
export type themeType = typeof theme
|
|
1
|
+
import { CSSProperties } from 'react'
|
|
2
|
+
import { isString } from 'es-toolkit'
|
|
3
|
+
|
|
4
|
+
export const theme = {
|
|
5
|
+
tools: {
|
|
6
|
+
ellipsis: () => ({
|
|
7
|
+
overflow: 'hidden',
|
|
8
|
+
textOverflow: 'ellipsis',
|
|
9
|
+
whiteSpace: 'nowrap'
|
|
10
|
+
}),
|
|
11
|
+
lineClamp: (n: number) => {
|
|
12
|
+
return {
|
|
13
|
+
WebkitLineClamp: `${n}`,
|
|
14
|
+
WebkitBoxOrient: 'vertical',
|
|
15
|
+
overflow: 'hidden',
|
|
16
|
+
display: '-webkit-box'
|
|
17
|
+
} satisfies CSSProperties
|
|
18
|
+
},
|
|
19
|
+
size: (s: string) => ({ width: s, height: s }),
|
|
20
|
+
py: (s: string) => ({ paddingTop: s, paddingBottom: s }),
|
|
21
|
+
px: (s: string) => ({ paddingLeft: s, paddingRight: s }),
|
|
22
|
+
my: (s: string) => ({ marginTop: s, marginBottom: s }),
|
|
23
|
+
mx: (s: string) => ({ marginLeft: s, marginRight: s }),
|
|
24
|
+
flex: (
|
|
25
|
+
align: CSSProperties['alignItems'],
|
|
26
|
+
justify: CSSProperties['justifyContent'],
|
|
27
|
+
vertical?: boolean
|
|
28
|
+
) => {
|
|
29
|
+
return {
|
|
30
|
+
display: 'flex',
|
|
31
|
+
alignItems: align,
|
|
32
|
+
justifyContent: justify,
|
|
33
|
+
flexDirection: vertical ? 'column' : 'row'
|
|
34
|
+
} satisfies CSSProperties
|
|
35
|
+
},
|
|
36
|
+
/** 数字为元素数量,字符串为对应css的值 */
|
|
37
|
+
grid: (rows: number | string, cols: number | string, gap?: number) => {
|
|
38
|
+
return {
|
|
39
|
+
display: 'grid',
|
|
40
|
+
gridTemplateRows: isString(rows) ? rows : `repeat(${rows}, minmax(0, 1fr))`,
|
|
41
|
+
gridTemplateColumns: isString(cols) ? cols : `repeat(${cols}, minmax(0, 1fr))`,
|
|
42
|
+
gap: gap ? `${gap}px` : void 0
|
|
43
|
+
} satisfies CSSProperties
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export type themeType = typeof theme
|