feat(design-center): 集中式设计中心,替代每页设计按钮
用户反馈每个功能页右上角一颗「设计」按钮散落、不合理。改为: - 新增 /design-center 页(DesignCenterPage):列全部功能页(按菜单分组+计数+ 搜索),每页一个「设计」入口开 editor.html;复用 fetchMenu/collectLeaves。 - Topbar 加 admin-only「设计中心」入口(brush 图标),useNavigate 直达。 - PageRenderPage 移除每页 DesignButton(及 getProfile import)。 验证:浏览器 /design-center 渲染 812 页/14 分组、顶栏按钮在、点行选中并存。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -8,7 +8,6 @@ import { fetchSchema } from '../api/schema';
|
||||
import { AmisRenderer } from '../components/AmisRenderer';
|
||||
import { recordRecentPage } from '../utils/recentPages';
|
||||
import { useTabTitle } from '../shell/TabTitleContext';
|
||||
import { getProfile } from '../auth/token';
|
||||
|
||||
// ---- amis 渲染层错误边界(class component,捕获子树抛错)----
|
||||
interface ErrorBoundaryState {
|
||||
@@ -71,36 +70,6 @@ function SchemaErrorCard({ templateId, summary }: { templateId: string; summary:
|
||||
);
|
||||
}
|
||||
|
||||
// ---- 管理员设计按钮 ----
|
||||
function DesignButton({ templateId }: { templateId: string }) {
|
||||
const profile = getProfile();
|
||||
const isAdmin = profile?.account === 'admin' || profile?.userId === 'ADMIN';
|
||||
if (!isAdmin) return null;
|
||||
return (
|
||||
<button
|
||||
data-testid="designer-open-btn"
|
||||
onClick={() => window.open(`/editor.html?templateId=${encodeURIComponent(templateId)}`, '_blank')}
|
||||
style={{
|
||||
position: 'absolute',
|
||||
top: 8,
|
||||
right: 12,
|
||||
zIndex: 10,
|
||||
background: '#1890ff',
|
||||
color: '#fff',
|
||||
border: 'none',
|
||||
borderRadius: 4,
|
||||
padding: '4px 12px',
|
||||
cursor: 'pointer',
|
||||
fontSize: 12,
|
||||
fontWeight: 500,
|
||||
opacity: 0.85,
|
||||
}}
|
||||
>
|
||||
设计
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
// ---- 主组件 ----
|
||||
export function PageRenderPage() {
|
||||
const { templateId = '' } = useParams();
|
||||
@@ -147,7 +116,7 @@ export function PageRenderPage() {
|
||||
}
|
||||
return (
|
||||
<div style={{ height: '100%', position: 'relative' }} data-testid="amis-host">
|
||||
<DesignButton templateId={templateId} />
|
||||
{/* 设计入口已收敛到顶栏「设计中心」(admin),不再每页一颗按钮 */}
|
||||
<AmisErrorBoundary templateId={templateId}>
|
||||
<AmisRenderer schema={schema} />
|
||||
</AmisErrorBoundary>
|
||||
|
||||
Reference in New Issue
Block a user