Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit639b0c4

Browse files
committed
update vue3 component page
1 parent9973d7b commit639b0c4

File tree

9 files changed

+52
-11
lines changed

9 files changed

+52
-11
lines changed

‎.DS_Store

0 Bytes
Binary file not shown.

‎index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ const program = require('commander');
44
consthelpOptions=require('./lib/core/help');
55
constcreateCommands=require('./lib/core/create');
66

7-
constlog=require('./lib/utils/log');
8-
97
// 定义显示模块的版本号
108
program.version(require('./package.json').version);
119

‎lib/config/repo_config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
constvueGitRepo="direct:https://github.com/coderwhy/hy-vue-temp.git";
22

3-
43
module.exports={
54
vueGitRepo
65
}

‎lib/core/actions.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,19 @@ const createProject = async (project, otherArg) => {
2323
constnpm=process.platform==='win32' ?'npm.cmd' :'npm';
2424
awaitterminal.spawn(npm,['install'],{cwd:`./${project}`});
2525

26+
// 5.运行项目
27+
terminal.spawn(npm,['run','serve'],{cwd:`./${project}`});
28+
2629
// 4.打开浏览器
2730
open('http://localhost:8080/');
28-
29-
// 5.运行项目
30-
awaitterminal.spawn(npm,['run','serve'],{cwd:`./${project}`});
3131
}
3232

3333
consthandleEjsToFile=async(name,dest,template,filename)=>{
3434
// 1.获取模块引擎的路径
3535
consttemplatePath=path.resolve(__dirname,template);
36-
constresult=awaitejsCompile(templatePath,{name,lowerName:name.toLowerCase()});
36+
constcpnPath=dest.replace('router','views').replace("src","@")+`/${name}.vue`
37+
constroutePath=dest.replace('/router','').replace('src','')
38+
constresult=awaitejsCompile(templatePath,{name,lowerName:name.toLowerCase(), cpnPath, routePath});
3739

3840
// 2.写入文件中
3941
// 判断文件不存在,那么就创建文件
@@ -45,12 +47,20 @@ const handleEjsToFile = async (name, dest, template, filename) => {
4547
constaddComponent=async(name,dest)=>{
4648
handleEjsToFile(name,dest,'../template/component.vue.ejs',`${name}.vue`);
4749
}
48-
4950
constaddPage=async(name,dest)=>{
5051
addComponent(name,dest);
5152
handleEjsToFile(name,dest,'../template/vue-router.js.ejs','router.js')
5253
}
5354

55+
constaddVue3TSComponent=async(name,dest)=>{
56+
handleEjsToFile(name,dest,'../template/component3_ts.vue.ejs',`${name}.vue`);
57+
}
58+
constaddVue3Page=async(name,dest)=>{
59+
addVue3TSComponent(name,dest);
60+
letrouterDest=dest.replace("views","router")
61+
handleEjsToFile(name,routerDest,'../template/vue-router4.js.ejs',`${name}.ts`)
62+
}
63+
5464
constaddStore=async(name,dest)=>{
5565
handleEjsToFile(name,dest,'../template/vue-store.js.ejs','index.js')
5666
handleEjsToFile(name,dest,'../template/vue-types.js.ejs','types.js')
@@ -60,5 +70,6 @@ module.exports = {
6070
createProject,
6171
addComponent,
6272
addPage,
73+
addVue3Page,
6374
addStore
6475
}

‎lib/core/create.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const {
44
createProject,
55
addComponent,
66
addPage,
7+
addVue3Page,
78
addStore
89
}=require('./actions');
910

@@ -26,6 +27,13 @@ const createCommands = () => {
2627
addPage(name,program.dest||`src/pages/${name.toLowerCase()}`)
2728
})
2829

30+
program
31+
.command('add3page <name>')
32+
.description('add vue page, 例如: coderwhy add3page Home [-d dest]')
33+
.action(name=>{
34+
addVue3Page(name,program.dest||`src/views/${name.toLowerCase()}`)
35+
})
36+
2937
program
3038
.command('addstore <name>')
3139
.description('add vue store, 例如: coderwhy addstore favor [-d dest]')

‎lib/template/component3_ts.vue.ejs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<template>
2+
<divclass="<%= data.lowerName %>">
3+
<h2><%=data.lowerName%></h2>
4+
</div>
5+
</template>
6+
7+
<scriptlang="ts">
8+
import {defineComponent }from'vue'
9+
10+
exportdefaultdefineComponent({
11+
name:'<%= data.name %>',
12+
setup() {
13+
return {}
14+
}
15+
})
16+
</script>
17+
18+
<stylescoped></style>

‎lib/template/vue-router4.js.ejs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const<%=data.name%> = () => import('<%=data.cpnPath%>')
2+
export default {
3+
path: '<%=data.routePath%>',
4+
name: '<%=data.name%>',
5+
component:<%=data.name%>,
6+
children: []
7+
}

‎package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name":"coderwhy",
3-
"version":"1.1.0",
3+
"version":"1.1.4",
44
"description":"CLI front-end development tools",
55
"main":"index.js",
66
"bin": {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp