Skip to content

Commit 49782b1

Browse files
committed
分类必填
1 parent 661ed1a commit 49782b1

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

front/src/components/LinkDialog.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<ComboboxInput
5252
class="w-full border-none px-3 py-2 text-gray-900 dark:text-gray-100 bg-white dark:bg-gray-700 focus:outline-none"
5353
:displayValue="(category: unknown) => category as string"
54-
@change="handleCategoryInput" />
54+
@change="handleCategoryInput" required />
5555
<ComboboxButton class="absolute inset-y-0 right-0 flex items-center pr-2">
5656
<div class="i-mdi-chevron-up-down h-5 w-5 text-gray-400 dark:text-gray-300"
5757
aria-hidden="true" />

main.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,14 @@ func addLinkHandler(w http.ResponseWriter, r *http.Request) {
469469
http.Error(w, "Bad Request", http.StatusBadRequest)
470470
return
471471
}
472+
if len(newLink.Url) == 0 {
473+
http.Error(w, "Url required", http.StatusBadRequest)
474+
return
475+
}
476+
if len(newLink.Category) == 0 {
477+
http.Error(w, "Category required", http.StatusBadRequest)
478+
return
479+
}
472480
nav, err := loadNavigation()
473481
if err != nil {
474482
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
@@ -495,6 +503,14 @@ func updateLinkHandler(w http.ResponseWriter, r *http.Request) {
495503
http.Error(w, "Bad Request", http.StatusBadRequest)
496504
return
497505
}
506+
if len(updatedLink.Url) == 0 {
507+
http.Error(w, "Url required", http.StatusBadRequest)
508+
return
509+
}
510+
if len(updatedLink.Category) == 0 {
511+
http.Error(w, "Category required", http.StatusBadRequest)
512+
return
513+
}
498514
var index int
499515
fmt.Sscanf(r.URL.Path, "/navigation/update/%d", &index)
500516
nav, err := loadNavigation()

0 commit comments

Comments
 (0)