Skip to content

Commit ae69847

Browse files
SukkaWxhofe
andauthored
fix: remove default polyfill (#6130 close #6100)
* refactor(setting): replace `polyfill.io`` * fix: remove default polyfill --------- Co-authored-by: Andy Hsu <[email protected]>
1 parent d0f88bd commit ae69847

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

internal/bootstrap/data/setting.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ func initSettings() {
2121
if err != nil {
2222
utils.Log.Fatalf("failed get settings: %+v", err)
2323
}
24-
2524
for i := range settings {
2625
if !isActive(settings[i].Key) && settings[i].Flag != model.DEPRECATED {
2726
settings[i].Flag = model.DEPRECATED
@@ -42,7 +41,7 @@ func initSettings() {
4241
continue
4342
}
4443
// save
45-
if stored != nil && item.Key != conf.VERSION {
44+
if stored != nil && item.Key != conf.VERSION && stored.Value != item.DeprecatedValue {
4645
item.Value = stored.Value
4746
}
4847
if stored == nil || *item != *stored {
@@ -129,7 +128,7 @@ func InitialSettings() []model.SettingItem {
129128
// global settings
130129
{Key: conf.HideFiles, Value: "/\\/README.md/i", Type: conf.TypeText, Group: model.GLOBAL},
131130
{Key: "package_download", Value: "true", Type: conf.TypeBool, Group: model.GLOBAL},
132-
{Key: conf.CustomizeHead, Value: `<script src="https://polyfill.io/v3/polyfill.min.js?features=String.prototype.replaceAll"></script>`, Type: conf.TypeText, Group: model.GLOBAL, Flag: model.PRIVATE},
131+
{Key: conf.CustomizeHead, DeprecatedValue: `<script src="https://polyfill.io/v3/polyfill.min.js?features=String.prototype.replaceAll"></script>`, Type: conf.TypeText, Group: model.GLOBAL, Flag: model.PRIVATE},
133132
{Key: conf.CustomizeBody, Type: conf.TypeText, Group: model.GLOBAL, Flag: model.PRIVATE},
134133
{Key: conf.LinkExpiration, Value: "0", Type: conf.TypeNumber, Group: model.GLOBAL, Flag: model.PRIVATE},
135134
{Key: conf.SignAll, Value: "true", Type: conf.TypeBool, Group: model.GLOBAL, Flag: model.PRIVATE},

internal/model/setting.go

+8-7
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@ const (
2121
)
2222

2323
type SettingItem struct {
24-
Key string `json:"key" gorm:"primaryKey" binding:"required"` // unique key
25-
Value string `json:"value"` // value
26-
Help string `json:"help"` // help message
27-
Type string `json:"type"` // string, number, bool, select
28-
Options string `json:"options"` // values for select
29-
Group int `json:"group"` // use to group setting in frontend
30-
Flag int `json:"flag"` // 0 = public, 1 = private, 2 = readonly, 3 = deprecated, etc.
24+
Key string `json:"key" gorm:"primaryKey" binding:"required"` // unique key
25+
Value string `json:"value"` // value
26+
DeprecatedValue string `json:"deprecated_value" gorm:"-:all"` // deprecated value
27+
Help string `json:"help"` // help message
28+
Type string `json:"type"` // string, number, bool, select
29+
Options string `json:"options"` // values for select
30+
Group int `json:"group"` // use to group setting in frontend
31+
Flag int `json:"flag"` // 0 = public, 1 = private, 2 = readonly, 3 = deprecated, etc.
3132
}
3233

3334
func (s SettingItem) IsDeprecated() bool {

0 commit comments

Comments
 (0)