From 9ae08cdd9b112ee294da83c7644cd7eef10b39cc Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Fri, 24 Feb 2023 15:10:12 +0800 Subject: [PATCH] fix: the issue that the useSlugify hook may cause the value to be undefined (halo-dev/console#884) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /kind bug #### What this PR does / why we need it: 修复新建分类和标签之后再次打开表单,别名显示为 undefined 的问题。 #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/3382 #### Special notes for your reviewer: 测试方式: 1. 新建分类或者标签,创建完成之后再次打开创建表单,检查别名是否还为 undefined。 #### Does this PR introduce a user-facing change? ```release-note 修复 Console 端新建分类和标签之后再次打开表单,别名显示为 undefined 的问题。 ``` --- src/composables/use-slugify.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/composables/use-slugify.ts b/src/composables/use-slugify.ts index 1a47228de..fb727da1e 100644 --- a/src/composables/use-slugify.ts +++ b/src/composables/use-slugify.ts @@ -15,6 +15,9 @@ export default function useSlugify( ); const handleGenerateSlug = () => { + if (!source.value) { + return; + } target.value = slugify(source.value, { trim: true, });