feat: 分组名称支持更多格式
This commit is contained in:
@@ -83,8 +83,8 @@ func isValidGroupName(name string) bool {
|
|||||||
if name == "" {
|
if name == "" {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// 允许使用小写字母、数字和下划线,长度在 3 到 30 个字符之间
|
// 允许使用小写字母、数字、下划线和中划线,长度在 3 到 30 个字符之间
|
||||||
match, _ := regexp.MatchString("^[a-z0-9_]{3,30}$", name)
|
match, _ := regexp.MatchString("^[a-z0-9_-]{3,30}$", name)
|
||||||
return match
|
return match
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,7 +151,7 @@ func (s *Server) CreateGroup(c *gin.Context) {
|
|||||||
// Data Cleaning and Validation
|
// Data Cleaning and Validation
|
||||||
name := strings.TrimSpace(req.Name)
|
name := strings.TrimSpace(req.Name)
|
||||||
if !isValidGroupName(name) {
|
if !isValidGroupName(name) {
|
||||||
response.Error(c, app_errors.NewAPIError(app_errors.ErrValidation, "Invalid group name format. Use 3-30 lowercase letters, numbers, and underscores."))
|
response.Error(c, app_errors.NewAPIError(app_errors.ErrValidation, "无效的分组名称。只能包含小写字母、数字、中划线或下划线,长度3-30位"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,7 +265,7 @@ func (s *Server) UpdateGroup(c *gin.Context) {
|
|||||||
if req.Name != nil {
|
if req.Name != nil {
|
||||||
cleanedName := strings.TrimSpace(*req.Name)
|
cleanedName := strings.TrimSpace(*req.Name)
|
||||||
if !isValidGroupName(cleanedName) {
|
if !isValidGroupName(cleanedName) {
|
||||||
response.Error(c, app_errors.NewAPIError(app_errors.ErrValidation, "Invalid group name format. Name is required and must be 3-30 lowercase letters, numbers, or underscores."))
|
response.Error(c, app_errors.NewAPIError(app_errors.ErrValidation, "无效的分组名称格式。只能包含小写字母、数字、中划线或下划线,长度3-30位"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
group.Name = cleanedName
|
group.Name = cleanedName
|
||||||
|
@@ -92,8 +92,8 @@ const rules: FormRules = {
|
|||||||
trigger: ["blur", "input"],
|
trigger: ["blur", "input"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pattern: /^[a-z]+$/,
|
pattern: /^[a-z0-9_-]{3,30}$/,
|
||||||
message: "只能输入小写字母",
|
message: "只能包含小写字母、数字、中划线或下划线,长度3-30位",
|
||||||
trigger: ["blur", "input"],
|
trigger: ["blur", "input"],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -330,7 +330,10 @@ async function handleSubmit() {
|
|||||||
<h4 class="section-title">基础信息</h4>
|
<h4 class="section-title">基础信息</h4>
|
||||||
|
|
||||||
<n-form-item label="分组名称" path="name">
|
<n-form-item label="分组名称" path="name">
|
||||||
<n-input v-model:value="formData.name" placeholder="请输入分组名称,如:gemini" />
|
<n-input
|
||||||
|
v-model:value="formData.name"
|
||||||
|
placeholder="作为路由的一部分,如:gemini-pro-group"
|
||||||
|
/>
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
|
|
||||||
<n-form-item label="显示名称" path="display_name">
|
<n-form-item label="显示名称" path="display_name">
|
||||||
|
Reference in New Issue
Block a user