Skip to content

Commit 9ec6cf4

Browse files
author
单贺喜
committed
fix:环境变量
1 parent 90da7fb commit 9ec6cf4

5 files changed

Lines changed: 15 additions & 8 deletions

File tree

chat2db-client/.umirc.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,4 @@ export default defineConfig({
4444
},
4545
headScripts: ['if (window.myAPI) { window.myAPI.startServerForSpawn() }'],
4646
favicons: ['logo.ico'],
47-
define: {
48-
'process.env.UMI_ENV': process.env.UMI_ENV,
49-
}
5047
});

chat2db-client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"start": "concurrently \"npm run start:web\" \"npm run start:main\"",
2323
"start:main": "cross-env NODE_ENV=development electron .",
2424
"start:main:prod": "cross-env NODE_ENV=production electron .",
25-
"start:web": "umi dev"
25+
"start:web": "cross-env UMI_ENV=local umi dev"
2626
},
2727
"dependencies": {
2828
"ahooks": "^3.7.7",

chat2db-client/src/components/Console/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { formatParams, uuid } from '@/utils/common';
1+
import { formatParams } from '@/utils/common';
22
import connectToEventSource from '@/utils/eventSource';
33
import { Button, Spin } from 'antd';
44
import React, { ForwardedRef, useEffect, useMemo, useRef, useState } from 'react';
@@ -9,6 +9,7 @@ import sqlServer from '@/service/sql';
99
import historyServer from '@/service/history';
1010
import MonacoEditor from 'react-monaco-editor';
1111
import { useReducerContext } from '@/pages/main/workspace/index';
12+
import { v4 as uuidv4 } from 'uuid';
1213

1314
import styles from './index.less';
1415
import Loading from '../Loading/Loading';
@@ -50,7 +51,7 @@ interface IProps {
5051

5152
function Console(props: IProps) {
5253
const { hasAiChat = true, value, executeParams, onChangeValue } = props;
53-
const uid = useMemo(() => uuid(), []);
54+
const uid = useMemo(() => uuidv4(), []);
5455
const chatResult = useRef('');
5556
const editorRef = useRef<IExportRefFunction>();
5657
const [context, setContext] = useState<string>();

chat2db-client/src/hooks/useEventSource.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React, { useEffect, useMemo, useState } from 'react';
2-
import { uuid } from '@/utils/common';
32
import { EventSourcePolyfill } from 'event-source-polyfill';
3+
import { v4 as uuidv4 } from 'uuid';
44

55
function useEventSource({ url }) {
6-
const uid = useMemo(() => uuid(), []);
6+
const uid = useMemo(() => uuidv4(), []);
77
const [messages, setMessage] = useState('');
88

99
useEffect(() => {

chat2db-client/src/utils/common.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export function formatParams(obj: { [key: string]: any }) {
2+
let params = '';
3+
for (let key in obj) {
4+
if (obj[key]) {
5+
params += `${key}=${obj[key]}&`;
6+
}
7+
}
8+
return params;
9+
}

0 commit comments

Comments
 (0)