diff --git a/.env.dev b/.env.dev new file mode 100644 index 0000000..5320843 --- /dev/null +++ b/.env.dev @@ -0,0 +1,2 @@ +API=192.168.3.233:9081 +http=https diff --git a/.env.local b/.env.local new file mode 100644 index 0000000..c939416 --- /dev/null +++ b/.env.local @@ -0,0 +1,2 @@ +API=localhost:9081 +http=https diff --git a/.env.prod b/.env.prod new file mode 100644 index 0000000..c939416 --- /dev/null +++ b/.env.prod @@ -0,0 +1,2 @@ +API=localhost:9081 +http=https diff --git a/.env.prod-test b/.env.prod-test new file mode 100644 index 0000000..c939416 --- /dev/null +++ b/.env.prod-test @@ -0,0 +1,2 @@ +API=localhost:9081 +http=https diff --git a/EnvParse.js b/EnvParse.js new file mode 100644 index 0000000..0d66b11 --- /dev/null +++ b/EnvParse.js @@ -0,0 +1,7 @@ + +const DotEnv = require('dotenv') +const parsedEnv = DotEnv.config({ path: `.env.${process.env.NODE_ENV}` }).parsed + +module.exports = function () { + return parsedEnv +} diff --git a/package.json b/package.json index 51ce124..e01b94b 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,11 @@ "lint": "eslint --ext .js,.ts,.vue ./", "format": "prettier --write \"**/*.{js,ts,vue,scss,html,md,json}\" --ignore-path .gitignore", "test": "echo \"No test specified\" && exit 0", - "dev": "quasar dev", - "build": "quasar build", + "dev": "set NODE_ENV=dev&&quasar dev", + "local": "set NODE_ENV=local&&quasar dev", + "build": "set NODE_ENV=prod&&quasar build", + "build-test": "set NODE_ENV=prod-test&&quasar build", + "protoc": "node scripts/proto.cjs", "sync": "node scripts/sync.cjs" }, @@ -19,14 +22,16 @@ "@pixi/graphics-extras": "^7.2.4", "@quasar/extras": "^1.0.0", "@stomp/stompjs": "^7.0.0", - "centrifuge": "^4.0.1", "axios": "^1.2.1", + "centrifuge": "^4.0.1", + "dotenv": "^16.3.1", "google-protobuf": "^3.21.2", "js-base64": "^3.7.5", "pinia": "^2.0.11", "pixi-viewport": "^5.0.1", "pixi.js": "^7.2.4", "quasar": "^2.6.0", + "save-dev": "0.0.1-security", "vue": "^3.0.0", "vue-router": "^4.0.0" }, diff --git a/quasar.config.js b/quasar.config.js index 6bc50e6..5bc4720 100644 --- a/quasar.config.js +++ b/quasar.config.js @@ -56,6 +56,7 @@ module.exports = configure(function (/* ctx */) { browser: ['es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1'], node: 'node16', }, + env: require('./EnvParse.js')(), vueRouterMode: 'history', // available values: 'hash', 'history' vueRouterBase: BasePath, diff --git a/src/configs/UrlManage.ts b/src/configs/UrlManage.ts index 131b3e8..24926c8 100644 --- a/src/configs/UrlManage.ts +++ b/src/configs/UrlManage.ts @@ -1,9 +1,8 @@ function getHost(): string { - // return '192.168.3.7:9081'; - // return '192.168.3.47:9081'; - // return '192.168.3.37:9081'; - // return '192.168.3.15:9081'; - return '192.168.3.233:9081'; + const base_api = process.env.API; + console.log(process.env); + console.log(' load env :' + process.env.NODE_ENV); + return base_api + ''; } export function getHttpBase() {