Skip to content

Commit 355b688

Browse files
committed
style 热更新
1 parent 54436c2 commit 355b688

9 files changed

Lines changed: 61 additions & 17 deletions

File tree

chat2db-client/src/components/Console/ChatInput/index.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.chatWrapper {
22
display: flex;
33
align-items: center;
4-
padding: 12px 20px;
4+
padding: 2px 20px;
55
box-sizing: border-box;
66
border-bottom: 1px solid var(--color-border-secondary);
77
}

chat2db-client/src/components/Loading/LoadingContent/index.less

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,13 @@
1717
max-width: 100%;
1818
}
1919
}
20+
21+
.coverLoading{
22+
position: absolute;
23+
inset: 0;
24+
background-color: rgba(0, 0, 0, 0.01);
25+
display: flex;
26+
justify-content: center;
27+
align-items: center;
28+
z-index: 999;
29+
}

chat2db-client/src/components/Loading/LoadingContent/index.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,36 @@ interface IProps<T> {
99
empty?: React.ReactNode;
1010
handleEmpty?: boolean;
1111
isLoading?: boolean;
12+
coverLoading?: boolean;
1213
}
1314

1415
export default function LoadingContent<T>(props: PropsWithChildren<IProps<T>>) {
15-
const { children, className, data = true, handleEmpty = false, empty, isLoading } = props;
16+
const { children, className, data = true, handleEmpty = false, empty, isLoading, coverLoading } = props;
1617
const isEmpty = !isLoading && handleEmpty && !(data as any).length;
1718

1819
const renderContent = () => {
19-
if (isLoading || !data) {
20+
if ((isLoading || !data) && !coverLoading) {
2021
return <StateIndicator state="loading" />;
2122
}
2223

2324
if (isEmpty) {
2425
return empty || <StateIndicator state="empty" />;
2526
}
2627

27-
return children;
28+
return <>
29+
{children}
30+
{
31+
(isLoading || !data) && coverLoading &&
32+
<div className={styles.coverLoading}>
33+
<StateIndicator state="loading" />
34+
</div>
35+
}
36+
</>
2837
};
2938

3039
return (
31-
<div className={classnames(styles.box, className)}>{
32-
renderContent()
33-
}</div>
40+
<div className={classnames(styles.box, className)}>
41+
{renderContent()}
42+
</div>
3443
);
3544
}

chat2db-client/src/main/preload.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,21 @@ const { contextBridge, ipcRenderer } = require('electron');
22
const { spawn } = require('child_process');
33
const { JAVA_APP_NAME, JAVA_PATH } = require('./constants');
44
const path = require('path');
5+
const { readVersion } = require('./utils');
56

67
contextBridge.exposeInMainWorld('myAPI', {
78
startServerForSpawn: async () => {
8-
const javaPath = path.join(__dirname, '../..', `./static/${JAVA_APP_NAME}`);
9+
readVersion();
10+
11+
const javaPath = path.join(__dirname, '../..', `./${readVersion()}`, `./static/${JAVA_APP_NAME}`);
912

1013
const productName = await ipcRenderer.invoke('get-product-name');
1114

1215
const isTest = productName.match(/test$/i) !== null;
1316

1417
console.log('productName:', productName, isTest);
1518

16-
const child = spawn(path.join(__dirname, '../..', `./static/${JAVA_PATH}`), [
19+
const child = spawn(path.join(__dirname, '../..', ` ./static/${JAVA_PATH}`), [
1720
'-jar',
1821
'-Xmx512M',
1922
`-Dspring.profiles.active=${isTest ? 'test' : 'release'}`,

chat2db-client/src/main/utils.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
const { DEV_WEB_URL } = require('./constants');
22
const path = require('path');
33
const url = require('url');
4+
const { version } = require('os');
5+
const fs = require('fs');
46

57
/**
68
* 加载主进程前端资源
@@ -10,20 +12,35 @@ function loadMainResource(mainWindow) {
1012
if (process.env.NODE_ENV === 'development') {
1113
mainWindow.loadURL(DEV_WEB_URL);
1214
mainWindow.webContents.openDevTools();
13-
1415
// 监听应用程序根路径下的所有文件,当文件发生修改时,自动刷新应用程序
1516
require('electron-reload')(path.join(__dirname, '..'));
1617
} else {
1718
mainWindow.loadURL(
1819
url.format({
19-
pathname: path.join(__dirname, '../..', './dist/index.html'),
20+
pathname: path.join(__dirname, '../..', `./${readVersion()}`, `./dist/index.html`),
2021
protocol: 'file:',
2122
slashes: true,
2223
}),
2324
);
2425
}
2526
}
2627

28+
/**
29+
* 应该读取哪个版本的资源
30+
* @param {*}
31+
*/
32+
function readVersion() {
33+
if (process.env.NODE_ENV !== 'development') {
34+
var readDir = fs.readdirSync(path.join(__dirname, '../..', './versions'));
35+
console.log(readDir);
36+
}
37+
if (readDir.length) {
38+
return readDir[readDir.length - 1]
39+
}
40+
return ''
41+
}
42+
2743
module.exports = {
2844
loadMainResource,
45+
readVersion
2946
};

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ const WorkspaceHeader = memo<IProps>((props) => {
9494
};
9595

9696
function connectionChange(id: any, data: any) {
97+
// if(id[0] === curConnection?.id){
98+
// return
99+
// }
97100
connectionList.map(t => {
98101
if (t.id === id[0]) {
99102
dispatch({
@@ -109,7 +112,6 @@ const WorkspaceHeader = memo<IProps>((props) => {
109112
}
110113

111114
return <>
112-
113115
{curConnection && !!connectionList.length && curWorkspaceParams && <div className={styles.workspaceHeader}>
114116
<div className={styles.databaseLogo}>
115117
{curConnection?.type ?
@@ -124,6 +126,7 @@ const WorkspaceHeader = memo<IProps>((props) => {
124126
options={connectionListOptions}
125127
onChange={connectionChange}
126128
bordered={false}
129+
defaultValue={[curConnection?.id]}
127130
>
128131
<div className={styles.crumbsItem}>
129132
<div className={styles.text}>{curConnection?.alias}</div>
@@ -136,6 +139,7 @@ const WorkspaceHeader = memo<IProps>((props) => {
136139
options={cascaderOptions}
137140
onChange={databaseChange}
138141
bordered={false}
142+
// defaultValue={[curWorkspaceParams.databaseName]}
139143
>
140144
<div className={styles.crumbsItem}>
141145
<div className={styles.text}>{curWorkspaceParams.databaseName}</div>
@@ -151,6 +155,7 @@ const WorkspaceHeader = memo<IProps>((props) => {
151155
options={curSchemaOptions}
152156
onChange={schemaChange}
153157
bordered={false}
158+
// defaultValue={[curWorkspaceParams.schemaName]}
154159
>
155160
<div className={styles.crumbsItem}>
156161
<div className={styles.text}>{curWorkspaceParams.schemaName}</div>

chat2db-client/src/pages/main/workspace/components/WorkspaceRight/index.less

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@
1515
}
1616

1717
.tabs {
18-
padding: 18px 4px 0px 4px;
18+
padding: 8px 4px 0px 4px;
1919
margin: 0px 4px;
2020
}
2121

2222
.consoleBox {
2323
position: absolute;
24-
top: 48px;
24+
top: 38px;
2525
left: 0;
2626
right: 0;
2727
bottom: 0;
2828
display: none;
2929
}
3030

3131
.tabBox {
32-
height: 48px;
32+
height: 38px;
3333
background-color: var(--color-bg-elevated);
3434
}
3535

chat2db-client/src/pages/main/workspace/components/WorkspaceRightItem/index.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
}
1010

1111
.boxRightConsole {
12-
height: 56vh;
12+
height: 50vh;
1313
overflow: hidden;
1414
}
1515

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ const workspace = memo<IProps>((props) => {
164164
return (
165165
<div className={styles.workspace}>
166166
<WorkspaceHeader cascaderOptions={cascaderOptions}></WorkspaceHeader>
167-
<LoadingContent isLoading={loading}>
167+
<LoadingContent coverLoading={true} isLoading={loading}>
168168
<DraggableContainer className={styles.workspaceMain}>
169169
<div ref={draggableRef} className={styles.boxLeft}>
170170
<WorkspaceLeft cascaderOptions={cascaderOptions} />

0 commit comments

Comments
 (0)