Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
energye
energy
提交
2fba3d3b
energy
项目概览
energye
/
energy
通知
13
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
energy
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2fba3d3b
编写于
9月 17, 2023
作者:
yanghye
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
command-line: 增加app init template
上级
4b7c0171
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
117 addition
and
9 deletion
+117
-9
cmd/internal/assets/assets/icon.ico
cmd/internal/assets/assets/icon.ico
+0
-0
cmd/internal/assets/assets/initialize/index.html
cmd/internal/assets/assets/initialize/index.html
+57
-3
cmd/internal/assets/assets/initialize/main.go.1
cmd/internal/assets/assets/initialize/main.go.1
+29
-2
cmd/internal/assets/assets/initialize/main.go.2
cmd/internal/assets/assets/initialize/main.go.2
+28
-1
cmd/internal/initialize/initialize.go
cmd/internal/initialize/initialize.go
+3
-3
未找到文件。
cmd/internal/assets/assets/icon.ico
查看替换文件 @
4b7c0171
浏览文件 @
2fba3d3b
264.1 KB
|
W:
|
H:
43.6 KB
|
W:
|
H:
2-up
Swipe
Onion skin
cmd/internal/assets/assets/initialize/index.html
浏览文件 @
2fba3d3b
<!
DOCTYPE
html>
<!
doctype
html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
Go Energy
</title>
<style>
.logo
{
width
:
300px
;
height
:
300px
;
margin
:
40px
auto
0
;
}
.logo
img
{
width
:
100%
;
}
.module
{
text-align
:
center
;
padding
:
0
20px
;
margin
:
0px
auto
;
color
:
#000
;
}
.module
.content
{
margin-right
:
20px
;
text-align
:
center
;
}
.module
p
{
color
:
#999
;
}
</style>
</head>
<body>
index.html
<div
class=
"logo"
>
<img
src=
"icon.png"
>
</div>
<div
class=
"module"
>
<div
class=
"content"
>
<p
style=
"font-weight: bold; font-size: 14px; color: #000;"
>
Welcome to your new project!
</p>
<p>
OS Info:
<span
id=
"osInfo"
>
--
</span></p>
</div>
<div
class=
"content"
>
<p
style=
"font-weight: bold; font-size: 14px; color: #000"
>
Getting start
</p>
<a
href=
"https://github.com/energye/energy"
>
Github
</a>
<a
href=
"https://energy.yanghy.cn/course/100/0"
>
Course
</a>
<a
href=
"https://energy.yanghy.cn/example/200/0"
>
Example
</a>
<a
href=
"https://energy.yanghy.cn/document/300/0"
>
Document
</a>
</div>
</div>
<script>
// js on osInfo
ipc
.
on
(
"
osInfo
"
,
function
(
os
)
{
document
.
getElementById
(
"
osInfo
"
).
innerText
=
os
;
});
// js emit send count++
let
count
=
0
;
setInterval
(
function
()
{
count
++
ipc
.
emit
(
"
count
"
,
[
count
]);
},
1000
)
</script>
</body>
</html>
\ No newline at end of file
</html>
cmd/internal/assets/assets/initialize/main.go.1
浏览文件 @
2fba3d3b
...
...
@@ -3,7 +3,10 @@ package main
import
(
"embed"
"github.com/energye/energy/v2/cef"
"github.com/energye/energy/v2/cef/ipc"
"github.com/energye/energy/v2/pkgs/assetserve"
"github.com/energye/golcl/lcl"
"github.com/energye/golcl/lcl/rtl/version"
)
//
go
:
embed
resources
...
...
@@ -13,7 +16,7 @@ func main() {
//
Global
initialization
must
be
called
cef
.
GlobalInit
(
nil
,
&
resources
)
//
Create
an
application
cefA
pp
:=
cef
.
NewApplication
()
a
pp
:=
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
...
...
@@ -26,6 +29,30 @@ func main() {
server.Assets = &resources //Assets resources
go server.StartHttpServer()
})
// run main process and main thread
cef.BrowserWindow.SetBrowserInit(browserInit)
//run app
cef.Run(cefApp)
cef.Run(app)
}
// run main process and main thread
func browserInit(event *cef.BrowserEvent, window cef.IBrowserWindow) {
// index.html ipc.emit("count", [count++])
ipc.On("count", func(value int) {
println("count", value)
})
// page load end
event.SetOnLoadEnd(func(sender lcl.IObject, browser *cef.ICefBrowser, frame *cef.ICefFrame, httpStatusCode int32) {
// index.html, ipc.on("osInfo", function(){...})
println("osInfo", version.OSVersion.ToString())
ipc.Emit("osInfo", version.OSVersion.ToString())
var windowType string
if window.IsLCL() {
windowType = "LCL"
} else {
windowType = "VF"
}
// index.html, ipc.on("windowType", function(){...});
ipc.Emit("windowType", windowType)
})
}
cmd/internal/assets/assets/initialize/main.go.2
浏览文件 @
2fba3d3b
...
...
@@ -3,6 +3,9 @@ package main
import
(
"embed"
"github.com/energye/energy/v2/cef"
"github.com/energye/energy/v2/cef/ipc"
"github.com/energye/golcl/lcl"
"github.com/energye/golcl/lcl/rtl/version"
)
//
go
:
embed
resources
...
...
@@ -10,7 +13,7 @@ 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
()
//
Local
load
resources
...
...
@@ -18,6 +21,30 @@ func main() {
ResRootDir
:
"resources"
,
FS
:
&
resources
,
}.
Build
())
//
run
main
process
and
main
thread
cef
.
BrowserWindow
.
SetBrowserInit
(
browserInit
)
//
run
app
cef
.
Run
(
app
)
}
//
run
main
process
and
main
thread
func
browserInit
(
event
*
cef
.
BrowserEvent
,
window
cef
.
IBrowserWindow
)
{
//
index
.
html
ipc
.
emit
(
"count"
,
[
count
++])
ipc
.
On
(
"count"
,
func
(
value
int
)
{
println
(
"count"
,
value
)
})
//
page
load
end
event
.
SetOnLoadEnd
(
func
(
sender
lcl
.
IObject
,
browser
*
cef
.
ICefBrowser
,
frame
*
cef
.
ICefFrame
,
httpStatusCode
int32
)
{
//
index
.
html
,
ipc
.
on
(
"osInfo"
,
function
(){...})
println
(
"osInfo"
,
version
.
OSVersion
.
ToString
())
ipc
.
Emit
(
"osInfo"
,
version
.
OSVersion
.
ToString
())
var
windowType
string
if
window
.
IsLCL
()
{
windowType
=
"LCL"
}
else
{
windowType
=
"VF"
}
//
index
.
html
,
ipc
.
on
(
"windowType"
,
function
(){...});
ipc
.
Emit
(
"windowType"
,
windowType
)
})
}
cmd/internal/initialize/initialize.go
浏览文件 @
2fba3d3b
...
...
@@ -39,7 +39,7 @@ func InitEnergyProject(c *command.Config) error {
term
.
Logger
.
Info
(
"Website"
,
term
.
Logger
.
Args
(
"Github"
,
"https://github.com/energye/energy"
,
"ENERGY"
,
"https://energy.yanghy.cn"
))
term
.
Section
.
Println
(
"Run Application"
)
tableData
:=
pterm
.
TableData
{
{
"command
-line
"
},
{
"go run main.go"
},
{
"command"
},
{
"go run main.go"
},
}
err
:=
pterm
.
DefaultTable
.
WithHasHeader
()
.
WithHeaderRowSeparator
(
"-"
)
.
WithBoxed
()
.
WithData
(
tableData
)
.
Render
()
if
err
!=
nil
{
...
...
@@ -47,7 +47,7 @@ func InitEnergyProject(c *command.Config) error {
}
term
.
Section
.
Println
(
"Building Application"
)
tableData
=
pterm
.
TableData
{
{
"
cmd name"
,
"command-line
"
},
{
"
name"
,
"command
"
},
}
tableData
=
append
(
tableData
,
[]
string
{
"go"
,
`go build -ldflags "-s -w"`
})
tableData
=
append
(
tableData
,
[]
string
{
"energy"
,
`energy build .`
})
...
...
@@ -57,7 +57,7 @@ func InitEnergyProject(c *command.Config) error {
}
term
.
Section
.
Println
(
"Make install package"
)
tableData
=
pterm
.
TableData
{
{
"command
-line
"
},
{
"energy package ."
},
{
"command"
},
{
"energy package ."
},
}
err
=
pterm
.
DefaultTable
.
WithHasHeader
()
.
WithHeaderRowSeparator
(
"-"
)
.
WithBoxed
()
.
WithData
(
tableData
)
.
Render
()
if
err
!=
nil
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录