Skip to content

Commit

Permalink
Merge pull request #1077 from chat2db/refactor-electron
Browse files Browse the repository at this point in the history
fix:electron build
  • Loading branch information
shanhexi committed Jan 8, 2024
2 parents 34c621e + 0cc4361 commit 7348f99
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 21 deletions.
2 changes: 1 addition & 1 deletion chat2db-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/chat2db/Chat2DB"
},
"author": "fjy, hexi",
"main": "src/main/main.js",
"main": "src/main/dist/index.js",
"scripts": {
"build": "npm run build:web && npm run build:main",
"build:desktop": "npm run build:web:desktop && npm run build:main:prod",
Expand Down
12 changes: 12 additions & 0 deletions chat2db-client/src/blocks/AppTitleBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { memo } from 'react';
import styles from './index.less';
import classnames from 'classnames';
import CustomLayout from '@/components/CustomLayout';
import Iconfont from '@/components/Iconfont';

interface IProps {
className?: string;
Expand All @@ -21,6 +22,17 @@ export default memo<IProps>((props) => {
<div>
<CustomLayout />
</div>
{/* <div className={styles.windowsCloseBar}>
<div>
<Iconfont code="icon-minimize" />
</div>
<div>
<Iconfont code="icon-minimize" />
</div>
<div>
<Iconfont code="icon-minimize" />
</div>
</div> */}
</div>
);
});
2 changes: 1 addition & 1 deletion chat2db-client/src/layouts/GlobalLayout/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@import '@/styles/var.less';

.loadingBox {
height: 100vh;
flex: 1;
width: 100vw;
display: flex;
justify-content: center;
Expand Down
38 changes: 23 additions & 15 deletions chat2db-client/src/layouts/GlobalLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,34 @@ const GlobalLayout = () => {

// 等待状态页面
if (serviceStatus === ServiceStatus.PENDING || curUser === null) {
return <Spin className={styles.loadingBox} size="large" />;
return (
<div className={styles.app}>
<AppTitleBar className={styles.appTitleBar} />
<Spin className={styles.loadingBox} size="large" />;
</div>
);
}

// 错误状态页面
if (serviceStatus === ServiceStatus.FAILURE) {
return (
<div className={styles.loadingBox}>
<Button type="primary" onClick={restartPolling} style={{ marginBottom: 20 }}>
<SyncOutlined />
{i18n('common.text.tryToRestart')}
</Button>
<div className={styles.contact}>
{i18n('common.text.contactUs')}
<GithubOutlined className={styles.icon} onClick={() => window.open('https://github.com/chat2db/Chat2DB')} />
<Tooltip
placement="bottom"
title={<img style={{ width: 200, height: 200 }} src="https://sqlgpt.cn/_static/img/chat2db_wechat.png" />}
>
<WechatOutlined className={styles.icon} />
</Tooltip>
<div className={styles.app}>
<AppTitleBar className={styles.appTitleBar} />
<div className={styles.loadingBox}>
<Button type="primary" onClick={restartPolling} style={{ marginBottom: 20 }}>
<SyncOutlined />
{i18n('common.text.tryToRestart')}
</Button>
<div className={styles.contact}>
{i18n('common.text.contactUs')}
<GithubOutlined className={styles.icon} onClick={() => window.open('https://github.com/chat2db/Chat2DB')} />
<Tooltip
placement="bottom"
title={<img style={{ width: 200, height: 200 }} src="https://sqlgpt.cn/_static/img/chat2db_wechat.png" />}
>
<WechatOutlined className={styles.icon} />
</Tooltip>
</div>
</div>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion chat2db-client/src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function createWindow() {
minHeight: 720,
show: false,
frame: false, // 无边框
titleBarStyle: 'hidden',
titleBarStyle: 'hiddenInset',
webPreferences: {
webSecurity: false,
spellcheck: false, // 禁用拼写检查器
Expand Down
2 changes: 1 addition & 1 deletion chat2db-client/src/main/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function loadMainResource(mainWindow) {
} else {
mainWindow.loadURL(
url.format({
pathname: path.join(__dirname, '../..', `./versions/${readVersion()}`, `./dist/index.html`),
pathname: path.join(__dirname, '../../..', `./versions/${readVersion()}`, `./dist/index.html`),
protocol: 'file:',
slashes: true,
}),
Expand Down
4 changes: 2 additions & 2 deletions chat2db-client/src/main/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
entry: './index.js',
output: {
filename: 'main.js',
path: path.resolve(__dirname),
path: path.resolve(__dirname, 'dist'),
},
target: 'electron-main'
target: 'electron-main',
};

0 comments on commit 7348f99

Please sign in to comment.