修复:旧浏览器样式与安全操作编号兼容,复用已完成的 Windows 数据库恢复
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { createRequestUuid } from './requestUuid';
|
||||
import { ManagementSections } from './ManagementSections';
|
||||
import { configurationDateTime } from './configurationName';
|
||||
import { alertObject, alertsForStatus, monitorLabel } from './taskMonitorModel';
|
||||
@@ -393,7 +394,7 @@ export function SourceGovernancePanel({ user, currentReleaseId, onUnauthorized }
|
||||
if (actionLock.current) return; actionLock.current = true;
|
||||
try {
|
||||
const value = await changeForm.validateFields(); setActionBusy('change');
|
||||
await api.createSourceChange({ ...value, reason: String(value.reason || '').trim(), idempotencyKey: crypto.randomUUID() });
|
||||
await api.createSourceChange({ ...value, reason: String(value.reason || '').trim(), idempotencyKey: createRequestUuid() });
|
||||
message.success('来源变更申请已提交,当前数据保持不变'); setChangeOpen(false); changeForm.resetFields(); markAffectedResources(['changes', 'candidates']);
|
||||
} catch (value) { if (value && typeof value === 'object' && 'errorFields' in value) return; if (!onUnauthorized(value)) message.error(value instanceof Error ? value.message : '来源变更申请失败'); }
|
||||
finally { actionLock.current = false; setActionBusy(''); }
|
||||
@@ -412,7 +413,7 @@ export function SourceGovernancePanel({ user, currentReleaseId, onUnauthorized }
|
||||
setActionBusy(id);
|
||||
try {
|
||||
const result = await api.releases();
|
||||
await api.buildSourceChange(id, { expectedCurrentReleaseId: result.currentReleaseId ?? null, idempotencyKey: crypto.randomUUID() });
|
||||
await api.buildSourceChange(id, { expectedCurrentReleaseId: result.currentReleaseId ?? null, idempotencyKey: createRequestUuid() });
|
||||
message.success('来源变更处理已完成;请检查候选数据与校验状态。'); markAffectedResources(['changes', 'candidates', 'coverage']);
|
||||
} catch (value) { if (!onUnauthorized(value)) message.error(value instanceof ApiError && value.status === 409 ? '当前数据或申请状态已变化,请刷新核对。' : value instanceof Error ? value.message : '变更处理失败'); if (value instanceof ApiError && value.status === 409) await refreshAffectedCurrent(['changes', 'candidates', 'coverage']); }
|
||||
finally { actionLock.current = false; setActionBusy(''); }
|
||||
@@ -531,7 +532,7 @@ export function BackupOperationsPanel({ user, onUnauthorized, onNavigate }: { us
|
||||
const runJob = async (type: string, backupId?: string) => {
|
||||
if (actionLock.current) return; actionLock.current = true;
|
||||
setBusy(true);
|
||||
try { await api.createBackupJob({ type, ...(backupId ? { backupId } : {}), idempotencyKey: crypto.randomUUID() }); message.success('备份任务已登记'); await load(); }
|
||||
try { await api.createBackupJob({ type, ...(backupId ? { backupId } : {}), idempotencyKey: createRequestUuid() }); message.success('备份任务已登记'); await load(); }
|
||||
catch (value) { if (!onUnauthorized(value)) message.error(value instanceof Error ? value.message : '备份任务提交失败'); }
|
||||
finally { actionLock.current = false; setBusy(false); }
|
||||
};
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { createRequestUuid } from './requestUuid';
|
||||
import { ConfigurationWorkbookActions } from './ConfigurationWorkbookActions';
|
||||
import { MappingEditorContext } from './MappingEditorContext';
|
||||
import { ClassificationRuleEditor } from './ClassificationRuleEditor';
|
||||
@@ -916,7 +917,7 @@ function TaskTable({ items, importOnly, user, onUnauthorized, onRefresh }: { ite
|
||||
setBusyId(id);
|
||||
try {
|
||||
const releases = await api.releases();
|
||||
const result = await api.retryTask(id, { idempotencyKey: crypto.randomUUID(), expectedCurrentReleaseId: releases.currentReleaseId ?? null });
|
||||
const result = await api.retryTask(id, { idempotencyKey: createRequestUuid(), expectedCurrentReleaseId: releases.currentReleaseId ?? null });
|
||||
const body = result && typeof result === 'object' ? result as Record<string, unknown> : {};
|
||||
const run = body.run && typeof body.run === 'object' ? body.run as Record<string, unknown> : {};
|
||||
if (String(run.status).toUpperCase() === 'FAILED') message.error(`重试后仍失败:${toText(run.errorMessage || run.errorCode)}`);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { createRequestUuid } from './requestUuid';
|
||||
import { useDeleteConfirmation } from './useDeleteConfirmation';
|
||||
import { configurationDateTime } from './configurationName';
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
@@ -115,7 +116,7 @@ function SimplifiedDataWorkflow({ options, workflowStatus, pendingDeletion, onBu
|
||||
const period = sourceFilenamePeriod(file.name);
|
||||
const nextMonth = period.month || new Date().getMonth() + 1;
|
||||
const nextYear = period.year || batchYear;
|
||||
return { id: crypto.randomUUID(), file, workbook: result, stage: detected, year: nextYear, month: nextMonth, sheetName: result.preview.sheetName, headerRow: result.preview.headerRow, fieldMap: matchFields(options.fields[detected] || [], result.preview.headers), mode: 'APPEND' as const, fileId: crypto.randomUUID(), targetId: '', scopeCode: options.scopes[0] || 'ALL' };
|
||||
return { id: createRequestUuid(), file, workbook: result, stage: detected, year: nextYear, month: nextMonth, sheetName: result.preview.sheetName, headerRow: result.preview.headerRow, fieldMap: matchFields(options.fields[detected] || [], result.preview.headers), mode: 'APPEND' as const, fileId: createRequestUuid(), targetId: '', scopeCode: options.scopes[0] || 'ALL' };
|
||||
} catch (value) { if (!onUnauthorized(value)) failures.push(`${file.name}:${failure(value)}`); return null; }
|
||||
}));
|
||||
const ready = results.filter(item => item !== null);
|
||||
@@ -350,7 +351,7 @@ function SourceDeletionDialog({ user, sourceId, restoring, sources, onUnauthoriz
|
||||
const [busy, setBusy] = useState(true); const [error, setError] = useState(''); const [notice, setNotice] = useState('');
|
||||
const [reason, setReason] = useState(''); const [confirmed, setConfirmed] = useState(false); const [finished, setFinished] = useState(false);
|
||||
const [candidateId, setCandidateId] = useState(''); const [options, setOptions] = useState<SourceUploadOptions | null>(null);
|
||||
const requestKey = useRef(crypto.randomUUID()); const buildKey = useRef(crypto.randomUUID());
|
||||
const requestKey = useRef(createRequestUuid()); const buildKey = useRef(createRequestUuid());
|
||||
const actionLock = useRef(false); const candidateLock = useRef(false);
|
||||
const showBusy = useDelayedIndicator(busy, 150);
|
||||
const reportError = useCallback((value: unknown) => { if (!onUnauthorized(value)) setError(failure(value)); }, [onUnauthorized]);
|
||||
@@ -371,7 +372,7 @@ function SourceDeletionDialog({ user, sourceId, restoring, sources, onUnauthoriz
|
||||
try {
|
||||
if (kind === 'delete') {
|
||||
const result = await api.deleteSource(sourceId, { expectedCurrentReleaseId: preview.currentReleaseId, expectedDeleteVersion: preview.deleteVersion, ...(preview.currentUsage ? { expectedRevisionId: preview.currentUsage.revisionId } : {}), reason: reason.trim(), idempotencyKey: requestKey.current });
|
||||
setPreview(result); requestKey.current = crypto.randomUUID(); setNotice(result.hidden ? '来源已从日常清单删除,可在“查看已删除来源”中恢复。' : '删除申请已提交,当前正式数据保持不变;下一步由发布者审批。'); setFinished(result.hidden);
|
||||
setPreview(result); requestKey.current = createRequestUuid(); setNotice(result.hidden ? '来源已从日常清单删除,可在“查看已删除来源”中恢复。' : '删除申请已提交,当前正式数据保持不变;下一步由发布者审批。'); setFinished(result.hidden);
|
||||
} else if (kind === 'restore') {
|
||||
const result = await api.restoreSource(sourceId, { expectedCurrentReleaseId: preview.currentReleaseId, expectedDeleteVersion: preview.deleteVersion, reason: reason.trim() });
|
||||
setPreview(result); setNotice('来源已恢复到日常清单。恢复文件清单不会修改已发布的数据结果。'); setFinished(true);
|
||||
@@ -429,7 +430,7 @@ function SourceDeletionDialog({ user, sourceId, restoring, sources, onUnauthoriz
|
||||
}
|
||||
|
||||
function DataUploadWizard({ user, mode, purpose, handoffSourceId, initialReason, options, sources, resumeId, onUnauthorized, onClose, onComplete }: { user: AuthUser; mode: 'ADD' | 'REPLACE' | 'REBUILD'; purpose?: 'WITHDRAW'; handoffSourceId?: string; initialReason?: string; options: SourceUploadOptions; sources: SourceItem[]; resumeId: string; onUnauthorized: (error: unknown) => boolean; onClose: () => void; onComplete: () => void }) {
|
||||
const { message } = App.useApp(); const { active } = usePageCache(); const activeRef = useRef(active); activeRef.current = active; const input = useRef<HTMLInputElement>(null); const generation = useRef(0); const importKey = useRef(crypto.randomUUID()); const publishKey = useRef(crypto.randomUUID());
|
||||
const { message } = App.useApp(); const { active } = usePageCache(); const activeRef = useRef(active); activeRef.current = active; const input = useRef<HTMLInputElement>(null); const generation = useRef(0); const importKey = useRef(createRequestUuid()); const publishKey = useRef(createRequestUuid());
|
||||
const runStorageKey = `quality-import-run:${user.id}`;
|
||||
const [storedRunId] = useState(() => { try { return localStorage.getItem(runStorageKey) || ''; } catch { return ''; } });
|
||||
const [step, setStep] = useState(resumeId ? 4 : storedRunId ? 3 : 0); const [busy, setBusy] = useState(Boolean(storedRunId)); const [error, setError] = useState('');
|
||||
@@ -526,7 +527,7 @@ function DataUploadWizard({ user, mode, purpose, handoffSourceId, initialReason,
|
||||
const uploaded = await api.previewSourceWorkbook(file);
|
||||
const detected = await detectSourceWorkbook(uploaded, options.fields, api.sourceWorkbookPreview);
|
||||
if (!detectedStage) detectedStage = detected.stage;
|
||||
ready.push({ id: crypto.randomUUID(), file, workbook: detected.workbook, sheetName: detected.workbook.preview.sheetName, headerRow: detected.workbook.preview.headerRow, fieldMap: matchFields(options.fields[detectedStage] || [], detected.workbook.preview.headers), fileId: crypto.randomUUID() });
|
||||
ready.push({ id: createRequestUuid(), file, workbook: detected.workbook, sheetName: detected.workbook.preview.sheetName, headerRow: detected.workbook.preview.headerRow, fieldMap: matchFields(options.fields[detectedStage] || [], detected.workbook.preview.headers), fileId: createRequestUuid() });
|
||||
} catch (value) { if (!onUnauthorized(value)) failures.push(`${file.name}:${failure(value)}`); }
|
||||
}
|
||||
if (ownGeneration !== generation.current) return;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { createRequestUuid } from './requestUuid';
|
||||
import { useDeleteConfirmation } from './useDeleteConfirmation';
|
||||
import { newMasterDataCode } from './masterDataIdentity';
|
||||
import { ConfigurationWorkbookActions } from './ConfigurationWorkbookActions';
|
||||
@@ -260,7 +261,7 @@ export function MatchRulesDefinitionEditor({ value, onChange, metadata, readOnly
|
||||
if (!next.name) { setError('请填写规则名称'); return; }
|
||||
if (!next.conditions.length || next.conditions.some(condition => !condition.field || (!['IS_BLANK', 'IS_NOT_BLANK'].includes(condition.operator) && !condition.value))) { setError('请补全每条条件的字段和判断值'); return; }
|
||||
if (!next.value) { setError('请填写匹配结果'); return; }
|
||||
const updated=editing.id ? rules.map(rule => rule.id === editing.id ? next : rule) : [...rules, { ...next, id: `match-${crypto.randomUUID()}` }];
|
||||
const updated=editing.id ? rules.map(rule => rule.id === editing.id ? next : rule) : [...rules, { ...next, id: `match-${createRequestUuid()}` }];
|
||||
const conflicts=matchRuleConflicts(updated);if(conflicts.length){setError(conflicts.join(';'));return;}
|
||||
commit(updated); setEditing(null);
|
||||
}}>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { createRequestUuid } from './requestUuid';
|
||||
import { ManagementSections } from './ManagementSections';
|
||||
import { useCallback, useEffect, useState, useRef } from 'react';
|
||||
import { Alert, App, Button, Drawer, Empty, Progress, Select, Spin, Tag } from 'antd';
|
||||
@@ -45,7 +46,7 @@ export function TasksMonitorPage({user,onUnauthorized}:{user:AuthUser;onUnauthor
|
||||
if(actionInFlight.current)return; actionInFlight.current=true;
|
||||
setBusy(true);
|
||||
try {
|
||||
if(action==='retry') {const releases=await api.releases();await api.retryTask(String(row.id),{idempotencyKey:crypto.randomUUID(),expectedCurrentReleaseId:releases.currentReleaseId??null});}
|
||||
if(action==='retry') {const releases=await api.releases();await api.retryTask(String(row.id),{idempotencyKey:createRequestUuid(),expectedCurrentReleaseId:releases.currentReleaseId??null});}
|
||||
else await api.cancelTask(String(row.id),{expectedStatus:String(row.status)});
|
||||
message.success(action==='retry'?'已提交重试,请查看最新任务状态':'已取消排队任务');setSelected(null);await load();
|
||||
} catch(error){if(!onUnauthorized(error))message.error(error instanceof Error?error.message:'任务操作失败');}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { createRequestUuid } from './requestUuid.ts';
|
||||
type Context = Record<string, unknown> | undefined;
|
||||
export type SubmissionInput = { sessionId: string; question: string; context?: Context; generation: number };
|
||||
export type AnalysisSubmission = SubmissionInput & {
|
||||
@@ -17,7 +18,7 @@ function canonical(value: unknown): string {
|
||||
}
|
||||
|
||||
/** Only an uncertain retry of the same question, session and frozen context reuses its key. */
|
||||
export function beginAnalysisSubmission(previous: AnalysisSubmission | null, input: SubmissionInput, key: () => string = () => crypto.randomUUID()): AnalysisSubmission {
|
||||
export function beginAnalysisSubmission(previous: AnalysisSubmission | null, input: SubmissionInput, key: () => string = () => createRequestUuid()): AnalysisSubmission {
|
||||
const contextKey = canonical(input.context || {});
|
||||
if (previous?.uncertain && previous.generation === input.generation && previous.sessionId === input.sessionId
|
||||
&& previous.question === input.question && previous.contextKey === contextKey) {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
/** 不按浏览器名称判断;只对缺少现代选择器的内核启用降级样式。 */
|
||||
export function needsLegacyComponentStyles(css: Pick<typeof CSS, 'supports'> | undefined = globalThis.CSS): boolean {
|
||||
try { return typeof css?.supports !== 'function' || !css.supports('selector(:where(*))'); }
|
||||
catch { return true; }
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { createRequestUuid } from './requestUuid.ts';
|
||||
import { editClassification, type ClassificationSelection, type ClassificationRuleOptions } from './classificationMaintenance.ts';
|
||||
import type { DataWorkflowOperation, DataWorkflowStatus } from './NoCodeDataTypes.ts';
|
||||
|
||||
@@ -33,7 +34,7 @@ export class ClassificationQueue {
|
||||
let definition=base;
|
||||
for(const job of this.jobs.filter(job=>!['failed','completed'].includes(job.status))) definition=editClassification(definition,job.selection,job.target,defaults,job.options);
|
||||
editClassification(definition,command.selection,command.target,defaults,command.options);
|
||||
const job:ClassificationJob={...structuredClone(command),id:crypto.randomUUID(),status:'queued'};
|
||||
const job:ClassificationJob={...structuredClone(command),id:createRequestUuid(),status:'queued'};
|
||||
this.jobs=[...this.jobs,job];this.emit();void this.run();return job.id;
|
||||
}
|
||||
retry(id: string) {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { StyleProvider, legacyLogicalPropertiesTransformer } from '@ant-design/cssinjs';
|
||||
import { needsLegacyComponentStyles } from './browserStyleCompatibility';
|
||||
import React, { useLayoutEffect, useState } from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import { App, ConfigProvider, theme as antdTheme } from 'antd';
|
||||
@@ -9,6 +11,9 @@ import './dark-theme.css';
|
||||
import './quality-table.css';
|
||||
import './workspace-finish.css';
|
||||
|
||||
const legacyComponentStyles = needsLegacyComponentStyles();
|
||||
const legacyStyleTransformers = [legacyLogicalPropertiesTransformer];
|
||||
|
||||
function QualityCenterApp() {
|
||||
const [themeId, setThemeId] = useState<WorkspaceThemeId>(getStoredWorkspaceThemeId);
|
||||
const appearance = getWorkspaceTheme(themeId);
|
||||
@@ -37,6 +42,7 @@ function QualityCenterApp() {
|
||||
}, [appearance]);
|
||||
|
||||
return (
|
||||
<StyleProvider hashPriority={legacyComponentStyles ? 'high' : undefined} transformers={legacyComponentStyles ? legacyStyleTransformers : undefined}>
|
||||
<ConfigProvider
|
||||
locale={zhCN}
|
||||
theme={{
|
||||
@@ -83,6 +89,7 @@ function QualityCenterApp() {
|
||||
<QualityWorkspace appearance={appearance} onAppearanceChange={setThemeId} />
|
||||
</App>
|
||||
</ConfigProvider>
|
||||
</StyleProvider>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { createRequestUuid } from './requestUuid.ts';
|
||||
/** Internal catalog identity never needs user input. Existing identities survive renames. */
|
||||
export function newMasterDataCode(existing: Iterable<string>): string {
|
||||
const used = existing instanceof Set ? existing : new Set(existing);
|
||||
let code: string;
|
||||
do { code = `REF-${crypto.randomUUID()}`; } while (used.has(code));
|
||||
do { code = `REF-${createRequestUuid()}`; } while (used.has(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
type UuidCrypto = Pick<Crypto, 'getRandomValues'> & { randomUUID?: () => string };
|
||||
|
||||
/** 旧内核与局域网 HTTP 仍使用安全随机数,操作编号保持 UUID v4 格式。 */
|
||||
export function createRequestUuid(source: UuidCrypto | undefined = globalThis.crypto): string {
|
||||
if (typeof source?.randomUUID === 'function') return source.randomUUID();
|
||||
if (typeof source?.getRandomValues !== 'function') throw new Error('当前浏览器无法生成安全操作编号,请升级浏览器后重试');
|
||||
const bytes = source.getRandomValues(new Uint8Array(16));
|
||||
bytes[6] = (bytes[6] & 0x0f) | 0x40;
|
||||
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
||||
const hex = Array.from(bytes, value => value.toString(16).padStart(2, '0')).join('');
|
||||
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
||||
}
|
||||
Reference in New Issue
Block a user