Skip to content

Commit 7cec528

Browse files
committed
fix:electron version
1 parent 3d3f288 commit 7cec528

8 files changed

Lines changed: 27 additions & 19 deletions

File tree

chat2db-client/src/blocks/DatabaseTableEditor/ColumnList/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ const ColumnList = forwardRef((props: IProps, ref: ForwardedRef<IColumnListRef>)
273273
}
274274
};
275275

276-
const handelFieldsChange = (field: any) => {
276+
const handleFieldsChange = (field: any) => {
277277
let { value } = field[0];
278278
const { name: nameList } = field[0];
279279
const name = nameList[0];
@@ -462,7 +462,7 @@ const ColumnList = forwardRef((props: IProps, ref: ForwardedRef<IColumnListRef>)
462462
<Button onClick={moveData.bind(null, 'up')}>{i18n('editTable.button.up')}</Button>
463463
<Button onClick={moveData.bind(null, 'down')}>{i18n('editTable.button.down')}</Button>
464464
</div> */}
465-
<Form className={styles.formBox} form={form} onFieldsChange={handelFieldsChange}>
465+
<Form className={styles.formBox} form={form} onFieldsChange={handleFieldsChange}>
466466
<div className={styles.tableBox}>
467467
<DndContext modifiers={[restrictToVerticalAxis]} onDragEnd={onDragEnd}>
468468
<SortableContext items={dataSource.map((i) => i.key!)} strategy={verticalListSortingStrategy}>

chat2db-client/src/blocks/DatabaseTableEditor/IncludeCol/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ const IncludeCol = forwardRef((props: IProps, ref: ForwardedRef<IIncludeColRef>)
207207
});
208208
}
209209

210-
const handelFieldsChange = (field: any) => {
210+
const handleFieldsChange = (field: any) => {
211211
const { value } = field[0];
212212
const { name: nameList } = field[0];
213213
const name = nameList[0];
@@ -241,7 +241,7 @@ const IncludeCol = forwardRef((props: IProps, ref: ForwardedRef<IIncludeColRef>)
241241
<Button onClick={addData}>{i18n('editTable.button.add')}</Button>
242242
{/* <Button onClick={deleteData}>{i18n('editTable.button.delete')}</Button> */}
243243
</div>
244-
<Form className={styles.formBox} form={form} onFieldsChange={handelFieldsChange}>
244+
<Form className={styles.formBox} form={form} onFieldsChange={handleFieldsChange}>
245245
<Table
246246
ref={tableRef}
247247
style={{

chat2db-client/src/blocks/DatabaseTableEditor/IndexList/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ const IndexList = forwardRef((props: IProps, ref: ForwardedRef<IIndexListRef>) =
137137
setDataSource(newList || []);
138138
};
139139

140-
const handelFieldsChange = (field: any) => {
140+
const handleFieldsChange = (field: any) => {
141141
let { value } = field[0];
142142
const { name: nameList } = field[0];
143143
const name = nameList[0];
@@ -376,7 +376,7 @@ const IndexList = forwardRef((props: IProps, ref: ForwardedRef<IIndexListRef>) =
376376
<Button onClick={moveData.bind(null, 'up')}>上移</Button>
377377
<Button onClick={moveData.bind(null, 'down')}>下移</Button>
378378
</div> */}
379-
<Form className={styles.formBox} form={form} onFieldsChange={handelFieldsChange}>
379+
<Form className={styles.formBox} form={form} onFieldsChange={handleFieldsChange}>
380380
<div className={styles.tableBox}>
381381
<DndContext modifiers={[restrictToVerticalAxis]} onDragEnd={onDragEnd}>
382382
<SortableContext items={dataSource.map((i) => i.key!)} strategy={verticalListSortingStrategy}>

chat2db-client/src/layouts/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ declare global {
3535
startServerForSpawn: () => void;
3636
quitApp: () => void;
3737
beforeQuitApp: (fn: () => void) => void;
38+
registerAppMenu: (data:any) => void;
3839
};
3940
}
4041
const __APP_VERSION__: string;
@@ -107,8 +108,12 @@ function AppContainer() {
107108

108109
// 注册Electron关闭时,关闭服务
109110
function registerElectronApi() {
111+
window.electronApi?.registerAppMenu({
112+
version: __APP_VERSION__,
113+
})
114+
110115
window.electronApi?.beforeQuitApp(()=>{
111-
configService.stopJavaService();
116+
configService.stopJavaService()
112117
})
113118
}
114119

chat2db-client/src/main/index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ app.commandLine.appendSwitch('--disable-gpu-sandbox');
5252

5353
app.on('ready', () => {
5454
createWindow();
55-
registerAppMenu();
55+
registerAppMenu(mainWindow);
5656
registerAnalysis();
5757

5858
app.on('activate', function () {
@@ -68,20 +68,21 @@ app.on('window-all-closed', () => {
6868
}
6969
});
7070

71-
app.on('before-quit', (event) => {
71+
app.on('before-quit', () => {
7272
mainWindow.webContents.send('before-quit-app');
7373
});
7474

75-
ipcMain.handle('get-product-name', (event) => {
75+
ipcMain.handle('get-product-name', () => {
7676
const exePath = app.getPath('exe');
7777
const { name } = path.parse(exePath);
7878
return name;
7979
});
8080

8181
// 注册退出应用事件
82-
ipcMain.on('quit-app', (event) => {
82+
ipcMain.on('quit-app', () => {
8383
app.quit();
8484
});
8585

86-
87-
86+
ipcMain.on('register-app-menu', (event, orgs) => {
87+
registerAppMenu(mainWindow, orgs);
88+
});

chat2db-client/src/main/menu.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { shell, app, dialog, BrowserWindow, Menu } = require('electron');
22
const os = require('os');
33
const path = require('path');
4-
const registerAppMenu = (mainWindow) => {
4+
const registerAppMenu = (mainWindow, orgs) => {
55
const menuBar = [
66
{
77
label: 'Chat2DB',
@@ -11,7 +11,7 @@ const registerAppMenu = (mainWindow) => {
1111
click() {
1212
dialog.showMessageBox({
1313
title: '关于Chat2DB',
14-
message: `关于Chat2DB v${app.getVersion()}`,
14+
message: `关于Chat2DB v${orgs?.version || app.getVersion()}`,
1515
detail:
1616
// An intelligent database client and smart BI reporting tool with integrated AI capabilities.
1717
'一个集成AI能力的智能数据库客户端和智能BI报表工具。',

chat2db-client/src/main/preload.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ contextBridge.exposeInMainWorld('electronApi', {
4343
quitApp: () => {
4444
ipcRenderer.send('quit-app');
4545
},
46-
47-
beforeQuitAPP: (callback)=>{
46+
beforeQuitApp: (callback)=>{
4847
ipcRenderer.on('before-quit-app', () => {
4948
callback();
5049
});
50+
},
51+
registerAppMenu: (menuProps)=>{
52+
ipcRenderer.send('register-app-menu', menuProps);
5153
}
5254
});
5355

chat2db-client/src/pages/main/workspace/components/Tree/TreeNodeRightClick/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,12 @@ function TreeNodeRightClick(props: IProps) {
155155
return {
156156
text: data.pinned ? i18n('workspace.menu.unPin') : i18n('workspace.menu.pin'),
157157
icon: data.pinned ? '\ue61d' : '\ue627',
158-
handle: handelTop,
158+
handle: handleTop,
159159
};
160160
},
161161
};
162162

163-
function handelTop() {
163+
function handleTop() {
164164
const api = data.pinned ? 'deleteTablePin' : 'addTablePin';
165165
mysqlServer[api]({
166166
...curWorkspaceParams,

0 commit comments

Comments
 (0)