Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
energye
energy
提交
feadef04
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,发现更多精彩内容 >>
提交
feadef04
编写于
8月 26, 2023
作者:
yanghye
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改内置资源XHR代理注释说明
上级
3694611b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
26 addition
and
18 deletion
+26
-18
cef/browser-config.go
cef/browser-config.go
+1
-0
cef/browser-window.go
cef/browser-window.go
+9
-5
cef/local-load-resource.go
cef/local-load-resource.go
+3
-0
cef/local-load-xhr-proxy.go
cef/local-load-xhr-proxy.go
+13
-13
未找到文件。
cef/browser-config.go
浏览文件 @
feadef04
...
...
@@ -27,6 +27,7 @@ type browserConfig struct {
// LocalResource
// 本地资源加载配置
// 在浏览器进程初始化
func
(
m
*
browserConfig
)
LocalResource
(
config
*
LocalLoadConfig
)
{
localLoadResourceInit
(
config
)
}
...
...
cef/browser-window.go
浏览文件 @
feadef04
...
...
@@ -35,11 +35,15 @@ type windowCurrentProperty struct {
// 提供部分窗口属性配置,初始化时生效
// 如需更多属性配置或自定义窗口行为请在`SetBrowserInit`回调函数中使用
type
WindowProperty
struct
{
IsShowModel
bool
// 是否以模态窗口显示
WindowInitState
types
.
TWindowState
// 窗口 初始状态: 最小化、最大化、全屏, 全屏时隐藏标题栏生效
WindowType
consts
.
WINDOW_TYPE
// 窗口 类型 WINDOW_TYPE default: WT_MAIN_BROWSER
Title
string
// 窗口 标题
Url
string
// 默认打开URL
IsShowModel
bool
// 是否以模态窗口显示
WindowInitState
types
.
TWindowState
// 窗口 初始状态: 最小化、最大化、全屏, 全屏时隐藏标题栏生效
WindowType
consts
.
WINDOW_TYPE
// 窗口 类型 WINDOW_TYPE default: WT_MAIN_BROWSER
Title
string
// 窗口 标题
//Url 默认打开URL, 支持http和LocalLoad(本地资源)加载方式
// http方式: http://www.example.com, LocalLoad方式: fs://energy/index.html, or file://energy/index.html
// http: 需要web服务支持, LocalLoad: 不需要web服务支持, 如果浏览器调用数据接口需要配置代理
// LocalLoad: 通过 Config.LocalResource 配置实现
Url
string
Icon
string
// 窗口图标 加载本地图标 local > /app/resources/icon.ico, VF窗口linux使用png
IconFS
string
// 窗口图标 加载emfs内置图标 emfs > resources/icon.ico, VF窗口linux使用png
EnableWebkitAppRegion
bool
//
...
...
cef/local-load-resource.go
浏览文件 @
feadef04
...
...
@@ -77,6 +77,9 @@ func localLoadResourceInit(config *LocalLoadConfig) {
localLoadRes
.
LocalLoadConfig
=
*
config
}
// Build
// 构建本地资源加载配置
// 初始化默认值和默认代理配置
func
(
m
LocalLoadConfig
)
Build
()
*
LocalLoadConfig
{
if
localLoadRes
!=
nil
&&
!
process
.
Args
.
IsMain
()
{
return
nil
...
...
cef/local-load-xhr-proxy.go
浏览文件 @
feadef04
...
...
@@ -188,10 +188,11 @@ func (m *XHRProxy) send(scheme string, request *ICefRequest) (*XHRProxyResponse,
if
err
!=
nil
{
return
nil
,
err
}
// 构造目标地址
targetUrl
:=
new
(
bytes
.
Buffer
)
targetUrl
.
WriteString
(
scheme
)
targetUrl
.
WriteString
(
m
.
IP
)
if
m
.
Port
>
0
{
if
m
.
Port
>
0
{
// ip:port
targetUrl
.
WriteString
(
":"
)
targetUrl
.
WriteString
(
strconv
.
Itoa
(
m
.
Port
))
}
...
...
@@ -199,10 +200,10 @@ func (m *XHRProxy) send(scheme string, request *ICefRequest) (*XHRProxyResponse,
targetUrl
.
WriteString
(
reqUrl
.
RawQuery
)
// 读取请求数据
requestData
:=
new
(
bytes
.
Buffer
)
postD
ata
:=
request
.
GetPostData
()
if
postD
ata
.
IsValid
()
{
dataCount
:=
int
(
postD
ata
.
GetElementCount
())
elements
:=
postD
ata
.
GetElements
()
d
ata
:=
request
.
GetPostData
()
if
d
ata
.
IsValid
()
{
dataCount
:=
int
(
d
ata
.
GetElementCount
())
elements
:=
d
ata
.
GetElements
()
for
i
:=
0
;
i
<
dataCount
;
i
++
{
element
:=
elements
.
Get
(
uint32
(
i
))
switch
element
.
GetType
()
{
...
...
@@ -220,10 +221,11 @@ func (m *XHRProxy) send(scheme string, request *ICefRequest) (*XHRProxyResponse,
}
element
.
Free
()
}
postD
ata
.
Free
()
d
ata
.
Free
()
}
logger
.
Debug
(
"XHRProxy TargetURL:"
,
targetUrl
.
String
(),
"method:"
,
request
.
Method
(),
"dataLength:"
,
len
(
requestData
.
Bytes
()))
httpRequest
,
err
:=
http
.
NewRequest
(
request
.
Method
(),
targetUrl
.
String
(),
requestData
)
tarUrl
:=
targetUrl
.
String
()
logger
.
Debug
(
"XHRProxy URL:"
,
tarUrl
,
"method:"
,
request
.
Method
(),
"length:"
,
requestData
.
Len
())
httpRequest
,
err
:=
http
.
NewRequest
(
request
.
Method
(),
tarUrl
,
requestData
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -241,11 +243,9 @@ func (m *XHRProxy) send(scheme string, request *ICefRequest) (*XHRProxyResponse,
}
header
.
Free
()
}
//httpRequest.Header.Add("Host", "energy.yanghy.cn")
//httpRequest.Header.Add("Origin", "https://energy.yanghy.cn")
//httpRequest.Header.Add("Referer", "https://energy.yanghy.cn/")
//httpRequest.Header.Add("Host", "www.example.com")
//httpRequest.Header.Add("Origin", "https://www.example.com")
//httpRequest.Header.Add("Referer", "https://www.example.com/")
httpResponse
,
err
:=
m
.
HttpClient
.
Client
.
Do
(
httpRequest
)
if
err
!=
nil
{
return
nil
,
err
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录