打包环境调整

This commit is contained in:
dong 2023-10-20 17:33:30 +08:00
parent 6fd7e6191e
commit 565900536a
3 changed files with 29 additions and 8 deletions

View File

@ -11,6 +11,8 @@
"test": "echo \"No test specified\" && exit 0",
"dev": "quasar dev",
"build": "quasar build",
"build:test": "set NODE_ENV=test&&quasar build",
"build:publish": "set NODE_ENV=publish&&quasar build",
"protoc": "node scripts/proto.cjs",
"sync": "node scripts/sync.cjs"
},

View File

@ -52,6 +52,10 @@ module.exports = configure(function (/* ctx */) {
// Full list of options: https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#build
build: {
env: {
// test:测试服务器publish正式服务器其他本地
ENV_MODE: process.env.NODE_ENV,
},
target: {
browser: ['es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1'],
node: 'node16',

View File

@ -1,4 +1,9 @@
function getHost(): string {
if (process.env.ENV_MODE == 'test') {
return 'test.joylink.club/bjrtss-server';
} else if (process.env.ENV_MODE == 'publish') {
return 'joylink.club/bjrtss-server';
}
// return '192.168.3.7:9091';
// return '192.168.3.47:9091';
// return '192.168.3.37:9091';
@ -6,18 +11,28 @@ function getHost(): string {
// return '192.168.3.5:9091';
// return '192.168.3.37:9091';
return '192.168.3.233:9091';
// return 'test.joylink.club/bjrtss-server';
}
export function getHttpBase() {
return `http://${getHost()}`;
// return `https://${getHost()}`;
let protocol = 'http';
if (['test', 'publish'].includes(process.env.ENV_MODE as string)) {
protocol = 'https';
}
return `${protocol}://${getHost()}`;
}
export function getWebsocketUrl() {
const host = '192.168.3.233';
const port = 8000;
// return `ws://${host}/ws-bj`;
return `ws://${host}:${port}/connection/websocket`;
// return `wss://${getHost()}/ws-bj`;
let protocol = 'ws';
let host = '192.168.3.233';
let port = '8000';
if (process.env.ENV_MODE == 'test') {
protocol = 'wss';
host = 'test.joylink.club/bjrtss-server';
port = '';
} else if (process.env.ENV_MODE == 'publish') {
protocol = 'wss';
host = 'joylink.club/bjrtss-server';
port = '';
}
return `${protocol}://${host}:${port}/connection/websocket`;
}