diff --git a/apps/web-antd/src/main.ts b/apps/web-antd/src/main.ts index d15a01ab..5f5acf3a 100644 --- a/apps/web-antd/src/main.ts +++ b/apps/web-antd/src/main.ts @@ -23,7 +23,7 @@ async function initApplication() { await bootstrap(namespace); // 移除并销毁loading - destoryAppLoading(); + destroyAppLoading(); } /** @@ -31,23 +31,28 @@ async function initApplication() { * 放在这里是而不是放在 index.html 的app标签内,主要是因为这样比较不会生硬,渲染过快可能会有闪烁 * 通过先添加css动画隐藏,在动画结束后在移除loading节点来改善体验 */ -function destoryAppLoading() { - // 全局搜索文件 loading.html, 找到对应的节点 +function destroyAppLoading() { + // 查找全局 loading 元素 const loadingElement = document.querySelector('#__app-loading__'); + if (loadingElement) { + // 添加隐藏类,触发过渡动画 loadingElement.classList.add('hidden'); + + // 查找所有需要移除的注入 loading 元素 const injectLoadingElements = document.querySelectorAll( '[data-app-loading^="inject"]', ); - // 过渡动画结束后移除loading节点 + + // 当过渡动画结束时,移除 loading 元素和所有注入的 loading 元素 loadingElement.addEventListener( 'transitionend', () => { - loadingElement.remove(); - injectLoadingElements.forEach((el) => el?.remove()); + loadingElement.remove(); // 移除 loading 元素 + injectLoadingElements.forEach((el) => el.remove()); // 移除所有注入的 loading 元素 }, { once: true }, - ); + ); // 确保事件只触发一次 } } diff --git a/packages/@core/uikit/shadcn-ui/src/components/index.ts b/packages/@core/uikit/shadcn-ui/src/components/index.ts index 05d87f49..3bb0af33 100644 --- a/packages/@core/uikit/shadcn-ui/src/components/index.ts +++ b/packages/@core/uikit/shadcn-ui/src/components/index.ts @@ -19,6 +19,7 @@ export * from './pin-input'; export * from './popover'; export * from './segmented'; export * from './sheet'; +export * from './spinner'; export * from './tooltip'; export * from './ui/alert-dialog'; export * from './ui/avatar'; diff --git a/packages/business/common-ui/src/spinner/index.ts b/packages/@core/uikit/shadcn-ui/src/components/spinner/index.ts similarity index 100% rename from packages/business/common-ui/src/spinner/index.ts rename to packages/@core/uikit/shadcn-ui/src/components/spinner/index.ts diff --git a/packages/business/common-ui/src/spinner/spinner.vue b/packages/@core/uikit/shadcn-ui/src/components/spinner/spinner.vue similarity index 81% rename from packages/business/common-ui/src/spinner/spinner.vue rename to packages/@core/uikit/shadcn-ui/src/components/spinner/spinner.vue index 68306435..5c44e0ea 100644 --- a/packages/business/common-ui/src/spinner/spinner.vue +++ b/packages/@core/uikit/shadcn-ui/src/components/spinner/spinner.vue @@ -1,6 +1,4 @@