Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
energye
energy
提交
769031ae
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,发现更多精彩内容 >>
提交
769031ae
编写于
8月 21, 2023
作者:
yanghye
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改 liblcl版本升级检查示例
上级
1473ccf4
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
10 addition
and
26 deletion
+10
-26
example/lib-checkupdate/main.go
example/lib-checkupdate/main.go
+10
-26
未找到文件。
example/lib-checkupdate/main.go
浏览文件 @
769031ae
...
...
@@ -5,10 +5,8 @@ package main
import
(
"archive/zip"
"embed"
"fmt"
"github.com/energye/energy/v2/cef/i18n"
"github.com/energye/energy/v2/cmd/autoupdate"
"github.com/energye/energy/v2/common"
"github.com/energye/energy/v2/common/imports"
"github.com/energye/energy/v2/consts"
"github.com/energye/energy/v2/example/lib-checkupdate/form"
...
...
@@ -42,9 +40,6 @@ var (
// form
updateForm
*
form
.
UpdateForm
version
=
[]
*
dllimports
.
ImportTable
{
dllimports
.
NewEnergyImport
(
""
,
0
),
//空导入
dllimports
.
NewEnergyImport
(
"LibVersion"
,
0
),
//获取lib库的版本号
dllimports
.
NewEnergyImport
(
"LibBuildVersion"
,
0
),
//获取lib库的构建工具版本
dllimports
.
NewEnergyImport
(
"Interface_CustomWidgetSetInitialization"
,
0
),
//linux lcl widget init
}
)
...
...
@@ -90,7 +85,7 @@ func main() {
// 初始化golcl
inits
.
Init
(
nil
,
&
resources
)
// inits.Init 完成之后,初始化LCL控件
imports
.
Proc
(
3
)
.
Call
()
imports
.
Proc
(
0
)
.
Call
()
// 注入资源
i18n
.
SetLocalFS
(
&
resources
,
"resources"
)
//i18n.Switch(consts.LANGUAGE_en_US)
...
...
@@ -100,17 +95,6 @@ func main() {
// 如果 liblcl 有更新该函数将被回调,并创建更新窗口
autoupdate
.
CanUpdateLiblcl
=
func
(
model
*
autoupdate
.
Model
,
level
int
,
canUpdate
bool
)
{
updateVersion
:=
model
.
Versions
[
model
.
Latest
]
var
energyLiblcl
=
func
()
(
string
,
bool
)
{
if
common
.
IsWindows
()
{
return
fmt
.
Sprintf
(
"Windows %d bits"
,
strconv
.
IntSize
),
true
}
else
if
common
.
IsLinux
()
{
return
"Linux x86 64 bits"
,
true
}
else
if
common
.
IsDarwin
()
{
return
"MacOSX x86 64 bits"
,
true
}
//not support download
return
fmt
.
Sprintf
(
"%v %v"
,
runtime
.
GOOS
,
runtime
.
GOARCH
),
false
}
// 这里使用窗口形式展示更新
// 运行应用后窗口创建时回调
...
...
@@ -219,16 +203,16 @@ func main() {
m
.
UpdateContentMemo
.
Lines
()
.
Add
(
i18n
.
Resource
(
"currentVersion"
)
+
": "
+
model
.
CurrentVersion
)
m
.
UpdateContentMemo
.
Lines
()
.
Add
(
i18n
.
Resource
(
"latestVersion"
)
+
": "
+
model
.
Latest
)
m
.
UpdateContentMemo
.
SetEnabled
(
false
)
}
else
if
canUpdate
{
// 有更新
}
else
{
// 有更新
m
.
UpdateContentMemo
.
SetScrollBars
(
types
.
SsAutoBoth
)
m
.
UpdateContentMemo
.
Lines
()
.
Add
(
i18n
.
Resource
(
"updateContent"
)
+
" "
+
model
.
Latest
)
for
i
,
content
:=
range
updateVersion
.
Content
{
m
.
UpdateContentMemo
.
Lines
()
.
Add
(
" "
+
strconv
.
Itoa
(
i
+
1
)
+
". "
+
content
)
}
m
.
UpdateContentMemo
.
Lines
()
.
Add
(
updateVersion
.
Content
)
// liblcl 下载版本URL
liblclZipName
,
_
:=
energyLiblcl
()
downUrl
:=
strings
.
Replace
(
model
.
Download
.
Url
,
"{url}"
,
model
.
Download
.
Source
[
model
.
Download
.
SourceSelect
],
-
1
)
// 使用配置的下载源
downUrl
=
strings
.
Replace
(
downUrl
,
"{version}"
,
updateVersion
.
EnergyVersion
,
-
1
)
// liblcl 所属的 enregy 版本
liblclZipName
,
_
:=
autoupdate
.
LibLCLName
(
model
.
Latest
,
updateVersion
.
BuildSupportOSArch
)
downSource
:=
strings
.
Split
(
updateVersion
.
DownloadSource
,
","
)
downUrl
:=
strings
.
Replace
(
updateVersion
.
DownloadUrl
,
"{source}"
,
downSource
[
updateVersion
.
DownloadSourceSelect
],
-
1
)
// 使用配置的下载源
downUrl
=
strings
.
Replace
(
downUrl
,
"{version}"
,
updateVersion
.
Version
,
-
1
)
// liblcl 所属的 enregy 版本
downUrl
=
strings
.
Replace
(
downUrl
,
"{module}"
,
updateVersion
.
Module
,
-
1
)
// 模块名
downUrl
=
strings
.
Replace
(
downUrl
,
"{OSARCH}"
,
liblclZipName
,
-
1
)
// 根据系统架构获取对应的文件名
m
.
UpdateContentMemo
.
Lines
()
.
Add
(
""
)
m
.
UpdateContentMemo
.
Lines
()
.
Add
(
i18n
.
Resource
(
"downloadURL"
))
...
...
@@ -280,7 +264,7 @@ func main() {
updateBtn
.
SetEnabled
(
isNotDownload
)
var
savePath
,
_
=
filepath
.
Split
(
libPath
)
var
fileName
,
_
=
energyLiblcl
(
)
var
fileName
,
_
=
autoupdate
.
LibLCLName
(
model
.
Latest
,
updateVersion
.
BuildSupportOSArch
)
var
saveFilePath
=
filepath
.
Join
(
savePath
,
fileName
)
+
".zip"
// zip
m
.
UpdateContentMemo
.
Lines
()
.
Add
(
"---------------------------------------------------------------"
)
m
.
UpdateContentMemo
.
Lines
()
.
Add
(
i18n
.
Resource
(
"beginDownload"
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录