Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
energye
energy
提交
4eabf9d9
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,体验更适合开发者的 AI 搜索 >>
提交
4eabf9d9
编写于
9月 19, 2023
作者:
yanghye
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
demo: new-window
上级
192e033d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
36 addition
and
15 deletion
+36
-15
example/window/new-window/new-window.go
example/window/new-window/new-window.go
+7
-6
example/window/new-window/resources/index.html
example/window/new-window/resources/index.html
+5
-3
example/window/new-window/resources/new-window.html
example/window/new-window/resources/new-window.html
+24
-6
未找到文件。
example/window/new-window/new-window.go
浏览文件 @
4eabf9d9
...
...
@@ -29,8 +29,8 @@ func main() {
//创建应用
app
:=
cef
.
NewApplication
()
//强制使用VF窗口
app
.
SetExternalMessagePump
(
false
)
app
.
SetMultiThreadedMessageLoop
(
false
)
//
app.SetExternalMessagePump(false)
//
app.SetMultiThreadedMessageLoop(false)
//指定一个URL地址,或本地html文件目录
cef
.
BrowserWindow
.
Config
.
Url
=
"fs://energy"
...
...
@@ -59,7 +59,8 @@ func main() {
wp
:=
cef
.
NewWindowProperty
()
wp
.
Url
=
"fs://energy/new-window.html"
wp
.
Title
=
name
// 创建新的浏览器窗口
wp
.
EnableHideCaption
=
true
// 无标题窗口
// 创建浏览器窗口
newWindow
:=
cef
.
NewBrowserWindow
(
nil
,
wp
)
newWindow
.
SetWidth
(
800
)
newWindow
.
SetHeight
(
600
)
...
...
@@ -68,9 +69,9 @@ func main() {
newWindow
.
EnableAllDefaultEvent
()
window
.
RunOnMainThread
(
func
()
{
println
(
"create-window show"
,
name
)
// 在主线程中
newWindow
.
Show
()
})
// 在主线程中
newWindow
.
Show
()
})
// 改变当前窗口大小
ipc
.
On
(
"resize"
,
func
(
_type
int
,
channel
callback
.
IChannel
)
{
...
...
@@ -86,7 +87,7 @@ func main() {
case
2
:
win
.
SetSize
(
600
,
400
)
case
3
:
win
.
SetSize
(
800
,
600
)
win
.
SetSize
(
1024
,
768
)
}
})
})
...
...
example/window/new-window/resources/index.html
浏览文件 @
4eabf9d9
...
...
@@ -4,15 +4,17 @@
<meta
charset=
"UTF-8"
>
<title>
new-window
</title>
<script>
// 创建子窗口
function
createWindow
()
{
ipc
.
emit
(
"
create-window
"
,
[
"
NewWindowName
"
+
new
Date
().
getTime
()]);
}
// 子窗口创建
ipc
.
on
(
"
on-create-window-ok
"
,
function
(
id
)
{
document
.
getElementById
(
"
msg
"
).
innerText
=
"
窗口创建成功
:
"
+
id
document
.
getElementById
(
"
msg
"
).
innerText
=
"
创建 - 窗口ID
:
"
+
id
});
// 子窗口关闭
ipc
.
on
(
"
on-close-window
"
,
function
(
id
)
{
document
.
getElementById
(
"
msg
"
).
innerText
=
"
窗口被关闭
:
"
+
id
document
.
getElementById
(
"
msg
"
).
innerText
=
"
关闭 - 窗口ID
:
"
+
id
});
</script>
</head>
...
...
example/window/new-window/resources/new-window.html
浏览文件 @
4eabf9d9
...
...
@@ -3,17 +3,35 @@
<head>
<meta
charset=
"UTF-8"
>
<title>
new-window
</title>
<style
type=
"text/css"
>
a
,
button
,
div
{
-webkit-app-region
:
no-drag
;
}
body
{
margin
:
0px
;
padding
:
0px
;
text-align
:
center
;
overflow
:
hidden
;
-webkit-app-region
:
drag
;
width
:
100%
;
height
:
100vh
;
}
</style>
<script>
function
resize
(
type
)
{
ipc
.
emit
(
"
resize
"
,
[
type
]);
}
</script>
</head>
<body
style=
"width: 100%;text-align: center;overflow: hidden;"
>
改变当前窗口大小:
<button
onclick=
"resize(1)"
>
小
</button>
<button
onclick=
"resize(2)"
>
中
</button>
<button
onclick=
"resize(3)"
>
大
</button>
<a
href=
"other.html"
>
other
</a>
<body>
改变当前窗口大小:
<button
onclick=
"resize(1)"
>
小
</button>
<button
onclick=
"resize(2)"
>
中
</button>
<button
onclick=
"resize(3)"
>
大
</button>
<a
href=
"other.html"
>
other
</a>
<div
style=
"height: 100px;width: 100px;background-color: gainsboro;text-align: center;vertical-align: center;"
>
此区域可右键关闭窗口
</div>
</body>
</html>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录