<script setup lang="ts">
|
import { computed } from 'vue';
|
|
import type { OperationState, RuntimeStatus } from '../stores/annotation';
|
|
const props = withDefaults(
|
defineProps<{
|
fatalMessage?: string;
|
operation: OperationState;
|
sdkAvailable?: boolean;
|
status: RuntimeStatus;
|
}>(),
|
{ fatalMessage: 'ONLYOFFICE SDK 未加载,无法初始化插件', sdkAvailable: true },
|
);
|
|
const busy = computed(() => props.status === 'initializing' || props.status === 'working');
|
const busyMessage = computed(() => (props.operation.kind === 'working' ? props.operation.message : '正在连接 ONLYOFFICE...'));
|
</script>
|
|
<template>
|
<div class="operation-status">
|
<div class="status-line">
|
<a-tag class="connection-status" :color="status === 'ready' ? 'success' : status === 'error' ? 'error' : 'default'" data-test="connection-status">
|
{{ status === 'initializing' ? '加载中' : status === 'working' ? '处理中' : status === 'ready' ? '已连接' : '连接异常' }}
|
</a-tag>
|
<span class="plugin-version" data-test="plugin-version">v0.1.0</span>
|
</div>
|
|
<a-result v-if="!sdkAvailable" class="fatal-result" status="error" :sub-title="fatalMessage" title="插件无法启动" />
|
<div v-else-if="busy" class="runtime-progress" aria-live="polite">
|
<a-spin size="small" />
|
<span data-test="runtime-message">{{ busyMessage }}</span>
|
</div>
|
<a-alert v-else-if="operation.kind === 'error'" data-test="operation-message" :message="operation.message" show-icon type="error" />
|
<p
|
v-else-if="operation.kind === 'success' && operation.message !== '文档字段已刷新'"
|
class="operation-message is-success"
|
data-test="operation-message"
|
role="status"
|
>
|
{{ operation.message }}
|
</p>
|
</div>
|
</template>
|