fix: 修复测试用例等
This commit is contained in:
@@ -9,10 +9,12 @@ const i18n = createI18n({
|
||||
export async function loadI18n () {
|
||||
if (!store.state.i18n) {
|
||||
const items = await getI18n()
|
||||
if (items) {
|
||||
store.commit('loadI18n')
|
||||
Object.keys(items).forEach(lang => {
|
||||
i18n.global.mergeLocaleMessage(lang, items[lang])
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
export default i18n
|
||||
|
||||
@@ -10,7 +10,7 @@ const loginWhiteList = ['/login', '/'] // 免登陆白名单
|
||||
const permissionWhiteList = [...loginWhiteList] // 权限白名单
|
||||
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
if (to.path.indexOf('/login') == -1) {
|
||||
if (to.path.indexOf('/login') === -1) {
|
||||
sessionStorage.setItem(storageKey.tokenExpireCurrentPath, decodeURIComponent(to.fullPath))
|
||||
}
|
||||
// 加载iso-3166-2资源
|
||||
|
||||
@@ -354,9 +354,9 @@ export async function getDictList (params) {
|
||||
return await getData(api.dict, params, true)
|
||||
}
|
||||
function handleResult (response) {
|
||||
if (response.data.list || response.data.result) {
|
||||
if (response.data && (response.data.list || response.data.result)) {
|
||||
return response.data.list || response.data.result
|
||||
} else if (response.data.result === 0) {
|
||||
} else if (response.data && response.data.result === 0) {
|
||||
return response.data.result
|
||||
} else {
|
||||
return response.data
|
||||
@@ -382,13 +382,17 @@ export async function getData (url, params = {}, isQueryList) {
|
||||
}
|
||||
|
||||
export async function getPermission () {
|
||||
const request = new Promise(resolve => {
|
||||
const request = new Promise((resolve, reject) => {
|
||||
axios.post(api.permission, { token: localStorage.getItem(storageKey.token) }).then(response => {
|
||||
if (response.status === 200) {
|
||||
resolve({
|
||||
menuList: sortByOrderNum(response.data.data.menus),
|
||||
buttonList: response.data.data.buttons,
|
||||
roleList: response.data.data.roles
|
||||
})
|
||||
} else {
|
||||
reject(response.data)
|
||||
}
|
||||
})
|
||||
})
|
||||
return await request
|
||||
@@ -396,6 +400,7 @@ export async function getPermission () {
|
||||
|
||||
export async function getI18n () {
|
||||
const dictData = await getDictList({ type: 'lang' })
|
||||
if (dictData) {
|
||||
const langs = dictData.map(d => d.value).join(',')
|
||||
localStorage.setItem(storageKey.languages, langs)
|
||||
const request = new Promise(resolve => {
|
||||
@@ -405,6 +410,8 @@ export async function getI18n () {
|
||||
})
|
||||
})
|
||||
return await request
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/* 获得原始的3611-2 json字符串数据 */
|
||||
|
||||
@@ -3,6 +3,8 @@ import { mount } from '@vue/test-utils'
|
||||
import axios from 'axios'
|
||||
import mockData from './mockData/InformationAggregation'
|
||||
import ElementPlus from 'element-plus'
|
||||
import common from '@/mixins/common'
|
||||
import chartMixin from '@/views/charts2/chart-mixin'
|
||||
|
||||
let wrapper = null
|
||||
const mockGet = mockData.common
|
||||
@@ -35,7 +37,8 @@ function axiosPostAndMounted (data) {
|
||||
propsData: {
|
||||
entity,
|
||||
timeFilter
|
||||
}
|
||||
},
|
||||
mixins: [common, chartMixin]
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ import { mount } from '@vue/test-utils'
|
||||
import axios from 'axios'
|
||||
import ElementPlus from 'element-plus'
|
||||
import { mockData } from './mockData/NpmAppEventByTable'
|
||||
import common from '@/mixins/common'
|
||||
import chartMixin from '@/views/charts2/chart-mixin'
|
||||
|
||||
let wrapper = null
|
||||
const mockGet = mockData.common.data
|
||||
@@ -30,7 +32,8 @@ function axiosPostAndMounted (data) {
|
||||
},
|
||||
propsData: {
|
||||
timeFilter
|
||||
}
|
||||
},
|
||||
mixins: [common, chartMixin]
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import NpmEventsByType from '@/views/charts2/charts/npm/NpmEventsByType'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import axios from 'axios'
|
||||
import { mockData } from './mockData/NpmEventsByType'
|
||||
import common from '@/mixins/common'
|
||||
|
||||
const mockGet = mockData.common.data
|
||||
let wrapper = null
|
||||
@@ -26,7 +27,8 @@ function axiosPostAndMounted (data) {
|
||||
wrapper = mount(NpmEventsByType, {
|
||||
propsData: {
|
||||
timeFilter
|
||||
}
|
||||
},
|
||||
mixins: [common]
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@ import NpmEventsHeader from '@/views/charts2/charts/npm/NpmEventsHeader'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import axios from 'axios'
|
||||
import { mockData } from './mockData/NpmEventsHeader'
|
||||
import common from '@/mixins/common'
|
||||
import chartMixin from '@/views/charts2/chart-mixin'
|
||||
|
||||
// 模拟数据
|
||||
const chartData = mockData.common.data
|
||||
@@ -23,7 +25,8 @@ function axiosPostAndMounted (data) {
|
||||
wrapper = mount(NpmEventsHeader, {
|
||||
propsData: {
|
||||
type
|
||||
}
|
||||
},
|
||||
mixins: [common, chartMixin]
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user