把「内核怎么知道有这个包」从手写改成生成,漏接直接报错而不是静默 404。 - crates/sspf-plugin:load_static() 收掉装配样板,bootstrap 的 load_packs 缩成一行 - 包统一出口:pub struct Pack + pub const DDLS(生成器不必理解各包常量命名) - 业务 DDL 跟包走(packs/*/schema/*.sql 经 include_str! 编进二进制) - packs_gen.rs / modules/mod.rs 5 段 / Cargo.toml / contract.md 三段改由 pack-sync.py 生成 - scripts/new-pack.sh:一条命令产出 5 个后端文件 + 接线 + 可选前端三件套 - scripts/verify.sh 静态闸门一键跑;.workbuddy 记忆与 HANDOFF 见下一提交
65 lines
1.8 KiB
TypeScript
65 lines
1.8 KiB
TypeScript
import { useEffect, useState } from 'react';
|
|
import { useNavigate } from 'react-router-dom';
|
|
import { currentUser } from '../api/auth';
|
|
import { clearToken } from '../api/request';
|
|
import { wrap, card, btnGhost, btn } from './ui';
|
|
|
|
interface MenuNode {
|
|
id: string;
|
|
fullName: string;
|
|
urlAddress?: string;
|
|
icon?: string;
|
|
parentId: string;
|
|
children: MenuNode[];
|
|
}
|
|
|
|
export default function Dashboard() {
|
|
const nav = useNavigate();
|
|
const [menu, setMenu] = useState<MenuNode[]>([]);
|
|
const [user, setUser] = useState<any>(null);
|
|
|
|
useEffect(() => {
|
|
currentUser()
|
|
.then((d) => {
|
|
setMenu(d.menuList || []);
|
|
setUser(d.userInfo);
|
|
})
|
|
.catch(() => {});
|
|
}, []);
|
|
|
|
function goto(addr?: string) {
|
|
if (addr) nav('/' + addr);
|
|
}
|
|
function logout() {
|
|
clearToken();
|
|
location.reload();
|
|
}
|
|
|
|
return (
|
|
<div style={wrap}>
|
|
<div style={card}>
|
|
<h2>SSW JNPF Lite · React</h2>
|
|
<div style={{ color: '#9aa7b5' }}>
|
|
{user?.userAccount} {user?.isAdministrator ? '(管理员)' : ''}
|
|
</div>
|
|
<h3 style={{ marginTop: 16 }}>功能菜单</h3>
|
|
{menu.map((node) => (
|
|
<div key={node.id} style={{ marginBottom: 10 }}>
|
|
<div style={{ color: '#9aa7b5', fontSize: 12 }}>{node.fullName}</div>
|
|
<div style={{ display: 'flex', gap: 8, flexWrap: 'wrap', marginTop: 4 }}>
|
|
{node.children.map((c) => (
|
|
<button key={c.id} style={btnGhost} onClick={() => goto(c.urlAddress)}>
|
|
{c.fullName}
|
|
</button>
|
|
))}
|
|
</div>
|
|
</div>
|
|
))}
|
|
<button style={{ ...btn, background: '#712b13', marginTop: 12 }} onClick={logout}>
|
|
退出
|
|
</button>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|