@neatui/nuxt 1.0.3 → 1.0.6

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.6",
4
4
  "description": "NeatUI component library for Nuxt 3",
5
5
  "main": "./src/index.ts",
6
6
  "license": "MIT",
@@ -69,8 +69,8 @@
69
69
  const route: any = useRoute();
70
70
  const props: any = defineProps({
71
71
  area: {
72
- type: HTMLElement,
73
- default: document.body
72
+ type: Object,
73
+ default: () => import.meta.client ? document.body : null
74
74
  },
75
75
  // 数据
76
76
  data: {
@@ -101,7 +101,7 @@
101
101
  // 对比数据
102
102
  diffs: computed(() => {
103
103
  const cloud = props.data || {};
104
- const local = JSON.parse(localStorage.getItem(state.cacheKey) || '{}');
104
+ const local = import.meta.client ? JSON.parse(localStorage.getItem(state.cacheKey) || '{}') : {};
105
105
 
106
106
  const diffs = Object.keys(local).length
107
107
  ? (diff(cloud, local) || []).map((item: any) => {
@@ -162,6 +162,8 @@
162
162
 
163
163
  // 定位字段
164
164
  const fScrollToField = (domId: any) => {
165
+ if (!import.meta.client || !props.area) return;
166
+
165
167
  const dom = document.querySelector(domId);
166
168
  if (dom) {
167
169
  scrollTo({
@@ -182,6 +184,8 @@
182
184
 
183
185
  // 使用草稿
184
186
  const fConfirmDrafts = ({ field = '', path = [] }: any = {}) => {
187
+ if (!import.meta.client) return;
188
+
185
189
  const local = JSON.parse(localStorage.getItem(state.cacheKey) || '{}');
186
190
  if (field) {
187
191
  state.field = field;
@@ -221,6 +225,8 @@
221
225
  };
222
226
  // 放弃草稿
223
227
  const fDiscardDrafts = ({ field = '', path = [] }: any = {}) => {
228
+ if (!import.meta.client) return;
229
+
224
230
  const local = JSON.parse(localStorage.getItem(state.cacheKey) || '{}');
225
231
  if (field) {
226
232
  // 无限树型遍历
@@ -312,6 +318,8 @@
312
318
  watch(
313
319
  () => props.data,
314
320
  (edit: any, old: any) => {
321
+ if (!import.meta.client) return;
322
+
315
323
  if (edit === old) {
316
324
  if (state.field) {
317
325
  const local = JSON.parse(localStorage.getItem(state.cacheKey) || '{}');