1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-08-10 20:39:48 +08:00

Add support to config based on json values

This commit is contained in:
Yamel Senih 2020-11-05 00:07:32 -04:00
parent 9c90f63b3e
commit 26596bb7e3
6 changed files with 31 additions and 23 deletions

4
.gitignore vendored
View File

@ -22,3 +22,7 @@ selenium-debug.log
package-lock.json
yarn.lock
/bin/
config/local.json
config/certs/*.pem
.classpath
.project

View File

@ -1,17 +0,0 @@
{
"adempiereApi": {
"images": {
"protocol": "http:",
"baseUrl": "//localhost",
"port": 9527
}
},
"adempiereStore": {
"images": {
"protocol": "http:",
"baseUrl": "//0.0.0.0:",
"port": 8085
}
},
"service": "/adempiere-api"
}

16
config/default.json Normal file
View File

@ -0,0 +1,16 @@
{
"server": {
"host": "localhost",
"port": 9527
},
"adempiere": {
"api": {
"url": "http://localhost:8085",
"service": "/adempiere-api"
},
"images": {
"url": "http://localhost:8085",
"service": "/adempiere-api"
}
}
}

View File

@ -1,3 +1,4 @@
import { getConfig } from '@/utils/ADempiere/config'
/**
* Instance for connection to API RESTful with axios
* @author EdwinBetanc0urt <EdwinBetanc0urt@oulook.com>
@ -24,8 +25,8 @@ export function ApiRest({
})
return request.interceptors
}
const config = require('../../../config/config.json')
const apiRestAddress = config.adempiereStore.images.protocol + config.adempiereStore.images.baseUrl + config.adempiereStore.images.port + config.service
var config = getConfig()
const apiRestAddress = config.adempiere.api.url + config.adempiere.api.service
const axios = require('axios')
const request = axios.create({
baseURL: apiRestAddress,

View File

@ -0,0 +1,5 @@
// Get Config based on default or local
export function getConfig() {
const config = require('../../../config/default.json')
return config
}

View File

@ -1,7 +1,7 @@
// This file allows generate util functions for handle arrays, resources and all
// related to upload to server side and downdload from server side to client side.
// Please add the necessary functions here:
import { getConfig } from '@/utils/ADempiere/config'
// Merge two arrays and return merged array
export function mergeByteArray(currentArray, arrayToMerge) {
const mergedArray = new currentArray.constructor(currentArray.length + arrayToMerge.length)
@ -58,9 +58,8 @@ export function getImagePath({
height = 300,
operation = 'fit'
}) {
// TODO: Evaluate path url 'http://domain:port/adempiere-api', 'adempiere-api' is part of urn
const config = require('../../../config/config.json')
const url = config.adempiereStore.images.protocol + config.adempiereStore.images.baseUrl + config.adempiereStore.images.port + config.service
var config = getConfig()
const url = config.adempiere.images.url + config.adempiere.images.service
const urn = `/img?action=${operation}&width=${width}&height=${height}&url=${file}`
const uri = `${url}${urn}`