精简平台配置顶部区域
This commit is contained in:
@@ -25,7 +25,7 @@ import {
|
||||
Typography,
|
||||
} from 'antd'
|
||||
import type { TableColumnsType } from 'antd'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useSearchParams } from 'react-router'
|
||||
|
||||
import PageHeader from '@/components/admin/PageHeader'
|
||||
@@ -58,7 +58,6 @@ import {
|
||||
validateAdminCloudtentaclesSession,
|
||||
} from '@/services/admin'
|
||||
import type {
|
||||
AdminCloudtentaclesSessionsMap,
|
||||
AdminCloudtentaclesSourceConfigResponse,
|
||||
AdminCloudtentaclesSourceItem,
|
||||
AdminKuaishouEticketDetailResult,
|
||||
@@ -131,28 +130,6 @@ export default function AdminPlatformShopsPage() {
|
||||
useState<AdminCloudtentaclesSourceConfigResponse | null>(null)
|
||||
const [ninetyoneData, setNinetyoneData] = useState<AdminNinetyoneOrderListResult | null>(null)
|
||||
|
||||
const overviewCards = useMemo(
|
||||
() =>
|
||||
buildOverviewCards({
|
||||
notificationConfig,
|
||||
scheduledJobs,
|
||||
eticketConfig,
|
||||
feifeiConfig,
|
||||
cloudtentaclesConfig,
|
||||
ninetyoneData,
|
||||
}),
|
||||
[
|
||||
cloudtentaclesConfig,
|
||||
eticketConfig,
|
||||
feifeiConfig,
|
||||
ninetyoneData,
|
||||
notificationConfig,
|
||||
scheduledJobs,
|
||||
],
|
||||
)
|
||||
const activeOverview =
|
||||
overviewCards.find((card) => card.key === activeTab) || overviewCards[0]
|
||||
|
||||
useEffect(() => {
|
||||
void loadConfigs()
|
||||
}, [])
|
||||
@@ -225,22 +202,6 @@ export default function AdminPlatformShopsPage() {
|
||||
</Card>
|
||||
) : (
|
||||
<>
|
||||
<Card className="platform-active-summary">
|
||||
<div>
|
||||
<div className="summary-kicker">{activeOverview.tag}</div>
|
||||
<Typography.Title level={3}>{activeOverview.label}</Typography.Title>
|
||||
<p>{activeOverview.meta}</p>
|
||||
</div>
|
||||
<Space size={16} wrap>
|
||||
<MetricCard
|
||||
label={activeOverview.unit}
|
||||
value={String(activeOverview.value)}
|
||||
detail={activeOverview.status}
|
||||
/>
|
||||
<Tag color={activeOverview.statusColor}>{activeOverview.status}</Tag>
|
||||
</Space>
|
||||
</Card>
|
||||
|
||||
<Tabs
|
||||
activeKey={activeTab}
|
||||
onChange={updateActiveTab}
|
||||
@@ -1598,80 +1559,3 @@ function normalizePlatformTab(value: unknown): PlatformTab {
|
||||
? (value as PlatformTab)
|
||||
: 'ninetyone'
|
||||
}
|
||||
|
||||
function buildOverviewCards({
|
||||
notificationConfig,
|
||||
scheduledJobs,
|
||||
eticketConfig,
|
||||
feifeiConfig,
|
||||
cloudtentaclesConfig,
|
||||
ninetyoneData,
|
||||
}: {
|
||||
notificationConfig: NotificationConfigResponse | null
|
||||
scheduledJobs: ScheduledJobsState | null
|
||||
eticketConfig: { filePath: string; source: AdminKuaishouEticketSourceConfig } | null
|
||||
feifeiConfig: AdminKuaishouFeifeiConfigResponse | null
|
||||
cloudtentaclesConfig: AdminCloudtentaclesSourceConfigResponse | null
|
||||
ninetyoneData: AdminNinetyoneOrderListResult | null
|
||||
}) {
|
||||
const barkRecipients = notificationConfig?.source.channels.bark.recipients || []
|
||||
const wpushRecipients = notificationConfig?.source.channels.wpush.recipients || []
|
||||
const eticketShops = eticketConfig?.source.shops || []
|
||||
const feifeiRules = feifeiConfig?.source.productRules || []
|
||||
const cloudSources = cloudtentaclesConfig?.sources || []
|
||||
const cloudSessions: AdminCloudtentaclesSessionsMap = cloudtentaclesConfig?.sessions || {}
|
||||
const cloudReadyCount = cloudSources.filter((source) => source.enabled !== false && cloudSessions[source.key]?.hasToken).length
|
||||
|
||||
return [
|
||||
{
|
||||
key: 'notifications',
|
||||
label: '内部通知',
|
||||
tag: '通知与监控',
|
||||
value: barkRecipients.filter((item) => item.enabled !== false).length + wpushRecipients.filter((item) => item.enabled !== false).length,
|
||||
unit: '启用接收人',
|
||||
meta: `Bark ${barkRecipients.length} 人 · WPush ${wpushRecipients.length} 人 · 任务 ${scheduledJobs?.source.jobs.length || 0} 个`,
|
||||
status: notificationConfig?.source.enabled ? '已启用' : '待配置',
|
||||
statusColor: notificationConfig?.source.enabled ? 'green' : 'orange',
|
||||
},
|
||||
{
|
||||
key: 'ninetyone',
|
||||
label: '91卡券',
|
||||
tag: '来源订单',
|
||||
value: ninetyoneData?.total || 0,
|
||||
unit: '当前订单',
|
||||
meta: `当前页 ${ninetyoneData?.items.length || 0} 条 · 用于补全订单和生成任务`,
|
||||
status: (ninetyoneData?.total || 0) > 0 ? '可查看' : '正常',
|
||||
statusColor: 'blue',
|
||||
},
|
||||
{
|
||||
key: 'kuaishouEticket',
|
||||
label: '快手小店核销',
|
||||
tag: '店铺凭据',
|
||||
value: eticketShops.length,
|
||||
unit: '已配置店铺',
|
||||
meta: `Cookie 就绪 ${eticketShops.filter((shop) => shop.hasCookie || shop.cookie).length} 家`,
|
||||
status: eticketShops.some((shop) => shop.hasCookie || shop.cookie) ? '已就绪' : '待配置',
|
||||
statusColor: eticketShops.some((shop) => shop.hasCookie || shop.cookie) ? 'green' : 'orange',
|
||||
},
|
||||
{
|
||||
key: 'kuaishouFeifei',
|
||||
label: 'kuaishou-feifei',
|
||||
tag: '补充发货平台',
|
||||
value: feifeiRules.filter((rule) => rule.enabled !== false).length,
|
||||
unit: '启用规则',
|
||||
meta: `API ${feifeiConfig?.effective.hasAppKey && feifeiConfig.effective.hasAppSecret ? '已配置' : '待补全'} · 总规则 ${feifeiRules.length} 条`,
|
||||
status: feifeiConfig?.effective.enabled ? '已启用' : '待配置',
|
||||
statusColor: feifeiConfig?.effective.enabled ? 'green' : 'orange',
|
||||
},
|
||||
{
|
||||
key: 'cloudtentacles',
|
||||
label: 'cloudtentacles',
|
||||
tag: '履约账号',
|
||||
value: `${cloudReadyCount} / ${cloudSources.length}`,
|
||||
unit: '可用账号',
|
||||
meta: `会话文件:${cloudtentaclesConfig?.sessionFilePath || '-'}`,
|
||||
status: cloudReadyCount > 0 ? '已验证' : '待验证',
|
||||
statusColor: cloudReadyCount > 0 ? 'green' : 'orange',
|
||||
},
|
||||
] as const
|
||||
}
|
||||
|
||||
@@ -712,34 +712,16 @@ select {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.platform-tabs > .ant-tabs-nav {
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.platform-panel-stack {
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.platform-active-summary .ant-card-body {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 18px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.platform-active-summary h3 {
|
||||
margin: 4px 0 0 !important;
|
||||
}
|
||||
|
||||
.platform-active-summary p {
|
||||
margin: 8px 0 0;
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
.summary-kicker {
|
||||
color: #1677ff;
|
||||
font-size: 12px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.metric-grid {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
@@ -974,10 +956,6 @@ select {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.platform-active-summary .ant-card-body {
|
||||
display: grid;
|
||||
}
|
||||
|
||||
.cloud-records-filter {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user