From d8a3c59e8562ca8ac287f5a8a22233f0b1da01c3 Mon Sep 17 00:00:00 2001 From: zhaojinfeng <121016171@qq.com> Date: Sun, 25 Jun 2023 10:50:20 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E7=94=9F=E6=88=90=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/gen.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/bin/gen.ts b/bin/gen.ts index cb73fb8..dc5ad74 100644 --- a/bin/gen.ts +++ b/bin/gen.ts @@ -2,8 +2,8 @@ * @Author: zhaojinfeng 121016171@qq.com * @Date: 2023-06-20 16:46:04 * @LastEditors: zhaojinfeng 121016171@qq.com - * @LastEditTime: 2023-06-21 10:56:31 - * @FilePath: \tianheng-design\bin\GEN.TS + * @LastEditTime: 2023-06-25 10:47:14 + * @FilePath: \uni\bin\gen.ts * @Description: * */ @@ -32,13 +32,18 @@ async function rendenVUE(data: RenderData) { } co(function*() { - const name: string = yield coprompt('起一个组件英文名称(不区分大小写): ') - if (!name) + const input: string = yield coprompt('起一个组件英文名称(不区分大小写): ') + + if (!input) throw new Error('不能创建') - const lowerName = name.toLowerCase() - const first = lowerName[0] - const component = first.toUpperCase() + lowerName.slice(1) + const lowerName = input.toLowerCase() + let component = '' + + input.split('-').forEach((name) => { + const first = name[0] + component += first.toUpperCase() + name.slice(1) + }) const data = { lowerName, component } Promise .all([rendenStories(data), rendenVUE(data)])