create-packer 1.44.2 → 1.45.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 +1 -1
- package/template/cli/package.json +0 -1
- package/template/web-app/react-rsbuild/postcss.config.cjs +2 -1
- package/template/web-app/react-rsbuild/shared/hooks/defineRouter/deineRouter.tsx +2 -1
- 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/postcss.config.cjs +8 -7
- package/template/web-app/react-vite/scripts/createChunks.ts +4 -3
- package/template/web-app/react-vite/shared/hooks/defineRouter/deineRouter.tsx +2 -1
- 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/vite.config.ts +79 -80
- 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/postcss.config.cjs +8 -7
- 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/postcss.config.cjs +9 -8
- 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/postcss.config.cjs +8 -7
- 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,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'
|
|
@@ -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
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
plugins: {
|
|
3
|
-
'postcss-import': {},
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
1
|
+
module.exports = {
|
|
2
|
+
plugins: {
|
|
3
|
+
'postcss-import': {},
|
|
4
|
+
'postcss-nesting': {},
|
|
5
|
+
autoprefixer: {},
|
|
6
|
+
...(process.env.NODE_ENV === 'production' ? { cssnano: {} } : {})
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -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'
|
|
@@ -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,80 +1,79 @@
|
|
|
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 { visualizer } from 'rollup-plugin-visualizer'
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
const
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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 checker from 'vite-plugin-checker'
|
|
6
|
+
import { visualizer } from 'rollup-plugin-visualizer'
|
|
7
|
+
import tailwindcss from '@tailwindcss/vite'
|
|
8
|
+
import { createChunks } from './scripts'
|
|
9
|
+
|
|
10
|
+
// https://vitejs.dev/config/
|
|
11
|
+
export default defineConfig(({ mode }) => {
|
|
12
|
+
const env = loadEnv(mode, process.cwd(), '')
|
|
13
|
+
const proxyBaseUrl = env.VITE_BASE_URL + env.VITE_API_HOST
|
|
14
|
+
const plugins: any[] = [
|
|
15
|
+
tailwindcss(),
|
|
16
|
+
svgr(),
|
|
17
|
+
mockDevServer({
|
|
18
|
+
include: ['**/*.mock.{ts,js}']
|
|
19
|
+
}),
|
|
20
|
+
checker({
|
|
21
|
+
enableBuild: false,
|
|
22
|
+
typescript: true,
|
|
23
|
+
eslint: { useFlatConfig: true, lintCommand: 'eslint', dev: { logLevel: ['error'] } }
|
|
24
|
+
}),
|
|
25
|
+
react({
|
|
26
|
+
babel: {
|
|
27
|
+
plugins: [
|
|
28
|
+
[
|
|
29
|
+
'babel-plugin-styled-components',
|
|
30
|
+
{
|
|
31
|
+
ssr: false,
|
|
32
|
+
displayName: false,
|
|
33
|
+
fileName: false,
|
|
34
|
+
transpileTemplateLiterals: false
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
if (mode === 'analyse') {
|
|
43
|
+
plugins.push(visualizer({ open: true, sourcemap: true, brotliSize: true, gzipSize: true }))
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
base: env.VITE_BASE_URL,
|
|
48
|
+
plugins,
|
|
49
|
+
resolve: {
|
|
50
|
+
alias: {
|
|
51
|
+
'@': __dirname
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
esbuild: {
|
|
55
|
+
drop: ['production', 'analyse'].includes(mode) ? ['console', 'debugger'] : []
|
|
56
|
+
},
|
|
57
|
+
build: {
|
|
58
|
+
sourcemap: mode === 'analyse',
|
|
59
|
+
reportCompressedSize: mode === 'analyse',
|
|
60
|
+
rollupOptions: {
|
|
61
|
+
output: {
|
|
62
|
+
manualChunks: createChunks({
|
|
63
|
+
react: ['react', 'react-dom']
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
server: {
|
|
69
|
+
host: '0.0.0.0',
|
|
70
|
+
proxy: {
|
|
71
|
+
[proxyBaseUrl]: {
|
|
72
|
+
target: 'http://127.0.0.1',
|
|
73
|
+
changeOrigin: true,
|
|
74
|
+
rewrite: path => path.replace(proxyBaseUrl, '')
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
})
|
|
@@ -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<
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
plugins: {
|
|
3
|
-
'postcss-import': {},
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
1
|
+
module.exports = {
|
|
2
|
+
plugins: {
|
|
3
|
+
'postcss-import': {},
|
|
4
|
+
'postcss-nesting': {},
|
|
5
|
+
autoprefixer: {},
|
|
6
|
+
...(process.env.NODE_ENV === 'production' ? { cssnano: {} } : {})
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -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<
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
plugins: {
|
|
3
|
-
'postcss-import': {},
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
1
|
+
module.exports = {
|
|
2
|
+
plugins: {
|
|
3
|
+
'postcss-import': {},
|
|
4
|
+
'@tailwindcss/postcss': {},
|
|
5
|
+
'postcss-nesting': {},
|
|
6
|
+
autoprefixer: {},
|
|
7
|
+
...(process.env.NODE_ENV === 'production' ? { cssnano: {} } : {})
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
plugins: {
|
|
3
|
-
'postcss-import': {},
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
1
|
+
module.exports = {
|
|
2
|
+
plugins: {
|
|
3
|
+
'postcss-import': {},
|
|
4
|
+
'postcss-nesting': {},
|
|
5
|
+
autoprefixer: {},
|
|
6
|
+
...(process.env.NODE_ENV === 'production' ? { cssnano: {} } : {})
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -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
|