Skip to content

Commit ece57d4

Browse files
committed
fix:electron build
1 parent 7e5a5a4 commit ece57d4

5 files changed

Lines changed: 39 additions & 8 deletions

File tree

chat2db-client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
"asar": false,
9797
"files": [
9898
"dist/**/*",
99-
"src/main/preload.js",
99+
"src/main",
100100
"src/main/main.js",
101101
"versions/**/*",
102102
"package.json",

chat2db-client/src/blocks/AppTitleBar/index.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import React, { memo } from 'react';
22
import styles from './index.less';
33
import classnames from 'classnames';
4-
import CustomLayout from '@/components/CustomLayout';
5-
import Iconfont from '@/components/Iconfont';
4+
import { useCommonStore } from '@/store/common';
5+
6+
// import Iconfont from '@/components/Iconfont';
67

78
interface IProps {
89
className?: string;
@@ -11,6 +12,12 @@ interface IProps {
1112
export default memo<IProps>((props) => {
1213
const { className } = props;
1314

15+
const { appTitleBarRightComponent } = useCommonStore((state) => {
16+
return {
17+
appTitleBarRightComponent: state.appTitleBarRightComponent,
18+
};
19+
});
20+
1421
const handleDoubleClick = () => {
1522
window.electronApi?.setMaximize();
1623
};
@@ -19,9 +26,7 @@ export default memo<IProps>((props) => {
1926
<div className={classnames(styles.appTitleBar, className)} onDoubleClick={handleDoubleClick}>
2027
<div />
2128
<div className={styles.appName}>Chat2DB Community</div>
22-
<div>
23-
<CustomLayout />
24-
</div>
29+
<div>{appTitleBarRightComponent}</div>
2530
{/* <div className={styles.windowsCloseBar}>
2631
<div>
2732
<Iconfont code="icon-minimize" />

chat2db-client/src/pages/main/workspace/index.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import classnames from 'classnames';
33

44
import { useWorkspaceStore } from '@/pages/main/workspace/store';
55
import { setPanelLeftWidth } from '@/pages/main/workspace/store/config';
6+
import { setAppTitleBarRightComponent } from '@/store/common/appTitleBarConfig';
67

78
import DraggableContainer from '@/components/DraggableContainer';
89
import WorkspaceLeft from './components/WorkspaceLeft';
910
import WorkspaceRight from './components/WorkspaceRight';
11+
import CustomLayout from '@/components/CustomLayout';
1012

1113
import useMonacoTheme from '@/components/MonacoEditor/useMonacoTheme';
1214
import shortcutKeyCreateConsole from './functions/shortcutKeyCreateConsole';
@@ -24,8 +26,15 @@ const workspacePage = memo(() => {
2426

2527
// 编辑器的主题
2628
useMonacoTheme();
27-
// 快捷键
2829

30+
useEffect(() => {
31+
setAppTitleBarRightComponent(<CustomLayout />);
32+
return () => {
33+
setAppTitleBarRightComponent(null);
34+
};
35+
}, []);
36+
37+
// 快捷键
2938
useEffect(() => {
3039
shortcutKeyCreateConsole();
3140
}, []);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React from 'react';
2+
import { useCommonStore } from './index';
3+
export interface IAppTitleBarConfig {
4+
appTitleBarRightComponent: React.ReactNode | null;
5+
}
6+
7+
export const initAppTitleBarConfig = {
8+
appTitleBarRightComponent: null,
9+
};
10+
11+
export const setAppTitleBarRightComponent: (appTitleBarRightComponent: React.ReactNode | null) => void = (
12+
appTitleBarRightComponent,
13+
) => {
14+
return useCommonStore.setState({ appTitleBarRightComponent });
15+
};

chat2db-client/src/store/common/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ import { StoreApi } from 'zustand';
55

66
import { initCopyFocusedContent, ICopyFocusedContent } from './copyFocusedContent';
77
import { initComponentsContent, IComponentsContent } from './components';
8+
import { initAppTitleBarConfig, IAppTitleBarConfig } from './appTitleBarConfig';
89

9-
export type IStore = ICopyFocusedContent & IComponentsContent;
10+
export type IStore = ICopyFocusedContent & IComponentsContent & IAppTitleBarConfig;
1011

1112
export const useCommonStore: UseBoundStoreWithEqualityFn<StoreApi<IStore>> = createWithEqualityFn(
1213
devtools(
1314
() => ({
1415
...initCopyFocusedContent,
1516
...initComponentsContent,
17+
...initAppTitleBarConfig
1618
}),
1719
),
1820
shallow

0 commit comments

Comments
 (0)