ljr-cli 1.0.0 → 1.0.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.
Files changed (102) hide show
  1. package/lib/demo1.js +36 -0
  2. package/lib/demo2.js +85 -0
  3. package/lib/index.js +183 -14
  4. package/lib/templates/flutter//346/210/221/346/230/257flutter.txt +0 -0
  5. package/lib/templates/java//346/210/221/346/230/257java.txt +0 -0
  6. package/lib/templates/monorepo//346/210/221/346/230/257monorepo.txt +0 -0
  7. package/lib/templates/mysql//346/210/221/346/230/257mysql.txt +0 -0
  8. package/lib/templates/node//346/210/221/346/230/257node.txt +0 -0
  9. package/lib/templates/qiankun//346/210/221/346/230/257qiankun.txt +0 -0
  10. package/lib/templates/react//346/210/221/346/230/257react.txt +0 -0
  11. package/lib/templates/uni-app//346/210/221/346/230/257uni-app.txt +0 -0
  12. package/lib/templates/vue2.7.16/.browserslistrc +3 -0
  13. package/lib/templates/vue2.7.16/.env +4 -0
  14. package/lib/templates/vue2.7.16/.env.development +7 -0
  15. package/lib/templates/vue2.7.16/.env.production +7 -0
  16. package/lib/templates/vue2.7.16/.eslintignore +3 -0
  17. package/lib/templates/vue2.7.16/.eslintrc.js +21 -0
  18. package/lib/templates/vue2.7.16/.prettierrc.js +11 -0
  19. package/lib/templates/vue2.7.16/.vscode/settings.json +10 -0
  20. package/lib/templates/vue2.7.16/README.md +55 -0
  21. package/lib/templates/vue2.7.16/babel.config.js +3 -0
  22. package/lib/templates/vue2.7.16/jsconfig.json +19 -0
  23. package/lib/templates/vue2.7.16/package-lock.json +12422 -0
  24. package/lib/templates/vue2.7.16/package.json +37 -0
  25. package/lib/templates/vue2.7.16/public/favicon.svg +14 -0
  26. package/lib/templates/vue2.7.16/public/index.html +20 -0
  27. package/lib/templates/vue2.7.16/src/App.vue +14 -0
  28. package/lib/templates/vue2.7.16/src/api/interface/index.js +6 -0
  29. package/lib/templates/vue2.7.16/src/api/request.js +121 -0
  30. package/lib/templates/vue2.7.16/src/api/server/index.js +6 -0
  31. package/lib/templates/vue2.7.16/src/assets/logo.png +0 -0
  32. package/lib/templates/vue2.7.16/src/components/README.md +5 -0
  33. package/lib/templates/vue2.7.16/src/components/baseInfo/index.vue +29 -0
  34. package/lib/templates/vue2.7.16/src/components/baseInfo/item.vue +64 -0
  35. package/lib/templates/vue2.7.16/src/components/index.js +14 -0
  36. package/lib/templates/vue2.7.16/src/components/layout/left-menu-and-top-info.vue +121 -0
  37. package/lib/templates/vue2.7.16/src/components/pagination/index.vue +52 -0
  38. package/lib/templates/vue2.7.16/src/css/coverage-style.css +6 -0
  39. package/lib/templates/vue2.7.16/src/directive/index.js +16 -0
  40. package/lib/templates/vue2.7.16/src/directive/input-number.js +18 -0
  41. package/lib/templates/vue2.7.16/src/directive/permission.js +52 -0
  42. package/lib/templates/vue2.7.16/src/directive/re-click.js +12 -0
  43. package/lib/templates/vue2.7.16/src/global-config.js +12 -0
  44. package/lib/templates/vue2.7.16/src/main.js +79 -0
  45. package/lib/templates/vue2.7.16/src/prototype/README.md +1 -0
  46. package/lib/templates/vue2.7.16/src/prototype/el-dialog.js +127 -0
  47. package/lib/templates/vue2.7.16/src/prototype/index.js +53 -0
  48. package/lib/templates/vue2.7.16/src/router/index.js +257 -0
  49. package/lib/templates/vue2.7.16/src/store/index.js +50 -0
  50. package/lib/templates/vue2.7.16/src/store/modules/dd.js +128 -0
  51. package/lib/templates/vue2.7.16/src/store/modules/permissions.js +24 -0
  52. package/lib/templates/vue2.7.16/src/views/404.vue +7 -0
  53. package/lib/templates/vue2.7.16/src/views/Pitfalls//345/206/205/345/255/230/346/272/242/345/207/272/index.vue +56 -0
  54. package/lib/templates/vue2.7.16/src/views/Pitfalls//345/206/205/345/255/230/346/272/242/345/207/272//351/200/240/346/210/220vue2/345/206/205/345/255/230/346/272/242/345/207/272/347/232/204/345/257/271/350/261/241.js +33518 -0
  55. package/lib/templates/vue2.7.16/src/views/about.vue +5 -0
  56. package/lib/templates/vue2.7.16/src/views/demo//345/205/250/345/261/200store/346/225/260/346/215/256/345/255/227/345/205/270/index.vue +85 -0
  57. package/lib/templates/vue2.7.16/src/views/demo//345/205/250/345/261/200/345/274/271/347/252/227/ce.vue +42 -0
  58. package/lib/templates/vue2.7.16/src/views/demo//345/205/250/345/261/200/345/274/271/347/252/227/index.vue +24 -0
  59. package/lib/templates/vue2.7.16/src/views/demo//345/205/250/345/261/200/346/214/207/344/273/244/index.vue +78 -0
  60. package/lib/templates/vue2.7.16/src/views/demo//350/257/267/346/261/202/347/244/272/344/276/213/index.vue +51 -0
  61. package/lib/templates/vue2.7.16/src/views/home.vue +3 -0
  62. package/lib/templates/vue2.7.16/src/views/login.vue +67 -0
  63. package/lib/templates/vue2.7.16/src/views/template/base-info.vue +29 -0
  64. package/lib/templates/vue2.7.16/src/views/template/base-info2.vue +56 -0
  65. package/lib/templates/vue2.7.16/src/views/template/list/ce.vue +58 -0
  66. package/lib/templates/vue2.7.16/src/views/template/list/index.vue +111 -0
  67. package/lib/templates/vue2.7.16/src/views/template/list/search.vue +60 -0
  68. package/lib/templates/vue2.7.16/vue.config.js +26 -0
  69. package/lib/templates/vue3.5.25-2025.12.4/.editorconfig +8 -0
  70. package/lib/templates/vue3.5.25-2025.12.4/.gitattributes +1 -0
  71. package/lib/templates/vue3.5.25-2025.12.4/.prettierrc.json +11 -0
  72. package/lib/templates/vue3.5.25-2025.12.4/.vscode/extensions.json +8 -0
  73. package/lib/templates/vue3.5.25-2025.12.4/.vscode/settings.json +13 -0
  74. package/lib/templates/vue3.5.25-2025.12.4/README.md +75 -0
  75. package/lib/templates/vue3.5.25-2025.12.4/env.d.ts +1 -0
  76. package/lib/templates/vue3.5.25-2025.12.4/eslint.config.ts +32 -0
  77. package/lib/templates/vue3.5.25-2025.12.4/index.html +13 -0
  78. package/lib/templates/vue3.5.25-2025.12.4/package-lock.json +5297 -0
  79. package/lib/templates/vue3.5.25-2025.12.4/package.json +44 -0
  80. package/lib/templates/vue3.5.25-2025.12.4/public/favicon.svg +14 -0
  81. package/lib/templates/vue3.5.25-2025.12.4/src/App.vue +16 -0
  82. package/lib/templates/vue3.5.25-2025.12.4/src/assets/vue.svg +1 -0
  83. package/lib/templates/vue3.5.25-2025.12.4/src/boot/element-plus.ts +13 -0
  84. package/lib/templates/vue3.5.25-2025.12.4/src/boot/index.ts +16 -0
  85. package/lib/templates/vue3.5.25-2025.12.4/src/boot/pinia.ts +10 -0
  86. package/lib/templates/vue3.5.25-2025.12.4/src/boot/router.ts +10 -0
  87. package/lib/templates/vue3.5.25-2025.12.4/src/boot/style.ts +9 -0
  88. package/lib/templates/vue3.5.25-2025.12.4/src/css/coverage-style.css +6 -0
  89. package/lib/templates/vue3.5.25-2025.12.4/src/directive/index.js +8 -0
  90. package/lib/templates/vue3.5.25-2025.12.4/src/directive/rememberScrollPosition.ts +17 -0
  91. package/lib/templates/vue3.5.25-2025.12.4/src/main.ts +8 -0
  92. package/lib/templates/vue3.5.25-2025.12.4/src/router/index.ts +20 -0
  93. package/lib/templates/vue3.5.25-2025.12.4/src/stores/counter.ts +12 -0
  94. package/lib/templates/vue3.5.25-2025.12.4/src/views/AboutView.vue +3 -0
  95. package/lib/templates/vue3.5.25-2025.12.4/src/views/HomeView.vue +8 -0
  96. package/lib/templates/vue3.5.25-2025.12.4/tsconfig.app.json +13 -0
  97. package/lib/templates/vue3.5.25-2025.12.4/tsconfig.json +11 -0
  98. package/lib/templates/vue3.5.25-2025.12.4/tsconfig.node.json +19 -0
  99. package/lib/templates/vue3.5.25-2025.12.4/vite.config.ts +17 -0
  100. package/lib/templates/wx-miniapp//346/210/221/346/230/257wx-miniapp.txt +0 -0
  101. package/lib/utils/date.js +148 -0
  102. package/package.json +11 -3
package/lib/demo1.js ADDED
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { program } from "commander"
4
+ import gradient from "gradient-string"
5
+ import { readFileSync } from "fs"
6
+ import { fileURLToPath } from "url"
7
+ import path from "path"
8
+
9
+ /** 渐变字符串 */
10
+ const gradientString = (str, gradientColor = ["#42d392", "#647eff"]) => {
11
+ return gradient(gradientColor)(str)
12
+ }
13
+
14
+ console.log(
15
+ gradientString(`------------------------------- ljr-cli --------------------------------`, ["red", "yellow"]),
16
+ )
17
+
18
+ // 读取 package.json 里的 version(在 ESM 下安全做法)
19
+ const __filename = fileURLToPath(import.meta.url)
20
+ const __dirname = path.dirname(__filename)
21
+ const pkg = JSON.parse(readFileSync(path.join(__dirname, "../package.json"), "utf-8"))
22
+ const version = pkg.version
23
+
24
+ program.version(version, "-v, --version", "查看版本号信息")
25
+
26
+ program
27
+ .command("init <name>")
28
+ .description("demo1演示")
29
+ .option("-l, --local", "从本地模板创建目录")
30
+ .option("-g, --git", "从git地址创建目录")
31
+ .action((name, options) => {
32
+ console.log("参数name=====>", name)
33
+ console.log("选项options=====>", options)
34
+ })
35
+
36
+ program.parse(process.argv)
package/lib/demo2.js ADDED
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { program } from "commander"
4
+ import gradient from "gradient-string"
5
+ import * as prompts from "@clack/prompts"
6
+ import { readFileSync } from "fs"
7
+ import { fileURLToPath } from "url"
8
+ import path from "path"
9
+
10
+ /** 渐变字符串 */
11
+ const gradientString = (str, gradientColor = ["#42d392", "#647eff"]) => {
12
+ return gradient(gradientColor)(str)
13
+ }
14
+
15
+ console.log(
16
+ gradientString(`------------------------------- ljr-cli --------------------------------`, ["red", "yellow"]),
17
+ )
18
+
19
+ // 读取 package.json 里的 version(在 ESM 下安全做法)
20
+ const __filename = fileURLToPath(import.meta.url)
21
+ const __dirname = path.dirname(__filename)
22
+ const pkg = JSON.parse(readFileSync(path.join(__dirname, "../package.json"), "utf-8"))
23
+ const version = pkg.version
24
+
25
+ program.version(version, "-v, --version", "查看版本号信息")
26
+
27
+ // 案例2
28
+ program
29
+ .command("init")
30
+ .description("demo2演示")
31
+ .action(async () => {
32
+ prompts.intro(gradientString("创建项目"))
33
+
34
+ const group = await prompts.group(
35
+ {
36
+ name: () =>
37
+ prompts.text({
38
+ message: "请输入项目名称:",
39
+ placeholder: "项目名称",
40
+ validate: (value) => {
41
+ if (!value.trim().length) {
42
+ return "请输入项目名称"
43
+ }
44
+ if (/[^a-z-_]+/i.test(value)) {
45
+ return "英文开头或下划线开头,且只能包含英文、数字、下划线或中划线"
46
+ }
47
+ },
48
+ }),
49
+ template: () =>
50
+ prompts.select({
51
+ message: "请选择模板:",
52
+ options: [
53
+ { label: "vue3.x", value: "vue3.x", hint: "vue3项目" },
54
+ { label: "vue2.7.16", value: "vue2.7.16", hint: "vue2的最后一个版本" },
55
+ ],
56
+ }),
57
+ age: () => prompts.text({ message: "What is your age?" }),
58
+ shouldContinue: () =>
59
+ prompts.confirm({
60
+ message: "是否继续?",
61
+ }),
62
+ color: ({ results }) =>
63
+ prompts.multiselect({
64
+ message: `What is your favorite color ${results.name}?`,
65
+ options: [
66
+ { value: "red", label: "Red" },
67
+ { value: "green", label: "Green" },
68
+ { value: "blue", label: "Blue" },
69
+ ],
70
+ }),
71
+ },
72
+ {
73
+ onCancel: ({ results }) => {
74
+ prompts.cancel("取消操作!")
75
+ process.exit(0)
76
+ },
77
+ },
78
+ )
79
+
80
+ console.log("group=====>", group)
81
+
82
+ prompts.outro(gradientString("项目创建完成"))
83
+ })
84
+
85
+ program.parse(process.argv)
package/lib/index.js CHANGED
@@ -1,23 +1,192 @@
1
1
  #!/usr/bin/env node
2
- // 第一行固定写法,指定脚本的解释器路径(注意:第一行不要添加注释啥的,不然运行不起来)
3
2
 
4
- const { program } = require("commander")
3
+ import { program } from "commander"
4
+ import gradient from "gradient-string"
5
+ import * as prompts from "@clack/prompts"
6
+ import { readFileSync, existsSync } from "fs"
7
+ import { copySync, emptyDirSync } from "fs-extra/esm"
8
+ import { fileURLToPath } from "url"
9
+ import path from "path"
10
+ import { dateFormat } from "./utils/date.js"
11
+ import download from "download-git-repo"
12
+ import { replaceInFile } from "replace-in-file"
5
13
 
6
- // 获取包的版本
7
- const version = require("../package.json").version
14
+ /** 渐变字符串 */
15
+ const gradientString = (str, gradientColor = ["#42d392", "#647eff"]) => {
16
+ return gradient(gradientColor)(str)
17
+ }
8
18
 
9
- program.version(version, "-v, --version")
19
+ console.log(
20
+ gradientString(`------------------------------- ljr-cli --------------------------------`, ["red", "yellow"]),
21
+ )
22
+ program.hook("preAction", () => {
23
+ console.log(gradientString(`-------------------- 开始时间 - ${dateFormat()} --------------------`, ["red", "yellow"]))
24
+ })
25
+ program.hook("postAction", () => {
26
+ console.log(gradientString(`-------------------- 结束时间 - ${dateFormat()} --------------------`, ["red", "yellow"]))
27
+ })
10
28
 
29
+ // 读取 package.json 里的 version(在 ESM 下安全做法)
30
+ // 当前运行文件的路径
31
+ const __filename = fileURLToPath(import.meta.url)
32
+ // 当前运行文件的文件夹
33
+ const __dirname = path.dirname(__filename)
34
+ const pkg = JSON.parse(readFileSync(path.join(__dirname, "../package.json"), "utf-8"))
35
+ const version = pkg.version
36
+
37
+ // 当前命令行的路径
38
+ const cwdPath = process.cwd()
39
+
40
+ program.version(version, "-v, --version", "查看版本号信息")
41
+
42
+ function downloadTemplate(gitUrl, projectName) {
43
+ return new Promise((resolve, reject) => {
44
+ download(gitUrl, path.resolve(cwdPath, projectName), { clone: true }, function (err) {
45
+ if (err) {
46
+ return reject(err)
47
+ }
48
+ resolve()
49
+ })
50
+ })
51
+ }
52
+
53
+ // 初始化项目
11
54
  program
12
- .command("init <name>") // 定义命令和参数
13
- .description("创建项目") // 命令描述
14
- .option("-l, --local", "从本地模板创建目录") // 定义选项
15
- .option("-g, --git", "从git地址创建目录") // 定义选项
16
- // 命令的回调函数
17
- .action((name, options) => {
18
- console.log("项目名=====>", name)
19
- console.log("选项=====>", options)
55
+ .command("init")
56
+ .description("创建项目")
57
+ .action(async () => {
58
+ prompts.intro(gradientString("开始创建项目"))
59
+
60
+ const group = await prompts.group(
61
+ {
62
+ name: () =>
63
+ prompts.text({
64
+ message: "请输入项目名称:",
65
+ placeholder: "项目名称",
66
+ validate: (value) => {
67
+ if (!value.trim().length) {
68
+ return "请输入项目名称"
69
+ }
70
+ if (/[^a-z-_]+/i.test(value)) {
71
+ return "英文开头或下划线开头,且只能包含英文、数字、下划线或中划线"
72
+ }
73
+ },
74
+ }),
75
+ templateName: () =>
76
+ prompts.select({
77
+ message: "请选择模板:",
78
+ options: [
79
+ { label: "vue3.5.25-2025.12.4", value: "vue3.5.25-2025.12.4", hint: "2025.12.4创建的" },
80
+ { label: "vue2.7.16", value: "vue2.7.16", hint: "vue2项目,这是vue2的最后一个版本" },
81
+ { label: "react", value: "react", hint: "react项目" },
82
+ { label: "qiankun", value: "qiankun", hint: "微前端-乾坤版本" },
83
+ { label: "monorepo", value: "monorepo", hint: "monorepo架构-单仓库多项目" },
84
+ { label: "node", value: "node", hint: "node服务" },
85
+ { label: "java", value: "java", hint: "java服务" },
86
+ { label: "mysql", value: "mysql", hint: "mysql数据库" },
87
+ { label: "wx-miniapp", value: "wx-miniapp", hint: "微信原生小程序" },
88
+ { label: "uni-app", value: "uni-app", hint: "uni-app项目" },
89
+ { label: "flutter", value: "flutter", hint: "flutter项目" },
90
+ ],
91
+ }),
92
+ source: () =>
93
+ prompts.select({
94
+ message: "请选择来源:",
95
+ options: [
96
+ { label: "本地", value: "local", hint: "从本地模板创建" },
97
+ {
98
+ label: "git仓库",
99
+ value: "git",
100
+ hint: "从git地址创建,这里为了演示,只是随便用了个git仓库,并不是真正的模版仓库",
101
+ },
102
+ ],
103
+ }),
104
+ },
105
+ {
106
+ onCancel: ({ results }) => {
107
+ prompts.cancel("取消操作!")
108
+ process.exit(0)
109
+ },
110
+ },
111
+ )
112
+
113
+ const s = prompts.spinner({ indicator: "timer" })
114
+
115
+ // 判断文件夹是否存在,存在询问是否清空
116
+ if (existsSync(group.name)) {
117
+ const confirm = await prompts.confirm({
118
+ message: gradientString("文件夹已存在,是否清空?", ["red", "red"]),
119
+ })
120
+ if (confirm) {
121
+ emptyDirSync(group.name)
122
+ } else {
123
+ prompts.cancel("取消操作!")
124
+ process.exit(0)
125
+ }
126
+ } else {
127
+ emptyDirSync(group.name)
128
+ }
129
+
130
+ s.start("创建文件夹...")
131
+ s.stop("文件夹操作完成!")
132
+
133
+ s.start("写入模版中...")
134
+ try {
135
+ if (group.source === "local") {
136
+ // 源路径
137
+ const srcPath = path.join(__dirname, "/templates/", group.templateName)
138
+ // 目标路径
139
+ const destPath = `./${group.name}`
140
+
141
+ copySync(srcPath, destPath, {
142
+ recursive: true,
143
+ filter: (src) => {
144
+ // 相对于模板根的相对路径
145
+ const rel = path.relative(srcPath, src)
146
+ // 根目录本身允许
147
+ if (!rel) return true
148
+ const parts = rel.split(path.sep)
149
+ // 如果路径中包含 node_modules 或 dist 则过滤掉
150
+ if (parts.includes("node_modules") || parts.includes("dist") || parts.includes(".eslintcache")) {
151
+ return false
152
+ }
153
+ return true
154
+ },
155
+ })
156
+ }
157
+
158
+ if (group.source === "git") {
159
+ await downloadTemplate("direct:https://gitee.com/ljr-395181403/git-test.git#master", group.name)
160
+ }
161
+ } catch (error) {
162
+ console.log("error=====>", error)
163
+ prompts.cancel("模版写入失败!")
164
+ process.exit(0)
165
+ }
166
+
167
+ await new Promise((resolve) => setTimeout(resolve, 2000)) // 为了更好的演示效果,强制等待
168
+ s.stop("模版写入完成!")
169
+
170
+ // 判断package.json是否存在
171
+ if (existsSync(path.join(cwdPath, group.name, "package.json"))) {
172
+ s.start("项目名操作...")
173
+ try {
174
+ const pkgFile = path.join(cwdPath, group.name, "package.json")
175
+ await replaceInFile({
176
+ files: pkgFile,
177
+ from: /("name"\s*:\s*)".*?"/,
178
+ to: `$1"${group.name}"`,
179
+ })
180
+ } catch (err) {
181
+ console.error("替换 package.json name 失败:", err)
182
+ prompts.cancel("项目名修改失败")
183
+ process.exit(1)
184
+ }
185
+ await new Promise((resolve) => setTimeout(resolve, 1000)) // 为了更好的演示效果,强制等待
186
+ s.stop("项目名操作完成!")
187
+ }
188
+
189
+ prompts.outro(gradientString("项目创建完成! 🎉"))
20
190
  })
21
191
 
22
- // 让commander解析process.argv的参数
23
192
  program.parse(process.argv)
@@ -0,0 +1,3 @@
1
+ > 1%
2
+ last 2 versions
3
+ not dead
@@ -0,0 +1,4 @@
1
+ # 公用的环境变量
2
+ VUE_APP_LAYOUT = 'layout'
3
+
4
+
@@ -0,0 +1,7 @@
1
+ # 开发环境的环境变量
2
+
3
+ # NODE_ENV 将决定您的应用运行的模式,是开发,生产还是测试,因此也决定了创建哪种 webpack 配置,如果文件内部不包含 NODE_ENV 变量,它的值将取决于模式,例如,在 production 模式下被设置为 "production",在 test 模式下被设置为 "test",默认则是 "development"。
4
+ ENV = 'development'
5
+
6
+ # 上下文
7
+ VUE_APP_BASE_API = '/dev-api'
@@ -0,0 +1,7 @@
1
+ # 生产环境的环境变量
2
+
3
+ # NODE_ENV 将决定您的应用运行的模式,是开发,生产还是测试,因此也决定了创建哪种 webpack 配置,如果文件内部不包含 NODE_ENV 变量,它的值将取决于模式,例如,在 production 模式下被设置为 "production",在 test 模式下被设置为 "test",默认则是 "development"。
4
+ ENV = 'production'
5
+
6
+ # 上下文
7
+ VUE_APP_BASE_API = '/api'
@@ -0,0 +1,3 @@
1
+
2
+ /node_modules
3
+ public/index.html
@@ -0,0 +1,21 @@
1
+ module.exports = {
2
+ root: true,
3
+ env: {
4
+ node: true,
5
+ },
6
+ extends: ["plugin:vue/essential", "eslint:recommended", "plugin:prettier/recommended"],
7
+ parserOptions: {
8
+ parser: "@babel/eslint-parser",
9
+ },
10
+ rules: {
11
+ semi: ["error", "never"], // 不允许将分号作为语句的结尾
12
+ indent: ["error", 2, { SwitchCase: 1 }], // 强制执行一致的缩进风格
13
+ quotes: ["error", "double", { avoidEscape: true, allowTemplateLiterals: true }], // 使用双引号
14
+ "no-unused-vars": ["off", { vars: "all", args: "none" }], // 有没有未使用的变量
15
+ "no-console": process.env.NODE_ENV === "production" ? "warn" : "off", // console是否要警告
16
+ "no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off", // debugger是否要警告
17
+ "spaced-comment": ["error", "always", { markers: ["/"] }], // 注释 // 或 /* 开始后的间距的一致性
18
+ "vue/multi-word-component-names": "off", // 组件名是否多单词
19
+ "vue/attributes-order": "error", // vue属性排序
20
+ },
21
+ }
@@ -0,0 +1,11 @@
1
+ module.exports = {
2
+ $schema: "https://json.schemastore.org/prettierrc",
3
+ printWidth: 120, // 一行的字符数,如果超过会进行换行,默认为80
4
+ semi: false, // 句尾是否添加分号
5
+ tabWidth: 2, // 一个tab代表几个空格数,默认为2
6
+ useTabs: false, // 是否使用tab进行缩进,默认为false,表示用空格进行缩减
7
+ singleQuote: false, // 字符串是否使用单引号,默认为false,使用双引号
8
+ trailingComma: "all", // 是否使用尾逗号,有三个可选值"<none|es5|all>"
9
+ bracketSpacing: true, // 对象大括号直接是否有空格,默认为true,效果:{ foo: bar }
10
+ endOfLine: "auto", // 避免报错delete (cr)的错
11
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "eslint.validate": ["javascript", "html", "vue"], // eslint指定要执行验证的文件
3
+ "editor.codeActionsOnSave": {
4
+ "source.fixAll.eslint": "explicit" // 显示保存时执行eslint程序
5
+ },
6
+ "editor.formatOnPaste": false, // 粘贴时自动格式化
7
+ "editor.formatOnSave": true, // 保存时自动格式化
8
+ "editor.formatOnType": false, // 控制编辑器在键入一行后,是否自动格式化该行
9
+ "editor.defaultFormatter": "esbenp.prettier-vscode" // 默认格式化程序
10
+ }
@@ -0,0 +1,55 @@
1
+ # vue2.7.16 模版
2
+
3
+ 此项目使用 vue-cli 搭建的 vue2.7.16 的最新版本,此版本应该是 vue2 最后一个版本了
4
+ 引入 l-global 包,包括 variable.css、base.css、global.css 和 utils 工具类
5
+ 引入 element-ui
6
+ 做了登录页,404 页
7
+ 做了通过路由配置生成左侧菜单
8
+ 使用 vuex-persist 插件做 vuex 持久化
9
+ 封装了全局登录判断的路由卫士
10
+ eslint + prettier
11
+ axios 封装
12
+ 封装自定义指令
13
+ 封装自动注册全局组件
14
+ 封装函数式弹窗
15
+ 封装 store 的数据字典
16
+ 原型扩展
17
+ 收集一些模版
18
+ 收集一些遇到的问题
19
+ 收集一些动画
20
+ 列表的模版,顶部搜索,中间表格,底下分页,新建编辑弹窗,删除二次确认模版
21
+
22
+ ## 项目初始化
23
+
24
+ ```
25
+ npm install
26
+ ```
27
+
28
+ ### 项目运行
29
+
30
+ ```
31
+ npm run dev || npm run serve
32
+ ```
33
+
34
+ ### 项目打包
35
+
36
+ ```
37
+ npm run build
38
+ ```
39
+
40
+ ### 检查和修复文件
41
+
42
+ ```
43
+ npm run lint
44
+ ```
45
+
46
+ ### 命名规范
47
+
48
+ | 类别 | 推荐命名方式 | 示例 | 关键点/例外情况 |
49
+ | ------------------ | ----------------------------------------------- | ----------------- | ---------------------- |
50
+ | 通用 | kebab-case | package-lock.json | 没有特别说明尽量用这个 |
51
+ | 变量 | camelCase | userProfile | |
52
+ | 路由名称 | camelCase 或者 PascalCase | userProfile | |
53
+ | App.vue | PascalCase | | |
54
+ | Vue 组件里的组件名 | PascalCase | | |
55
+ | Vue 组件里的 Props | 在声明时使用 camelCase,在模板中使用 kebab-case | | |
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ presets: ["@vue/cli-plugin-babel/preset"],
3
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es5",
4
+ "module": "esnext",
5
+ "baseUrl": "./",
6
+ "moduleResolution": "node",
7
+ "paths": {
8
+ "@/*": [
9
+ "src/*"
10
+ ]
11
+ },
12
+ "lib": [
13
+ "esnext",
14
+ "dom",
15
+ "dom.iterable",
16
+ "scripthost"
17
+ ]
18
+ }
19
+ }