Add a new field version into preference.

This commit is contained in:
zicla
2018-01-01 15:57:39 +08:00
parent 68c7da1f58
commit f49f9137fe
4 changed files with 5 additions and 3 deletions

View File

@ -49,7 +49,7 @@ func InstallDatabase() {
preference := &Preference{} preference := &Preference{}
hasTable = db.HasTable(preference) hasTable = db.HasTable(preference)
if !hasTable { if !hasTable {
createPreference := "CREATE TABLE `tank10_preference` (`uuid` char(36) NOT NULL,`name` varchar(45) DEFAULT NULL COMMENT '网站名称',`logo_url` varchar(255) DEFAULT NULL,`favicon_url` varchar(255) DEFAULT NULL,`footer_line1` varchar(1024) DEFAULT NULL,`footer_line2` varchar(1024) DEFAULT NULL,`sort` bigint(20) DEFAULT NULL,`modify_time` timestamp NULL DEFAULT NULL,`create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',PRIMARY KEY (`uuid`),UNIQUE KEY `id_UNIQUE` (`uuid`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='网站偏好设置表';" createPreference := "CREATE TABLE `tank10_preference` (`uuid` char(36) NOT NULL,`name` varchar(45) DEFAULT NULL COMMENT '网站名称',`logo_url` varchar(255) DEFAULT NULL,`favicon_url` varchar(255) DEFAULT NULL,`footer_line1` varchar(1024) DEFAULT NULL,`footer_line2` varchar(1024) DEFAULT NULL,`version` varchar(45) DEFAULT NULL,`sort` bigint(20) DEFAULT NULL,`modify_time` timestamp NULL DEFAULT NULL,`create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',PRIMARY KEY (`uuid`),UNIQUE KEY `id_UNIQUE` (`uuid`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='网站偏好设置表';"
db = db.Exec(createPreference) db = db.Exec(createPreference)
if db.Error != nil { if db.Error != nil {
LogPanic(db.Error) LogPanic(db.Error)

View File

@ -20,6 +20,7 @@ func (this *PreferenceDao) Fetch() *Preference {
if db.Error.Error() == "record not found" { if db.Error.Error() == "record not found" {
preference.Name = "蓝眼云盘" preference.Name = "蓝眼云盘"
preference.Version = VERSION
this.Create(preference) this.Create(preference)
return preference return preference
} else { } else {

View File

@ -7,6 +7,7 @@ type Preference struct {
FaviconUrl string `json:"faviconUrl"` FaviconUrl string `json:"faviconUrl"`
FooterLine1 string `json:"footerLine1"` FooterLine1 string `json:"footerLine1"`
FooterLine2 string `json:"footerLine2"` FooterLine2 string `json:"footerLine2"`
Version string `json:"version"`
} }
// set File's table name to be `profiles` // set File's table name to be `profiles`

View File

@ -18,9 +18,9 @@ func HumanFileSize(bytes int64, si bool) string {
if bytes < thresh { if bytes < thresh {
return fmt.Sprintf("%dB", bytes) return fmt.Sprintf("%dB", bytes)
} }
var units = []string{"kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"} var units = []string{"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"}
if si { if si {
units = []string{"KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"} units = []string{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"}
} }
var u = 0 var u = 0
var tmp = float64(bytes) var tmp = float64(bytes)