mrxy-yk 1.6.0-beta.7 → 1.6.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.
@@ -30,14 +30,14 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
30
30
  const mapKey = props.mapKey || AMapConfig.mapKey;
31
31
  const mapSecret = props.mapSecret || AMapConfig.mapSecret;
32
32
  watch(() => props.modelValue, (nv) => {
33
- if (nv && !aMapHook.value.map) {
33
+ if (nv && !aMapHook.map) {
34
34
  nextTick(() => {
35
35
  loadAMap();
36
36
  });
37
37
  } else {
38
38
  placeSearch.clear();
39
39
  showMarker(props.lnglat, props.address);
40
- emits("open", aMapHook.value.map);
40
+ emits("open", aMapHook.map);
41
41
  }
42
42
  });
43
43
  const changeDialogCustomer = computed({
@@ -74,8 +74,8 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
74
74
  }
75
75
  }, loadAMap);
76
76
  function loadAMap() {
77
- const AMap = aMapHook.value.AMap;
78
- const map = aMapHook.value.map;
77
+ const AMap = aMapHook.AMap;
78
+ const map = aMapHook.map;
79
79
  satelliteLayer = new AMap["TileLayer"].Satellite();
80
80
  map.on("click", clickHandler);
81
81
  autoComplete = new AMap["Autocomplete"]({ city: "全国" });
@@ -92,7 +92,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
92
92
  showMarker(lnglat, address);
93
93
  };
94
94
  onUnmounted(function() {
95
- const map = aMapHook.value.map;
95
+ const map = aMapHook.map;
96
96
  if (map) {
97
97
  map.off("click", clickHandler);
98
98
  map.destroy();
@@ -166,7 +166,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
166
166
  }
167
167
  let marker = null;
168
168
  function showMarker(lnglat, address) {
169
- const { map, AMap } = aMapHook.value;
169
+ const { map, AMap } = aMapHook;
170
170
  if (lnglat) {
171
171
  const position = lnglat.split(",");
172
172
  if (marker) {
@@ -186,7 +186,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
186
186
  let satelliteLayer = null;
187
187
  const isSatelliteLayer = ref(false);
188
188
  function setSatelliteLayer() {
189
- const { map } = aMapHook.value;
189
+ const { map } = aMapHook;
190
190
  if (isSatelliteLayer.value) {
191
191
  map.add(satelliteLayer);
192
192
  } else {
@@ -1,6 +1,6 @@
1
1
  import { AMapClassProxy, LoaderOptions, UseAMapHookExample, UseAMapHookOptions } from './type';
2
2
  import { AMap } from './@type/index';
3
- import { TemplateRef, ShallowRef } from 'vue';
3
+ import { ShallowRef, TemplateRef } from 'vue';
4
4
  export * from './utils';
5
5
  export declare function useAMapLoader(options?: LoaderOptions): Promise<AMap>;
6
6
  /**
@@ -41,4 +41,4 @@ export declare function newAMapInfoWindow(options: ConstructorParameters<typeof
41
41
  * @param options
42
42
  * @param callback
43
43
  */
44
- export declare function useAMapClassicHook(options: UseAMapHookOptions, callback?: (res: ShallowRef<UseAMapHookExample>) => void): ShallowRef<UseAMapHookExample>;
44
+ export declare function useAMapClassicHook(options: UseAMapHookOptions, callback?: (res: UseAMapHookExample) => void): UseAMapHookExample;
@@ -1,6 +1,6 @@
1
1
  import AMapLoader from "@amap/amap-jsapi-loader";
2
2
  import { AMapConfig } from "../../config/index.js";
3
- import { shallowRef, onMounted, useTemplateRef, onBeforeUnmount, toValue } from "vue";
3
+ import { onMounted, shallowRef, useTemplateRef, onBeforeUnmount, toValue } from "vue";
4
4
  async function useAMapLoader(options) {
5
5
  const o = options || {};
6
6
  const win = window;
@@ -64,7 +64,7 @@ function newAMapInfoWindow(options, AMap) {
64
64
  }
65
65
  function useAMapClassicHook(options, callback) {
66
66
  const o = options;
67
- const retRes = shallowRef({});
67
+ const retRes = {};
68
68
  let map = null;
69
69
  onMounted(async () => {
70
70
  const mapPlugins = /* @__PURE__ */ new Set(["AMap.MarkerCluster", ...o?.plugins || [], ...o?.loaderOptions?.plugins || []]);
@@ -72,7 +72,7 @@ function useAMapClassicHook(options, callback) {
72
72
  ...o?.loaderOptions,
73
73
  plugins: [...mapPlugins]
74
74
  });
75
- retRes.value.AMap = AMap;
75
+ retRes.AMap = AMap;
76
76
  let elRef = shallowRef();
77
77
  if (typeof o.el === "string") {
78
78
  elRef = useTemplateRef(o.el);
@@ -85,8 +85,9 @@ function useAMapClassicHook(options, callback) {
85
85
  mapStyle: o.mapStyle,
86
86
  opts: mapOptions
87
87
  }, AMap);
88
+ retRes.map = map;
88
89
  const markerClusterOptions = typeof o?.markerClusterOpts === "function" ? o.markerClusterOpts() : o.markerClusterOpts;
89
- const markerCluster = newAMapMarkerCluster({
90
+ retRes.markerCluster = newAMapMarkerCluster({
90
91
  map,
91
92
  markerClusterOptions: {
92
93
  renderMarker: o.renderMarker,
@@ -103,18 +104,12 @@ function useAMapClassicHook(options, callback) {
103
104
  }
104
105
  }
105
106
  const infoWindowOptions = typeof o?.infoWindowOpts === "function" ? o.infoWindowOpts() : o.infoWindowOpts;
106
- const infoWindow = newAMapInfoWindow({
107
+ retRes.infoWindow = newAMapInfoWindow({
107
108
  isCustom: true,
108
109
  closeWhenClickMap: true,
109
110
  content: infoRef.value,
110
111
  ...infoWindowOptions
111
112
  }, AMap);
112
- retRes.value = {
113
- map,
114
- markerCluster,
115
- infoWindow,
116
- AMap
117
- };
118
113
  callback?.(retRes);
119
114
  });
120
115
  onBeforeUnmount(() => {
@@ -20,8 +20,9 @@ class FnPeriodically {
20
20
  // Vue中在onBeforeUnmount事件中销毁
21
21
  isUnmountStop = false;
22
22
  constructor(option) {
23
- Object.assign(this, option);
24
- if (option.run === true) this.state = 1;
23
+ const { run, ...rest } = option;
24
+ Object.assign(this, rest);
25
+ if (run === true) this.state = 1;
25
26
  if (this.state === 1) this.run(this.immediate, this.arg);
26
27
  if (this.isUnmountStop) {
27
28
  onBeforeUnmount(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mrxy-yk",
3
- "version": "1.6.0-beta.7",
3
+ "version": "1.6.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "A collection of Vue 3 components and utilities",