energy-command-line, 增加应用初始化 energy init .

增加默认的应用图标
This commit is contained in:
杨红岩 2023-09-03 13:06:33 +08:00
parent ba72112fe0
commit 376b6d75dc
5 changed files with 76 additions and 9 deletions

View File

@ -112,7 +112,13 @@ func (m *LCLBrowserWindow) setProperty() {
if tools.IsExist(wp.Icon) {
lcl.Application.Icon().LoadFromFile(wp.Icon)
}
} else {
// 默认
// vf png
// lcl ico
lcl.Application.Icon().LoadFromBytes(defaultICONIco)
}
freeDefaultICON()
if wp.EnableCenterWindow {
m.SetSize(wp.Width, wp.Height)
m.SetCenterWindow(true)

View File

@ -92,7 +92,15 @@ func NewViewsFrameworkBrowserWindow(config *TCefChromiumConfig, windowProperty W
logger.Error("set window application icon error:", err.Error())
}
}
} else {
// 默认
// vf png
// lcl ico
icon := ImageRef.New()
icon.AddPng(1, defaultICONPng)
m.windowComponent.SetWindowAppIcon(icon)
}
freeDefaultICON()
m.browserViewComponent.RequestFocus()
m.windowComponent.Show()
if m.doOnWindowCreated != nil {

31
cef/default-icon.go Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,16 +1,23 @@
package main
import (
"embed"
"github.com/energye/energy/v2/cef"
)
//go:embed resources
var resources embed.FS
func main() {
//Global initialization must be called
cef.GlobalInit(nil, nil)
//Create an application
app := cef.NewApplication()
//指定一个URL地址或本地html文件目录
cef.BrowserWindow.Config.Url = "https://www.baidu.com"
//运行应用
//Local load resources
cef.BrowserWindow.Config.LocalResource(cef.LocalLoadConfig{
ResRootDir: "resources",
FS: &resources,
}.Build())
//run app
cef.Run(app)
}

View File

@ -1,16 +1,31 @@
package main
import (
"embed"
"github.com/energye/energy/v2/cef"
"github.com/energye/energy/v2/pkgs/assetserve"
)
//go:embed resources
var resources embed.FS
func main() {
//Global initialization must be called
cef.GlobalInit(nil, nil)
cef.GlobalInit(nil, &resources)
//Create an application
app := cef.NewApplication()
//指定一个URL地址或本地html文件目录
cef.BrowserWindow.Config.Url = "https://www.baidu.com"
//运行应用
cef.Run(app)
cefApp := cef.NewApplication()
//http's url
cef.BrowserWindow.Config.Url = "http://localhost:22022/index.html"
//Security key and value settings for built-in static resource services
assetserve.AssetsServerHeaderKeyName = "energy"
assetserve.AssetsServerHeaderKeyValue = "energy"
cef.SetBrowserProcessStartAfterCallback(func(b bool) {
server := assetserve.NewAssetsHttpServer() //Built in HTTP service
server.PORT = 22022 //Service Port Number
server.AssetsFSName = "resources" //Resource folder with the same name
server.Assets = &resources //Assets resources
go server.StartHttpServer()
})
//run app
cef.Run(cefApp)
}