From 1972acfd2e02a9bbbc7a571c0dc2e25d505a4fcf Mon Sep 17 00:00:00 2001 From: fmm <1442620801@qq.com> Date: Wed, 18 Sep 2024 10:18:01 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20cli=E8=A1=A5=E5=85=85redis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/toolkits/pro/src/lib/init.ts | 21 ++++++++++++++++++--- packages/toolkits/pro/src/lib/interfaces.ts | 2 ++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/toolkits/pro/src/lib/init.ts b/packages/toolkits/pro/src/lib/init.ts index 7d2678d8..b1e2f78b 100644 --- a/packages/toolkits/pro/src/lib/init.ts +++ b/packages/toolkits/pro/src/lib/init.ts @@ -97,6 +97,20 @@ const getProjectInfo = (): Promise => { answers.framework === VUE_TEMPLATE_PATH && answers.serverFramework !== ServerFrameworks.Skip, }, + { + type: 'input', + name: 'redisHost', + message: '请输入Redis地址:', + default: 'localhost', + prefix: '*', + }, + { + type: 'input', + name: 'redisPort', + message: '请输入Redis端口:', + default: 6379, + prefix: '*', + }, { type: 'list', name: 'dialect', @@ -164,7 +178,7 @@ const createServerSync = (answers: ProjectInfo) => { const serverTo = utils.getDistPath(`${name}/${serverFramework}`); const config = { DATABASE_HOST: answers.host ?? 'localhost', - DATABASE_PORT: 3306, + DATABASE_PORT: Number(answers.port ?? 3306), DATABASE_USERNAME: answers.username ?? 'root', DATABASE_PASSWORD: answers.password ?? 'root', DATABASE_NAME: answers.database, @@ -172,8 +186,8 @@ const createServerSync = (answers: ProjectInfo) => { DATABASE_AUTOLOADENTITIES: true, AUTH_SECRET: 'secret', REDIS_SECONDS: 7200, - REDIS_HOST: 'localhost', - REDIS_PORT: 6379, + REDIS_HOST: answers.redisHost ?? 'localhost', + REDIS_PORT: Number(answers.redisPort ?? 6379), EXPIRES_IN: '2h', PAGINATION_PAGE: 1, PAGINATION_LIMIT: 10, @@ -428,6 +442,7 @@ export default async () => { projectInfo = await getProjectInfo(); createProjectSync(projectInfo); } catch (e) { + console.log(e); log.error('项目模板创建失败'); return; } diff --git a/packages/toolkits/pro/src/lib/interfaces.ts b/packages/toolkits/pro/src/lib/interfaces.ts index 8a4f9e6d..f2892f4f 100644 --- a/packages/toolkits/pro/src/lib/interfaces.ts +++ b/packages/toolkits/pro/src/lib/interfaces.ts @@ -102,6 +102,8 @@ export interface ProjectInfo { database?: string; username?: string; password?: string; + redisHost?: string; + redisPort?: number; buildTool: BuildTool; vueVersion: VueVersion; } From ba0868e7966d68e24a5db5731415b7e128b287c5 Mon Sep 17 00:00:00 2001 From: fmm <1442620801@qq.com> Date: Wed, 18 Sep 2024 10:21:01 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20cli=E5=8E=BB=E9=99=A4console?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/toolkits/pro/src/lib/init.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/toolkits/pro/src/lib/init.ts b/packages/toolkits/pro/src/lib/init.ts index b1e2f78b..dafb1041 100644 --- a/packages/toolkits/pro/src/lib/init.ts +++ b/packages/toolkits/pro/src/lib/init.ts @@ -442,7 +442,6 @@ export default async () => { projectInfo = await getProjectInfo(); createProjectSync(projectInfo); } catch (e) { - console.log(e); log.error('项目模板创建失败'); return; }