geng
This commit is contained in:
@@ -0,0 +1,118 @@
|
||||
<script setup lang="ts">
|
||||
import { Cell, CellGroup, Empty, Loading, Popup, Search } from 'vant';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
|
||||
import { type AccountSummary, api, ApiError } from '../api';
|
||||
import { session, viewAccount, viewedAccountId } from '../session';
|
||||
|
||||
const show = defineModel<boolean>('show', { default: false });
|
||||
|
||||
const query = ref('');
|
||||
const items = ref<AccountSummary[]>([]);
|
||||
const loading = ref(false);
|
||||
const error = ref('');
|
||||
let serial = 0;
|
||||
let debounce: number | undefined;
|
||||
|
||||
const me = computed(() => session.me?.account);
|
||||
|
||||
async function load() {
|
||||
const current = ++serial;
|
||||
loading.value = true;
|
||||
error.value = '';
|
||||
try {
|
||||
const { items: rows } = await api.accounts(query.value.trim());
|
||||
if (current === serial) items.value = rows.filter((row) => row.id !== me.value?.id);
|
||||
} catch (reason) {
|
||||
if (current === serial) error.value = reason instanceof ApiError ? reason.message : '加载失败';
|
||||
} finally {
|
||||
if (current === serial) loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
watch(show, (open) => {
|
||||
if (open) void load();
|
||||
});
|
||||
watch(query, () => {
|
||||
window.clearTimeout(debounce);
|
||||
debounce = window.setTimeout(load, 300);
|
||||
});
|
||||
|
||||
function pick(account: AccountSummary | null) {
|
||||
viewAccount(account);
|
||||
show.value = false;
|
||||
}
|
||||
|
||||
function statusText(account: AccountSummary): string {
|
||||
if (!account.device_count) return '没有电脑';
|
||||
if (!account.online) return '离线';
|
||||
return account.listening ? '监听中' : '已停止';
|
||||
}
|
||||
|
||||
function statusTone(account: AccountSummary): string {
|
||||
if (!account.online) return 'tone-muted';
|
||||
return account.listening ? 'tone-success' : 'tone-warning';
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Popup v-model:show="show" position="bottom" round closeable safe-area-inset-bottom class="switcher">
|
||||
<div class="switcher-body">
|
||||
<h3>切换客服</h3>
|
||||
<Search v-model="query" shape="round" placeholder="搜索客服姓名或账号" />
|
||||
<CellGroup inset>
|
||||
<Cell
|
||||
title="我自己"
|
||||
:label="me ? `${me.nickname || me.sn}` : ''"
|
||||
icon="user-o"
|
||||
clickable
|
||||
:value="viewedAccountId === undefined ? '当前' : ''"
|
||||
@click="pick(null)"
|
||||
/>
|
||||
</CellGroup>
|
||||
<div v-if="loading && !items.length" class="switcher-state"><Loading size="20" /></div>
|
||||
<Empty v-else-if="error" image="network" :description="error" />
|
||||
<Empty v-else-if="!items.length" image="search" description="没有找到其他客服" />
|
||||
<CellGroup v-else inset class="switcher-list">
|
||||
<Cell
|
||||
v-for="account in items"
|
||||
:key="account.id"
|
||||
:title="account.nickname || account.sn || `客服 #${account.id}`"
|
||||
:label="account.sn"
|
||||
clickable
|
||||
@click="pick(account)"
|
||||
>
|
||||
<template #value>
|
||||
<span :class="statusTone(account)">{{ statusText(account) }}</span>
|
||||
<span v-if="viewedAccountId === account.id" class="current">当前</span>
|
||||
</template>
|
||||
</Cell>
|
||||
</CellGroup>
|
||||
</div>
|
||||
</Popup>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.switcher {
|
||||
max-height: 80vh;
|
||||
}
|
||||
.switcher-body {
|
||||
padding: 16px 0 12px;
|
||||
}
|
||||
.switcher-body h3 {
|
||||
margin: 0 16px 8px;
|
||||
font-size: 17px;
|
||||
}
|
||||
.switcher-state {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
padding: 32px 0;
|
||||
}
|
||||
.switcher-list {
|
||||
margin-top: 12px;
|
||||
}
|
||||
.current {
|
||||
margin-left: 6px;
|
||||
color: var(--app-primary);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,260 @@
|
||||
<script setup lang="ts">
|
||||
import { Button, Cell, CellGroup, Field, Icon, showConfirmDialog, showToast } from 'vant';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
|
||||
import { api, ApiError, type Conversation } from '../api';
|
||||
import { initial, relativeTime } from '../format';
|
||||
|
||||
const props = defineProps<{
|
||||
conversation: Conversation;
|
||||
accountId?: number;
|
||||
canAdd: boolean;
|
||||
canRemove: boolean;
|
||||
addCode: string;
|
||||
removeCode: string;
|
||||
}>();
|
||||
const emit = defineEmits<{ updated: [item: Conversation] }>();
|
||||
|
||||
const reason = ref('');
|
||||
const saving = ref(false);
|
||||
watch(
|
||||
() => `${props.conversation.account}|${props.conversation.conversation}`,
|
||||
() => {
|
||||
reason.value = '';
|
||||
},
|
||||
);
|
||||
|
||||
const entry = computed(() => props.conversation.blacklist);
|
||||
const sourceLabel = computed(() => {
|
||||
const source = entry.value?.source;
|
||||
if (source === 'mobile') return '手机控制台';
|
||||
if (source === 'desktop') return '客服电脑';
|
||||
return source || '—';
|
||||
});
|
||||
|
||||
async function block() {
|
||||
if (saving.value) return;
|
||||
try {
|
||||
await showConfirmDialog({
|
||||
title: '加入忽略?',
|
||||
message: `加入后,系统不再向「${props.conversation.name}」自动发送任何消息,只能由客服手动处理。`,
|
||||
confirmButtonText: '加入忽略',
|
||||
confirmButtonColor: 'var(--app-danger)',
|
||||
});
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
saving.value = true;
|
||||
try {
|
||||
const { entry: saved } = await api.block(props.conversation, reason.value.trim(), props.accountId);
|
||||
emit('updated', { ...props.conversation, blocked: true, blacklist: saved });
|
||||
showToast({ message: '已加入忽略,电脑同步后立即生效', type: 'success' });
|
||||
} catch (error) {
|
||||
showToast({ message: error instanceof ApiError ? error.message : '操作失败,请重试', type: 'fail' });
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function unblock() {
|
||||
if (saving.value) return;
|
||||
try {
|
||||
await showConfirmDialog({
|
||||
title: '移出忽略?',
|
||||
message: `移出后,系统会恢复向「${props.conversation.name}」自动回复。`,
|
||||
confirmButtonText: '移出',
|
||||
});
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
saving.value = true;
|
||||
try {
|
||||
await api.unblock(props.conversation.account, props.conversation.conversation, props.accountId);
|
||||
emit('updated', { ...props.conversation, blocked: false, blacklist: null });
|
||||
showToast({ message: '已移出忽略', type: 'success' });
|
||||
} catch (error) {
|
||||
showToast({ message: error instanceof ApiError ? error.message : '操作失败,请重试', type: 'fail' });
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="detail">
|
||||
<header class="detail-head">
|
||||
<span class="avatar" aria-hidden="true">{{ initial(conversation.name) }}</span>
|
||||
<div class="detail-title">
|
||||
<h2>{{ conversation.name }}</h2>
|
||||
<p class="app-muted">{{ conversation.type_label }}</p>
|
||||
</div>
|
||||
<span v-if="conversation.blocked" class="badge"><Icon name="shield-o" /> 忽略</span>
|
||||
</header>
|
||||
|
||||
<CellGroup inset class="group">
|
||||
<Cell title="企业微信账号" :value="conversation.account_name || '—'" :label="conversation.account" />
|
||||
<Cell title="最近消息" :value="conversation.last_message_at ? relativeTime(conversation.last_message_at) : '—'" />
|
||||
<Cell title="会话标识">
|
||||
<template #label><span class="app-mono">{{ conversation.conversation }}</span></template>
|
||||
</Cell>
|
||||
</CellGroup>
|
||||
|
||||
<div v-if="conversation.blocked && entry" class="state state--blocked">
|
||||
<h3><Icon name="shield-o" /> 已加入忽略</h3>
|
||||
<p>系统不会向这个会话自动发送消息;电脑离线时,下次联网自动同步。</p>
|
||||
<dl>
|
||||
<div><dt>原因</dt><dd>{{ entry.reason || '未填写' }}</dd></div>
|
||||
<div><dt>操作人</dt><dd>{{ entry.created_by || '—' }}</dd></div>
|
||||
<div><dt>时间</dt><dd>{{ relativeTime(entry.created_at) }}</dd></div>
|
||||
<div><dt>来源</dt><dd>{{ sourceLabel }}</dd></div>
|
||||
</dl>
|
||||
<Button
|
||||
v-if="canRemove"
|
||||
block
|
||||
round
|
||||
plain
|
||||
type="primary"
|
||||
icon="revoke"
|
||||
:loading="saving"
|
||||
@click="unblock"
|
||||
>
|
||||
移出忽略
|
||||
</Button>
|
||||
<p v-else class="note">移出忽略需要主管权限({{ removeCode }}),请联系主管处理。</p>
|
||||
</div>
|
||||
|
||||
<div v-else class="state">
|
||||
<h3><Icon name="info-o" /> 正常接收自动回复</h3>
|
||||
<p>客户投诉、需要人工跟进或不适合机器人回复的会话,可以加入忽略。</p>
|
||||
<template v-if="canAdd">
|
||||
<CellGroup inset class="reason">
|
||||
<Field
|
||||
v-model="reason"
|
||||
label="原因"
|
||||
placeholder="选填,例如:客户要求人工服务"
|
||||
maxlength="200"
|
||||
show-word-limit
|
||||
rows="2"
|
||||
autosize
|
||||
type="textarea"
|
||||
/>
|
||||
</CellGroup>
|
||||
<Button block round type="danger" icon="shield-o" :loading="saving" @click="block">
|
||||
加入忽略
|
||||
</Button>
|
||||
</template>
|
||||
<p v-else class="note">加入忽略需要 ZYT 权限({{ addCode }}),请联系管理员开通。</p>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.detail {
|
||||
padding-bottom: 16px;
|
||||
}
|
||||
.detail-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 16px;
|
||||
}
|
||||
.avatar {
|
||||
flex: none;
|
||||
width: 52px;
|
||||
height: 52px;
|
||||
border-radius: 14px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
font-size: 22px;
|
||||
font-weight: 600;
|
||||
color: var(--app-primary);
|
||||
background: var(--app-primary-soft);
|
||||
}
|
||||
.detail-title {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.detail-title h2 {
|
||||
margin: 0 0 4px;
|
||||
font-size: 18px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.detail-title p {
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
}
|
||||
.badge {
|
||||
flex: none;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 4px 10px;
|
||||
border-radius: 999px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: var(--app-danger);
|
||||
background: var(--app-danger-soft);
|
||||
}
|
||||
.group {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.state {
|
||||
margin: 0 16px;
|
||||
padding: 16px;
|
||||
border-radius: 14px;
|
||||
background: var(--app-surface);
|
||||
border: 1px solid var(--app-border);
|
||||
}
|
||||
.state--blocked {
|
||||
border-color: var(--app-danger-soft);
|
||||
background: linear-gradient(0deg, var(--app-danger-soft), var(--app-danger-soft)), var(--app-surface);
|
||||
}
|
||||
.state h3 {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin: 0 0 6px;
|
||||
font-size: 15px;
|
||||
}
|
||||
.state--blocked h3 {
|
||||
color: var(--app-danger);
|
||||
}
|
||||
.state > p {
|
||||
margin: 0 0 12px;
|
||||
color: var(--app-text-2);
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.state dl {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 8px 12px;
|
||||
margin: 0 0 14px;
|
||||
}
|
||||
.state dt {
|
||||
font-size: 12px;
|
||||
color: var(--app-muted);
|
||||
}
|
||||
.state dd {
|
||||
margin: 2px 0 0;
|
||||
font-size: 14px;
|
||||
word-break: break-all;
|
||||
}
|
||||
.reason {
|
||||
margin: 0 0 12px;
|
||||
}
|
||||
.reason :deep(.van-cell-group--inset) {
|
||||
margin: 0;
|
||||
}
|
||||
.state :deep(.van-cell-group--inset) {
|
||||
margin: 0 0 12px;
|
||||
}
|
||||
.note {
|
||||
margin: 0;
|
||||
color: var(--app-muted);
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,116 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
|
||||
import type { Conversation } from '../api';
|
||||
import { initial, relativeTime } from '../format';
|
||||
|
||||
const props = defineProps<{ item: Conversation; active?: boolean }>();
|
||||
defineEmits<{ select: [item: Conversation] }>();
|
||||
|
||||
const hue = computed(() => {
|
||||
if (props.item.type === 'group') return 'group';
|
||||
if (props.item.type === 'direct_wechat') return 'wechat';
|
||||
return 'wecom';
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<button type="button" class="row" :class="{ active }" @click="$emit('select', item)">
|
||||
<span class="avatar" :class="`avatar--${hue}`" aria-hidden="true">{{ initial(item.name) }}</span>
|
||||
<span class="body">
|
||||
<span class="line">
|
||||
<strong class="name">{{ item.name }}</strong>
|
||||
<span class="time">{{ item.last_message_at ? relativeTime(item.last_message_at) : '' }}</span>
|
||||
</span>
|
||||
<span class="line sub">
|
||||
<span class="meta">{{ item.type_label }}<template v-if="item.account_name"> · {{ item.account_name }}</template></span>
|
||||
<span v-if="item.blocked" class="blocked">已拉黑</span>
|
||||
</span>
|
||||
</span>
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
width: 100%;
|
||||
min-height: 64px;
|
||||
padding: 10px 16px;
|
||||
border: 0;
|
||||
border-bottom: 1px solid var(--app-border);
|
||||
background: var(--app-surface);
|
||||
color: inherit;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
}
|
||||
.row:active,
|
||||
.row.active {
|
||||
background: var(--app-primary-soft);
|
||||
}
|
||||
.avatar {
|
||||
flex: none;
|
||||
width: 42px;
|
||||
height: 42px;
|
||||
border-radius: 12px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
font-size: 17px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.avatar--wecom {
|
||||
color: #2f6fff;
|
||||
background: rgba(47, 111, 255, 0.12);
|
||||
}
|
||||
.avatar--wechat {
|
||||
color: #0f9e69;
|
||||
background: rgba(19, 183, 122, 0.14);
|
||||
}
|
||||
.avatar--group {
|
||||
color: #7a5cff;
|
||||
background: rgba(138, 107, 255, 0.14);
|
||||
}
|
||||
.body {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
}
|
||||
.line {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
.name {
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.time {
|
||||
flex: none;
|
||||
font-size: 12px;
|
||||
color: var(--app-muted);
|
||||
}
|
||||
.sub {
|
||||
font-size: 12px;
|
||||
color: var(--app-muted);
|
||||
}
|
||||
.meta {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.blocked {
|
||||
flex: none;
|
||||
padding: 1px 8px;
|
||||
border-radius: 999px;
|
||||
color: var(--app-danger);
|
||||
background: var(--app-danger-soft);
|
||||
font-weight: 600;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,336 @@
|
||||
<script setup lang="ts">
|
||||
import { Button, Icon, Loading, showConfirmDialog, showToast } from 'vant';
|
||||
import { computed, onBeforeUnmount, ref, watch } from 'vue';
|
||||
|
||||
import { api, ApiError, type Command, type CommandType, type Device } from '../api';
|
||||
import { describeCommand, describeDevice, durationText } from '../format';
|
||||
|
||||
const props = defineProps<{
|
||||
device: Device;
|
||||
accountId?: number;
|
||||
canControl: boolean;
|
||||
controlCode: string;
|
||||
}>();
|
||||
const emit = defineEmits<{ changed: [] }>();
|
||||
|
||||
const sending = ref(false);
|
||||
const command = ref<Command | null>(null);
|
||||
let pollTimer: number | undefined;
|
||||
let pollDeadline = 0;
|
||||
|
||||
const summary = computed(() => describeDevice(props.device));
|
||||
const status = computed(() => props.device.status);
|
||||
const listening = computed(() => Boolean(status.value?.listening));
|
||||
const nextAction = computed<CommandType>(() => (listening.value ? 'stop_listening' : 'start_listening'));
|
||||
const progress = computed(() => (command.value ? describeCommand(command.value) : null));
|
||||
const busy = computed(() => sending.value || Boolean(progress.value?.busy));
|
||||
|
||||
// 按钮不能点的时候,要告诉人为什么,而不是一个灰按钮。
|
||||
const blockedReason = computed(() => {
|
||||
if (!props.device.online) return '电脑离线:客服软件没有运行,无法远程拉起。请到电脑上打开软件。';
|
||||
if (!props.device.remote_capable) return '电脑上的客服软件版本过低,升级到最新版后才能远程控制。';
|
||||
if (!props.canControl) return `你的 ZYT 账号没有远程启停权限(${props.controlCode}),请联系管理员开通。`;
|
||||
return '';
|
||||
});
|
||||
|
||||
function stopPolling() {
|
||||
if (pollTimer !== undefined) window.clearTimeout(pollTimer);
|
||||
pollTimer = undefined;
|
||||
}
|
||||
|
||||
async function pollCommand() {
|
||||
const current = command.value;
|
||||
if (!current || current.final) return;
|
||||
try {
|
||||
const { command: fresh } = await api.command(current.id);
|
||||
command.value = fresh;
|
||||
if (fresh.final) {
|
||||
emit('changed');
|
||||
const text = describeCommand(fresh).text;
|
||||
showToast({ message: text, type: fresh.status === 'succeeded' ? 'success' : 'fail' });
|
||||
return;
|
||||
}
|
||||
} catch (error) {
|
||||
if (error instanceof ApiError && error.status === 404) return;
|
||||
}
|
||||
if (Date.now() < pollDeadline) {
|
||||
pollTimer = window.setTimeout(pollCommand, 3000);
|
||||
} else {
|
||||
// 电脑迟迟不回执时不再傻等;指令本身 10 分钟后在服务端作废。
|
||||
emit('changed');
|
||||
}
|
||||
}
|
||||
|
||||
function track(next: Command) {
|
||||
stopPolling();
|
||||
command.value = next;
|
||||
if (!next.final) {
|
||||
pollDeadline = Date.now() + 150_000;
|
||||
pollTimer = window.setTimeout(pollCommand, 1500);
|
||||
}
|
||||
}
|
||||
|
||||
// 页面刷新或重新打开时,接着追踪还没执行完的指令。
|
||||
watch(
|
||||
() => props.device.last_command,
|
||||
(latest) => {
|
||||
if (!latest) return;
|
||||
if (command.value && command.value.id === latest.id) {
|
||||
if (!command.value.final && latest.final) command.value = latest;
|
||||
return;
|
||||
}
|
||||
const recent = latest.expires_at * 1000 > Date.now();
|
||||
if (!latest.final && recent) track(latest);
|
||||
else if (!command.value && latest.final && recent) command.value = latest;
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
onBeforeUnmount(stopPolling);
|
||||
|
||||
async function toggle() {
|
||||
if (busy.value || blockedReason.value) return;
|
||||
const stopping = nextAction.value === 'stop_listening';
|
||||
try {
|
||||
await showConfirmDialog({
|
||||
title: stopping ? '停止自动回复?' : '启动自动回复?',
|
||||
message: stopping
|
||||
? `「${props.device.device_name || '这台电脑'}」将停止监听,新消息不再自动回复。`
|
||||
: `「${props.device.device_name || '这台电脑'}」将开始监听,并按电脑上的设置自动回复新消息。`,
|
||||
confirmButtonText: stopping ? '停止' : '启动',
|
||||
confirmButtonColor: stopping ? 'var(--app-danger)' : 'var(--app-primary)',
|
||||
});
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
sending.value = true;
|
||||
try {
|
||||
const { command: created } = await api.sendCommand(props.device.device_id, nextAction.value, props.accountId);
|
||||
track(created);
|
||||
} catch (error) {
|
||||
showToast({ message: error instanceof ApiError ? error.message : '指令发送失败,请重试', type: 'fail' });
|
||||
emit('changed');
|
||||
} finally {
|
||||
sending.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<article class="panel app-card" :class="`panel--${summary.tone}`">
|
||||
<header class="panel-head">
|
||||
<div class="panel-icon" aria-hidden="true"><Icon name="desktop-o" /></div>
|
||||
<div class="panel-title">
|
||||
<h2>{{ device.device_name || '未命名电脑' }}</h2>
|
||||
<p class="app-muted">{{ summary.hint }}</p>
|
||||
</div>
|
||||
<span class="pill" :class="`pill--${summary.tone}`">
|
||||
<span class="dot" aria-hidden="true" />
|
||||
{{ summary.label }}
|
||||
</span>
|
||||
</header>
|
||||
|
||||
<dl class="stats">
|
||||
<div class="stat">
|
||||
<dt>自动回复</dt>
|
||||
<dd :class="listening ? 'tone-success' : 'tone-muted'">
|
||||
{{ status ? (listening ? '监听中' : '已停止') : '—' }}
|
||||
</dd>
|
||||
</div>
|
||||
<div class="stat">
|
||||
<dt>企业微信</dt>
|
||||
<dd :class="status?.wecom_connected ? 'tone-success' : 'tone-muted'">
|
||||
{{ status ? (status.wecom_connected ? '已连接' : '未连接') : '—' }}
|
||||
</dd>
|
||||
</div>
|
||||
<div class="stat">
|
||||
<dt>回复通道</dt>
|
||||
<dd>{{ status?.transport_label || '—' }}</dd>
|
||||
</div>
|
||||
<div class="stat">
|
||||
<dt>待处理</dt>
|
||||
<dd :class="(status?.pending_count || 0) > 0 ? 'tone-warning' : ''">
|
||||
{{ status ? `${status.pending_count} 条` : '—' }}
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
|
||||
<p class="meta app-muted">
|
||||
<span>版本 {{ device.app_version || '未知' }}</span>
|
||||
<span v-if="device.online && status?.reported_seconds !== null && status?.reported_seconds !== undefined">
|
||||
· 状态 {{ durationText(status.reported_seconds) }}前上报
|
||||
</span>
|
||||
<span v-else-if="!device.online && device.last_seen_seconds !== null">
|
||||
· {{ durationText(device.last_seen_seconds) }}前在线
|
||||
</span>
|
||||
</p>
|
||||
|
||||
<div v-if="progress" class="progress" :class="`progress--${progress.tone}`" role="status" aria-live="polite">
|
||||
<Loading v-if="progress.busy" size="16" />
|
||||
<Icon v-else :name="progress.tone === 'success' ? 'passed' : 'info-o'" />
|
||||
<span>{{ progress.text }}</span>
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
<Button
|
||||
block
|
||||
round
|
||||
:type="listening ? 'danger' : 'primary'"
|
||||
:plain="listening"
|
||||
:icon="listening ? 'pause-circle-o' : 'play-circle-o'"
|
||||
:disabled="Boolean(blockedReason)"
|
||||
:loading="busy"
|
||||
:loading-text="sending ? '正在下发…' : '等待电脑执行…'"
|
||||
@click="toggle"
|
||||
>
|
||||
{{ listening ? '停止自动回复' : '启动自动回复' }}
|
||||
</Button>
|
||||
<p v-if="blockedReason" class="blocked app-muted">{{ blockedReason }}</p>
|
||||
</div>
|
||||
</article>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.panel {
|
||||
padding: 16px;
|
||||
}
|
||||
.panel-head {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
}
|
||||
.panel-icon {
|
||||
flex: none;
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
border-radius: 12px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
font-size: 22px;
|
||||
color: var(--app-primary);
|
||||
background: var(--app-primary-soft);
|
||||
}
|
||||
.panel-title {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.panel-title h2 {
|
||||
margin: 2px 0 4px;
|
||||
font-size: 17px;
|
||||
font-weight: 600;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.panel-title p {
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
line-height: 1.45;
|
||||
}
|
||||
.pill {
|
||||
flex: none;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 4px 10px;
|
||||
border-radius: 999px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.pill .dot {
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
border-radius: 50%;
|
||||
background: currentColor;
|
||||
}
|
||||
.pill--success {
|
||||
color: var(--app-success);
|
||||
background: var(--app-success-soft);
|
||||
}
|
||||
.pill--success .dot {
|
||||
box-shadow: 0 0 0 3px var(--app-success-soft);
|
||||
animation: breathe 2.2s ease-in-out infinite;
|
||||
}
|
||||
.pill--warning {
|
||||
color: var(--app-warning);
|
||||
background: var(--app-warning-soft);
|
||||
}
|
||||
.pill--danger {
|
||||
color: var(--app-danger);
|
||||
background: var(--app-danger-soft);
|
||||
}
|
||||
.pill--muted,
|
||||
.pill--primary {
|
||||
color: var(--app-muted);
|
||||
background: var(--app-muted-soft);
|
||||
}
|
||||
@keyframes breathe {
|
||||
50% {
|
||||
opacity: 0.45;
|
||||
}
|
||||
}
|
||||
.stats {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 8px;
|
||||
margin: 16px 0 0;
|
||||
}
|
||||
.stat {
|
||||
padding: 10px 12px;
|
||||
border-radius: 12px;
|
||||
background: var(--app-surface-2);
|
||||
border: 1px solid var(--app-border);
|
||||
}
|
||||
.stat dt {
|
||||
font-size: 12px;
|
||||
color: var(--app-muted);
|
||||
}
|
||||
.stat dd {
|
||||
margin: 4px 0 0;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.meta {
|
||||
margin: 12px 0 0;
|
||||
font-size: 12px;
|
||||
}
|
||||
.progress {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-top: 12px;
|
||||
padding: 10px 12px;
|
||||
border-radius: 12px;
|
||||
font-size: 13px;
|
||||
line-height: 1.45;
|
||||
}
|
||||
.progress--primary {
|
||||
color: var(--app-primary);
|
||||
background: var(--app-primary-soft);
|
||||
}
|
||||
.progress--success {
|
||||
color: var(--app-success);
|
||||
background: var(--app-success-soft);
|
||||
}
|
||||
.progress--danger {
|
||||
color: var(--app-danger);
|
||||
background: var(--app-danger-soft);
|
||||
}
|
||||
.progress--warning {
|
||||
color: var(--app-warning);
|
||||
background: var(--app-warning-soft);
|
||||
}
|
||||
.progress--muted {
|
||||
color: var(--app-muted);
|
||||
background: var(--app-muted-soft);
|
||||
}
|
||||
.actions {
|
||||
margin-top: 16px;
|
||||
}
|
||||
.blocked {
|
||||
margin: 10px 4px 0;
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user