Skip to content

Commit ededd67

Browse files
authored
Merge pull request #24 from lizhongyuan3/fix-mac
fix mac 下运行 下载路径格式不对的问题
2 parents abe25e2 + 92ffd41 commit ededd67

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

packages/renderer/src/utils/download.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ export function downloadImage (tile, downloadOption) {
138138
function _downloadImage (tile, downloadOption) {
139139
return new Promise((resolve) => {
140140

141-
const temppath = downloadOption.downloadPath + tile.z + '\\' + tile.x;
141+
const temppath = downloadOption.downloadPath + tile.z + '/' + tile.x;
142142
window.electron.ipcRenderer.send('ensure-dir', temppath);
143-
const savePath = temppath + '\\' + tile.y + downloadOption.pictureType;
143+
const savePath = temppath + '/' + tile.y + downloadOption.pictureType;
144144
const param = {zoom: tile.z, url:tile.url, savePath, x:tile.x, y:tile.y};
145145

146146
window.electron.ipcRenderer.send('save-image', param);
@@ -171,9 +171,9 @@ function _downloadClipImage (tile, downloadOption) {
171171
const code = prj.code;
172172

173173
const apiDownload = (temp, imageBuffer) => {
174-
const temppath = downloadPath + temp.z + '\\' + temp.x;
174+
const temppath = downloadPath + temp.z + '/' + temp.x;
175175
window.electron.ipcRenderer.send('ensure-dir', temppath);
176-
const savePath = temppath + '\\' + temp.y + pictureType;
176+
const savePath = temppath + '/' + temp.y + pictureType;
177177
const param = {zoom: temp.z, url:temp.url, savePath, x:temp.x, y:temp.y, imageBuffer};
178178
window.electron.ipcRenderer.send('save-image', param);
179179
};

packages/renderer/src/utils/fileSaveTms.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class TileTMS {
1818
}
1919
async downloadTiles(clipImage) {
2020
// 当前绝对路径
21-
const downloadPath = this.rootPath + '\\';
21+
const downloadPath = this.rootPath + '/';
2222
// 下载范围
2323
const zmin = this.minZoom;
2424
const zmax = this.maxZoom + 1;
@@ -78,7 +78,7 @@ export class TileTMSList {
7878
}
7979
async downloadTiles(clipImage, tileLayer, count) {
8080
// 当前绝对路径
81-
const downloadPath = this.rootPath + '\\' + tileLayer.config().style + '\\';
81+
const downloadPath = this.rootPath + '/' + tileLayer.config().style + '/';
8282
// 下载范围
8383
const zmin = this.minZoom;
8484
const zmax = this.maxZoom + 1;
@@ -126,7 +126,7 @@ export class TileTMSList {
126126
}
127127
calcTiles() {
128128
// 当前绝对路径
129-
const downloadPath = this.rootPath + '\\';
129+
const downloadPath = this.rootPath + '/';
130130

131131
// 下载范围
132132
const zmin = this.minZoom;
@@ -142,9 +142,9 @@ export class TileTMSList {
142142
tileGridsList.forEach(tileGrids => {
143143
for (let x = 0; x < tileGrids.tiles.length; x++) {
144144
const tile = tileGrids.tiles[x];
145-
const temppath = downloadPath + tile.z + '\\' + tile.x;
145+
const temppath = downloadPath + tile.z + '/' + tile.x;
146146
this.apiEnsureDirSync(temppath);
147-
const savePath = temppath + '\\' + tile.y + pictureType;
147+
const savePath = temppath + '/' + tile.y + pictureType;
148148

149149
storeMap[`${tile.x}${tile.y}${tile.z}`] = {zoom: tile.z, layers:[
150150
{

packages/renderer/src/utils/tileBaidu.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class TileBaidu {
141141
}
142142
calcTiles() {
143143
// 当前绝对路径
144-
const downloadPath = this.rootPath + '\\';
144+
const downloadPath = this.rootPath + '/';
145145

146146
// 下载范围
147147
const zmin = this.minZoom;
@@ -166,12 +166,12 @@ class TileBaidu {
166166
if (minLat < 0) minLat = 0;
167167
const maxLat = Math.max(bottom_tile, top_tile);
168168
for (let x = minLong; x < maxLong; x++) {
169-
const temppath = downloadPath + z + '\\' + x;
169+
const temppath = downloadPath + z + '/' + x;
170170
this.apiEnsureDirSync(temppath);
171171
for (let y = minLat; y < maxLat; y++) {
172172
// const str3 = baseUrl.replace('{z}', z).replace('{x}', x).replace('{y}', y);
173173
const str3 = this.tileLayer.getTileUrl(x, y, z);
174-
const path2 = temppath + '\\' + y + pictureType;
174+
const path2 = temppath + '/' + y + pictureType;
175175
list.push({ zoom: z, url: str3, savePath: path2 });
176176
}
177177
}

packages/renderer/src/utils/tileTms.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class TileTMS {
3535
}
3636
calcTiles() {
3737
// 当前绝对路径
38-
const downloadPath = this.rootPath + '\\';
38+
const downloadPath = this.rootPath + '/';
3939

4040
// 下载范围
4141
const zmin = this.minZoom;
@@ -60,12 +60,12 @@ export class TileTMS {
6060
if (minLat < 0) minLat = 0;
6161
const maxLat = Math.max(bottom_tile, top_tile);
6262
for (let x = minLong; x < maxLong; x++) {
63-
const temppath = downloadPath + z + '\\' + x;
63+
const temppath = downloadPath + z + '/' + x;
6464
this.apiEnsureDirSync(temppath);
6565
for (let y = minLat; y < maxLat; y++) {
6666
// const str3 = baseUrl.replace('{z}', z).replace('{x}', x).replace('{y}', y);
6767
const str3 = this.tileLayer.getTileUrl(x, y, z);
68-
const path2 = temppath + '\\' + y + pictureType;
68+
const path2 = temppath + '/' + y + pictureType;
6969
list.push({zoom: z, url:str3, savePath:path2});
7070
}
7171
}
@@ -96,7 +96,7 @@ export class TileTMSList {
9696
}
9797
calcTiles(subpath, layer) {
9898
// 当前绝对路径
99-
const downloadPath = this.rootPath + '\\' + subpath + '\\';
99+
const downloadPath = this.rootPath + '/' + subpath + '/';
100100

101101
// 下载范围
102102
const zmin = this.minZoom;
@@ -120,11 +120,11 @@ export class TileTMSList {
120120
if (minLat < 0) minLat = 0;
121121
const maxLat = Math.max(bottom_tile, top_tile);
122122
for (let x = minLong; x < maxLong; x++) {
123-
const temppath = downloadPath + z + '\\' + x;
123+
const temppath = downloadPath + z + '/' + x;
124124
this.apiEnsureDirSync(temppath);
125125
for (let y = minLat; y < maxLat; y++) {
126126
const str3 = layer.getTileUrl(x, y, z);
127-
const path2 = temppath + '\\' + y + pictureType;
127+
const path2 = temppath + '/' + y + pictureType;
128128
list.push({zoom: z, url:str3, savePath:path2});
129129
}
130130
}
@@ -151,7 +151,7 @@ export class TileTMSList {
151151
}
152152
calcTiles(layers) {
153153
// 当前绝对路径
154-
const downloadPath = this.rootPath + '\\';
154+
const downloadPath = this.rootPath + '/';
155155

156156
// 下载范围
157157
const zmin = this.minZoom;
@@ -175,11 +175,11 @@ export class TileTMSList {
175175
if (minLat < 0) minLat = 0;
176176
const maxLat = Math.max(bottom_tile, top_tile);
177177
for (let x = minLong; x < maxLong; x++) {
178-
const temppath = downloadPath + z + '\\' + x;
178+
const temppath = downloadPath + z + '/' + x;
179179
this.apiEnsureDirSync(temppath);
180180
for (let y = minLat; y < maxLat; y++) {
181181
const str3 = layers.map(ll => {return {url: ll.getTileUrl(x, y, z), isLabel: ll.config().style.includes('_Label')};});
182-
const path2 = temppath + '\\' + y + pictureType;
182+
const path2 = temppath + '/' + y + pictureType;
183183
list.push({zoom: z, layers:str3, savePath:path2});
184184
}
185185
}

0 commit comments

Comments
 (0)