功能:新增连接状态展示,优化绑定信息加载逻辑及状态提示

This commit is contained in:
liRQ 2026-06-27 17:26:50 +08:00
parent 3fb7f45789
commit fe27fb4399

View File

@ -136,6 +136,12 @@
<span class="bound-info__label">Token有效</span> <span class="bound-info__label">Token有效</span>
<span class="bound-info__value">{{ boundInfo.tokenValid ? '✅ 是' : '❌ 否' }}</span> <span class="bound-info__value">{{ boundInfo.tokenValid ? '✅ 是' : '❌ 否' }}</span>
</div> </div>
<div class="bound-info__item" v-if="boundInfo.connectMessage">
<span class="bound-info__label">连接状态</span>
<span class="bound-info__value connect-message" :class="{ 'connect-ok': boundInfo.connected === true, 'connect-error': boundInfo.connected === false }">
{{ boundInfo.connected ? '✅' : '❌' }} {{ boundInfo.connectMessage }}
</span>
</div>
<div class="bound-info__item"> <div class="bound-info__item">
<span class="bound-info__label">创建时间</span> <span class="bound-info__label">创建时间</span>
<span class="bound-info__value">{{ formatTime(boundInfo.createTime) }}</span> <span class="bound-info__value">{{ formatTime(boundInfo.createTime) }}</span>
@ -178,8 +184,8 @@ const boundInfo = ref(null)
/** /**
* 加载已绑定的 OpenList 信息 * 加载已绑定的 OpenList 信息
* 后端返回格式 * 后端返回格式
* - null 或未绑定返回 null * - 未绑定或报错返回错误信息
* - 已绑定返回 { code: 200, data: { id, openlistUrl, openlistUsername, storageId, mountPath, status, tokenValid, createTime, updateTime } } * - 已绑定返回 { code: 200, data: { id, openlistUrl, openlistUsername, storageId, mountPath, status, tokenValid, connected, connectMessage, createTime, updateTime } }
*/ */
async function loadBoundInfo() { async function loadBoundInfo() {
try { try {
@ -195,9 +201,12 @@ async function loadBoundInfo() {
mountPath: d.mountPath || '', mountPath: d.mountPath || '',
status: d.status || '', status: d.status || '',
tokenValid: d.tokenValid, tokenValid: d.tokenValid,
connected: d.connected,
connectMessage: d.connectMessage || '',
createTime: d.createTime || '', createTime: d.createTime || '',
updateTime: d.updateTime || '', updateTime: d.updateTime || '',
} }
bindStatus.value = null //
} else { } else {
// null // null
boundInfo.value = null boundInfo.value = null
@ -205,6 +214,9 @@ async function loadBoundInfo() {
} catch (err) { } catch (err) {
console.warn('加载绑定信息失败:', err) console.warn('加载绑定信息失败:', err)
boundInfo.value = null boundInfo.value = null
//
const errorMsg = err?.payload?.message || err?.message || '加载绑定信息失败'
setBindStatus('error', errorMsg)
} }
} }
@ -317,7 +329,7 @@ function formatTime(timeStr) {
/** /**
* 设置绑定状态提示 * 设置绑定状态提示
*/ */
function setBindStatus(type, message) { function setBindStatus(type, message, autoClear = true) {
if (!type) { if (!type) {
bindStatus.value = null bindStatus.value = null
return return
@ -336,8 +348,8 @@ function setBindStatus(type, message) {
icon: icons[type] || '', icon: icons[type] || '',
} }
// 3 // 3
if (type !== 'success') { if (autoClear && type !== 'error') {
setTimeout(() => { setTimeout(() => {
bindStatus.value = null bindStatus.value = null
}, 3000) }, 3000)
@ -612,6 +624,24 @@ onMounted(() => {
word-break: break-all; word-break: break-all;
} }
/* 连接状态样式 */
.connect-message {
font-weight: 500;
}
.connect-ok {
color: #67c23a;
}
.connect-error {
color: #f56c6c;
}
.status-active {
color: #67c23a;
font-weight: 600;
}
.btn-unbind { .btn-unbind {
width: 100%; width: 100%;
padding: 8px 16px; padding: 8px 16px;