package main import ( "embed" "fmt" "github.com/energye/energy/v2/cef" "github.com/energye/energy/v2/common" "github.com/energye/energy/v2/pkgs/assetserve" ) //go:embed resources var resources embed.FS func main() { cef.GlobalInit(nil, &resources) app := cef.NewApplication() cef.BrowserWindow.Config.Url = "http://localhost:22022/index.html" if common.IsLinux() && app.IsUIGtk3() { cef.BrowserWindow.Config.IconFS = "resources/icon.png" } else { cef.BrowserWindow.Config.IconFS = "resources/icon.ico" } cef.BrowserWindow.Config.Title = "ENERGY - Custom Drag Window" cef.SetBrowserProcessStartAfterCallback(func(b bool) { fmt.Println("主进程启动 创建一个内置http服务") //通过内置http服务加载资源 server := assetserve.NewAssetsHttpServer() server.PORT = 22022 //服务端口号 server.AssetsFSName = "resources" //必须设置目录名和资源文件夹同名 server.Assets = &resources go server.StartHttpServer() }) cef.Run(app) }