新版界面:品牌主题(深绿、暖纸色、金色强调)与应用外壳(顶栏、左侧导航、手机抽屉)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4a00b8f3fc
commit
eeea870963
10 files changed
+1331
-348
No files matched your search
+1
-1
@@ -2,7 +2,7 @@
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover" />
|
||||
<title>开单 · 新账系统(新版界面)</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Generated
+1
@@ -6,6 +6,7 @@
|
||||
"": {
|
||||
"name": "ledger-web-next",
|
||||
"dependencies": {
|
||||
"@ant-design/icons": "^5.6.1",
|
||||
"antd": "^5.29.3",
|
||||
"dayjs": "^1.11.23",
|
||||
"react": "^19.3.1",
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ant-design/icons": "^5.6.1",
|
||||
"antd": "^5.29.3",
|
||||
"dayjs": "^1.11.23",
|
||||
"react": "^19.3.1",
|
||||
|
||||
@@ -6,7 +6,7 @@ import { navigate, useRoute } from './lib/router';
|
||||
import type { LedgerState, SessionInfo } from './shared';
|
||||
import { LoginPage } from './pages/Login/LoginPage';
|
||||
import { CreateOrderPage } from './pages/CreateOrder/CreateOrderPage';
|
||||
import { TopBar } from './components/TopBar';
|
||||
import { AppShell } from './components/AppShell';
|
||||
import { RequestStatus } from './components/RequestStatus';
|
||||
|
||||
export function App({ client }: { client: LedgerClient }) {
|
||||
@@ -48,6 +48,7 @@ export function App({ client }: { client: LedgerClient }) {
|
||||
|
||||
if (error)
|
||||
return (
|
||||
<div className="page-center">
|
||||
<Result
|
||||
status="warning"
|
||||
title="系统暂时没有连接上"
|
||||
@@ -58,6 +59,7 @@ export function App({ client }: { client: LedgerClient }) {
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
if (!session)
|
||||
return (
|
||||
@@ -78,10 +80,8 @@ export function App({ client }: { client: LedgerClient }) {
|
||||
</div>
|
||||
);
|
||||
return (
|
||||
<div className="shell">
|
||||
<TopBar client={client} state={state} session={session} onLoggedOut={init} />
|
||||
<AppShell client={client} state={state} session={session} onLoggedOut={init}>
|
||||
<RequestStatus client={client} />
|
||||
<main className="main">
|
||||
<CreateOrderPage
|
||||
key={state.user.id}
|
||||
client={client}
|
||||
@@ -90,7 +90,6 @@ export function App({ client }: { client: LedgerClient }) {
|
||||
refreshState={refreshState}
|
||||
onAccountChanged={init}
|
||||
/>
|
||||
</main>
|
||||
</div>
|
||||
</AppShell>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
import { useState, type ReactNode } from 'react';
|
||||
import { App as AntApp, Button, Drawer, Tag } from 'antd';
|
||||
import { LogoutOutlined, MenuOutlined, RollbackOutlined } from '@ant-design/icons';
|
||||
import type { LedgerClient } from '../lib/api';
|
||||
import { logout, shopName } from '../lib/session';
|
||||
import { modeLabel } from '../lib/format';
|
||||
import { useClientSnapshot } from '../lib/useClient';
|
||||
import type { LedgerState, SessionInfo } from '../shared';
|
||||
import { BrandMark } from './BrandMark';
|
||||
|
||||
// 与旧界面左侧导航相同的分区与编号。旧界面没有可直接定位到某个分区的地址,其余分区统一打开旧版首页(/)。
|
||||
interface NavItem {
|
||||
key: string;
|
||||
no?: string;
|
||||
label: string;
|
||||
}
|
||||
function navItems(role: string): NavItem[] {
|
||||
const owner = role === 'owner';
|
||||
return [
|
||||
{ key: 'create', no: '01', label: '开单' },
|
||||
{ key: 'price-locks', no: '02', label: '待交付' },
|
||||
{ key: 'material-pools', no: '03', label: '每日购料' },
|
||||
{ key: 'recoveries', no: '04', label: '回收/置换' },
|
||||
{ key: 'orders', no: '05', label: '订单' },
|
||||
{ key: 'stock', no: '06', label: '库存' },
|
||||
{ key: 'report', no: '07', label: '每日对账' },
|
||||
...(owner
|
||||
? [
|
||||
{ key: 'team-funds', no: '08', label: '团队账目' },
|
||||
{ key: 'private-operations', no: '09', label: '私域运营概况' },
|
||||
]
|
||||
: [{ key: 'people-entry', label: '登记人数' }]),
|
||||
{ key: 'settings', no: '10', label: owner ? '店铺与打印设置' : '修改密码' },
|
||||
];
|
||||
}
|
||||
|
||||
function SideNav({ role, onNavigate }: { role: string; onNavigate?: () => void }) {
|
||||
return (
|
||||
<nav className="side-nav" aria-label="主要功能">
|
||||
<ul>
|
||||
{navItems(role).map(item =>
|
||||
item.key === 'create' ? (
|
||||
<li key={item.key}>
|
||||
<a className="nav-link active" href="/next/" aria-current="page" onClick={onNavigate}>
|
||||
<span className="nav-no">{item.no}</span>
|
||||
<span className="nav-label">{item.label}</span>
|
||||
</a>
|
||||
</li>
|
||||
) : (
|
||||
<li key={item.key}>
|
||||
<a className="nav-link" href="/" title={'在旧版界面打开「' + item.label + '」'}>
|
||||
<span className="nav-no">{item.no || '··'}</span>
|
||||
<span className="nav-label">{item.label}</span>
|
||||
<span className="nav-old">旧版</span>
|
||||
</a>
|
||||
</li>
|
||||
),
|
||||
)}
|
||||
</ul>
|
||||
<p className="nav-foot">
|
||||
新版界面目前只有开单;
|
||||
<br />
|
||||
其他分区在旧版界面中打开。
|
||||
</p>
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
|
||||
export function AppShell({
|
||||
client,
|
||||
state,
|
||||
session,
|
||||
onLoggedOut,
|
||||
children,
|
||||
}: {
|
||||
client: LedgerClient;
|
||||
state: LedgerState;
|
||||
session: SessionInfo;
|
||||
onLoggedOut: () => void;
|
||||
children: ReactNode;
|
||||
}) {
|
||||
const { message } = AntApp.useApp();
|
||||
const [leaving, setLeaving] = useState(false);
|
||||
const [menuOpen, setMenuOpen] = useState(false);
|
||||
useClientSnapshot(client);
|
||||
const name = shopName(state, session);
|
||||
const who = state.user.label || state.user.name;
|
||||
async function leave() {
|
||||
setLeaving(true);
|
||||
try {
|
||||
await logout(client);
|
||||
onLoggedOut();
|
||||
} catch (err) {
|
||||
message.error((err as Error).message);
|
||||
} finally {
|
||||
setLeaving(false);
|
||||
}
|
||||
}
|
||||
return (
|
||||
<div className="shell">
|
||||
<header className="app-header">
|
||||
<div className="app-header-brand">
|
||||
<Button
|
||||
className="menu-button"
|
||||
type="text"
|
||||
icon={<MenuOutlined />}
|
||||
aria-label="打开导航"
|
||||
aria-expanded={menuOpen}
|
||||
onClick={() => setMenuOpen(true)}
|
||||
/>
|
||||
<BrandMark name={name} />
|
||||
<div className="brand-text">
|
||||
<strong data-testid="store-name">{name}</strong>
|
||||
<small>开单 · 库存 · 订单利润</small>
|
||||
</div>
|
||||
</div>
|
||||
<div className="app-header-right">
|
||||
<Tag className="mode-tag" bordered={false}>
|
||||
{modeLabel(state.mode)}
|
||||
</Tag>
|
||||
<a className="old-ui-link" href="/">
|
||||
<RollbackOutlined aria-hidden="true" /> 返回旧版界面
|
||||
</a>
|
||||
<span className="identity" data-testid="identity" title={'当前账号:' + who}>
|
||||
<span className="identity-avatar" aria-hidden="true">
|
||||
{Array.from(who)[0]}
|
||||
</span>
|
||||
<span className="identity-name">{who}</span>
|
||||
</span>
|
||||
<Button
|
||||
className="logout-button"
|
||||
icon={<LogoutOutlined />}
|
||||
loading={leaving}
|
||||
disabled={client.busy}
|
||||
onClick={() => void leave()}
|
||||
>
|
||||
退出
|
||||
</Button>
|
||||
</div>
|
||||
</header>
|
||||
<div className="app-body">
|
||||
<aside className="app-sider">
|
||||
<SideNav role={state.user.role} />
|
||||
</aside>
|
||||
<Drawer
|
||||
className="nav-drawer"
|
||||
placement="left"
|
||||
width={272}
|
||||
open={menuOpen}
|
||||
onClose={() => setMenuOpen(false)}
|
||||
title={
|
||||
<span className="drawer-title">
|
||||
<BrandMark name={name} />
|
||||
{name}
|
||||
</span>
|
||||
}
|
||||
>
|
||||
<SideNav role={state.user.role} onNavigate={() => setMenuOpen(false)} />
|
||||
<div className="drawer-meta">
|
||||
<Tag bordered={false}>{modeLabel(state.mode)}</Tag>
|
||||
<a href="/">返回旧版界面</a>
|
||||
</div>
|
||||
</Drawer>
|
||||
<main className="main">{children}</main>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// 店铺标志:深绿底、米金色衬线字,取店名首字(与旧界面 .brand-mark 一致)。
|
||||
export function BrandMark({ name, size = 'md' }: { name: string; size?: 'md' | 'lg' }) {
|
||||
return (
|
||||
<span className={'brand-mark brand-mark-' + size} aria-hidden="true">
|
||||
{Array.from(name)[0] || '店'}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
import { useState } from 'react';
|
||||
import { App as AntApp, Button, Tag } from 'antd';
|
||||
import type { LedgerClient } from '../lib/api';
|
||||
import { logout, shopName } from '../lib/session';
|
||||
import { modeLabel } from '../lib/format';
|
||||
import { useClientSnapshot } from '../lib/useClient';
|
||||
import type { LedgerState, SessionInfo } from '../shared';
|
||||
|
||||
export function TopBar({
|
||||
client,
|
||||
state,
|
||||
session,
|
||||
onLoggedOut,
|
||||
}: {
|
||||
client: LedgerClient;
|
||||
state: LedgerState;
|
||||
session: SessionInfo;
|
||||
onLoggedOut: () => void;
|
||||
}) {
|
||||
const { message } = AntApp.useApp();
|
||||
const [leaving, setLeaving] = useState(false);
|
||||
useClientSnapshot(client);
|
||||
const name = shopName(state, session);
|
||||
return (
|
||||
<header className="topbar">
|
||||
<div className="topbar-brand">
|
||||
<span className="brand-mark" aria-hidden="true">
|
||||
{Array.from(name)[0] || '店'}
|
||||
</span>
|
||||
<div>
|
||||
<strong data-testid="store-name">{name}</strong>
|
||||
<small>新版界面 · 开单</small>
|
||||
</div>
|
||||
</div>
|
||||
<div className="topbar-right">
|
||||
<Tag className="mode-tag">{modeLabel(state.mode)}</Tag>
|
||||
<span className="identity" data-testid="identity">
|
||||
{state.user.label || state.user.name}
|
||||
</span>
|
||||
<a className="old-ui-link" href="/">
|
||||
返回旧版界面
|
||||
</a>
|
||||
<Button
|
||||
size="small"
|
||||
loading={leaving}
|
||||
disabled={client.busy}
|
||||
onClick={async () => {
|
||||
setLeaving(true);
|
||||
try {
|
||||
await logout(client);
|
||||
onLoggedOut();
|
||||
} catch (err) {
|
||||
message.error((err as Error).message);
|
||||
} finally {
|
||||
setLeaving(false);
|
||||
}
|
||||
}}
|
||||
>
|
||||
退出
|
||||
</Button>
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
}
|
||||
@@ -6,17 +6,15 @@ import dayjs from 'dayjs';
|
||||
import 'dayjs/locale/zh-cn';
|
||||
import { App } from './App';
|
||||
import { browserClient } from './lib/api';
|
||||
import { applyCssVars, theme } from './theme';
|
||||
import './styles.css';
|
||||
|
||||
dayjs.locale('zh-cn');
|
||||
applyCssVars();
|
||||
const client = browserClient();
|
||||
createRoot(document.getElementById('root')!).render(
|
||||
<StrictMode>
|
||||
<ConfigProvider
|
||||
locale={zhCN}
|
||||
theme={{ token: { colorPrimary: '#9a6a2f', borderRadius: 8, fontSize: 15 } }}
|
||||
componentSize="middle"
|
||||
>
|
||||
<ConfigProvider locale={zhCN} theme={theme} componentSize="middle">
|
||||
<AntApp>
|
||||
<App client={client} />
|
||||
</AntApp>
|
||||
|
||||
+1067
-272
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,77 @@
|
||||
// 品牌主题:沿用旧界面(public/app.css)的深绿、暖纸色与金色强调。所有颜色只在这里定义,
|
||||
// antd 组件通过 ConfigProvider 的 token 取用;styles.css 里的少量自定义样式通过 CSS 变量取用(见 cssVars)。
|
||||
import type { ThemeConfig } from 'antd';
|
||||
|
||||
export const brand = {
|
||||
ink: '#233d35',
|
||||
muted: '#5f6a64', // 旧界面 #68736d 在暖纸底上略低于 4.5:1,这里加深一点以满足 WCAG AA。
|
||||
paper: '#f6f5f0',
|
||||
border: '#dedfd6',
|
||||
borderStrong: '#c9cbbf',
|
||||
gold: '#a97b35',
|
||||
goldText: '#86601f', // 金色用作小号文字时的加深版(对白底 ≥ 4.5:1)。
|
||||
green: '#254e40',
|
||||
greenHover: '#336553',
|
||||
white: '#fffefa',
|
||||
danger: '#a03d31',
|
||||
soft: '#edf2ec',
|
||||
internalText: '#6e4b17',
|
||||
internalTextAlt: '#805617',
|
||||
internalBg: '#fffaf0',
|
||||
internalBgAlt: '#faf7ef',
|
||||
internalBorder: '#d2bf98',
|
||||
internalBorderAlt: '#d9cbae',
|
||||
};
|
||||
|
||||
export const fontFamily = "-apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif";
|
||||
|
||||
export const theme: ThemeConfig = {
|
||||
token: {
|
||||
colorPrimary: brand.green,
|
||||
colorInfo: brand.green,
|
||||
colorSuccess: '#2f6b4f',
|
||||
colorWarning: brand.gold,
|
||||
colorError: brand.danger,
|
||||
colorLink: brand.green,
|
||||
colorLinkHover: brand.greenHover,
|
||||
colorText: brand.ink,
|
||||
colorTextHeading: brand.ink,
|
||||
colorTextSecondary: brand.muted,
|
||||
colorTextDescription: brand.muted,
|
||||
colorBorder: brand.borderStrong,
|
||||
colorBorderSecondary: brand.border,
|
||||
colorBgLayout: brand.paper,
|
||||
colorBgContainer: brand.white,
|
||||
colorBgElevated: '#ffffff',
|
||||
colorFillAlter: brand.internalBgAlt,
|
||||
colorBgContainerDisabled: '#f1f0ea',
|
||||
fontFamily,
|
||||
fontSize: 14,
|
||||
borderRadius: 8,
|
||||
borderRadiusLG: 12,
|
||||
borderRadiusSM: 6,
|
||||
controlHeight: 38,
|
||||
controlHeightLG: 46,
|
||||
controlHeightSM: 28,
|
||||
lineWidthFocus: 2,
|
||||
controlOutline: 'rgba(37, 78, 64, 0.16)',
|
||||
boxShadowTertiary: '0 1px 2px rgba(35, 61, 53, 0.04), 0 2px 8px rgba(35, 61, 53, 0.04)',
|
||||
},
|
||||
components: {
|
||||
Button: { primaryShadow: 'none', defaultShadow: 'none', fontWeight: 500 },
|
||||
Card: { headerFontSize: 16, headerHeight: 56, paddingLG: 24 },
|
||||
Radio: { buttonSolidCheckedBg: brand.green, buttonSolidCheckedHoverBg: brand.greenHover, buttonPaddingInline: 12 },
|
||||
Collapse: { headerBg: brand.white, contentBg: brand.white },
|
||||
Tag: { defaultBg: brand.soft, defaultColor: brand.ink },
|
||||
Tooltip: { colorBgSpotlight: brand.ink },
|
||||
Result: { titleFontSize: 22 },
|
||||
Drawer: { colorBgElevated: brand.white },
|
||||
},
|
||||
};
|
||||
|
||||
// 供 styles.css 使用的 CSS 变量:--ink、--gold、--internal-bg 等,通过 CSSOM 写到根节点(不受 CSP 限制)。
|
||||
export function applyCssVars(root: HTMLElement = document.documentElement) {
|
||||
for (const [key, value] of Object.entries(brand))
|
||||
root.style.setProperty('--' + key.replace(/[A-Z]/g, c => '-' + c.toLowerCase()), value);
|
||||
root.style.setProperty('--font', fontFamily);
|
||||
}
|
||||
Reference in new issue
Block a user