Skip to content

Commit

Permalink
web: 修改配置文件,同时支持本地测试和生成发布
Browse files Browse the repository at this point in the history
  • Loading branch information
shinny-mayanqiong committed May 12, 2020
1 parent 91f3d50 commit de4f641
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions web/public/index.html
Expand Up @@ -15,10 +15,10 @@
<% if (NODE_ENV === 'development') {%>

<script>
const TqsdkAddress = '127.0.0.1:53813'
const GetTqsdkUrl = function () {
return new Promise(function (resolve, reject) {
// resolve({"ins_url": "https://openmd.shinnytech.com/t/md/symbols/latest.json", "md_url": "wss://openmd.shinnytech.com/t/md/front/mobile", "ws_url": "ws://127.0.0.1:61253"})
fetch('http://127.0.0.1:54738/urlcors').then(function(response) {
fetch('http://' + TqsdkAddress + '/urlcors').then(function(response) {
response.json().then(function(json){
resolve(json)
})
Expand All @@ -28,6 +28,7 @@
</script>
<% } else if (NODE_ENV === 'production'){%>
<script>
const TqsdkAddress = location.host
const GetTqsdkUrl = function () {
return new Promise(function (resolve, reject) {
fetch('/url').then(function(response) {
Expand Down
3 changes: 2 additions & 1 deletion web/src/main.js
Expand Up @@ -77,13 +77,14 @@ GetTqsdkUrl().then(function(urlJson){
})
Vue.prototype.$tqsdk = Vue.$tqsdk
Vue.$tqsdk.initMdWebsocket()
let tqWs = Vue.$tqsdk.addWebSocket('ws://' + location.host + '/ws')
let tqWs = Vue.$tqsdk.addWebSocket(`ws://${TqsdkAddress}/ws`)
tqWs.on('close', function(){
store.commit('set_py_file_status', false)
})
tqWs.on('open', function(){
store.commit('set_py_file_status', true)
})

Vue.$tqsdk.on('rtn_data', function(){
let backtest = Vue.$tqsdk.get_by_path(['_tqsdk_backtest'])
if (backtest && backtest.current_dt) {
Expand Down
2 changes: 1 addition & 1 deletion web/vue.config.js
@@ -1,6 +1,6 @@
module.exports = {
outputDir: '../tqsdk/web',
publicPath: 'web/',
publicPath: process.env.NODE_ENV === 'production' ? 'web/' : '/',
lintOnSave: false,
productionSourceMap: false,
chainWebpack: config => {
Expand Down

0 comments on commit de4f641

Please sign in to comment.