@@ -23,7 +23,7 @@ const (
2323 configDefaultUserKey = "userConfig.defaultUser"
2424 configUsersKey = "userConfig.users"
2525 configExportPathKey = "exportPath"
26- appVersion = "v1.1 .0"
26+ appVersion = "v1.2 .0"
2727)
2828
2929type FileLoader struct {
@@ -183,14 +183,15 @@ func (a *App) startup(ctx context.Context) {
183183}
184184
185185func (a * App ) beforeClose (ctx context.Context ) (prevent bool ) {
186+ return false
187+ }
186188
189+ func (a * App ) shutdown (ctx context.Context ) {
187190 if a .provider != nil {
188191 a .provider .WechatWechatDataProviderClose ()
189192 a .provider = nil
190193 }
191-
192- return false
193-
194+ log .Printf ("App Version %s exit!" , appVersion )
194195}
195196
196197func (a * App ) GetWeChatAllInfo () string {
@@ -713,3 +714,159 @@ func (a *App) SaveFileDialog(file string, alisa string) string {
713714
714715 return ""
715716}
717+
718+ func (a * App ) GetSessionLastTime (userName string ) string {
719+ if a .provider == nil || userName == "" {
720+ lastTime := & wechat.WeChatLastTime {}
721+ lastTimeString , _ := json .Marshal (lastTime )
722+ return string (lastTimeString )
723+ }
724+
725+ lastTime := a .provider .WeChatGetSessionLastTime (userName )
726+
727+ lastTimeString , _ := json .Marshal (lastTime )
728+
729+ return string (lastTimeString )
730+ }
731+
732+ func (a * App ) SetSessionLastTime (userName string , stamp int64 , messageId string ) string {
733+ if a .provider == nil {
734+ return ""
735+ }
736+
737+ lastTime := & wechat.WeChatLastTime {
738+ UserName : userName ,
739+ Timestamp : stamp ,
740+ MessageId : messageId ,
741+ }
742+ err := a .provider .WeChatSetSessionLastTime (lastTime )
743+ if err != nil {
744+ log .Println ("WeChatSetSessionLastTime failed:" , err .Error ())
745+ return err .Error ()
746+ }
747+
748+ return ""
749+ }
750+
751+ func (a * App ) SetSessionBookMask (userName , tag , info string ) string {
752+ if a .provider == nil || userName == "" {
753+ return "invaild params"
754+ }
755+ err := a .provider .WeChatSetSessionBookMask (userName , tag , info )
756+ if err != nil {
757+ log .Println ("WeChatSetSessionBookMask failed:" , err .Error ())
758+ return err .Error ()
759+ }
760+
761+ return ""
762+ }
763+
764+ func (a * App ) DelSessionBookMask (markId string ) string {
765+ if a .provider == nil || markId == "" {
766+ return "invaild params"
767+ }
768+
769+ err := a .provider .WeChatDelSessionBookMask (markId )
770+ if err != nil {
771+ log .Println ("WeChatDelSessionBookMask failed:" , err .Error ())
772+ return err .Error ()
773+ }
774+
775+ return ""
776+ }
777+
778+ func (a * App ) GetSessionBookMaskList (userName string ) string {
779+ if a .provider == nil || userName == "" {
780+ return "invaild params"
781+ }
782+ markLIst , err := a .provider .WeChatGetSessionBookMaskList (userName )
783+ if err != nil {
784+ log .Println ("WeChatGetSessionBookMaskList failed:" , err .Error ())
785+ _list := & wechat.WeChatBookMarkList {}
786+ _listString , _ := json .Marshal (_list )
787+ return string (_listString )
788+ }
789+
790+ markLIstString , _ := json .Marshal (markLIst )
791+ return string (markLIstString )
792+ }
793+
794+ func (a * App ) SelectedDirDialog (title string ) string {
795+ dialogOptions := runtime.OpenDialogOptions {
796+ Title : title ,
797+ }
798+ selectedDir , err := runtime .OpenDirectoryDialog (a .ctx , dialogOptions )
799+ if err != nil {
800+ log .Println ("OpenDirectoryDialog:" , err )
801+ return ""
802+ }
803+
804+ if selectedDir == "" {
805+ return ""
806+ }
807+
808+ return selectedDir
809+ }
810+
811+ func (a * App ) ExportWeChatDataByUserName (userName , path string ) string {
812+ if a .provider == nil || userName == "" || path == "" {
813+ return "invaild params" + userName
814+ }
815+
816+ if ! utils .PathIsCanWriteFile (path ) {
817+ log .Println ("PathIsCanWriteFile: " + path )
818+ return "PathIsCanWriteFile: " + path
819+ }
820+
821+ exPath := path + "\\ " + "wechatDataBackup_" + userName
822+ if _ , err := os .Stat (exPath ); err != nil {
823+ os .MkdirAll (exPath , os .ModePerm )
824+ } else {
825+ return "path exist:" + exPath
826+ }
827+
828+ log .Println ("ExportWeChatDataByUserName:" , userName , exPath )
829+ err := a .provider .WeChatExportDataByUserName (userName , exPath )
830+ if err != nil {
831+ log .Println ("WeChatExportDataByUserName failed:" , err )
832+ return "WeChatExportDataByUserName failed:" + err .Error ()
833+ }
834+
835+ exeSrcPath := a .FLoader .FilePrefix + "\\ " + "wechatDataBackup.exe"
836+ exeDstPath := exPath + "\\ " + "wechatDataBackup.exe"
837+ _ , err = utils .CopyFile (exeSrcPath , exeDstPath )
838+ if err != nil {
839+ log .Println ("CopyFile:" , err )
840+ return "CopyFile:" + err .Error ()
841+ }
842+
843+ config := map [string ]interface {}{
844+ "exportpath" : ".\\ " ,
845+ "userconfig" : map [string ]interface {}{
846+ "defaultuser" : a .defaultUser ,
847+ "users" : []string {a .defaultUser },
848+ },
849+ }
850+
851+ configJson , err := json .MarshalIndent (config , "" , " " )
852+ if err != nil {
853+ log .Println ("MarshalIndent:" , err )
854+ return "MarshalIndent:" + err .Error ()
855+ }
856+
857+ configPath := exPath + "\\ " + "config.json"
858+ err = os .WriteFile (configPath , configJson , os .ModePerm )
859+ if err != nil {
860+ log .Println ("WriteFile:" , err )
861+ return "WriteFile:" + err .Error ()
862+ }
863+
864+ return ""
865+ }
866+
867+ func (a * App ) GetAppIsShareData () bool {
868+ if a .provider != nil {
869+ return a .provider .IsShareData
870+ }
871+ return false
872+ }
0 commit comments