Browse Source

改变环境变量的取值方式

master
巴林闲侠 2 years ago
parent
commit
f65f9ad754
  1. 1
      console/client/assets/env.js
  2. 1
      console/client/index.ejs
  3. 13
      console/client/index.html
  4. 2
      console/client/src/layout/containers/layout/index.js
  5. 1
      console/client/src/sections/console/containers/index.js
  6. 6
      console/config.js

1
console/client/assets/env.js

@ -0,0 +1 @@
window.FS_API_ROOT = 'http://localhost:4600'

1
console/client/index.ejs

@ -5,6 +5,7 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<link rel="shortcut icon" href="/assets/images/logo.png"> <link rel="shortcut icon" href="/assets/images/logo.png">
<link rel="stylesheet" type="text/css" href="/assets/font_sc/iconfont.css"> <link rel="stylesheet" type="text/css" href="/assets/font_sc/iconfont.css">
<script type="text/javascript" src="/assets/env.js"></script>
</head> </head>
<style> <style>

13
console/client/index.html

@ -1,20 +1,21 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title></title> <title></title>
<link rel="shortcut icon" href="/assets/images/logo.png"> <link rel="shortcut icon" href="/assets/images/logo.png">
<link rel="stylesheet" type="text/css" href="/assets/font_sc/iconfont.css"> <link rel="stylesheet" type="text/css" href="/assets/font_sc/iconfont.css">
</head> <script type="text/javascript" src="/assets/env.js"></script>
<style> </head>
<style>
</style> </style>
<body> <body>
<div id='App'></div> <div id='App'></div>
<script type="text/javascript" src="http://localhost:5401/client/build/vendor.js"></script> <script type="text/javascript" src="http://localhost:5401/client/build/vendor.js"></script>
<script type="text/javascript" src="http://localhost:5401/client/build/app.js"></script> <script type="text/javascript" src="http://localhost:5401/client/build/app.js"></script>
</body> </body>
</html> </html>

2
console/client/src/layout/containers/layout/index.js

@ -66,7 +66,7 @@ const LayoutContainer = props => {
dom.scrollTop = 0; dom.scrollTop = 0;
} }
}) })
console.log(FS_API_ROOT);
return ( return (
<Layout id="layout"> <Layout id="layout">
<Layout.Header style={{ padding: 0 }}> <Layout.Header style={{ padding: 0 }}>

1
console/client/src/sections/console/containers/index.js

@ -44,6 +44,7 @@ function Index (props) {
}) })
useEffect(() => { useEffect(() => {
console.log(FS_API_ROOT, window.FS_API_ROOT);
const canvasArea = document.getElementById('canvasArea') const canvasArea = document.getElementById('canvasArea')
const canvasHeight = canvasArea.clientHeight - 12 * 2 - 6 const canvasHeight = canvasArea.clientHeight - 12 * 2 - 6
const canvasWidth = canvasArea.clientWidth - 12 * 2 const canvasWidth = canvasArea.clientWidth - 12 * 2

6
console/config.js

@ -7,6 +7,7 @@
const path = require('path'); const path = require('path');
/*这种以CommonJS的同步形式去引入其它模块的方式代码更加简洁:获取组件*/ /*这种以CommonJS的同步形式去引入其它模块的方式代码更加简洁:获取组件*/
const os = require('os'); const os = require('os');
const fs = require('fs')
const moment = require('moment'); const moment = require('moment');
const args = require('args'); const args = require('args');
const dev = process.env.NODE_ENV == 'development'; const dev = process.env.NODE_ENV == 'development';
@ -126,6 +127,11 @@ if (product.frontParams) {
process.exit(-1); process.exit(-1);
} }
} }
let env = []
for (let k in product.frontParams) {
env.push(`window.${k} = '${product.frontParams[k]}'`)
}
fs.writeFileSync('./client/assets/env.js', env.join(';'))
} }
let config; let config;

Loading…
Cancel
Save