feat: sync httpdns sdk/platform updates without large binaries

This commit is contained in:
robin
2026-03-04 17:59:14 +08:00
parent 853897a6f8
commit 532891fad0
700 changed files with 6096 additions and 2712 deletions

View File

@@ -127,7 +127,7 @@
<td>
v{{node.status.buildVersion}}
&nbsp;
<a :href="'/httpdns/clusters/upgradeRemote?clusterId=' + clusterId + '&nodeId=' + node.id" v-if="shouldUpgrade"><span class="red">发现新版本 v{{newVersion}} &raquo;</span></a>
<a :href="'/httpdns/clusters/cluster/upgradeRemote?clusterId=' + clusterId" v-if="shouldUpgrade"><span class="red">发现新版本 v{{newVersion}} &raquo;</span></a>
</td>
</tr>
<tr v-if="node.status.exePath != null && node.status.exePath.length > 0">

View File

@@ -66,30 +66,37 @@
<tr>
<td>自动远程启动</td>
<td>
<div class="ui checkbox">
<input type="checkbox" name="autoRemoteStart" value="1" v-model="settings.autoRemoteStart" />
<label></label>
</div>
<checkbox name="autoRemoteStart" v-model="settings.autoRemoteStart"></checkbox>
<p class="comment">当检测到节点离线时自动尝试远程启动前提是节点已经设置了SSH登录认证</p>
</td>
</tr>
<tr>
<td>访问日志</td>
<td>
<div class="ui checkbox">
<input type="checkbox" name="accessLogIsOn" value="1" v-model="settings.accessLogIsOn" />
<label></label>
</div>
<checkbox name="accessLogIsOn" v-model="settings.accessLogIsOn"></checkbox>
<p class="comment">启用后HTTPDNS 节点将会记录客户端的请求访问日志。</p>
</td>
</tr>
<tr>
<td>时区</td>
<td>
<div>
<span class="ui label basic small" v-if="timeZoneLocation != null">当前:{{timeZoneLocation.name}}
({{timeZoneLocation.offset}})</span>
</div>
<div style="margin-top: 0.5em">
<select class="ui dropdown auto-width" name="timeZone" v-model="settings.timeZone">
<option v-for="tz in timeZoneLocations" :value="tz.name">{{tz.name}} ({{tz.offset}})
</option>
</select>
</div>
<p class="comment">HTTPDNS 节点进程使用的时区设置,默认为 Asia/Shanghai。</p>
</td>
</tr>
<tr>
<td>启用当前集群</td>
<td>
<div class="ui checkbox">
<input type="checkbox" name="isOn" value="1" v-model="settings.isOn" />
<label></label>
</div>
<checkbox name="isOn" v-model="settings.isOn"></checkbox>
<p class="comment">取消启用后,该集群不会参与 HTTPDNS 服务。</p>
</td>
</tr>
@@ -110,4 +117,4 @@
<submit-btn></submit-btn>
</form>
</div>
</div>

View File

@@ -7,4 +7,27 @@ Tea.context(function () {
if (!this.settings) {
this.settings = {}
}
let toBool = function (v) {
if (typeof v === "boolean") {
return v
}
if (typeof v === "number") {
return v === 1
}
if (typeof v === "string") {
let s = v.toLowerCase().trim()
return s === "1" || s === "true" || s === "on" || s === "yes" || s === "enabled"
}
return false
}
this.settings.autoRemoteStart = toBool(this.settings.autoRemoteStart)
this.settings.accessLogIsOn = toBool(this.settings.accessLogIsOn)
this.settings.isOn = toBool(this.settings.isOn)
if (!this.settings.timeZone || this.settings.timeZone.length == 0) {
this.settings.timeZone = "Asia/Shanghai"
}
})

View File

@@ -43,7 +43,7 @@
<tr>
<td>节点安装根目录</td>
<td>
<input type="text" name="installDir" maxlength="255" value="/opt/edge-httpdns" />
<input type="text" name="installDir" maxlength="255" value="/root/edge-httpdns" />
<p class="comment">边缘节点安装 HTTPDNS 服务的默认目录。</p>
</td>
</tr>
@@ -59,4 +59,4 @@
</tr>
</table>
<submit-btn></submit-btn>
</form>
</form>

View File

@@ -19,7 +19,7 @@
<tr>
<td>安装目录</td>
<td>
<input type="text" name="installDir" maxlength="100" :value="cluster.installDir || '/opt/edge-httpdns'" />
<input type="text" name="installDir" maxlength="100" :value="cluster.installDir || '/root/edge-httpdns'" />
<p class="comment">默认使用集群配置目录。</p>
</td>
</tr>

View File

@@ -51,6 +51,12 @@
:class="{red:cluster.countAllNodes > cluster.countActiveNodes}">{{cluster.countAllNodes}}</span>
</a>
<span class="disabled" v-else="">-</span>
<div v-if="cluster.countUpgradeNodes > 0" style="margin-top:0.5em">
<a :href="'/httpdns/clusters/cluster/upgradeRemote?clusterId=' + cluster.id" title="点击进入远程升级页面">
<span class="red">有{{cluster.countUpgradeNodes}}个节点需要升级</span>
</a>
</div>
</td>
<td class="center">
<a :href="'/httpdns/clusters/cluster?clusterId=' + cluster.id" v-if="cluster.countActiveNodes > 0">
@@ -67,4 +73,4 @@
</table>
<div class="page" v-html="page"></div>
</div>
</div>

View File

@@ -1,3 +1,62 @@
{$layout}
{$layout}
<p class="ui message error">姝ゅ姛鑳芥殏鏈紑鏀俱€?/p>
<p class="comment" v-if="nodes.length == 0">暂时没有需要升级的节点。</p>
<div v-if="nodes.length > 0">
<h3>
所有需要升级的节点
<button class="ui button primary tiny" v-if="countCheckedNodes() > 0" @click.prevent="installBatch()">批量升级({{countCheckedNodes()}})</button>
</h3>
<table class="ui table selectable celled">
<thead>
<tr>
<th style="width:3em">
<checkbox @input="checkNodes"></checkbox>
</th>
<th>节点名</th>
<th>访问IP</th>
<th>SSH地址</th>
<th>版本变化</th>
<th class="four wide">节点状态</th>
<th class="two op">操作</th>
</tr>
</thead>
<tbody>
<tr v-for="node in nodes">
<td>
<checkbox v-model="node.isChecked" v-if="node.installStatus == null || !node.installStatus.isOk"></checkbox>
</td>
<td>
<a :href="'/httpdns/clusters/cluster/node?clusterId=' + clusterId + '&nodeId=' + node.id">{{node.name}}</a>
<a :href="'/httpdns/clusters/cluster/node?clusterId=' + clusterId + '&nodeId=' + node.id" title="节点详情" style="margin-left: 0.4em">[详情]</a>
</td>
<td>
<span v-if="node.accessIP.length > 0" class="ui label tiny basic">{{node.accessIP}}</span>
<span v-else class="disabled">-</span>
</td>
<td>
<span v-if="node.login != null && node.login.type == 'ssh' && node.loginParams != null && node.loginParams.host != null && node.loginParams.host.length > 0">
{{node.loginParams.host}}:{{node.loginParams.port}}
</span>
<span v-else class="disabled">没有设置</span>
</td>
<td>v{{node.oldVersion}} -&gt; v{{node.newVersion}}</td>
<td>
<div v-if="node.installStatus != null && (node.installStatus.isRunning || node.installStatus.isFinished)">
<div v-if="node.installStatus.isRunning" class="blue">升级中...</div>
<div v-if="node.installStatus.isFinished">
<span v-if="node.installStatus.isOk" class="green">已升级成功</span>
<span v-if="!node.installStatus.isOk" class="red">升级过程中发生错误:{{node.installStatus.error}}</span>
</div>
</div>
<span v-else class="disabled">等待升级</span>
</td>
<td>
<a href="" @click.prevent="installNode(node)" v-if="!isInstalling">升级</a>
<span v-if="isInstalling && node.isInstalling">升级中...</span>
<span v-if="isInstalling && !node.isInstalling" class="disabled">升级</span>
</td>
</tr>
</tbody>
</table>
</div>

View File

@@ -0,0 +1,147 @@
Tea.context(function () {
this.isInstalling = false
this.isBatch = false
let installingNode = null
this.nodes.forEach(function (v) {
v.isChecked = false
})
this.$delay(function () {
this.reload()
})
let that = this
this.checkNodes = function (isChecked) {
this.nodes.forEach(function (v) {
v.isChecked = isChecked
})
}
this.countCheckedNodes = function () {
return that.nodes.$count(function (k, v) {
return v.isChecked
})
}
this.installNode = function (node) {
let that = this
if (this.isBatch) {
installingNode = node
that.isInstalling = true
node.isInstalling = true
that.$post("$")
.params({
nodeId: node.id
})
} else {
teaweb.confirm("确定要开始升级此节点吗?", function () {
installingNode = node
that.isInstalling = true
node.isInstalling = true
that.$post("$")
.params({
nodeId: node.id
})
})
}
}
this.installBatch = function () {
let that = this
this.isBatch = true
teaweb.confirm("确定要批量升级选中的节点吗?", function () {
that.installNext()
})
}
this.installNext = function () {
let nextNode = this.nodes.$find(function (k, v) {
return v.isChecked
})
if (nextNode == null) {
teaweb.success("全部升级成功", function () {
teaweb.reload()
})
} else {
this.installNode(nextNode)
}
return
}
this.reload = function () {
let that = this
if (installingNode != null) {
this.$post("/httpdns/clusters/upgradeStatus")
.params({
nodeId: installingNode.id
})
.success(function (resp) {
if (resp.data.status != null) {
installingNode.installStatus = resp.data.status
if (installingNode.installStatus.isFinished) {
if (installingNode.installStatus.isOk) {
installingNode.isChecked = false
installingNode = null
if (that.isBatch) {
that.installNext()
} else {
teaweb.success("升级成功", function () {
teaweb.reload()
})
}
} else {
let nodeId = installingNode.id
let errMsg = installingNode.installStatus.error
that.isInstalling = false
installingNode.isInstalling = false
installingNode = null
switch (resp.data.status.errorCode) {
case "EMPTY_LOGIN":
case "EMPTY_SSH_HOST":
case "EMPTY_SSH_PORT":
case "EMPTY_GRANT":
teaweb.warn("需要填写SSH登录信息", function () {
teaweb.popup("/httpdns/clusters/updateNodeSSH?nodeId=" + nodeId, {
height: "20em",
callback: function () {
teaweb.reload()
}
})
})
return
case "CREATE_ROOT_DIRECTORY_FAILED":
teaweb.warn("创建根目录失败,请检查目录权限或手工创建:" + errMsg)
return
case "INSTALL_HELPER_FAILED":
teaweb.warn("安装助手失败:" + errMsg)
return
case "TEST_FAILED":
teaweb.warn("环境测试失败:" + errMsg)
return
case "RPC_TEST_FAILED":
teaweb.confirm("html:要升级的节点到API服务之间的RPC通讯测试失败具体错误" + errMsg + "<br/>现在修改API信息", function () {
window.location = "/settings/api"
})
return
default:
teaweb.warn("升级失败:" + errMsg)
}
}
}
}
})
.done(function () {
setTimeout(this.reload, 3000)
})
} else {
setTimeout(this.reload, 3000)
}
}
})