-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from ClearXs/0.1.x
0.1.x
- Loading branch information
Showing
174 changed files
with
7,065 additions
and
4,577 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,83 @@ | ||
import '@/pages/developer/editor'; | ||
import { Layout } from '@douyinfe/semi-ui'; | ||
import MotionContent from './components/MotionContent'; | ||
import MotionHeader from './components/MotionHeader'; | ||
import { useEffect } from 'react'; | ||
import { useEffect, useMemo } from 'react'; | ||
import { GlobalRegistry } from '@designable/core'; | ||
import { SUPPORT_LOCALES } from './components/MotionHeader/Locales'; | ||
import { useLoaderData, useLocation } from 'react-router-dom'; | ||
import { TurboRoute } from './route/AppRouter'; | ||
import { observable } from '@formily/reactive'; | ||
import { findRoute } from './route/util'; | ||
import { AppContext } from './context'; | ||
import { observer } from '@formily/reactive-react'; | ||
import { UserTab } from './components/MotionContent/interface'; | ||
import { createContentTab } from './components/MotionContent/util'; | ||
import './locales'; | ||
import './theme/default.css'; | ||
|
||
import { SUPPORT_LOCALES } from './components/MotionHeader/Locales'; | ||
export type AppProperty = { | ||
// 当前用户route | ||
userRoutes: TurboRoute[]; | ||
// 选择顶部菜单的key | ||
selectTopKey: string | undefined; | ||
// 选择侧边菜单的key | ||
selectSideKey: string | undefined; | ||
// 小tab栏 | ||
userTabs: UserTab[]; | ||
// 选中的小tab栏 | ||
selectTabKey: string | undefined; | ||
}; | ||
|
||
export default function App(): React.ReactNode { | ||
const userRoutes = useLoaderData() as TurboRoute[]; | ||
const location = useLocation(); | ||
|
||
const app = useMemo(() => { | ||
const { pathname } = location; | ||
const route = findRoute(pathname, userRoutes); | ||
const app: AppProperty = observable({ | ||
userRoutes, | ||
selectTopKey: route ? route.topRouteKey || 'home' : 'home', | ||
selectSideKey: undefined, | ||
userTabs: [], | ||
selectTabKey: undefined, | ||
}); | ||
return app; | ||
}, []); | ||
|
||
useEffect(() => { | ||
const supportLocales = SUPPORT_LOCALES.map((locales) => locales.value); | ||
if (!supportLocales.includes(GlobalRegistry.getDesignerLanguage())) { | ||
GlobalRegistry.setDesignerLanguage('zh-cn'); | ||
} | ||
}, []); | ||
const { pathname } = location; | ||
const route = findRoute(pathname, app.userRoutes); | ||
if (route) { | ||
app.selectTopKey = route.topRouteKey; | ||
app.selectSideKey = route.code; | ||
const newTabs = createContentTab( | ||
app.userTabs, | ||
route, | ||
route.topRouteKey as string, | ||
); | ||
if (newTabs) { | ||
app.userTabs = newTabs; | ||
} | ||
app.selectTabKey = route.code; | ||
} | ||
}, [location]); | ||
|
||
return <AppLayout app={app} />; | ||
} | ||
|
||
const AppLayout: React.FC<{ app: AppProperty }> = observer(({ app }) => { | ||
return ( | ||
<Layout className="h-100vh w-100vw overflow-hidden"> | ||
<MotionHeader /> | ||
<MotionContent /> | ||
<AppContext.Provider value={app}> | ||
<MotionHeader /> | ||
<MotionContent /> | ||
</AppContext.Provider> | ||
</Layout> | ||
); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import useRequest from '@/hook/request'; | ||
import { | ||
CategoryEntity, | ||
GeneralApi, | ||
GeneralApiImpl, | ||
TenantEntity, | ||
} from '../interface'; | ||
|
||
export interface Dataset extends TenantEntity, CategoryEntity { | ||
/** | ||
* 数据集名称 | ||
*/ | ||
name: string; | ||
|
||
/** | ||
* 数据集编码 | ||
*/ | ||
code: string; | ||
|
||
/** | ||
* 来源 | ||
*/ | ||
source: string; | ||
|
||
/** | ||
* 来源id | ||
*/ | ||
sourceId: string; | ||
|
||
/** | ||
* 配置信息 | ||
*/ | ||
advanced: string; | ||
|
||
/** | ||
* 分类id | ||
*/ | ||
categoryId: string; | ||
} | ||
|
||
export interface DatasetApi extends GeneralApi<Dataset> {} | ||
|
||
class DatasetApiImpl extends GeneralApiImpl<Dataset> implements DatesetApi {} | ||
|
||
export default function useDatasetApi(): DatasetApi { | ||
const request = useRequest(); | ||
return new DatasetApiImpl('/api/dev/dataset', request); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.