@neatui/nuxt 1.0.8 → 1.1.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neatui/nuxt",
3
- "version": "1.0.8",
3
+ "version": "1.1.0",
4
4
  "description": "NeatUI component library for Nuxt 3",
5
5
  "main": "./src/index.ts",
6
6
  "license": "MIT",
@@ -103,8 +103,10 @@
103
103
 
104
104
  const ph = ref(0);
105
105
  onMounted(() => {
106
- const side = document.getElementById('side-layerloader');
107
- ph.value = side?.clientHeight || 0;
106
+ if (import.meta.client) {
107
+ const side = document.getElementById('side-layerloader');
108
+ ph.value = side?.clientHeight || 0;
109
+ }
108
110
  });
109
111
 
110
112
  // 计算路径
@@ -131,18 +133,20 @@
131
133
  unfoldActivePath(props.data, newActive);
132
134
 
133
135
  nextTick(() => {
134
- const el = document.getElementById(`LID${newActive.replace(/\./g, '')}`);
135
- if (el && !store.isMouseInLayer) {
136
- scrollto({
137
- el: '#side-layerloader',
138
- to: {
139
- y: el,
140
- },
141
- offset: {
142
- y: -(ph.value / 2.5),
143
- },
144
- time: 600,
145
- });
136
+ if (import.meta.client) {
137
+ const el = document.getElementById(`LID${newActive.replace(/\./g, '')}`);
138
+ if (el && !store.isMouseInLayer) {
139
+ scrollto({
140
+ el: '#side-layerloader',
141
+ to: {
142
+ y: el,
143
+ },
144
+ offset: {
145
+ y: -(ph.value / 2.5),
146
+ },
147
+ time: 600,
148
+ });
149
+ }
146
150
  }
147
151
  });
148
152
  },
@@ -108,7 +108,7 @@
108
108
  watch(
109
109
  () => props.limit,
110
110
  () => {
111
- const _cache = JSON.parse(localStorage.getItem(`${state.name}_limit`) || '{}');
111
+ const _cache = import.meta.client ? JSON.parse(localStorage.getItem(`${state.name}_limit`) || '{}') : {};
112
112
  state.limit = deepcopy(props.limit)?.map((item: any) => {
113
113
  if (_cache[item.field] && Object.prototype.hasOwnProperty.call(_cache[item.field], '_close')) {
114
114
  item._close = Number(_cache[item.field]?._close);
@@ -159,7 +159,7 @@
159
159
  }
160
160
  }
161
161
  });
162
- localStorage.setItem(`${state.name}_limit`, JSON.stringify(_limit));
162
+ if (import.meta.client) localStorage.setItem(`${state.name}_limit`, JSON.stringify(_limit));
163
163
  },
164
164
  { deep: true },
165
165
  );
@@ -70,8 +70,10 @@
70
70
 
71
71
  const ph = ref(0);
72
72
  onMounted(() => {
73
- const side = document.getElementById('side-layerloader');
74
- ph.value = side?.clientHeight || 0;
73
+ if (import.meta.client) {
74
+ const side = document.getElementById('side-layerloader');
75
+ ph.value = side?.clientHeight || 0;
76
+ }
75
77
  });
76
78
 
77
79
  // 计算路径
@@ -264,7 +264,7 @@
264
264
  watch(
265
265
  () => props.table,
266
266
  () => {
267
- const _cache = JSON.parse(localStorage.getItem(`${name}_table`) || '{}');
267
+ const _cache = import.meta.client ? JSON.parse(localStorage.getItem(`${name}_table`) || '{}') : {};
268
268
  state.__last = 0;
269
269
  state.table = deepcopy(props.table || [])
270
270
  ?.map((col: TableColumn, idx: number) => {
@@ -340,7 +340,7 @@
340
340
  state.__last = idx;
341
341
  }
342
342
  });
343
- localStorage.setItem(`${name}_table`, JSON.stringify(_table));
343
+ if (import.meta.client) localStorage.setItem(`${name}_table`, JSON.stringify(_table));
344
344
  },
345
345
  { deep: true },
346
346
  );
@@ -38,7 +38,7 @@
38
38
  const props: any = defineProps({
39
39
  area: {
40
40
  type: [Object, HTMLElement],
41
- default: () => (typeof document !== 'undefined' ? document.body : null),
41
+ default: () => (import.meta.client ? document.body : null),
42
42
  },
43
43
  data: {
44
44
  type: Object,
@@ -128,7 +128,7 @@
128
128
  );
129
129
 
130
130
  const fScrollToField = (path: any) => {
131
- if (typeof document === 'undefined') return;
131
+ if (!import.meta.client) return;
132
132
  const dom = document.querySelector(path);
133
133
  if (dom) {
134
134
  scrollTo({
@@ -210,12 +210,14 @@
210
210
  const size = (size: any) => {
211
211
  emits('update:modelValue', { ...props.modelValue, ...{ [props.defined.pageSize || 'pageSize']: size } });
212
212
  emits('size', size);
213
- window.localStorage.setItem(state.id, `${size}`);
213
+ if (import.meta.client) window.localStorage.setItem(state.id, `${size}`);
214
214
  };
215
215
 
216
216
  // 缓存
217
- const cache = window.localStorage.getItem(state.id);
218
- if (cache) {
219
- size(Number(cache));
217
+ if (import.meta.client) {
218
+ const cache = window.localStorage.getItem(state.id);
219
+ if (cache) {
220
+ size(Number(cache));
221
+ }
220
222
  }
221
223
  </script>
@@ -216,6 +216,6 @@
216
216
  const size = (size: any) => {
217
217
  emits('update:modelValue', { ...props.modelValue, ...{ pageSize: size } });
218
218
  emits('size', size);
219
- window.localStorage.setItem(state.id, `${size}`);
219
+ if (import.meta.client) window.localStorage.setItem(state.id, `${size}`);
220
220
  };
221
221
  </script>