实现自动下载升级版本
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
<div class="ui icon message error" v-if="!isLoading && newVersionCode.length > 0">
|
||||
<i class="icon warning circle"></i>
|
||||
升级提醒:有新版本管理系统可以更新:v{{currentVersionCode}} -> v{{newVersionCode}}
|
||||
<a href="https://goedge.cn/docs/Releases/Index.md?nav=1" target="_blank">[去官网查看]</a> <a :href="newVersionDownloadURL" target="_blank">[直接下载]</a>
|
||||
<a href="/settings/updates?doCheck=1">[查看详情]</a>
|
||||
|
||||
<a href="" title="关闭" @click.prevent="closeMessage"><i class="ui icon remove small"></i></a>
|
||||
</div>
|
||||
|
||||
5
web/views/@default/settings/updates/index.css
Normal file
5
web/views/@default/settings/updates/index.css
Normal file
@@ -0,0 +1,5 @@
|
||||
.version-box {
|
||||
line-height: 1.8;
|
||||
color: #21ba45;
|
||||
}
|
||||
/*# sourceMappingURL=index.css.map */
|
||||
1
web/views/@default/settings/updates/index.css.map
Normal file
1
web/views/@default/settings/updates/index.css.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["index.less"],"names":[],"mappings":"AAAA;EACC,gBAAA;EACA,cAAA","file":"index.css"}
|
||||
@@ -1,32 +1,68 @@
|
||||
{$layout}
|
||||
|
||||
<div class="ui margin"></div>
|
||||
<form class="ui form">
|
||||
<table class="ui table definition selectable">
|
||||
<tr>
|
||||
<td class="title">当前已安装版本</td>
|
||||
<td>v{{version}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>自动检查</td>
|
||||
<td>
|
||||
<checkbox v-model="config.autoCheck" @input="changeAutoCheck"></checkbox>
|
||||
<p class="comment">选中后系统将定时检查是否有新版本更新。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="isStarted">
|
||||
<td>最新版本</td>
|
||||
<td>
|
||||
<div v-if="isChecking">
|
||||
<span class="blue">正在连接服务器检查更新...</span>
|
||||
</div>
|
||||
<div v-if="!isChecking">
|
||||
<span class="green" v-if="result.isOk">{{result.message}}<span v-if="result.hasNew">:<br/><a :href="result.dlURL">下载地址:{{result.dlURL}}</a> </span></span>
|
||||
<span class="red" v-if="!result.isOk">{{result.message}}</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<button class="ui button primary" type="button" @click.prevent="start">开始检查</button>
|
||||
</form>
|
||||
<div v-show="isUpgrading">
|
||||
<p class="ui message warning">正在下载升级到新版本,请耐心等待 {{upgradeProgress}}%...</p>
|
||||
</div>
|
||||
|
||||
<div v-show="!isUpgrading">
|
||||
<form class="ui form">
|
||||
<table class="ui table definition selectable">
|
||||
<tr>
|
||||
<td class="title">当前已安装版本</td>
|
||||
<td>v{{version}}</td>
|
||||
</tr>
|
||||
<tr v-if="config.ignoredVersion.length > 0">
|
||||
<td>已忽略版本</td>
|
||||
<td>
|
||||
v{{config.ignoredVersion}} <a href="" style="font-size: 0.8em" @click.prevent="resetIgnoredVersion()">[重置]</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>自动检查</td>
|
||||
<td>
|
||||
<checkbox v-model="config.autoCheck" @input="changeAutoCheck"></checkbox>
|
||||
<p class="comment">选中后系统将定时检查是否有新版本更新。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="isStarted">
|
||||
<td>最新版本</td>
|
||||
<td>
|
||||
<div v-if="isChecking">
|
||||
<span class="blue">正在连接服务器检查更新...</span>
|
||||
</div>
|
||||
<div v-if="!isChecking">
|
||||
<div class="version-box" v-if="result.isOk">
|
||||
<span class="green">{{result.message}}
|
||||
<span v-if="result.hasNew">:<br/><a :href="result.dlURL">下载地址:{{result.dlURL}}</a> </span>
|
||||
</span>
|
||||
<div v-if="result.hasNew">
|
||||
<div class="ui divider"></div>
|
||||
|
||||
<!-- 操作按钮 -->
|
||||
<button class="ui button tiny" type="button" @click.prevent="install(result.dlURL)">安装此版本</button>
|
||||
|
||||
<button class="ui button tiny basic" type="button" @click.prevent="ignoreVersion(result.version)">忽略此版本</button>
|
||||
<div class="ui divider"></div>
|
||||
|
||||
<div v-if="result.day != null && result.day.length > 0">发布日期:{{result.day}}</div>
|
||||
<div v-if="result.description != null && result.description.length > 0">
|
||||
版本介绍:<pre>{{result.description}}</pre>
|
||||
<div v-if="result.docURL != null && result.docURL.length > 0">
|
||||
<div class="ui divider"></div>
|
||||
<div>完整变更说明:<a :href="result.docURL" target="_blank">{{result.docURL}}</a> </div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<span class="red" v-if="!result.isOk">{{result.message}}</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<button class="ui button primary" type="button" @click.prevent="start" v-show="!isChecking">开始检查</button>
|
||||
<button class="ui button disabled" type="button" v-show="isChecking">正在检查...</button>
|
||||
</form>
|
||||
</div>
|
||||
@@ -1,8 +1,14 @@
|
||||
Tea.context(function () {
|
||||
this.isStarted = false
|
||||
this.isChecking = true
|
||||
this.isChecking = false
|
||||
this.result = {isOk: false, message: "", hasNew: false, dlURL: ""}
|
||||
|
||||
this.$delay(function () {
|
||||
if (this.doCheck) {
|
||||
this.start()
|
||||
}
|
||||
})
|
||||
|
||||
this.start = function () {
|
||||
this.isStarted = true
|
||||
this.isChecking = true
|
||||
@@ -28,4 +34,61 @@ Tea.context(function () {
|
||||
autoCheck: this.config.autoCheck ? 1 : 0
|
||||
})
|
||||
}
|
||||
|
||||
this.ignoreVersion = function (version) {
|
||||
teaweb.confirm("确定要忽略版本 v" + version + " 版本更新吗?", function () {
|
||||
this.$post(".ignoreVersion")
|
||||
.params({version: version})
|
||||
.success(function () {
|
||||
teaweb.reload()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
this.resetIgnoredVersion = function (version) {
|
||||
teaweb.confirm("确定要重置已忽略版本吗?", function () {
|
||||
this.$post(".resetIgnoredVersion")
|
||||
.success(function () {
|
||||
teaweb.reload()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
this.install = function (dlURL) {
|
||||
this.$post(".upgrade")
|
||||
.params({
|
||||
url: dlURL
|
||||
})
|
||||
.timeout(3600)
|
||||
.success(function () {
|
||||
teaweb.success("下载覆盖成功,系统将会尝试自动重启,请刷新页面查看重启状态。如果没能重启成功,请手动使用命令重启。", function () {
|
||||
teaweb.reload()
|
||||
})
|
||||
})
|
||||
|
||||
this.isUpgrading = true
|
||||
this.updateUpgradeProgress()
|
||||
}
|
||||
|
||||
if (this.isUpgrading) {
|
||||
this.$delay(function () {
|
||||
this.updateUpgradeProgress()
|
||||
})
|
||||
}
|
||||
|
||||
this.updateUpgradeProgress = function () {
|
||||
if (!this.isUpgrading) {
|
||||
return
|
||||
}
|
||||
this.$get(".upgrade")
|
||||
.success(function (resp) {
|
||||
this.upgradeProgress = resp.data.upgradeProgress
|
||||
this.isUpgrading = resp.data.isUpgrading
|
||||
})
|
||||
.done(function () {
|
||||
this.$delay(function () {
|
||||
this.updateUpgradeProgress()
|
||||
}, 3000)
|
||||
})
|
||||
}
|
||||
})
|
||||
4
web/views/@default/settings/updates/index.less
Normal file
4
web/views/@default/settings/updates/index.less
Normal file
@@ -0,0 +1,4 @@
|
||||
.version-box {
|
||||
line-height: 1.8;
|
||||
color: #21ba45;
|
||||
}
|
||||
Reference in New Issue
Block a user