feat(API config ): [A] use .env file to control api url

[A] use .env file to control api url

Signed-off-by: Ching <loooching@gmail.com>
This commit is contained in:
Ching 2021-10-05 13:46:54 +08:00
parent b860359404
commit ae8dd8a974
16 changed files with 70 additions and 42 deletions

View File

@ -1 +0,0 @@
.summit-recipe[data-v-7bae9cfe]{width:100%}.el-row{margin-bottom:20px;&:last-child{margin-bottom:0}}.el-col,.grid-content{border-radius:4px}.grid-content{min-height:36px}.row-bg{padding:10px 0;background-color:#f9fafc}.content{padding:20px 10px}.re-generate{margin:20px 0;width:100%}.el-tag#meal a:link,.el-tag#meal a:visited{text-decoration:none}.el-tag#meal a:active,.el-tag#meal a:hover{text-decoration:underline}.el-tag{margin:0 5px 0 0}.el-tag+.el-tag{margin:5px 0 0 0}

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Binary file not shown.

View File

@ -1 +0,0 @@
<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>frontend</title><link href="/css/app.6b2379b2.css" rel="preload" as="style"><link href="/css/chunk-vendors.8823d44d.css" rel="preload" as="style"><link href="/js/app.adba93a7.js" rel="preload" as="script"><link href="/js/chunk-vendors.cdb5b95f.js" rel="preload" as="script"><link href="/css/chunk-vendors.8823d44d.css" rel="stylesheet"><link href="/css/app.6b2379b2.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but frontend doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="/js/chunk-vendors.cdb5b95f.js"></script><script src="/js/app.adba93a7.js"></script></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -22,6 +22,7 @@
"@vue/cli-service": "~4.5.0",
"@vue/compiler-sfc": "^3.0.5",
"babel-eslint": "^10.1.0",
"dotenv-webpack": "^7.0.3",
"eslint": "^6.8.0",
"eslint-config-google": "^0.14.0",
"eslint-plugin-vue": "^7.17.0",
@ -6106,6 +6107,15 @@
"node": ">=10"
}
},
"node_modules/dotenv-defaults": {
"version": "2.0.2",
"resolved": "https://registry.nlark.com/dotenv-defaults/download/dotenv-defaults-2.0.2.tgz",
"integrity": "sha1-az7C5DGar7cJQKvactOFZ3Dud6w=",
"dev": true,
"dependencies": {
"dotenv": "^8.2.0"
}
},
"node_modules/dotenv-expand": {
"version": "5.1.0",
"resolved": "https://registry.nlark.com/dotenv-expand/download/dotenv-expand-5.1.0.tgz",
@ -6113,6 +6123,21 @@
"dev": true,
"license": "BSD-2-Clause"
},
"node_modules/dotenv-webpack": {
"version": "7.0.3",
"resolved": "https://registry.nlark.com/dotenv-webpack/download/dotenv-webpack-7.0.3.tgz?cache=0&sync_timestamp=1622697504782&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fdotenv-webpack%2Fdownload%2Fdotenv-webpack-7.0.3.tgz",
"integrity": "sha1-9Q7Dxwg6aexgduEQVmcgADt7EHs=",
"dev": true,
"dependencies": {
"dotenv-defaults": "^2.0.2"
},
"engines": {
"node": ">=10"
},
"peerDependencies": {
"webpack": "^4 || ^5"
}
},
"node_modules/duplexer": {
"version": "0.1.2",
"resolved": "https://registry.nlark.com/duplexer/download/duplexer-0.1.2.tgz",
@ -19561,12 +19586,30 @@
"integrity": "sha1-Bhr2ZNGff02PxuT/m1hM4jety4s=sha512-IrPdXQsk2BbzvCBGBOTmmSH5SodmqZNt4ERAZDmW4CT+tL8VtvinqywuANaFu4bOMWki16nqf0e4oC0QIaDr/g==",
"dev": true
},
"dotenv-defaults": {
"version": "2.0.2",
"resolved": "https://registry.nlark.com/dotenv-defaults/download/dotenv-defaults-2.0.2.tgz",
"integrity": "sha1-az7C5DGar7cJQKvactOFZ3Dud6w=",
"dev": true,
"requires": {
"dotenv": "^8.2.0"
}
},
"dotenv-expand": {
"version": "5.1.0",
"resolved": "https://registry.nlark.com/dotenv-expand/download/dotenv-expand-5.1.0.tgz",
"integrity": "sha1-P7rwIL/XlIhAcuomsel5HUWmKfA=sha512-YXQl1DSa4/PQyRfgrv6aoNjhasp/p4qs9FjJ4q4cQk+8m4r6k4ZSiEyytKG8f8W9gi8WsQtIObNmKd+tMzNTmA==",
"dev": true
},
"dotenv-webpack": {
"version": "7.0.3",
"resolved": "https://registry.nlark.com/dotenv-webpack/download/dotenv-webpack-7.0.3.tgz?cache=0&sync_timestamp=1622697504782&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fdotenv-webpack%2Fdownload%2Fdotenv-webpack-7.0.3.tgz",
"integrity": "sha1-9Q7Dxwg6aexgduEQVmcgADt7EHs=",
"dev": true,
"requires": {
"dotenv-defaults": "^2.0.2"
}
},
"duplexer": {
"version": "0.1.2",
"resolved": "https://registry.nlark.com/duplexer/download/duplexer-0.1.2.tgz",

View File

@ -68,6 +68,7 @@
</template>
<script>
import axios from 'axios';
import config from '@/config/index';
export default {
props: ['recipe_'],
watch: {
@ -102,7 +103,7 @@ export default {
};
if (!recipe_id) {
axios
.post('//localhost:8000/recipe/recipe/', data)
.post(config.publicPath + '/recipe/recipe/', data)
.then(function() {
location.reload();
})
@ -111,7 +112,7 @@ export default {
});
} else {
axios
.put('//localhost:8000/recipe/recipe/' + recipe_id, data)
.put(config.publicPath + '/recipe/recipe/' + recipe_id, data)
.then(function() {
location.reload();
})

View File

@ -35,6 +35,7 @@
<script>
import axios from 'axios';
import router from '@/router/index';
import config from '@/config/index.js';
const type_map = {
vegetable: '青菜',
@ -96,7 +97,7 @@ export default {
},
mounted() {
axios
.get('//localhost:8000/recipe/recipe/')
.get(config.publicPath + '/recipe/recipe/')
.then((response) => (this.recipes = response.data));
},
};

View File

@ -65,6 +65,7 @@
<script>
import axios from 'axios';
import router from '@/router/index';
import config from '@/config/index';
function formatDate(row, column, cellValue) {
if (cellValue === undefined) {
@ -96,16 +97,16 @@ export default {
},
mounted() {
axios
.get('//localhost:8000/recipe/week-recipe/')
.get(config.publicPath + '/recipe/week-recipe/')
.then((response) => (this.daily_recipes = response.data));
},
methods: {
reGenerateRecipe() {
axios
.post('//localhost:8000/recipe/week-recipe/')
.post(config.publicPath + '/recipe/week-recipe/')
.then((response) => {
response;
return axios.get('//localhost:8000/recipe/week-recipe/');
return axios.get(config.publicPath + '/recipe/week-recipe/');
})
.then((response) => (this.daily_recipes = response.data));
},

View File

@ -0,0 +1,3 @@
module.exports = {
publicPath: process.env.VUE_APP_BASEURL
}

View File

@ -3412,11 +3412,25 @@
dependencies:
"is-obj" "^2.0.0"
"dotenv-defaults@^2.0.2":
"integrity" "sha1-az7C5DGar7cJQKvactOFZ3Dud6w="
"resolved" "https://registry.nlark.com/dotenv-defaults/download/dotenv-defaults-2.0.2.tgz"
"version" "2.0.2"
dependencies:
"dotenv" "^8.2.0"
"dotenv-expand@^5.1.0":
"integrity" "sha1-P7rwIL/XlIhAcuomsel5HUWmKfA=sha512-YXQl1DSa4/PQyRfgrv6aoNjhasp/p4qs9FjJ4q4cQk+8m4r6k4ZSiEyytKG8f8W9gi8WsQtIObNmKd+tMzNTmA=="
"resolved" "https://registry.nlark.com/dotenv-expand/download/dotenv-expand-5.1.0.tgz"
"version" "5.1.0"
"dotenv-webpack@^7.0.3":
"integrity" "sha1-9Q7Dxwg6aexgduEQVmcgADt7EHs="
"resolved" "https://registry.nlark.com/dotenv-webpack/download/dotenv-webpack-7.0.3.tgz?cache=0&sync_timestamp=1622697504782&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fdotenv-webpack%2Fdownload%2Fdotenv-webpack-7.0.3.tgz"
"version" "7.0.3"
dependencies:
"dotenv-defaults" "^2.0.2"
"dotenv@^8.2.0":
"integrity" "sha1-Bhr2ZNGff02PxuT/m1hM4jety4s=sha512-IrPdXQsk2BbzvCBGBOTmmSH5SodmqZNt4ERAZDmW4CT+tL8VtvinqywuANaFu4bOMWki16nqf0e4oC0QIaDr/g=="
"resolved" "https://registry.nlark.com/dotenv/download/dotenv-8.6.0.tgz"
@ -8710,7 +8724,7 @@
"source-list-map" "^2.0.0"
"source-map" "~0.6.1"
"webpack@^1.0.0 || ^2.0.0 || ^3.0.0 || ^4.0.0", "webpack@^2.0.0 || ^3.0.0 || ^4.0.0", "webpack@^3.0.0 || ^4.1.0 || ^5.0.0-0", "webpack@^4.0.0", "webpack@^4.0.0 || ^5.0.0", "webpack@^4.1.0 || ^5.0.0-0", "webpack@^4.4.0", "webpack@>=2", "webpack@>=2.0.0 <5.0.0", "webpack@>=4.0.0":
"webpack@^1.0.0 || ^2.0.0 || ^3.0.0 || ^4.0.0", "webpack@^2.0.0 || ^3.0.0 || ^4.0.0", "webpack@^3.0.0 || ^4.1.0 || ^5.0.0-0", "webpack@^4 || ^5", "webpack@^4.0.0", "webpack@^4.0.0 || ^5.0.0", "webpack@^4.1.0 || ^5.0.0-0", "webpack@^4.4.0", "webpack@>=2", "webpack@>=2.0.0 <5.0.0", "webpack@>=4.0.0":
"integrity" "sha1-v5tEBOogoHNgXgoBHRiNd8tq1UI=sha512-6jJuJjg8znb/xRItk7bkT0+Q7AHCYjjFnvKIWQPkNIOyRqoCGvkOs0ipeQzrqz4l5FtN5ZI/ukEHroeX/o1/5Q=="
"resolved" "https://registry.nlark.com/webpack/download/webpack-4.46.0.tgz?cache=0&sync_timestamp=1630682912330&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fwebpack%2Fdownload%2Fwebpack-4.46.0.tgz"
"version" "4.46.0"