421 lines
8.8 KiB
Vue
421 lines
8.8 KiB
Vue
|
|
<script setup lang="ts">
|
||
|
|
import { computed } from "vue";
|
||
|
|
import { RouterLink, RouterView, useRoute } from "vue-router";
|
||
|
|
|
||
|
|
import StatusBadge from "./StatusBadge.vue";
|
||
|
|
import { useDesktopRuntime } from "../composables/useDesktopRuntime";
|
||
|
|
import { useDesktopSession } from "../composables/useDesktopSession";
|
||
|
|
import { formatRelativeTime } from "../lib/formatters";
|
||
|
|
import { desktopMonitoringMediaCatalog, desktopPublishMediaCatalog } from "../lib/media-catalog";
|
||
|
|
|
||
|
|
const route = useRoute();
|
||
|
|
const { snapshot, error } = useDesktopRuntime();
|
||
|
|
const { session, logout, isPreviewMode } = useDesktopSession();
|
||
|
|
|
||
|
|
const navItems = computed(() => {
|
||
|
|
const data = snapshot.value;
|
||
|
|
const accounts = data?.accounts ?? [];
|
||
|
|
const publishIDs = new Set(desktopPublishMediaCatalog.map((item) => item.id));
|
||
|
|
const monitoringIDs = new Set(desktopMonitoringMediaCatalog.map((item) => item.id));
|
||
|
|
|
||
|
|
return [
|
||
|
|
{
|
||
|
|
to: "/",
|
||
|
|
title: "控制台",
|
||
|
|
description: "运行总览、活动流和总体健康度",
|
||
|
|
count: data?.summary.issuesOpen ?? 0,
|
||
|
|
},
|
||
|
|
{
|
||
|
|
to: "/tasks",
|
||
|
|
title: "任务中心",
|
||
|
|
description: "MQ 投递、租约占用、人工审核与 fallback",
|
||
|
|
count: data?.tasks.length ?? 0,
|
||
|
|
},
|
||
|
|
{
|
||
|
|
to: "/media-platforms",
|
||
|
|
title: "媒体平台",
|
||
|
|
description: "发布媒体授权、多个账号绑定与表格化管理",
|
||
|
|
count: accounts.filter((item) => publishIDs.has(item.platform)).length,
|
||
|
|
},
|
||
|
|
{
|
||
|
|
to: "/ai-platforms",
|
||
|
|
title: "AI 平台",
|
||
|
|
description: "AI 平台一平台一绑定,按卡片查看状态与归属",
|
||
|
|
count: accounts.filter((item) => monitoringIDs.has(item.platform)).length,
|
||
|
|
},
|
||
|
|
{
|
||
|
|
to: "/diagnostics",
|
||
|
|
title: "诊断",
|
||
|
|
description: "vault、scheduler、transport 与原始快照",
|
||
|
|
count: data?.clients.length ?? 0,
|
||
|
|
},
|
||
|
|
];
|
||
|
|
});
|
||
|
|
|
||
|
|
|
||
|
|
const updatedLabel = computed(() =>
|
||
|
|
snapshot.value ? formatRelativeTime(snapshot.value.generatedAt) : "等待首帧快照",
|
||
|
|
);
|
||
|
|
const operatorName = computed(() => session.value?.user?.name ?? "未命名操作员");
|
||
|
|
const operatorEmail = computed(() => session.value?.user?.email ?? "preview@geo-rankly.local");
|
||
|
|
const clientLabel = computed(
|
||
|
|
() => session.value?.desktopClient?.device_name ?? "当前设备尚未注册 client",
|
||
|
|
);
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<template>
|
||
|
|
<div class="app-shell">
|
||
|
|
<aside class="sidebar">
|
||
|
|
<div class="sidebar-top">
|
||
|
|
<div class="brand-block">
|
||
|
|
<div class="brand-mark">
|
||
|
|
<span class="brand-ring"></span>
|
||
|
|
<span class="brand-core"></span>
|
||
|
|
</div>
|
||
|
|
<div>
|
||
|
|
<p class="eyebrow">Workspace Cockpit</p>
|
||
|
|
<h1>GEO Rankly Desktop</h1>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<section class="workspace-card">
|
||
|
|
<div class="workspace-topline">
|
||
|
|
<StatusBadge
|
||
|
|
:tone="snapshot?.previewMode || isPreviewMode ? 'brand' : 'success'"
|
||
|
|
:label="snapshot?.previewMode || isPreviewMode ? 'Preview Runtime' : 'Live Runtime'"
|
||
|
|
/>
|
||
|
|
<StatusBadge
|
||
|
|
v-if="snapshot"
|
||
|
|
tone="info"
|
||
|
|
:label="`Sync: ${updatedLabel}`"
|
||
|
|
/>
|
||
|
|
</div>
|
||
|
|
<div class="workspace-meta">
|
||
|
|
<div>
|
||
|
|
<span>在线客户端</span>
|
||
|
|
<strong>{{ snapshot?.summary.onlineClients ?? 0 }}</strong>
|
||
|
|
</div>
|
||
|
|
<div>
|
||
|
|
<span>绑定账号</span>
|
||
|
|
<strong>{{ snapshot?.summary.accountsBound ?? 0 }}</strong>
|
||
|
|
</div>
|
||
|
|
<div>
|
||
|
|
<span>待处理任务</span>
|
||
|
|
<strong>{{ snapshot?.summary.queuedTasks ?? 0 }}</strong>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</section>
|
||
|
|
|
||
|
|
<nav class="nav">
|
||
|
|
<RouterLink
|
||
|
|
v-for="item in navItems"
|
||
|
|
:key="item.to"
|
||
|
|
:to="item.to"
|
||
|
|
class="nav-link"
|
||
|
|
:class="{ active: route.path === item.to }"
|
||
|
|
>
|
||
|
|
<div class="nav-copy">
|
||
|
|
<strong>{{ item.title }}</strong>
|
||
|
|
</div>
|
||
|
|
<span class="nav-count">{{ item.count }}</span>
|
||
|
|
</RouterLink>
|
||
|
|
</nav>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<footer class="sidebar-footer">
|
||
|
|
<section class="operator-card">
|
||
|
|
<div class="operator-topline">
|
||
|
|
<div>
|
||
|
|
<span class="label">当前操作员</span>
|
||
|
|
<strong>{{ operatorName }}</strong>
|
||
|
|
</div>
|
||
|
|
<button type="button" class="logout-button" @click="logout">退出</button>
|
||
|
|
</div>
|
||
|
|
<p>{{ operatorEmail }}</p>
|
||
|
|
<small>{{ clientLabel }}</small>
|
||
|
|
</section>
|
||
|
|
|
||
|
|
|
||
|
|
<div class="footer-row">
|
||
|
|
<span>Version</span>
|
||
|
|
<strong>{{ snapshot?.app.version ?? "0.1.0" }}</strong>
|
||
|
|
</div>
|
||
|
|
<p v-if="error" class="error-text">{{ error }}</p>
|
||
|
|
</footer>
|
||
|
|
</aside>
|
||
|
|
|
||
|
|
<main class="content">
|
||
|
|
<RouterView />
|
||
|
|
</main>
|
||
|
|
</div>
|
||
|
|
</template>
|
||
|
|
|
||
|
|
<style scoped>
|
||
|
|
.app-shell {
|
||
|
|
display: flex;
|
||
|
|
height: 100vh;
|
||
|
|
overflow: hidden;
|
||
|
|
background: #f0f2f5;
|
||
|
|
color: #1a1a1a;
|
||
|
|
}
|
||
|
|
|
||
|
|
.sidebar {
|
||
|
|
width: 320px;
|
||
|
|
height: 100vh;
|
||
|
|
overflow-y: auto;
|
||
|
|
display: flex;
|
||
|
|
flex-direction: column;
|
||
|
|
justify-content: space-between;
|
||
|
|
gap: 24px;
|
||
|
|
padding: 24px;
|
||
|
|
border-right: 1px solid #e6edf5;
|
||
|
|
background: #ffffff;
|
||
|
|
flex-shrink: 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
.sidebar-top {
|
||
|
|
display: flex;
|
||
|
|
flex-direction: column;
|
||
|
|
gap: 24px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.brand-block {
|
||
|
|
display: flex;
|
||
|
|
gap: 16px;
|
||
|
|
align-items: center;
|
||
|
|
}
|
||
|
|
|
||
|
|
.brand-mark {
|
||
|
|
position: relative;
|
||
|
|
width: 40px;
|
||
|
|
height: 40px;
|
||
|
|
display: grid;
|
||
|
|
place-items: center;
|
||
|
|
}
|
||
|
|
|
||
|
|
.brand-ring,
|
||
|
|
.brand-core {
|
||
|
|
position: absolute;
|
||
|
|
border-radius: 50%;
|
||
|
|
}
|
||
|
|
|
||
|
|
.brand-ring {
|
||
|
|
inset: 0;
|
||
|
|
border: 1px solid #91caff;
|
||
|
|
background: #e6f4ff;
|
||
|
|
}
|
||
|
|
|
||
|
|
.brand-core {
|
||
|
|
width: 16px;
|
||
|
|
height: 16px;
|
||
|
|
background: #1677ff;
|
||
|
|
box-shadow: 0 2px 6px rgba(22, 119, 255, 0.4);
|
||
|
|
}
|
||
|
|
|
||
|
|
.eyebrow {
|
||
|
|
margin: 0 0 4px;
|
||
|
|
color: #8c8c8c;
|
||
|
|
font-size: 11px;
|
||
|
|
letter-spacing: 0.1em;
|
||
|
|
text-transform: uppercase;
|
||
|
|
}
|
||
|
|
|
||
|
|
h1 {
|
||
|
|
margin: 0;
|
||
|
|
font-size: 20px;
|
||
|
|
font-weight: 700;
|
||
|
|
color: #1a1a1a;
|
||
|
|
line-height: 1.2;
|
||
|
|
}
|
||
|
|
|
||
|
|
.workspace-card,
|
||
|
|
.operator-card {
|
||
|
|
padding: 16px;
|
||
|
|
border-radius: 12px;
|
||
|
|
border: 1px solid #e6edf5;
|
||
|
|
background: #fafafb;
|
||
|
|
}
|
||
|
|
|
||
|
|
.workspace-topline {
|
||
|
|
display: flex;
|
||
|
|
align-items: center;
|
||
|
|
gap: 8px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.operator-topline {
|
||
|
|
display: flex;
|
||
|
|
align-items: center;
|
||
|
|
justify-content: space-between;
|
||
|
|
gap: 12px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.operator-topline strong {
|
||
|
|
font-size: 15px;
|
||
|
|
font-weight: 600;
|
||
|
|
color: #1a1a1a;
|
||
|
|
}
|
||
|
|
|
||
|
|
.workspace-meta {
|
||
|
|
display: grid;
|
||
|
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||
|
|
gap: 12px;
|
||
|
|
margin-top: 16px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.workspace-meta span,
|
||
|
|
.footer-row span,
|
||
|
|
.label {
|
||
|
|
display: block;
|
||
|
|
color: #8c8c8c;
|
||
|
|
font-size: 12px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.workspace-meta strong {
|
||
|
|
display: block;
|
||
|
|
margin-top: 4px;
|
||
|
|
font-size: 18px;
|
||
|
|
font-weight: 600;
|
||
|
|
color: #1a1a1a;
|
||
|
|
}
|
||
|
|
|
||
|
|
.nav {
|
||
|
|
display: grid;
|
||
|
|
gap: 12px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.nav-link {
|
||
|
|
display: flex;
|
||
|
|
justify-content: space-between;
|
||
|
|
align-items: center;
|
||
|
|
padding: 14px 16px;
|
||
|
|
border-radius: 12px;
|
||
|
|
text-decoration: none;
|
||
|
|
background: #ffffff;
|
||
|
|
border: 1px solid #e6edf5;
|
||
|
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
|
||
|
|
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
||
|
|
}
|
||
|
|
|
||
|
|
.nav-link:hover {
|
||
|
|
border-color: #91caff;
|
||
|
|
box-shadow: 0 4px 12px rgba(22, 119, 255, 0.08);
|
||
|
|
transform: translateY(-1px);
|
||
|
|
}
|
||
|
|
|
||
|
|
.nav-link.active {
|
||
|
|
background: #f0f7ff;
|
||
|
|
border-color: #1677ff;
|
||
|
|
box-shadow: 0 4px 12px rgba(22, 119, 255, 0.1);
|
||
|
|
}
|
||
|
|
|
||
|
|
.nav-copy {
|
||
|
|
display: grid;
|
||
|
|
gap: 4px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.nav-copy strong {
|
||
|
|
font-size: 14px;
|
||
|
|
font-weight: 600;
|
||
|
|
color: #1a1a1a;
|
||
|
|
}
|
||
|
|
|
||
|
|
.nav-link.active .nav-copy strong {
|
||
|
|
color: #1677ff;
|
||
|
|
}
|
||
|
|
|
||
|
|
.nav-count {
|
||
|
|
display: inline-flex;
|
||
|
|
align-items: center;
|
||
|
|
justify-content: center;
|
||
|
|
min-width: 28px;
|
||
|
|
height: 28px;
|
||
|
|
padding: 0 8px;
|
||
|
|
border-radius: 14px;
|
||
|
|
background: #f0f0f0;
|
||
|
|
color: #595959;
|
||
|
|
font-size: 13px;
|
||
|
|
font-weight: 600;
|
||
|
|
}
|
||
|
|
|
||
|
|
.nav-link.active .nav-count {
|
||
|
|
background: #1677ff;
|
||
|
|
color: #fff;
|
||
|
|
}
|
||
|
|
|
||
|
|
.sidebar-footer {
|
||
|
|
display: flex;
|
||
|
|
flex-direction: column;
|
||
|
|
gap: 16px;
|
||
|
|
padding-top: 16px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.operator-card {
|
||
|
|
padding: 16px;
|
||
|
|
border-radius: 16px;
|
||
|
|
border: 1px solid #e6edf5;
|
||
|
|
background: #ffffff;
|
||
|
|
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
|
||
|
|
}
|
||
|
|
|
||
|
|
.operator-card p,
|
||
|
|
.operator-card small {
|
||
|
|
display: block;
|
||
|
|
margin: 6px 0 0;
|
||
|
|
color: #8c8c8c;
|
||
|
|
font-size: 13px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.operator-card small {
|
||
|
|
font-size: 12px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.logout-button {
|
||
|
|
height: 28px;
|
||
|
|
padding: 0 12px;
|
||
|
|
border-radius: 14px;
|
||
|
|
border: 1px solid #d9d9d9;
|
||
|
|
background: #fff;
|
||
|
|
color: #595959;
|
||
|
|
font-size: 12px;
|
||
|
|
cursor: pointer;
|
||
|
|
transition: all 0.2s;
|
||
|
|
}
|
||
|
|
|
||
|
|
.logout-button:hover {
|
||
|
|
color: #ff4d4f;
|
||
|
|
border-color: #ff4d4f;
|
||
|
|
}
|
||
|
|
|
||
|
|
.footer-row {
|
||
|
|
display: flex;
|
||
|
|
align-items: center;
|
||
|
|
justify-content: space-between;
|
||
|
|
padding-top: 12px;
|
||
|
|
border-top: 1px solid #f0f0f0;
|
||
|
|
}
|
||
|
|
|
||
|
|
.footer-row strong {
|
||
|
|
font-size: 13px;
|
||
|
|
color: #1a1a1a;
|
||
|
|
}
|
||
|
|
|
||
|
|
.error-text {
|
||
|
|
margin: 0;
|
||
|
|
color: #ff4d4f;
|
||
|
|
font-size: 13px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.content {
|
||
|
|
flex: 1;
|
||
|
|
height: 100vh;
|
||
|
|
padding: 24px 32px;
|
||
|
|
overflow-y: auto;
|
||
|
|
}
|
||
|
|
|
||
|
|
@media (max-width: 1080px) {
|
||
|
|
.sidebar {
|
||
|
|
width: 260px;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
</style>
|