fix:electron build

This commit is contained in:
shanhexi
2024-01-08 16:42:49 +08:00
parent 7e5a5a4b03
commit ece57d43a1
5 changed files with 39 additions and 8 deletions

View File

@ -96,7 +96,7 @@
"asar": false,
"files": [
"dist/**/*",
"src/main/preload.js",
"src/main",
"src/main/main.js",
"versions/**/*",
"package.json",

View File

@ -1,8 +1,9 @@
import React, { memo } from 'react';
import styles from './index.less';
import classnames from 'classnames';
import CustomLayout from '@/components/CustomLayout';
import Iconfont from '@/components/Iconfont';
import { useCommonStore } from '@/store/common';
// import Iconfont from '@/components/Iconfont';
interface IProps {
className?: string;
@ -11,6 +12,12 @@ interface IProps {
export default memo<IProps>((props) => {
const { className } = props;
const { appTitleBarRightComponent } = useCommonStore((state) => {
return {
appTitleBarRightComponent: state.appTitleBarRightComponent,
};
});
const handleDoubleClick = () => {
window.electronApi?.setMaximize();
};
@ -19,9 +26,7 @@ export default memo<IProps>((props) => {
<div className={classnames(styles.appTitleBar, className)} onDoubleClick={handleDoubleClick}>
<div />
<div className={styles.appName}>Chat2DB Community</div>
<div>
<CustomLayout />
</div>
<div>{appTitleBarRightComponent}</div>
{/* <div className={styles.windowsCloseBar}>
<div>
<Iconfont code="icon-minimize" />

View File

@ -3,10 +3,12 @@ import classnames from 'classnames';
import { useWorkspaceStore } from '@/pages/main/workspace/store';
import { setPanelLeftWidth } from '@/pages/main/workspace/store/config';
import { setAppTitleBarRightComponent } from '@/store/common/appTitleBarConfig';
import DraggableContainer from '@/components/DraggableContainer';
import WorkspaceLeft from './components/WorkspaceLeft';
import WorkspaceRight from './components/WorkspaceRight';
import CustomLayout from '@/components/CustomLayout';
import useMonacoTheme from '@/components/MonacoEditor/useMonacoTheme';
import shortcutKeyCreateConsole from './functions/shortcutKeyCreateConsole';
@ -24,8 +26,15 @@ const workspacePage = memo(() => {
// 编辑器的主题
useMonacoTheme();
// 快捷键
useEffect(() => {
setAppTitleBarRightComponent(<CustomLayout />);
return () => {
setAppTitleBarRightComponent(null);
};
}, []);
// 快捷键
useEffect(() => {
shortcutKeyCreateConsole();
}, []);

View File

@ -0,0 +1,15 @@
import React from 'react';
import { useCommonStore } from './index';
export interface IAppTitleBarConfig {
appTitleBarRightComponent: React.ReactNode | null;
}
export const initAppTitleBarConfig = {
appTitleBarRightComponent: null,
};
export const setAppTitleBarRightComponent: (appTitleBarRightComponent: React.ReactNode | null) => void = (
appTitleBarRightComponent,
) => {
return useCommonStore.setState({ appTitleBarRightComponent });
};

View File

@ -5,14 +5,16 @@ import { StoreApi } from 'zustand';
import { initCopyFocusedContent, ICopyFocusedContent } from './copyFocusedContent';
import { initComponentsContent, IComponentsContent } from './components';
import { initAppTitleBarConfig, IAppTitleBarConfig } from './appTitleBarConfig';
export type IStore = ICopyFocusedContent & IComponentsContent;
export type IStore = ICopyFocusedContent & IComponentsContent & IAppTitleBarConfig;
export const useCommonStore: UseBoundStoreWithEqualityFn<StoreApi<IStore>> = createWithEqualityFn(
devtools(
() => ({
...initCopyFocusedContent,
...initComponentsContent,
...initAppTitleBarConfig
}),
),
shallow