f
Some checks failed
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Lint (ubuntu-latest) (push) Has been cancelled
CI / Lint (windows-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Website on push / Deploy Push Playground Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Docs Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Antd Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Element Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Naive Ftp (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
CI / CI OK (push) Has been cancelled
Deploy Website on push / Rerun on failure (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Issue Close Require / close-issues (push) Has been cancelled
Close stale issues / stale (push) Has been cancelled

This commit is contained in:
2026-01-10 18:11:29 +08:00
commit 69f3c4ce45
1443 changed files with 125558 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
# 全局loading
全局 loading 指的是页面刷新时出现的加载效果,通常是一个旋转的图标:
![Global loading spinner](/guide/loading.png)
## 原理
`vite-plugin-inject-app-loading` 插件实现,插件会在每个应用都注入一个全局的 `loading html`
## 关闭
如果你不需要全局 loading可以在 `.env` 文件中关闭:
```bash
VITE_INJECT_APP_LOADING=false
```
## 自定义
如果你想要自定义全局 loading可以在应用目录下`index.html`同级,创建一个`loading.html`文件插件会自动读取并注入。这个html可以自行定义样式和动画。
::: tip
- 你可以使用跟`index.html`一样的语法,比如`VITE_APP_TITLE`变量,来获取应用的标题。
- 必须保证有一个`id="__app-loading__"`的元素。
-`id="__app-loading__"`的元素,加一个 `hidden` class。
- 必须保证有一个`style[data-app-loading="inject-css"]`的元素。
```html{1,4}
<style data-app-loading="inject-css">
#__app-loading__.hidden {
pointer-events: none;
visibility: hidden;
opacity: 0;
transition: all 1s ease-out;
}
/* ... */
</style>
<div id="__app-loading__">
<!-- ... -->
<div class="title"><%= VITE_APP_TITLE %></div>
</div>
```
:::