create-uniapps 1.0.4 → 1.0.6

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 (37) hide show
  1. package/README.md +2 -2
  2. package/index.mjs +35 -17
  3. package/package.json +3 -4
  4. package/template/.prettierrc +9 -0
  5. package/template/.vscode/settings.json +27 -0
  6. package/template/LICENSE +21 -0
  7. package/template/README.md +2 -2
  8. package/template/eslint.config.ts +23 -0
  9. package/template/package-lock.json +17910 -14602
  10. package/template/package.json +5 -13
  11. package/template/prettier.config.ts +2 -2
  12. package/template/shims-uni.d.ts +3 -5
  13. package/template/src/App.vue +7 -6
  14. package/template/src/auto-imports.d.ts +1 -0
  15. package/template/src/env.d.ts +4 -4
  16. package/template/src/main.ts +6 -8
  17. package/template/src/manifest.json +71 -71
  18. package/template/src/pages/index/index.vue +5 -7
  19. package/template/src/pages.json +7 -9
  20. package/template/src/shime-uni.d.ts +5 -5
  21. package/template/src/static/css/index.scss +2 -0
  22. package/template/src/static/css/tailwind.css +1 -2
  23. package/template/src/uni_modules/uview-plus/components/u-icon/u-icon.vue +197 -179
  24. package/template/src/uni_modules/uview-plus/components/u-icon/util.js +61 -76
  25. package/template/src/uni_modules/uview-plus/libs/config/config.js +39 -39
  26. package/template/src/utils/config.ts +23 -0
  27. package/template/src/utils/request.ts +29 -11
  28. package/template/src/uview-plus.d.ts +1 -1
  29. package/template/tailwind.config.ts +1 -1
  30. package/template/tsconfig.json +8 -18
  31. package/template/vite.config.ts +9 -11
  32. package/template/eslint.config.mjs +0 -30
  33. package/template/src/static/font_2225171_8kdcwk4po24.ttf +0 -0
  34. package/template/src/uni_modules/uview-plus/components/u-icon/font_2225171_8kdcwk4po24.ttf +0 -0
  35. package/template/src/uni_modules/uview-plus/libs/font/font_2225171_8kdcwk4po24.ttf +0 -0
  36. /package/template/src/static/{logo.png → favicon.ico} +0 -0
  37. /package/template/src/types/{index.d.ts → global.d.ts} +0 -0
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # 🌈 uni-preset-vue 模板说明文档
2
2
 
3
- 一个基于 **Vue3 + TypeScript + Vite + Pinia + TailwindCSS** 的 `uni-app` 模板,内置多端开发环境配置,支持一键运行微信小程序、H5、App 及各类小程序平台。
3
+ 一个基于 **Vue3 + TypeScript + Vite + Pinia + TailwindCSS** 的 `uni-app` 模板,内置多端开发环境配置,支持一键运行微信小程序、H5、App 及各类小程序平台。
4
4
  本模板旨在快速搭建跨端项目,统一前端开发规范,提高开发效率。
5
5
 
6
6
  ---
@@ -170,7 +170,7 @@ uni-preset-vue/
170
170
 
171
171
  ## 🧾 License
172
172
 
173
- 本项目模板仅供学习与快速开发使用。
173
+ 本项目模板仅供学习与快速开发使用。
174
174
  如需商用或二次封装,请保留原作者说明或在适当位置注明出处。
175
175
 
176
176
  ---
package/index.mjs CHANGED
@@ -37,6 +37,14 @@ function toValidPackageName(projectName) {
37
37
  .replace(/[^a-z0-9-~]+/g, "-");
38
38
  }
39
39
 
40
+ // 将包名转换为目录名
41
+ function packageNameToDirName(packageName) {
42
+ if (packageName.includes("/")) {
43
+ return packageName.split("/")[1];
44
+ }
45
+ return packageName;
46
+ }
47
+
40
48
  // 交互式提问
41
49
  async function askForOptions(targetDir) {
42
50
  const options = await prompt([
@@ -59,11 +67,11 @@ async function askForOptions(targetDir) {
59
67
  return options;
60
68
  }
61
69
 
62
- // 拷贝模板(固定模板)
70
+ // 拷贝模板
63
71
  async function copyTemplate(src, dest) {
64
72
  const spinner = ora(`正在创建项目...`).start();
65
73
  try {
66
- await copy(src, dest); // 直接拷贝 src 下的所有文件到 dest
74
+ await copy(src, dest);
67
75
  spinner.succeed("项目创建成功");
68
76
  } catch (err) {
69
77
  spinner.fail("项目创建失败");
@@ -121,34 +129,44 @@ function printCompletion(targetDir, installDeps) {
121
129
  }
122
130
 
123
131
  console.log(chalk.dim(` # 启动开发服务器`));
124
- console.log(` npm run dev:h5`);
132
+ console.log(` npm run dev`);
133
+ console.log();
134
+ console.log(chalk.dim(` # 构建生产版本`));
135
+ console.log(` npm run build`);
136
+ console.log();
125
137
  }
126
138
 
127
139
  // 主函数
128
140
  async function main() {
129
141
  printWelcome();
130
142
 
131
- // 获取目标目录
132
- const targetDir = process.argv[2];
143
+ // 获取初始目标目录
144
+ const initialTargetDir = process.argv[2];
133
145
 
134
- if (!targetDir) {
146
+ if (!initialTargetDir) {
135
147
  console.error(
136
148
  chalk.red("❌ 必须指定项目名称,例如:") +
137
- chalk.cyan(" npx create-uniapps my-project")
149
+ chalk.cyan("npx create-uniapps my-project")
138
150
  );
139
151
  process.exit(1);
140
152
  }
141
153
 
142
- // 检查目录是否已存在
143
- const destDir = resolve(process.cwd(), targetDir);
144
- if (fsExtra.existsSync(destDir)) {
145
- console.error(chalk.red(`❌ 目录 "${targetDir}" 已存在!`));
146
- process.exit(1);
147
- }
154
+ let destDir = null;
155
+ let finalDirName = null;
148
156
 
149
157
  try {
150
- // 获取用户选项
151
- const options = await askForOptions(targetDir);
158
+ // 先获取用户选项
159
+ const options = await askForOptions(initialTargetDir);
160
+
161
+ // 基于用户输入的项目名称确定最终目录名
162
+ finalDirName = packageNameToDirName(options.packageName);
163
+ destDir = resolve(process.cwd(), finalDirName);
164
+
165
+ // 检查目录是否已存在
166
+ if (fsExtra.existsSync(destDir)) {
167
+ console.error(chalk.red(`❌ 目录 "${finalDirName}" 已存在!`));
168
+ process.exit(1);
169
+ }
152
170
 
153
171
  // 拷贝模板
154
172
  await copyTemplate(join(__dirname, "template"), destDir);
@@ -162,12 +180,12 @@ async function main() {
162
180
  }
163
181
 
164
182
  // 打印完成信息
165
- printCompletion(targetDir, options.installDeps);
183
+ printCompletion(finalDirName, options.installDeps);
166
184
  } catch (err) {
167
185
  console.error(chalk.red("❌ 创建项目失败:"), err.message);
168
186
 
169
187
  // 清理已创建的文件
170
- if (fsExtra.existsSync(destDir)) {
188
+ if (destDir && fsExtra.existsSync(destDir)) {
171
189
  const spinner = ora("清理已创建的文件...").start();
172
190
  await remove(destDir);
173
191
  spinner.succeed("清理完成");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-uniapps",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "UniApps template",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -8,15 +8,14 @@
8
8
  },
9
9
  "files": [
10
10
  "index.mjs",
11
- "template",
12
- "README.md"
11
+ "template"
13
12
  ],
14
13
  "scripts": {
15
14
  "test": "echo \"Error: no test specified\" && exit 1"
16
15
  },
17
16
  "repository": {
18
17
  "type": "git",
19
- "url": "https://gitee.com/hu-hai-aaa/uniapps.git"
18
+ "url": "https://github.com/359Steve/create-uniplus.git"
20
19
  },
21
20
  "keywords": [
22
21
  "uniapp",
@@ -0,0 +1,9 @@
1
+ {
2
+ "plugins": ["prettier-plugin-tailwindcss"],
3
+ "vueIndentScriptAndStyle": false,
4
+ "printWidth": 120,
5
+ "singleQuote": true,
6
+ "semi": true,
7
+ "tabWidth": 4,
8
+ "htmlWhitespaceSensitivity": "ignore"
9
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "editor.formatOnSave": true,
3
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
4
+ "editor.codeActionsOnSave": {
5
+ "source.fixAll.eslint": "explicit"
6
+ },
7
+ "[vue]": {
8
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
9
+ },
10
+ "[typescript]": {
11
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
12
+ },
13
+ "[javascript]": {
14
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
15
+ },
16
+ "[json]": {
17
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
18
+ },
19
+ "eslint.validate": [
20
+ "javascript",
21
+ "javascriptreact",
22
+ "typescript",
23
+ "typescriptreact",
24
+ "vue"
25
+ ],
26
+ "prettier.requireConfig": true
27
+ }
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Josef-qiao
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,6 +1,6 @@
1
1
  # 🌈 uni-preset-vue 模板说明文档
2
2
 
3
- 一个基于 **Vue3 + TypeScript + Vite + Pinia + TailwindCSS** 的 `uni-app` 模板,内置多端开发环境配置,支持一键运行微信小程序、H5、App 及各类小程序平台。
3
+ 一个基于 **Vue3 + TypeScript + Vite + Pinia + TailwindCSS** 的 `uni-app` 模板,内置多端开发环境配置,支持一键运行微信小程序、H5、App 及各类小程序平台。
4
4
  本模板旨在快速搭建跨端项目,统一前端开发规范,提高开发效率。
5
5
 
6
6
  ---
@@ -169,7 +169,7 @@ uni-preset-vue/
169
169
 
170
170
  ## 🧾 License
171
171
 
172
- 本项目模板仅供学习与快速开发使用。
172
+ 本项目模板仅供学习与快速开发使用。
173
173
  如需商用或二次封装,请保留原作者说明或在适当位置注明出处。
174
174
 
175
175
  ---
@@ -0,0 +1,23 @@
1
+ // eslint.config.ts
2
+ import antfu from '@antfu/eslint-config';
3
+
4
+ export default antfu({
5
+ vue: true,
6
+ typescript: true,
7
+ stylistic: {
8
+ indent: 'tab',
9
+ quotes: 'single',
10
+ semi: true,
11
+ },
12
+ ignores: ['**/dist', '**/node_modules', '**/.vite', '**/auto-imports.d.ts', '**/components.d.ts'],
13
+ rules: {
14
+ 'style/indent': 'off',
15
+ 'style/no-tabs': 'off',
16
+ 'unused-imports/no-unused-vars': 'warn',
17
+ 'style/brace-style': 'warn',
18
+ 'ts/no-empty-object-type': 'warn',
19
+ 'style/eol-last': 'off',
20
+ 'no-console': 'off',
21
+ 'vue/html-indent': 'off',
22
+ },
23
+ });