feat(admin-web): prefer runtime account health when ranking and gating accounts
Surface the new runtime_health/runtime_checked_at fields through a tiny desktop-account-runtime helper so PublishArticleModal, MediaView, and TrackingView fall back to the desktop client's last live signal instead of the slower DB column. This keeps the publishable card and tracking breakdown in sync with the desktop probe loop. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import { computed, ref } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
||||
import { mediaApi, resolveApiURL, tenantAccountsApi } from "@/lib/api";
|
||||
import { resolveAccountCheckedAt, resolveAccountHealth } from "@/lib/desktop-account-runtime";
|
||||
import { formatDateTime } from "@/lib/display";
|
||||
import { getPublishPlatformMeta, isPublishPlatformId, normalizePublishPlatformId } from "@/lib/publish-platforms";
|
||||
|
||||
@@ -85,6 +86,7 @@ const mediaAccounts = computed<MediaAccountCard[]>(() => {
|
||||
const platform = platformMap.value.get(platformId);
|
||||
const fallback = getPublishPlatformMeta(platformId);
|
||||
const publishState = resolvePublishState(account);
|
||||
const health = resolveAccountHealth(account);
|
||||
|
||||
return {
|
||||
id: account.id,
|
||||
@@ -96,8 +98,8 @@ const mediaAccounts = computed<MediaAccountCard[]>(() => {
|
||||
displayName: account.display_name,
|
||||
platformUid: normalizePlatformUid(account.platform_uid),
|
||||
avatarUrl: resolveApiURL(account.avatar_url),
|
||||
health: account.health,
|
||||
verifiedAt: account.verified_at,
|
||||
health,
|
||||
verifiedAt: resolveAccountCheckedAt(account),
|
||||
clientId: account.client_id,
|
||||
clientOnline: account.client_online,
|
||||
clientDeviceName: account.client_device_name,
|
||||
@@ -149,7 +151,7 @@ const filteredAccounts = computed(() => {
|
||||
});
|
||||
|
||||
function resolvePublishState(account: DesktopAccountInfo): PublishState {
|
||||
if (account.health !== "live") {
|
||||
if (resolveAccountHealth(account) !== "live") {
|
||||
return "unavailable";
|
||||
}
|
||||
if (!account.client_id) {
|
||||
@@ -165,7 +167,7 @@ function resolvePublishHint(account: DesktopAccountInfo, publishState: PublishSt
|
||||
if (publishState === "queued") {
|
||||
return "客户端当前离线,任务会先进入发布队列,等桌面端上线后自动继续。";
|
||||
}
|
||||
if (account.health !== "live") {
|
||||
if (resolveAccountHealth(account) !== "live") {
|
||||
return "授权状态异常,先在桌面端重新校验后再发布。";
|
||||
}
|
||||
return "还没有绑定桌面客户端,当前无法加入发布队列。";
|
||||
|
||||
@@ -19,6 +19,7 @@ import { useRoute, useRouter } from "vue-router";
|
||||
|
||||
import PageHero from "@/components/PageHero.vue";
|
||||
import { brandsApi, monitoringApi, tenantAccountsApi } from "@/lib/api";
|
||||
import { resolveAccountCheckedAt, resolveAccountHealth } from "@/lib/desktop-account-runtime";
|
||||
import { formatDateTime } from "@/lib/display";
|
||||
import { formatError } from "@/lib/errors";
|
||||
import { isMonitoringPlatformId, normalizeMonitoringPlatformFilter, normalizeMonitoringPlatformId } from "@/lib/monitoring-platforms";
|
||||
@@ -354,8 +355,8 @@ const aiPlatformStatusCards = computed<AIPlatformStatusCard[]>(() => {
|
||||
|
||||
return aiPlatformCatalog.map((platform) => {
|
||||
const matchedAccounts = [...(accountGroups.get(platform.id) ?? [])].sort((left, right) => {
|
||||
const leftAt = Date.parse(left.verified_at ?? "") || 0;
|
||||
const rightAt = Date.parse(right.verified_at ?? "") || 0;
|
||||
const leftAt = Date.parse(resolveAccountCheckedAt(left) ?? "") || 0;
|
||||
const rightAt = Date.parse(resolveAccountCheckedAt(right) ?? "") || 0;
|
||||
return rightAt - leftAt;
|
||||
});
|
||||
const breakdown = breakdownMap.get(platform.id);
|
||||
@@ -537,7 +538,7 @@ function accountAuthLabel(account: DesktopAccountInfo | null): string {
|
||||
return "未绑定";
|
||||
}
|
||||
|
||||
switch (account.health) {
|
||||
switch (resolveAccountHealth(account)) {
|
||||
case "live":
|
||||
return "授权正常";
|
||||
case "captcha":
|
||||
@@ -554,7 +555,7 @@ function accountAuthColor(account: DesktopAccountInfo | null): string {
|
||||
return "default";
|
||||
}
|
||||
|
||||
switch (account.health) {
|
||||
switch (resolveAccountHealth(account)) {
|
||||
case "live":
|
||||
return "green";
|
||||
case "captcha":
|
||||
|
||||
Reference in New Issue
Block a user