Skip to content

Commit 3ef1961

Browse files
committed
【fix】修复英文示例找不到libs
AI-GEN: 80% Claude
1 parent e6b6157 commit 3ef1961

7 files changed

Lines changed: 30 additions & 1 deletion

File tree

dist/classic/include-classic.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@
5858
var distMatch = selfSrc.match(/^(.*?)\/?(?:classic\/)?include-classic\.js(?:[?#]|$)/);
5959
if (distMatch && distMatch[1]) {
6060
disturl = distMatch[1];
61+
//web 与 dist 同级:libsurl 若是相对路径的 web/libs,随 disturl 一起校正
62+
if (libsurl && !/^https?:\/\//i.test(libsurl) && /(?:^|\/)web\/libs\/?$/.test(libsurl)) {
63+
libsurl = disturl.replace(/\/?dist\/?$/, '') + '/web/libs';
64+
}
6165
}
6266
var includes = (targetScript.getAttribute('include') || "").split(",");
6367
var excludes = (targetScript.getAttribute('exclude') || "").split(",");

dist/leaflet/include-leaflet.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@
5858
var distMatch = selfSrc.match(/^(.*?)\/?(?:leaflet\/)?include-leaflet\.js(?:[?#]|$)/);
5959
if (distMatch && distMatch[1]) {
6060
disturl = distMatch[1];
61+
//web 与 dist 同级:libsurl 若是相对路径的 web/libs,随 disturl 一起校正
62+
if (libsurl && !/^https?:\/\//i.test(libsurl) && /(?:^|\/)web\/libs\/?$/.test(libsurl)) {
63+
libsurl = disturl.replace(/\/?dist\/?$/, '') + '/web/libs';
64+
}
6165
}
6266
var includes = (targetScript.getAttribute('include') || '').split(',');
6367
var excludes = (targetScript.getAttribute('exclude') || '').split(',');
@@ -187,7 +191,7 @@
187191
}
188192

189193
load({
190-
libsurl: 'https://iclient.supermap.io/web/libs',
194+
libsurl: '../../web/libs',
191195
disturl: '../../dist'
192196
});
193197
window.isLocal = false;

dist/mapboxgl/include-mapboxgl.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@
5858
var distMatch = selfSrc.match(/^(.*?)\/?(?:mapboxgl\/)?include-mapboxgl\.js(?:[?#]|$)/);
5959
if (distMatch && distMatch[1]) {
6060
disturl = distMatch[1];
61+
//web 与 dist 同级:libsurl 若是相对路径的 web/libs,随 disturl 一起校正
62+
if (libsurl && !/^https?:\/\//i.test(libsurl) && /(?:^|\/)web\/libs\/?$/.test(libsurl)) {
63+
libsurl = disturl.replace(/\/?dist\/?$/, '') + '/web/libs';
64+
}
6165
}
6266
var includes = (targetScript.getAttribute('include') || '').split(',');
6367
var excludes = (targetScript.getAttribute('exclude') || '').split(',');

dist/maplibregl/include-maplibregl.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@
5858
var distMatch = selfSrc.match(/^(.*?)\/?(?:maplibregl\/)?include-maplibregl\.js(?:[?#]|$)/);
5959
if (distMatch && distMatch[1]) {
6060
disturl = distMatch[1];
61+
//web 与 dist 同级:libsurl 若是相对路径的 web/libs,随 disturl 一起校正
62+
if (libsurl && !/^https?:\/\//i.test(libsurl) && /(?:^|\/)web\/libs\/?$/.test(libsurl)) {
63+
libsurl = disturl.replace(/\/?dist\/?$/, '') + '/web/libs';
64+
}
6165
}
6266
var includes = (targetScript.getAttribute('include') || '').split(',');
6367
var excludes = (targetScript.getAttribute('exclude') || '').split(',');

dist/ol/include-ol.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@
5858
var distMatch = selfSrc.match(/^(.*?)\/?(?:ol\/)?include-ol\.js(?:[?#]|$)/);
5959
if (distMatch && distMatch[1]) {
6060
disturl = distMatch[1];
61+
//web 与 dist 同级:libsurl 若是相对路径的 web/libs,随 disturl 一起校正
62+
if (libsurl && !/^https?:\/\//i.test(libsurl) && /(?:^|\/)web\/libs\/?$/.test(libsurl)) {
63+
libsurl = disturl.replace(/\/?dist\/?$/, '') + '/web/libs';
64+
}
6165
}
6266
var includes = (targetScript.getAttribute('include') || '').split(',');
6367
var excludes = (targetScript.getAttribute('exclude') || '').split(',');

dist/openlayers/include-openlayers.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@
5858
var distMatch = selfSrc.match(/^(.*?)\/?(?:openlayers\/)?include-openlayers\.js(?:[?#]|$)/);
5959
if (distMatch && distMatch[1]) {
6060
disturl = distMatch[1];
61+
//web 与 dist 同级:libsurl 若是相对路径的 web/libs,随 disturl 一起校正
62+
if (libsurl && !/^https?:\/\//i.test(libsurl) && /(?:^|\/)web\/libs\/?$/.test(libsurl)) {
63+
libsurl = disturl.replace(/\/?dist\/?$/, '') + '/web/libs';
64+
}
6165
}
6266
var includes = (targetScript.getAttribute('include') || '').split(',');
6367
var excludes = (targetScript.getAttribute('exclude') || '').split(',');

examples/js/include-web.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@
7070
//加载类库资源文件
7171
function load(config) {
7272
var libsurl = config.libsurl;
73+
//web 在 examples 上一级:libsurl 若是相对路径的 web/libs,按 basePath 校正
74+
if (libsurl && !/^https?:\/\//i.test(libsurl) && /(?:^|\/)web\/libs\/?$/.test(libsurl)) {
75+
libsurl = basePath.replace(/\/?$/, '/../') + 'web/libs';
76+
}
77+
7378
var includes = (targetScript.getAttribute('include') || "").split(",");
7479
var excludes = (targetScript.getAttribute('exclude') || "").split(",");
7580
const resourceLanguage = getLanguage();

0 commit comments

Comments
 (0)