feat: manually mirror opencoze's code from bytedance
Change-Id: I09a73aadda978ad9511264a756b2ce51f5761adf
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Outlet, useParams } from 'react-router-dom';
|
||||
|
||||
import { I18n } from '@coze-arch/i18n';
|
||||
import { IconCozIllusAdd } from '@coze-arch/coze-design/illustrations';
|
||||
import { Empty } from '@coze-arch/coze-design';
|
||||
|
||||
import { useInitSpace } from '../../hooks/use-init-space';
|
||||
|
||||
export const SpaceLayout = () => {
|
||||
const { space_id } = useParams();
|
||||
const { loading, spaceListLoading, spaceList } = useInitSpace(space_id);
|
||||
|
||||
if (!loading && !spaceListLoading && spaceList.length === 0) {
|
||||
return (
|
||||
<Empty
|
||||
className="h-full justify-center w-full"
|
||||
image={<IconCozIllusAdd width="160" height="160" />}
|
||||
title={I18n.t('enterprise_workspace_no_space_title')}
|
||||
description={I18n.t('enterprise_workspace_default_tips1_nonspace')}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (loading) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return <Outlet />;
|
||||
};
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { WorkspaceSubMenu as BaseWorkspaceSubMenu } from '@coze-foundation/space-ui-base';
|
||||
import { useSpaceStore } from '@coze-foundation/space-store';
|
||||
import { I18n } from '@coze-arch/i18n';
|
||||
import { useRouteConfig } from '@coze-arch/bot-hooks';
|
||||
import {
|
||||
IconCozBot,
|
||||
IconCozBotFill,
|
||||
IconCozKnowledge,
|
||||
IconCozKnowledgeFill,
|
||||
} from '@coze-arch/coze-design/icons';
|
||||
import { Space, Avatar, Typography } from '@coze-arch/coze-design';
|
||||
|
||||
import { SpaceSubModuleEnum } from '@/const';
|
||||
|
||||
export const WorkspaceSubMenu = () => {
|
||||
const { subMenuKey } = useRouteConfig();
|
||||
|
||||
const currentSpace = useSpaceStore(state => state.space);
|
||||
|
||||
const subMenu = [
|
||||
{
|
||||
icon: <IconCozBot />,
|
||||
activeIcon: <IconCozBotFill />,
|
||||
title: () => I18n.t('navigation_workspace_develop', {}, 'Develop'),
|
||||
path: SpaceSubModuleEnum.DEVELOP,
|
||||
dataTestId: 'navigation_workspace_develop',
|
||||
},
|
||||
{
|
||||
icon: <IconCozKnowledge />,
|
||||
activeIcon: <IconCozKnowledgeFill />,
|
||||
title: () => I18n.t('navigation_workspace_library', {}, 'Library'),
|
||||
path: SpaceSubModuleEnum.LIBRARY,
|
||||
dataTestId: 'navigation_workspace_library',
|
||||
},
|
||||
];
|
||||
|
||||
const headerNode = (
|
||||
<div className="cursor-pointer w-full">
|
||||
<Space
|
||||
className="h-[48px] px-[8px] w-full hover:coz-mg-secondary-hovered rounded-[8px]"
|
||||
spacing={8}
|
||||
>
|
||||
<Avatar
|
||||
className="w-[24px] h-[24px] rounded-[6px] shrink-0"
|
||||
src={currentSpace?.icon_url}
|
||||
/>
|
||||
<Typography.Text
|
||||
ellipsis={{ showTooltip: true, rows: 1 }}
|
||||
className="flex-1 coz-fg-primary text-[14px] font-[500]"
|
||||
>
|
||||
{currentSpace?.name || ''}
|
||||
</Typography.Text>
|
||||
</Space>
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<BaseWorkspaceSubMenu
|
||||
header={headerNode}
|
||||
menus={subMenu}
|
||||
currentSubMenu={subMenuKey}
|
||||
/>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user