energy/cef/browser-config.go

51 lines
1.3 KiB
Go
Raw Normal View History

//----------------------------------------
//
// Copyright © yanghy. All Rights Reserved.
//
// Licensed under Apache License Version 2.0, January 2004
//
// https://www.apache.org/licenses/LICENSE-2.0
//
//----------------------------------------
// 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
)
type browserWindowOnEventCallback func(event *BrowserEvent, window IBrowserWindow)
// 创建主窗口指定的一些快捷配置属性
2022-10-26 16:48:32 +08:00
type browserConfig struct {
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-06-19 12:41:52 +08:00
return m.config
}
// 主窗口初始化回调
2023-05-31 17:41:14 +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
}
}