main.go 2.2 KB

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