mirror of
https://gitee.com/energye/energy.git
synced 2024-11-30 02:37:46 +08:00
v2.2.14 Fixed Chinese input and gtk3 issues for linux packagin
This commit is contained in:
parent
198faa41f7
commit
9293e488c6
@ -143,6 +143,9 @@ func (m *assetsHttpServer) graceShutdown(server *http.Server) {
|
||||
}
|
||||
}
|
||||
|
||||
//启动内置Http Server
|
||||
//
|
||||
//需要使用goroutine启动 [go x.StartHttpServer()]
|
||||
func (m *assetsHttpServer) StartHttpServer() {
|
||||
if m.LocalAssets != "" {
|
||||
m.LocalAssets = strings.ReplaceAll(m.LocalAssets, "\\", "/")
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
"github.com/energye/energy/cef"
|
||||
"github.com/energye/energy/common/assetserve"
|
||||
"github.com/energye/energy/example/mini-browser/src"
|
||||
"github.com/energye/energy/example/dev-test/combination-sundry-browser/src"
|
||||
"github.com/energye/energy/logger"
|
||||
)
|
||||
|
@ -46,15 +46,7 @@
|
||||
<button class="inpQuery">GO</button>
|
||||
</div>
|
||||
<div style="margin-top: 70px;overflow-y: auto;height: 850px;overflow-x: hidden;">
|
||||
<h3>这是一个各种使用方式的集合示例</h3>
|
||||
<h3>
|
||||
在Go和Web端技术中,基于IPC通信,你可以很方便的在Go和Web端交互数据和事件
|
||||
<br>不再需要繁琐的web service接口
|
||||
<br>在Go中还可以定义JS变量,提供给Web端JS使用
|
||||
<br>在Go中调用JavaScript函数
|
||||
<br>在JavaScript中调用Go函数
|
||||
<br>就像调用语言本身函数一样简单
|
||||
</h3>
|
||||
<h3>开发时测试的各种使用方式的集合示例</h3>
|
||||
|
||||
<p>Golang 绑定映射 Javascript 通用类型属性、函数,结构对象属性</p>
|
||||
通用类型:
|
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 66 KiB |
41
example/dev-test/lcl-browser/lcl-browser.go
Normal file
41
example/dev-test/lcl-browser/lcl-browser.go
Normal file
@ -0,0 +1,41 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"fmt"
|
||||
"github.com/energye/energy/cef"
|
||||
"github.com/energye/energy/common/assetserve"
|
||||
"github.com/energye/golcl/lcl"
|
||||
"github.com/energye/golcl/lcl/types"
|
||||
)
|
||||
|
||||
//go:embed resources
|
||||
var resources embed.FS
|
||||
|
||||
func main() {
|
||||
//全局初始化 每个应用都必须调用的
|
||||
cef.GlobalCEFInit(nil, &resources)
|
||||
//创建应用
|
||||
cefApp := cef.NewApplication(nil)
|
||||
//指定一个URL地址,或本地html文件目录
|
||||
cef.BrowserWindow.Config.Url = "http://localhost:22022/index.html"
|
||||
cef.BrowserWindow.SetBrowserInit(func(event *cef.BrowserEvent, window cef.IBrowserWindow) {
|
||||
event.SetOnWidgetCompMsg(func(sender lcl.IObject, message types.TMessage, aHandled bool) {
|
||||
fmt.Println("SetOnWidgetCompMsg:", message)
|
||||
})
|
||||
event.SetOnDraggableRegionsChanged(func(sender lcl.IObject, browser *cef.ICefBrowser, frame *cef.ICefFrame, regions *cef.TCefDraggableRegions) {
|
||||
fmt.Println("RegionsCount:", regions.RegionsCount())
|
||||
})
|
||||
})
|
||||
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(cefApp)
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
提取Energy压缩包动态链接库liblcl.dll到该目录下
|
||||
|
||||
libs目录下的文件会被编译到执行文件中
|
BIN
example/dev-test/lcl-browser/resources/icon.ico
Normal file
BIN
example/dev-test/lcl-browser/resources/icon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 66 KiB |
20
example/dev-test/lcl-browser/resources/index.html
Normal file
20
example/dev-test/lcl-browser/resources/index.html
Normal file
@ -0,0 +1,20 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>cookie</title>
|
||||
<style>
|
||||
</style>
|
||||
<script type="application/javascript">
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body style="overflow: hidden;margin: 0px;padding: 0px;">
|
||||
<h3>开发时测试的一个针对【-webkit-app-region: drag/no-drag】示例</h3>
|
||||
<div style="-webkit-app-region: drag;width: 600px;border: 1px solid red;">
|
||||
<a href="https://www.baidu.com" style="-webkit-app-region:no-drag">百度</a>
|
||||
<a href="https://energy.yanghy.cn" style="-webkit-app-region:no-drag">Energy</a>
|
||||
<a href="https://www.baidu.com" target="_blank">新窗口百度-此处点不到</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
18
example/dev-test/lcl-browser/resources/资源存放目录-可内置到执行程序中.md
Normal file
18
example/dev-test/lcl-browser/resources/资源存放目录-可内置到执行程序中.md
Normal file
@ -0,0 +1,18 @@
|
||||
可将html css javascript image等静态资源放入该目录,编译后将内置到执行程序中
|
||||
|
||||
通过内置http server 读取该目录文件,展示到页面中
|
||||
```go
|
||||
//内置http服务链接安全配置
|
||||
assetserve.AssetsServerHeaderKeyName = "energy"
|
||||
assetserve.AssetsServerHeaderKeyValue = "energy"
|
||||
//内置http服务链接安全配置
|
||||
cef.SetBrowserProcessStartAfterCallback(func(b bool) {
|
||||
fmt.Println("主进程启动 创建一个内置http服务")
|
||||
//通过内置http服务加载资源
|
||||
server := assetserve.NewAssetsHttpServer()
|
||||
server.PORT = 22022
|
||||
server.AssetsFSName = "resources" //必须设置目录名
|
||||
server.Assets = &resources
|
||||
go server.StartHttpServer()
|
||||
})
|
||||
```
|
Loading…
Reference in New Issue
Block a user