fix: 修改配置文件形式

This commit is contained in:
chenjinsong
2022-06-22 10:45:41 +08:00
parent 47b333ff85
commit db1a9a1c9c
5 changed files with 7 additions and 13 deletions

4
public/config.js Normal file
View File

@@ -0,0 +1,4 @@
var BASE_CONFIG = {
baseUrl: 'http://192.168.44.53:8090/',
version: '2.0.2021.05.11.19.43'
}

View File

@@ -1 +0,0 @@
{"baseUrl": "http://192.168.44.53:8090/", "version": "2.0.2021.05.11.19.43"}

View File

@@ -5,6 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0"> <meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>images/cn-logo-medium.svg"> <link rel="icon" href="<%= BASE_URL %>images/cn-logo-medium.svg">
<script src="config.js"></script>
<title>Cyber Narrator</title> <title>Cyber Narrator</title>
</head> </head>
<body class="theme-light"> <body class="theme-light">

View File

@@ -1,7 +1,7 @@
import router from './router' import router from './router'
import store from './store' import store from './store'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import { getConfigJson, getPermission } from '@/utils/api' import { getPermission } from '@/utils/api'
import { loadGeoData } from '@/utils/tools' import { loadGeoData } from '@/utils/tools'
import axios from 'axios' import axios from 'axios'
import { storageKey } from '@/utils/constants' import { storageKey } from '@/utils/constants'
@@ -18,8 +18,7 @@ router.beforeEach(async (to, from, next) => {
loadGeoData() loadGeoData()
// 加载baseUrl // 加载baseUrl
if (!axios.defaults.baseURL) { if (!axios.defaults.baseURL) {
const config = await getConfigJson() axios.defaults.baseURL = BASE_CONFIG.baseUrl
axios.defaults.baseURL = config.baseUrl
} }
if (localStorage.getItem(storageKey.token)) { if (localStorage.getItem(storageKey.token)) {
// 加载i18n // 加载i18n

View File

@@ -194,15 +194,6 @@ export async function getData (url, params = {}, isQueryList) {
return await request 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 () { export async function getPermission () {
const request = new Promise(resolve => { const request = new Promise(resolve => {
post(api.permission, { token: localStorage.getItem(storageKey.token) }).then(response => { post(api.permission, { token: localStorage.getItem(storageKey.token) }).then(response => {