vue-openlayers-plugin 1.1.15 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +302 -170
  2. package/lib/{BasemapPanel-7664fc20.mjs → BasemapPanel-d6e4ea88.mjs} +1 -1
  3. package/lib/{CoordinateLocationDialog-f505c006.mjs → CoordinateLocationDialog-81d00abc.mjs} +1 -1
  4. package/lib/{MapPrintDialog-0cf04cae.mjs → FilterPanel-7358e3fb.mjs} +1 -1
  5. package/lib/{FilterPanel-4cfbbfeb.mjs → LayerPanel-9bf28955.mjs} +1 -1
  6. package/lib/{LayerPanel-354b6ac7.mjs → MapPrintDialog-64d46412.mjs} +1 -1
  7. package/lib/{MeasurementDialog-4fd11413.mjs → MeasurementDialog-4e084192.mjs} +1 -1
  8. package/lib/{MyMarkersDialog-f413337c.mjs → MyMarkersDialog-aa44e5bd.mjs} +1 -1
  9. package/lib/{QuadCompareDialog-176a8178.mjs → QuadCompareDialog-84a88cf9.mjs} +1 -1
  10. package/lib/{RegionNavigationDialog-1edd078f.mjs → RegionNavigationDialog-467ad6c0.mjs} +1 -1
  11. package/lib/{SplitCompareDialog-3fe419de.mjs → SplitCompareDialog-50410c0b.mjs} +1 -1
  12. package/lib/{SwipeCompareDialog-e2c28122.mjs → SwipeCompareDialog-c322e2f6.mjs} +1 -1
  13. package/lib/{ViewBookmarksDialog-9873fb3c.mjs → ViewBookmarksDialog-83cf5ec4.mjs} +1 -1
  14. package/lib/{index-923f7253.mjs → index-58704a25.mjs} +400 -152
  15. package/lib/{index-a30f4100.mjs → index-ee58f2f8.mjs} +1 -1
  16. package/lib/{index.es-b7728855.mjs → index.es-320e524d.mjs} +1 -1
  17. package/lib/index.esm.js +1 -1
  18. package/lib/index.umd.js +386 -138
  19. package/lib/style.css +13 -4
  20. package/package.json +106 -106
  21. package/types/components/OlDialogs/LayerPanel.vue.d.ts +102 -0
  22. package/types/components/OlDialogs/LayerPanel.vue.d.ts.map +1 -1
  23. package/types/components/OlMap.vue.d.ts +204 -0
  24. package/types/components/OlMap.vue.d.ts.map +1 -1
  25. package/types/components/OlMapSearch.vue.d.ts +20 -1
  26. package/types/components/OlMapSearch.vue.d.ts.map +1 -1
  27. package/types/core/LayerManager.d.ts +5 -5
  28. package/types/core/LayerManager.d.ts.map +1 -1
  29. package/types/core/layers/GeoJSONLayerHandler.d.ts +3 -4
  30. package/types/core/layers/GeoJSONLayerHandler.d.ts.map +1 -1
  31. package/types/core/layers/interfaces.d.ts +1 -1
  32. package/types/core/layers/interfaces.d.ts.map +1 -1
  33. package/types/core/storage.d.ts.map +1 -1
  34. package/types/core/tiandituSearchApi.d.ts.map +1 -1
  35. package/types/lowcode-entry.d.ts +204 -0
  36. package/types/lowcode-entry.d.ts.map +1 -1
  37. package/types/plugins/index.d.ts +90 -0
  38. package/types/plugins/index.d.ts.map +1 -0
  39. package/types/services/searchService.d.ts +21 -1
  40. package/types/services/searchService.d.ts.map +1 -1
  41. package/types/tsconfig.tsbuildinfo +1 -1
  42. package/types/types/map.d.ts +29 -1
  43. package/types/types/map.d.ts.map +1 -1
package/lib/index.umd.js CHANGED
@@ -53759,33 +53759,10 @@ ${this.attributes_.map(
53759
53759
  };
53760
53760
  if (config.url)
53761
53761
  optimizedConfig.url = config.url;
53762
- if (config.method)
53763
- optimizedConfig.method = config.method;
53764
- if (config.params && Object.keys(config.params).length > 0) {
53765
- optimizedConfig.params = config.params;
53766
- }
53767
- if (config.headers && Object.keys(config.headers).length > 0) {
53768
- optimizedConfig.headers = config.headers;
53769
- }
53770
- if (config.body !== void 0)
53771
- optimizedConfig.body = config.body;
53772
- if (config.dataPath)
53773
- optimizedConfig.dataPath = config.dataPath;
53774
53762
  if (config.opacity !== void 0 && config.opacity !== 1)
53775
53763
  optimizedConfig.opacity = config.opacity;
53776
53764
  if (config.zIndex !== void 0 && config.zIndex !== 0)
53777
53765
  optimizedConfig.zIndex = config.zIndex;
53778
- if (config.geojsonConfig)
53779
- optimizedConfig.geojsonConfig = config.geojsonConfig;
53780
- if (config.config)
53781
- optimizedConfig.config = config.config;
53782
- if (config.projection)
53783
- optimizedConfig.projection = config.projection;
53784
- if (config.projectionDefinition) {
53785
- optimizedConfig.projectionDefinition = config.projectionDefinition;
53786
- }
53787
- if (config.style)
53788
- optimizedConfig.style = config.style;
53789
53766
  if (config.legend)
53790
53767
  optimizedConfig.legend = config.legend;
53791
53768
  if (config.metadata && Object.keys(config.metadata).length > 0) {
@@ -68327,6 +68304,7 @@ ${this.attributes_.map(
68327
68304
  __publicField(this, "vectorSource", null);
68328
68305
  __publicField(this, "refreshTimer", null);
68329
68306
  __publicField(this, "refreshDebounceTimer", null);
68307
+ __publicField(this, "initialRefreshTimer", null);
68330
68308
  __publicField(this, "moveEndListener", null);
68331
68309
  __publicField(this, "lastKnownZoom");
68332
68310
  __publicField(this, "isRefreshing", false);
@@ -68348,9 +68326,6 @@ ${this.attributes_.map(
68348
68326
  this.setupRefreshBehavior();
68349
68327
  return vectorLayer;
68350
68328
  }
68351
- /**
68352
- * 创建矢量数据源
68353
- */
68354
68329
  createVectorSource() {
68355
68330
  this.registerCustomProjection();
68356
68331
  return new VectorSource$1();
@@ -68381,14 +68356,13 @@ ${this.attributes_.map(
68381
68356
  const normalizedParams = {
68382
68357
  ...requestConfig.params || {}
68383
68358
  };
68384
- const layerConfig = this.config;
68385
68359
  const landTypeParamName = requestConfig.landTypeParamName || "landType";
68386
- const landTypeValue = requestConfig.landType ?? layerConfig.geojsonLandType ?? normalizedParams[landTypeParamName] ?? normalizedParams.landType;
68360
+ const landTypeValue = requestConfig.landType ?? this.config.geojsonLandType ?? normalizedParams[landTypeParamName] ?? normalizedParams.landType;
68387
68361
  if (landTypeValue !== void 0 && normalizedParams[landTypeParamName] === void 0) {
68388
68362
  normalizedParams[landTypeParamName] = landTypeValue;
68389
68363
  }
68390
68364
  const managementUnitParamName = requestConfig.managementUnitParamName || "managementUnit";
68391
- const managementUnitValue = requestConfig.managementUnit ?? layerConfig.managementUnit ?? ((_a2 = this.config.metadata) == null ? void 0 : _a2.managementUnit) ?? normalizedParams[managementUnitParamName] ?? normalizedParams.managementUnit;
68365
+ const managementUnitValue = requestConfig.managementUnit ?? this.config.managementUnit ?? ((_a2 = this.config.metadata) == null ? void 0 : _a2.managementUnit) ?? normalizedParams[managementUnitParamName] ?? normalizedParams.managementUnit;
68392
68366
  if (managementUnitValue !== void 0 && normalizedParams[managementUnitParamName] === void 0) {
68393
68367
  normalizedParams[managementUnitParamName] = managementUnitValue;
68394
68368
  }
@@ -68407,20 +68381,30 @@ ${this.attributes_.map(
68407
68381
  async initializeSource() {
68408
68382
  var _a2;
68409
68383
  const source = this.getVectorSource();
68410
- if (!source)
68384
+ if (!source) {
68411
68385
  return;
68386
+ }
68412
68387
  const geojsonConfig = this.getGeoJSONConfig();
68413
68388
  if (geojsonConfig.data) {
68414
68389
  this.applyGeoJSONData(geojsonConfig.data);
68415
68390
  return;
68416
68391
  }
68417
68392
  if (((_a2 = geojsonConfig.request) == null ? void 0 : _a2.url) || this.config.url) {
68418
- await this.refresh();
68393
+ this.scheduleInitialRefresh();
68419
68394
  return;
68420
68395
  }
68421
68396
  source.clear();
68422
68397
  this.originalFeatures = [];
68423
68398
  }
68399
+ scheduleInitialRefresh() {
68400
+ if (this.initialRefreshTimer) {
68401
+ clearTimeout(this.initialRefreshTimer);
68402
+ }
68403
+ this.initialRefreshTimer = setTimeout(() => {
68404
+ this.initialRefreshTimer = null;
68405
+ void this.refresh();
68406
+ }, 0);
68407
+ }
68424
68408
  getVectorSource() {
68425
68409
  if (this.vectorSource) {
68426
68410
  return this.vectorSource;
@@ -68434,8 +68418,9 @@ ${this.attributes_.map(
68434
68418
  }
68435
68419
  applyGeoJSONData(data2) {
68436
68420
  const source = this.getVectorSource();
68437
- if (!source)
68421
+ if (!source) {
68438
68422
  return;
68423
+ }
68439
68424
  const features2 = this.readFeaturesFromData(data2);
68440
68425
  source.clear();
68441
68426
  source.addFeatures(features2);
@@ -68459,7 +68444,7 @@ ${this.attributes_.map(
68459
68444
  }
68460
68445
  try {
68461
68446
  return this.normalizeGeoJSONData(JSON.parse(trimmed));
68462
- } catch (error2) {
68447
+ } catch {
68463
68448
  throw new Error("GeoJSON 字符串解析失败");
68464
68449
  }
68465
68450
  }
@@ -68543,15 +68528,17 @@ ${this.attributes_.map(
68543
68528
  };
68544
68529
  }
68545
68530
  createRequestUrl(url, params, method2) {
68546
- const requestUrl = new URL(url, window.location.origin);
68531
+ var _a2;
68532
+ const baseOrigin = typeof window !== "undefined" && ((_a2 = window.location) == null ? void 0 : _a2.origin) ? window.location.origin : "http://localhost";
68533
+ const requestUrl = new URL(url, baseOrigin);
68547
68534
  Object.entries(params).forEach(([key2, value]) => {
68548
68535
  if (value === void 0 || value === null || method2 !== "GET") {
68549
68536
  return;
68550
68537
  }
68551
68538
  if (Array.isArray(value)) {
68552
- value.forEach(
68553
- (item) => requestUrl.searchParams.append(key2, String(item))
68554
- );
68539
+ value.forEach((item) => {
68540
+ requestUrl.searchParams.append(key2, String(item));
68541
+ });
68555
68542
  return;
68556
68543
  }
68557
68544
  requestUrl.searchParams.set(key2, String(value));
@@ -68561,6 +68548,8 @@ ${this.attributes_.map(
68561
68548
  async refresh(overrides) {
68562
68549
  const geojsonConfig = this.getGeoJSONConfig();
68563
68550
  const requestConfig = geojsonConfig.request;
68551
+ let requestUrl = "";
68552
+ let requestMethod = (requestConfig == null ? void 0 : requestConfig.method) || "GET";
68564
68553
  if (!(requestConfig == null ? void 0 : requestConfig.url)) {
68565
68554
  if (geojsonConfig.data) {
68566
68555
  this.applyGeoJSONData(geojsonConfig.data);
@@ -68573,12 +68562,13 @@ ${this.attributes_.map(
68573
68562
  this.isRefreshing = true;
68574
68563
  try {
68575
68564
  const refreshPayload = this.buildExtentPayload(geojsonConfig.refresh);
68565
+ const currentRequestBody = (overrides == null ? void 0 : overrides.body) ?? requestConfig.body;
68576
68566
  const context = this.buildRequestContext({
68577
68567
  params: {
68578
68568
  ...refreshPayload.params || {},
68579
68569
  ...(overrides == null ? void 0 : overrides.params) || {}
68580
68570
  },
68581
- body: typeof refreshPayload.body === "object" && !Array.isArray(refreshPayload.body) && typeof ((overrides == null ? void 0 : overrides.body) || requestConfig.body) === "object" && !Array.isArray((overrides == null ? void 0 : overrides.body) || requestConfig.body) ? {
68571
+ body: typeof refreshPayload.body === "object" && !Array.isArray(refreshPayload.body) && typeof currentRequestBody === "object" && !Array.isArray(currentRequestBody) ? {
68582
68572
  ...requestConfig.body,
68583
68573
  ...refreshPayload.body,
68584
68574
  ...overrides == null ? void 0 : overrides.body
@@ -68609,17 +68599,19 @@ ${this.attributes_.map(
68609
68599
  }
68610
68600
  };
68611
68601
  }
68612
- const requestUrl = this.createRequestUrl(
68602
+ requestMethod = request.method;
68603
+ requestUrl = this.createRequestUrl(
68613
68604
  request.url,
68614
68605
  request.params,
68615
68606
  request.method
68616
68607
  );
68608
+ const requestHeaders = request.method === "GET" ? { ...request.headers } : {
68609
+ "Content-Type": "application/json;charset=UTF-8",
68610
+ ...request.headers
68611
+ };
68617
68612
  const response = await fetch(requestUrl, {
68618
68613
  method: request.method,
68619
- headers: {
68620
- "Content-Type": request.method === "GET" ? void 0 : "application/json;charset=UTF-8",
68621
- ...request.headers
68622
- },
68614
+ headers: requestHeaders,
68623
68615
  body: request.method === "GET" || request.body === void 0 ? void 0 : typeof request.body === "string" ? request.body : JSON.stringify(request.body)
68624
68616
  });
68625
68617
  if (!response.ok) {
@@ -68656,7 +68648,10 @@ ${this.attributes_.map(
68656
68648
  source == null ? void 0 : source.clear();
68657
68649
  this.originalFeatures = [];
68658
68650
  }
68659
- throw error2;
68651
+ const errorMessage = error2 instanceof Error ? error2.message : String(error2);
68652
+ throw new Error(
68653
+ `GeoJSON 请求失败 [${this.config.id}] ${requestMethod} ${requestUrl || requestConfig.url}: ${errorMessage}`
68654
+ );
68660
68655
  } finally {
68661
68656
  this.isRefreshing = false;
68662
68657
  }
@@ -69414,6 +69409,10 @@ ${this.attributes_.map(
69414
69409
  }
69415
69410
  destroy() {
69416
69411
  this.clearRefreshBehavior();
69412
+ if (this.initialRefreshTimer) {
69413
+ clearTimeout(this.initialRefreshTimer);
69414
+ this.initialRefreshTimer = null;
69415
+ }
69417
69416
  this.vectorSource = null;
69418
69417
  super.destroy();
69419
69418
  }
@@ -334173,72 +334172,6 @@ ${indentData}`);
334173
334172
  getLayerHandler(layerId) {
334174
334173
  return this.layerHandlers.get(layerId);
334175
334174
  }
334176
- async refreshLayer(layerId, options) {
334177
- try {
334178
- const config = this.getLayerConfig(layerId);
334179
- if (!config) {
334180
- return false;
334181
- }
334182
- if (!this.layerHandlers.has(layerId) && config.visible) {
334183
- const loaded = await this.loadLayerOnDemand(layerId);
334184
- if (!loaded) {
334185
- return false;
334186
- }
334187
- }
334188
- const handler = this.layerHandlers.get(layerId);
334189
- if (!(handler == null ? void 0 : handler.refresh)) {
334190
- return false;
334191
- }
334192
- await handler.refresh(options);
334193
- return true;
334194
- } catch (error2) {
334195
- console.error("刷新图层失败:", error2);
334196
- return false;
334197
- }
334198
- }
334199
- updateLayerRequestParams(layerId, params) {
334200
- var _a2, _b2, _c2, _d, _e2, _f, _g, _h, _i2, _j, _k, _l, _m;
334201
- try {
334202
- const config = this.getLayerConfig(layerId);
334203
- if (!config) {
334204
- return false;
334205
- }
334206
- const nextConfig = {
334207
- ...config,
334208
- params: {
334209
- ...config.params || {},
334210
- ...params
334211
- },
334212
- geojsonConfig: {
334213
- ...config.geojsonConfig || ((_b2 = (_a2 = config.config) == null ? void 0 : _a2.vector) == null ? void 0 : _b2.geojson) || ((_c2 = config.config) == null ? void 0 : _c2.geojson) || {},
334214
- request: {
334215
- ...((_g = config.geojsonConfig || ((_e2 = (_d = config.config) == null ? void 0 : _d.vector) == null ? void 0 : _e2.geojson) || ((_f = config.config) == null ? void 0 : _f.geojson)) == null ? void 0 : _g.request) || {},
334216
- params: {
334217
- ...((_l = (_k = config.geojsonConfig || ((_i2 = (_h = config.config) == null ? void 0 : _h.vector) == null ? void 0 : _i2.geojson) || ((_j = config.config) == null ? void 0 : _j.geojson)) == null ? void 0 : _k.request) == null ? void 0 : _l.params) || {},
334218
- ...params
334219
- }
334220
- }
334221
- }
334222
- };
334223
- if (this.layerConfigs.has(layerId)) {
334224
- this.layerConfigs.set(layerId, nextConfig);
334225
- }
334226
- if (this.pendingLayerConfigs.has(layerId)) {
334227
- this.pendingLayerConfigs.set(layerId, nextConfig);
334228
- }
334229
- const handler = this.layerHandlers.get(layerId);
334230
- (_m = handler == null ? void 0 : handler.updateRequestParams) == null ? void 0 : _m.call(handler, params);
334231
- this.saveLayerConfigs();
334232
- this.eventBus.emit("layer-config-updated", {
334233
- layerId,
334234
- config: nextConfig
334235
- });
334236
- return true;
334237
- } catch (error2) {
334238
- console.error("更新图层请求参数失败:", error2);
334239
- return false;
334240
- }
334241
- }
334242
334175
  /**
334243
334176
  * 设置底图图层ID列表(用于底图互斥判断)
334244
334177
  */
@@ -334556,25 +334489,74 @@ ${indentData}`);
334556
334489
  }
334557
334490
  return void 0;
334558
334491
  }
334492
+ async refreshLayer(layerId, options) {
334493
+ try {
334494
+ const handler = this.layerHandlers.get(layerId);
334495
+ if (!handler || typeof handler.refresh !== "function") {
334496
+ return false;
334497
+ }
334498
+ await handler.refresh(options);
334499
+ return true;
334500
+ } catch (error2) {
334501
+ console.error("刷新图层失败:", error2);
334502
+ return false;
334503
+ }
334504
+ }
334505
+ updateLayerRequestParams(layerId, params) {
334506
+ var _a2, _b2, _c2, _d, _e2, _f, _g, _h, _i2, _j, _k, _l, _m, _n2, _o2, _p, _q, _r2, _s;
334507
+ try {
334508
+ const config = this.getLayerConfig(layerId);
334509
+ if (!config) {
334510
+ return false;
334511
+ }
334512
+ const nextConfig = {
334513
+ ...config,
334514
+ params: {
334515
+ ...config.params || {},
334516
+ ...params
334517
+ },
334518
+ geojsonConfig: {
334519
+ ...config.geojsonConfig || ((_b2 = (_a2 = config.config) == null ? void 0 : _a2.vector) == null ? void 0 : _b2.geojson) || ((_c2 = config.config) == null ? void 0 : _c2.geojson) || {},
334520
+ request: {
334521
+ ...((_d = config.geojsonConfig) == null ? void 0 : _d.request) || ((_g = (_f = (_e2 = config.config) == null ? void 0 : _e2.vector) == null ? void 0 : _f.geojson) == null ? void 0 : _g.request) || ((_i2 = (_h = config.config) == null ? void 0 : _h.geojson) == null ? void 0 : _i2.request) || {},
334522
+ params: {
334523
+ ...((_k = (_j = config.geojsonConfig) == null ? void 0 : _j.request) == null ? void 0 : _k.params) || ((_o2 = (_n2 = (_m = (_l = config.config) == null ? void 0 : _l.vector) == null ? void 0 : _m.geojson) == null ? void 0 : _n2.request) == null ? void 0 : _o2.params) || ((_r2 = (_q = (_p = config.config) == null ? void 0 : _p.geojson) == null ? void 0 : _q.request) == null ? void 0 : _r2.params) || {},
334524
+ ...params
334525
+ }
334526
+ }
334527
+ }
334528
+ };
334529
+ if (this.layerConfigs.has(layerId)) {
334530
+ this.layerConfigs.set(layerId, nextConfig);
334531
+ }
334532
+ if (this.pendingLayerConfigs.has(layerId)) {
334533
+ this.pendingLayerConfigs.set(layerId, nextConfig);
334534
+ }
334535
+ const handler = this.layerHandlers.get(layerId);
334536
+ (_s = handler == null ? void 0 : handler.updateRequestParams) == null ? void 0 : _s.call(handler, params);
334537
+ this.saveLayerConfigs();
334538
+ this.eventBus.emit("layer-config-updated", {
334539
+ layerId,
334540
+ config: nextConfig
334541
+ });
334542
+ return true;
334543
+ } catch (error2) {
334544
+ console.error("更新图层请求参数失败:", error2);
334545
+ return false;
334546
+ }
334547
+ }
334559
334548
  /**
334560
334549
  * 更新图层配置
334561
334550
  */
334562
334551
  updateLayerConfig(layerId, newConfig) {
334563
334552
  try {
334564
334553
  const handler = this.layerHandlers.get(layerId);
334565
- const config = this.layerConfigs.get(layerId) || this.pendingLayerConfigs.get(layerId);
334566
- if (config) {
334554
+ const config = this.layerConfigs.get(layerId);
334555
+ if (handler && config) {
334567
334556
  const updatedConfig = { ...config, ...newConfig };
334568
- if (this.layerConfigs.has(layerId)) {
334569
- this.layerConfigs.set(layerId, updatedConfig);
334570
- }
334571
- if (this.pendingLayerConfigs.has(layerId)) {
334572
- this.pendingLayerConfigs.set(layerId, updatedConfig);
334573
- }
334574
- if (handler) {
334575
- handler.updateConfig(newConfig);
334576
- }
334577
- if (handler && (newConfig.style || newConfig.customCss !== void 0)) {
334557
+ this.layerConfigs.set(layerId, updatedConfig);
334558
+ handler.updateConfig(newConfig);
334559
+ if (newConfig.style || newConfig.customCss !== void 0) {
334578
334560
  if ("updateLayerStyles" in handler) {
334579
334561
  handler.updateLayerStyles(
334580
334562
  updatedConfig.style,
@@ -335406,7 +335388,7 @@ ${indentData}`);
335406
335388
  const _hoisted_16$5 = { key: 1 };
335407
335389
  const _hoisted_17$5 = ["href"];
335408
335390
  const _hoisted_18$5 = { key: 2 };
335409
- const _hoisted_19$4 = { key: 3 };
335391
+ const _hoisted_19$5 = { key: 3 };
335410
335392
  const _hoisted_20$3 = { key: 4 };
335411
335393
  const _hoisted_21$2 = {
335412
335394
  key: 6,
@@ -335696,7 +335678,7 @@ ${indentData}`);
335696
335678
  target: "_blank",
335697
335679
  class: "table-link"
335698
335680
  }, vue.toDisplayString(getFieldValue(item, field.key || field.name)), 9, _hoisted_17$5)
335699
- ])) : field.type === "date" ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_18$5, vue.toDisplayString(formatDate(getFieldValue(item, field.key || field.name))), 1)) : field.type === "number" ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_19$4, vue.toDisplayString(formatNumber2(getFieldValue(item, field.key || field.name))), 1)) : (vue.openBlock(), vue.createElementBlock("span", _hoisted_20$3, vue.toDisplayString(getFieldValue(item, field.key || field.name)), 1))
335681
+ ])) : field.type === "date" ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_18$5, vue.toDisplayString(formatDate(getFieldValue(item, field.key || field.name))), 1)) : field.type === "number" ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_19$5, vue.toDisplayString(formatNumber2(getFieldValue(item, field.key || field.name))), 1)) : (vue.openBlock(), vue.createElementBlock("span", _hoisted_20$3, vue.toDisplayString(getFieldValue(item, field.key || field.name)), 1))
335700
335682
  ]);
335701
335683
  }), 128))
335702
335684
  ], 8, _hoisted_13$8);
@@ -338300,6 +338282,7 @@ ${indentData}`);
338300
338282
  * @param options 搜索选项
338301
338283
  */
338302
338284
  async search(query, options = {}) {
338285
+ var _a2;
338303
338286
  try {
338304
338287
  const {
338305
338288
  maxResults = 10,
@@ -338327,8 +338310,10 @@ ${indentData}`);
338327
338310
  throw new Error(`天地图API请求失败: ${response.status}`);
338328
338311
  }
338329
338312
  const data2 = await response.json();
338330
- if (data2.status !== "200" && data2.status !== "0") {
338331
- throw new Error(`天地图API返回错误: ${data2.status}`);
338313
+ const isSuccess = data2.status === "200" || data2.status === "0" || typeof data2.status === "object" && ((_a2 = data2.status) == null ? void 0 : _a2.infocode) === 1e3;
338314
+ if (!isSuccess) {
338315
+ const errorMessage = typeof data2.status === "object" ? `${data2.status.cndesc || "未知错误"} (${data2.status.infocode ?? "unknown"})` : data2.status;
338316
+ throw new Error(`天地图API返回错误: ${errorMessage}`);
338332
338317
  }
338333
338318
  return this.transformResults(data2, type);
338334
338319
  } catch (error2) {
@@ -338495,6 +338480,20 @@ ${indentData}`);
338495
338480
  }
338496
338481
  }
338497
338482
  const tiandituSearchApi = new TiandituSearchApi();
338483
+ class MapSearchError extends Error {
338484
+ constructor(options) {
338485
+ super(options.message);
338486
+ __publicField(this, "code");
338487
+ __publicField(this, "userMessage");
338488
+ __publicField(this, "provider");
338489
+ __publicField(this, "cause");
338490
+ this.name = "MapSearchError";
338491
+ this.code = options.code;
338492
+ this.userMessage = options.userMessage;
338493
+ this.provider = options.provider;
338494
+ this.cause = options.cause;
338495
+ }
338496
+ }
338498
338497
  class MapSearchService {
338499
338498
  constructor(config, deps) {
338500
338499
  __publicField(this, "config");
@@ -338548,7 +338547,7 @@ ${indentData}`);
338548
338547
  return results;
338549
338548
  } catch (error2) {
338550
338549
  console.error("搜索失败:", error2);
338551
- return [];
338550
+ throw this.createSearchError(query, error2);
338552
338551
  }
338553
338552
  }
338554
338553
  /**
@@ -338663,7 +338662,7 @@ ${indentData}`);
338663
338662
  async searchTianditu(query) {
338664
338663
  try {
338665
338664
  const results = await tiandituSearchApi.search(query, {
338666
- ...this.config,
338665
+ ...this.getTiandituSearchOptions(),
338667
338666
  maxResults: this.config.maxResults || 10,
338668
338667
  type: this.config.type || "all"
338669
338668
  });
@@ -338673,6 +338672,111 @@ ${indentData}`);
338673
338672
  throw error2;
338674
338673
  }
338675
338674
  }
338675
+ getTiandituSearchOptions() {
338676
+ const {
338677
+ enabled: _enabled,
338678
+ position: _position,
338679
+ placeholder: _placeholder,
338680
+ provider: _provider,
338681
+ apiKey: _apiKey,
338682
+ customApi: _customApi,
338683
+ layerSearch: _layerSearch,
338684
+ maxResults: _maxResults,
338685
+ showHistory: _showHistory,
338686
+ enableStorage: _enableStorage,
338687
+ searchDelay: _searchDelay,
338688
+ minSearchLength: _minSearchLength,
338689
+ messages: _messages,
338690
+ resultStyle: _resultStyle,
338691
+ onSearch: _onSearch,
338692
+ onSelect: _onSelect,
338693
+ customSearchFn: _customSearchFn,
338694
+ ...tiandituOptions
338695
+ } = this.config;
338696
+ return tiandituOptions;
338697
+ }
338698
+ createSearchError(query, error2) {
338699
+ var _a2;
338700
+ if (error2 instanceof MapSearchError) {
338701
+ return error2;
338702
+ }
338703
+ const provider = this.getResolvedProvider();
338704
+ const code = this.inferSearchErrorCode(error2);
338705
+ const technicalMessage = error2 instanceof Error ? error2.message : "搜索服务发生未知错误";
338706
+ const userMessage = this.resolveMessage((_a2 = this.config.messages) == null ? void 0 : _a2.searchFailed, {
338707
+ query,
338708
+ provider,
338709
+ error: error2,
338710
+ code
338711
+ }) || this.getDefaultSearchFailedMessage(provider, code);
338712
+ return new MapSearchError({
338713
+ code,
338714
+ message: technicalMessage,
338715
+ userMessage,
338716
+ provider,
338717
+ cause: error2
338718
+ });
338719
+ }
338720
+ inferSearchErrorCode(error2) {
338721
+ if (error2 instanceof MapSearchError) {
338722
+ return error2.code;
338723
+ }
338724
+ if (error2 instanceof TypeError) {
338725
+ return "network_error";
338726
+ }
338727
+ if (!(error2 instanceof Error)) {
338728
+ return "unknown_error";
338729
+ }
338730
+ const message = error2.message.toLowerCase();
338731
+ if (message.includes("未配置") || message.includes("not configured")) {
338732
+ return "config_error";
338733
+ }
338734
+ if (message.includes("failed to fetch") || message.includes("networkerror") || message.includes("网络")) {
338735
+ return "network_error";
338736
+ }
338737
+ if (message.includes("http error") || message.includes("请求失败") || /^http\s\d+/.test(message)) {
338738
+ return "http_error";
338739
+ }
338740
+ if (message.includes("api错误") || message.includes("返回错误") || message.includes("业务错误")) {
338741
+ return "api_error";
338742
+ }
338743
+ return "unknown_error";
338744
+ }
338745
+ getResolvedProvider() {
338746
+ return this.config.provider || "tianditu";
338747
+ }
338748
+ getDefaultSearchFailedMessage(provider, code) {
338749
+ const providerLabel = this.getProviderLabel(provider);
338750
+ switch (code) {
338751
+ case "config_error":
338752
+ return `${providerLabel}未完成配置,请联系管理员`;
338753
+ case "http_error":
338754
+ return `${providerLabel}服务连接失败,请稍后重试`;
338755
+ case "api_error":
338756
+ return `${providerLabel}返回业务错误,请调整关键词后重试`;
338757
+ case "network_error":
338758
+ return `网络连接异常,无法访问${providerLabel}`;
338759
+ default:
338760
+ return `${providerLabel}搜索暂不可用,请稍后重试`;
338761
+ }
338762
+ }
338763
+ getProviderLabel(provider) {
338764
+ const labelMap = {
338765
+ baidu: "百度地图搜索服务",
338766
+ amap: "高德地图搜索服务",
338767
+ google: "Google 地图搜索服务",
338768
+ tianditu: "天地图搜索服务",
338769
+ custom: "自定义搜索服务",
338770
+ layer: "图层搜索服务"
338771
+ };
338772
+ return labelMap[provider];
338773
+ }
338774
+ resolveMessage(resolver, context) {
338775
+ if (!resolver) {
338776
+ return void 0;
338777
+ }
338778
+ return typeof resolver === "function" ? resolver(context) : resolver;
338779
+ }
338676
338780
  /**
338677
338781
  * 自定义API搜索
338678
338782
  */
@@ -339017,6 +339121,11 @@ ${indentData}`);
339017
339121
  showHistory: true,
339018
339122
  searchDelay: 300,
339019
339123
  minSearchLength: 2,
339124
+ messages: {
339125
+ historyTitle: "搜索历史",
339126
+ clearHistory: "清除",
339127
+ resultsTitle: "搜索结果"
339128
+ },
339020
339129
  resultStyle: {
339021
339130
  markerColor: "#409eff",
339022
339131
  markerSize: 20,
@@ -339026,6 +339135,7 @@ ${indentData}`);
339026
339135
  };
339027
339136
  const searchService = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
339028
339137
  __proto__: null,
339138
+ MapSearchError,
339029
339139
  MapSearchService,
339030
339140
  defaultSearchConfig
339031
339141
  }, Symbol.toStringTag, { value: "Module" }));
@@ -339062,6 +339172,10 @@ ${indentData}`);
339062
339172
  class: "item-confidence"
339063
339173
  };
339064
339174
  const _hoisted_18$4 = {
339175
+ key: 0,
339176
+ class: "search-error"
339177
+ };
339178
+ const _hoisted_19$4 = {
339065
339179
  key: 0,
339066
339180
  class: "no-results"
339067
339181
  };
@@ -339078,10 +339192,15 @@ ${indentData}`);
339078
339192
  enableStorage: false,
339079
339193
  // 默认禁用存储
339080
339194
  searchDelay: 300,
339081
- minSearchLength: 2
339195
+ minSearchLength: 2,
339196
+ messages: {
339197
+ historyTitle: "搜索历史",
339198
+ clearHistory: "清除",
339199
+ resultsTitle: "搜索结果"
339200
+ }
339082
339201
  }) }
339083
339202
  },
339084
- emits: ["search", "select", "clear"],
339203
+ emits: ["search", "select", "clear", "search-error"],
339085
339204
  setup(__props, { expose: __expose, emit: __emit }) {
339086
339205
  const props = __props;
339087
339206
  const emit = __emit;
@@ -339097,12 +339216,52 @@ ${indentData}`);
339097
339216
  const showResults = vue.ref(false);
339098
339217
  const selectedIndex = vue.ref(-1);
339099
339218
  const searchTimer = vue.ref(null);
339219
+ const searchErrorMessage = vue.ref("");
339220
+ const searchErrorCode = vue.ref("");
339100
339221
  const position2 = vue.computed(() => props.config.position || "top-left");
339101
339222
  const placeholder = vue.computed(() => props.config.placeholder || "搜索地点...");
339102
339223
  const maxResults = vue.computed(() => props.config.maxResults || 10);
339103
339224
  const showHistory = vue.computed(() => props.config.showHistory !== false);
339104
339225
  const searchDelay = vue.computed(() => props.config.searchDelay || 300);
339105
339226
  const minSearchLength = vue.computed(() => props.config.minSearchLength || 2);
339227
+ const historyTitleText = vue.computed(
339228
+ () => {
339229
+ var _a2;
339230
+ return resolveMessage((_a2 = props.config.messages) == null ? void 0 : _a2.historyTitle, {}, "搜索历史");
339231
+ }
339232
+ );
339233
+ const clearHistoryText = vue.computed(
339234
+ () => {
339235
+ var _a2;
339236
+ return resolveMessage((_a2 = props.config.messages) == null ? void 0 : _a2.clearHistory, {}, "清除");
339237
+ }
339238
+ );
339239
+ const resultsTitleText = vue.computed(
339240
+ () => {
339241
+ var _a2;
339242
+ return resolveMessage(
339243
+ (_a2 = props.config.messages) == null ? void 0 : _a2.resultsTitle,
339244
+ {
339245
+ query: searchQuery.value,
339246
+ count: searchResults.value.length
339247
+ },
339248
+ "搜索结果"
339249
+ );
339250
+ }
339251
+ );
339252
+ const noResultsText = vue.computed(
339253
+ () => {
339254
+ var _a2;
339255
+ return resolveMessage(
339256
+ (_a2 = props.config.messages) == null ? void 0 : _a2.noResults,
339257
+ {
339258
+ query: searchQuery.value,
339259
+ provider: props.config.provider
339260
+ },
339261
+ getDefaultNoResultsMessage(props.config.provider || "tianditu")
339262
+ );
339263
+ }
339264
+ );
339106
339265
  const displayResults = vue.computed(() => {
339107
339266
  return searchResults.value.slice(0, maxResults.value);
339108
339267
  });
@@ -339116,15 +339275,65 @@ ${indentData}`);
339116
339275
  }
339117
339276
  return count2;
339118
339277
  });
339278
+ const resolveMessage = (resolver, context, fallback) => {
339279
+ if (!resolver) {
339280
+ return fallback;
339281
+ }
339282
+ return typeof resolver === "function" ? resolver(context) : resolver;
339283
+ };
339284
+ const getProviderLabel = (provider) => {
339285
+ const labelMap = {
339286
+ baidu: "百度地图",
339287
+ amap: "高德地图",
339288
+ google: "Google 地图",
339289
+ tianditu: "天地图",
339290
+ custom: "自定义搜索服务",
339291
+ layer: "图层搜索"
339292
+ };
339293
+ return labelMap[provider];
339294
+ };
339295
+ const getDefaultNoResultsMessage = (provider) => {
339296
+ switch (provider) {
339297
+ case "baidu":
339298
+ return "百度地图未找到相关地点,请尝试更换关键词";
339299
+ case "amap":
339300
+ return "高德地图未找到相关地点,请尝试更换关键词";
339301
+ case "google":
339302
+ return "Google 地图未找到相关地点,请尝试更换关键词";
339303
+ case "custom":
339304
+ return "自定义搜索服务未返回结果";
339305
+ case "layer":
339306
+ return "当前图层中未找到匹配结果";
339307
+ default:
339308
+ return "天地图未找到相关地点,请尝试补充行政区或 POI 名称";
339309
+ }
339310
+ };
339311
+ const normalizeSearchError = (error2) => {
339312
+ if (error2 instanceof MapSearchError) {
339313
+ return error2;
339314
+ }
339315
+ const provider = props.config.provider || "tianditu";
339316
+ return new MapSearchError({
339317
+ code: "unknown_error",
339318
+ message: error2 instanceof Error ? error2.message : "搜索服务发生未知错误",
339319
+ userMessage: `${getProviderLabel(provider)}搜索暂不可用,请稍后重试`,
339320
+ provider,
339321
+ cause: error2
339322
+ });
339323
+ };
339119
339324
  const handleSearchInput = (value) => {
339120
339325
  if (searchTimer.value) {
339121
339326
  clearTimeout(searchTimer.value);
339122
339327
  }
339123
339328
  if (value.length >= minSearchLength.value) {
339329
+ searchErrorMessage.value = "";
339330
+ searchErrorCode.value = "";
339124
339331
  searchTimer.value = setTimeout(() => {
339125
339332
  performSearch(value);
339126
339333
  }, searchDelay.value);
339127
339334
  } else {
339335
+ searchErrorMessage.value = "";
339336
+ searchErrorCode.value = "";
339128
339337
  searchResults.value = [];
339129
339338
  showResults.value = value.length === 0 && showHistory.value;
339130
339339
  }
@@ -339172,6 +339381,8 @@ ${indentData}`);
339172
339381
  selectedIndex.value = -1;
339173
339382
  searchQuery.value = "";
339174
339383
  searchResults.value = [];
339384
+ searchErrorMessage.value = "";
339385
+ searchErrorCode.value = "";
339175
339386
  };
339176
339387
  const getSelectableItems = () => {
339177
339388
  const items = [];
@@ -339184,11 +339395,14 @@ ${indentData}`);
339184
339395
  return items;
339185
339396
  };
339186
339397
  const performSearch = async (query) => {
339398
+ var _a2;
339187
339399
  if (!query || query.length < minSearchLength.value) {
339188
339400
  return;
339189
339401
  }
339190
339402
  isLoading.value = true;
339191
339403
  showResults.value = true;
339404
+ searchErrorMessage.value = "";
339405
+ searchErrorCode.value = "";
339192
339406
  try {
339193
339407
  const results = await searchService2.search(query);
339194
339408
  searchResults.value = results;
@@ -339196,6 +339410,19 @@ ${indentData}`);
339196
339410
  } catch (error2) {
339197
339411
  console.error("搜索失败:", error2);
339198
339412
  searchResults.value = [];
339413
+ const normalizedError = normalizeSearchError(error2);
339414
+ searchErrorCode.value = normalizedError.code;
339415
+ searchErrorMessage.value = error2 instanceof MapSearchError ? normalizedError.userMessage : resolveMessage(
339416
+ (_a2 = props.config.messages) == null ? void 0 : _a2.searchFailed,
339417
+ {
339418
+ query,
339419
+ provider: normalizedError.provider,
339420
+ error: error2,
339421
+ code: normalizedError.code
339422
+ },
339423
+ normalizedError.userMessage
339424
+ );
339425
+ emit("search-error", normalizedError);
339199
339426
  } finally {
339200
339427
  isLoading.value = false;
339201
339428
  }
@@ -339205,7 +339432,6 @@ ${indentData}`);
339205
339432
  showResults.value = false;
339206
339433
  selectedIndex.value = -1;
339207
339434
  addToHistory(result);
339208
- debugger;
339209
339435
  emit("select", result);
339210
339436
  };
339211
339437
  const selectHistoryItem = (item) => {
@@ -339268,12 +339494,16 @@ ${indentData}`);
339268
339494
  const updateResults = (results) => {
339269
339495
  searchResults.value = results;
339270
339496
  isLoading.value = false;
339497
+ searchErrorMessage.value = "";
339498
+ searchErrorCode.value = "";
339271
339499
  };
339272
339500
  const clearResults = () => {
339273
339501
  searchResults.value = [];
339274
339502
  searchQuery.value = "";
339275
339503
  showResults.value = false;
339276
339504
  selectedIndex.value = -1;
339505
+ searchErrorMessage.value = "";
339506
+ searchErrorCode.value = "";
339277
339507
  emit("clear");
339278
339508
  };
339279
339509
  vue.onMounted(() => {
@@ -339291,6 +339521,8 @@ ${indentData}`);
339291
339521
  (newConfig) => {
339292
339522
  searchService2.updateConfig(newConfig);
339293
339523
  searchResults.value = [];
339524
+ searchErrorMessage.value = "";
339525
+ searchErrorCode.value = "";
339294
339526
  selectedIndex.value = -1;
339295
339527
  console.log("MapSearch配置已更新:", newConfig);
339296
339528
  },
@@ -339385,15 +339617,15 @@ ${indentData}`);
339385
339617
  showHistory.value && searchHistory.value.length > 0 && !searchQuery.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3$v, [
339386
339618
  vue.renderSlot(_ctx.$slots, "history-title", { clearHistory }, () => [
339387
339619
  vue.createElementVNode("div", _hoisted_4$t, [
339388
- _cache[2] || (_cache[2] = vue.createElementVNode("span", null, "搜索历史", -1)),
339620
+ vue.createElementVNode("span", null, vue.toDisplayString(historyTitleText.value), 1),
339389
339621
  vue.createVNode(vue.unref(elementPlus.ElButton), {
339390
339622
  link: "",
339391
339623
  size: "small",
339392
339624
  onClick: clearHistory
339393
339625
  }, {
339394
- default: vue.withCtx(() => [..._cache[1] || (_cache[1] = [
339395
- vue.createTextVNode(" 清除 ", -1)
339396
- ])]),
339626
+ default: vue.withCtx(() => [
339627
+ vue.createTextVNode(vue.toDisplayString(clearHistoryText.value), 1)
339628
+ ]),
339397
339629
  _: 1
339398
339630
  })
339399
339631
  ])
@@ -339430,7 +339662,7 @@ ${indentData}`);
339430
339662
  resultsCount: searchResults.value.length
339431
339663
  }, () => [
339432
339664
  searchQuery.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_10$c, [
339433
- _cache[3] || (_cache[3] = vue.createElementVNode("span", null, "搜索结果", -1)),
339665
+ vue.createElementVNode("span", null, vue.toDisplayString(resultsTitleText.value), 1),
339434
339666
  vue.createElementVNode("span", _hoisted_11$a, "(" + vue.toDisplayString(searchResults.value.length) + ")", 1)
339435
339667
  ])) : vue.createCommentVNode("", true)
339436
339668
  ]),
@@ -339472,19 +339704,35 @@ ${indentData}`);
339472
339704
  ]);
339473
339705
  }), 128))
339474
339706
  ])) : vue.createCommentVNode("", true),
339707
+ vue.renderSlot(_ctx.$slots, "search-error", {
339708
+ searchQuery: searchQuery.value,
339709
+ errorMessage: searchErrorMessage.value,
339710
+ errorCode: searchErrorCode.value,
339711
+ isLoading: isLoading.value
339712
+ }, () => [
339713
+ searchErrorMessage.value && !isLoading.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_18$4, [
339714
+ vue.createVNode(vue.unref(elementPlus.ElIcon), null, {
339715
+ default: vue.withCtx(() => [
339716
+ vue.createVNode(vue.unref(iconsVue.InfoFilled))
339717
+ ]),
339718
+ _: 1
339719
+ }),
339720
+ vue.createElementVNode("span", null, vue.toDisplayString(searchErrorMessage.value), 1)
339721
+ ])) : vue.createCommentVNode("", true)
339722
+ ]),
339475
339723
  vue.renderSlot(_ctx.$slots, "no-results", {
339476
339724
  searchQuery: searchQuery.value,
339477
339725
  searchResults: searchResults.value,
339478
339726
  isLoading: isLoading.value
339479
339727
  }, () => [
339480
- searchQuery.value && searchResults.value.length === 0 && !isLoading.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_18$4, [
339728
+ searchQuery.value && searchResults.value.length === 0 && !isLoading.value && !searchErrorMessage.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_19$4, [
339481
339729
  vue.createVNode(vue.unref(elementPlus.ElIcon), null, {
339482
339730
  default: vue.withCtx(() => [
339483
339731
  vue.createVNode(vue.unref(iconsVue.InfoFilled))
339484
339732
  ]),
339485
339733
  _: 1
339486
339734
  }),
339487
- _cache[4] || (_cache[4] = vue.createElementVNode("span", null, "未找到相关结果", -1))
339735
+ vue.createElementVNode("span", null, vue.toDisplayString(noResultsText.value), 1)
339488
339736
  ])) : vue.createCommentVNode("", true)
339489
339737
  ])
339490
339738
  ])