feat(client): show digital sync credential gaps
This commit is contained in:
@@ -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