Merge pull request #6310 from dataease/pr@dev@perf_map_key_config

fix: 符号地图key配置
This commit is contained in:
fit2cloud-chenyw 2023-10-23 16:23:42 +08:00 committed by GitHub
commit 455f480ae7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 70 additions and 16 deletions

View File

@ -132,6 +132,7 @@ public class ShiroServiceImpl implements ShiroService {
filterChainDefinitionMap.put("/dataset/field/linkMultFieldValues", "link");
filterChainDefinitionMap.put("/dataset/field/linkMappingFieldValues", "link");
filterChainDefinitionMap.put("/systemInfo/proxyUserLoginInfo", ANON);
filterChainDefinitionMap.put("/system/onlineMapKey", ANON);
filterChainDefinitionMap.put("/**", "authc");

View File

@ -165,4 +165,9 @@ public class SystemParameterController {
return systemParameterService.defaultLoginType();
}
@GetMapping("/onlineMapKey")
public String onlineMapKey() {
return systemParameterService.onlineMapKey();
}
}

View File

@ -22,6 +22,7 @@ import io.dataease.service.datasource.DatasourceService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@ -56,6 +57,9 @@ public class SystemParameterService {
return extSystemParameterMapper.email();
}
@Value("${dataease.mapkey:}")
private String mapKey;
public BasicInfo basicInfo() {
List<SystemParameter> paramList = this.getParamList("basic");
List<SystemParameter> homePageList = this.getParamList("ui.openHomePage");
@ -409,4 +413,8 @@ public class SystemParameterService {
public void clearMultiLoginCache() {
}
public String onlineMapKey() {
return mapKey;
}
}

View File

@ -29,13 +29,13 @@
</template>
<script>
import { Scene, PointLayer, Popup } from '@antv/l7'
import { uuid, hexColorToRGBA} from '@/utils/symbolmap'
import ViewTrackBar from '@/components/views/ViewTrackBar'
import { getDefaultTemplate, reverseColor } from '@/utils/map'
import {getRemark} from "../../../components/views/utils";
import {PointLayer, Popup, Scene} from '@antv/l7'
import {hexColorToRGBA, uuid} from '@/utils/symbolmap'
import ViewTrackBar from '@/components/views/ViewTrackBar'
import {getDefaultTemplate} from '@/utils/map'
import {getRemark} from "../../../components/views/utils";
export default {
export default {
name: 'ChartComponentG2',
components: { ViewTrackBar },
props: {
@ -239,19 +239,59 @@
window.addEventListener('resize', this.calcHeightDelay)
},
initMap() {
executeAxios(url, type, data, callBack) {
const param = {
url: url,
type: type,
data: data,
callBack: callBack
}
this.$emit('execute-axios', param)
if (process.env.NODE_ENV === 'development') {
execute(param).then(res => {
if (param.callBack) {
param.callBack(res)
}
}).catch(e => {
if (param.error) {
param.error(e)
}
})
}
},
getMapKey() {
const key = 'online-map-key'
return new Promise((resolve, reject) => {
if (localStorage.getItem(key)) {
resolve(localStorage.getItem(key))
} else {
const url = "/system/onlineMapKey"
this.executeAxios(url, 'get', {}, res => {
const val = res.data
localStorage.setItem(key, val)
resolve(val)
})
}
})
},
async initMap() {
if (!this.myChart) {
let theme = this.getMapTheme(this.chart)
const lang = this.$i18n.locale.includes('zh') ? 'zh' : 'en'
const mapConfig = {
lang: lang,
pitch: 0,
style: theme,
center: [121.434765, 31.256735],
zoom: 6
}
const key = await this.getMapKey()
if (key) {
mapConfig.token = key
}
this.myChart = new Scene({
id: this.chartId,
map: new this.$gaodeMap({
lang: lang,
pitch: 0,
style: theme,
center: [ 121.434765, 31.256735 ],
zoom: 6
}),
map: new this.$gaodeMap(mapConfig),
logoVisible: false
})
const chart = JSON.parse(JSON.stringify(this.chart))
@ -260,7 +300,7 @@
this.antVRenderStatus = true
if (!chart.data || !chart.data.data) {
chart.data = {
data: []
data: []
}
}
this.myChart.on('loaded', () => {
@ -268,7 +308,7 @@
this.drawView()
this.myChart.on('click', ev => {
this.$emit('trigger-edit-click', ev.originEvent)
this.$emit('trigger-edit-click', ev.originEvent)
})
})
} else {