@@ -21,7 +21,7 @@ const (
2121 configDefaultUserKey = "userConfig.defaultUser"
2222 configUsersKey = "userConfig.users"
2323 configExportPathKey = "exportPath"
24- appVersion = "v1.0.4 "
24+ appVersion = "v1.0.5 "
2525)
2626
2727type FileLoader struct {
@@ -59,8 +59,8 @@ type App struct {
5959 defaultUser string
6060 users []string
6161 firstStart bool
62-
63- FLoader * FileLoader
62+ firstInit bool
63+ FLoader * FileLoader
6464}
6565
6666type WeChatInfo struct {
@@ -91,6 +91,7 @@ type ErrorMessage struct {
9191func NewApp () * App {
9292 a := & App {}
9393
94+ a .firstInit = true
9495 a .FLoader = NewFileLoader (".\\ " )
9596 viper .SetConfigName (defaultConfig )
9697 viper .SetConfigType ("json" )
@@ -103,14 +104,8 @@ func NewApp() *App {
103104 log .Println ("SetFilePrefix" , prefix )
104105 a .FLoader .SetFilePrefix (prefix )
105106 }
106-
107- a .scanAccountByPath (prefix )
108- // log.Println(a.defaultUser)
109- // log.Println(a.users)
110107 } else {
111- if a .scanAccountByPath (".\\ " ) != nil {
112- log .Println ("not config exist" )
113- }
108+ log .Println ("not config exist" )
114109 }
115110 log .Printf ("default: %s users: %v\n " , a .defaultUser , a .users )
116111 if len (a .users ) == 0 {
@@ -257,6 +252,13 @@ func (a *App) createWechatDataProvider(resPath string, prefix string) error {
257252}
258253
259254func (a * App ) WeChatInit () {
255+
256+ if a .firstInit {
257+ a .firstInit = false
258+ a .scanAccountByPath (a .FLoader .FilePrefix )
259+ log .Println ("scanAccountByPath:" , a .FLoader .FilePrefix )
260+ }
261+
260262 if len (a .defaultUser ) == 0 {
261263 log .Println ("not defaultUser" )
262264 return
0 commit comments