Skip to content

Commit

Permalink
fix: 修复问题。
Browse files Browse the repository at this point in the history
  • Loading branch information
JackySoft committed Oct 11, 2024
1 parent 97bef13 commit 316a3dd
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 13 deletions.
8 changes: 6 additions & 2 deletions packages/admin/src/components/Menu/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const MenuComponent: React.FC = () => {
if (item.type === 1 && item.status === 1) {
const iconsList: { [key: string]: any } = Icons;
if (item.buttons?.length || !item.children) {
const path = `/project/${env}/${projectId}/${item.page_id || 0}`;
const path = `/project/${env}/${projectId}/${item.page_id || -item.id}`;
return treeList.push(getMenuItem(item.name, path, iconsList[item.icon] && React.createElement(iconsList[item.icon])));
}
const path = `/project/${env}/${projectId}/${item.id}`;
Expand Down Expand Up @@ -59,7 +59,11 @@ const MenuComponent: React.FC = () => {
const onClick: MenuProps['onClick'] = (e: { key: string }) => {
const key = e.key;
if (pathname === key) return;
navigate(key);
if (Number(e.key.split('/').slice(-1)[0]) < 0) {
navigate('notPublish');
} else {
navigate(key);
}
};

return (
Expand Down
4 changes: 4 additions & 0 deletions packages/admin/src/router/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export const router = [
path: ':pageId',
element: lazyLoad(React.lazy(() => import('@/pages/project'))),
},
{
path: 'notPublish',
element: lazyLoad(React.lazy(() => import('@/pages/500'))),
},
{
path: '*',
element: lazyLoad(React.lazy(() => import('@/pages/project/notFound'))),
Expand Down
13 changes: 9 additions & 4 deletions packages/admin/src/utils/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function isEnv(env?: string) {
* menuMap: 菜单ID映射
* @returns
*/
export function arrayToTree(array: IMenuItem[]) {
export function arrayToTree(array: IMenuItem[] = []) {
const buttons: IMenuItem[] = [];
const pageMap: { [key: number]: IMenuItem } = {};
const menuMap: { [key: number]: IMenuItem } = {};
Expand All @@ -23,8 +23,13 @@ export function arrayToTree(array: IMenuItem[]) {
array.forEach((item) => {
map[item.id] = { ...item };
if (item.type === 2) buttons.push(item);
if ((item.type === 1 || item.type === 3) && item.page_id) pageMap[item.page_id] = { ...item };
if (item.type === 1 || item.type === 3) menuMap[item.id] = { ...item };
if (item.type === 1 || item.type === 3) {
if (item.page_id) {
pageMap[item.page_id] = { ...item };
} else {
menuMap[item.id] = { ...item };
}
}
});

// 找到每个节点的父节点
Expand All @@ -43,7 +48,7 @@ export function arrayToTree(array: IMenuItem[]) {
}
});
const menuTree = Object.values(map)
.filter((item) => item.parent_id === null)
.filter((item) => !item.parent_id)
.sort((a, b) => a.sort_num - b.sort_num);
return {
menuTree,
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/src/packages/Basic/Text/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const MText = ({ id, type, config }: ComponentType, ref: any) => {

return (
visible && (
<Typography.Text style={config.style} {...omit(config.props, ['script'])} text={undefined} data-id={id} data-type={type}>
<Typography.Text style={config.style} {...omit(config.props, ['script', 'text'])} data-id={id} data-type={type}>
{text}
</Typography.Text>
)
Expand Down
7 changes: 4 additions & 3 deletions packages/editor/src/pages/admin/user/CreateUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default function CreateMenu(props: IModalProp<UserItem>) {
});
},
{
wait: 500,
wait: 800,
},
);

Expand Down Expand Up @@ -130,14 +130,15 @@ export default function CreateMenu(props: IModalProp<UserItem>) {
</Radio.Group>
</Form.Item>
{action === 'create' && (
<Form.Item label="用户" name="sso_info" rules={[{ required: true, message: '请输入飞书用户名' }]}>
<Form.Item label="用户" name="sso_info" rules={[{ required: true, message: '请输入用户邮箱' }]}>
<Select
labelInValue
filterOption={true}
filterOption={false}
showSearch
onSearch={run}
notFoundContent={userLoading ? <Spin size="small" /> : null}
options={users}
placeholder="请输入用户完整邮箱"
/>
</Form.Item>
)}
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/src/pages/login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export default function Login() {

<Form.Item style={{ marginTop: 40 }}>
<Button type="primary" block htmlType="submit" loading={loading2}>
登录
{type === 'login' ? '登录' : '注册'}
</Button>
</Form.Item>
<Form.Item style={{ marginTop: 40 }}>
Expand Down
3 changes: 2 additions & 1 deletion packages/editor/src/utils/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export const formatDate = (date?: Date | string, rule?: string) => {

// 递归生成菜单
export function arrayToTree(array: Menu.MenuItem[], parentId = null) {
if (!Array.isArray(array)) return [];
// 创建一个映射,将id映射到节点对象
const map: { [key: number]: Menu.MenuItem & { children?: Menu.MenuItem[] } } = {};
array.forEach((item) => {
Expand All @@ -161,7 +162,7 @@ export function arrayToTree(array: Menu.MenuItem[], parentId = null) {
}
});
return Object.values(map)
.filter((item) => item.parent_id === parentId)
.filter((item) => (parentId ? item.parent_id === parentId : !item.parent_id))
.sort((a, b) => a.sort_num - b.sort_num);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/materials/Basic/Text/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const MText = ({ config }: ComponentType, ref: any) => {

return (
visible && (
<Typography.Text style={config.style} {...omit(config.props, ['script'])}>
<Typography.Text style={config.style} {...omit(config.props, ['script', 'text'])}>
{text}
</Typography.Text>
)
Expand Down

0 comments on commit 316a3dd

Please sign in to comment.