diff --git a/chat2db-client/package.json b/chat2db-client/package.json index 67e2c8d28..79a044d88 100644 --- a/chat2db-client/package.json +++ b/chat2db-client/package.json @@ -96,7 +96,7 @@ "asar": false, "files": [ "dist/**/*", - "src/main/preload.js", + "src/main", "src/main/main.js", "versions/**/*", "package.json", diff --git a/chat2db-client/src/blocks/AppTitleBar/index.tsx b/chat2db-client/src/blocks/AppTitleBar/index.tsx index 7372dfa0a..9a4c07827 100644 --- a/chat2db-client/src/blocks/AppTitleBar/index.tsx +++ b/chat2db-client/src/blocks/AppTitleBar/index.tsx @@ -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((props) => { const { className } = props; + const { appTitleBarRightComponent } = useCommonStore((state) => { + return { + appTitleBarRightComponent: state.appTitleBarRightComponent, + }; + }); + const handleDoubleClick = () => { window.electronApi?.setMaximize(); }; @@ -19,9 +26,7 @@ export default memo((props) => {
Chat2DB Community
-
- -
+
{appTitleBarRightComponent}
{/*
diff --git a/chat2db-client/src/pages/main/workspace/index.tsx b/chat2db-client/src/pages/main/workspace/index.tsx index 5f2a23e85..399636591 100644 --- a/chat2db-client/src/pages/main/workspace/index.tsx +++ b/chat2db-client/src/pages/main/workspace/index.tsx @@ -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(); + return () => { + setAppTitleBarRightComponent(null); + }; + }, []); + + // 快捷键 useEffect(() => { shortcutKeyCreateConsole(); }, []); diff --git a/chat2db-client/src/store/common/appTitleBarConfig.ts b/chat2db-client/src/store/common/appTitleBarConfig.ts new file mode 100644 index 000000000..fc92e03c3 --- /dev/null +++ b/chat2db-client/src/store/common/appTitleBarConfig.ts @@ -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 }); +}; diff --git a/chat2db-client/src/store/common/index.ts b/chat2db-client/src/store/common/index.ts index dbae03adf..a65436fbb 100644 --- a/chat2db-client/src/store/common/index.ts +++ b/chat2db-client/src/store/common/index.ts @@ -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> = createWithEqualityFn( devtools( () => ({ ...initCopyFocusedContent, ...initComponentsContent, + ...initAppTitleBarConfig }), ), shallow