fix: 修改配置文件形式
This commit is contained in:
4
public/config.js
Normal file
4
public/config.js
Normal file
@@ -0,0 +1,4 @@
|
||||
var BASE_CONFIG = {
|
||||
baseUrl: 'http://192.168.44.53:8090/',
|
||||
version: '2.0.2021.05.11.19.43'
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
{"baseUrl": "http://192.168.44.53:8090/", "version": "2.0.2021.05.11.19.43"}
|
||||
@@ -5,6 +5,7 @@
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="icon" href="<%= BASE_URL %>images/cn-logo-medium.svg">
|
||||
<script src="config.js"></script>
|
||||
<title>Cyber Narrator</title>
|
||||
</head>
|
||||
<body class="theme-light">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import router from './router'
|
||||
import store from './store'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { getConfigJson, getPermission } from '@/utils/api'
|
||||
import { getPermission } from '@/utils/api'
|
||||
import { loadGeoData } from '@/utils/tools'
|
||||
import axios from 'axios'
|
||||
import { storageKey } from '@/utils/constants'
|
||||
@@ -18,8 +18,7 @@ router.beforeEach(async (to, from, next) => {
|
||||
loadGeoData()
|
||||
// 加载baseUrl
|
||||
if (!axios.defaults.baseURL) {
|
||||
const config = await getConfigJson()
|
||||
axios.defaults.baseURL = config.baseUrl
|
||||
axios.defaults.baseURL = BASE_CONFIG.baseUrl
|
||||
}
|
||||
if (localStorage.getItem(storageKey.token)) {
|
||||
// 加载i18n
|
||||
|
||||
@@ -194,15 +194,6 @@ export async function getData (url, params = {}, isQueryList) {
|
||||
return await request
|
||||
}
|
||||
|
||||
export async function getConfigJson () {
|
||||
const request = new Promise(resolve => {
|
||||
get(`${process.env.BASE_URL}config.json?Timestamp=${new Date().getTime()}`).then(config => {
|
||||
resolve(config)
|
||||
})
|
||||
})
|
||||
return await request
|
||||
}
|
||||
|
||||
export async function getPermission () {
|
||||
const request = new Promise(resolve => {
|
||||
post(api.permission, { token: localStorage.getItem(storageKey.token) }).then(response => {
|
||||
|
||||
Reference in New Issue
Block a user