mirror of
https://github.com/lobehub/lobehub.git
synced 2026-03-27 13:29:15 +07:00
🐛 fix: fix desktop quiting with reopen window (#7675)
* add rename renderer * fix close issue
This commit is contained in:
@@ -55,6 +55,12 @@ export default class Browser {
|
||||
return this.retrieveOrInitialize();
|
||||
}
|
||||
|
||||
get webContents() {
|
||||
if (this._browserWindow.isDestroyed()) return null;
|
||||
|
||||
return this._browserWindow.webContents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to construct BrowserWindows object
|
||||
* @param options
|
||||
@@ -210,7 +216,6 @@ export default class Browser {
|
||||
session: browserWindow.webContents.session,
|
||||
});
|
||||
|
||||
console.log('platform:',process.platform);
|
||||
// Windows 11 can use this new API
|
||||
if (process.platform === 'win32' && browserWindow.setBackgroundMaterial) {
|
||||
logger.debug(`[${this.identifier}] Setting window background material for Windows 11`);
|
||||
|
||||
@@ -157,8 +157,8 @@ export default class BrowserManager {
|
||||
this.webContentsMap.set(browser.browserWindow.webContents, identifier);
|
||||
|
||||
// 当窗口关闭时清理映射
|
||||
browser.browserWindow.on('closed', () => {
|
||||
this.webContentsMap.delete(browser.browserWindow.webContents);
|
||||
browser.browserWindow.on('close', () => {
|
||||
if (browser.webContents) this.webContentsMap.delete(browser.webContents);
|
||||
});
|
||||
|
||||
return browser;
|
||||
|
||||
@@ -163,6 +163,7 @@
|
||||
"@vercel/edge-config": "^1.4.0",
|
||||
"@vercel/functions": "^2.0.0",
|
||||
"@vercel/speed-insights": "^1.2.0",
|
||||
"@xterm/xterm": "^5.5.0",
|
||||
"ahooks": "^3.8.4",
|
||||
"ai": "^3.4.33",
|
||||
"antd": "^5.24.6",
|
||||
|
||||
@@ -44,7 +44,7 @@ const CheckError = ({
|
||||
|
||||
const errorMessage = errorBody.error?.message;
|
||||
|
||||
if (error?.type === 'OllamaServiceUnavailable') return <OllamaSetupGuide container={false} />;
|
||||
if (error?.type === 'OllamaServiceUnavailable') return <OllamaSetupGuide />;
|
||||
|
||||
// error of not pull the model
|
||||
const unresolvedModel = errorMessage?.match(UNRESOLVED_MODEL_REGEXP)?.[1];
|
||||
|
||||
@@ -9,8 +9,6 @@ import { Center } from 'react-layout-kit';
|
||||
import FormAction from '@/components/FormAction';
|
||||
import { useChatStore } from '@/store/chat';
|
||||
|
||||
import { ErrorActionContainer } from '../Conversation/Error/style';
|
||||
|
||||
// TODO: 优化 Ollama setup 的流程,isDesktop 模式下可以直接做到端到端检测
|
||||
const OllamaDesktopSetupGuide = memo<{ id?: string }>(({ id }) => {
|
||||
const theme = useTheme();
|
||||
@@ -22,44 +20,42 @@ const OllamaDesktopSetupGuide = memo<{ id?: string }>(({ id }) => {
|
||||
]);
|
||||
|
||||
return (
|
||||
<ErrorActionContainer style={{ paddingBlock: 0 }}>
|
||||
<Center gap={16} paddingBlock={32} style={{ maxWidth: 300, width: '100%' }}>
|
||||
<FormAction
|
||||
avatar={<Ollama color={theme.colorPrimary} size={64} />}
|
||||
description={
|
||||
<span>
|
||||
<Trans i18nKey={'OllamaSetupGuide.install.description'} ns={'components'}>
|
||||
请确认你已经开启 Ollama ,如果没有安装 Ollama ,请前往官网
|
||||
<Link href={'https://ollama.com/download'}>下载</Link>
|
||||
</Trans>
|
||||
</span>
|
||||
}
|
||||
title={t('OllamaSetupGuide.install.title')}
|
||||
/>
|
||||
{id && (
|
||||
<>
|
||||
<Button
|
||||
block
|
||||
onClick={() => {
|
||||
delAndRegenerateMessage(id);
|
||||
}}
|
||||
style={{ marginTop: 8 }}
|
||||
type={'primary'}
|
||||
>
|
||||
{t('OllamaSetupGuide.action.start')}
|
||||
</Button>
|
||||
<Button
|
||||
block
|
||||
onClick={() => {
|
||||
deleteMessage(id);
|
||||
}}
|
||||
>
|
||||
{t('OllamaSetupGuide.action.close')}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</Center>
|
||||
</ErrorActionContainer>
|
||||
<Center gap={16} paddingBlock={32} style={{ maxWidth: 300, width: '100%' }}>
|
||||
<FormAction
|
||||
avatar={<Ollama color={theme.colorPrimary} size={64} />}
|
||||
description={
|
||||
<span>
|
||||
<Trans i18nKey={'OllamaSetupGuide.install.description'} ns={'components'}>
|
||||
请确认你已经开启 Ollama ,如果没有安装 Ollama ,请前往官网
|
||||
<Link href={'https://ollama.com/download'}>下载</Link>
|
||||
</Trans>
|
||||
</span>
|
||||
}
|
||||
title={t('OllamaSetupGuide.install.title')}
|
||||
/>
|
||||
{id && (
|
||||
<>
|
||||
<Button
|
||||
block
|
||||
onClick={() => {
|
||||
delAndRegenerateMessage(id);
|
||||
}}
|
||||
style={{ marginTop: 8 }}
|
||||
type={'primary'}
|
||||
>
|
||||
{t('OllamaSetupGuide.action.start')}
|
||||
</Button>
|
||||
<Button
|
||||
block
|
||||
onClick={() => {
|
||||
deleteMessage(id);
|
||||
}}
|
||||
>
|
||||
{t('OllamaSetupGuide.action.close')}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</Center>
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ export const createPluginStoreSlice: StateCreator<
|
||||
loadPluginStore: async () => {
|
||||
const pluginMarketIndex = await toolService.getToolList();
|
||||
|
||||
set({ pluginStoreList: pluginMarketIndex }, false, n('loadPluginList'));
|
||||
set({ pluginStoreList: pluginMarketIndex || [] }, false, n('loadPluginList'));
|
||||
|
||||
return pluginMarketIndex;
|
||||
},
|
||||
|
||||
46
src/tools/local-files/Render/RenameLocalFile/index.tsx
Normal file
46
src/tools/local-files/Render/RenameLocalFile/index.tsx
Normal file
@@ -0,0 +1,46 @@
|
||||
import { RenameLocalFileParams } from '@lobechat/electron-client-ipc';
|
||||
import { Icon } from '@lobehub/ui';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { ArrowRightIcon } from 'lucide-react';
|
||||
import React, { memo } from 'react';
|
||||
import { Flexbox } from 'react-layout-kit';
|
||||
|
||||
import FileIcon from '@/components/FileIcon';
|
||||
import { LocalReadFileState } from '@/tools/local-files/type';
|
||||
import { ChatMessagePluginError } from '@/types/message';
|
||||
|
||||
const useStyles = createStyles(({ css, token }) => ({
|
||||
container: css`
|
||||
color: ${token.colorTextQuaternary};
|
||||
`,
|
||||
new: css`
|
||||
color: ${token.colorTextSecondary};
|
||||
`,
|
||||
}));
|
||||
|
||||
interface RenameLocalFileProps {
|
||||
args: RenameLocalFileParams;
|
||||
messageId: string;
|
||||
pluginError: ChatMessagePluginError;
|
||||
pluginState: LocalReadFileState;
|
||||
}
|
||||
|
||||
const RenameLocalFile = memo<RenameLocalFileProps>(({ args }) => {
|
||||
const { styles } = useStyles();
|
||||
|
||||
const oldFileName = args.path.split('/').at(-1);
|
||||
return (
|
||||
<Flexbox align={'center'} className={styles.container} gap={8} horizontal paddingInline={12}>
|
||||
<Flexbox>{oldFileName}</Flexbox>
|
||||
<Flexbox>
|
||||
<Icon icon={ArrowRightIcon} />
|
||||
</Flexbox>
|
||||
<Flexbox className={styles.new} gap={4} horizontal>
|
||||
<FileIcon fileName={args.newName} size={20} variant={'raw'} />
|
||||
{args.newName}
|
||||
</Flexbox>
|
||||
</Flexbox>
|
||||
);
|
||||
});
|
||||
|
||||
export default RenameLocalFile;
|
||||
@@ -6,12 +6,14 @@ import { BuiltinRenderProps } from '@/types/tool';
|
||||
|
||||
import ListFiles from './ListFiles';
|
||||
import ReadLocalFile from './ReadLocalFile';
|
||||
import RenameLocalFile from './RenameLocalFile';
|
||||
import SearchFiles from './SearchFiles';
|
||||
|
||||
const RenderMap = {
|
||||
[LocalFilesApiName.searchLocalFiles]: SearchFiles,
|
||||
[LocalFilesApiName.listLocalFiles]: ListFiles,
|
||||
[LocalFilesApiName.readLocalFile]: ReadLocalFile,
|
||||
[LocalFilesApiName.renameLocalFile]: RenameLocalFile,
|
||||
};
|
||||
|
||||
const LocalFilesRender = memo<BuiltinRenderProps<LocalFileItem[]>>(
|
||||
|
||||
Reference in New Issue
Block a user