12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- package main
- import (
- "container/list"
- "embed"
- be "spider_creator/backend"
- bdb "spider_creator/backend/db"
- "spider_creator/backend/script"
- bvm "spider_creator/backend/vm"
- bws "spider_creator/backend/webservice"
- "github.com/wailsapp/wails/v2"
- "github.com/wailsapp/wails/v2/pkg/options"
- "github.com/wailsapp/wails/v2/pkg/options/assetserver"
- qu "jygit.jydev.jianyu360.cn/data_processing/common_utils"
- )
- var (
- //go:embed all:frontend/dist
- assets embed.FS
- app *App
- db *bdb.SpiderDb
- exitCh chan bool
- baseDir, attachesDir string = ".", ""
- currentSpiderConfig *be.SpiderConfig = new(be.SpiderConfig)
- currentResults = list.New() //b.ResultItems = make(b.ResultItems, 0)
- vm *bvm.VM
- glvm *script.GLVm
- ws *bws.WebService
- //重点网站和正式环境
- isOnly4MainSite string = "false"
- browserDisableLoadResources = ""
- serverAddress = "http://visualizeld.spdata.jianyu360.com/%s" //正式环境
- //serverAddress = "http://127.0.0.1:8091/%s" //正式环境
- )
- //build
- // wails build -ldflags="-X 'main.isOnly4MainSite=false'" -o="剑鱼可视化爬虫开发工具_正式.exe"
- func init() {
- be.LoadConfig("./config.yaml")
- //从配置文件外,编译时设定浏览器排除加载资源。比配置文件优先级低
- if be.Cfg.DisableLoadResource == "" && browserDisableLoadResources != "" {
- be.Cfg.DisableLoadResource = browserDisableLoadResources
- }
- be.Cfg.IsOnly4MainSite = isOnly4MainSite == "true"
- if be.Cfg.IsOnly4MainSite {
- serverAddress = "http://visualize.spdata.jianyu360.com/%s" //重点网站
- }
- qu.Debug("重点网站:", be.Cfg.IsOnly4MainSite, serverAddress)
- }
- func main() {
- go updateData() //数据保存
- // Create an instance of the app structure
- app = NewApp()
- // Create application with options
- err := wails.Run(&options.App{
- Title: "剑鱼-爬虫开发平台 v1.0",
- Width: 1224,
- Height: 668,
- AssetServer: &assetserver.Options{
- Assets: assets,
- },
- BackgroundColour: &options.RGBA{R: 255, G: 255, B: 255, A: 1},
- OnStartup: app.startup,
- OnShutdown: app.destory,
- Bind: []interface{}{
- app,
- },
- })
- if err != nil {
- println("Error:", err.Error())
- }
- }
|