main.go 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. package main
  2. import (
  3. "container/list"
  4. "embed"
  5. be "spider_creator/backend"
  6. bdb "spider_creator/backend/db"
  7. "spider_creator/backend/script"
  8. bvm "spider_creator/backend/vm"
  9. bws "spider_creator/backend/webservice"
  10. "github.com/wailsapp/wails/v2"
  11. "github.com/wailsapp/wails/v2/pkg/options"
  12. "github.com/wailsapp/wails/v2/pkg/options/assetserver"
  13. qu "jygit.jydev.jianyu360.cn/data_processing/common_utils"
  14. )
  15. var (
  16. //go:embed all:frontend/dist
  17. assets embed.FS
  18. app *App
  19. db *bdb.SpiderDb
  20. exitCh chan bool
  21. baseDir, attachesDir string = ".", ""
  22. currentSpiderConfig *be.SpiderConfig = new(be.SpiderConfig)
  23. currentResults = list.New() //b.ResultItems = make(b.ResultItems, 0)
  24. vm *bvm.VM
  25. glvm *script.GLVm
  26. ws *bws.WebService
  27. //重点网站和正式环境
  28. isOnly4MainSite string = "false"
  29. browserDisableLoadResources = ""
  30. serverAddress = "http://visualizeld.spdata.jianyu360.com/%s" //正式环境
  31. //serverAddress = "http://127.0.0.1:8091/%s" //正式环境
  32. )
  33. //build
  34. // wails build -ldflags="-X 'main.isOnly4MainSite=false'" -o="剑鱼可视化爬虫开发工具_正式.exe"
  35. func init() {
  36. be.LoadConfig("./config.yaml")
  37. //从配置文件外,编译时设定浏览器排除加载资源。比配置文件优先级低
  38. if be.Cfg.DisableLoadResource == "" && browserDisableLoadResources != "" {
  39. be.Cfg.DisableLoadResource = browserDisableLoadResources
  40. }
  41. be.Cfg.IsOnly4MainSite = isOnly4MainSite == "true"
  42. if be.Cfg.IsOnly4MainSite {
  43. serverAddress = "http://visualize.spdata.jianyu360.com/%s" //重点网站
  44. }
  45. qu.Debug("重点网站:", be.Cfg.IsOnly4MainSite, serverAddress)
  46. }
  47. func main() {
  48. go updateData() //数据保存
  49. // Create an instance of the app structure
  50. app = NewApp()
  51. // Create application with options
  52. err := wails.Run(&options.App{
  53. Title: "剑鱼-爬虫开发平台 v1.0",
  54. Width: 1224,
  55. Height: 668,
  56. AssetServer: &assetserver.Options{
  57. Assets: assets,
  58. },
  59. BackgroundColour: &options.RGBA{R: 255, G: 255, B: 255, A: 1},
  60. OnStartup: app.startup,
  61. OnShutdown: app.destory,
  62. Bind: []interface{}{
  63. app,
  64. },
  65. })
  66. if err != nil {
  67. println("Error:", err.Error())
  68. }
  69. }