diff --git a/internal/models/types.go b/internal/models/types.go index e8bc878..4abdcbe 100644 --- a/internal/models/types.go +++ b/internal/models/types.go @@ -66,7 +66,7 @@ type Group struct { // APIKey 对应 api_keys 表 type APIKey struct { ID uint `gorm:"primaryKey;autoIncrement" json:"id"` - KeyValue string `gorm:"type:varchar(512);not null;uniqueIndex:idx_group_key" json:"key_value"` + KeyValue string `gorm:"type:varchar(1024);not null;uniqueIndex:idx_group_key" json:"key_value"` GroupID uint `gorm:"not null;uniqueIndex:idx_group_key" json:"group_id"` Status string `gorm:"type:varchar(50);not null;default:'active'" json:"status"` RequestCount int64 `gorm:"not null;default:0" json:"request_count"` @@ -82,9 +82,9 @@ type RequestLog struct { Timestamp time.Time `gorm:"not null;index" json:"timestamp"` GroupID uint `gorm:"not null;index" json:"group_id"` GroupName string `gorm:"type:varchar(255);index" json:"group_name"` - KeyValue string `gorm:"type:varchar(512)" json:"key_value"` + KeyValue string `gorm:"type:varchar(1024)" json:"key_value"` IsSuccess bool `gorm:"not null" json:"is_success"` - SourceIP string `gorm:"type:varchar(45)" json:"source_ip"` + SourceIP string `gorm:"type:varchar(64)" json:"source_ip"` StatusCode int `gorm:"not null" json:"status_code"` RequestPath string `gorm:"type:varchar(500)" json:"request_path"` Duration int64 `gorm:"not null" json:"duration_ms"` diff --git a/web/src/components/keys/GroupList.vue b/web/src/components/keys/GroupList.vue index 2891341..18ef1c4 100644 --- a/web/src/components/keys/GroupList.vue +++ b/web/src/components/keys/GroupList.vue @@ -62,14 +62,12 @@ function openCreateGroupModal() { showGroupModal.value = true; } -function handleGroupCreated(_group: Group) { +function handleGroupCreated(group: Group) { showGroupModal.value = false; - emit("refresh"); -} - -function handleSwitchToGroup(groupId: number) { - // 创建成功后,通知父组件刷新并切换到新创建的分组 - emit("refresh-and-select", groupId); + if (group && group.id) { + // 创建成功后,通知父组件刷新并切换到新创建的分组 + emit("refresh-and-select", group.id); + } } @@ -132,7 +130,6 @@ function handleSwitchToGroup(groupId: number) {