Skip to content

前端脚手架

Vue3 项目前端脚手架,支持:

  • uni-app 项目
  • uni-app,H5 移动端
  • uni-app,PC 管理端 - 普通
  • uni-app,PC 管理端 - TGS
  • uni-app,PC 电子流
  • uni-app,H5 电子流

1. 如何使用

安装:

bash
pnpm add net-cli -g

命令行使用,新建工程:

bash
# Vue3
net-cli init my-project --vueVersion vue3

# Vue3 uni-app
net-cli init my-project --vueVersion vue3-cross

命令行使用,新建子工程:

bash
# Vue3 H5
net-cli initSubProject sub-project --type h5 --vueVersion vue3

# Vue3 PC 管理端
net-cli initSubProject sub-project --type admin --vueVersion vue3

# Vue3 uni-app
net-cli initSubProject sub-project --vueVersion vue3-cross

脚本中使用:

ts
const { initProject, initSubProject } = require('net-cli');

initProject({
  downloadPath: process.cwd(),
  vueVersion: 'vue3',
});

initSubProject({
  subProjectName: 'user',
  downloadPath: process.cwd(),
  type: 'h5',
  vueVersion: 'vue3',
});

2. 类型

ts
export type VueVersion = 'vue3-cross' | 'vue3';

export type SubProjectType = 'admin' | 'h5' | 'tgs' | 'match-apply' | 'match-apply-mobile';

export interface InitVue3Options {
  downloadPath: string;
  vueVersion: VueVersion;
}

export interface InitSubProjectOptions {
  subProjectName: string;
  downloadPath: string;
  vueVersion: VueVersion;
  type?: SubProjectType;
}

3. 常见问题

3.1. 本地调试

先构建好:

bash
pnpm --filter="./packages/net-cli" build

去一个想创建新工程的父级目录下,执行下面命令:

bash
# 参数参考上面指引
node /Users/xxx/Documents/git-woa/tx-plugin-light/packages/net-cli/bin/index.js init vue3-temp-2 --vueVersion vue3

4. 更新日志

点此查看