@neatui/nuxt 1.5.0 → 1.5.2

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.5.0",
3
+ "version": "1.5.2",
4
4
  "description": "NeatUI component library for Nuxt 3",
5
5
  "main": "./src/index.ts",
6
6
  "license": "MIT",
@@ -19,11 +19,16 @@
19
19
  import { onBeforeUnmount, reactive, watch } from 'vue';
20
20
  import { isFunction } from '@fekit/utils';
21
21
 
22
- // 弹层队列
23
- if (!(window as any)._FEKIT_LAYER_TASKS) {
24
- (window as any)._FEKIT_LAYER_TASKS = {};
25
- }
26
- const _tasks: any = (window as any)._FEKIT_LAYER_TASKS;
22
+ // 弹层队列 - 兼容服务端渲染
23
+ const _tasks: any = (() => {
24
+ if (typeof window === 'undefined') {
25
+ return {}; // 服务端渲染时返回空对象
26
+ }
27
+ if (!(window as any)._FEKIT_LAYER_TASKS) {
28
+ (window as any)._FEKIT_LAYER_TASKS = {};
29
+ }
30
+ return (window as any)._FEKIT_LAYER_TASKS;
31
+ })();
27
32
 
28
33
  // 获取活跃的弹层
29
34
  const getActiveLayer = () => {
@@ -73,6 +78,7 @@
73
78
  });
74
79
 
75
80
  function disableScroll() {
81
+ if (typeof window === 'undefined') return;
76
82
  state.top = document.documentElement.scrollTop;
77
83
  const sw = window.innerWidth - document.documentElement.clientWidth;
78
84
  state.sw = sw;
@@ -84,6 +90,7 @@
84
90
  }
85
91
 
86
92
  function enableScroll() {
93
+ if (typeof window === 'undefined') return;
87
94
  document.body.style.removeProperty('overflow');
88
95
  document.body.style.removeProperty('position');
89
96
  document.body.style.removeProperty('top');
@@ -1,5 +1,6 @@
1
1
  import Layer from './Layer.vue';
2
2
  const LayerById = (id: any) => {
3
- return (window as any)._FEKIT_LAYER_TASKS[id];
3
+ const win: any = typeof window !== 'undefined' ? window : {};
4
+ return win._FEKIT_LAYER_TASKS?.[id];
4
5
  };
5
6
  export { Layer, LayerById };
@@ -1,5 +1,4 @@
1
- import Layer from './LayerView/Layer.vue';
2
- import { LayerById } from './LayerView/index';
1
+ import { Layer, LayerById } from './LayerView';
3
2
  import Icon from './Icon.vue';
4
3
  import IFollowView from './IFollowView.vue';
5
4
  import IPickerView from './IPickerView.vue';