mirror of
https://gitee.com/energye/energy.git
synced 2024-11-30 10:47:57 +08:00
优化&修复 tag -> v14
This commit is contained in:
parent
a3efd214f3
commit
099a7ec60d
@ -420,16 +420,18 @@ func init() {
|
||||
dllimports.NewEnergyImport("CEFWindowInfoAsWindowless", 0),
|
||||
dllimports.NewEnergyImport("CEFJSRegisterExtension", 0),
|
||||
//ICefRequest
|
||||
dllimports.NewEnergyImport("cefRequest_IsReadOnly", 0),
|
||||
dllimports.NewEnergyImport("cefRequest_SetUrl", 0),
|
||||
dllimports.NewEnergyImport("cefRequest_SetMethod", 0),
|
||||
dllimports.NewEnergyImport("cefRequest_SetReferrer", 0),
|
||||
dllimports.NewEnergyImport("cefRequest_SetFlags", 0),
|
||||
dllimports.NewEnergyImport("cefRequest_SetFirstPartyForCookies", 0),
|
||||
dllimports.NewEnergyImport("cefRequest_GetHeaderByName", 0),
|
||||
dllimports.NewEnergyImport("cefRequest_SetHeaderByName", 0),
|
||||
dllimports.NewEnergyImport("cefRequest_GetHeaderMap", 0),
|
||||
dllimports.NewEnergyImport("cefRequest_SetHeaderMap", 0),
|
||||
dllimports.NewEnergyImport("CefRequest_IsReadOnly", 0),
|
||||
dllimports.NewEnergyImport("CefRequest_SetUrl", 0),
|
||||
dllimports.NewEnergyImport("CefRequest_SetMethod", 0),
|
||||
dllimports.NewEnergyImport("CefRequest_SetReferrer", 0),
|
||||
dllimports.NewEnergyImport("CefRequest_SetFlags", 0),
|
||||
dllimports.NewEnergyImport("CefRequest_SetFirstPartyForCookies", 0),
|
||||
dllimports.NewEnergyImport("CefRequest_GetHeaderByName", 0),
|
||||
dllimports.NewEnergyImport("CefRequest_SetHeaderByName", 0),
|
||||
dllimports.NewEnergyImport("CefRequest_GetHeaderMap", 0),
|
||||
dllimports.NewEnergyImport("CefRequest_SetHeaderMap", 0),
|
||||
dllimports.NewEnergyImport("CefRequest_GetPostData", 0),
|
||||
dllimports.NewEnergyImport("CefRequest_SetPostData", 0),
|
||||
//ICefResponse
|
||||
dllimports.NewEnergyImport("cefResponse_IsReadOnly", 0),
|
||||
dllimports.NewEnergyImport("cefResponse_SetError", 0),
|
||||
@ -442,13 +444,13 @@ func init() {
|
||||
dllimports.NewEnergyImport("cefResponse_SetURL", 0),
|
||||
dllimports.NewEnergyImport("cefResponse_GetHeaderMap", 0),
|
||||
//ICefStringMultiMap
|
||||
dllimports.NewEnergyImport("cefHeaderMap_GetSize", 0),
|
||||
dllimports.NewEnergyImport("cefHeaderMap_FindCount", 0),
|
||||
dllimports.NewEnergyImport("cefHeaderMap_GetEnumerate", 0),
|
||||
dllimports.NewEnergyImport("cefHeaderMap_GetKey", 0),
|
||||
dllimports.NewEnergyImport("cefHeaderMap_GetValue", 0),
|
||||
dllimports.NewEnergyImport("cefHeaderMap_Append", 0),
|
||||
dllimports.NewEnergyImport("cefHeaderMap_Clear", 0),
|
||||
dllimports.NewEnergyImport("StringMultimap_GetSize", 0),
|
||||
dllimports.NewEnergyImport("StringMultimap_FindCount", 0),
|
||||
dllimports.NewEnergyImport("StringMultimap_GetEnumerate", 0),
|
||||
dllimports.NewEnergyImport("StringMultimap_GetKey", 0),
|
||||
dllimports.NewEnergyImport("StringMultimap_GetValue", 0),
|
||||
dllimports.NewEnergyImport("StringMultimap_Append", 0),
|
||||
dllimports.NewEnergyImport("StringMultimap_Clear", 0),
|
||||
//ICefImage
|
||||
dllimports.NewEnergyImport("CEFImage_New", 0),
|
||||
dllimports.NewEnergyImport("CEFImage_AddPng", 0),
|
||||
@ -1181,16 +1183,18 @@ const (
|
||||
internale_CEFWindowInfoAsWindowless
|
||||
internale_CEFJSRegisterExtension
|
||||
//ICefRequest
|
||||
internale_cefRequest_IsReadOnly
|
||||
internale_cefRequest_SetUrl
|
||||
internale_cefRequest_SetMethod
|
||||
internale_cefRequest_SetReferrer
|
||||
internale_cefRequest_SetFlags
|
||||
internale_cefRequest_SetFirstPartyForCookies
|
||||
internale_cefRequest_GetHeaderByName
|
||||
internale_cefRequest_SetHeaderByName
|
||||
internale_cefRequest_GetHeaderMap
|
||||
internale_cefRequest_SetHeaderMap
|
||||
internale_CefRequest_IsReadOnly
|
||||
internale_CefRequest_SetUrl
|
||||
internale_CefRequest_SetMethod
|
||||
internale_CefRequest_SetReferrer
|
||||
internale_CefRequest_SetFlags
|
||||
internale_CefRequest_SetFirstPartyForCookies
|
||||
internale_CefRequest_GetHeaderByName
|
||||
internale_CefRequest_SetHeaderByName
|
||||
internale_CefRequest_GetHeaderMap
|
||||
internale_CefRequest_SetHeaderMap
|
||||
internale_CefRequest_GetPostData
|
||||
internale_CefRequest_SetPostData
|
||||
//ICefResponse
|
||||
internale_cefResponse_IsReadOnly
|
||||
internale_cefResponse_SetError
|
||||
@ -1203,13 +1207,13 @@ const (
|
||||
internale_cefResponse_SetURL
|
||||
internale_cefResponse_GetHeaderMap
|
||||
//ICefStringMultiMap
|
||||
internale_cefHeaderMap_GetSize
|
||||
internale_cefHeaderMap_FindCount
|
||||
internale_cefHeaderMap_GetEnumerate
|
||||
internale_cefHeaderMap_GetKey
|
||||
internale_cefHeaderMap_GetValue
|
||||
internale_cefHeaderMap_Append
|
||||
internale_cefHeaderMap_Clear
|
||||
internale_StringMultimap_GetSize
|
||||
internale_StringMultimap_FindCount
|
||||
internale_StringMultimap_GetEnumerate
|
||||
internale_StringMultimap_GetKey
|
||||
internale_StringMultimap_GetValue
|
||||
internale_StringMultimap_Append
|
||||
internale_StringMultimap_Clear
|
||||
//ICefImage
|
||||
internale_CEFImage_New
|
||||
internale_CEFImage_AddPng
|
||||
|
@ -18,103 +18,70 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// Instance 实例
|
||||
func (m *ICefRequest) Instance() uintptr {
|
||||
return uintptr(m.instance)
|
||||
}
|
||||
|
||||
// IsReadOnly 是否只读
|
||||
func (m *ICefRequest) IsReadOnly() bool {
|
||||
return api.GoBool(cefRequest_IsReadOnly(m.Instance()))
|
||||
r1, _, _ := imports.Proc(internale_CefRequest_IsReadOnly).Call(m.Instance())
|
||||
return api.GoBool(r1)
|
||||
}
|
||||
|
||||
// SetURL 设置URL
|
||||
func (m *ICefRequest) SetURL(url string) {
|
||||
cefRequest_SetUrl(m.Instance(), url)
|
||||
imports.Proc(internale_CefRequest_SetUrl).Call(m.Instance(), api.PascalStr(url))
|
||||
}
|
||||
|
||||
// SetMethod 设置请求方式
|
||||
func (m *ICefRequest) SetMethod(method string) {
|
||||
cefRequest_SetMethod(m.Instance(), method)
|
||||
imports.Proc(internale_CefRequest_SetMethod).Call(m.Instance(), api.PascalStr(method))
|
||||
}
|
||||
|
||||
// SetReferrer 设置来源策略
|
||||
func (m *ICefRequest) SetReferrer(referrerUrl string, policy TCefReferrerPolicy) {
|
||||
cefRequest_SetReferrer(m.Instance(), referrerUrl, policy)
|
||||
imports.Proc(internale_CefRequest_SetReferrer).Call(m.Instance(), api.PascalStr(referrerUrl), policy.ToPtr())
|
||||
}
|
||||
|
||||
// SetFlags 设置请求标记
|
||||
func (m *ICefRequest) SetFlags(flags TCefUrlRequestFlags) {
|
||||
cefRequest_SetFlags(m.Instance(), flags)
|
||||
imports.Proc(internale_CefRequest_SetFlags).Call(m.Instance(), flags.ToPtr())
|
||||
}
|
||||
|
||||
// SetFirstPartyForCookies
|
||||
func (m *ICefRequest) SetFirstPartyForCookies(url string) {
|
||||
cefRequest_SetFirstPartyForCookies(m.Instance(), url)
|
||||
imports.Proc(internale_CefRequest_SetFirstPartyForCookies).Call(m.Instance(), api.PascalStr(url))
|
||||
}
|
||||
|
||||
// GetHeaderByName
|
||||
func (m *ICefRequest) GetHeaderByName(name string) string {
|
||||
return api.GoStr(cefRequest_GetHeaderByName(m.Instance(), name))
|
||||
r1, _, _ := imports.Proc(internale_CefRequest_GetHeaderByName).Call(m.Instance(), api.PascalStr(name))
|
||||
return api.GoStr(r1)
|
||||
}
|
||||
|
||||
// SetHeaderByName
|
||||
func (m *ICefRequest) SetHeaderByName(name, value string, overwrite bool) {
|
||||
cefRequest_SetHeaderByName(m.Instance(), name, value, overwrite)
|
||||
imports.Proc(internale_CefRequest_SetHeaderByName).Call(m.Instance(), api.PascalStr(name), api.PascalStr(value), api.PascalBool(overwrite))
|
||||
}
|
||||
|
||||
// GetHeaderMap
|
||||
func (m *ICefRequest) GetHeaderMap() *ICefStringMultiMap {
|
||||
headerMap := &ICefStringMultiMap{}
|
||||
headerMap.instance = cefRequest_GetHeaderMap(m.Instance())
|
||||
headerMap.ptr = unsafe.Pointer(headerMap.instance)
|
||||
return headerMap
|
||||
var result uintptr
|
||||
imports.Proc(internale_CefRequest_GetHeaderMap).Call(m.Instance(), uintptr(unsafe.Pointer(&result)))
|
||||
return &ICefStringMultiMap{instance: unsafe.Pointer(result)}
|
||||
}
|
||||
|
||||
func (m *ICefRequest) SetHeaderMap(headerMap *ICefStringMultiMap) {
|
||||
cefRequest_SetHeaderMap(m.Instance(), headerMap.instance)
|
||||
imports.Proc(internale_CefRequest_SetHeaderMap).Call(m.Instance(), headerMap.Instance())
|
||||
}
|
||||
|
||||
// request
|
||||
func cefRequest_IsReadOnly(instance uintptr) uintptr {
|
||||
r1, _, _ := imports.Proc(internale_cefRequest_IsReadOnly).Call(instance)
|
||||
return r1
|
||||
func (m *ICefRequest) GetPostData() *ICefPostData {
|
||||
var result uintptr
|
||||
imports.Proc(internale_CefRequest_GetPostData).Call(m.Instance(), uintptr(unsafe.Pointer(&result)))
|
||||
return &ICefPostData{instance: unsafe.Pointer(result)}
|
||||
}
|
||||
|
||||
func cefRequest_SetUrl(instance uintptr, url string) {
|
||||
imports.Proc(internale_cefRequest_SetUrl).Call(instance, api.PascalStr(url))
|
||||
}
|
||||
|
||||
func cefRequest_SetMethod(instance uintptr, method string) {
|
||||
imports.Proc(internale_cefRequest_SetMethod).Call(instance, api.PascalStr(method))
|
||||
}
|
||||
|
||||
func cefRequest_SetReferrer(instance uintptr, referrerUrl string, policy TCefReferrerPolicy) {
|
||||
imports.Proc(internale_cefRequest_SetReferrer).Call(instance, api.PascalStr(referrerUrl), uintptr(policy))
|
||||
}
|
||||
|
||||
func cefRequest_SetFlags(instance uintptr, flags TCefUrlRequestFlags) {
|
||||
imports.Proc(internale_cefRequest_SetFlags).Call(instance, uintptr(flags))
|
||||
}
|
||||
|
||||
func cefRequest_SetFirstPartyForCookies(instance uintptr, url string) {
|
||||
imports.Proc(internale_cefRequest_SetFirstPartyForCookies).Call(instance, api.PascalStr(url))
|
||||
}
|
||||
|
||||
func cefRequest_GetHeaderByName(instance uintptr, name string) uintptr {
|
||||
r1, _, _ := imports.Proc(internale_cefRequest_GetHeaderByName).Call(instance, api.PascalStr(name))
|
||||
return r1
|
||||
}
|
||||
|
||||
func cefRequest_SetHeaderByName(instance uintptr, url, value string, overwrite bool) {
|
||||
imports.Proc(internale_cefRequest_SetHeaderByName).Call(instance, api.PascalStr(url), api.PascalStr(value), api.PascalBool(overwrite))
|
||||
}
|
||||
|
||||
func cefRequest_GetHeaderMap(instance uintptr) uintptr {
|
||||
r1, _, _ := imports.Proc(internale_cefRequest_GetHeaderMap).Call(instance)
|
||||
return r1
|
||||
}
|
||||
|
||||
func cefRequest_SetHeaderMap(instance, headerMap uintptr) uintptr {
|
||||
r1, _, _ := imports.Proc(internale_cefRequest_SetHeaderMap).Call(instance, headerMap)
|
||||
return r1
|
||||
func (m *ICefRequest) SetPostData(value *ICefPostData) {
|
||||
imports.Proc(internale_CefRequest_SetPostData).Call(m.Instance(), value.Instance())
|
||||
}
|
||||
|
@ -15,7 +15,6 @@ import (
|
||||
"github.com/energye/energy/common/imports"
|
||||
. "github.com/energye/energy/consts"
|
||||
"github.com/energye/golcl/lcl/api"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// IsReadOnly 是否只读
|
||||
@ -65,10 +64,11 @@ func (m *ICefResponse) SetHeaderByName(name, value string, overwrite bool) {
|
||||
|
||||
// GetHeaderMap
|
||||
func (m *ICefResponse) GetHeaderMap() *ICefStringMultiMap {
|
||||
headerMap := &ICefStringMultiMap{}
|
||||
headerMap.instance = cefResponse_GetHeaderMap(uintptr(m.instance))
|
||||
headerMap.ptr = unsafe.Pointer(headerMap.instance)
|
||||
return headerMap
|
||||
//headerMap := &ICefStringMultiMap{}
|
||||
//headerMap.instance = cefResponse_GetHeaderMap(uintptr(m.instance))
|
||||
//headerMap.ptr = unsafe.Pointer(headerMap.instance)
|
||||
//return headerMap
|
||||
return nil // TODO dev
|
||||
}
|
||||
|
||||
func cefResponse_IsReadOnly(instance uintptr) uintptr {
|
||||
|
@ -19,69 +19,54 @@ import (
|
||||
|
||||
// ICefStringMultiMap 实例
|
||||
type ICefStringMultiMap struct {
|
||||
instance uintptr
|
||||
ptr unsafe.Pointer
|
||||
instance unsafe.Pointer
|
||||
}
|
||||
|
||||
// Instance 实例
|
||||
func (m *ICefStringMultiMap) Instance() uintptr {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
return uintptr(m.instance)
|
||||
}
|
||||
|
||||
// GetSize 大小
|
||||
func (m *ICefStringMultiMap) GetSize() int {
|
||||
return cefHeaderMap_GetSize(m.instance)
|
||||
func (m *ICefStringMultiMap) GetSize() int32 {
|
||||
r1, _, _ := imports.Proc(internale_StringMultimap_GetSize).Call(m.Instance())
|
||||
return int32(r1)
|
||||
}
|
||||
|
||||
// FindCount key值数量
|
||||
func (m *ICefStringMultiMap) FindCount(key string) int {
|
||||
return cefHeaderMap_FindCount(m.instance, key)
|
||||
func (m *ICefStringMultiMap) FindCount(key string) int32 {
|
||||
r1, _, _ := imports.Proc(internale_StringMultimap_FindCount).Call(m.Instance(), api.PascalStr(key))
|
||||
return int32(r1)
|
||||
}
|
||||
|
||||
// GetEnumerate 根据key & index获取枚举
|
||||
func (m *ICefStringMultiMap) GetEnumerate(key string, valueIndex int) string {
|
||||
return api.GoStr(cefHeaderMap_GetEnumerate(m.instance, key, valueIndex))
|
||||
// GetEnumerate 根据 key and index 获取
|
||||
func (m *ICefStringMultiMap) GetEnumerate(key string, valueIndex int32) string {
|
||||
r1, _, _ := imports.Proc(internale_StringMultimap_GetEnumerate).Call(m.Instance(), api.PascalStr(key), uintptr(valueIndex))
|
||||
return api.GoStr(r1)
|
||||
}
|
||||
|
||||
// GetKey 根据 index 获取key
|
||||
func (m *ICefStringMultiMap) GetKey(index int) string {
|
||||
return api.GoStr(cefHeaderMap_GetKey(m.instance, index))
|
||||
func (m *ICefStringMultiMap) GetKey(index int32) string {
|
||||
r1, _, _ := imports.Proc(internale_StringMultimap_GetKey).Call(m.Instance(), uintptr(index))
|
||||
return api.GoStr(r1)
|
||||
}
|
||||
|
||||
// GetValue 根据 index 获取value
|
||||
func (m *ICefStringMultiMap) GetValue(index int) string {
|
||||
return api.GoStr(cefHeaderMap_GetValue(m.instance, index))
|
||||
func (m *ICefStringMultiMap) GetValue(index int32) string {
|
||||
r1, _, _ := imports.Proc(internale_StringMultimap_GetValue).Call(m.Instance(), uintptr(index))
|
||||
return api.GoStr(r1)
|
||||
}
|
||||
|
||||
// Append 给key追加值
|
||||
func (m *ICefStringMultiMap) Append(key, value string) bool {
|
||||
return api.GoBool(cefHeaderMap_Append(m.instance, key, value))
|
||||
r1, _, _ := imports.Proc(internale_StringMultimap_Append).Call(m.Instance(), api.PascalStr(key), api.PascalStr(value))
|
||||
return api.GoBool(r1)
|
||||
}
|
||||
|
||||
// Clear 清空
|
||||
func (m *ICefStringMultiMap) Clear() {
|
||||
cefHeaderMap_Clear(m.instance)
|
||||
}
|
||||
|
||||
func cefHeaderMap_GetSize(instance uintptr) int {
|
||||
r1, _, _ := imports.Proc(internale_cefHeaderMap_GetSize).Call(instance)
|
||||
return int(r1)
|
||||
}
|
||||
func cefHeaderMap_FindCount(instance uintptr, key string) int {
|
||||
r1, _, _ := imports.Proc(internale_cefHeaderMap_FindCount).Call(instance, api.PascalStr(key))
|
||||
return int(r1)
|
||||
}
|
||||
func cefHeaderMap_GetEnumerate(instance uintptr, key string, valueIndex int) uintptr {
|
||||
r1, _, _ := imports.Proc(internale_cefHeaderMap_GetEnumerate).Call(instance, api.PascalStr(key), uintptr(valueIndex))
|
||||
return r1
|
||||
}
|
||||
func cefHeaderMap_GetKey(instance uintptr, index int) uintptr {
|
||||
r1, _, _ := imports.Proc(internale_cefHeaderMap_GetKey).Call(instance, uintptr(index))
|
||||
return r1
|
||||
}
|
||||
func cefHeaderMap_GetValue(instance uintptr, index int) uintptr {
|
||||
r1, _, _ := imports.Proc(internale_cefHeaderMap_GetValue).Call(instance, uintptr(index))
|
||||
return r1
|
||||
}
|
||||
func cefHeaderMap_Append(instance uintptr, key, value string) uintptr {
|
||||
r1, _, _ := imports.Proc(internale_cefHeaderMap_Append).Call(instance, api.PascalStr(key), api.PascalStr(value))
|
||||
return r1
|
||||
}
|
||||
func cefHeaderMap_Clear(instance uintptr) {
|
||||
imports.Proc(internale_cefHeaderMap_Clear).Call(instance)
|
||||
imports.Proc(internale_StringMultimap_Clear).Call(m.Instance())
|
||||
}
|
||||
|
9
cef/cef-types-post-data.go
Normal file
9
cef/cef-types-post-data.go
Normal file
@ -0,0 +1,9 @@
|
||||
package cef
|
||||
|
||||
// Instance 实例
|
||||
func (m *ICefPostData) Instance() uintptr {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
return uintptr(m.instance)
|
||||
}
|
@ -246,6 +246,11 @@ type ICefResponse struct {
|
||||
URL string
|
||||
}
|
||||
|
||||
// ICefPostData
|
||||
type ICefPostData struct {
|
||||
instance unsafe.Pointer
|
||||
}
|
||||
|
||||
// ICefView
|
||||
type ICefView struct {
|
||||
instance unsafe.Pointer
|
||||
@ -296,6 +301,7 @@ type ICefV8ArrayBufferReleaseCallback struct {
|
||||
instance unsafe.Pointer
|
||||
}
|
||||
|
||||
// Exception 异常返回信息
|
||||
type Exception struct {
|
||||
message string
|
||||
}
|
||||
|
@ -429,13 +429,12 @@ func AppBrowserInit() {
|
||||
}
|
||||
})
|
||||
event.SetOnBeforeResourceLoad(func(sender lcl.IObject, browser *cef.ICefBrowser, frame *cef.ICefFrame, request *cef.ICefRequest, callback *cef.ICefCallback, result *consts.TCefReturnValue) {
|
||||
//fmt.Println("SetOnBeforeResourceLoad:", request.Url, request.Method, "headerMap:", request.GetHeaderMap().GetSize())
|
||||
//headerMap := request.GetHeaderMap()
|
||||
//fmt.Println("\t", request.GetHeaderByName("energy"), headerMap.GetEnumerate("energy", 1), "size:", headerMap.GetSize())
|
||||
//for i := 0; i < headerMap.GetSize(); i++ {
|
||||
// fmt.Println("\tkey:", headerMap.GetKey(i), "value:", headerMap.GetValue(i))
|
||||
//}
|
||||
|
||||
fmt.Println("SetOnBeforeResourceLoad:", request.Url, request.Method, "headerMap:", request.GetHeaderMap().GetSize())
|
||||
headerMap := request.GetHeaderMap()
|
||||
fmt.Println("\t", request.GetHeaderByName("energy"), headerMap.GetEnumerate("energy", 1), "size:", headerMap.GetSize())
|
||||
for i := 0; i < int(headerMap.GetSize()); i++ {
|
||||
fmt.Println("\tkey:", headerMap.GetKey(int32(i)), "value:", headerMap.GetValue(int32(i)))
|
||||
}
|
||||
})
|
||||
})
|
||||
//添加子窗口初始化
|
||||
|
Loading…
Reference in New Issue
Block a user