fix: improve error handling and enhance setting management

- Updated error handling in GetSetting to use errors.Is for better clarity when checking for no documents.
- Refactored setting retrieval in the Vuex store to ensure a default value is set if the retrieved setting is empty.
- Adjusted API calls in the store to wrap payloads in a data object for consistency.
- Cleaned up SystemDetail.vue by removing unnecessary navigation actions for a more streamlined UI.
- Enhanced conditional rendering in SystemDetailTabDependency to ensure form value checks are safe.
- Replaced el-input with cl-edit-input in SystemDetailTabCustomize for improved input handling and added change event for saving.
This commit is contained in:
Marvin Zhang
2025-04-17 14:50:59 +08:00
parent e0649dc91f
commit 336ca5770b
5 changed files with 13 additions and 14 deletions

View File

@@ -1,6 +1,7 @@
package controllers
import (
"errors"
"github.com/crawlab-team/crawlab/core/models/models"
"github.com/crawlab-team/crawlab/core/models/service"
"github.com/gin-gonic/gin"
@@ -16,7 +17,7 @@ func GetSetting(_ *gin.Context, params *GetSettingParams) (response *Response[mo
// setting
s, err := service.NewModelService[models.Setting]().GetOne(bson.M{"key": params.Key}, nil)
if err != nil {
if err == mongo.ErrNoDocuments {
if errors.Is(err, mongo.ErrNoDocuments) {
return GetDataResponse(models.Setting{})
}
return GetErrorResponse[models.Setting](err)