Skip to content

Commit 17e3199

Browse files
committed
v1.0.0 alpha
1 parent a0795dd commit 17e3199

File tree

4 files changed

+47
-25
lines changed

4 files changed

+47
-25
lines changed

backend/app.go

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ func (a *App) WailsShutdown() {
5454
//检查更新
5555
func (a *App) CheckUpdate() {
5656
var err error
57+
//我更新我自己
58+
if err = a.updateApp(); err != nil {
59+
a.noticeError(err.Error())
60+
}
61+
5762
//检查是否初始化,否则通知前端选择安装方式和位置
5863
if a.cfg.Init == false {
5964
a.doSelectOption()
@@ -110,7 +115,13 @@ func (a *App) checkState() error {
110115
} else if ok == true {
111116
a.cfg.HlaeState = true
112117
//解析修正本地hlae版本号
113-
if tVersion, err := api.ParseChangelog(a.cfg.HlaePath + "/changelog.xml"); err != nil {
118+
changelog, err := tool.ReadAll(a.cfg.HlaePath + "/changelog.xml")
119+
if err != nil {
120+
a.noticeError("读取本地版本号失败: " + err.Error())
121+
return err
122+
}
123+
if tVersion, err := api.ParseChangelog(changelog); err != nil {
124+
a.noticeError("解析本地版本号失败: " + err.Error())
114125
return err
115126
} else {
116127
a.cfg.HlaeVersion = tVersion
@@ -141,6 +152,12 @@ func (a *App) checkState() error {
141152
return nil
142153
}
143154

155+
//TODO 我更新我自己
156+
func (a *App) updateApp() error {
157+
158+
return nil
159+
}
160+
144161
//设定安装hlae的方式
145162
func (a *App) SetOption(ok bool) {
146163
a.cfg.Standalone = ok
@@ -580,10 +597,6 @@ func (a *App) updateFFmpeg() error {
580597
_, cdnFilename = filepath.Split(cdnURL)
581598
}
582599

583-
//对比版本号,决定是否更新
584-
if version == a.cfg.FFmpegVersion {
585-
return nil
586-
}
587600
//决定下载的文件
588601
if srcVersion == "" && cdnVersion == "" {
589602
return errors.New("FFmpeg官方和CDN的API均获取或解析失败")
@@ -604,6 +617,12 @@ func (a *App) updateFFmpeg() error {
604617
filename = srcFilename
605618
}
606619

620+
//对比版本号,决定是否更新
621+
//a.noticeWarning(version + " ? " + a.cfg.FFmpegVersion)
622+
if version == a.cfg.FFmpegVersion {
623+
return nil
624+
}
625+
607626
i += 100
608627
a.setProgress(i / count)
609628
a.setLog("正在下载FFmpeg安装包...")
@@ -651,14 +670,10 @@ func (a *App) updateFFmpeg() error {
651670
//启动HLAE
652671
func (a *App) LaunchHLAE() bool {
653672
if a.cfg.HlaeState == true {
654-
out, err := tool.Cmd("start " + a.cfg.HlaePath + "/hlae.exe")
655-
if err != nil {
656-
a.setLog(out)
657-
log.Println(out, err)
658-
return false
659-
}
673+
_ = a.runtime.Browser.OpenFile(a.cfg.HlaePath + "/hlae.exe")
660674
}
661-
return false
675+
676+
return true
662677
}
663678

664679
//打开HLAE文件夹

backend/config/default.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package config
22

33
var defaultCFG = CFG{
44
VersionCode: "Testify",
5-
AppVersion: "v0.0.2",
5+
AppVersion: "v0.0.4",
66
HlaeVersion: "",
77
FFmpegVersion: "",
88
HlaeAPI: "https://api.github.com/repos/advancedfx/advancedfx/releases/latest",

backend/wails.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,15 @@ func (a *App) doSelectOption() {
4343
func (a *App) noticeSuccess(msg string) {
4444
a.runtime.Events.Emit("NoticeSuccess", msg)
4545
}
46+
4647
func (a *App) noticeError(msg string) {
4748
a.runtime.Events.Emit("NoticeError", msg)
4849
}
50+
4951
func (a *App) noticeWarning(msg string) {
5052
a.runtime.Events.Emit("NoticeWarning", msg)
5153
}
5254

53-
//
5455
func (a *App) SelectDirectory() string {
5556
directory := a.runtime.Dialog.SelectDirectory()
5657
if ok, err := tool.IsFileExisted(directory); err != nil || !ok {

frontend/src/components/Main.vue

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
{{ log }}
2626
</div>
2727
<div class="btn-control">
28-
<a-button class="btn" size="large" @click="tabSetting">
28+
<a-button class="btn" size="large" @click="tabSetting" :loading="btnSetting">
2929
<!-- <a-icon type="setting" />-->
3030
<a-icon type="reload" />
3131
</a-button>
32-
<a-button class="btn" size="large" @click="openDirHLAE"><a-icon type="folder-open" /></a-button>
33-
<a-button class="btn" @click="launchHLAE" style="margin-right: 0;width: 36vw;font-size: 4.5vw;" size="large">打开HLAE</a-button>
32+
<a-button class="btn" size="large" @click="openDirHLAE"><a-icon type="folder-open" :loading="btnOpenDir" /></a-button>
33+
<a-button class="btn" @click="launchHLAE" style="margin-right: 0;width: 36vw;font-size: 4.5vw;" size="large" :loading="btnLaunchHLAE" >打开HLAE</a-button>
3434
</div>
3535
</div>
3636
</template>
@@ -43,10 +43,13 @@ export default {
4343
data() {
4444
return {
4545
versionCode: "Testify",
46-
appVersion: "v0.0.1",
46+
appVersion: "v1.0.0",
4747
progress: 0,
48-
log: " ",
48+
log: "",
4949
standalone: true,
50+
btnSetting: false,
51+
btnOpenDir: false,
52+
btnLaunchHLAE: false,
5053
};
5154
},
5255
mounted() {
@@ -83,11 +86,13 @@ export default {
8386
methods: {
8487
launchHLAE () {
8588
// console.log("启动HLAE");
89+
this.btnLaunchHLAE = true;
8690
window.backend.App.LaunchHLAE().then(ok => {
8791
if (ok === false) {
8892
this.$message.warning('HLAE启动失败', 5);
8993
}
9094
});
95+
this.btnLaunchHLAE = false;
9196
},
9297
tabSetting () {
9398
console.log("切换到设置Tab页"); //TODO
@@ -96,7 +101,9 @@ export default {
96101
},
97102
openDirHLAE () {
98103
// console.log("打开HLAE安装位置");
104+
this.btnOpenDir = true;
99105
window.backend.App.OpenHlaeDirectory();
106+
this.btnOpenDir = false;
100107
//发送wails信息->Go?
101108
// window.wails.Events.Emit("error", "这是一条错误信息!");
102109
},
@@ -105,25 +112,22 @@ export default {
105112
window.backend.App.CheckState();
106113
},
107114
selectOption() {
108-
//选择HLAE安装方法和安装位置 TODO: debug 默认选择是ok
109-
let standalone = false;
115+
//选择HLAE安装方法和安装位置
110116
this.$confirm({
111117
title: '选择HLAE和FFmpeg的安装方式',
112118
content: '附属安装:关联CSGO Demos Manager\n单独安装:单独选择位置安装',
113119
okText: '附属安装',
114120
cancelText: '单独安装',
115121
// bodyStyle: 'font-size: 20vw',
116122
onOk() {
117-
standalone = false;
118123
//选择完成,传给后端
119-
window.backend.App.SetOption(standalone);
124+
window.backend.App.SetOption(false);
120125
//安装/检查更新
121126
window.backend.App.CheckUpdate();
122127
},
123128
onCancel() {
124-
standalone = true;
125129
//选择完成,传给后端
126-
window.backend.App.SetOption(standalone);
130+
window.backend.App.SetOption(true);
127131
//安装/检查更新
128132
window.backend.App.CheckUpdate();
129133
},
@@ -132,7 +136,9 @@ export default {
132136
},
133137
checkUpdate () {
134138
// console.log("检查HLAE更新");
139+
this.btnOpenDir = true; //TODO 修改成update相关名称
135140
window.backend.App.CheckUpdate();
141+
this.btnOpenDir = false;
136142
}
137143
}
138144
}

0 commit comments

Comments
 (0)