create-uniapps 1.0.4 → 1.0.5

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 +43 -167
  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,191 +1,67 @@
1
- # 🌈 uni-preset-vue 模板说明文档
1
+ # Nuxt App Starter
2
2
 
3
- 一个基于 **Vue3 + TypeScript + Vite + Pinia + TailwindCSS** 的 `uni-app` 模板,内置多端开发环境配置,支持一键运行微信小程序、H5、App 及各类小程序平台。
4
- 本模板旨在快速搭建跨端项目,统一前端开发规范,提高开发效率。
3
+ 一个由我个人搭建和维护的 **Nuxt 4 项目模板**,用于快速创建现代化的前端项目。
4
+ 该模板集成了常用的 UI、样式、代码规范与工程化工具,开箱即用,适合中小型项目快速启动。
5
5
 
6
6
  ---
7
7
 
8
- ## 📦 技术栈
8
+ ## 特性
9
9
 
10
- | 技术 | 说明 |
11
- | ---------------------------------- | ---------------------- |
12
- | **Vue 3** | 渐进式前端框架 |
13
- | **TypeScript** | 静态类型检查 |
14
- | **Vite** | 高性能构建工具 |
15
- | **Pinia** | 轻量级状态管理 |
16
- | **TailwindCSS** | 原子化 CSS 框架 |
17
- | **VueUse** | Vue3 实用工具库 |
18
- | **Iconify** | 图标库整合方案 |
19
- | **Day.js** | 日期处理库 |
20
- | **Crypto-js / js-md5 / js-base64** | 数据加密与编码工具 |
21
- | **ESLint + Prettier** | 统一代码风格与语法检查 |
10
+ - 基于 **Nuxt 4 + Vue 3**
11
+ - 🎨 内置 **Tailwind CSS** + **Nuxt UI**
12
+ - 🧩 集成 **Element Plus(Nuxt 模块)**
13
+ - 🧭 使用 **Vue Router 4**
14
+ - 🛠 完整的 **ESLint + Prettier** 代码规范
15
+ - 📦 使用 **ESM(type: module)**
16
+ - 🔧 已配置 PostCSS 与 Sass
17
+ - 🚀 支持构建、开发、生成、预览完整流程
22
18
 
23
19
  ---
24
20
 
25
- ## 🚀 快速开始
26
-
27
- ### 1️⃣ 安装依赖
28
-
29
- ```bash
30
- pnpm install
31
- # 或
32
- npm install
33
- # 或
34
- yarn
35
- ```
36
-
37
- ### 2️⃣ 启动开发
38
-
39
- 可根据需要启动不同端的调试模式:
40
-
41
- | 命令 | 平台说明 |
42
- | ------------------------------ | ------------------- |
43
- | `npm run dev:h5` | 运行 H5 页面 |
44
- | `npm run dev:mp-weixin` | 运行微信小程序 |
45
- | `npm run dev:mp-alipay` | 运行支付宝小程序 |
46
- | `npm run dev:mp-toutiao` | 运行字节跳动小程序 |
47
- | `npm run dev:mp-baidu` | 运行百度小程序 |
48
- | `npm run dev:mp-qq` | 运行 QQ 小程序 |
49
- | `npm run dev:mp-xhs` | 运行小红书小程序 |
50
- | `npm run dev:quickapp-webview` | 运行快应用 |
51
- | `npm run dev:h5:ssr` | 运行 SSR 模式(H5) |
52
-
53
- ---
54
-
55
- ### 3️⃣ 打包构建
56
-
57
- | 命令 | 说明 |
58
- | -------------------------------- | ---------------- |
59
- | `npm run build:h5` | 构建 H5 版本 |
60
- | `npm run build:mp-weixin` | 构建微信小程序 |
61
- | `npm run build:mp-alipay` | 构建支付宝小程序 |
62
- | `npm run build:mp-toutiao` | 构建字节小程序 |
63
- | `npm run build:h5:ssr` | 构建 SSR H5 |
64
- | `npm run build:quickapp-webview` | 构建快应用 |
65
-
66
- ---
67
-
68
- ## 🧩 项目结构
69
-
70
- ```
71
- uni-preset-vue/
72
- ├── src/
73
- │ ├── pages/ # 页面目录
74
- │ ├── components/ # 公共组件
75
- │ ├── store/ # Pinia 状态管理
76
- │ ├── utils/ # 工具函数与封装
77
- │ ├── locales/ # i18n 国际化配置
78
- │ ├── styles/ # 全局样式与 Tailwind 配置
79
- │ └── main.ts # 入口文件
80
-
81
- ├── uni_modules/ # uni-app 模块目录
82
- ├── static/ # 静态资源
83
- ├── package.json
84
- ├── vite.config.ts
85
- ├── tsconfig.json
86
- └── README.md
87
- ```
88
-
89
- ---
90
-
91
- ## 🧠 开发规范
92
-
93
- ### 代码规范
94
-
95
- - 使用 **TypeScript** 编写逻辑。
96
-
97
- - 使用 **ESLint + Prettier + Tailwind** 进行自动格式化。
98
-
99
- - 提交前执行:
100
-
101
- ```bash
102
- npm run type-check
103
- ```
104
-
105
- 确保类型检查通过。
106
-
107
- ### 目录规范
108
-
109
- - 页面统一放在 `src/pages/`
110
- - 公共组件放在 `src/components/`
111
- - 全局状态放在 `src/store/`
112
- - 工具函数放在 `src/utils/`
113
- - 样式配置统一放在 `src/styles/`
114
-
115
- ---
116
-
117
- ## 🧰 常用依赖说明
118
-
119
- | 依赖 | 用途 |
120
- | ------------------------------------ | -------------- |
121
- | `@vueuse/core` | 常用组合式函数 |
122
- | `dayjs` | 时间格式化 |
123
- | `crypto-js` / `js-md5` / `js-base64` | 数据加密与签名 |
124
- | `qs` | 请求参数序列化 |
125
- | `@iconify/vue` | 图标组件 |
126
- | `pinia` | 全局状态管理 |
127
- | `vue-i18n` | 多语言支持 |
21
+ ## 📦 技术栈
128
22
 
129
- ---
23
+ ### 核心框架
130
24
 
131
- ## 🧪 检查与优化
25
+ - **Nuxt** `^4.1.1`
26
+ - **Vue** `^3.5.21`
27
+ - **Vue Router** `^4.5.1`
132
28
 
133
- | 命令 | 功能 |
134
- | -------------------- | --------------------------- |
135
- | `npm run type-check` | 类型检查 |
136
- | `npm run lint` | 语法检查 |
137
- | `npm run format` | 自动格式化(结合 Prettier) |
29
+ ### UI / 样式
138
30
 
139
- ---
31
+ - **Tailwind CSS** `^3.4.17`
32
+ - **Nuxt UI** `^3.3.3`
33
+ - **Element Plus(Nuxt)** `^1.1.4`
34
+ - **Sass Embedded**
35
+ - **PostCSS**
36
+ - **postcss-custom-media**
140
37
 
141
- ## 🌍 支持平台
38
+ ### 工程化 & 规范
142
39
 
143
- | 平台 | 是否支持 |
144
- | --------------------- | -------- |
145
- | H5 | ✅ |
146
- | 微信小程序 | ✅ |
147
- | 支付宝小程序 | ✅ |
148
- | 抖音小程序 | ✅ |
149
- | 百度小程序 | ✅ |
150
- | QQ 小程序 | ✅ |
151
- | 快应用 | ✅ |
152
- | HarmonyOS (鸿蒙 NEXT) | ✅ |
40
+ - **TypeScript** `^5.9.2`
41
+ - **ESLint** `^9.35.0`
42
+ - **Prettier**
43
+ - **prettier-plugin-tailwindcss**
44
+ - **@types/node**
153
45
 
154
46
  ---
155
47
 
156
- ## 💡 开发建议
48
+ ## 📁 项目定位
157
49
 
158
- 1. 推荐使用 **VSCode** 搭配以下插件:
50
+ 该项目是一个 **基础模板 / 起始项目(Starter)**:
159
51
 
160
- - 🌟 `Volar`(Vue 3 支持)
161
- - 🌟 `ESLint`
162
- - 🌟 `Tailwind CSS IntelliSense`
163
- - 🌟 `Iconify IntelliSense`
164
-
165
- 2. 若需自定义端平台启动,请修改 `package.json` 中的 `scripts` 命令。
166
-
167
- 3. 统一风格建议使用 `prettier-plugin-tailwindcss` 自动调整类名顺序。
168
-
169
- ---
170
-
171
- ## 🧾 License
172
-
173
- 本项目模板仅供学习与快速开发使用。
174
- 如需商用或二次封装,请保留原作者说明或在适当位置注明出处。
52
+ - 不包含业务代码
53
+ - 不强制约束目录结构
54
+ - 适合作为:
55
+ - 新项目起点
56
+ - 技术选型实验
57
+ - 中小型项目基础工程
175
58
 
176
59
  ---
177
60
 
178
- ## 👨‍💻 作者信息
61
+ ## 🚀 使用方式
179
62
 
180
- - 作者:josef
181
- - 模板名称:`uni-preset-vue`
182
- - 创建时间:2025 年
183
- - 版本:v1.0.0
63
+ ### 安装依赖
184
64
 
185
- ---
186
-
187
- ## 📅 更新日志
188
-
189
- | 日期 | 版本 | 内容 |
190
- | ---------- | ------ | -------------- |
191
- | 2025-10-13 | v1.0.0 | 初始化项目模板 |
65
+ ```bash
66
+ npm install
67
+ ```
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.5",
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
+ });