U: README

This commit is contained in:
杨红岩 2023-06-29 16:19:33 +08:00
parent 6e2469874d
commit adeef95c60
2 changed files with 64 additions and 47 deletions

View File

@ -35,17 +35,6 @@ Energy is a framework developed by Golang based on CEF(Chromium Embedded Framewo
> - event driven: High performance event driven, IPC based communication, Go and Web side is very convenient function call and data interaction
### Go interacts with the Web
> The Go and Web technologies are based on IPC communication. Data and event triggering can be exchanged between Go and Web without using the http interface, which is as simple as calling the functions of the language itself
>
> Define JS binding type variables in Go and provide them to JS on the Web side to realize data synchronization of Go variables or structural objects
>
> Listen for events in JS and trigger JS events in Go to achieve Go calling JS functions and passing parameter
>
> Listen for events in Go and trigger Go events in JS to achieve JS calling Go functions and passing parameters
>
### Built-in dependency&integration
- [![LCL](https://img.shields.io/badge/LCL-green)](https://github.com/energye/golcl)
@ -61,24 +50,29 @@ Energy is a framework developed by Golang based on CEF(Chromium Embedded Framewo
>
> Use the energy command line tool to automatically install the development environment
>
> Get [energy](https://github.com/energye/energy)
> project, or use the precompiled command line tool directly [Download address](https://energy.yanghy.cn/#/course/6342d92c401bfe4d0cdf6065/63511b14a749ba0318943f3a)
> 1. go get github.com/energye/energy
> Get [energy](https://github.com/energye/energy) project, or use the precompiled command line tool directly [Download address](https://energy.yanghy.cn/#/course/6342d92c401bfe4d0cdf6065/63511b14a749ba0318943f3a)
>
> <p style="color:palevioletred;">If using pre compiled command-line tools, the following steps can be skipped</p>
>
> `go get github.com/energye/energy`
>
> Enter the [energy](https://github.com/energye/energy) command line directory
> 2. cd energy/cmd/energy
>
> `cd energy/cmd/energy`
>
> Install command line tools
> 3. go install
>
> `go install`
>
> Execute the installation command
> 4. energy install .
>
> `energy install .`
### Getting Started Guide - [Transfer gate](https://energy.yanghy.cn)
* [course](https://energy.yanghy.cn/#/course/6342d92c401bfe4d0cdf6065/6350f94ca749ba0318943f25)
* [example](https://energy.yanghy.cn/#/example/6342d986401bfe4d0cdf6067/634d3bd5a749ba0318943eb6)
* [document](https://energy.yanghy.cn/#/document/6342d9a4401bfe4d0cdf6069/0)
* [Course](https://energy.yanghy.cn/#/course/6342d92c401bfe4d0cdf6065/6350f94ca749ba0318943f25)
* [Example](https://energy.yanghy.cn/#/example/6342d986401bfe4d0cdf6067/634d3bd5a749ba0318943eb6)
* [Document](https://energy.yanghy.cn/#/document/6342d9a4401bfe4d0cdf6069/0)
### Quick Get Start
> Use [energy](https://github.com/energye/energy) Command line tool automatic installation environment dependency `energy install .`
@ -106,23 +100,37 @@ func main() {
//Create application
cefApp := cef.NewApplication()
//Set URL
cef.BrowserWindow.Config.Url = "https://energy.yanghy.cn"
cef.BrowserWindow.Config.Url = "https://www.yanghy.cn"
//Run App
cef.Run(cefApp)
}
```
---
### Run app
- Windows、Linux
> `go run simple.go`
- MacOS
> `go run simple.go energy_env=dev`
### Pack Project [reference](https://energy.yanghy.cn/#/course/6342d92c401bfe4d0cdf6065/636e397ba749ba01d04ff595)
1. Compile: Go program compilation `go build xxx. go` If you use resource built-in (HTML, CSS, JavaScript, Image, etc.), the resource will be compiled into the execution file
1. Compile: Go program compilation `go build simple.go` If you use resource built-in (HTML, CSS, JavaScript, Image, etc.), the resource will be compiled into the execution file
2. Copy: copy the execution file to the CEF directory of the ENERGY environment
3. Packaging: use the installation package tool to make it as an installation package, Or refer to the production of installation package for each system platform
4. Finally: the compiled program or installation package and CEF directory no longer need to configure the environment, and can be run directly in the CEF root directory
#### Go Compile Command
1. Compress and hide the cmd window `go build -ldflags "-H windowsgui -s -w"`, Note: Windows needs to hide the CMD window
2. Compress `go build -ldflags "-s -w"`
2. Uncompressed `go build`
- `go build -ldflags "-H windowsgui -s -w"`
> `-ldflags`
>
>> `-H windowsgui` optional: windows hide cmd black window
>>
>> `-w` optional: Removing debugging information can reduce the size of the execution file
>>
>> `-s` optional: Removing Symbol table information can reduce the size of the execution file
---
---

View File

@ -28,7 +28,7 @@
### 特性
> - 开发环境简单,编译速度快,只需要Go开发环境和Energy依赖的CEF二进制框架
> - 开发环境简单,编译速度快,只需要Go和Energy依赖的CEF二进制框架
> - 跨平台: 一套代码可以打包成 Windows, 国产UOS、Deepin、Kylin, MacOS, Linux
> - 语言职责
>> - Go: Go负责窗口创建、CEF配置和功能实现、各种UI组件创建、系统低层调用和JS处理不了的功能如: 文件流、安全加密、高性能处理等等,可作为纯后端开发
@ -36,13 +36,6 @@
> - 前端技术: 支持主流前端框架例如Vue、React、Angular, 或纯HTML+CSS等等
> - 事件驱动: 高性能事件驱动, 基于IPC通信实现Go和Web端很方便功能调用以及数据交互
#### 事件驱动 Go和Web交互
> - 在Go和Web技术基于IPC通信可以在Go和Web交互数据、事件触发, 可以不使用 http 接口,就像调用语言本身函数一样简单
> - 在Go中定义JS绑定类型变量提供给Web端JS使用实现Go变量或结构对象数据同步
> - 在JS监听事件在Go中触发JS事件以达到Go调用JS函数和数据传递
> - 在Go监听事件在JS中触发Go事件以达到JS调用Go函数和数据传递
### 内置依赖&集成
- [![LCL](https://img.shields.io/badge/LCL-green)](https://github.com/energye/golcl)
@ -52,23 +45,28 @@
#### 基本需求
> - golang >= 1.18
> - energy 开发环境
> - Golang >= 1.18
> - Energy 开发环境
>
> 使用 energy 命令行工具自动安装开发环境
>
> 获取 [energy](https://github.com/energye/energy)
> 项目,或直接使用预编译命令行工具 [下载地址](https://energy.yanghy.cn/#/course/6342d92c401bfe4d0cdf6065/63511b14a749ba0318943f3a)
> 1. go get github.com/energye/energy
> 获取 [energy](https://github.com/energye/energy) 项目,或直接使用预编译命令行工具 [下载地址](https://energy.yanghy.cn/#/course/6342d92c401bfe4d0cdf6065/63511b14a749ba0318943f3a)
>
> <p style="color:palevioletred;">如果使用预编译命令行工具以下步骤可跳过</p>
>
> `go get github.com/energye/energy`
>
> 进入 [energy](https://github.com/energye/energy) 命令行目录
> 2. cd energy/cmd/energy
>
> `cd energy/cmd/energy`
>
> 安装命令行工具
> 3. go install
>
> `go install`
>
> 执行安装命令
> 4. energy install .
>
> `energy install .`
### 入门指南 - [传送门](https://energy.yanghy.cn)
@ -84,9 +82,9 @@
>
> 更新最新发布版本依赖
>
> 2. go mod tidy
> `go mod tidy`
>
> 在IDE中运行simple 或 go run simple.go
> 在IDE中运行 simple 或 go run simple.go
### example/simple 示例代码
@ -110,16 +108,27 @@ func main() {
```
---
### 运行应用
- Windows、Linux
> `go run simple.go`
- MacOS
> `go run simple.go energy_env=dev`
### 项目打包 [参考](https://energy.yanghy.cn/#/course/6342d92c401bfe4d0cdf6065/636e397ba749ba01d04ff595)
1. 编译Go 程序编译`go build xxx.go` 如果使用资源内置(HTML、CSS、JavaScript、Image等等)会把资源编译到执行文件内
1. 编译Go 程序编译`go build simple.go` 如果使用资源内置(HTML、CSS、JavaScript、Image等等)会把资源编译到执行文件内
2. 复制把执行文件复制到ENERGY环境的CEF目录中即可
3. 打包:使用制作安装包工具将其制作为安装包, 查阅各系统平台安装包制作
4. 最后编译后的程序或安装包和CEF目录不再需要配置环境,在CEF根目录可直接运行
#### Go编译命令
1. 压缩并隐藏cmd窗口 `go build -ldflags "-H windowsgui -s -w"`, 注意: windows需要隐藏CMD窗口
2. 会压缩 不隐藏cmd窗口 `go build -ldflags "-s -w"`
2. 不压缩 不隐藏cmd窗口 `go build`
- `go build -ldflags "-H windowsgui -s -w"`
> `-ldflags`
>
>> `-H windowsgui` 可选: windows 隐藏cmd黑窗口
>>
>> `-w` 可选: 去除调试信息, 可减小执行文件大小
>>
>> `-s` 可选: 去除符号表信息, 可减小执行文件大小
---