Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
energye
energy
提交
bafaf363
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 搜索 >>
提交
bafaf363
编写于
6月 03, 2023
作者:
yanghye
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
up: auto update
上级
381b5de5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
179 addition
and
1 deletion
+179
-1
cef/autoupdate/README.md
cef/autoupdate/README.md
+101
-0
cef/autoupdate/autoupdate.go
cef/autoupdate/autoupdate.go
+63
-1
cef/autoupdate/internal/internal.go
cef/autoupdate/internal/internal.go
+15
-0
未找到文件。
cef/autoupdate/README.md
0 → 100644
浏览文件 @
bafaf363
### energy lib framework auto update
#### Divided into three modules
*
liblcl
*
enregy
*
cef
#### Control whether to enable the module update based on enable
#### Field description
> first level node is the module name
>
> download: module download source
>
> url: module download source url template
>
> source: module download source, addrs
>
> sourceSelect: Download the address source selection, select the source based on the index, and replace it with the Url template
>
> enable: module update based on enable
>
> latest: module latest version
>
> versions: version list
>
>> forced: forced update, a significant update that applies to the current version
>>
>> content: update logs
---
#### update json template
```
json
{
"liblcl"
:
{
"download"
:
{
"url"
:
"https://{url}/energye/energy/releases/download/{version}/{OSARCH}.zip"
,
"source"
:
[
"gitee.com"
,
"github.com"
],
"sourceSelect"
:
0
},
"enable"
:
true
,
"latest"
:
"version.1"
,
"versions"
:
{
"version.1"
:
{
"content"
:
[
"update log 1"
,
"update log 2"
],
"forced"
:
false
},
"version.0"
:
{
"content"
:
[
""
],
"forcede"
:
false
}
}
},
"energy"
:
{
"download"
:
{
"url"
:
""
,
"source"
:
[],
"sourceSelect"
:
0
},
"enable"
:
false
,
"latest"
:
""
,
"versions"
:
{
""
:
{
"content"
:
[
""
],
"forcede"
:
false
}
}
},
"cef"
:
{
"download"
:
{
"url"
:
""
,
"source"
:
[
""
],
"sourceSelect"
:
0
},
"enable"
:
false
,
"latest"
:
""
,
"versions"
:
{
""
:
{
"content"
:
[
""
],
"forcede"
:
false
}
}
}
}
```
---
\ No newline at end of file
cef/autoupdate/autoupdate.go
浏览文件 @
bafaf363
...
...
@@ -11,11 +11,49 @@
// Package autoupdate Energy check auto update
package
autoupdate
import
(
"crypto/tls"
"encoding/json"
"fmt"
"github.com/energye/energy/v2/cef/autoupdate/internal"
"io/ioutil"
"net/http"
"time"
)
var
(
// 检查更新开关, 默认关闭
isCheckUpdate
=
false
)
// 更新模块
type
update
struct
{
Liblcl
model
`json:"liblcl"`
Energy
model
`json:"energy"`
CEF
model
`json:"cef"`
}
// 模块
type
model
struct
{
Latest
string
`json:"latest"`
// 最新版本
Download
download
`json:"download"`
// 下载源
Enable
bool
`json:"enable"`
// 是否开启该模块更新
Versions
map
[
string
]
versionInfo
`json:"versions"`
// 当前模块所有版本集合 key=版本, value=版本信息
}
// 更新下载源
type
download
struct
{
Url
string
`json:"url"`
// 下载地址模板 https://{url}/energye/energy/releases/download/{version}/{OSARCH}.zip
Source
[]
string
`json:"source"`
// 下载地址源 ["gitee.com", "github.com"]
SourceSelect
uint8
`json:"sourceSelect"`
// 下载地址源选择, 根据下标(index)选择源(Source), 替换到(Url)模板
}
// 版本信息
type
versionInfo
struct
{
Content
[]
string
`json:"content"`
// 更新内容
Forced
bool
`json:"forced"`
// 强制更新, 适用当前版本的启作用
}
// CheckUpdate
// 检查更新, isCheckUpdate 为true时
func
CheckUpdate
()
{
...
...
@@ -35,7 +73,31 @@ func UpdateLog() []string {
}
func
check
()
{
client
:=
&
http
.
Client
{
Timeout
:
5
*
time
.
Second
,
Transport
:
&
http
.
Transport
{
TLSClientConfig
:
&
tls
.
Config
{
InsecureSkipVerify
:
true
},
}}
request
,
err
:=
http
.
NewRequest
(
"GET"
,
internal
.
CheckURL
,
nil
)
if
err
!=
nil
{
println
(
"energy check update http.NewRequest error:"
,
err
.
Error
())
return
}
response
,
err
:=
client
.
Do
(
request
)
if
err
!=
nil
{
println
(
"energy check update client.Do error:"
,
err
.
Error
())
return
}
defer
response
.
Body
.
Close
()
if
data
,
err
:=
ioutil
.
ReadAll
(
response
.
Body
);
err
==
nil
{
//var v map[string]any
var
v
=
update
{}
if
err
=
json
.
Unmarshal
(
data
,
&
v
);
err
==
nil
{
fmt
.
Printf
(
"data: %+v
\n
"
,
v
)
}
else
{
println
(
"energy check update json.Unmarshal error"
,
err
.
Error
())
}
}
else
{
println
(
"energy check update ioutil.ReadAl(response.Body) error"
,
err
.
Error
())
}
}
func
updatePrompt
()
{
...
...
cef/autoupdate/internal/internal.go
0 → 100644
浏览文件 @
bafaf363
//----------------------------------------
//
// Copyright © yanghy. All Rights Reserved.
//
// Licensed under Apache License Version 2.0, January 2004
//
// https://www.apache.org/licenses/LICENSE-2.0
//
//----------------------------------------
package
internal
const
(
CheckURL
=
"https://energy.yanghy.cn/autoconfig/update.json"
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录