feat(client): show digital sync credential gaps
This commit is contained in:
@@ -57,6 +57,7 @@ interface QimingclawSyncStatus {
|
||||
syncing: boolean;
|
||||
enabled: boolean;
|
||||
endpoint: string | null;
|
||||
missingCredentials?: string[];
|
||||
pending: number;
|
||||
failed: number;
|
||||
lastSyncAt: string | null;
|
||||
|
||||
@@ -57,6 +57,7 @@ interface ManagementSyncStatus {
|
||||
syncing: boolean;
|
||||
enabled: boolean;
|
||||
endpoint: string | null;
|
||||
missingCredentials?: string[];
|
||||
pending: number;
|
||||
failed: number;
|
||||
lastSyncAt: string | null;
|
||||
@@ -448,6 +449,7 @@ function summarizeSyncError(value?: string | null): string {
|
||||
function syncStatusTone(status: ManagementSyncStatus | null): 'info' | 'success' | 'warning' | 'danger' {
|
||||
if (!status) return 'info';
|
||||
if (!status.enabled || !status.endpoint) return 'warning';
|
||||
if ((status.missingCredentials?.length ?? 0) > 0) return 'warning';
|
||||
if (status.failed > 0 || status.lastSyncError) return 'danger';
|
||||
if (status.syncing || status.pending > 0) return 'warning';
|
||||
return status.lastSyncAt ? 'success' : 'info';
|
||||
@@ -457,6 +459,7 @@ function syncStatusLabel(status: ManagementSyncStatus | null): string {
|
||||
if (!status) return '未连接';
|
||||
if (!status.enabled) return '已停用';
|
||||
if (!status.endpoint) return '未配置';
|
||||
if ((status.missingCredentials?.length ?? 0) > 0) return '缺少凭据';
|
||||
if (status.syncing) return '同步中';
|
||||
if (status.failed > 0 || status.lastSyncError) return '同步异常';
|
||||
if (status.pending > 0) return '待同步';
|
||||
@@ -467,6 +470,9 @@ function syncStatusSummary(status: ManagementSyncStatus | null): string {
|
||||
if (!status) return '当前环境未连接 qimingclaw 同步桥。';
|
||||
if (!status.enabled) return '管理端同步已停用。';
|
||||
if (!status.endpoint) return '管理端同步地址未配置。';
|
||||
if ((status.missingCredentials?.length ?? 0) > 0) {
|
||||
return `管理端同步凭据未完整:${status.missingCredentials?.join('、')}`;
|
||||
}
|
||||
const error = summarizeSyncError(status.lastSyncError);
|
||||
if (status.failed > 0 || error) {
|
||||
const retrySummary = status.failureSummary
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -13,7 +13,7 @@
|
||||
console.warn("[qimingclaw] digital employee auth bootstrap skipped", error);
|
||||
}
|
||||
</script>
|
||||
<script type="module" crossorigin src="./assets/index-BKHFgVhX.js"></script>
|
||||
<script type="module" crossorigin src="./assets/index-gtzF6MAO.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="./assets/index-ReBtI0Fy.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -95,6 +95,7 @@ export interface DigitalEmployeeSyncStatus {
|
||||
syncing: boolean;
|
||||
enabled: boolean;
|
||||
endpoint: string | null;
|
||||
missingCredentials: string[];
|
||||
pending: number;
|
||||
failed: number;
|
||||
lastSyncAt: string | null;
|
||||
@@ -132,6 +133,7 @@ export function getDigitalEmployeeSyncStatus(): DigitalEmployeeSyncStatus {
|
||||
syncing,
|
||||
enabled: config.enabled,
|
||||
endpoint: config.endpoint,
|
||||
missingCredentials: missingSyncCredentialLabels(config),
|
||||
pending: countOutbox("pending"),
|
||||
failed: countOutbox("failed"),
|
||||
lastSyncAt,
|
||||
@@ -147,7 +149,11 @@ export async function flushDigitalEmployeeSyncOutbox(
|
||||
if (syncing) return getDigitalEmployeeSyncStatus();
|
||||
|
||||
const config = resolveSyncConfig();
|
||||
if (!config.enabled || !config.endpoint || !config.clientKey || !config.authToken) {
|
||||
if (
|
||||
!config.enabled ||
|
||||
!config.endpoint ||
|
||||
missingSyncCredentialLabels(config).length > 0
|
||||
) {
|
||||
lastSyncError = null;
|
||||
return getDigitalEmployeeSyncStatus();
|
||||
}
|
||||
@@ -255,6 +261,15 @@ function buildEndpoint(serverHost: string | null): string | null {
|
||||
return `${normalized.replace(/\/+$/, "")}${DEFAULT_SYNC_PATH}`;
|
||||
}
|
||||
|
||||
function missingSyncCredentialLabels(
|
||||
config: DigitalEmployeeSyncConfig,
|
||||
): string[] {
|
||||
return [
|
||||
config.clientKey ? "" : "客户端 Key",
|
||||
config.authToken ? "" : "登录 token",
|
||||
].filter((value): value is string => Boolean(value));
|
||||
}
|
||||
|
||||
function readClientKey(serverHost: string | null): string | null {
|
||||
const username = readSetting("auth.username");
|
||||
const globalKey = readSetting("auth.saved_key");
|
||||
|
||||
Reference in New Issue
Block a user