Skip to content

Commit a77e515

Browse files
Suyunmengj2rong4cn
andauthored
fix(ocr): repair verification code OCR recognition service (OpenListTeam#602)
* fix(ocr):Repair verification code OCR recognition service * 修复对 非新用户 无效的问题 * chore: SettingItem.PreDefault重命名为MigrationValue --------- Co-authored-by: j2rong4cn <j2rong@qq.com>
1 parent 4af16ab commit a77e515

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

internal/bootstrap/data/setting.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ func initSettings() {
4040
for i := range initialSettingItems {
4141
item := &initialSettingItems[i]
4242
item.Index = uint(i)
43-
if item.PreDefault == "" {
44-
item.PreDefault = item.Value
43+
if len(item.MigrationValue) == 0 {
44+
item.MigrationValue = item.Value
4545
}
4646
// err
4747
stored, ok := settingMap[item.Key]
@@ -52,7 +52,7 @@ func initSettings() {
5252
continue
5353
}
5454
}
55-
if stored != nil && item.Key != conf.VERSION && stored.Value != item.PreDefault {
55+
if stored != nil && item.Key != conf.VERSION && stored.Value != item.MigrationValue {
5656
item.Value = stored.Value
5757
}
5858
_, err = op.HandleSettingItemHook(item)
@@ -147,15 +147,15 @@ func InitialSettings() []model.SettingItem {
147147
// global settings
148148
{Key: conf.HideFiles, Value: "/\\/README.md/i", Type: conf.TypeText, Group: model.GLOBAL},
149149
{Key: "package_download", Value: "true", Type: conf.TypeBool, Group: model.GLOBAL},
150-
{Key: conf.CustomizeHead, PreDefault: `<script src="https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?features=String.prototype.replaceAll"></script>`, Type: conf.TypeText, Group: model.GLOBAL, Flag: model.PRIVATE},
150+
{Key: conf.CustomizeHead, MigrationValue: `<script src="https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?features=String.prototype.replaceAll"></script>`, Type: conf.TypeText, Group: model.GLOBAL, Flag: model.PRIVATE},
151151
{Key: conf.CustomizeBody, Type: conf.TypeText, Group: model.GLOBAL, Flag: model.PRIVATE},
152152
{Key: conf.LinkExpiration, Value: "0", Type: conf.TypeNumber, Group: model.GLOBAL, Flag: model.PRIVATE},
153153
{Key: conf.SignAll, Value: "true", Type: conf.TypeBool, Group: model.GLOBAL, Flag: model.PRIVATE},
154154
{Key: conf.PrivacyRegs, Value: `(?:(?:\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])
155155
([[:xdigit:]]{1,4}(?::[[:xdigit:]]{1,4}){7}|::|:(?::[[:xdigit:]]{1,4}){1,6}|[[:xdigit:]]{1,4}:(?::[[:xdigit:]]{1,4}){1,5}|(?:[[:xdigit:]]{1,4}:){2}(?::[[:xdigit:]]{1,4}){1,4}|(?:[[:xdigit:]]{1,4}:){3}(?::[[:xdigit:]]{1,4}){1,3}|(?:[[:xdigit:]]{1,4}:){4}(?::[[:xdigit:]]{1,4}){1,2}|(?:[[:xdigit:]]{1,4}:){5}:[[:xdigit:]]{1,4}|(?:[[:xdigit:]]{1,4}:){1,6}:)
156156
(?U)access_token=(.*)&`,
157157
Type: conf.TypeText, Group: model.GLOBAL, Flag: model.PRIVATE},
158-
{Key: conf.OcrApi, Value: "https://api.example.com/ocr/file/json", Type: conf.TypeString, Group: model.GLOBAL}, // TODO: This can be replace by a community-hosted endpoint, see https://github.com/OpenListTeam/ocr_api_server
158+
{Key: conf.OcrApi, Value: "https://openlistteam-ocr-api-server.hf.space/ocr/file/json", MigrationValue: "https://api.example.com/ocr/file/json", Type: conf.TypeString, Group: model.GLOBAL}, // TODO: This can be replace by a community-hosted endpoint, see https://github.com/OpenListTeam/ocr_api_server
159159
{Key: conf.FilenameCharMapping, Value: `{"/": "|"}`, Type: conf.TypeText, Group: model.GLOBAL},
160160
{Key: conf.ForwardDirectLinkParams, Value: "false", Type: conf.TypeBool, Group: model.GLOBAL},
161161
{Key: conf.IgnoreDirectLinkParams, Value: "sign,openlist_ts", Type: conf.TypeString, Group: model.GLOBAL},

internal/model/setting.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ const (
2323
)
2424

2525
type SettingItem struct {
26-
Key string `json:"key" gorm:"primaryKey" binding:"required"` // unique key
27-
Value string `json:"value"` // value
28-
PreDefault string `json:"-" gorm:"-:all"` // deprecated value
29-
Help string `json:"help"` // help message
30-
Type string `json:"type"` // string, number, bool, select
31-
Options string `json:"options"` // values for select
32-
Group int `json:"group"` // use to group setting in frontend
33-
Flag int `json:"flag"` // 0 = public, 1 = private, 2 = readonly, 3 = deprecated, etc.
34-
Index uint `json:"index"`
26+
Key string `json:"key" gorm:"primaryKey" binding:"required"` // unique key
27+
Value string `json:"value"` // value
28+
MigrationValue string `json:"-" gorm:"-:all"` // deprecated value
29+
Help string `json:"help"` // help message
30+
Type string `json:"type"` // string, number, bool, select
31+
Options string `json:"options"` // values for select
32+
Group int `json:"group"` // use to group setting in frontend
33+
Flag int `json:"flag"` // 0 = public, 1 = private, 2 = readonly, 3 = deprecated, etc.
34+
Index uint `json:"index"`
3535
}
3636

3737
func (s SettingItem) IsDeprecated() bool {

0 commit comments

Comments
 (0)