刘光辉
13 小时以前 0dfe84494048ce27ba8449831782128412d3eb13
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<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>