@@ -21,7 +21,7 @@ const (
21
21
configDefaultUserKey = "userConfig.defaultUser"
22
22
configUsersKey = "userConfig.users"
23
23
configExportPathKey = "exportPath"
24
- appVersion = "v1.0.4 "
24
+ appVersion = "v1.0.5 "
25
25
)
26
26
27
27
type FileLoader struct {
@@ -59,8 +59,8 @@ type App struct {
59
59
defaultUser string
60
60
users []string
61
61
firstStart bool
62
-
63
- FLoader * FileLoader
62
+ firstInit bool
63
+ FLoader * FileLoader
64
64
}
65
65
66
66
type WeChatInfo struct {
@@ -91,6 +91,7 @@ type ErrorMessage struct {
91
91
func NewApp () * App {
92
92
a := & App {}
93
93
94
+ a .firstInit = true
94
95
a .FLoader = NewFileLoader (".\\ " )
95
96
viper .SetConfigName (defaultConfig )
96
97
viper .SetConfigType ("json" )
@@ -103,14 +104,8 @@ func NewApp() *App {
103
104
log .Println ("SetFilePrefix" , prefix )
104
105
a .FLoader .SetFilePrefix (prefix )
105
106
}
106
-
107
- a .scanAccountByPath (prefix )
108
- // log.Println(a.defaultUser)
109
- // log.Println(a.users)
110
107
} else {
111
- if a .scanAccountByPath (".\\ " ) != nil {
112
- log .Println ("not config exist" )
113
- }
108
+ log .Println ("not config exist" )
114
109
}
115
110
log .Printf ("default: %s users: %v\n " , a .defaultUser , a .users )
116
111
if len (a .users ) == 0 {
@@ -257,6 +252,13 @@ func (a *App) createWechatDataProvider(resPath string, prefix string) error {
257
252
}
258
253
259
254
func (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
+
260
262
if len (a .defaultUser ) == 0 {
261
263
log .Println ("not defaultUser" )
262
264
return
0 commit comments