Skip to content

Commit d7e0f6f

Browse files
authored
Merge pull request #3 from ClearXs/0.1.x
0.1.x
2 parents 0db0f2a + 069eed8 commit d7e0f6f

File tree

174 files changed

+7065
-4577
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

174 files changed

+7065
-4577
lines changed

package.json

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "clearx",
3-
"version": "0.1.0.beta.1",
2+
"name": "ClearX-Turbo",
3+
"version": "0.1.0",
44
"description": "Turbo快速开发框架",
55
"license": "MIT",
66
"author": "[email protected]",
@@ -35,14 +35,14 @@
3535
"test:cover": "vitest run --coverage"
3636
},
3737
"dependencies": {
38-
"@designable/core": "0.0.1-beta.13",
39-
"@designable/formily-semi": "0.0.1-beta.13",
40-
"@designable/formily-setters": "0.0.1-beta.13",
41-
"@designable/formily-transformer": "0.0.1-beta.13",
42-
"@designable/react": "0.0.1-beta.13",
43-
"@designable/react-sandbox": "0.0.1-beta.13",
44-
"@designable/react-settings-form": "0.0.1-beta.13",
45-
"@designable/shared": "0.0.1-beta.13",
38+
"@designable/core": "0.0.1-beta.22",
39+
"@designable/formily-semi": "0.0.1-beta.22",
40+
"@designable/formily-setters": "0.0.1-beta.22",
41+
"@designable/formily-transformer": "0.0.1-beta.22",
42+
"@designable/react": "0.0.1-beta.22",
43+
"@designable/react-sandbox": "0.0.1-beta.22",
44+
"@designable/react-settings-form": "0.0.1-beta.22",
45+
"@designable/shared": "0.0.1-beta.22",
4646
"@douyinfe/semi-icons": "^2.50.0",
4747
"@douyinfe/semi-illustrations": "^2.50.0",
4848
"@douyinfe/semi-ui": "^2.50.0",
@@ -61,8 +61,10 @@
6161
"iconoir": "^7.2.0",
6262
"iconoir-react": "^7.2.0",
6363
"lodash": "^4.17.21",
64+
"lottie-react": "^2.4.0",
6465
"moment": "^2.29.4",
6566
"react": "^18.2.0",
67+
"react-cache": "2.0.0-alpha.1",
6668
"react-dnd": "^16.0.1",
6769
"react-dnd-html5-backend": "^16.0.1",
6870
"react-dom": "^18.2.0",

pnpm-lock.yaml

+2,033-2,418
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/App.tsx

+65-6
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,83 @@
1+
import '@/pages/developer/editor';
12
import { Layout } from '@douyinfe/semi-ui';
23
import MotionContent from './components/MotionContent';
34
import MotionHeader from './components/MotionHeader';
4-
import { useEffect } from 'react';
5+
import { useEffect, useMemo } from 'react';
56
import { GlobalRegistry } from '@designable/core';
7+
import { SUPPORT_LOCALES } from './components/MotionHeader/Locales';
8+
import { useLoaderData, useLocation } from 'react-router-dom';
9+
import { TurboRoute } from './route/AppRouter';
10+
import { observable } from '@formily/reactive';
11+
import { findRoute } from './route/util';
12+
import { AppContext } from './context';
13+
import { observer } from '@formily/reactive-react';
14+
import { UserTab } from './components/MotionContent/interface';
15+
import { createContentTab } from './components/MotionContent/util';
616
import './locales';
17+
import './theme/default.css';
718

8-
import { SUPPORT_LOCALES } from './components/MotionHeader/Locales';
19+
export type AppProperty = {
20+
// 当前用户route
21+
userRoutes: TurboRoute[];
22+
// 选择顶部菜单的key
23+
selectTopKey: string | undefined;
24+
// 选择侧边菜单的key
25+
selectSideKey: string | undefined;
26+
// 小tab栏
27+
userTabs: UserTab[];
28+
// 选中的小tab栏
29+
selectTabKey: string | undefined;
30+
};
931

1032
export default function App(): React.ReactNode {
33+
const userRoutes = useLoaderData() as TurboRoute[];
34+
const location = useLocation();
35+
36+
const app = useMemo(() => {
37+
const { pathname } = location;
38+
const route = findRoute(pathname, userRoutes);
39+
const app: AppProperty = observable({
40+
userRoutes,
41+
selectTopKey: route ? route.topRouteKey || 'home' : 'home',
42+
selectSideKey: undefined,
43+
userTabs: [],
44+
selectTabKey: undefined,
45+
});
46+
return app;
47+
}, []);
48+
1149
useEffect(() => {
1250
const supportLocales = SUPPORT_LOCALES.map((locales) => locales.value);
1351
if (!supportLocales.includes(GlobalRegistry.getDesignerLanguage())) {
1452
GlobalRegistry.setDesignerLanguage('zh-cn');
1553
}
16-
}, []);
54+
const { pathname } = location;
55+
const route = findRoute(pathname, app.userRoutes);
56+
if (route) {
57+
app.selectTopKey = route.topRouteKey;
58+
app.selectSideKey = route.code;
59+
const newTabs = createContentTab(
60+
app.userTabs,
61+
route,
62+
route.topRouteKey as string,
63+
);
64+
if (newTabs) {
65+
app.userTabs = newTabs;
66+
}
67+
app.selectTabKey = route.code;
68+
}
69+
}, [location]);
1770

71+
return <AppLayout app={app} />;
72+
}
73+
74+
const AppLayout: React.FC<{ app: AppProperty }> = observer(({ app }) => {
1875
return (
1976
<Layout className="h-100vh w-100vw overflow-hidden">
20-
<MotionHeader />
21-
<MotionContent />
77+
<AppContext.Provider value={app}>
78+
<MotionHeader />
79+
<MotionContent />
80+
</AppContext.Provider>
2281
</Layout>
2382
);
24-
}
83+
});

src/api/developer/bo.ts

+34
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,52 @@ export interface Bo extends TenantEntity, CategoryEntity {
3131
}
3232

3333
export interface BoApi extends GeneralApi<Bo> {
34+
check: (boId: string) => Promise<R<boolean>>;
3435
/**
3536
* 获取bo schema
3637
*/
3738
schema: (boId: string) => Promise<R<BoSchema>>;
39+
40+
/**
41+
* 保存bo schema
42+
* @param boSchema bo schema
43+
* @returns
44+
*/
45+
saveSchema: (boSchema: BoSchema) => Promise<R<boolean>>;
46+
47+
/**
48+
* 物化
49+
* @param boId bo id
50+
* @returns true if success
51+
*/
52+
materialize: (boId: string) => Promise<R<boolean>>;
3853
}
3954

4055
class BoApiImpl extends GeneralApiImpl<Bo> implements BoApi {
56+
check(boId: string): Promise<R<boolean>> {
57+
return this.request.get(this.apiPath + `/check/${boId}`).then((res) => {
58+
return res.data;
59+
});
60+
}
61+
materialize(boId: string): Promise<R<boolean>> {
62+
return this.request
63+
.get(this.apiPath + `/materialize/${boId}`)
64+
.then((res) => {
65+
return res.data;
66+
});
67+
}
4168
schema(boId: string): Promise<R<BoSchema>> {
4269
return this.request.get(this.apiPath + `/schema/${boId}`).then((res) => {
4370
return res.data;
4471
});
4572
}
73+
saveSchema(boSchema: BoSchema): Promise<R<boolean>> {
74+
return this.request
75+
.post(this.apiPath + '/save-schema', boSchema)
76+
.then((res) => {
77+
return res.data;
78+
});
79+
}
4680
}
4781

4882
export default function useBoApi(): BoApi {

src/api/developer/dataset.ts

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import useRequest from '@/hook/request';
2+
import {
3+
CategoryEntity,
4+
GeneralApi,
5+
GeneralApiImpl,
6+
TenantEntity,
7+
} from '../interface';
8+
9+
export interface Dataset extends TenantEntity, CategoryEntity {
10+
/**
11+
* 数据集名称
12+
*/
13+
name: string;
14+
15+
/**
16+
* 数据集编码
17+
*/
18+
code: string;
19+
20+
/**
21+
* 来源
22+
*/
23+
source: string;
24+
25+
/**
26+
* 来源id
27+
*/
28+
sourceId: string;
29+
30+
/**
31+
* 配置信息
32+
*/
33+
advanced: string;
34+
35+
/**
36+
* 分类id
37+
*/
38+
categoryId: string;
39+
}
40+
41+
export interface DatasetApi extends GeneralApi<Dataset> {}
42+
43+
class DatasetApiImpl extends GeneralApiImpl<Dataset> implements DatesetApi {}
44+
45+
export default function useDatasetApi(): DatasetApi {
46+
const request = useRequest();
47+
return new DatasetApiImpl('/api/dev/dataset', request);
48+
}

src/api/developer/datasource.ts

+27-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import useRequest from '@/hook/request';
2-
import { GeneralApi, GeneralApiImpl, TenantEntity } from '../interface';
2+
import { GeneralApi, GeneralApiImpl, R, TenantEntity } from '../interface';
33

44
export interface DataSource extends TenantEntity {
55
/**
@@ -10,7 +10,7 @@ export interface DataSource extends TenantEntity {
1010
/**
1111
* 数据源连接地址
1212
*/
13-
url: string;
13+
address: string;
1414

1515
/**
1616
* 连接用户名
@@ -22,17 +22,40 @@ export interface DataSource extends TenantEntity {
2222
*/
2323
password: string;
2424

25+
/**
26+
* 连接数据库
27+
*/
28+
database: string;
29+
2530
/**
2631
* 数据源引擎
2732
*/
2833
engine: string;
2934
}
3035

31-
export interface DataSourceApi extends GeneralApi<DataSource> {}
36+
export interface DataSourceApi extends GeneralApi<DataSource> {
37+
testConnection: (dataSource: DataSource) => Promise<R<boolean>>;
38+
showTables: (id: string) => Promise<R<Record<string, object>>>;
39+
}
3240

3341
class DataSourceApiImpl
3442
extends GeneralApiImpl<DataSource>
35-
implements DataSourceApi {}
43+
implements DataSourceApi
44+
{
45+
testConnection(dataSource: DataSource): Promise<R<boolean>> {
46+
return this.request
47+
.post(this.apiPath + '/test-connection', dataSource)
48+
.then((res) => {
49+
return res.data;
50+
});
51+
}
52+
53+
showTables(id: string): Promise<R<Record<string, object>>> {
54+
return this.request.get(this.apiPath + `/show-tables/${id}`).then((res) => {
55+
return res.data;
56+
});
57+
}
58+
}
3659

3760
export default function useDataSourceApi(): DataSourceApi {
3861
const request = useRequest();

0 commit comments

Comments
 (0)