@neatui/nuxt 1.0.3 → 1.0.5

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.3",
3
+ "version": "1.0.5",
4
4
  "description": "NeatUI component library for Nuxt 3",
5
5
  "main": "./src/index.ts",
6
6
  "license": "MIT",
@@ -43,6 +43,8 @@
43
43
  import scrollTo from '@fekit/scrollto';
44
44
  import { diff, deepcopy, isArray } from '@fekit/utils';
45
45
 
46
+ const isClient = typeof window !== 'undefined';
47
+
46
48
  // 通过枚举值查找枚举名
47
49
  const findEnumName = (enums: any, val: any, join: boolean | string = ' Ι ') => {
48
50
  // 转换核心
@@ -69,8 +71,8 @@
69
71
  const route: any = useRoute();
70
72
  const props: any = defineProps({
71
73
  area: {
72
- type: HTMLElement,
73
- default: document.body
74
+ type: Object,
75
+ default: () => isClient ? document.body : null
74
76
  },
75
77
  // 数据
76
78
  data: {
@@ -101,7 +103,7 @@
101
103
  // 对比数据
102
104
  diffs: computed(() => {
103
105
  const cloud = props.data || {};
104
- const local = JSON.parse(localStorage.getItem(state.cacheKey) || '{}');
106
+ const local = isClient ? JSON.parse(localStorage.getItem(state.cacheKey) || '{}') : {};
105
107
 
106
108
  const diffs = Object.keys(local).length
107
109
  ? (diff(cloud, local) || []).map((item: any) => {
@@ -162,6 +164,8 @@
162
164
 
163
165
  // 定位字段
164
166
  const fScrollToField = (domId: any) => {
167
+ if (!isClient || !props.area) return;
168
+
165
169
  const dom = document.querySelector(domId);
166
170
  if (dom) {
167
171
  scrollTo({
@@ -182,6 +186,8 @@
182
186
 
183
187
  // 使用草稿
184
188
  const fConfirmDrafts = ({ field = '', path = [] }: any = {}) => {
189
+ if (!isClient) return;
190
+
185
191
  const local = JSON.parse(localStorage.getItem(state.cacheKey) || '{}');
186
192
  if (field) {
187
193
  state.field = field;
@@ -221,6 +227,8 @@
221
227
  };
222
228
  // 放弃草稿
223
229
  const fDiscardDrafts = ({ field = '', path = [] }: any = {}) => {
230
+ if (!isClient) return;
231
+
224
232
  const local = JSON.parse(localStorage.getItem(state.cacheKey) || '{}');
225
233
  if (field) {
226
234
  // 无限树型遍历
@@ -312,6 +320,8 @@
312
320
  watch(
313
321
  () => props.data,
314
322
  (edit: any, old: any) => {
323
+ if (!isClient) return;
324
+
315
325
  if (edit === old) {
316
326
  if (state.field) {
317
327
  const local = JSON.parse(localStorage.getItem(state.cacheKey) || '{}');