沉淀数字员工角色偏好状态
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
export interface DigitalEmployeeProfileState {
|
||||
name: string;
|
||||
company: string;
|
||||
position: string;
|
||||
currentStatus: string;
|
||||
}
|
||||
|
||||
export interface DigitalEmployeeUiState {
|
||||
selectedDutyIdsByDate: Record<string, string[]>;
|
||||
confirmedDates: Record<string, string>;
|
||||
reportScheduleTime: string;
|
||||
reportGeneratedAtByDate: Record<string, string>;
|
||||
decisionResultsByDate: Record<string, Record<string, string>>;
|
||||
profile: DigitalEmployeeProfileState;
|
||||
consoleRole?: string;
|
||||
rolePreferences?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
interface DigitalEmployeeBridgeWindow {
|
||||
QimingClawBridge?: {
|
||||
digital?: {
|
||||
getUiState?: () => Promise<DigitalEmployeeUiState>;
|
||||
saveUiState?: (update: {
|
||||
state: DigitalEmployeeUiState;
|
||||
action?: string;
|
||||
date?: string;
|
||||
metadata?: Record<string, unknown>;
|
||||
}) => Promise<DigitalEmployeeUiState>;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export function defaultDigitalEmployeeUiState(): DigitalEmployeeUiState {
|
||||
return {
|
||||
selectedDutyIdsByDate: {},
|
||||
confirmedDates: {},
|
||||
reportScheduleTime: '18:00',
|
||||
reportGeneratedAtByDate: {},
|
||||
decisionResultsByDate: {},
|
||||
profile: {
|
||||
name: '飞天数字员工',
|
||||
company: 'qimingclaw 客户端',
|
||||
position: '客户端任务执行员',
|
||||
currentStatus: 'working',
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export async function readDigitalEmployeeUiState(): Promise<DigitalEmployeeUiState | null> {
|
||||
try {
|
||||
return await (window as DigitalEmployeeBridgeWindow).QimingClawBridge?.digital?.getUiState?.() ?? null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export async function saveDigitalEmployeeUiStatePatch(
|
||||
patch: Partial<DigitalEmployeeUiState>,
|
||||
options: { action?: string; date?: string; metadata?: Record<string, unknown> } = {},
|
||||
): Promise<DigitalEmployeeUiState | null> {
|
||||
const bridge = (window as DigitalEmployeeBridgeWindow).QimingClawBridge?.digital;
|
||||
if (!bridge?.saveUiState) return null;
|
||||
try {
|
||||
const current = await bridge.getUiState?.().catch(() => null) ?? null;
|
||||
const state = {
|
||||
...defaultDigitalEmployeeUiState(),
|
||||
...(current ?? {}),
|
||||
...patch,
|
||||
};
|
||||
return await bridge.saveUiState({ state, ...options });
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,8 @@ interface AdapterState {
|
||||
reportScheduleTime: string;
|
||||
reportGeneratedAtByDate: Record<string, string>;
|
||||
decisionResultsByDate: Record<string, Record<string, string>>;
|
||||
consoleRole?: string;
|
||||
rolePreferences?: Record<string, unknown>;
|
||||
profile: {
|
||||
name: string;
|
||||
company: string;
|
||||
@@ -484,6 +486,8 @@ function defaultState(): AdapterState {
|
||||
reportScheduleTime: DEFAULT_REPORT_TIME,
|
||||
reportGeneratedAtByDate: {},
|
||||
decisionResultsByDate: {},
|
||||
consoleRole: 'sales',
|
||||
rolePreferences: {},
|
||||
profile: {
|
||||
name: '飞天数字员工',
|
||||
company: 'qimingclaw 客户端',
|
||||
|
||||
Reference in New Issue
Block a user