main.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package main
  2. import (
  3. "container/list"
  4. "embed"
  5. "github.com/wailsapp/wails/v2"
  6. "github.com/wailsapp/wails/v2/pkg/options"
  7. "github.com/wailsapp/wails/v2/pkg/options/assetserver"
  8. qu "jygit.jydev.jianyu360.cn/data_processing/common_utils"
  9. be "spider_creator/backend"
  10. bdb "spider_creator/backend/db"
  11. "spider_creator/backend/script"
  12. bvm "spider_creator/backend/vm"
  13. bws "spider_creator/backend/webservice"
  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. isOnly4MainSite = "false"
  28. serverAddress = "http://visualizeld.spdata.jianyu360.com/%s" //正式环境
  29. //serverAddress = "http://127.0.0.1:8091/%s" //正式环境
  30. )
  31. //build
  32. // wails build -ldflags="-X 'main.isOnly4MainSite=false'" -o="剑鱼可视化爬虫开发工具_正式.exe"
  33. func init() {
  34. be.LoadConfig("backend/config.yaml")
  35. be.Cfg.IsOnly4MainSite = isOnly4MainSite == "true"
  36. if be.Cfg.IsOnly4MainSite {
  37. serverAddress = "http://visualize.spdata.jianyu360.com/%s" //重点网站
  38. }
  39. qu.Debug("重点网站:", be.Cfg.IsOnly4MainSite, serverAddress)
  40. }
  41. func main() {
  42. go updateData() //数据保存
  43. // Create an instance of the app structure
  44. app = NewApp()
  45. // Create application with options
  46. err := wails.Run(&options.App{
  47. Title: "剑鱼-爬虫开发平台 v1.0",
  48. Width: 1224,
  49. Height: 668,
  50. AssetServer: &assetserver.Options{
  51. Assets: assets,
  52. },
  53. BackgroundColour: &options.RGBA{R: 255, G: 255, B: 255, A: 1},
  54. OnStartup: app.startup,
  55. OnShutdown: app.destory,
  56. Bind: []interface{}{
  57. app,
  58. },
  59. })
  60. if err != nil {
  61. println("Error:", err.Error())
  62. }
  63. }