mirror of
https://gitee.com/energye/energy.git
synced 2024-12-02 11:47:37 +08:00
energy-command-line, 增加应用初始化 energy init .
增加默认的应用图标
This commit is contained in:
parent
ba72112fe0
commit
376b6d75dc
@ -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)
|
||||
|
@ -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
31
cef/default-icon.go
Normal file
File diff suppressed because one or more lines are too long
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user