1. 修复FileStorage\Image文件没有导出的问题

2. 增加图片定位到聊天位置的功能
3. 导出界面增加提示
This commit is contained in:
HAL
2025-04-16 00:00:48 +08:00
parent 26399847ee
commit 260c7306ad
21 changed files with 584 additions and 563 deletions
+36 -24
View File
@@ -310,6 +310,7 @@ func exportWeChatVideoAndFile(info WeChatInfo, expPath string, progress chan<- s
videoRootPath := info.FilePath + "\\FileStorage\\Video"
fileRootPath := info.FilePath + "\\FileStorage\\File"
cacheRootPath := info.FilePath + "\\FileStorage\\Cache"
rootPaths := []string{videoRootPath, fileRootPath, cacheRootPath}
handleNumber := int64(0)
@@ -326,6 +327,9 @@ func exportWeChatVideoAndFile(info WeChatInfo, expPath string, progress chan<- s
go func() {
for _, rootPath := range rootPaths {
log.Println(rootPath)
if _, err := os.Stat(rootPath); err != nil {
continue
}
err := filepath.Walk(rootPath, func(path string, finfo os.FileInfo, err error) error {
if err != nil {
log.Printf("filepath.Walk:%v\n", err)
@@ -399,43 +403,51 @@ func exportWeChatVideoAndFile(info WeChatInfo, expPath string, progress chan<- s
func exportWeChatBat(info WeChatInfo, expPath string, progress chan<- string) {
progress <- "{\"status\":\"processing\", \"result\":\"export WeChat Dat start\", \"progress\": 21}"
datRootPath := info.FilePath + "\\FileStorage\\MsgAttach"
fileInfo, err := os.Stat(datRootPath)
if err != nil || !fileInfo.IsDir() {
progress <- fmt.Sprintf("{\"status\":\"error\", \"result\":\"%s error\"}", datRootPath)
return
}
imageRootPath := info.FilePath + "\\FileStorage\\Image"
rootPaths := []string{datRootPath, imageRootPath}
handleNumber := int64(0)
fileNumber := getPathFileNumber(datRootPath, ".dat")
fileNumber := int64(0)
for i := range rootPaths {
fileNumber += getPathFileNumber(rootPaths[i], ".dat")
}
log.Println("DatFileNumber ", fileNumber)
var wg sync.WaitGroup
var reportWg sync.WaitGroup
quitChan := make(chan struct{})
taskChan := make(chan [2]string, 100)
go func() {
err = filepath.Walk(datRootPath, func(path string, finfo os.FileInfo, err error) error {
if err != nil {
log.Printf("filepath.Walk:%v\n", err)
return err
for i := range rootPaths {
if _, err := os.Stat(rootPaths[i]); err != nil {
continue
}
if !finfo.IsDir() && strings.HasSuffix(path, ".dat") {
expFile := expPath + path[len(info.FilePath):]
_, err := os.Stat(filepath.Dir(expFile))
err := filepath.Walk(rootPaths[i], func(path string, finfo os.FileInfo, err error) error {
if err != nil {
os.MkdirAll(filepath.Dir(expFile), 0644)
log.Printf("filepath.Walk:%v\n", err)
return err
}
if !finfo.IsDir() && strings.HasSuffix(path, ".dat") {
expFile := expPath + path[len(info.FilePath):]
_, err := os.Stat(filepath.Dir(expFile))
if err != nil {
os.MkdirAll(filepath.Dir(expFile), 0644)
}
task := [2]string{path, expFile}
taskChan <- task
return nil
}
task := [2]string{path, expFile}
taskChan <- task
return nil
})
if err != nil {
log.Println("filepath.Walk:", err)
progress <- fmt.Sprintf("{\"status\":\"error\", \"result\":\"%v\"}", err)
}
return nil
})
if err != nil {
log.Println("filepath.Walk:", err)
progress <- fmt.Sprintf("{\"status\":\"error\", \"result\":\"%v\"}", err)
}
close(taskChan)
}()
@@ -445,7 +457,7 @@ func exportWeChatBat(info WeChatInfo, expPath string, progress chan<- string) {
go func() {
defer wg.Done()
for task := range taskChan {
_, err = os.Stat(task[1])
_, err := os.Stat(task[1])
if err == nil {
atomic.AddInt64(&handleNumber, 1)
continue
+3
View File
@@ -182,6 +182,7 @@ type WeChatMessage struct {
}
type WeChatMessageList struct {
MsgType string `json:"MsgType"`
KeyWord string `json:"KeyWord"`
Total int `json:"Total"`
Rows []WeChatMessage `json:"Rows"`
@@ -692,6 +693,7 @@ func (P *WechatDataProvider) WeChatGetMessageListByKeyWord(userName string, time
List := &WeChatMessageList{}
List.Rows = make([]WeChatMessage, 0)
List.KeyWord = keyWord
List.MsgType = msgType
_time := time
selectPagesize := pageSize
if keyWord != "" || msgType != "" {
@@ -732,6 +734,7 @@ func (P *WechatDataProvider) WeChatGetMessageListByType(userName string, time in
List := &WeChatMessageList{}
List.Rows = make([]WeChatMessage, 0)
List.MsgType = msgType
selectTime := time
selectpageSize := 30
needSize := pageSize