Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
shanhexi committed Jun 24, 2023
2 parents a745a99 + 624e3a8 commit 31bc803
Show file tree
Hide file tree
Showing 16 changed files with 124 additions and 51 deletions.
4 changes: 2 additions & 2 deletions chat2db-client/.umirc.desktop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ const chainWebpack = (config: any, { webpack }: any) => {
};

export default defineConfig({
// publicPath: './',
publicPath: UMI_PublicPath,
chainWebpack,
headScripts: ['if (window.myAPI) { window.myAPI.startServerForSpawn() }'],
define: {
'process.env.UMI_ENV': 'desktop'
'process.env.UMI_ENV': process.env.UMI_ENV,
}
});
4 changes: 2 additions & 2 deletions chat2db-client/.umirc.prod.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { formatDate } from './src/utils/date';
import { defineConfig } from 'umi';
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
const UMI_PublicPath = process.env.UMI_PublicPath || './';
const UMI_PublicPath = process.env.UMI_PublicPath || './static/front/';

const chainWebpack = (config: any, { webpack }: any) => {
config.plugin('monaco-editor').use(MonacoWebpackPlugin, [
Expand All @@ -22,6 +22,6 @@ export default defineConfig({
publicPath: UMI_PublicPath,
chainWebpack,
define: {
'process.env.UMI_ENV': 'prod'
'process.env.UMI_ENV': process.env.UMI_ENV,
}
});
4 changes: 3 additions & 1 deletion chat2db-client/.umirc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,7 @@ export default defineConfig({
},
headScripts: ['if (window.myAPI) { window.myAPI.startServerForSpawn() }'],
favicons: ['logo.ico'],

define: {
'process.env.UMI_ENV': process.env.UMI_ENV,
}
});
3 changes: 0 additions & 3 deletions chat2db-client/config/config.desktop.js

This file was deleted.

3 changes: 0 additions & 3 deletions chat2db-client/config/config.js

This file was deleted.

3 changes: 0 additions & 3 deletions chat2db-client/config/config.prod.js

This file was deleted.

5 changes: 3 additions & 2 deletions chat2db-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"start": "concurrently \"npm run start:web\" \"npm run start:main\"",
"start:main": "cross-env NODE_ENV=development electron .",
"start:main:prod": "cross-env NODE_ENV=production electron .",
"start:web": "cross-env umi dev"
"start:web": "umi dev"
},
"dependencies": {
"ahooks": "^3.7.7",
Expand Down Expand Up @@ -69,7 +69,8 @@
"productName": "Chat2DB",
"asar": false,
"files": [
"dist/",
"dist/**/*",
"!node_modules",
"static/",
"src/main",
"package.json"
Expand Down
10 changes: 9 additions & 1 deletion chat2db-client/src/components/Iconfont/index.less
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
@font-face {
font-family: 'iconfont';
/* Project id 3633546 */
src: url('../../assets/font/iconfont.woff2') format('woff2'),
url('../../assets/font/iconfont.woff') format('woff'),
url('../../assets/font/iconfont.ttf') format('truetype');
}

.iconfont {
font-family: 'iconfont' !important;
font-size: 14px;
Expand All @@ -6,4 +14,4 @@
-webkit-font-smoothing: antialiased;
-webkit-text-stroke-width: 0.2px;
-moz-osx-font-smoothing: grayscale;
}
}
49 changes: 25 additions & 24 deletions chat2db-client/src/components/Iconfont/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,31 @@ import classnames from 'classnames';
// import desktopStyle from './desktop.less';
import styles from './index.less';

let container = ''
container = `
@font-face {
font-family: 'iconfont'; /* Project id 3633546 */
src: url('../../assets/font/iconfont.woff2') format('woff2'),
url('../../assets/font/iconfont.woff') format('woff'),
url('../../assets/font/iconfont.ttf') format('truetype');
}
`
if (process.env.UMI_ENV === 'desktop') {
} else {
container = `
@font-face {
font-family: 'iconfont'; /* Project id 3633546 */
src: url('//at.alicdn.com/t/c/font_3633546_bobs6jadiya.woff2?t=1687102726036') format('woff2'),
url('//at.alicdn.com/t/c/font_3633546_bobs6jadiya.woff?t=1687102726036') format('woff'),
url('//at.alicdn.com/t/c/font_3633546_bobs6jadiya.ttf?t=1687102726036') format('truetype');
}
`
}
let style = document.createElement("style");
style.type = "text/css";
document.head.appendChild(style);
style.appendChild(document.createTextNode(container));
// let container = ''
// container = `
// @font-face {
// font-family: 'iconfont'; /* Project id 3633546 */
// src: url('../../assets/font/iconfont.woff2') format('woff2'),
// url('../../assets/font/iconfont.woff') format('woff'),
// url('../../assets/font/iconfont.ttf') format('truetype');
// }
// `

// if (process.env.UMI_ENV === 'desktop') {
// } else {
// container = `
// @font-face {
// font-family: 'iconfont'; /* Project id 3633546 */
// src: url('//at.alicdn.com/t/c/font_3633546_bobs6jadiya.woff2?t=1687102726036') format('woff2'),
// url('//at.alicdn.com/t/c/font_3633546_bobs6jadiya.woff?t=1687102726036') format('woff'),
// url('//at.alicdn.com/t/c/font_3633546_bobs6jadiya.ttf?t=1687102726036') format('truetype');
// }
// `
// }
// let style = document.createElement("style");
// style.type = "text/css";
// document.head.appendChild(style);
// style.appendChild(document.createTextNode(container));

export default class Iconfont extends PureComponent<{
code: string;
Expand Down
22 changes: 21 additions & 1 deletion chat2db-client/src/pages/main/dashboard/chart-item/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { Button, Dropdown, Form, MenuProps, Select } from 'antd';
import { initChartItem } from '..';
import { deleteChart, getChartById } from '@/service/dashboard';
import { data } from '../../../../../mock/sqlResult.json';
import Console from '@/components/Console';

const handleSQLResult2ChartData = (data) => {
const { headerList, dataList } = data;
Expand Down Expand Up @@ -57,6 +58,7 @@ interface IChartItemProps {
function ChartItem(props: IChartItemProps) {
const [chartData, setChartData] = useState<IChartItem>();
const [chartMetaData, setChartMetaData] = useState<any>();
const [consoleValue, setConsoleValue] = useState<string>();
const [isEditing, setIsEditing] = useState<boolean>(false);
const [toggle, setToggle] = useState(false);
const [form] = Form.useForm(); // 创建一个表单实例
Expand Down Expand Up @@ -176,7 +178,25 @@ function ChartItem(props: IChartItemProps) {

return (
<div className={styles.editorBlock}>
<div className={styles.editor}>编辑区域</div>
<div className={styles.editor}>
<Console
executeParams={{
// databaseName: currentWorkspaceData.databaseName,
// dataSourceId: currentWorkspaceData.dataSourceId,
// type: currentWorkspaceData.databaseType,
// schemaName: currentWorkspaceData?.schemaName,
// consoleId: t.id,
// consoleName: t.name,
}}
hasAiChat={true}
hasAi2Lang={false}
// value={consoleValue}
onExecuteSQL={(result) => {
console.log('onExecuteSQL', result);
// setResultData(result);
}}
/>
</div>
<Form
form={form}
labelCol={{ span: 6 }}
Expand Down
2 changes: 1 addition & 1 deletion chat2db-client/src/pages/main/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Chat from './chat';

import styles from './index.less';
import { INavItem } from '@/typings/main';

console.log('UMI_ENV', process.env.UMI_ENV)
const navConfig: INavItem[] = [
{
key: 'workspace',
Expand Down
7 changes: 6 additions & 1 deletion chat2db-client/typings.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import 'umi/typings';

// declare const process.env.UMI_ENV: string;
declare namespace NodeJS {
interface ProcessEnv {
readonly NODE_ENV: 'development' | 'production'
readonly UMI_ENV: string
}
}
6 changes: 6 additions & 0 deletions chat2db-server/chat2db-server-start/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<artifactId>log4j-api</artifactId>
<groupId>org.apache.logging.log4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>ai.chat2db</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
rel="icon"
type="image/ico"
sizes="32x32"
href="./static/front/logo.ico"
href="/static/front/logo.ico"
/>
<title>Chat2DB</title>
<meta
Expand All @@ -26,7 +26,6 @@
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"
/>
<link rel="stylesheet" href="./static/front/umi.css"/>
<script>
window.routerBase = "/";

Expand All @@ -48,6 +47,6 @@

</script>

<script src="./static/front/umi.js"></script>
<script src="/static/front/umi.js"></script>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
Expand Down
44 changes: 44 additions & 0 deletions chat2db-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@
<artifactId>mapstruct-processor</artifactId>
<version>1.5.5.Final</version>
</dependency>
<!-- 确保先生成lombok 再生成mapstruct -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-mapstruct-binding</artifactId>
<version>0.2.0</version>
</dependency>

<!-- 自带数据库 -->
<dependency>
Expand Down Expand Up @@ -165,13 +171,37 @@
<groupId>cn.dev33</groupId>
<artifactId>sa-token-jwt</artifactId>
<version>1.34.0</version>
<exclusions>
<exclusion>
<artifactId>hutool-jwt</artifactId>
<groupId>cn.hutool</groupId>
</exclusion>
</exclusions>
</dependency>

<!-- http -->
<dependency>
<groupId>com.dtflys.forest</groupId>
<artifactId>forest-spring-boot-starter</artifactId>
<version>1.5.32</version>
<exclusions>
<exclusion>
<artifactId>httpclient</artifactId>
<groupId>org.apache.httpcomponents</groupId>
</exclusion>
<exclusion>
<artifactId>httpclient-cache</artifactId>
<groupId>org.apache.httpcomponents</groupId>
</exclusion>
<exclusion>
<artifactId>httpcore</artifactId>
<groupId>org.apache.httpcomponents</groupId>
</exclusion>
<exclusion>
<artifactId>httpmime</artifactId>
<groupId>org.apache.httpcomponents</groupId>
</exclusion>
</exclusions>
</dependency>

<!-- 数据库版本管理 -->
Expand Down Expand Up @@ -225,6 +255,20 @@
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<!-- 确保先生成lombok 再生成mapstruct -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-mapstruct-binding</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>


<build>
<plugins>
Expand Down

0 comments on commit 31bc803

Please sign in to comment.