Add ONE-OS Web legacy prototypes and sidebar menu folder.
Import desktop web originals into dedicated prototypes with a shared legacy shell, sync script, and a new「ONE-OS Web 端」sidebar section for review alongside existing refactored pages. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
86
src/common/oneosWebLegacy/OneosWebLegacyShell.tsx
Normal file
86
src/common/oneosWebLegacy/OneosWebLegacyShell.tsx
Normal file
@@ -0,0 +1,86 @@
|
||||
import React, { useMemo } from 'react';
|
||||
import { ConfigProvider, Layout, Menu, Typography } from 'antd';
|
||||
import { defineHashPageRoute, useHashPage } from '../useHashPage';
|
||||
import { ensureOneosWebLegacyGlobals } from './legacyGlobals';
|
||||
|
||||
import '../../resources/oneos-web-legacy/styles/oneos-app.css';
|
||||
import '../../resources/oneos-web-legacy/styles/oneos-tokens.css';
|
||||
import '../../resources/oneos-web-legacy/styles/index.css';
|
||||
|
||||
export interface OneosWebLegacyPage {
|
||||
id: string;
|
||||
title: string;
|
||||
component: React.ComponentType;
|
||||
}
|
||||
|
||||
export interface OneosWebLegacyShellProps {
|
||||
moduleTitle: string;
|
||||
pages: OneosWebLegacyPage[];
|
||||
defaultPageId?: string;
|
||||
}
|
||||
|
||||
const oneosTheme = {
|
||||
token: {
|
||||
colorPrimary: '#165dff',
|
||||
borderRadius: 8,
|
||||
fontFamily:
|
||||
'Inter, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif',
|
||||
},
|
||||
};
|
||||
|
||||
export function OneosWebLegacyShell({
|
||||
moduleTitle,
|
||||
pages,
|
||||
defaultPageId,
|
||||
}: OneosWebLegacyShellProps) {
|
||||
ensureOneosWebLegacyGlobals();
|
||||
|
||||
const route = useMemo(
|
||||
() => defineHashPageRoute(
|
||||
pages.map((page) => ({ id: page.id, title: page.title })),
|
||||
{ defaultPageId: defaultPageId ?? pages[0]?.id },
|
||||
),
|
||||
[pages, defaultPageId],
|
||||
);
|
||||
const { page, setPage } = useHashPage(route);
|
||||
const active = pages.find((item) => item.id === page) ?? pages[0];
|
||||
|
||||
if (!active) {
|
||||
return (
|
||||
<Typography.Text type="secondary">
|
||||
未配置可预览页面
|
||||
</Typography.Text>
|
||||
);
|
||||
}
|
||||
|
||||
const ActivePage = active.component;
|
||||
const showMenu = pages.length > 1;
|
||||
|
||||
return (
|
||||
<ConfigProvider theme={oneosTheme}>
|
||||
<Layout style={{ minHeight: '100vh', background: '#f5f7fa' }}>
|
||||
{showMenu ? (
|
||||
<Layout.Sider
|
||||
width={220}
|
||||
theme="light"
|
||||
style={{ borderRight: '1px solid #e5e7eb' }}
|
||||
>
|
||||
<div style={{ padding: '16px 16px 8px', fontWeight: 600 }}>{moduleTitle}</div>
|
||||
<Menu
|
||||
mode="inline"
|
||||
selectedKeys={[active.id]}
|
||||
items={pages.map((item) => ({
|
||||
key: item.id,
|
||||
label: item.title,
|
||||
onClick: () => setPage(item.id),
|
||||
}))}
|
||||
/>
|
||||
</Layout.Sider>
|
||||
) : null}
|
||||
<Layout.Content style={{ minHeight: '100vh', overflow: 'auto' }}>
|
||||
<ActivePage />
|
||||
</Layout.Content>
|
||||
</Layout>
|
||||
</ConfigProvider>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user