vue-openlayers-plugin 1.1.16 → 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 (30) hide show
  1. package/README.md +341 -0
  2. package/lib/{BasemapPanel-d1332546.mjs → BasemapPanel-d6e4ea88.mjs} +1 -1
  3. package/lib/{CoordinateLocationDialog-c2d89c1e.mjs → CoordinateLocationDialog-81d00abc.mjs} +1 -1
  4. package/lib/{MapPrintDialog-eea9e39e.mjs → FilterPanel-7358e3fb.mjs} +1 -1
  5. package/lib/{FilterPanel-d7cb1c79.mjs → LayerPanel-9bf28955.mjs} +1 -1
  6. package/lib/{LayerPanel-f411a32b.mjs → MapPrintDialog-64d46412.mjs} +1 -1
  7. package/lib/{MeasurementDialog-9914f4e9.mjs → MeasurementDialog-4e084192.mjs} +1 -1
  8. package/lib/{MyMarkersDialog-ef717e8c.mjs → MyMarkersDialog-aa44e5bd.mjs} +1 -1
  9. package/lib/{QuadCompareDialog-3d6eaf0c.mjs → QuadCompareDialog-84a88cf9.mjs} +1 -1
  10. package/lib/{RegionNavigationDialog-2843eedd.mjs → RegionNavigationDialog-467ad6c0.mjs} +1 -1
  11. package/lib/{SplitCompareDialog-1e678e69.mjs → SplitCompareDialog-50410c0b.mjs} +1 -1
  12. package/lib/{SwipeCompareDialog-547de7ee.mjs → SwipeCompareDialog-c322e2f6.mjs} +1 -1
  13. package/lib/{ViewBookmarksDialog-d3e38c53.mjs → ViewBookmarksDialog-83cf5ec4.mjs} +1 -1
  14. package/lib/{index-198a96d2.mjs → index-58704a25.mjs} +296 -30
  15. package/lib/{index-92020358.mjs → index-ee58f2f8.mjs} +1 -1
  16. package/lib/{index.es-dd926512.mjs → index.es-320e524d.mjs} +1 -1
  17. package/lib/index.esm.js +1 -1
  18. package/lib/index.umd.js +282 -16
  19. package/lib/style.css +13 -4
  20. package/package.json +1 -1
  21. package/types/components/OlMapSearch.vue.d.ts +20 -1
  22. package/types/components/OlMapSearch.vue.d.ts.map +1 -1
  23. package/types/core/tiandituSearchApi.d.ts.map +1 -1
  24. package/types/plugins/index.d.ts +90 -0
  25. package/types/plugins/index.d.ts.map +1 -0
  26. package/types/services/searchService.d.ts +21 -1
  27. package/types/services/searchService.d.ts.map +1 -1
  28. package/types/tsconfig.tsbuildinfo +1 -1
  29. package/types/types/map.d.ts +24 -0
  30. package/types/types/map.d.ts.map +1 -1
package/lib/index.umd.js CHANGED
@@ -335388,7 +335388,7 @@ ${indentData}`);
335388
335388
  const _hoisted_16$5 = { key: 1 };
335389
335389
  const _hoisted_17$5 = ["href"];
335390
335390
  const _hoisted_18$5 = { key: 2 };
335391
- const _hoisted_19$4 = { key: 3 };
335391
+ const _hoisted_19$5 = { key: 3 };
335392
335392
  const _hoisted_20$3 = { key: 4 };
335393
335393
  const _hoisted_21$2 = {
335394
335394
  key: 6,
@@ -335678,7 +335678,7 @@ ${indentData}`);
335678
335678
  target: "_blank",
335679
335679
  class: "table-link"
335680
335680
  }, vue.toDisplayString(getFieldValue(item, field.key || field.name)), 9, _hoisted_17$5)
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$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))
335682
335682
  ]);
335683
335683
  }), 128))
335684
335684
  ], 8, _hoisted_13$8);
@@ -338282,6 +338282,7 @@ ${indentData}`);
338282
338282
  * @param options 搜索选项
338283
338283
  */
338284
338284
  async search(query, options = {}) {
338285
+ var _a2;
338285
338286
  try {
338286
338287
  const {
338287
338288
  maxResults = 10,
@@ -338309,8 +338310,10 @@ ${indentData}`);
338309
338310
  throw new Error(`天地图API请求失败: ${response.status}`);
338310
338311
  }
338311
338312
  const data2 = await response.json();
338312
- if (data2.status !== "200" && data2.status !== "0") {
338313
- 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}`);
338314
338317
  }
338315
338318
  return this.transformResults(data2, type);
338316
338319
  } catch (error2) {
@@ -338477,6 +338480,20 @@ ${indentData}`);
338477
338480
  }
338478
338481
  }
338479
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
+ }
338480
338497
  class MapSearchService {
338481
338498
  constructor(config, deps) {
338482
338499
  __publicField(this, "config");
@@ -338530,7 +338547,7 @@ ${indentData}`);
338530
338547
  return results;
338531
338548
  } catch (error2) {
338532
338549
  console.error("搜索失败:", error2);
338533
- return [];
338550
+ throw this.createSearchError(query, error2);
338534
338551
  }
338535
338552
  }
338536
338553
  /**
@@ -338645,7 +338662,7 @@ ${indentData}`);
338645
338662
  async searchTianditu(query) {
338646
338663
  try {
338647
338664
  const results = await tiandituSearchApi.search(query, {
338648
- ...this.config,
338665
+ ...this.getTiandituSearchOptions(),
338649
338666
  maxResults: this.config.maxResults || 10,
338650
338667
  type: this.config.type || "all"
338651
338668
  });
@@ -338655,6 +338672,111 @@ ${indentData}`);
338655
338672
  throw error2;
338656
338673
  }
338657
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
+ }
338658
338780
  /**
338659
338781
  * 自定义API搜索
338660
338782
  */
@@ -338999,6 +339121,11 @@ ${indentData}`);
338999
339121
  showHistory: true,
339000
339122
  searchDelay: 300,
339001
339123
  minSearchLength: 2,
339124
+ messages: {
339125
+ historyTitle: "搜索历史",
339126
+ clearHistory: "清除",
339127
+ resultsTitle: "搜索结果"
339128
+ },
339002
339129
  resultStyle: {
339003
339130
  markerColor: "#409eff",
339004
339131
  markerSize: 20,
@@ -339008,6 +339135,7 @@ ${indentData}`);
339008
339135
  };
339009
339136
  const searchService = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
339010
339137
  __proto__: null,
339138
+ MapSearchError,
339011
339139
  MapSearchService,
339012
339140
  defaultSearchConfig
339013
339141
  }, Symbol.toStringTag, { value: "Module" }));
@@ -339044,6 +339172,10 @@ ${indentData}`);
339044
339172
  class: "item-confidence"
339045
339173
  };
339046
339174
  const _hoisted_18$4 = {
339175
+ key: 0,
339176
+ class: "search-error"
339177
+ };
339178
+ const _hoisted_19$4 = {
339047
339179
  key: 0,
339048
339180
  class: "no-results"
339049
339181
  };
@@ -339060,10 +339192,15 @@ ${indentData}`);
339060
339192
  enableStorage: false,
339061
339193
  // 默认禁用存储
339062
339194
  searchDelay: 300,
339063
- minSearchLength: 2
339195
+ minSearchLength: 2,
339196
+ messages: {
339197
+ historyTitle: "搜索历史",
339198
+ clearHistory: "清除",
339199
+ resultsTitle: "搜索结果"
339200
+ }
339064
339201
  }) }
339065
339202
  },
339066
- emits: ["search", "select", "clear"],
339203
+ emits: ["search", "select", "clear", "search-error"],
339067
339204
  setup(__props, { expose: __expose, emit: __emit }) {
339068
339205
  const props = __props;
339069
339206
  const emit = __emit;
@@ -339079,12 +339216,52 @@ ${indentData}`);
339079
339216
  const showResults = vue.ref(false);
339080
339217
  const selectedIndex = vue.ref(-1);
339081
339218
  const searchTimer = vue.ref(null);
339219
+ const searchErrorMessage = vue.ref("");
339220
+ const searchErrorCode = vue.ref("");
339082
339221
  const position2 = vue.computed(() => props.config.position || "top-left");
339083
339222
  const placeholder = vue.computed(() => props.config.placeholder || "搜索地点...");
339084
339223
  const maxResults = vue.computed(() => props.config.maxResults || 10);
339085
339224
  const showHistory = vue.computed(() => props.config.showHistory !== false);
339086
339225
  const searchDelay = vue.computed(() => props.config.searchDelay || 300);
339087
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
+ );
339088
339265
  const displayResults = vue.computed(() => {
339089
339266
  return searchResults.value.slice(0, maxResults.value);
339090
339267
  });
@@ -339098,15 +339275,65 @@ ${indentData}`);
339098
339275
  }
339099
339276
  return count2;
339100
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
+ };
339101
339324
  const handleSearchInput = (value) => {
339102
339325
  if (searchTimer.value) {
339103
339326
  clearTimeout(searchTimer.value);
339104
339327
  }
339105
339328
  if (value.length >= minSearchLength.value) {
339329
+ searchErrorMessage.value = "";
339330
+ searchErrorCode.value = "";
339106
339331
  searchTimer.value = setTimeout(() => {
339107
339332
  performSearch(value);
339108
339333
  }, searchDelay.value);
339109
339334
  } else {
339335
+ searchErrorMessage.value = "";
339336
+ searchErrorCode.value = "";
339110
339337
  searchResults.value = [];
339111
339338
  showResults.value = value.length === 0 && showHistory.value;
339112
339339
  }
@@ -339154,6 +339381,8 @@ ${indentData}`);
339154
339381
  selectedIndex.value = -1;
339155
339382
  searchQuery.value = "";
339156
339383
  searchResults.value = [];
339384
+ searchErrorMessage.value = "";
339385
+ searchErrorCode.value = "";
339157
339386
  };
339158
339387
  const getSelectableItems = () => {
339159
339388
  const items = [];
@@ -339166,11 +339395,14 @@ ${indentData}`);
339166
339395
  return items;
339167
339396
  };
339168
339397
  const performSearch = async (query) => {
339398
+ var _a2;
339169
339399
  if (!query || query.length < minSearchLength.value) {
339170
339400
  return;
339171
339401
  }
339172
339402
  isLoading.value = true;
339173
339403
  showResults.value = true;
339404
+ searchErrorMessage.value = "";
339405
+ searchErrorCode.value = "";
339174
339406
  try {
339175
339407
  const results = await searchService2.search(query);
339176
339408
  searchResults.value = results;
@@ -339178,6 +339410,19 @@ ${indentData}`);
339178
339410
  } catch (error2) {
339179
339411
  console.error("搜索失败:", error2);
339180
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);
339181
339426
  } finally {
339182
339427
  isLoading.value = false;
339183
339428
  }
@@ -339187,7 +339432,6 @@ ${indentData}`);
339187
339432
  showResults.value = false;
339188
339433
  selectedIndex.value = -1;
339189
339434
  addToHistory(result);
339190
- debugger;
339191
339435
  emit("select", result);
339192
339436
  };
339193
339437
  const selectHistoryItem = (item) => {
@@ -339250,12 +339494,16 @@ ${indentData}`);
339250
339494
  const updateResults = (results) => {
339251
339495
  searchResults.value = results;
339252
339496
  isLoading.value = false;
339497
+ searchErrorMessage.value = "";
339498
+ searchErrorCode.value = "";
339253
339499
  };
339254
339500
  const clearResults = () => {
339255
339501
  searchResults.value = [];
339256
339502
  searchQuery.value = "";
339257
339503
  showResults.value = false;
339258
339504
  selectedIndex.value = -1;
339505
+ searchErrorMessage.value = "";
339506
+ searchErrorCode.value = "";
339259
339507
  emit("clear");
339260
339508
  };
339261
339509
  vue.onMounted(() => {
@@ -339273,6 +339521,8 @@ ${indentData}`);
339273
339521
  (newConfig) => {
339274
339522
  searchService2.updateConfig(newConfig);
339275
339523
  searchResults.value = [];
339524
+ searchErrorMessage.value = "";
339525
+ searchErrorCode.value = "";
339276
339526
  selectedIndex.value = -1;
339277
339527
  console.log("MapSearch配置已更新:", newConfig);
339278
339528
  },
@@ -339367,15 +339617,15 @@ ${indentData}`);
339367
339617
  showHistory.value && searchHistory.value.length > 0 && !searchQuery.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3$v, [
339368
339618
  vue.renderSlot(_ctx.$slots, "history-title", { clearHistory }, () => [
339369
339619
  vue.createElementVNode("div", _hoisted_4$t, [
339370
- _cache[2] || (_cache[2] = vue.createElementVNode("span", null, "搜索历史", -1)),
339620
+ vue.createElementVNode("span", null, vue.toDisplayString(historyTitleText.value), 1),
339371
339621
  vue.createVNode(vue.unref(elementPlus.ElButton), {
339372
339622
  link: "",
339373
339623
  size: "small",
339374
339624
  onClick: clearHistory
339375
339625
  }, {
339376
- default: vue.withCtx(() => [..._cache[1] || (_cache[1] = [
339377
- vue.createTextVNode(" 清除 ", -1)
339378
- ])]),
339626
+ default: vue.withCtx(() => [
339627
+ vue.createTextVNode(vue.toDisplayString(clearHistoryText.value), 1)
339628
+ ]),
339379
339629
  _: 1
339380
339630
  })
339381
339631
  ])
@@ -339412,7 +339662,7 @@ ${indentData}`);
339412
339662
  resultsCount: searchResults.value.length
339413
339663
  }, () => [
339414
339664
  searchQuery.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_10$c, [
339415
- _cache[3] || (_cache[3] = vue.createElementVNode("span", null, "搜索结果", -1)),
339665
+ vue.createElementVNode("span", null, vue.toDisplayString(resultsTitleText.value), 1),
339416
339666
  vue.createElementVNode("span", _hoisted_11$a, "(" + vue.toDisplayString(searchResults.value.length) + ")", 1)
339417
339667
  ])) : vue.createCommentVNode("", true)
339418
339668
  ]),
@@ -339454,19 +339704,35 @@ ${indentData}`);
339454
339704
  ]);
339455
339705
  }), 128))
339456
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
+ ]),
339457
339723
  vue.renderSlot(_ctx.$slots, "no-results", {
339458
339724
  searchQuery: searchQuery.value,
339459
339725
  searchResults: searchResults.value,
339460
339726
  isLoading: isLoading.value
339461
339727
  }, () => [
339462
- 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, [
339463
339729
  vue.createVNode(vue.unref(elementPlus.ElIcon), null, {
339464
339730
  default: vue.withCtx(() => [
339465
339731
  vue.createVNode(vue.unref(iconsVue.InfoFilled))
339466
339732
  ]),
339467
339733
  _: 1
339468
339734
  }),
339469
- _cache[4] || (_cache[4] = vue.createElementVNode("span", null, "未找到相关结果", -1))
339735
+ vue.createElementVNode("span", null, vue.toDisplayString(noResultsText.value), 1)
339470
339736
  ])) : vue.createCommentVNode("", true)
339471
339737
  ])
339472
339738
  ])
package/lib/style.css CHANGED
@@ -779,6 +779,17 @@ to {
779
779
  .result-count {
780
780
  color: var(--el-text-color-placeholder);
781
781
  }
782
+ .search-error,
783
+ .no-results {
784
+ display: flex;
785
+ align-items: center;
786
+ gap: 8px;
787
+ }
788
+ .search-error {
789
+ padding: 16px;
790
+ color: var(--el-color-danger);
791
+ font-size: 14px;
792
+ }
782
793
  .search-item {
783
794
  display: flex;
784
795
  align-items: center;
@@ -845,15 +856,13 @@ to {
845
856
  flex-shrink: 0;
846
857
  }
847
858
  .no-results {
848
- display: flex;
849
- align-items: center;
850
859
  justify-content: center;
851
860
  padding: 24px 16px;
852
861
  color: var(--el-text-color-secondary);
853
862
  font-size: 14px;
854
863
  }
855
- .no-results .el-icon {
856
- margin-right: 8px;
864
+ .no-results .el-icon,
865
+ .search-error .el-icon {
857
866
  font-size: 16px;
858
867
  }
859
868
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-openlayers-plugin",
3
- "version": "1.1.16",
3
+ "version": "1.2.0",
4
4
  "description": "A Vue 3 plugin for OpenLayers with custom components and utilities",
5
5
  "main": "lib/index.umd.js",
6
6
  "module": "lib/index.esm.js",
@@ -1,4 +1,5 @@
1
- import { MapSearchConfig, SearchResult } from '../types';
1
+ import { MapSearchConfig, SearchResult, SearchErrorCode } from '../types';
2
+ import { MapSearchError } from '../services/searchService';
2
3
 
3
4
  interface Props {
4
5
  config: MapSearchConfig;
@@ -14,6 +15,11 @@ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<im
14
15
  enableStorage: boolean;
15
16
  searchDelay: number;
16
17
  minSearchLength: number;
18
+ messages: {
19
+ historyTitle: string;
20
+ clearHistory: string;
21
+ resultsTitle: string;
22
+ };
17
23
  };
18
24
  }>>, {
19
25
  updateResults: (results: SearchResult[]) => void;
@@ -23,6 +29,7 @@ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<im
23
29
  search: (query: string) => void;
24
30
  select: (result: SearchResult) => void;
25
31
  clear: () => void;
32
+ "search-error": (error: MapSearchError) => void;
26
33
  }, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {
27
34
  config: () => {
28
35
  enabled: boolean;
@@ -34,11 +41,17 @@ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<im
34
41
  enableStorage: boolean;
35
42
  searchDelay: number;
36
43
  minSearchLength: number;
44
+ messages: {
45
+ historyTitle: string;
46
+ clearHistory: string;
47
+ resultsTitle: string;
48
+ };
37
49
  };
38
50
  }>>> & Readonly<{
39
51
  onSearch?: (query: string) => any;
40
52
  onSelect?: (result: SearchResult) => any;
41
53
  onClear?: () => any;
54
+ "onSearch-error"?: (error: MapSearchError) => any;
42
55
  }>, {
43
56
  config: MapSearchConfig;
44
57
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>, {
@@ -161,6 +174,12 @@ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<im
161
174
  highlightText: (text: string, query: string) => string;
162
175
  searchQuery: string;
163
176
  }): any;
177
+ "search-error"?(_: {
178
+ searchQuery: string;
179
+ errorMessage: string;
180
+ errorCode: "" | SearchErrorCode;
181
+ isLoading: boolean;
182
+ }): any;
164
183
  "no-results"?(_: {
165
184
  searchQuery: string;
166
185
  searchResults: {
@@ -1 +1 @@
1
- {"version":3,"file":"OlMapSearch.vue.d.ts","sourceRoot":"","sources":["../../src/components/OlMapSearch.vue"],"names":[],"mappings":"AAmMA;AAWA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAK9D,UAAU,KAAK;IACb,MAAM,EAAE,eAAe,CAAC;CACzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2+BD,wBAAwG;AACxG,KAAK,sBAAsB,CAAC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