create-packer 1.12.7 → 1.13.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/.gitignore +2 -0
- package/package.json +1 -1
- package/template/react/.editorconfig +14 -0
- package/template/react/.env +1 -0
- package/template/react/.env.development +1 -0
- package/template/react/.eslintrc +55 -52
- package/template/react/.stylelintrc +23 -22
- package/template/react/README.md +14 -13
- package/template/react/package.json +1 -0
- package/template/react/src/providers/index.ts +1 -0
- package/template/react/src/providers/request.ts +7 -0
- package/template/react/src/router/{router.config.tsx → config.tsx} +1 -1
- package/template/react/src/router/home/index.ts +2 -2
- package/template/react/src/router/index.ts +2 -2
- package/template/react/src/vite-env.d.ts +15 -0
- package/template/vue/.editorconfig +14 -0
- package/template/vue/.env +1 -0
- package/template/vue/.env.development +1 -0
- package/template/vue/.eslintrc +24 -4
- package/template/vue/.stylelintrc +23 -22
- package/template/vue/README.md +13 -12
- package/template/vue/package.json +1 -0
- package/template/vue/src/layout/index.ts +1 -0
- package/template/vue/src/layout/layout.vue +3 -0
- package/template/vue/src/main.ts +1 -1
- package/template/vue/src/pages/home/index.ts +1 -1
- package/template/vue/src/pages/not-found/index.ts +1 -0
- package/template/vue/src/{app/index.ts → providers/app.ts} +1 -1
- package/template/vue/src/providers/createApiComponent.ts +22 -0
- package/template/vue/src/providers/index.ts +3 -1
- package/template/vue/src/providers/request.ts +7 -0
- package/template/vue/src/providers/useVisible.ts +2 -1
- package/template/vue/src/router/home/index.ts +2 -0
- package/template/vue/src/router/home/names.ts +3 -0
- package/template/vue/src/router/home/routes.ts +8 -0
- package/template/vue/src/router/index.ts +12 -5
- package/template/vue/src/router/names.ts +5 -0
- package/template/vue/src/vite-env.d.ts +9 -0
- package/template/vue/src/app/app.store.ts +0 -8
- package/template/vue/src/pages/notFound/index.ts +0 -1
- package/template/vue/src/providers/renderToDom.ts +0 -16
- package/template/vue/src/router/router.names.ts +0 -4
- /package/template/react/src/router/home/{home.paths.ts → paths.ts} +0 -0
- /package/template/react/src/router/home/{home.routes.tsx → routes.tsx} +0 -0
- /package/template/react/src/router/{router.paths.ts → paths.ts} +0 -0
- /package/template/vue/src/{app/app.container.vue → app.vue} +0 -0
- /package/template/vue/src/pages/home/{home.container.vue → home.vue} +0 -0
- /package/template/vue/src/pages/{notFound/notFound.container.vue → not-found/not-found.vue} +0 -0
package/.gitignore
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VITE_API_HOST=https://127.0.0.1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VITE_API_HOST=https://127.0.0.1
|
package/template/react/.eslintrc
CHANGED
|
@@ -1,52 +1,55 @@
|
|
|
1
|
-
{
|
|
2
|
-
"root": true,
|
|
3
|
-
"parser": "@typescript-eslint/parser",
|
|
4
|
-
"plugins": ["@typescript-eslint", "prettier"],
|
|
5
|
-
"extends": ["eslint:recommended", "plugin:react/recommended", "plugin:react-hooks/recommended"],
|
|
6
|
-
"settings": {
|
|
7
|
-
"react": {
|
|
8
|
-
"version": "18"
|
|
9
|
-
}
|
|
10
|
-
},
|
|
11
|
-
"env": {
|
|
12
|
-
"browser": true,
|
|
13
|
-
"node": true,
|
|
14
|
-
"es6": true,
|
|
15
|
-
"jest": true
|
|
16
|
-
},
|
|
17
|
-
"parserOptions": {
|
|
18
|
-
"ecmaVersion": 2018,
|
|
19
|
-
"sourceType": "module",
|
|
20
|
-
"ecmaFeatures": {
|
|
21
|
-
"jsx": true
|
|
22
|
-
},
|
|
23
|
-
"useJSXTextNode": true
|
|
24
|
-
},
|
|
25
|
-
"rules": {
|
|
26
|
-
"@typescript-eslint/no-var-requires": 0,
|
|
27
|
-
"@typescript-eslint/explicit-function-return-type": "off",
|
|
28
|
-
"@typescript-eslint/no-explicit-any": 0,
|
|
29
|
-
"@typescript-eslint/no-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"@typescript-eslint/
|
|
37
|
-
"@typescript-eslint/
|
|
38
|
-
"@typescript-eslint/
|
|
39
|
-
"@typescript-eslint/
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"react
|
|
43
|
-
"react/
|
|
44
|
-
"react/
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
1
|
+
{
|
|
2
|
+
"root": true,
|
|
3
|
+
"parser": "@typescript-eslint/parser",
|
|
4
|
+
"plugins": ["@typescript-eslint", "prettier"],
|
|
5
|
+
"extends": ["eslint:recommended", "plugin:react/recommended", "plugin:react-hooks/recommended"],
|
|
6
|
+
"settings": {
|
|
7
|
+
"react": {
|
|
8
|
+
"version": "18"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"env": {
|
|
12
|
+
"browser": true,
|
|
13
|
+
"node": true,
|
|
14
|
+
"es6": true,
|
|
15
|
+
"jest": true
|
|
16
|
+
},
|
|
17
|
+
"parserOptions": {
|
|
18
|
+
"ecmaVersion": 2018,
|
|
19
|
+
"sourceType": "module",
|
|
20
|
+
"ecmaFeatures": {
|
|
21
|
+
"jsx": true
|
|
22
|
+
},
|
|
23
|
+
"useJSXTextNode": true
|
|
24
|
+
},
|
|
25
|
+
"rules": {
|
|
26
|
+
"@typescript-eslint/no-var-requires": 0,
|
|
27
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
28
|
+
"@typescript-eslint/no-explicit-any": 0,
|
|
29
|
+
"@typescript-eslint/no-non-null-assertion": "off",
|
|
30
|
+
"@typescript-eslint/no-inferrable-types": [
|
|
31
|
+
"warn",
|
|
32
|
+
{
|
|
33
|
+
"ignoreParameters": true
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"@typescript-eslint/no-unused-vars": "warn",
|
|
37
|
+
"@typescript-eslint/member-delimiter-style": 0,
|
|
38
|
+
"@typescript-eslint/class-name-casing": 0,
|
|
39
|
+
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
40
|
+
"@typescript-eslint/ban-ts-comment": "off",
|
|
41
|
+
"@typescript-eslint/no-empty-interface": "off",
|
|
42
|
+
"react/prop-types": "off",
|
|
43
|
+
"react/no-find-dom-node": "off",
|
|
44
|
+
"react-hooks/exhaustive-deps": "warn",
|
|
45
|
+
"react/display-name": "off",
|
|
46
|
+
"react/react-in-jsx-scope": "off",
|
|
47
|
+
"prettier/prettier": [
|
|
48
|
+
"error",
|
|
49
|
+
{
|
|
50
|
+
"endOfLine": "auto"
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"no-constant-condition": "off"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "stylelint-config-standard",
|
|
3
|
-
"rules": {
|
|
4
|
-
"indentation": 4,
|
|
5
|
-
"comment-empty-line-before": "never",
|
|
6
|
-
"no-empty-source": null,
|
|
7
|
-
"no-descending-specificity": null,
|
|
8
|
-
"string-quotes": "single",
|
|
9
|
-
"at-rule-no-unknown": [
|
|
10
|
-
true,
|
|
11
|
-
{
|
|
12
|
-
"ignoreAtRules": ["tailwind", "apply"]
|
|
13
|
-
}
|
|
14
|
-
],
|
|
15
|
-
"selector-pseudo-class-no-unknown": [
|
|
16
|
-
true,
|
|
17
|
-
{
|
|
18
|
-
"ignorePseudoClasses": ["global"]
|
|
19
|
-
}
|
|
20
|
-
]
|
|
21
|
-
|
|
22
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"extends": "stylelint-config-standard",
|
|
3
|
+
"rules": {
|
|
4
|
+
"indentation": 4,
|
|
5
|
+
"comment-empty-line-before": "never",
|
|
6
|
+
"no-empty-source": null,
|
|
7
|
+
"no-descending-specificity": null,
|
|
8
|
+
"string-quotes": "single",
|
|
9
|
+
"at-rule-no-unknown": [
|
|
10
|
+
true,
|
|
11
|
+
{
|
|
12
|
+
"ignoreAtRules": ["tailwind", "apply", "use"]
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"selector-pseudo-class-no-unknown": [
|
|
16
|
+
true,
|
|
17
|
+
{
|
|
18
|
+
"ignorePseudoClasses": ["global"]
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"selector-class-pattern": null
|
|
22
|
+
}
|
|
23
|
+
}
|
package/template/react/README.md
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
## Vite + react18 + Typescript
|
|
2
|
-
|
|
3
|
-
### Features
|
|
4
|
-
- Vite 3.x
|
|
5
|
-
- React 18.x
|
|
6
|
-
- Typescript 4.x
|
|
7
|
-
- react-router 6.x
|
|
8
|
-
- Zustand 4.x
|
|
9
|
-
- Tailwindcss 3.x
|
|
10
|
-
- Jest 28.x
|
|
11
|
-
- Eslint
|
|
12
|
-
- Prettier
|
|
13
|
-
-
|
|
1
|
+
## Vite + react18 + Typescript
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
- Vite 3.x
|
|
5
|
+
- React 18.x
|
|
6
|
+
- Typescript 4.x
|
|
7
|
+
- react-router 6.x
|
|
8
|
+
- Zustand 4.x
|
|
9
|
+
- Tailwindcss 3.x
|
|
10
|
+
- Jest 28.x
|
|
11
|
+
- Eslint
|
|
12
|
+
- Prettier
|
|
13
|
+
- axios 1.x
|
|
14
|
+
- Alias @ to <project_root>/src
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { lazy } from 'react'
|
|
2
2
|
import { createBrowserRouter } from 'react-router-dom'
|
|
3
3
|
import * as home from './home'
|
|
4
|
-
import paths from './
|
|
4
|
+
import paths from './paths'
|
|
5
5
|
|
|
6
6
|
const Layout = lazy(() => import('@/layout'))
|
|
7
7
|
const NotFound = lazy(() => import('@/pages/notFound'))
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as routes } from './
|
|
2
|
-
export { default as paths } from './
|
|
1
|
+
export { default as routes } from './routes'
|
|
2
|
+
export { default as paths } from './paths'
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as routePaths } from '
|
|
2
|
-
export { default as router } from './
|
|
1
|
+
export { default as routePaths } from './paths'
|
|
2
|
+
export { default as router } from './config'
|
|
@@ -1 +1,16 @@
|
|
|
1
1
|
/// <reference types="vite/client" />
|
|
2
|
+
|
|
3
|
+
declare module '*.vue' {
|
|
4
|
+
import type { DefineComponent } from 'vue'
|
|
5
|
+
const component: DefineComponent<{}, {}, any>
|
|
6
|
+
export default component
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface ImportMetaEnv {
|
|
10
|
+
readonly VITE_API_HOST: string
|
|
11
|
+
// 更多环境变量...
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface ImportMeta {
|
|
15
|
+
readonly env: ImportMetaEnv
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VITE_API_HOST=https://127.0.0.1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VITE_API_HOST=https://127.0.0.1
|
package/template/vue/.eslintrc
CHANGED
|
@@ -14,19 +14,23 @@
|
|
|
14
14
|
},
|
|
15
15
|
"plugins": ["prettier"],
|
|
16
16
|
"extends": [
|
|
17
|
-
"plugin:vue/vue3-recommended",
|
|
18
17
|
"eslint:recommended",
|
|
19
|
-
"plugin:@typescript-eslint/recommended"
|
|
18
|
+
"plugin:@typescript-eslint/recommended",
|
|
19
|
+
"plugin:vue/vue3-recommended"
|
|
20
20
|
],
|
|
21
21
|
"parser": "vue-eslint-parser",
|
|
22
22
|
"parserOptions": {
|
|
23
23
|
"parser": "@typescript-eslint/parser",
|
|
24
|
-
"ecmaVersion": 2021
|
|
24
|
+
"ecmaVersion": 2021,
|
|
25
|
+
"ecmaFeatures": {
|
|
26
|
+
"jsx": true
|
|
27
|
+
}
|
|
25
28
|
},
|
|
26
29
|
"rules": {
|
|
27
30
|
"@typescript-eslint/no-var-requires": 0,
|
|
28
31
|
"@typescript-eslint/explicit-function-return-type": "off",
|
|
29
32
|
"@typescript-eslint/no-explicit-any": 0,
|
|
33
|
+
"@typescript-eslint/no-non-null-assertion": "off",
|
|
30
34
|
"@typescript-eslint/no-inferrable-types": [
|
|
31
35
|
"warn",
|
|
32
36
|
{
|
|
@@ -38,6 +42,7 @@
|
|
|
38
42
|
"@typescript-eslint/class-name-casing": 0,
|
|
39
43
|
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
40
44
|
"@typescript-eslint/ban-ts-comment": "off",
|
|
45
|
+
"@typescript-eslint/no-empty-interface": "off",
|
|
41
46
|
"prettier/prettier": [
|
|
42
47
|
"error",
|
|
43
48
|
{
|
|
@@ -45,6 +50,21 @@
|
|
|
45
50
|
}
|
|
46
51
|
],
|
|
47
52
|
"vue/multi-word-component-names": 0,
|
|
48
|
-
"vue/html-indent": ["error", 4]
|
|
53
|
+
"vue/html-indent": ["error", 4],
|
|
54
|
+
"vue/html-self-closing": [
|
|
55
|
+
"error",
|
|
56
|
+
{
|
|
57
|
+
"html": {
|
|
58
|
+
"void": "always",
|
|
59
|
+
"normal": "always",
|
|
60
|
+
"component": "always"
|
|
61
|
+
},
|
|
62
|
+
"svg": "always",
|
|
63
|
+
"math": "always"
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
"vue/max-attributes-per-line": "off",
|
|
67
|
+
"vue/singleline-html-element-content-newline": "off",
|
|
68
|
+
"no-constant-condition": "off"
|
|
49
69
|
}
|
|
50
70
|
}
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "stylelint-config-standard",
|
|
3
|
-
"rules": {
|
|
4
|
-
"indentation": 4,
|
|
5
|
-
"comment-empty-line-before": "never",
|
|
6
|
-
"no-empty-source": null,
|
|
7
|
-
"no-descending-specificity": null,
|
|
8
|
-
"string-quotes": "single",
|
|
9
|
-
"at-rule-no-unknown": [
|
|
10
|
-
true,
|
|
11
|
-
{
|
|
12
|
-
"ignoreAtRules": ["tailwind", "apply"]
|
|
13
|
-
}
|
|
14
|
-
],
|
|
15
|
-
"selector-pseudo-class-no-unknown": [
|
|
16
|
-
true,
|
|
17
|
-
{
|
|
18
|
-
"ignorePseudoClasses": ["global"]
|
|
19
|
-
}
|
|
20
|
-
]
|
|
21
|
-
|
|
22
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"extends": "stylelint-config-standard",
|
|
3
|
+
"rules": {
|
|
4
|
+
"indentation": 4,
|
|
5
|
+
"comment-empty-line-before": "never",
|
|
6
|
+
"no-empty-source": null,
|
|
7
|
+
"no-descending-specificity": null,
|
|
8
|
+
"string-quotes": "single",
|
|
9
|
+
"at-rule-no-unknown": [
|
|
10
|
+
true,
|
|
11
|
+
{
|
|
12
|
+
"ignoreAtRules": ["tailwind", "apply", "use"]
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"selector-pseudo-class-no-unknown": [
|
|
16
|
+
true,
|
|
17
|
+
{
|
|
18
|
+
"ignorePseudoClasses": ["global"]
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"selector-class-pattern": null
|
|
22
|
+
}
|
|
23
|
+
}
|
package/template/vue/README.md
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
## Vite + Vue3.x + Typescript
|
|
2
|
-
|
|
3
|
-
### Features
|
|
4
|
-
- Vite 3.x
|
|
5
|
-
- Vue 3.x
|
|
6
|
-
- Typescript 4.x
|
|
7
|
-
- vue-router 4.x
|
|
8
|
-
- pinia 2.x
|
|
9
|
-
- Tailwindcss 3.x
|
|
10
|
-
- Eslint
|
|
11
|
-
- Prettier
|
|
12
|
-
-
|
|
1
|
+
## Vite + Vue3.x + Typescript
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
- Vite 3.x
|
|
5
|
+
- Vue 3.x
|
|
6
|
+
- Typescript 4.x
|
|
7
|
+
- vue-router 4.x
|
|
8
|
+
- pinia 2.x
|
|
9
|
+
- Tailwindcss 3.x
|
|
10
|
+
- Eslint
|
|
11
|
+
- Prettier
|
|
12
|
+
- axios 1.x
|
|
13
|
+
- Alias @ to <project_root>/src
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './layout.vue'
|
package/template/vue/src/main.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from './home.
|
|
1
|
+
export { default } from './home.vue'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './not-found.vue'
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import app from '@/providers/app'
|
|
2
|
+
import { createVNode, render } from 'vue'
|
|
3
|
+
import { assign } from 'lodash-es'
|
|
4
|
+
|
|
5
|
+
const store = new Map()
|
|
6
|
+
export default function createApiComponent(component: any, props?: Record<string, any>) {
|
|
7
|
+
const container = document.createElement('div')
|
|
8
|
+
let vNode = store.get(component)
|
|
9
|
+
if (!vNode) {
|
|
10
|
+
vNode = createVNode(component)
|
|
11
|
+
vNode.appContext = app._context || {}
|
|
12
|
+
store.set(component, vNode)
|
|
13
|
+
}
|
|
14
|
+
assign(vNode.component.props, props)
|
|
15
|
+
render(vNode, container)
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
instance: vNode,
|
|
19
|
+
el: container.firstElementChild,
|
|
20
|
+
...vNode.component?.exposed
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -2,11 +2,12 @@ import { ref } from 'vue'
|
|
|
2
2
|
import { isFunction } from 'lodash-es'
|
|
3
3
|
|
|
4
4
|
export interface useVisibleConfigType {
|
|
5
|
+
defaultVisible?: boolean
|
|
5
6
|
onBeforeShow?: () => Promise<boolean | void>
|
|
6
7
|
onBeforeHide?: () => Promise<boolean | void>
|
|
7
8
|
}
|
|
8
9
|
export default function useVisible(config?: useVisibleConfigType) {
|
|
9
|
-
const visible = ref(false)
|
|
10
|
+
const visible = ref(config?.defaultVisible ?? false)
|
|
10
11
|
const onShow = async () => {
|
|
11
12
|
let isShow: boolean | void = true
|
|
12
13
|
if (isFunction(config?.onBeforeShow)) {
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
|
|
2
|
-
import names from './
|
|
2
|
+
import names from './names'
|
|
3
|
+
import * as homeRouter from './home'
|
|
4
|
+
import Layout from '@/layout'
|
|
3
5
|
|
|
4
|
-
const routes:
|
|
5
|
-
{
|
|
6
|
-
|
|
6
|
+
const routes: RouteRecordRaw[] = [
|
|
7
|
+
{
|
|
8
|
+
path: '/',
|
|
9
|
+
component: Layout,
|
|
10
|
+
redirect: { name: names.home },
|
|
11
|
+
children: [...homeRouter.routes]
|
|
12
|
+
},
|
|
13
|
+
{ path: '/404', name: names.notFound, component: () => import('@/pages/not-found') }
|
|
7
14
|
]
|
|
8
15
|
const router = createRouter({
|
|
9
16
|
history: createWebHashHistory(),
|
|
10
17
|
routes
|
|
11
18
|
})
|
|
12
19
|
router.beforeEach(async to => {
|
|
13
|
-
if (!Object.values(names).includes(to.name
|
|
20
|
+
if (!Object.values(names).includes(to.name as string)) {
|
|
14
21
|
return {
|
|
15
22
|
replace: true,
|
|
16
23
|
name: names.notFound
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './notFound.container.vue'
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { createVNode, render } from 'vue'
|
|
2
|
-
import { merge } from 'lodash-es'
|
|
3
|
-
|
|
4
|
-
export default function renderToDom(component: any, props?: Record<string, any>) {
|
|
5
|
-
const container = document.createElement('div')
|
|
6
|
-
const instance = createVNode(component)
|
|
7
|
-
merge(instance.props, props)
|
|
8
|
-
render(instance, container)
|
|
9
|
-
document.body.appendChild(container)
|
|
10
|
-
|
|
11
|
-
return {
|
|
12
|
-
context: instance,
|
|
13
|
-
destroy: () => render(null, container),
|
|
14
|
-
...instance.component?.exposed
|
|
15
|
-
}
|
|
16
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|