diff --git a/index.js b/index.js
index 8fe5b24..cbbe70a 100755
--- a/index.js
+++ b/index.js
@@ -57,7 +57,7 @@ function isEmpty(dir) {
return true
}
-function getVueLiveVersion() {
+function getFiteVersion() {
return new Promise(yes => {
request('https://registry.npmmirror.com/fite', res => {
let data = ''
@@ -145,14 +145,14 @@ function sleep(num = 1) {
console.log(cyan('\n初始化项目...'))
- let vueLiveVer = await getVueLiveVersion()
+ let fiteVerion = await getFiteVersion()
fs.mkdir(join(targetDir, 'src'))
console.log('[c---------]', '10%')
- writePackageJson(join(targetDir, 'package.json'), res.projectName, vueLiveVer)
- writeConfigFile(join(targetDir, 'vue.live.js'))
+ writePackageJson(join(targetDir, 'package.json'), res.projectName, fiteVerion)
+ writeConfigFile(join(targetDir, 'fite.config.js'))
writeGitIgnore(join(targetDir, '.gitignore'))
writePrettierrc(join(targetDir, '.prettierrc.yaml'))
@@ -165,13 +165,28 @@ function sleep(num = 1) {
console.log('[oooooc----]', '60%')
- writeMainJs(join(targetDir, 'src/main.js'))
- writeAppVue(join(targetDir, 'src/app.vue'))
- writeHomeVue(join(targetDir, 'src/views/home.vue'))
- writeAboutVue(join(targetDir, 'src/views/about.vue'))
- writeHelloVue(join(targetDir, 'src/components/hello.vue'))
- writeRouter(join(targetDir, 'src/router.js'))
- writeStore(join(targetDir, 'src/store.js'), vueLiveVer)
+ if (res.isSPA) {
+ writeMainJs(join(targetDir, 'src/main.js'))
+ writeAppVue(join(targetDir, 'src/app.vue'))
+ writeHomeVue(join(targetDir, 'src/views/home.vue'))
+ writeAboutVue(join(targetDir, 'src/views/about.vue'))
+ writeHelloVue(join(targetDir, 'src/components/hello.vue'))
+ writeRouter(join(targetDir, 'src/router.js'))
+ writeStore(join(targetDir, 'src/store.js'), fiteVerion)
+ } else {
+ // index page
+ writeMainJs(join(targetDir, 'src/pages/index/main.js'))
+ writeAppVue(join(targetDir, 'src/pages/index/app.vue'))
+ writeHomeVue(join(targetDir, 'src/pages/index/views/home.vue'))
+ writeAboutVue(join(targetDir, 'src/pages/index/views/about.vue'))
+ writeHelloVue(join(targetDir, 'src/pages/index/components/hello.vue'))
+ writeRouter(join(targetDir, 'src/pages/index/router.js'))
+ writeStore(join(targetDir, 'src/pages/index/store.js'), fiteVerion)
+
+ // demo page
+ writeMainJs(join(targetDir, 'src/pages/demo/main.js', true))
+ writeAppVue(join(targetDir, 'src/pages/demo/app.vue', true))
+ }
console.log('[oooooooooo]', '100%')
console.log(cyan('初始化完成, 可依次执行以下命令启动项目: '))
diff --git a/lib/demo-js.js b/lib/demo-js.js
index 6a2e3c6..5f13e53 100644
--- a/lib/demo-js.js
+++ b/lib/demo-js.js
@@ -6,18 +6,24 @@
import fs from 'iofs'
-export function writeMainJs(file) {
+export function writeMainJs(file, demo) {
fs.echo(
`
import { createApp } from 'vue'
import App from './app.vue'
-import router from './router'
+
import store from './store'
+${demo ? '' : `import router from './router'`}
const app = createApp(App)
-app.use(router).use(store).mount('.app')
+${
+ demo
+ ? `app.use(store).mount('.app')`
+ : `app.use(router).use(store).mount('.app')`
+}
+
`,
file
@@ -72,9 +78,70 @@ export default function (app) {
)
}
-export function writeAppVue(file) {
- fs.echo(
- `
+export function writeAppVue(file, demo) {
+ if (demo) {
+ fs.echo(
+ `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ `,
+ file
+ )
+ } else {
+ fs.echo(
+ `
@@ -138,8 +205,9 @@ main {
`,
- file
- )
+ file
+ )
+ }
}
export function writeHelloVue(file) {
@@ -150,7 +218,7 @@ export function writeHelloVue(file) {
{{ msg }}
@@ -229,7 +297,7 @@ export default {
{{content}}
- 当前vue-live版本: v{{$store.version}}
+ 当前Fite版本: v{{$store.version}}