初始化:质量数据分析平台源码
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
import React, { useLayoutEffect, useState } from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import { App, ConfigProvider, theme as antdTheme } from 'antd';
|
||||
import zhCN from 'antd/locale/zh_CN';
|
||||
import QualityWorkspace from './QualityWorkspace';
|
||||
import { getStoredWorkspaceThemeId, getWorkspaceTheme, workspaceThemeStorageKey, type WorkspaceThemeId } from './ui-themes';
|
||||
import './styles.css';
|
||||
import './dark-theme.css';
|
||||
|
||||
function QualityCenterApp() {
|
||||
const [themeId, setThemeId] = useState<WorkspaceThemeId>(getStoredWorkspaceThemeId);
|
||||
const appearance = getWorkspaceTheme(themeId);
|
||||
const dark = appearance.id === 'dark';
|
||||
|
||||
useLayoutEffect(() => {
|
||||
const root = document.documentElement;
|
||||
root.dataset.workspaceTheme = appearance.id;
|
||||
root.style.setProperty('--ink', dark ? '#EAF0FA' : '#111111');
|
||||
root.style.setProperty('--blue', appearance.primary);
|
||||
root.style.setProperty('--blue-dark', dark ? '#A9BDFF' : appearance.primary);
|
||||
root.style.setProperty('--blue-soft', appearance.soft);
|
||||
root.style.setProperty('--blue-muted', appearance.muted);
|
||||
root.style.setProperty('--background', appearance.background);
|
||||
root.style.setProperty('--hover', appearance.hover);
|
||||
root.style.setProperty('--metric-grid', appearance.metricGrid);
|
||||
root.style.setProperty('--metric-grid-head', appearance.metricGridHead);
|
||||
root.style.setProperty('--sidebar-surface', dark ? '#111B2A' : 'color-mix(in srgb, var(--background) 48%, white)');
|
||||
root.style.setProperty('--surface', dark ? '#172234' : '#ffffff');
|
||||
root.style.setProperty('--line', dark ? '#35445A' : '#dfe5ef');
|
||||
root.style.setProperty('--teal', dark ? '#54D5BF' : '#008f7d');
|
||||
try { window.localStorage.setItem(workspaceThemeStorageKey, appearance.id); } catch { /* local preference is optional */ }
|
||||
}, [appearance]);
|
||||
|
||||
return (
|
||||
<ConfigProvider
|
||||
locale={zhCN}
|
||||
theme={{
|
||||
algorithm: dark ? antdTheme.darkAlgorithm : antdTheme.defaultAlgorithm,
|
||||
token: {
|
||||
colorPrimary: appearance.primary,
|
||||
colorInfo: appearance.primary,
|
||||
colorBgBase: dark ? '#101928' : '#ffffff',
|
||||
colorBgContainer: dark ? '#172234' : '#ffffff',
|
||||
// Ant Design 6 renders modal panels on `.ant-modal-container` and
|
||||
// derives their background from this token. Keep it explicit in
|
||||
// light themes so overlays never inherit a transparent default.
|
||||
colorBgElevated: dark ? '#1A2638' : '#ffffff',
|
||||
colorText: dark ? '#EAF0FA' : '#111111',
|
||||
colorTextSecondary: dark ? '#ADBDD1' : '#111111',
|
||||
colorTextPlaceholder: dark ? '#98ABC5' : undefined,
|
||||
colorBorder: dark ? '#35445A' : '#dfe5ef',
|
||||
colorBorderSecondary: dark ? '#35445A' : undefined,
|
||||
borderRadius: 0,
|
||||
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif',
|
||||
controlHeight: 32,
|
||||
fontSize: 14,
|
||||
},
|
||||
components: {
|
||||
Button: { borderRadius: 0 },
|
||||
Input: { borderRadius: 0 },
|
||||
Select: { borderRadius: 0 },
|
||||
Table: { headerBg: dark ? '#202D40' : '#f6f8fd', rowHoverBg: appearance.hover },
|
||||
Modal: { borderRadiusLG: 0 },
|
||||
Drawer: { borderRadiusLG: 0 },
|
||||
},
|
||||
}}
|
||||
>
|
||||
<App>
|
||||
<QualityWorkspace appearance={appearance} onAppearanceChange={setThemeId} />
|
||||
</App>
|
||||
</ConfigProvider>
|
||||
);
|
||||
}
|
||||
|
||||
ReactDOM.createRoot(document.getElementById('root')!).render(
|
||||
<React.StrictMode>
|
||||
<QualityCenterApp />
|
||||
</React.StrictMode>,
|
||||
);
|
||||
Reference in New Issue
Block a user