🎨 加入只读模式配置

This commit is contained in:
Liang Ding 2022-08-09 09:56:45 +08:00
parent 877e96df4d
commit 68fee17793
No known key found for this signature in database
GPG Key ID: 136F30F901A2231D
2 changed files with 9 additions and 4 deletions

View File

@ -84,8 +84,8 @@ var Docker bool
const DockerImageGo = "golang" const DockerImageGo = "golang"
// Load loads the Wide configurations from wide.json and users' configurations from users/{userId}.json. // Load loads the Wide configurations from wide.json and users' configurations from users/{userId}.json.
func Load(confPath, confData, confServer, confLogLevel string, confSiteStatCode template.HTML) { func Load(confPath, confData, confServer, confLogLevel, confReadOnly string, confSiteStatCode template.HTML) {
initWide(confPath, confData, confServer, confLogLevel, confSiteStatCode) initWide(confPath, confData, confServer, confLogLevel, confReadOnly, confSiteStatCode)
initUsers() initUsers()
cmd := exec.Command("docker", "version") cmd := exec.Command("docker", "version")
@ -155,7 +155,7 @@ func initUsers() {
initCustomizedConfs() initCustomizedConfs()
} }
func initWide(confPath, confData, confServer, confLogLevel string, confSiteStatCode template.HTML) { func initWide(confPath, confData, confServer, confLogLevel, confReadOnly string, confSiteStatCode template.HTML) {
bytes, err := ioutil.ReadFile(confPath) bytes, err := ioutil.ReadFile(confPath)
if nil != err { if nil != err {
logger.Error(err) logger.Error(err)
@ -219,6 +219,10 @@ func initWide(confPath, confData, confServer, confLogLevel string, confSiteStatC
Wide.Server = confServer Wide.Server = confServer
} }
if "" != confReadOnly {
Wide.ReadOnly, _ = strconv.ParseBool(confReadOnly)
}
// SiteStatCode // SiteStatCode
if "" != confSiteStatCode { if "" != confSiteStatCode {
Wide.SiteStatCode = confSiteStatCode Wide.SiteStatCode = confSiteStatCode

View File

@ -50,6 +50,7 @@ func init() {
confData := flag.String("data", "", "path of data dir") confData := flag.String("data", "", "path of data dir")
confServer := flag.String("server", "", "this will overwrite Wide.Server if specified") confServer := flag.String("server", "", "this will overwrite Wide.Server if specified")
confLogLevel := flag.String("log_level", "", "this will overwrite Wide.LogLevel if specified") confLogLevel := flag.String("log_level", "", "this will overwrite Wide.LogLevel if specified")
confReadOnly := flag.String("readonly", "", "this will overrite Wide.ReadOnly if specified")
confSiteStatCode := flag.String("site_stat_code", "", "this will overrite Wide.SiteStatCode if specified") confSiteStatCode := flag.String("site_stat_code", "", "this will overrite Wide.SiteStatCode if specified")
flag.Parse() flag.Parse()
@ -66,7 +67,7 @@ func init() {
i18n.Load() i18n.Load()
event.Load() event.Load()
conf.Load(*confPath, *confData, *confServer, *confLogLevel, template.HTML(*confSiteStatCode)) conf.Load(*confPath, *confData, *confServer, *confLogLevel, *confReadOnly, template.HTML(*confSiteStatCode))
conf.FixedTimeCheckEnv() conf.FixedTimeCheckEnv()
session.FixedTimeSave() session.FixedTimeSave()