diff --git a/src/GeolocationEditor/country-editor.js b/src/GeolocationEditor/country-editor.js index e80ba1fc..410bb1ef 100644 --- a/src/GeolocationEditor/country-editor.js +++ b/src/GeolocationEditor/country-editor.js @@ -177,12 +177,12 @@ class CountryEditor extends Component { getLocationData = () => { const { config } = this.props; - const { mediaUrl } = { ...window.dtable, ...config }; + const { mediaUrl, server } = { ...window?.dtable, ...config }; let geoFileName = 'en-region-location'; if (this.lang === 'cn') { geoFileName = 'cn-region-location'; } - return fetch(`${mediaUrl}geo-data/${geoFileName}.json`) + return fetch(`${server}${mediaUrl}geo-data/${geoFileName}.json`.replaceAll('//', '/')) .then(res => { return res.json(); }) diff --git a/src/GeolocationEditor/index.css b/src/GeolocationEditor/index.css index 356b1bb1..0eac337c 100644 --- a/src/GeolocationEditor/index.css +++ b/src/GeolocationEditor/index.css @@ -205,7 +205,6 @@ } .dtable-ui-geolocation-map-editor .search-tables-input { - line-height: 38px; padding-right: 30px; border-bottom: 0; background: #fff; diff --git a/src/GeolocationEditor/index.js b/src/GeolocationEditor/index.js index 53066816..fc021694 100644 --- a/src/GeolocationEditor/index.js +++ b/src/GeolocationEditor/index.js @@ -31,6 +31,9 @@ class GeolocationEditor extends React.Component { this.state = { editorPosition: null, }; + if (!window.app) { + window.app = {}; + } this.editor = null; } diff --git a/src/GeolocationEditor/location-editor.js b/src/GeolocationEditor/location-editor.js index f68f1196..99414fd1 100644 --- a/src/GeolocationEditor/location-editor.js +++ b/src/GeolocationEditor/location-editor.js @@ -97,10 +97,11 @@ class LocationEditor extends Component { }; getLocationData = () => { - const { mediaUrl } = window.dtable; + const { config } = this.props; + const { mediaUrl, server } = { ...window?.dtable, ...config }; // get locations from server - return fetch(`${mediaUrl}geo-data/cn-location.json`).then((res) => { + return fetch(`${server}${mediaUrl}geo-data/cn-location.json`.replaceAll('//', '/')).then((res) => { return res.json(); }).catch(() => { // get locations from local diff --git a/src/GeolocationEditor/map-editor-utils.js b/src/GeolocationEditor/map-editor-utils.js index b713e42f..e60b893c 100644 --- a/src/GeolocationEditor/map-editor-utils.js +++ b/src/GeolocationEditor/map-editor-utils.js @@ -16,7 +16,7 @@ const MINE_MAP_ONLINE_SERVICE = { }; export const getMineMapUrl = (config = {}) => { - const { dtableMineMapCustomConfig = {} } = { ...window.dtable, ...config }; + const { dtableMineMapCustomConfig = {} } = { ...window?.dtable, ...config }; const { domain_url = '', data_domain_url = '', server_domain_url = '', sprite_url = '', service_url = '' } = dtableMineMapCustomConfig; return { @@ -44,7 +44,7 @@ export const getInitCenter = (isSelectionEditor = false) => { }; export const getMapInfo = (config = {}) => { - const { dtableBaiduMapKey: baiduMapKey, dtableGoogleMapKey: googleMapKey, dtableMineMapKey: mineMapKey } = { ...window.dtable, ...config }; + const { dtableBaiduMapKey: baiduMapKey, dtableGoogleMapKey: googleMapKey, dtableMineMapKey: mineMapKey } = { ...window?.dtable, ...config }; let mapType; let mapKey; if (baiduMapKey) { diff --git a/src/GeolocationEditor/map-editor/index.js b/src/GeolocationEditor/map-editor/index.js index 4393ab12..346adad0 100644 --- a/src/GeolocationEditor/map-editor/index.js +++ b/src/GeolocationEditor/map-editor/index.js @@ -88,7 +88,7 @@ class MapEditor extends Component { loadMineMapCallBack = () => { if (!this.timer) { this.timer = setTimeout(() => { - const { domainUrl, dataDomainUrl, serverDomainUrl, spriteUrl, serviceUrl } = getMineMapUrl(); + const { domainUrl, dataDomainUrl, serverDomainUrl, spriteUrl, serviceUrl } = getMineMapUrl(this.props.config); window.minemap.domainUrl = domainUrl; window.minemap.dataDomainUrl = dataDomainUrl; window.minemap.serverDomainUrl = serverDomainUrl; diff --git a/src/GeolocationEditor/map-editor/large-editor/index.css b/src/GeolocationEditor/map-editor/large-editor/index.css index 3eea8393..0871d85b 100644 --- a/src/GeolocationEditor/map-editor/large-editor/index.css +++ b/src/GeolocationEditor/map-editor/large-editor/index.css @@ -51,7 +51,6 @@ } .dtable-ui-large-map-editor-dialog .dtable-ui-geolocation-map-editor-large .search-tables-input { - line-height: 38px; padding-right: 30px; border-bottom: 0; background: #fff; diff --git a/src/GeolocationEditor/map-editor/large-editor/index.js b/src/GeolocationEditor/map-editor/large-editor/index.js index c21d0b66..c115776f 100644 --- a/src/GeolocationEditor/map-editor/large-editor/index.js +++ b/src/GeolocationEditor/map-editor/large-editor/index.js @@ -90,7 +90,7 @@ class LargeMapEditorDialog extends React.Component { loadMineMapCallBack = () => { if (!this.timer) { this.timer = setTimeout(() => { - const { domainUrl, dataDomainUrl, serverDomainUrl, spriteUrl, serviceUrl } = getMineMapUrl(); + const { domainUrl, dataDomainUrl, serverDomainUrl, spriteUrl, serviceUrl } = getMineMapUrl(this.props.config); window.minemap.domainUrl = domainUrl; window.minemap.dataDomainUrl = dataDomainUrl; window.minemap.serverDomainUrl = serverDomainUrl; diff --git a/src/GeolocationEditor/map-selection-editor/index.js b/src/GeolocationEditor/map-selection-editor/index.js index 6d80bf42..4bcda0a1 100644 --- a/src/GeolocationEditor/map-selection-editor/index.js +++ b/src/GeolocationEditor/map-selection-editor/index.js @@ -52,7 +52,7 @@ class MapSelectionEditor extends Component { } componentWillUnmount() { - if (this.mapType === MAP_TYPES.B_MAP) { + if (this.map && this.mapType === MAP_TYPES.B_MAP) { let center = {}; center.zoom = this.map.getZoom(); let coordinate = this.map.getCenter(); diff --git a/src/GeolocationEditor/map-selection-editor/large-editor/index.js b/src/GeolocationEditor/map-selection-editor/large-editor/index.js index 6ddecc42..12978897 100644 --- a/src/GeolocationEditor/map-selection-editor/large-editor/index.js +++ b/src/GeolocationEditor/map-selection-editor/large-editor/index.js @@ -53,7 +53,7 @@ class LargeMapSelectionEditorDialog extends React.Component { } componentWillUnmount() { - if (this.mapType === MAP_TYPES.B_MAP) { + if (this.map && this.mapType === MAP_TYPES.B_MAP) { let center = {}; center.zoom = this.map.getZoom(); let coordinate = this.map.getCenter(); diff --git a/src/GeolocationEditor/province-city-editor.js b/src/GeolocationEditor/province-city-editor.js index e268f05d..768b8a7b 100644 --- a/src/GeolocationEditor/province-city-editor.js +++ b/src/GeolocationEditor/province-city-editor.js @@ -85,10 +85,11 @@ class ProvinceCityEditor extends Component { }; getLocationData = () => { - const { mediaUrl } = window.dtable; + const { config } = this.props; + const { mediaUrl, server } = { ...window?.dtable, ...config }; // get locations from server - return fetch(`${mediaUrl}geo-data/cn-location.json`).then((res) => { + return fetch(`${server}${mediaUrl}geo-data/cn-location.json`.replaceAll('//', '/')).then((res) => { return res.json(); }).catch(() => { // get locations from local diff --git a/src/GeolocationEditor/province-editor.js b/src/GeolocationEditor/province-editor.js index 5d8e26a4..a5fac4a2 100644 --- a/src/GeolocationEditor/province-editor.js +++ b/src/GeolocationEditor/province-editor.js @@ -61,9 +61,10 @@ class ProvinceEditor extends Component { getLocationData = () => { // mediaUrl - const { mediaUrl } = window.dtable; + const { config } = this.props; + const { mediaUrl, server } = { ...window?.dtable, ...config }; // get locations from server - return fetch(`${mediaUrl}geo-data/cn-location.json`).then((res) => { + return fetch(`${server}${mediaUrl}geo-data/cn-location.json`.replaceAll('//', '/')).then((res) => { return res.json(); }).catch(() => { // get locations from local diff --git a/src/RowExpandEditor/RowExpandGeolocationEditor/index.js b/src/RowExpandEditor/RowExpandGeolocationEditor/index.js index 422974cc..825ffd08 100644 --- a/src/RowExpandEditor/RowExpandGeolocationEditor/index.js +++ b/src/RowExpandEditor/RowExpandGeolocationEditor/index.js @@ -123,14 +123,14 @@ class RowExpandGeolocationEditor extends React.Component { }; getLocationInfo = (value) => { - const { column } = this.props; - const { dtableBaiduMapKey, dtableMineMapKey } = window.dtable; + const { column, config } = this.props; + const { dtableBaiduMapKey, dtableMineMapKey } = { ...window?.dtable, ...config }; const isBaiduMap = !!(dtableBaiduMapKey || dtableMineMapKey); return getGeolocationDisplayString(value, column.data, { isBaiduMap, hyphen: ' ' }); }; render() { - const { column, row } = this.props; + const { column, row, config } = this.props; const { value } = this.state; return (
this.editorContainer = ref} className="mt-2"> @@ -140,6 +140,7 @@ class RowExpandGeolocationEditor extends React.Component { ref={ref => this.geoEditor = ref} isInModal={true} column={column} + config={config} row={row} value={value} onCommit={this.onCommit}