Skip to content

Commit

Permalink
refactor:Configure URL
Browse files Browse the repository at this point in the history
  • Loading branch information
gphper committed Jul 31, 2022
1 parent 2d35fb4 commit 55640f2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion web/baseUrl.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
let baseUrl= ""; //这里是一个默认的url,可以没有
let wsUrl = "";
switch (process.env.NODE_ENV) {
case 'prv':
baseUrl = "/api" //开发环境url
wsUrl = "localhost:8088"
break
case 'pro': // 注意这里的名字要和步骤二中设置的环境名字对应起来
baseUrl = "/" //测试环境中的url
wsUrl = window.location.host
break
}

export default baseUrl;
export {baseUrl,wsUrl};
2 changes: 1 addition & 1 deletion web/src/utils/request.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from 'axios';
import { ElMessage } from 'element-plus';
import store from '@/store'
import baseUrl from '../../baseUrl'
import {baseUrl} from '../../baseUrl'
import Vrouter from "@/router"
const router = Vrouter

Expand Down
3 changes: 2 additions & 1 deletion web/src/utils/terminal.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Terminal } from "xterm";
import { FitAddon } from "xterm-addon-fit";
import { wsUrl } from '../../baseUrl'
import { Buffer } from 'buffer'
import 'xterm/css/xterm.css'
import router from "@/router";
Expand Down Expand Up @@ -118,7 +119,7 @@ const NewShell = (id,sk,db,name)=>{

});

let socket = new WebSocket("ws://localhost:8088/ws/cmd")
let socket = new WebSocket('ws://'+wsUrl+"/ws/cmd")
socket.onopen = () => {
// 连接成功后
term.loadAddon(fitAddon)
Expand Down

0 comments on commit 55640f2

Please sign in to comment.