create-vite-vue 1.5.5 → 1.5.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 (2) hide show
  1. package/README.md +51 -39
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -19,6 +19,7 @@
19
19
  - 🌐 本地及网络访问启动日志显示
20
20
  - 📝 自定义 Banner 插件显示项目信息
21
21
  - 🎨 可选集成 Tailwind CSS(通过 postcss 配置)
22
+ - 🟢 支持多种包管理器:npm / yarn / pnpm,可根据环境自动识别并使用
22
23
 
23
24
  ---
24
25
 
@@ -58,7 +59,7 @@
58
59
 
59
60
  ## 📁 项目目录结构说明
60
61
 
61
- project-name
62
+ project-name
62
63
  ├─ public/ —— 公共静态资源目录
63
64
  │ └─ favicon.ico
64
65
  ├─ src/
@@ -70,11 +71,11 @@ project-name
70
71
  │ ├─ types/ —— 类型声明文件
71
72
  │ ├─ utils/ —— 工具方法、请求封装
72
73
  │ ├─ views/ —— 页面级组件(路由页面)
73
- │ │ └─ home/ —— 示例页面文件夹
74
- │ │ ├─ index.vue —— 默认首页 /home
75
- │ │ ├─ meta.json —— 页面 meta 信息
76
- │ │ └─ [id]/ —— 动态参数路由示例
77
- │ │ └─ [name].vue —— 路由 /home/:id/:name
74
+ │ │ └─ home/ —— 示例页面文件夹
75
+ │ │ ├─ index.vue —— 默认首页 /home
76
+ │ │ ├─ meta.json —— 页面 meta 信息
77
+ │ │ └─ [id]/ —— 动态参数路由示例
78
+ │ │ └─ [name].vue —— 路由 /home/:id/:name
78
79
  │ ├─ App.vue —— 根组件
79
80
  │ ├─ main.js / main.ts —— 项目启动入口
80
81
  │ └─ style.css —— 全局样式文件
@@ -101,47 +102,54 @@ project-name
101
102
 
102
103
  ---
103
104
 
104
- ## ⚙️ 使用方式
105
+ ## ⚙️ 使用方式(多包管理器支持)
105
106
 
106
107
  1. 创建项目
108
+
107
109
  ```bash
108
110
  npm create vite-vue@latest
111
+ pnpm create vite-vue@latest
109
112
  ```
110
113
 
111
114
  2. 进入项目目录
115
+
112
116
  ```bash
113
117
  cd 项目名
114
118
  ```
115
119
 
116
- 3. 安装依赖 (已自动执行可省略)
117
- ```bash
118
- npm install
119
- ```
120
+ 3. 安装依赖
121
+
122
+ > ⚡ 脚手架会自动检测你当前的包管理器并自动运行一下命令:
123
+ >
124
+ > - 如果使用 **npm**:`npm install`
125
+ > - 如果使用 **pnpm**:`pnpm install`
120
126
 
121
127
  4. 启动开发环境
128
+
122
129
  ```bash
123
130
  npm run dev
131
+ pnpm dev
124
132
  ```
125
133
 
126
- > 如果在创建时选择了「立即运行」,工具会自动执行启动命令。
134
+ > 如果在创建时选择了「立即运行」,工具会自动执行启动命令。使用yarn创建项目会报错,暂时未适配
127
135
 
128
136
  ---
129
137
 
130
138
  ## 🌐 技术栈官网链接
131
139
 
132
- - [Vite](https://vitejs.dev/)
133
- - [Vue 3](https://vuejs.org/)
134
- - [JavaScript](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript)
135
- - [TypeScript](https://www.typescriptlang.org/)
136
- - [Vue Router](https://router.vuejs.org/)
137
- - [Pinia](https://pinia.vuejs.org/)
138
- - [Axios](https://axios-http.com/)
139
- - [Element Plus](https://element-plus.org/)
140
- - [Vant](https://vant-contrib.gitee.io/vant/)
141
- - [VueUse](https://vueuse.org/)
142
- - [Lodash](https://lodash.com/)
143
- - [Day.js](https://day.js.org/)
144
- - [Tailwind CSS](https://tailwindcss.com/)
140
+ - [Vite](https://vitejs.dev/)
141
+ - [Vue 3](https://vuejs.org/)
142
+ - [JavaScript](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript)
143
+ - [TypeScript](https://www.typescriptlang.org/)
144
+ - [Vue Router](https://router.vuejs.org/)
145
+ - [Pinia](https://pinia.vuejs.org/)
146
+ - [Axios](https://axios-http.com/)
147
+ - [Element Plus](https://element-plus.org/)
148
+ - [Vant](https://vant-contrib.gitee.io/vant/)
149
+ - [VueUse](https://vueuse.org/)
150
+ - [Lodash](https://lodash.com/)
151
+ - [Day.js](https://day.js.org/)
152
+ - [Tailwind CSS](https://tailwindcss.com/)
145
153
 
146
154
  ---
147
155
 
@@ -151,33 +159,32 @@ npm run dev
151
159
 
152
160
  ### 使用 nvm 切换 Node 版本
153
161
 
154
- 如果你安装了 **nvm(Node Version Manager)**,进入项目目录后执行:
162
+ 如果你安装了 **nvm(Node Version Manager)**,进入项目目录后执行:
155
163
 
156
- ``` bash
164
+ ```bash
157
165
  nvm use
158
166
  ```
159
167
 
160
- nvm 会自动读取 `.nvmrc` 文件中的 Node 版本并切换。
168
+ > nvm 会自动读取 `.nvmrc` 文件中的 Node 版本并切换。
161
169
 
162
170
  ### Windows 可能出现的问题
163
171
 
164
- 在 **Windows PowerShell** 中,`nvm use` 有时不会自动读取`.nvmrc`,可能会报错或无法切换版本。
172
+ 在 **Windows PowerShell** 中,`nvm use` 有时不会自动读取`.nvmrc`,可能会报错或无法切换版本。
165
173
 
166
- 如果出现这种情况,可以执行:
174
+ 如果出现这种情况,可以执行:
167
175
 
168
- ``` powershell
176
+ ```powershell
169
177
  nvm use $(Get-Content .nvmrc)
170
178
  ```
171
179
 
172
- 该命令会读取 `.nvmrc` 文件内容并手动切换 Node 版本。
173
-
174
180
  ---
175
181
 
176
182
  ## 🔧 常见需要调整的地方(具体文件示例)
177
183
 
178
184
  ### 1️⃣ 接口请求地址
179
185
 
180
- 文件:`src/utils/request.ts` `src/utils/request.js`
186
+ 文件:`src/utils/request.ts` / `src/utils/request.js`
187
+
181
188
  ```ts
182
189
  import axios from 'axios';
183
190
 
@@ -187,7 +194,7 @@ const service = axios.create({
187
194
  });
188
195
 
189
196
  // 示例请求
190
- export const getUserList = () => request.get('/users');
197
+ export const getUserList = () => service.get('/users');
191
198
 
192
199
  export default service;
193
200
  ```
@@ -198,7 +205,8 @@ export default service;
198
205
 
199
206
  ### 2️⃣ 本地代理配置
200
207
 
201
- 文件:`vite.config.ts` `vite.config.js`
208
+ 文件:`vite.config.ts` / `vite.config.js`
209
+
202
210
  ```ts
203
211
  import { defineConfig } from 'vite';
204
212
  import vue from '@vitejs/plugin-vue';
@@ -224,7 +232,8 @@ export default defineConfig({
224
232
 
225
233
  ### 3️⃣ 路由结构(支持动态参数)
226
234
 
227
- 文件:`src/router/index.ts` `src/router/index.js`
235
+ 文件:`src/router/index.ts` / `src/router/index.js`
236
+
228
237
  ```ts
229
238
  import { createRouter, createWebHistory } from 'vue-router'
230
239
  import routes from '~pages' // 自动生成的路由
@@ -237,14 +246,16 @@ const router = createRouter({
237
246
  export default router
238
247
  ```
239
248
 
240
- > 🔹 页面文件夹结构示例:
249
+ > 页面文件夹结构示例:
250
+
241
251
  ```text
242
252
  src/views/home/
243
253
  ├─ index.vue -> /home
244
254
  └─ [id]/[name].vue -> /home/:id/:name
245
255
  ```
246
256
 
247
- > 🔹 获取路由参数:
257
+ > 获取路由参数:
258
+
248
259
  ```ts
249
260
  import { useRoute } from 'vue-router'
250
261
  const route = useRoute()
@@ -257,6 +268,7 @@ console.log(route.params.name)
257
268
  ### 4️⃣ 页面内容与样式
258
269
 
259
270
  文件示例:`src/views/home/index.vue`
271
+
260
272
  ```vue
261
273
  <template>
262
274
  <div class="home-container">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-vite-vue",
3
- "version": "1.5.5",
3
+ "version": "1.5.6",
4
4
  "description": "基于Vite+Vue3创建基础项目模板",
5
5
  "main": "index.js",
6
6
  "author": "YwaiX",