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.
- package/README.md +2 -2
- package/index.mjs +35 -17
- package/package.json +3 -4
- package/template/.prettierrc +9 -0
- package/template/.vscode/settings.json +27 -0
- package/template/LICENSE +21 -0
- package/template/README.md +2 -2
- package/template/eslint.config.ts +23 -0
- package/template/package-lock.json +17910 -14602
- package/template/package.json +5 -13
- package/template/prettier.config.ts +2 -2
- package/template/shims-uni.d.ts +3 -5
- package/template/src/App.vue +7 -6
- package/template/src/auto-imports.d.ts +1 -0
- package/template/src/env.d.ts +4 -4
- package/template/src/main.ts +6 -8
- package/template/src/manifest.json +71 -71
- package/template/src/pages/index/index.vue +5 -7
- package/template/src/pages.json +7 -9
- package/template/src/shime-uni.d.ts +5 -5
- package/template/src/static/css/index.scss +2 -0
- package/template/src/static/css/tailwind.css +1 -2
- package/template/src/uni_modules/uview-plus/components/u-icon/u-icon.vue +197 -179
- package/template/src/uni_modules/uview-plus/components/u-icon/util.js +61 -76
- package/template/src/uni_modules/uview-plus/libs/config/config.js +39 -39
- package/template/src/utils/config.ts +23 -0
- package/template/src/utils/request.ts +29 -11
- package/template/src/uview-plus.d.ts +1 -1
- package/template/tailwind.config.ts +1 -1
- package/template/tsconfig.json +8 -18
- package/template/vite.config.ts +9 -11
- package/template/eslint.config.mjs +0 -30
- package/template/src/static/font_2225171_8kdcwk4po24.ttf +0 -0
- package/template/src/uni_modules/uview-plus/components/u-icon/font_2225171_8kdcwk4po24.ttf +0 -0
- package/template/src/uni_modules/uview-plus/libs/font/font_2225171_8kdcwk4po24.ttf +0 -0
- /package/template/src/static/{logo.png → favicon.ico} +0 -0
- /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);
|
|
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
|
|
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
|
|
143
|
+
// 获取初始目标目录
|
|
144
|
+
const initialTargetDir = process.argv[2];
|
|
133
145
|
|
|
134
|
-
if (!
|
|
146
|
+
if (!initialTargetDir) {
|
|
135
147
|
console.error(
|
|
136
148
|
chalk.red("❌ 必须指定项目名称,例如:") +
|
|
137
|
-
chalk.cyan("
|
|
149
|
+
chalk.cyan("npx create-uniapps my-project")
|
|
138
150
|
);
|
|
139
151
|
process.exit(1);
|
|
140
152
|
}
|
|
141
153
|
|
|
142
|
-
|
|
143
|
-
|
|
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(
|
|
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(
|
|
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.
|
|
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://
|
|
18
|
+
"url": "https://github.com/359Steve/create-uniplus.git"
|
|
20
19
|
},
|
|
21
20
|
"keywords": [
|
|
22
21
|
"uniapp",
|
|
@@ -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
|
+
}
|
package/template/LICENSE
ADDED
|
@@ -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.
|
package/template/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
|
---
|
|
@@ -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
|
+
});
|