新增下载页面

This commit is contained in:
zyj
2025-10-21 18:30:40 +08:00
parent 2bb0c7dc98
commit 60f4995dc7
12 changed files with 953 additions and 204 deletions

52
app.go Normal file
View File

@@ -0,0 +1,52 @@
package main
import (
"go-site-clone/services"
"github.com/go-rod/rod/lib/proto"
"github.com/wailsapp/wails/v3/pkg/application"
)
type App struct {
app *application.App
}
var siteService services.SiteService
func (a *App) GetResources(rawURL string) *services.ResourcesList {
RequestParamsAll, RouterAll := siteService.GetAllResources(rawURL)
// 再次去重 根据url链接去除重复项
dataList := siteService.DeduplicationRequestByUrl(RequestParamsAll)
resources := &services.ResourcesList{
Dom: RouterAll,
}
// 将页面及资源一起返回
for _, v := range dataList {
if v.Type == proto.NetworkResourceTypeImage {
resources.Image = append(resources.Image, v.URL)
}
if v.Type == proto.NetworkResourceTypeStylesheet {
resources.CSS = append(resources.CSS, v.URL)
}
if v.Type == proto.NetworkResourceTypeScript {
resources.Script = append(resources.Script, v.URL)
}
}
return resources
}
func (a *App) DownloadSite() {
// 将页面及资源一起返回
// for _, v := range dataList {
// u, _ := url.Parse(v.URL)
// if v.Type == proto.NetworkResourceTypeImage && u.Hostname() == parsed.Hostname() {
// var File utils.File
// File.Download(v.URL)
// }
// }
// for _, v := range RouterAll {
// var File utils.File
// File.HTMLDownload(v)
// }
}