Skip to content

Commit 8c9f048

Browse files
committed
feat:函数触发器过程
1 parent c0cc2fb commit 8c9f048

22 files changed

Lines changed: 994 additions & 473 deletions

File tree

chat2db-client/.vscode/settings.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,24 @@
2323
"Appstore",
2424
"CLICKHOUSE",
2525
"Cascader",
26+
"Consolas",
2627
"DBAI",
2728
"Dmaven",
2829
"Iconfont",
2930
"JDBC",
3031
"KEYPAIR",
32+
"KINGBASE",
33+
"MARIADB",
3134
"Mddhhmmss",
35+
"Menlo",
36+
"OCEANBASE",
3237
"OPENAI",
38+
"POSTGRESQL",
3339
"RESTAI",
3440
"SQLSERVER",
3541
"Sercurity",
3642
"USERANDPASSWORD",
43+
"VIEWCOLUMN",
3744
"ahooks",
3845
"antd",
3946
"bgcolor",
@@ -45,12 +52,17 @@
4552
"favicons",
4653
"findstr",
4754
"gtag",
55+
"indexs",
4856
"lsof",
4957
"netstat",
5058
"pgsql",
5159
"pnpm",
5260
"remaininguses",
61+
"scrollbar",
5362
"sortablejs",
63+
"ueabe",
64+
"ueabf",
65+
"ueac",
5466
"umijs",
5567
"uuidv",
5668
"wireframe"

chat2db-client/src/components/Iconfont/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ if (__ENV__ === 'local') {
99
/* 在线链接服务仅供平台体验和调试使用,平台不承诺服务的稳定性,企业客户需下载字体包自行发布使用并做好备份。 */
1010
@font-face {
1111
font-family: 'iconfont'; /* Project id 3633546 */
12-
src: url('//at.alicdn.com/t/c/font_3633546_71qdvj9b14y.woff2?t=1689947297468') format('woff2'),
13-
url('//at.alicdn.com/t/c/font_3633546_71qdvj9b14y.woff?t=1689947297468') format('woff'),
14-
url('//at.alicdn.com/t/c/font_3633546_71qdvj9b14y.ttf?t=1689947297468') format('truetype');
12+
src: url('//at.alicdn.com/t/c/font_3633546_26r1r56bfkj.woff2?t=1691821503781') format('woff2'),
13+
url('//at.alicdn.com/t/c/font_3633546_26r1r56bfkj.woff?t=1691821503781') format('woff'),
14+
url('//at.alicdn.com/t/c/font_3633546_26r1r56bfkj.ttf?t=1691821503781') format('truetype');
1515
}
1616
`;
1717
let style = document.createElement('style');

chat2db-client/src/components/Tabs/index.less

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
margin: 0px 2px;
3232
cursor: pointer;
3333
user-select: none;
34+
.text{
35+
display: flex;
36+
align-items: center;
37+
}
3438
&:hover {
3539
.tab-focus();
3640
.text {
@@ -131,3 +135,8 @@
131135
outline: none;
132136
}
133137
}
138+
139+
.prefixIcon{
140+
flex-shrink: 0;
141+
margin-right: 4px;
142+
}

chat2db-client/src/components/Tabs/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import lodash from 'lodash';
55
import styles from './index.less';
66

77
export interface IOption {
8+
prefixIcon?: string;
89
label: string | React.ReactNode;
910
value: number | string;
1011
}
@@ -90,6 +91,7 @@ export default memo<IProps>(function Tab(props) {
9091
<input value={t.label as string} onChange={(e) => { inputOnChange(e.target.value) }} className={styles.input} autoFocus onBlur={onBlur} type="text" />
9192
:
9293
<div className={styles.text} key={t.value} onClick={changeTab.bind(null, t)}>
94+
{t.prefixIcon && <Iconfont className={styles.prefixIcon} code={t.prefixIcon} />}
9395
{t.label}
9496
</div>
9597
}

chat2db-client/src/constants/common.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,34 @@ export enum OSType {
3232
MAC = 'Mac',
3333
RESTS = 'rests',
3434
}
35+
36+
export enum OperationType {
37+
CONSOLE = 'console',
38+
FUNCTION = 'function',
39+
PROCEDURE = 'procedure',
40+
VIEW = 'view',
41+
TRIGGER = 'trigger',
42+
}
43+
44+
export const operationTypeConfig: {
45+
[key in OperationType]: {
46+
icon: string
47+
};
48+
} = {
49+
[OperationType.CONSOLE]: {
50+
icon: '\ue619'
51+
},
52+
[OperationType.VIEW]: {
53+
icon: '\ue647'
54+
},
55+
[OperationType.FUNCTION]: {
56+
icon: '\ue6fd'
57+
},
58+
[OperationType.PROCEDURE]: {
59+
icon: '\ue647'
60+
},
61+
62+
[OperationType.TRIGGER]: {
63+
icon: '\ue647'
64+
}
65+
}

chat2db-client/src/constants/tree.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,15 @@ export enum TreeNodeType {
1111
KEY = 'key',
1212
INDEXES = 'indexes',
1313
INDEX = 'index',
14+
VIEWS = 'views', // 视图组
15+
VIEW = 'view', // 视图
16+
VIEWCOLUMN = 'viewColumn',
17+
VIEWCOLUMNS = 'viewColumns',
18+
FUNCTIONS = 'functions', // 函数组
19+
FUNCTION = 'function', // 函数
20+
PROCEDURES = 'procedures', // procedure组
21+
PROCEDURE = 'procedure', // procedure
22+
TRIGGERS = 'triggers', // trigger组
23+
TRIGGER = 'trigger', // trigger
24+
1425
}

chat2db-client/src/i18n/en-us/workspace.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,8 @@ export default {
1515
'workspace.table.export.cur.csv': 'Export result of current page set csv',
1616
'workspace.table.export.all.insert': 'Export result set insert sql',
1717
'workspace.table.export.cur.insert': 'Export result of current page set insert sql',
18+
'workspace.tree.view': 'View',
19+
'workspace.tree.trigger': 'Trigger',
20+
'workspace.tree.function': 'Function',
21+
'workspace.tree.procedure': 'Procedure',
1822
};

chat2db-client/src/i18n/zh-cn/workspace.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,9 @@ export default {
1414
'workspace.table.export.cur.csv': '导出当前页结果集 csv',
1515
'workspace.table.export.all.insert': '导出结果集 insert sql',
1616
'workspace.table.export.cur.insert': '导出当前页结果集 insert sql',
17+
'workspace.tree.view': '视图',
18+
'workspace.tree.trigger': '触发器',
19+
'workspace.tree.function': '函数',
20+
'workspace.tree.procedure': '过程',
21+
1722
};

chat2db-client/src/models/workspace.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export interface IWorkspaceModelState {
2525
curConsoleId: number | null;
2626
openConsoleList: IConsole[];
2727
curTableList: ITreeNode[];
28+
curViewList: ITreeNode[];
2829
}
2930

3031
export interface IWorkspaceModelType {
@@ -39,13 +40,15 @@ export interface IWorkspaceModelType {
3940
setOpenConsoleList: Reducer<IWorkspaceModelState>;
4041
setCurConsoleId: Reducer<IWorkspaceModelState>;
4142
setCurTableList: Reducer<IWorkspaceModelState>;
43+
setCurViewList: Reducer<IWorkspaceModelState>;
4244
};
4345
effects: {
4446
fetchDatabaseAndSchema: Effect;
4547
fetchDatabaseAndSchemaLoading: Effect;
4648
fetchGetSavedConsole: Effect;
4749
fetchGetCurTableList: Effect;
4850
fetchGetSavedConsoleLoading: Effect;
51+
fetchGetCurViewList: Effect;
4952
};
5053
}
5154

@@ -59,6 +62,7 @@ const WorkspaceModel: IWorkspaceModelType = {
5962
consoleList: [],
6063
openConsoleList: [],
6164
curTableList: [],
65+
curViewList: [],
6266
curConsoleId: null
6367
},
6468

@@ -115,6 +119,14 @@ const WorkspaceModel: IWorkspaceModelType = {
115119
curTableList: payload,
116120
};
117121
},
122+
123+
// 视图列表
124+
setCurViewList(state, { payload }) {
125+
return {
126+
...state,
127+
curViewList: payload,
128+
};
129+
},
118130
},
119131

120132
effects: {
@@ -191,6 +203,26 @@ const WorkspaceModel: IWorkspaceModelType = {
191203
}
192204
catch {
193205

206+
}
207+
},
208+
*fetchGetCurViewList({ payload, callback }, { put, call }) {
209+
try {
210+
const res = (yield treeConfig[TreeNodeType.VIEWS].getChildren!({
211+
pageNo: 1,
212+
pageSize: 999,
213+
...payload,
214+
})) as ITreeNode[];
215+
// 异步操作完成后调用回调函数
216+
if (callback && typeof callback === 'function') {
217+
callback(res);
218+
}
219+
yield put({
220+
type: 'setCurViewList',
221+
payload: res,
222+
});
223+
}
224+
catch {
225+
194226
}
195227
},
196228
},
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
@import '../../../../../styles/var.less';
2+
3+
.saveModule {
4+
flex-shrink: 0;
5+
}
6+
7+
.leftModuleTitle {
8+
flex-shrink: 0;
9+
margin-bottom: 10px;
10+
.leftModuleTitleText {
11+
display: flex;
12+
justify-content: space-between;
13+
align-items: center;
14+
height: 26px;
15+
.modelName {
16+
font-weight: bold;
17+
}
18+
.iconBox {
19+
display: flex;
20+
align-items: center;
21+
}
22+
.refreshIcon {
23+
margin-right: 10px;
24+
}
25+
.refreshIcon,
26+
.searchIcon {
27+
cursor: pointer;
28+
&:hover {
29+
color: var(--color-primary);
30+
}
31+
}
32+
}
33+
.leftModuleTitleSearch {
34+
height: 26px;
35+
}
36+
}
37+
38+
.saveBoxList {
39+
margin: 0px -10px;
40+
height: calc(26px * 3 + 6px);
41+
overflow-y: auto;
42+
}
43+
44+
.saveItem {
45+
display: flex;
46+
justify-content: space-between;
47+
align-items: center;
48+
padding: 0px 10px;
49+
margin-bottom: 2px;
50+
line-height: 26px;
51+
border-radius: 2px;
52+
user-select: none;
53+
cursor: pointer;
54+
.saveItemText{
55+
width: 0px;
56+
flex: 1;
57+
.f-single-line();
58+
}
59+
.moreButton {
60+
flex-shrink: 0;
61+
display: none;
62+
transform: rotate(90deg);
63+
}
64+
65+
&:hover {
66+
background-color: var(--color-hover-bg);
67+
color: var(--color-primary);
68+
.moreButton {
69+
display: block;
70+
}
71+
}
72+
}

0 commit comments

Comments
 (0)