fix(avatar): fail closed on BOXIM connection errors
This commit is contained in:
@@ -63,7 +63,14 @@
|
||||
|
||||
<span class="permission-copy">
|
||||
<strong>{{ item.title }}</strong>
|
||||
<small>{{ item.key === 'takeover' ? takeoverDescription : item.description }}</small>
|
||||
<small>
|
||||
{{ item.description }}
|
||||
<span
|
||||
v-if="item.key === 'takeover' && takeoverConnectionLabel"
|
||||
class="connection-state"
|
||||
:class="takeoverConnectionTone"
|
||||
> · {{ takeoverConnectionLabel }}</span>
|
||||
</small>
|
||||
</span>
|
||||
|
||||
<span class="permission-switch" :class="{ active: permissionState[item.key] }" aria-hidden="true">
|
||||
@@ -179,9 +186,21 @@ const takeoverStatus = ref<TakeoverStatus | null>(null)
|
||||
let toastTimer: number | undefined
|
||||
let takeoverStatusTimer: number | undefined
|
||||
|
||||
const takeoverDescription = computed(() => {
|
||||
if (!permissionState.takeover) return '收到私聊消息 3 秒后回复,主人发言时暂停'
|
||||
return takeoverStatus.value?.message || '正在连接 BOXIM'
|
||||
const takeoverConnectionLabel = computed(() => {
|
||||
if (takeoverStatus.value?.status === 'error' || takeoverStatus.value?.status === 'needs_login') {
|
||||
return '连接失败'
|
||||
}
|
||||
if (takeoverStatus.value?.status === 'ready') return '已连接'
|
||||
if (permissionState.takeover) return '正在连接'
|
||||
return ''
|
||||
})
|
||||
|
||||
const takeoverConnectionTone = computed(() => {
|
||||
if (takeoverStatus.value?.status === 'ready') return 'ready'
|
||||
if (takeoverStatus.value?.status === 'error' || takeoverStatus.value?.status === 'needs_login') {
|
||||
return 'failed'
|
||||
}
|
||||
return 'connecting'
|
||||
})
|
||||
|
||||
const setPermissions = (permissions: AvatarPermission[]) => {
|
||||
@@ -249,6 +268,9 @@ const loadTakeoverStatus = async () => {
|
||||
if (!activeAvatarId.value) return
|
||||
try {
|
||||
takeoverStatus.value = await getTakeoverStatus(activeAvatarId.value)
|
||||
if (!takeoverStatus.value.enabled && permissionState.takeover) {
|
||||
permissionState.takeover = false
|
||||
}
|
||||
} catch {
|
||||
takeoverStatus.value = null
|
||||
}
|
||||
@@ -476,6 +498,22 @@ svg {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.connection-state {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.connection-state.connecting {
|
||||
color: #d78532;
|
||||
}
|
||||
|
||||
.connection-state.ready {
|
||||
color: #31966b;
|
||||
}
|
||||
|
||||
.connection-state.failed {
|
||||
color: #d95849;
|
||||
}
|
||||
|
||||
.permission-copy strong {
|
||||
color: #26272b;
|
||||
font-size: 14px;
|
||||
|
||||
Reference in New Issue
Block a user