未初始化设置时 recipients 为 null,前端严格解析判为无效,导致周报页显示“响应无效”。 后端统一返回空数组,前端同时兼容历史的 null。
This commit is contained in:
@@ -217,7 +217,7 @@ func normalize(input SettingsInput) (SettingsInput, error) {
|
||||
}
|
||||
|
||||
func (s *Store) ReadSettings(ctx context.Context) (Settings, error) {
|
||||
out := Settings{Port: 465, Weekday: 1, Hour: 9}
|
||||
out := Settings{Port: 465, Weekday: 1, Hour: 9, Recipients: []string{}}
|
||||
if !s.valid() {
|
||||
return out, ErrUnavailable
|
||||
}
|
||||
@@ -230,6 +230,9 @@ func (s *Store) ReadSettings(ctx context.Context) (Settings, error) {
|
||||
if err != nil {
|
||||
return Settings{}, ErrUnavailable
|
||||
}
|
||||
if out.Recipients == nil {
|
||||
out.Recipients = []string{}
|
||||
}
|
||||
out.HasPassword = len(sealed) > 0
|
||||
return out, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user