CN-39 feat: 地图
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
import { get, post } from '@/utils/http'
|
||||
import { sortByOrderNum } from '@/permission'
|
||||
import {storageKey} from "@/utils/constants";
|
||||
|
||||
export const api = {
|
||||
// 系统相关
|
||||
@@ -77,3 +78,9 @@ export async function getI18n () {
|
||||
})
|
||||
return await request
|
||||
}
|
||||
|
||||
export function loadIso36112 () {
|
||||
get(`${process.env.BASE_URL}geojson/data/countriesWithCapital.json`).then(response => {
|
||||
sessionStorage.setItem(storageKey.iso36112, JSON.stringify(response))
|
||||
})
|
||||
}
|
||||
|
||||
17
src/utils/cache.js
Normal file
17
src/utils/cache.js
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* 缓存
|
||||
* @author 陈劲松
|
||||
* @date 2021/6/30
|
||||
*/
|
||||
|
||||
const cache = {
|
||||
capitalGeo: null
|
||||
}
|
||||
|
||||
export function getCache (key, defaultValue = null) {
|
||||
return cache[key] ? cache[key] : defaultValue
|
||||
}
|
||||
|
||||
export function setCache (key, value) {
|
||||
cache[key] = value
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
export const defaultPageSize = 20
|
||||
|
||||
export const storageKey = {
|
||||
iso36112: 'cn-iso3611-2',
|
||||
i18n: 'cn-i18n',
|
||||
language: 'cn-language',
|
||||
timezone: 'cn-timezone',
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { ElMessageBox } from 'element-plus'
|
||||
import i18n from '@/i18n'
|
||||
import _ from 'lodash'
|
||||
import { storageKey } from '@/utils/constants'
|
||||
import { getCache, setCache } from '@/utils/cache'
|
||||
|
||||
export const tableSort = {
|
||||
// 是否需要排序
|
||||
@@ -388,11 +390,16 @@ export function replaceUrlPlaceholder (url, params) {
|
||||
|
||||
// 下划线转换驼峰
|
||||
export function lineToHump (name) {
|
||||
return name.replace(/\_(\w)/g, function(all, letter){
|
||||
return name.replace(/\_(\w)/g, function (all, letter) {
|
||||
return letter.toUpperCase()
|
||||
})
|
||||
}
|
||||
// 驼峰转换下划线
|
||||
export function humpToLine (name) {
|
||||
return name.replace(/([A-Z])/g,"_$1").toLowerCase()
|
||||
return name.replace(/([A-Z])/g, '_$1').toLowerCase()
|
||||
}
|
||||
|
||||
export function getCapitalGeo (countryId) {
|
||||
!getCache('capitalGeo') && setCache('capitalGeo', JSON.parse(sessionStorage.getItem(storageKey.iso36112)))
|
||||
return getCache('capitalGeo')[countryId]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user