create-young-proj 0.13.0 → 1.1.0-alpha.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (198) hide show
  1. package/.editorconfig +14 -0
  2. package/.vscode/settings.json +39 -0
  3. package/CHANGELOG.md +256 -0
  4. package/README.md +38 -25
  5. package/build.config.ts +22 -0
  6. package/eslint.config.js +35 -0
  7. package/package.json +10 -15
  8. package/src/index.ts +366 -0
  9. package/template-admin-server/_nvmrc +1 -0
  10. package/template-nuxt-admin/.vscode/settings.json +20 -6
  11. package/template-nuxt-admin/Dockerfile +3 -3
  12. package/template-nuxt-admin/README.md +23 -16
  13. package/template-nuxt-admin/_nvmrc +1 -0
  14. package/template-nuxt-admin/app.vue +10 -2
  15. package/template-nuxt-admin/boot.mjs +7 -7
  16. package/template-nuxt-admin/components/TopSearch.vue +1 -2
  17. package/template-nuxt-admin/components/YoungChangePassword.vue +2 -5
  18. package/template-nuxt-admin/components/YoungCodeInput.vue +1 -2
  19. package/template-nuxt-admin/components/YoungEditor.vue +81 -0
  20. package/template-nuxt-admin/components/ZenMode.vue +21 -0
  21. package/template-nuxt-admin/components/layout/NavBar.vue +3 -2
  22. package/template-nuxt-admin/composables/api.ts +7 -15
  23. package/template-nuxt-admin/composables/icon.ts +1 -3
  24. package/template-nuxt-admin/composables/nav.ts +11 -1
  25. package/template-nuxt-admin/composables/user.ts +3 -1
  26. package/template-nuxt-admin/env.d.ts +8 -8
  27. package/template-nuxt-admin/eslint.config.js +33 -0
  28. package/template-nuxt-admin/layouts/default.vue +45 -7
  29. package/template-nuxt-admin/middleware/auth.global.ts +2 -5
  30. package/template-nuxt-admin/nuxt.config.ts +21 -21
  31. package/template-nuxt-admin/package.json +8 -9
  32. package/template-nuxt-admin/pages/system/api.vue +1 -3
  33. package/template-nuxt-admin/pages/system/hooks/useRole.ts +1 -8
  34. package/template-nuxt-admin/pages/system/menuList.vue +4 -6
  35. package/template-nuxt-admin/pages/system/role.vue +1 -2
  36. package/template-nuxt-admin/pages/system/user.vue +1 -3
  37. package/template-nuxt-admin/public/index.umd.js +74 -0
  38. package/template-nuxt-admin/public/index.umd.js.map +1 -0
  39. package/template-nuxt-admin/server/plugins/env.ts +3 -2
  40. package/template-nuxt-admin/server/utils/index.ts +1 -1
  41. package/template-nuxt-admin/typings/global.d.ts +6 -6
  42. package/template-nuxt-admin/typings/system.d.ts +55 -54
  43. package/template-nuxt-admin/typings/user.d.ts +12 -12
  44. package/template-nuxt-admin/utils/tool.ts +4 -8
  45. package/template-nuxt-admin/yarn.lock +1913 -2002
  46. package/template-nuxt-website/.nvmrc +1 -0
  47. package/template-nuxt-website/.vscode/extensions.json +12 -0
  48. package/template-nuxt-website/.vscode/settings.json +39 -0
  49. package/template-nuxt-website/Dockerfile +41 -0
  50. package/template-nuxt-website/README.md +117 -0
  51. package/template-nuxt-website/_gitignore +26 -0
  52. package/template-nuxt-website/_npmrc +2 -0
  53. package/template-nuxt-website/_nvmrc +1 -0
  54. package/template-nuxt-website/app.vue +66 -0
  55. package/template-nuxt-website/assets/tabbar/event.png +0 -0
  56. package/template-nuxt-website/assets/tabbar/event_active.png +0 -0
  57. package/template-nuxt-website/assets/tabbar/game.png +0 -0
  58. package/template-nuxt-website/assets/tabbar/game_active.png +0 -0
  59. package/template-nuxt-website/assets/tabbar/shop.png +0 -0
  60. package/template-nuxt-website/assets/tabbar/shop_active.png +0 -0
  61. package/template-nuxt-website/assets/tabbar/user.png +0 -0
  62. package/template-nuxt-website/assets/tabbar/user_active.png +0 -0
  63. package/template-nuxt-website/boot.mjs +16 -0
  64. package/template-nuxt-website/components/AboutNav.vue +27 -0
  65. package/template-nuxt-website/components/BreadNav.vue +35 -0
  66. package/template-nuxt-website/components/Follow.vue +48 -0
  67. package/template-nuxt-website/components/FriendLink.vue +36 -0
  68. package/template-nuxt-website/components/mobile/NavBar.vue +50 -0
  69. package/template-nuxt-website/components/top/Extra.vue +50 -0
  70. package/template-nuxt-website/components/top/Nav.vue +87 -0
  71. package/template-nuxt-website/components/young/Banner.vue +100 -0
  72. package/template-nuxt-website/components/young/Footer.vue +44 -0
  73. package/template-nuxt-website/components/young/Header.vue +25 -0
  74. package/template-nuxt-website/components/young/Tabbar.vue +76 -0
  75. package/template-nuxt-website/composables/ad.ts +20 -0
  76. package/template-nuxt-website/composables/config.ts +11 -0
  77. package/template-nuxt-website/composables/nav.ts +30 -0
  78. package/template-nuxt-website/composables/share.ts +22 -0
  79. package/template-nuxt-website/composables/utils.ts +84 -0
  80. package/template-nuxt-website/config/.devrc +11 -0
  81. package/template-nuxt-website/config/.onlinerc +13 -0
  82. package/template-nuxt-website/config/.testrc +11 -0
  83. package/template-nuxt-website/env.d.ts +55 -0
  84. package/template-nuxt-website/error.vue +69 -0
  85. package/template-nuxt-website/eslint.config.js +34 -0
  86. package/template-nuxt-website/layouts/default.vue +80 -0
  87. package/template-nuxt-website/layouts/home.vue +75 -0
  88. package/template-nuxt-website/layouts/tabbar.vue +78 -0
  89. package/template-nuxt-website/nuxt.config.ts +98 -0
  90. package/template-nuxt-website/package.json +41 -0
  91. package/template-nuxt-website/pages/index.html.vue +16 -0
  92. package/template-nuxt-website/pages/index.vue +29 -0
  93. package/template-nuxt-website/pages/match.html.vue +23 -0
  94. package/template-nuxt-website/pages/news/[id].html.vue +57 -0
  95. package/template-nuxt-website/pages/news.html.vue +26 -0
  96. package/template-nuxt-website/pages/shop.html.vue +26 -0
  97. package/template-nuxt-website/public/favicon.ico +0 -0
  98. package/template-nuxt-website/public/robots.txt +2 -0
  99. package/template-nuxt-website/public/svg/image_placeholder.svg +15 -0
  100. package/template-nuxt-website/server/api/get_footer_info.get.ts +52 -0
  101. package/template-nuxt-website/server/api/get_gray_status.get.ts +38 -0
  102. package/template-nuxt-website/server/api/get_head_nav.get.ts +38 -0
  103. package/template-nuxt-website/server/api/get_home_banner.get.ts +28 -0
  104. package/template-nuxt-website/server/api/get_seo_info.get.ts +32 -0
  105. package/template-nuxt-website/server/middleware/platform.ts +11 -0
  106. package/template-nuxt-website/server/plugins/init.ts +147 -0
  107. package/template-nuxt-website/server/tsconfig.json +3 -0
  108. package/template-nuxt-website/server/utils/index.ts +12 -0
  109. package/template-nuxt-website/server/utils/proxy.ts +59 -0
  110. package/template-nuxt-website/tsconfig.json +4 -0
  111. package/template-nuxt-website/typings/banner.d.ts +30 -0
  112. package/template-nuxt-website/typings/nav.d.ts +34 -0
  113. package/template-nuxt-website/typings/system.d.ts +22 -0
  114. package/template-nuxt-website/uno.config.ts +40 -0
  115. package/template-nuxt-website/utils/tool.ts +171 -0
  116. package/template-nuxt-website/yarn.lock +8018 -0
  117. package/template-uni-app/.vscode/settings.json +20 -6
  118. package/template-uni-app/README.md +5 -0
  119. package/template-uni-app/_nvmrc +1 -0
  120. package/template-uni-app/eslint.config.js +35 -0
  121. package/template-uni-app/package.json +22 -21
  122. package/template-uni-app/pnpm-lock.yaml +2557 -1543
  123. package/template-uni-app/src/env.d.ts +6 -6
  124. package/template-uni-app/src/typings/global.d.ts +1 -1
  125. package/template-uni-app/src/utils/modal.ts +2 -2
  126. package/template-uni-app/tsconfig.json +3 -3
  127. package/tsconfig.json +11 -0
  128. package/dist/index.mjs +0 -51
  129. package/template-nuxt-admin/.eslintrc +0 -14
  130. package/template-uni-app/.vscode/.server-controller-port.log +0 -5
  131. package/template-uni-app/dist/dev/mp-weixin/apis/index.js +0 -43
  132. package/template-uni-app/dist/dev/mp-weixin/apis/requests/get.js +0 -10
  133. package/template-uni-app/dist/dev/mp-weixin/apis/requests/index.js +0 -1
  134. package/template-uni-app/dist/dev/mp-weixin/apis/requests/post.js +0 -15
  135. package/template-uni-app/dist/dev/mp-weixin/app.js +0 -92
  136. package/template-uni-app/dist/dev/mp-weixin/app.json +0 -51
  137. package/template-uni-app/dist/dev/mp-weixin/app.wxss +0 -2378
  138. package/template-uni-app/dist/dev/mp-weixin/common/assets.js +0 -13
  139. package/template-uni-app/dist/dev/mp-weixin/common/vendor.js +0 -9166
  140. package/template-uni-app/dist/dev/mp-weixin/components/young-loading/young-loading.js +0 -22
  141. package/template-uni-app/dist/dev/mp-weixin/components/young-loading/young-loading.json +0 -4
  142. package/template-uni-app/dist/dev/mp-weixin/components/young-loading/young-loading.wxml +0 -1
  143. package/template-uni-app/dist/dev/mp-weixin/components/young-loading/young-loading.wxss +0 -0
  144. package/template-uni-app/dist/dev/mp-weixin/components/young-loading-mini/young-loading-mini.js +0 -22
  145. package/template-uni-app/dist/dev/mp-weixin/components/young-loading-mini/young-loading-mini.json +0 -4
  146. package/template-uni-app/dist/dev/mp-weixin/components/young-loading-mini/young-loading-mini.wxml +0 -1
  147. package/template-uni-app/dist/dev/mp-weixin/components/young-loading-mini/young-loading-mini.wxss +0 -0
  148. package/template-uni-app/dist/dev/mp-weixin/components/young-navbar/young-navbar.js +0 -81
  149. package/template-uni-app/dist/dev/mp-weixin/components/young-navbar/young-navbar.json +0 -4
  150. package/template-uni-app/dist/dev/mp-weixin/components/young-navbar/young-navbar.wxml +0 -1
  151. package/template-uni-app/dist/dev/mp-weixin/components/young-navbar/young-navbar.wxss +0 -108
  152. package/template-uni-app/dist/dev/mp-weixin/components/young-tabbar/young-tabbar.js +0 -55
  153. package/template-uni-app/dist/dev/mp-weixin/components/young-tabbar/young-tabbar.json +0 -4
  154. package/template-uni-app/dist/dev/mp-weixin/components/young-tabbar/young-tabbar.wxml +0 -1
  155. package/template-uni-app/dist/dev/mp-weixin/components/young-tabbar/young-tabbar.wxss +0 -88
  156. package/template-uni-app/dist/dev/mp-weixin/config/enum.js +0 -21
  157. package/template-uni-app/dist/dev/mp-weixin/config/index.js +0 -1
  158. package/template-uni-app/dist/dev/mp-weixin/config/map.js +0 -1
  159. package/template-uni-app/dist/dev/mp-weixin/layouts/default.js +0 -29
  160. package/template-uni-app/dist/dev/mp-weixin/layouts/default.json +0 -6
  161. package/template-uni-app/dist/dev/mp-weixin/layouts/default.wxml +0 -1
  162. package/template-uni-app/dist/dev/mp-weixin/layouts/default.wxss +0 -0
  163. package/template-uni-app/dist/dev/mp-weixin/layouts/tabbar.js +0 -56
  164. package/template-uni-app/dist/dev/mp-weixin/layouts/tabbar.json +0 -9
  165. package/template-uni-app/dist/dev/mp-weixin/layouts/tabbar.wxml +0 -1
  166. package/template-uni-app/dist/dev/mp-weixin/layouts/tabbar.wxss +0 -0
  167. package/template-uni-app/dist/dev/mp-weixin/node-modules/@dcloudio/uni-ui/lib/uni-card/uni-card.js +0 -98
  168. package/template-uni-app/dist/dev/mp-weixin/node-modules/@dcloudio/uni-ui/lib/uni-card/uni-card.json +0 -4
  169. package/template-uni-app/dist/dev/mp-weixin/node-modules/@dcloudio/uni-ui/lib/uni-card/uni-card.wxml +0 -1
  170. package/template-uni-app/dist/dev/mp-weixin/node-modules/@dcloudio/uni-ui/lib/uni-card/uni-card.wxss +0 -125
  171. package/template-uni-app/dist/dev/mp-weixin/pages/demo/index.js +0 -37
  172. package/template-uni-app/dist/dev/mp-weixin/pages/demo/index.json +0 -5
  173. package/template-uni-app/dist/dev/mp-weixin/pages/demo/index.wxml +0 -1
  174. package/template-uni-app/dist/dev/mp-weixin/pages/demo/index.wxss +0 -0
  175. package/template-uni-app/dist/dev/mp-weixin/pages/index.js +0 -50
  176. package/template-uni-app/dist/dev/mp-weixin/pages/index.json +0 -5
  177. package/template-uni-app/dist/dev/mp-weixin/pages/index.wxml +0 -1
  178. package/template-uni-app/dist/dev/mp-weixin/pages/index.wxss +0 -0
  179. package/template-uni-app/dist/dev/mp-weixin/pages/my.js +0 -22
  180. package/template-uni-app/dist/dev/mp-weixin/pages/my.json +0 -3
  181. package/template-uni-app/dist/dev/mp-weixin/pages/my.wxml +0 -1
  182. package/template-uni-app/dist/dev/mp-weixin/pages/my.wxss +0 -0
  183. package/template-uni-app/dist/dev/mp-weixin/project.config.json +0 -55
  184. package/template-uni-app/dist/dev/mp-weixin/project.private.config.json +0 -6
  185. package/template-uni-app/dist/dev/mp-weixin/static/back.png +0 -0
  186. package/template-uni-app/dist/dev/mp-weixin/static/h.png +0 -0
  187. package/template-uni-app/dist/dev/mp-weixin/static/home.png +0 -0
  188. package/template-uni-app/dist/dev/mp-weixin/static/home_active.png +0 -0
  189. package/template-uni-app/dist/dev/mp-weixin/static/more.png +0 -0
  190. package/template-uni-app/dist/dev/mp-weixin/static/my.png +0 -0
  191. package/template-uni-app/dist/dev/mp-weixin/static/my_active.png +0 -0
  192. package/template-uni-app/dist/dev/mp-weixin/static/network.png +0 -0
  193. package/template-uni-app/dist/dev/mp-weixin/store/index.js +0 -8
  194. package/template-uni-app/dist/dev/mp-weixin/store/local/index.js +0 -13
  195. package/template-uni-app/dist/dev/mp-weixin/store/system.js +0 -14
  196. package/template-uni-app/dist/dev/mp-weixin/utils/modal.js +0 -78
  197. package/template-uni-app/dist/dev/mp-weixin/utils/route.js +0 -83
  198. package/template-uni-app/dist/dev/mp-weixin/utils/system.js +0 -27
package/src/index.ts ADDED
@@ -0,0 +1,366 @@
1
+ /*
2
+ * @Author: zhangyang
3
+ * @Date: 2022-12-03 15:14:08
4
+ * @LastEditTime: 2023-11-08 11:27:47
5
+ * @Description:
6
+ */
7
+ import fs from 'node:fs'
8
+ import path from 'node:path'
9
+ import { fileURLToPath } from 'node:url'
10
+ import spawn from 'cross-spawn'
11
+ import minimist from 'minimist'
12
+ import prompts from 'prompts'
13
+ import { blue, green, red, reset } from 'kolorist'
14
+
15
+ // Avoids autoconversion to number of the project name by defining that the args
16
+ // non associated with an option ( _ ) needs to be parsed as a string. See #4606
17
+ const argv = minimist<{
18
+ t?: string
19
+ template?: string
20
+ }>(process.argv.slice(2), { string: ['_'] })
21
+ const cwd = process.cwd()
22
+
23
+ type ColorFunc = (str: string | number) => string
24
+ interface Framework {
25
+ name: string
26
+ display: string
27
+ color: ColorFunc
28
+ variants: FrameworkVariant[]
29
+ }
30
+ interface FrameworkVariant {
31
+ name: string
32
+ display: string
33
+ color: ColorFunc
34
+ customCommand?: string
35
+ /**
36
+ * 待实现,暂时禁用选项
37
+ */
38
+ wip?: boolean
39
+ /**
40
+ * 已淘汰
41
+ */
42
+ deprecated?: boolean
43
+ }
44
+
45
+ const FRAMEWORKS: Framework[] = [
46
+ {
47
+ name: 'vue',
48
+ display: 'Young Designed Vue Template',
49
+ color: green,
50
+ variants: [
51
+ {
52
+ name: 'nuxt-admin',
53
+ display: 'Nuxt3 Admin',
54
+ color: blue,
55
+ },
56
+ {
57
+ name: 'nuxt-website',
58
+ display: 'Nuxt3 Website',
59
+ color: blue,
60
+ },
61
+ {
62
+ name: 'vue-mobile',
63
+ display: 'Vue3 Mobile',
64
+ color: blue,
65
+ },
66
+ {
67
+ name: 'uni-app',
68
+ display: 'Vue3 uni-app',
69
+ color: blue,
70
+ },
71
+ {
72
+ name: 'vue-thin',
73
+ display: 'Vue3 mini demo',
74
+ color: green,
75
+ },
76
+ {
77
+ name: 'admin-server',
78
+ display: 'Node Server Based on Midwayjs',
79
+ color: green,
80
+ },
81
+ ],
82
+ },
83
+ {
84
+ name: 'vite',
85
+ display: 'Vite Formal',
86
+ color: reset,
87
+ variants: [
88
+ {
89
+ name: 'create-vite',
90
+ display: 'create-vite',
91
+ color: reset,
92
+ customCommand: 'npm create vite@latest TARGET_DIR',
93
+ },
94
+ ],
95
+ },
96
+ {
97
+ name: 'others',
98
+ display: 'Others',
99
+ color: reset,
100
+ variants: [
101
+ {
102
+ name: 'create-vite-extra',
103
+ display: 'create-vite-extra ↗',
104
+ color: reset,
105
+ customCommand: 'npm create vite-extra@latest TARGET_DIR',
106
+ },
107
+ ],
108
+ },
109
+ ]
110
+
111
+ const TEMPLATES = FRAMEWORKS.map(
112
+ f => (f.variants && f.variants.map(v => v.name)) || [f.name],
113
+ ).reduce((a, b) => a.concat(b), [])
114
+
115
+ const renameFiles: Record<string, string | undefined> = {
116
+ _gitignore: '.gitignore',
117
+ _npmrc: '.npmrc',
118
+ _nvmrc: '.nvmrc',
119
+ }
120
+
121
+ const renameEnvBatch = /_env.*/
122
+
123
+ const defaultTargetDir = 'vite-project'
124
+
125
+ async function init() {
126
+ const argTargetDir = formatTargetDir(argv._[0])
127
+ const argTemplate = argv.template || argv.t
128
+
129
+ let targetDir = argTargetDir || defaultTargetDir
130
+ const getProjectName = () => (targetDir === '.' ? path.basename(path.resolve()) : targetDir)
131
+
132
+ let result: prompts.Answers<
133
+ 'projectName' | 'overwrite' | 'packageName' | 'framework' | 'variant'
134
+ >
135
+
136
+ try {
137
+ result = await prompts(
138
+ [
139
+ {
140
+ type: argTargetDir ? null : 'text',
141
+ name: 'projectName',
142
+ message: reset('Project name:'),
143
+ initial: defaultTargetDir,
144
+ onState: (state) => {
145
+ targetDir = formatTargetDir(state.value) || defaultTargetDir
146
+ },
147
+ },
148
+ {
149
+ type: () => (!fs.existsSync(targetDir) || isEmpty(targetDir) ? null : 'confirm'),
150
+ name: 'overwrite',
151
+ message: () =>
152
+ `${targetDir === '.' ? 'Current directory' : `Target directory "${targetDir}"`
153
+ } is not empty. Remove existing files and continue?`,
154
+ },
155
+ {
156
+ type: (_, { overwrite }: { overwrite?: boolean }) => {
157
+ if (overwrite === false)
158
+ throw new Error(`${red('✖')} Operation cancelled`)
159
+
160
+ return null
161
+ },
162
+ name: 'overwriteChecker',
163
+ },
164
+ {
165
+ type: () => (isValidPackageName(getProjectName()) ? null : 'text'),
166
+ name: 'packageName',
167
+ message: reset('Package name:'),
168
+ initial: () => toValidPackageName(getProjectName()),
169
+ validate: dir => isValidPackageName(dir) || 'Invalid package.json name',
170
+ },
171
+ {
172
+ type: argTemplate && TEMPLATES.includes(argTemplate) ? null : 'select',
173
+ name: 'framework',
174
+ message:
175
+ typeof argTemplate === 'string' && !TEMPLATES.includes(argTemplate)
176
+ ? reset(`"${argTemplate}" isn't a valid template. Please choose from below: `)
177
+ : reset('Select a framework:'),
178
+ initial: 0,
179
+ choices: FRAMEWORKS.map((framework) => {
180
+ const frameworkColor = framework.color
181
+ return {
182
+ title: frameworkColor(framework.display || framework.name),
183
+ value: framework,
184
+ }
185
+ }),
186
+ },
187
+ {
188
+ type: (framework: Framework) => (framework && framework.variants ? 'select' : null),
189
+ name: 'variant',
190
+ message: reset('Select a variant:'),
191
+ choices: (framework: Framework) =>
192
+ framework.variants.map((variant) => {
193
+ const variantColor = variant.color
194
+ return {
195
+ title: variantColor(variant.display || variant.name),
196
+ value: variant.name,
197
+ disabled: variant.wip || variant.deprecated,
198
+ }
199
+ }),
200
+ },
201
+ ],
202
+ {
203
+ onCancel: () => {
204
+ throw new Error(`${red('✖')} Operation cancelled`)
205
+ },
206
+ },
207
+ )
208
+ }
209
+ catch (cancelled: any) {
210
+ console.log(cancelled.message)
211
+ return
212
+ }
213
+
214
+ // user choice associated with prompts
215
+ const { framework, overwrite, packageName, variant } = result
216
+
217
+ const root = path.join(cwd, targetDir)
218
+
219
+ if (overwrite)
220
+ emptyDir(root)
221
+ else if (!fs.existsSync(root))
222
+ fs.mkdirSync(root, { recursive: true })
223
+
224
+ // determine template
225
+ const template: string = variant || framework?.name || argTemplate
226
+
227
+ const pkgInfo = pkgFromUserAgent(process.env.npm_config_user_agent)
228
+ const pkgManager = pkgInfo ? pkgInfo.name : 'npm'
229
+ const isYarn1 = pkgManager === 'yarn' && pkgInfo?.version.startsWith('1.')
230
+
231
+ const { customCommand }
232
+ = FRAMEWORKS.flatMap(f => f.variants).find(v => v.name === template) ?? {}
233
+
234
+ if (customCommand) {
235
+ const fullCustomCommand = customCommand
236
+ .replace('TARGET_DIR', targetDir)
237
+ .replace(/^npm create/, `${pkgManager} create`)
238
+ // Only Yarn 1.x doesn't support `@version` in the `create` command
239
+ .replace('@latest', () => (isYarn1 ? '' : '@latest'))
240
+ .replace(/^npm exec/, () => {
241
+ // Prefer `pnpm dlx` or `yarn dlx`
242
+ if (pkgManager === 'pnpm')
243
+ return 'pnpm dlx'
244
+
245
+ if (pkgManager === 'yarn' && !isYarn1)
246
+ return 'yarn dlx'
247
+
248
+ // Use `npm exec` in all other cases,
249
+ // including Yarn 1.x and other custom npm clients.
250
+ return 'npm exec'
251
+ })
252
+
253
+ const [command, ...args] = fullCustomCommand.split(' ')
254
+ const { status } = spawn.sync(command, args, {
255
+ stdio: 'inherit',
256
+ })
257
+ process.exit(status ?? 0)
258
+ }
259
+
260
+ console.log(`\nScaffolding project in ${root}...`)
261
+
262
+ const templateDir = path.resolve(fileURLToPath(import.meta.url), '../..', `template-${template}`)
263
+
264
+ const write = (file: string, content?: string) => {
265
+ const targetPath = path.join(
266
+ root,
267
+ renameFiles[file] ?? renameEnvBatch.test(file) ? file.replace('_', '.') : file,
268
+ )
269
+ if (content)
270
+ fs.writeFileSync(targetPath, content)
271
+ else
272
+ copy(path.join(templateDir, file), targetPath)
273
+ }
274
+
275
+ const files = fs.readdirSync(templateDir)
276
+ for (const file of files.filter(f => f !== 'package.json'))
277
+ write(file)
278
+
279
+ const pkg = JSON.parse(fs.readFileSync(path.join(templateDir, 'package.json'), 'utf-8'))
280
+
281
+ pkg.name = packageName || getProjectName()
282
+
283
+ write('package.json', JSON.stringify(pkg, null, 2))
284
+
285
+ console.log('\nDone. Now run:\n')
286
+ if (root !== cwd)
287
+ console.log(` cd ${path.relative(cwd, root)}`)
288
+
289
+ switch (pkgManager) {
290
+ case 'yarn':
291
+ console.log(' yarn')
292
+ console.log(' yarn dev')
293
+ break
294
+ default:
295
+ console.log(` ${pkgManager} install`)
296
+ console.log(` ${pkgManager} run dev`)
297
+ break
298
+ }
299
+ console.log()
300
+ }
301
+
302
+ function formatTargetDir(targetDir: string | undefined) {
303
+ return targetDir?.trim().replace(/\/+$/g, '')
304
+ }
305
+
306
+ function copy(src: string, dest: string) {
307
+ const stat = fs.statSync(src)
308
+ if (stat.isDirectory())
309
+ copyDir(src, dest)
310
+ else
311
+ fs.copyFileSync(src, dest)
312
+ }
313
+
314
+ function isValidPackageName(projectName: string) {
315
+ return /^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(projectName)
316
+ }
317
+
318
+ function toValidPackageName(projectName: string) {
319
+ return projectName
320
+ .trim()
321
+ .toLowerCase()
322
+ .replace(/\s+/g, '-')
323
+ .replace(/^[._]/, '')
324
+ .replace(/[^a-z\d\-~]+/g, '-')
325
+ }
326
+
327
+ function copyDir(srcDir: string, destDir: string) {
328
+ fs.mkdirSync(destDir, { recursive: true })
329
+ for (const file of fs.readdirSync(srcDir)) {
330
+ const srcFile = path.resolve(srcDir, file)
331
+ const destFile = path.resolve(destDir, file)
332
+ copy(srcFile, destFile)
333
+ }
334
+ }
335
+
336
+ function isEmpty(path: string) {
337
+ const files = fs.readdirSync(path)
338
+ return files.length === 0 || (files.length === 1 && files[0] === '.git')
339
+ }
340
+
341
+ function emptyDir(dir: string) {
342
+ if (!fs.existsSync(dir))
343
+ return
344
+
345
+ for (const file of fs.readdirSync(dir)) {
346
+ if (file === '.git')
347
+ continue
348
+
349
+ fs.rmSync(path.resolve(dir, file), { recursive: true, force: true })
350
+ }
351
+ }
352
+
353
+ function pkgFromUserAgent(userAgent: string | undefined) {
354
+ if (!userAgent)
355
+ return undefined
356
+ const pkgSpec = userAgent.split(' ')[0]
357
+ const pkgSpecArr = pkgSpec.split('/')
358
+ return {
359
+ name: pkgSpecArr[0],
360
+ version: pkgSpecArr[1],
361
+ }
362
+ }
363
+
364
+ init().catch((e) => {
365
+ console.error(e)
366
+ })
@@ -0,0 +1 @@
1
+ 16
@@ -1,15 +1,29 @@
1
1
  {
2
2
  "prettier.enable": false,
3
3
  "editor.formatOnSave": false,
4
+
5
+ // Enable the ESlint flat config support
6
+ "eslint.experimental.useFlatConfig": true,
7
+ // Auto fix
4
8
  "editor.codeActionsOnSave": {
5
- "source.fixAll.eslint": true,
6
- "source.organizeImports": false
9
+ "source.fixAll.eslint": "explicit",
10
+ "source.organizeImports": "never"
7
11
  },
8
12
 
9
- // The following is optional.
10
- // It's better to put under project setting `.vscode/settings.json`
11
- // to avoid conflicts with working with different eslint configs
12
- // that does not support all formats.
13
+ // Silent the stylistic rules in you IDE, but still auto fix them
14
+ "eslint.rules.customizations": [
15
+ { "rule": "style/*", "severity": "off" },
16
+ { "rule": "*-indent", "severity": "off" },
17
+ { "rule": "*-spacing", "severity": "off" },
18
+ { "rule": "*-spaces", "severity": "off" },
19
+ { "rule": "*-order", "severity": "off" },
20
+ { "rule": "*-dangle", "severity": "off" },
21
+ { "rule": "*-newline", "severity": "off" },
22
+ { "rule": "*quotes", "severity": "off" },
23
+ { "rule": "*semi", "severity": "off" }
24
+ ],
25
+
26
+ // Enable eslint for all supported languages
13
27
  "eslint.validate": [
14
28
  "javascript",
15
29
  "javascriptreact",
@@ -1,5 +1,5 @@
1
1
  # 拉取基础镜像
2
- FROM intranet-harbor.laiyouxi.com/base/alpine/node:19 as builder
2
+ FROM intranet-harbor.laiyouxi.com/base/alpine/node:20.9.0 as builder
3
3
  # 添加部分元数据,暂无意义
4
4
  LABEL vendor="Lyx-yunwei" \
5
5
  com.example.release-date="2022-11-10" \
@@ -20,7 +20,7 @@ COPY package.json yarn.lock /app/
20
20
 
21
21
  # 设置npm仓库 + 下载依赖,上面的文件如果没有变化则跳过下载,直接使用缓存
22
22
  RUN npm config set registry https://registry.npmmirror.com && \
23
- yarn config set registry https://registry.npmmirror.com && \
23
+ yarn config set registry https://registry.npmmirror.com && \
24
24
  yarn
25
25
 
26
26
  # 加入代码
@@ -29,7 +29,7 @@ COPY . /app
29
29
  RUN yarn build
30
30
 
31
31
  # 打包完成,构建最终的极简镜像
32
- FROM intranet-harbor.laiyouxi.com/base/alpine/node:19
32
+ FROM intranet-harbor.laiyouxi.com/base/alpine/node:20.9.0
33
33
 
34
34
  WORKDIR /app
35
35
  # 复制源码
@@ -1,44 +1,50 @@
1
1
  # 基于 Nuxt 3 的后台
2
2
 
3
+ [![](https://img.shields.io/badge/Author-BluesYoung--web-blue)](https://gitee.com/BluesYoung-web)
4
+
5
+
3
6
  [![code style](https://antfu.me/badge-code-style.svg)](https://github.com/antfu/eslint-config)
4
7
 
5
8
  ## 与旧版的区别
6
9
 
7
10
  ### 所有的页面都是默认缓存的
8
11
 
9
- - 原有的 route 代码块,使用 definePageMeta 宏进行定义
12
+ - 原有的 `route` 代码块,使用 `definePageMeta` 宏进行定义
10
13
 
11
- - 所有需要 keep-alive 的页面,setup 里面直接执行的函数或者 onMounted 包裹的函数,全部替换为 useTabReOpen 进行包裹
14
+ - 所有需要 `keep-alive` 的页面,`setup` 里面直接执行的函数或者 `onMounted` 包裹的函数,全部替换为 `useTabReOpen` 进行包裹
12
15
 
13
- - 所有不需要 keep-alive 的页面,setup 里面直接执行的函数或者 onMounted 包裹的函数,全部替换为 useTabNoCache 进行包裹
16
+ - 所有不需要 `keep-alive` 的页面,`setup` 里面直接执行的函数或者 `onMounted` 包裹的函数,全部替换为 `useTabNoCache` 进行包裹
14
17
 
15
- - onUnmounted 包裹的函数,全部替换为 useTabClose 进行包裹
18
+ - `onUnmounted` 包裹的函数,全部替换为 `useTabClose` 进行包裹
16
19
 
17
20
  ### 组件库(@bluesyoung/ui-vue3-element-plus)
18
21
 
19
22
  > 自 0.13.0 开始,YoungDialog 默认表现为 Drawer !!!, 可通过设置 as='dialog' 改为 Dialog
20
23
 
21
- ### 其他
24
+ > 自 1.2.1 开始,常规使用下,组件、类型以及方法都可以自动按需导入,<del>渲染函数及 tsx 可能仍需手动导入</del>
25
+ - 需要显示注册模块 (`@bluesyoung/ui-vue3-element-plus/nuxt`)
22
26
 
23
- - 路由跳转,使用 navigateTo 替换 router
27
+ > 1.3.0 开始,可以全量按需自动导入
28
+
29
+ ### 其他
24
30
 
25
- - 二次确认弹窗,统一使用 useConfirm(自带汉化,代码更精简)
31
+ - 路由跳转,使用 `navigateTo` 替换 `router`
26
32
 
27
- - prompt 情况更复杂,需自行汉化
33
+ - 二次确认弹窗,统一使用 `useConfirm`(自带汉化,代码更精简)
28
34
 
29
- - alert 使用频率不高,自行汉化
35
+ - `prompt` 情况更复杂,需自行汉化
30
36
 
31
- - 使用 tsx 代替 h:
32
- - hooks 直接修改扩展名为 .tsx
33
- - vue 内修改 lang 为 tsx
37
+ - `alert` 使用频率不高,自行汉化
34
38
 
35
- - stores/* 已经被删除了,需要取数据,使用 pinia
39
+ - 使用 `tsx` 代替 `h`:
40
+ - `hooks` 直接修改扩展名为 `.tsx`
41
+ - `vue` 内修改 `lang` 为 `tsx`
36
42
 
37
- - 一些存在于 keep-alive 页面内的组件,需要在例如 @focus 内 getList(),或者使用 useTabReOpen 替换 onMounted
43
+ - 一些存在于 `keep-alive` 页面内的组件,需要在例如 `@focus``getList()`,或者使用 `useTabReOpen` 替换 `onMounted`
38
44
 
39
- - 尽量使用 YoungTablePro 而不是 YoungTable
45
+ - 尽量使用 `YoungTablePro` 而不是 `YoungTable`
40
46
 
41
- - 保持页面美观,页面内容全部使用 ElCard 进行包裹
47
+ - 保持页面美观,页面内容全部使用 `ElCard` 进行包裹
42
48
 
43
49
  - **SelectOption 的值不要给 null !!!**
44
50
 
@@ -54,6 +60,7 @@ npm i -g young-commit
54
60
 
55
61
  ### 使用
56
62
 
63
+ > **依赖 which 命令,Windows 环境请在 git bash 内执行!!!**
57
64
 
58
65
  - 正常使用 `git add` 将要提交的文件添加到暂存区
59
66
 
@@ -0,0 +1 @@
1
+ 20.9.0
@@ -1,7 +1,7 @@
1
1
  <!--
2
2
  * @Author: zhangyang
3
3
  * @Date: 2023-05-25 19:53:07
4
- * @LastEditTime: 2023-07-26 10:26:50
4
+ * @LastEditTime: 2023-11-07 16:30:06
5
5
  * @Description:
6
6
  -->
7
7
  <script lang="ts" setup>
@@ -11,7 +11,7 @@ import { ElConfigProvider } from 'element-plus'
11
11
  import locale from 'element-plus/dist/locale/zh-cn.mjs'
12
12
 
13
13
  const app = useNuxtApp()
14
- const { isLoading } = storeToRefs(useNavStore())
14
+ const { isLoading, zen_mode, zen_mode_helper } = storeToRefs(useNavStore())
15
15
 
16
16
  app.hook('page:start', () => {
17
17
  console.log('loading...')
@@ -22,6 +22,13 @@ app.hook('page:finish', () => {
22
22
  console.log('loading end ...')
23
23
  isLoading.value = false
24
24
  })
25
+
26
+ function showZenModeHelper() {
27
+ zen_mode_helper.value = true
28
+ setTimeout(() => {
29
+ zen_mode_helper.value = false
30
+ }, 1e4)
31
+ }
25
32
  </script>
26
33
 
27
34
  <template>
@@ -31,6 +38,7 @@ app.hook('page:finish', () => {
31
38
  </NuxtLayout>
32
39
  </ElConfigProvider>
33
40
  <YoungLoading v-show="isLoading" />
41
+ <young-float-ball v-show="zen_mode && !zen_mode_helper" zindex="9" top="0" icon="/logo.svg" title="显示顶部导航栏,无操作 10s 后收起" custom @click="showZenModeHelper" />
34
42
  </template>
35
43
 
36
44
  <style lang="scss">
@@ -5,12 +5,12 @@
5
5
  * @Description:
6
6
  */
7
7
  (async () => {
8
- const env = process.env.DEPLOY_ENV;
9
- const listenPort = process.env.LISTEN_PORT || 3003;
10
- console.log('当前环境:', env);
11
- console.log('服务监听端口:', listenPort);
8
+ const env = process.env.DEPLOY_ENV
9
+ const listenPort = process.env.LISTEN_PORT || 3003
10
+ console.log('当前环境:', env)
11
+ console.log('服务监听端口:', listenPort)
12
12
 
13
- process.env.NITRO_PORT = listenPort;
13
+ process.env.NITRO_PORT = listenPort
14
14
 
15
- await import('./dist/server/index.mjs');
16
- })();
15
+ await import('./dist/server/index.mjs')
16
+ })()
@@ -1,11 +1,10 @@
1
1
  <!--
2
2
  * @Author: zhangyang
3
3
  * @Date: 2023-07-21 17:01:21
4
- * @LastEditTime: 2023-07-28 17:32:46
4
+ * @LastEditTime: 2023-11-07 14:47:37
5
5
  * @Description:
6
6
  -->
7
7
  <script lang="ts" setup>
8
- import type { SelectOptionItem } from '@bluesyoung/ui-vue3-element-plus'
9
8
  import { YoungCmdPopup } from '@bluesyoung/ui-vue3'
10
9
  import { isHttpUrl } from '@bluesyoung/utils'
11
10
 
@@ -1,7 +1,7 @@
1
1
  <!--
2
2
  * @Author: zhangyang
3
3
  * @Date: 2023-07-24 14:21:55
4
- * @LastEditTime: 2023-09-08 10:34:56
4
+ * @LastEditTime: 2023-11-07 14:56:32
5
5
  * @Description:
6
6
  -->
7
7
  <script lang="ts" setup>
@@ -41,10 +41,7 @@ function sure() {
41
41
  if (valid) {
42
42
  await apis.post.changePassword(form)
43
43
  hide()
44
- showNotify({
45
- message: '密码修改成功,请重新登录',
46
- type: 'success',
47
- })
44
+ ElMessage.success('密码修改成功,请重新登录')
48
45
  user.removeToken()
49
46
  const redirect = location.pathname === '/login' ? '/' : encodeURIComponent(location.href.replace(location.origin, ''))
50
47
  navigateTo(`/login?redirect=${redirect}`)
@@ -1,12 +1,11 @@
1
1
  <!--
2
2
  * @Author: zhangyang
3
3
  * @Date: 2022-08-19 13:52:58
4
- * @LastEditTime: 2023-07-24 11:57:12
4
+ * @LastEditTime: 2023-11-07 14:47:52
5
5
  * @Description:
6
6
  -->
7
7
  <script lang="ts" setup>
8
8
  import { YoungSlideVerify } from '@bluesyoung/ui-vue3'
9
- import { useVerifyCode } from '@bluesyoung/ui-vue3-element-plus'
10
9
  import { isNumber } from '@bluesyoung/utils'
11
10
 
12
11
  interface Props {