create-packer 1.40.0 → 1.41.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.
Files changed (55) hide show
  1. package/package.json +1 -1
  2. package/template/web-app/vue/router/index.ts +2 -2
  3. package/template/web-app/vue-rsbuild/.editorconfig +14 -0
  4. package/template/web-app/vue-rsbuild/.env +2 -0
  5. package/template/web-app/vue-rsbuild/.env.development +2 -0
  6. package/template/web-app/vue-rsbuild/.gitignore +27 -0
  7. package/template/web-app/vue-rsbuild/.husky/commit-msg +4 -0
  8. package/template/web-app/vue-rsbuild/.husky/pre-commit +4 -0
  9. package/template/web-app/vue-rsbuild/.prettierignore +6 -0
  10. package/template/web-app/vue-rsbuild/.prettierrc +18 -0
  11. package/template/web-app/vue-rsbuild/.stylelintignore +4 -0
  12. package/template/web-app/vue-rsbuild/.stylelintrc +29 -0
  13. package/template/web-app/vue-rsbuild/.vscode/extensions.json +9 -0
  14. package/template/web-app/vue-rsbuild/README.md +14 -0
  15. package/template/web-app/vue-rsbuild/commitlint.config.cjs +1 -0
  16. package/template/web-app/vue-rsbuild/domain/app/app.ts +4 -0
  17. package/template/web-app/vue-rsbuild/domain/app/components/app.vue +18 -0
  18. package/template/web-app/vue-rsbuild/domain/app/components/index.ts +1 -0
  19. package/template/web-app/vue-rsbuild/domain/app/createComponentInstance.ts +44 -0
  20. package/template/web-app/vue-rsbuild/domain/app/index.ts +3 -0
  21. package/template/web-app/vue-rsbuild/env.d.ts +17 -0
  22. package/template/web-app/vue-rsbuild/eslint.config.js +109 -0
  23. package/template/web-app/vue-rsbuild/index.html +12 -0
  24. package/template/web-app/vue-rsbuild/main.ts +7 -0
  25. package/template/web-app/vue-rsbuild/package.json +73 -0
  26. package/template/web-app/vue-rsbuild/pages/home/index.ts +1 -0
  27. package/template/web-app/vue-rsbuild/pages/home/view.vue +16 -0
  28. package/template/web-app/vue-rsbuild/pages/index.ts +1 -0
  29. package/template/web-app/vue-rsbuild/pages/index.vue +3 -0
  30. package/template/web-app/vue-rsbuild/pages/not-found.vue +3 -0
  31. package/template/web-app/vue-rsbuild/postcss.config.cjs +9 -0
  32. package/template/web-app/vue-rsbuild/public/vite.svg +1 -0
  33. package/template/web-app/vue-rsbuild/router/home/index.ts +2 -0
  34. package/template/web-app/vue-rsbuild/router/home/names.ts +3 -0
  35. package/template/web-app/vue-rsbuild/router/home/routes.ts +8 -0
  36. package/template/web-app/vue-rsbuild/router/index.ts +26 -0
  37. package/template/web-app/vue-rsbuild/router/names.ts +5 -0
  38. package/template/web-app/vue-rsbuild/rsbuild.config.ts +74 -0
  39. package/template/web-app/vue-rsbuild/scripts/createChunks.ts +26 -0
  40. package/template/web-app/vue-rsbuild/scripts/index.ts +1 -0
  41. package/template/web-app/vue-rsbuild/shared/assets/vue.svg +1 -0
  42. package/template/web-app/vue-rsbuild/shared/components/index.ts +0 -0
  43. package/template/web-app/vue-rsbuild/shared/constant/index.ts +0 -0
  44. package/template/web-app/vue-rsbuild/shared/hooks/index.ts +2 -0
  45. package/template/web-app/vue-rsbuild/shared/hooks/useList.ts +104 -0
  46. package/template/web-app/vue-rsbuild/shared/hooks/useVisible.ts +27 -0
  47. package/template/web-app/vue-rsbuild/shared/service/api.ts +1 -0
  48. package/template/web-app/vue-rsbuild/shared/service/home.ts +10 -0
  49. package/template/web-app/vue-rsbuild/shared/service/index.ts +3 -0
  50. package/template/web-app/vue-rsbuild/shared/service/request.ts +5 -0
  51. package/template/web-app/vue-rsbuild/shared/tools/index.ts +0 -0
  52. package/template/web-app/vue-rsbuild/style.css +3 -0
  53. package/template/web-app/vue-rsbuild/tailwind.config.cjs +18 -0
  54. package/template/web-app/vue-rsbuild/tsconfig.json +24 -0
  55. package/template/web-app/vue-rsbuild/tsconfig.node.json +10 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-packer",
3
- "version": "1.40.0",
3
+ "version": "1.41.0",
4
4
  "main": "index.js",
5
5
  "repository": "https://github.com/kevily/create-packer",
6
6
  "author": "1k <bug_zero@163.com>",
@@ -1,4 +1,4 @@
1
- import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
1
+ import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
2
2
  import names from './names'
3
3
  import * as homeRouter from './home'
4
4
 
@@ -21,6 +21,6 @@ const routes: RouteRecordRaw[] = [
21
21
  export { default as routerNames } from './names'
22
22
 
23
23
  export const router = createRouter({
24
- history: createWebHashHistory(),
24
+ history: createWebHistory(import.meta.env.PUBLIC_BASE_URL),
25
25
  routes
26
26
  })
@@ -0,0 +1,14 @@
1
+ # editorconfig.org
2
+
3
+ root = true
4
+
5
+ [*]
6
+ charset = utf-8
7
+ indent_size = 4
8
+ indent_style = space
9
+ insert_final_newline = true
10
+ trim_trailing_whitespace = true
11
+
12
+
13
+ [*.md]
14
+ trim_trailing_whitespace = false
@@ -0,0 +1,2 @@
1
+ PUBLIC_BASE_URL=/
2
+ PUBLIC_API_HOST=
@@ -0,0 +1,2 @@
1
+ PUBLIC_BASE_URL=/dev
2
+ PUBLIC_API_HOST=/api
@@ -0,0 +1,27 @@
1
+ # Logs
2
+ logs
3
+ *.log
4
+ npm-debug.log*
5
+ yarn-debug.log*
6
+ yarn-error.log*
7
+ pnpm-debug.log*
8
+ lerna-debug.log*
9
+
10
+ node_modules
11
+ dist
12
+ dist-ssr
13
+ *.local
14
+ stats.html
15
+ vite.config.ts.*
16
+
17
+ # Editor directories and files
18
+ .vscode/*
19
+ !.vscode/extensions.json
20
+ .history
21
+ .idea
22
+ .DS_Store
23
+ *.suo
24
+ *.ntvs*
25
+ *.njsproj
26
+ *.sln
27
+ *.sw?
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ npx --no -- commitlint --edit
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ npm run lint
@@ -0,0 +1,6 @@
1
+ **/*.md
2
+ **/*.svg
3
+ **/*.ejs
4
+ **/*.html
5
+ .history
6
+ dist
@@ -0,0 +1,18 @@
1
+ {
2
+ "overrides": [
3
+ {
4
+ "files": ".prettierrc",
5
+ "options": { "parser": "json" }
6
+ }
7
+ ],
8
+ "printWidth": 100,
9
+ "tabWidth": 4,
10
+ "useTabs": false,
11
+ "semi": false,
12
+ "singleQuote": true,
13
+ "trailingComma": "none",
14
+ "bracketSpacing": true,
15
+ "bracketSameLine": false,
16
+ "arrowParens": "avoid",
17
+ "rangeStart": 0
18
+ }
@@ -0,0 +1,4 @@
1
+ node_modules
2
+ /dist
3
+ /.vscode
4
+ /.history
@@ -0,0 +1,29 @@
1
+ {
2
+ "extends": "stylelint-config-standard-scss",
3
+ "rules": {
4
+ "comment-empty-line-before": "never",
5
+ "no-empty-source": null,
6
+ "alpha-value-notation": null,
7
+ "color-function-notation": null,
8
+ "at-rule-no-unknown": [
9
+ true,
10
+ {
11
+ "ignoreAtRules": ["tailwind", "apply", "use"]
12
+ }
13
+ ],
14
+ "declaration-block-no-redundant-longhand-properties": null,
15
+ "selector-pseudo-class-no-unknown": [
16
+ true,
17
+ {
18
+ "ignorePseudoClasses": ["global"]
19
+ }
20
+ ],
21
+ "selector-class-pattern": null,
22
+ "scss/at-rule-no-unknown": [
23
+ true,
24
+ {
25
+ "ignoreAtRules": ["tailwind", "apply"]
26
+ }
27
+ ]
28
+ }
29
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "recommendations": [
3
+ "vue.volar",
4
+ "vue.vscode-typescript-vue-plugin",
5
+ "dbaeumer.vscode-eslint",
6
+ "stylelint.vscode-stylelint",
7
+ "esbenp.prettier-vscode"
8
+ ]
9
+ }
@@ -0,0 +1,14 @@
1
+ ## Vite + Vue3.x + Typescript
2
+
3
+ ### Features
4
+
5
+ - Vite
6
+ - Vue
7
+ - Typescript
8
+ - vue-router
9
+ - pinia
10
+ - Tailwindcss
11
+ - Eslint
12
+ - Prettier
13
+ - axios
14
+ - Alias @ to <project_root>/src
@@ -0,0 +1 @@
1
+ module.exports = { extends: ['@commitlint/config-conventional'] }
@@ -0,0 +1,4 @@
1
+ import { createApp } from 'vue'
2
+ import { App } from './components'
3
+
4
+ export default createApp(App)
@@ -0,0 +1,18 @@
1
+ <template>
2
+ <router-view />
3
+ </template>
4
+
5
+ <script setup lang="ts">
6
+ import { router, routerNames } from '@/router'
7
+
8
+ router.beforeEach(async to => {
9
+ if (!Object.values(routerNames).includes(to.name as string)) {
10
+ return {
11
+ replace: true,
12
+ name: routerNames.notFound
13
+ }
14
+ }
15
+ })
16
+ </script>
17
+
18
+ <style scoped></style>
@@ -0,0 +1 @@
1
+ export { default as App } from './app.vue'
@@ -0,0 +1,44 @@
1
+ import { createVNode, render, VNodeChild } from 'vue'
2
+ import { assign, keys } from 'lodash-es'
3
+ import app from './app'
4
+
5
+ const store = new Map()
6
+
7
+ function reset(oldObj: Record<string, any>, newObj: Record<string, any>) {
8
+ keys(oldObj).forEach(k => {
9
+ oldObj[k] = void 0
10
+ })
11
+ assign(oldObj, newObj)
12
+ }
13
+
14
+ export function createComponentInstance<
15
+ P extends Record<string, any>,
16
+ E extends Record<string, any>,
17
+ Slots extends Record<string, () => VNodeChild> = Record<string, () => VNodeChild>
18
+ >(name: string, component: any, props?: P, slots?: Slots) {
19
+ let vNode = store.get(name)
20
+ function updateProps(props: Partial<P>) {
21
+ reset(vNode.component.props, props)
22
+ }
23
+
24
+ function updateSlots(slots: Partial<Record<string, () => VNodeChild>>) {
25
+ reset(vNode.component.slots, slots)
26
+ }
27
+
28
+ if (!vNode) {
29
+ const container = document.createElement('div')
30
+ vNode = createVNode(component, props, slots)
31
+ vNode.appContext = app._context || {}
32
+ store.set(name, vNode)
33
+ render(vNode, container)
34
+ } else {
35
+ updateProps(props || {})
36
+ updateSlots(slots || {})
37
+ }
38
+ return {
39
+ instance: vNode,
40
+ updateProps,
41
+ updateSlots,
42
+ ...(vNode.component?.exposed as E)
43
+ }
44
+ }
@@ -0,0 +1,3 @@
1
+ export { default as app } from './app'
2
+ export * from './components'
3
+ export * from './createComponentInstance'
@@ -0,0 +1,17 @@
1
+ /// <reference types="@rsbuild/core/types" />
2
+
3
+ declare module '*.vue' {
4
+ import type { DefineComponent } from 'vue'
5
+ const component: DefineComponent<Record<string, any>, Record<string, any>, any>
6
+ export default component
7
+ }
8
+
9
+ interface ImportMetaEnv {
10
+ readonly PUBLIC_BASE_URL: string
11
+ readonly PUBLIC_API_HOST: string
12
+ // 更多环境变量...
13
+ }
14
+
15
+ interface ImportMeta {
16
+ readonly env: ImportMetaEnv
17
+ }
@@ -0,0 +1,109 @@
1
+ import eslint from '@eslint/js'
2
+ import globals from 'globals'
3
+ import tseslint from 'typescript-eslint'
4
+ import importPlugin from 'eslint-plugin-import'
5
+ import pluginVue from 'eslint-plugin-vue'
6
+
7
+ const scriptExtensions = ['js', 'jsx', 'mjs', 'cjs', 'ts', 'tsx']
8
+ const files = [...scriptExtensions.map(ext => `**/*.${ext}`), '**/*.vue']
9
+
10
+ export default tseslint.config([
11
+ { ignores: ['**/node_modules/', 'dist/', '.history/', '.vscode'] },
12
+ eslint.configs.recommended,
13
+ importPlugin.flatConfigs.recommended,
14
+ tseslint.configs.recommended,
15
+ pluginVue.configs['flat/recommended'],
16
+ {
17
+ files,
18
+ languageOptions: {
19
+ ecmaVersion: 2018,
20
+ sourceType: 'module',
21
+ parserOptions: {
22
+ ecmaFeatures: {
23
+ jsx: true
24
+ },
25
+ useJSXTextNode: true
26
+ },
27
+ globals: {
28
+ ...globals.browser,
29
+ ...globals.node
30
+ }
31
+ },
32
+ settings: {
33
+ 'import/resolver': {
34
+ typescript: true,
35
+ node: true
36
+ }
37
+ },
38
+ rules: {
39
+ 'import/export': 'off',
40
+ 'import/namespace': 'off',
41
+ 'import/default': 'off',
42
+ 'import/no-named-as-default-member': 'off',
43
+ 'import/no-named-as-default': 'off',
44
+ 'import/order': [
45
+ 'error',
46
+ {
47
+ groups: [
48
+ 'builtin',
49
+ 'external',
50
+ 'internal',
51
+ 'parent',
52
+ 'sibling',
53
+ 'index',
54
+ 'object',
55
+ 'type'
56
+ ],
57
+ pathGroups: [
58
+ { pattern: 'vue', group: 'external', position: 'before' },
59
+ { pattern: 'vue-router', group: 'external', position: 'before' }
60
+ ],
61
+ pathGroupsExcludedImportTypes: ['vue', 'vue-router']
62
+ }
63
+ ],
64
+ 'no-case-declarations': 'off',
65
+ '@typescript-eslint/no-unused-expressions': 'off',
66
+ '@typescript-eslint/no-empty-object-type': 'off',
67
+ '@typescript-eslint/no-var-requires': 0,
68
+ '@typescript-eslint/explicit-function-return-type': 'off',
69
+ '@typescript-eslint/no-explicit-any': 0,
70
+ '@typescript-eslint/no-non-null-assertion': 'off',
71
+ '@typescript-eslint/no-inferrable-types': [
72
+ 'warn',
73
+ {
74
+ ignoreParameters: true
75
+ }
76
+ ],
77
+ '@typescript-eslint/no-unused-vars': [
78
+ 'warn',
79
+ {
80
+ argsIgnorePattern: '^_'
81
+ }
82
+ ],
83
+ '@typescript-eslint/member-delimiter-style': 0,
84
+ '@typescript-eslint/class-name-casing': 0,
85
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
86
+ '@typescript-eslint/ban-ts-comment': 'off',
87
+ '@typescript-eslint/no-empty-interface': 'off',
88
+ 'vue/multi-word-component-names': 0,
89
+ 'vue/html-indent': ['error', 4],
90
+ 'vue/require-default-prop': 'off',
91
+ 'vue/one-component-per-file': 'off',
92
+ 'vue/html-self-closing': [
93
+ 'error',
94
+ {
95
+ html: {
96
+ void: 'always',
97
+ normal: 'always',
98
+ component: 'always'
99
+ },
100
+ svg: 'always',
101
+ math: 'always'
102
+ }
103
+ ],
104
+ 'vue/max-attributes-per-line': 'off',
105
+ 'vue/singleline-html-element-content-newline': 'off',
106
+ 'no-constant-condition': 'off'
107
+ }
108
+ }
109
+ ])
@@ -0,0 +1,12 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ </head>
8
+ <body>
9
+ <div id="app"></div>
10
+ <script type="module" src="/main.ts"></script>
11
+ </body>
12
+ </html>
@@ -0,0 +1,7 @@
1
+ import { createPinia } from 'pinia'
2
+ import { VueQueryPlugin } from '@tanstack/vue-query'
3
+ import { router } from '@/router'
4
+ import { app } from '@/domain/app'
5
+ import './style.css'
6
+
7
+ app.use(VueQueryPlugin).use(createPinia()).use(router).mount('#app')
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "vue-vite",
3
+ "private": true,
4
+ "version": "0.0.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "prepare": "husky install",
8
+ "dev": "rsbuild dev",
9
+ "build": "rsbuild build",
10
+ "build:analyse": "rsbuild build --env-mode analyse",
11
+ "build:rsdoctor": "cross-env RSDOCTOR=true rsbuild build",
12
+ "preview": "rsbuild preview",
13
+ "up:rsbuild": "pnpm up @rsbuild/* -L",
14
+ "format": "prettier --write \"**/*.{vue,ts,js,tsx,jsx,json,css,scss,less}\"",
15
+ "lint": "vue-tsc --noEmit && eslint --no-error-on-unmatched-pattern && stylelint **/*.{css,scss,less}",
16
+ "lint:fix": "eslint --fix && stylelint **/*.{css,scss,less} --fix",
17
+ "cz": "cz",
18
+ "push": "npm run commit && git push",
19
+ "commit": "git add . && npm run cz",
20
+ "up:vite": "pnpm up vite @vitejs/* vite-plugin-* -L"
21
+ },
22
+ "dependencies": {
23
+ "@tanstack/vue-query": "5.51.15",
24
+ "axios": "1.7.9",
25
+ "lodash-es": "4.17.21",
26
+ "pinia": "2.3.1",
27
+ "vue": "3.5.13",
28
+ "vue-router": "4.5.0"
29
+ },
30
+ "devDependencies": {
31
+ "@commitlint/cli": "17.6.1",
32
+ "@commitlint/config-conventional": "17.6.1",
33
+ "@commitlint/cz-commitlint": "17.5.0",
34
+ "@eslint/js": "9.15.0",
35
+ "@rsbuild/core": "1.2.2",
36
+ "@rsbuild/plugin-eslint": "1.1.0",
37
+ "@rsbuild/plugin-vue": "1.0.5",
38
+ "@rsbuild/plugin-styled-components": "1.2.0",
39
+ "@rsbuild/plugin-svgr": "1.0.6",
40
+ "@rsbuild/plugin-type-check": "1.2.1",
41
+ "@rsdoctor/rspack-plugin": "0.4.13",
42
+ "@faker-js/faker": "8.4.1",
43
+ "@types/lodash-es": "4.17.12",
44
+ "@types/mockjs": "1.0.10",
45
+ "autoprefixer": "10.4.14",
46
+ "commitizen": "4.3.0",
47
+ "cssnano": "6.0.0",
48
+ "eslint": "9.17.0",
49
+ "eslint-import-resolver-typescript": "3.7.0",
50
+ "eslint-plugin-import": "2.31.0",
51
+ "eslint-plugin-vue": "9.32.0",
52
+ "globals": "15.12.0",
53
+ "husky": "9.1.6",
54
+ "inquirer": "8.1.2",
55
+ "postcss": "8.4.38",
56
+ "postcss-import": "16.1.0",
57
+ "postcss-nesting": "12.1.1",
58
+ "prettier": "3.2.5",
59
+ "rollup-plugin-visualizer": "5.12.0",
60
+ "stylelint": "16.10.0",
61
+ "stylelint-config-standard-scss": "13.1.0",
62
+ "stylelint-webpack-plugin": "5.0.0",
63
+ "tailwindcss": "3.4.3",
64
+ "typescript": "5.7.2",
65
+ "typescript-eslint": "8.15.0",
66
+ "vue-tsc": "2.2.0"
67
+ },
68
+ "config": {
69
+ "commitizen": {
70
+ "path": "@commitlint/cz-commitlint"
71
+ }
72
+ }
73
+ }
@@ -0,0 +1 @@
1
+ export { default } from './view.vue'
@@ -0,0 +1,16 @@
1
+ <script setup lang="ts">
2
+ import { watch } from 'vue'
3
+ import { useHomeQuery } from '@/shared/service'
4
+
5
+ const { data } = useHomeQuery()
6
+
7
+ watch(data, data => {
8
+ console.log('data', data?.data)
9
+ })
10
+ </script>
11
+
12
+ <template>
13
+ <div>Home</div>
14
+ </template>
15
+
16
+ <style scoped></style>
@@ -0,0 +1 @@
1
+ export { default } from './index.vue'
@@ -0,0 +1,3 @@
1
+ <template>
2
+ <div><router-view /></div>
3
+ </template>
@@ -0,0 +1,3 @@
1
+ <template>
2
+ <div>404</div>
3
+ </template>
@@ -0,0 +1,9 @@
1
+ module.exports = {
2
+ plugins: {
3
+ 'postcss-import': {},
4
+ 'tailwindcss/nesting': 'postcss-nesting',
5
+ tailwindcss: {},
6
+ autoprefixer: {},
7
+ ...(process.env.NODE_ENV === 'production' ? { cssnano: {} } : {})
8
+ }
9
+ }
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
@@ -0,0 +1,2 @@
1
+ export { default as names } from './names'
2
+ export { default as routes } from './routes'
@@ -0,0 +1,3 @@
1
+ export default {
2
+ home: 'home'
3
+ }
@@ -0,0 +1,8 @@
1
+ import { RouteRecordRaw } from 'vue-router'
2
+ import names from './names'
3
+
4
+ const routes: RouteRecordRaw[] = [
5
+ { path: '/home', name: names.home, component: () => import('@/pages/home') }
6
+ ]
7
+
8
+ export default routes
@@ -0,0 +1,26 @@
1
+ import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
2
+ import names from './names'
3
+ import * as homeRouter from './home'
4
+
5
+ const routes: RouteRecordRaw[] = [
6
+ {
7
+ path: '/',
8
+ component: () => import('@/pages'),
9
+ redirect: { name: names.home },
10
+ children: [
11
+ ...homeRouter.routes,
12
+ {
13
+ path: '/404',
14
+ name: names.notFound,
15
+ component: () => import('@/pages/not-found.vue')
16
+ }
17
+ ]
18
+ }
19
+ ]
20
+
21
+ export { default as routerNames } from './names'
22
+
23
+ export const router = createRouter({
24
+ history: createWebHistory(import.meta.env.PUBLIC_BASE_URL),
25
+ routes
26
+ })
@@ -0,0 +1,5 @@
1
+ import * as homeRouter from './home'
2
+ export default {
3
+ ...homeRouter.names,
4
+ notFound: '404'
5
+ }
@@ -0,0 +1,74 @@
1
+ import { defineConfig, loadEnv } from '@rsbuild/core'
2
+ import { pluginVue } from '@rsbuild/plugin-vue'
3
+ import { pluginEslint } from '@rsbuild/plugin-eslint'
4
+ import StylelintWebpackPlugin from 'stylelint-webpack-plugin'
5
+ import { pluginTypeCheck } from '@rsbuild/plugin-type-check'
6
+ import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin'
7
+ import { pluginSvgr } from '@rsbuild/plugin-svgr'
8
+ import { createChunks } from './scripts'
9
+
10
+ export default defineConfig(({ envMode, command }) => {
11
+ const { parsed: env } = loadEnv()
12
+ return {
13
+ html: {
14
+ template: './index.html',
15
+ title: 'Vite + Vue + TS'
16
+ },
17
+ source: {
18
+ entry: {
19
+ index: './main.ts'
20
+ }
21
+ },
22
+ resolve: {
23
+ alias: {
24
+ '@': __dirname
25
+ }
26
+ },
27
+ output: {
28
+ distPath: {
29
+ root: 'dist'
30
+ },
31
+ cleanDistPath: true
32
+ },
33
+ tools: {
34
+ rspack: {
35
+ plugins: [
36
+ new StylelintWebpackPlugin(),
37
+ process.env.RSDOCTOR && new RsdoctorRspackPlugin()
38
+ ]
39
+ }
40
+ },
41
+ plugins: [
42
+ pluginTypeCheck(),
43
+ pluginEslint({
44
+ eslintPluginOptions: {
45
+ configType: 'flat'
46
+ }
47
+ }),
48
+ pluginSvgr(),
49
+ pluginVue()
50
+ ],
51
+ performance: {
52
+ removeConsole: command === 'build' ? ['log'] : false,
53
+ chunkSplit: {
54
+ strategy: 'custom',
55
+ splitChunks: {
56
+ minChunks: 1,
57
+ cacheGroups: createChunks([{ libs: ['vue', 'vue-router'], name: 'vue' }])
58
+ }
59
+ },
60
+ bundleAnalyze: envMode === 'analyse' ? { openAnalyzer: true } : void 0
61
+ },
62
+ server: {
63
+ base: env.PUBLIC_BASE_URL,
64
+ host: '0.0.0.0',
65
+ compress: false,
66
+ proxy: [
67
+ {
68
+ context: [env.PUBLIC_API_HOST],
69
+ target: 'http://127.0.0.1:3000'
70
+ }
71
+ ]
72
+ }
73
+ }
74
+ })
@@ -0,0 +1,26 @@
1
+ import { CacheGroups } from '@rsbuild/core'
2
+
3
+ export function createChunks(
4
+ chunks: Array<{ name: string; libs: string[] | RegExp; priority?: number }>
5
+ ) {
6
+ const result: CacheGroups = {
7
+ vendors: {
8
+ test: /[\\/]node_modules[\\/]/,
9
+ chunks: 'all',
10
+ name: 'vendors',
11
+ priority: -1
12
+ }
13
+ }
14
+ chunks.forEach(({ name, libs, priority }) => {
15
+ result[name] = {
16
+ test: Array.isArray(libs)
17
+ ? new RegExp(`[\\\\/]node_modules[\\\\/](${libs.join('|')})[\\\\/]`)
18
+ : libs,
19
+ chunks: 'all',
20
+ name,
21
+ priority
22
+ }
23
+ return result
24
+ })
25
+ return result
26
+ }
@@ -0,0 +1 @@
1
+ export * from './createChunks'
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="37.07" height="36" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 198"><path fill="#41B883" d="M204.8 0H256L128 220.8L0 0h97.92L128 51.2L157.44 0h47.36Z"></path><path fill="#41B883" d="m0 0l128 220.8L256 0h-51.2L128 132.48L50.56 0H0Z"></path><path fill="#35495E" d="M50.56 0L128 133.12L204.8 0h-47.36L128 51.2L97.92 0H50.56Z"></path></svg>
@@ -0,0 +1,2 @@
1
+ export { default as useVisible } from './useVisible'
2
+ export { default as useList } from './useList'
@@ -0,0 +1,104 @@
1
+ import { ref, reactive, computed, unref } from 'vue'
2
+ import { cloneDeep, concat, assign, pick, isNil, size, max } from 'lodash-es'
3
+
4
+ export interface stateType<ListItem, P> {
5
+ loading: boolean
6
+ total: number
7
+ params: P
8
+ list: ListItem[]
9
+ sum: Record<string, any>
10
+ selected: ListItem[]
11
+ selectedKeys: (string | number)[]
12
+ pagination: {
13
+ current: number
14
+ pageSize: number
15
+ total: number
16
+ }
17
+ selectedLen: number
18
+ }
19
+ export interface createListStorePropsType<ListItem, P> {
20
+ /**
21
+ * @description 默认请求参数
22
+ */
23
+ defaultParams: P
24
+ /** 列表请求 */
25
+ fetch: (
26
+ state: Pick<stateType<ListItem, P>, 'pagination' | 'selected' | 'total' | 'params'>
27
+ ) => Promise<{
28
+ list: any[]
29
+ page?: number
30
+ pageSize?: number
31
+ total?: number
32
+ sum?: Record<string, any>
33
+ }>
34
+ /** 初始化列表时的配置 */
35
+ initConfig?: {
36
+ /** 初始化的时候需要保留值的字段 */
37
+ keepParamsKeys?: Array<keyof P>
38
+ }
39
+ }
40
+
41
+ export default function createListStore<
42
+ ListItem extends Record<string, any>,
43
+ P extends { page?: number; pageSize?: number; [key: string]: any }
44
+ >(config: createListStorePropsType<ListItem, P>) {
45
+ const loading = ref<stateType<ListItem, P>['loading']>(true)
46
+ const total = ref<stateType<ListItem, P>['total']>(0)
47
+ const params = reactive<stateType<ListItem, P>['params']>(cloneDeep(config.defaultParams))
48
+ const list = ref<stateType<ListItem, P>['list']>([])
49
+ const sum = reactive<stateType<ListItem, P>['sum']>({})
50
+ const selected = ref<stateType<ListItem, P>['selected']>([])
51
+ const selectedKeys = ref<stateType<ListItem, P>['selectedKeys']>([])
52
+ const pagination = computed<stateType<ListItem, P>['pagination']>(() => ({
53
+ current: params.page || 0,
54
+ pageSize: params.pageSize || 0,
55
+ total: total.value
56
+ }))
57
+ const selectedLen = computed<stateType<ListItem, P>['selectedLen']>(() => {
58
+ return max([size(selected.value), size(selectedKeys.value)]) || 0
59
+ })
60
+ function resetParams() {
61
+ assign(params, cloneDeep(config.defaultParams))
62
+ }
63
+ async function fetchList(arg?: { params?: Partial<P>; isConcat?: boolean; isInit?: boolean }) {
64
+ loading.value = true
65
+ try {
66
+ if (arg?.isInit) {
67
+ assign(
68
+ params,
69
+ cloneDeep(config.defaultParams),
70
+ pick(params, config?.initConfig?.keepParamsKeys || [])
71
+ )
72
+ }
73
+ assign(params, arg?.params)
74
+ const result = await config.fetch({
75
+ pagination: unref(pagination),
76
+ selected: unref(selected) as ListItem[],
77
+ total: unref(total),
78
+ params: params as P
79
+ })
80
+ list.value =
81
+ !isNil(result.page) && arg?.isConcat ? concat(list.value, result.list) : result.list
82
+ sum.value = result.sum || {}
83
+ total.value = result.total || total.value
84
+ params.page = result.page || params.page
85
+ params.pageSize = result.pageSize || params.pageSize
86
+ } finally {
87
+ loading.value = false
88
+ }
89
+ }
90
+
91
+ return {
92
+ loading,
93
+ total,
94
+ params,
95
+ list,
96
+ sum,
97
+ selected,
98
+ selectedKeys,
99
+ pagination,
100
+ selectedLen,
101
+ resetParams,
102
+ fetchList
103
+ }
104
+ }
@@ -0,0 +1,27 @@
1
+ import { ref } from 'vue'
2
+ import { isFunction } from 'lodash-es'
3
+
4
+ export interface useVisibleConfigType {
5
+ defaultVisible?: boolean
6
+ onBeforeShow?: () => Promise<boolean | void>
7
+ onBeforeHide?: () => Promise<boolean | void>
8
+ }
9
+ export default function useVisible(config?: useVisibleConfigType) {
10
+ const visible = ref(config?.defaultVisible ?? false)
11
+ const onShow = async () => {
12
+ let isShow: boolean | void = true
13
+ if (isFunction(config?.onBeforeShow)) {
14
+ isShow = await config?.onBeforeShow?.()
15
+ }
16
+ visible.value = isShow !== false
17
+ }
18
+ const onClose = async () => {
19
+ let isHide: boolean | void = true
20
+ if (isFunction(config?.onBeforeHide)) {
21
+ isHide = await config?.onBeforeHide?.()
22
+ }
23
+ visible.value = isHide === false
24
+ }
25
+
26
+ return { visible, onShow, onClose }
27
+ }
@@ -0,0 +1 @@
1
+ export const HOME_DATA = '/homeData'
@@ -0,0 +1,10 @@
1
+ import { useQuery } from '@tanstack/vue-query'
2
+ import { request } from './request'
3
+ import { HOME_DATA } from './api'
4
+
5
+ export function useHomeQuery() {
6
+ return useQuery({
7
+ queryKey: ['home_data'],
8
+ queryFn: () => request.post(HOME_DATA)
9
+ })
10
+ }
@@ -0,0 +1,3 @@
1
+ export * from './request'
2
+ export * as API from './api'
3
+ export * from './home'
@@ -0,0 +1,5 @@
1
+ import axios from 'axios'
2
+
3
+ export const request = axios.create({
4
+ baseURL: import.meta.env.PUBLIC_BASE_URL + import.meta.env.PUBLIC_API_HOST
5
+ })
@@ -0,0 +1,3 @@
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
@@ -0,0 +1,18 @@
1
+ /** @type {import('tailwindcss').Config} */
2
+ module.exports = {
3
+ content: [
4
+ './index.html',
5
+ './app.vue',
6
+ './main.ts',
7
+ './pages/**/*.{vue,ts,tsx,js,jsx}',
8
+ './domain/**/*.{vue,ts,tsx,js,jsx}',
9
+ './shared/**/*.{vue,ts,tsx,js,jsx}'
10
+ ],
11
+ theme: {
12
+ extend: {}
13
+ },
14
+ plugins: [],
15
+ corePlugins: {
16
+ preflight: false
17
+ }
18
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "compilerOptions": {
3
+ "baseUrl": ".",
4
+ "target": "ESNext",
5
+ "useDefineForClassFields": true,
6
+ "module": "ESNext",
7
+ "moduleResolution": "Node",
8
+ "strict": true,
9
+ "jsx": "preserve",
10
+ "sourceMap": true,
11
+ "resolveJsonModule": true,
12
+ "isolatedModules": true,
13
+ "strictPropertyInitialization": false,
14
+ "esModuleInterop": true,
15
+ "lib": ["ESNext", "DOM"],
16
+ "skipLibCheck": true,
17
+ "paths": {
18
+ "@/*": ["./*"]
19
+ }
20
+ },
21
+ "include": ["**/*.tsx", "**/*.ts", "**/*.vue"],
22
+ "exclude": ["scripts", "rsbuild.config.ts"],
23
+ "references": [{ "path": "./tsconfig.node.json" }]
24
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "compilerOptions": {
3
+ "composite": true,
4
+ "module": "ESNext",
5
+ "moduleResolution": "Node",
6
+ "allowSyntheticDefaultImports": true,
7
+ "resolveJsonModule": true
8
+ },
9
+ "include": ["scripts", "vite.config.ts", "package.json"]
10
+ }