Skip to content

Commit

Permalink
fix: add config yaml
Browse files Browse the repository at this point in the history
Signed-off-by: liuying <[email protected]>
  • Loading branch information
lysign committed Dec 26, 2023
1 parent 6f50466 commit 89c04b7
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 28 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ cypress/config/local_config.yaml
coverage
unitCoverage
.history
config/local_config.yaml
19 changes: 0 additions & 19 deletions config/common.js

This file was deleted.

1 change: 1 addition & 0 deletions config/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
devIp: xxxxx:8080
6 changes: 5 additions & 1 deletion config/webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ const theme = require('./theme');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const { devIp } = require('./common');
const root = (path) => resolve(__dirname, `../${path}`);

const util = require('./util');
const { getConfig } = util;
const { devIp } = getConfig();

module.exports = (env = {}) => {
const devServer = {
host: 'localhost',
Expand Down Expand Up @@ -187,6 +190,7 @@ module.exports = (env = {}) => {
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
env: JSON.stringify(env),
devIp,
},
}),
],
Expand Down
6 changes: 2 additions & 4 deletions docs/1-ready-to-work.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@
- 准备好可用的后端

- 准备好可访问的后端,举个例子:<https://172.20.150.52:8080>
- 修改`config/common.js`中的相应配置:
- 修改`config/config.yaml`中的相应配置:

```javascript
module.exports = {
devIp: '172.20.150.52:8080',
};
devIp: 'xxxx:8080',
```

- 配置访问的 host 与 port
Expand Down
3 changes: 1 addition & 2 deletions src/components/Terminal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import React, { Suspense } from 'react';
import { getWebSocketProtocol } from 'utils';
import ContainerTerminal from './terminal';
import { devIp } from '../../../config/common';

const BG_COLOR = '#181d28';

Expand All @@ -27,7 +26,7 @@ export default function SessionTerminal(props) {
const { protocol, host } = window.location;

const wsIp = `${getWebSocketProtocol(protocol)}://${
process.env.NODE_ENV === 'development' ? devIp : host
process.env.NODE_ENV === 'development' ? process.env.devIp : host
}`;

return `${wsIp}${url}`;
Expand Down
3 changes: 1 addition & 2 deletions src/stores/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import { action, observable, makeObservable } from 'mobx';
import { getWebSocketProtocol } from 'utils';
import SocketClient from 'utils/socket.client';
import { devIp } from '../../config/common';

export default class WebSocketStore {
message = {};
Expand All @@ -30,7 +29,7 @@ export default class WebSocketStore {

get host() {
return process.env.NODE_ENV === 'development'
? devIp
? process.env.devIp
: window.location.host;
}

Expand Down

0 comments on commit 89c04b7

Please sign in to comment.