main.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. qlmDir string = ""
  23. currentSpiderConfig *be.SpiderConfig = new(be.SpiderConfig)
  24. currentResults = list.New() //b.ResultItems = make(b.ResultItems, 0)
  25. vm *bvm.VM
  26. glvm *script.GLVm
  27. ws *bws.WebService
  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. if be.Cfg.IsOnly4MainSite {
  36. serverAddress = "http://visualize.spdata.jianyu360.com/%s" //重点网站
  37. }
  38. qu.Debug("重点网站:", be.Cfg.IsOnly4MainSite, serverAddress)
  39. }
  40. func main() {
  41. go updateData() //数据保存
  42. // Create an instance of the app structure
  43. app = NewApp()
  44. // Create application with options
  45. err := wails.Run(&options.App{
  46. Title: "剑鱼-爬虫开发平台 v1.0",
  47. Width: 1224,
  48. Height: 668,
  49. AssetServer: &assetserver.Options{
  50. Assets: assets,
  51. },
  52. BackgroundColour: &options.RGBA{R: 255, G: 255, B: 255, A: 1},
  53. OnStartup: app.startup,
  54. OnShutdown: app.destory,
  55. Bind: []interface{}{
  56. app,
  57. },
  58. })
  59. if err != nil {
  60. println("Error:", err.Error())
  61. }
  62. }