2022-12-07 15:50:59 +08:00
|
|
|
//----------------------------------------
|
|
|
|
//
|
|
|
|
// Copyright © yanghy. All Rights Reserved.
|
|
|
|
//
|
2023-02-19 23:21:47 +08:00
|
|
|
// Licensed under Apache License Version 2.0, January 2004
|
|
|
|
//
|
|
|
|
// https://www.apache.org/licenses/LICENSE-2.0
|
2022-12-07 15:50:59 +08:00
|
|
|
//
|
|
|
|
//----------------------------------------
|
|
|
|
|
2023-02-19 23:21:47 +08:00
|
|
|
// Browser Window 配置
|
2023-05-31 17:41:14 +08:00
|
|
|
|
2022-10-26 16:48:32 +08:00
|
|
|
package cef
|
|
|
|
|
|
|
|
import (
|
2023-05-31 18:00:34 +08:00
|
|
|
"github.com/energye/energy/v2/cef/process"
|
2022-10-26 16:48:32 +08:00
|
|
|
)
|
|
|
|
|
2023-01-06 18:26:40 +08:00
|
|
|
type browserWindowOnEventCallback func(event *BrowserEvent, window IBrowserWindow)
|
2023-01-01 22:19:26 +08:00
|
|
|
|
2023-02-19 23:21:47 +08:00
|
|
|
// 创建主窗口指定的一些快捷配置属性
|
2022-10-26 16:48:32 +08:00
|
|
|
type browserConfig struct {
|
2023-01-23 10:52:40 +08:00
|
|
|
WindowProperty
|
2023-06-19 12:41:52 +08:00
|
|
|
config *TCefChromiumConfig //主窗体浏览器配置
|
2023-05-31 17:41:14 +08:00
|
|
|
browserWindowOnEventCallback browserWindowOnEventCallback //主窗口初始化回调
|
2022-10-26 16:48:32 +08:00
|
|
|
}
|
|
|
|
|
2023-06-19 12:41:52 +08:00
|
|
|
// SetChromiumConfig 设置 chromium 配置
|
|
|
|
func (m *browserConfig) SetChromiumConfig(config *TCefChromiumConfig) {
|
|
|
|
if config != nil && process.Args.IsMain() {
|
|
|
|
m.config = config
|
2022-10-26 16:48:32 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-31 17:41:14 +08:00
|
|
|
// ChromiumConfig 扩展配置
|
2023-06-19 12:41:52 +08:00
|
|
|
// 获取/创建 CEF Chromium Options
|
|
|
|
func (m *browserConfig) ChromiumConfig() *TCefChromiumConfig {
|
|
|
|
if m.config == nil {
|
|
|
|
m.config = NewChromiumConfig()
|
2023-01-05 13:02:03 +08:00
|
|
|
}
|
2023-06-19 12:41:52 +08:00
|
|
|
return m.config
|
2023-01-05 13:02:03 +08:00
|
|
|
}
|
|
|
|
|
2023-02-19 23:21:47 +08:00
|
|
|
// 主窗口初始化回调
|
2023-05-31 17:41:14 +08:00
|
|
|
// 创建主窗口后,显示之前执行
|
2023-01-01 22:19:26 +08:00
|
|
|
func (m *browserConfig) setBrowserWindowInitOnEvent(fn browserWindowOnEventCallback) {
|
2023-05-31 17:41:14 +08:00
|
|
|
if fn != nil && process.Args.IsMain() {
|
2022-10-26 16:48:32 +08:00
|
|
|
m.browserWindowOnEventCallback = fn
|
|
|
|
}
|
|
|
|
}
|