Initial commit: One Pipe System
完整的管理系统,包含账户管理、卡片管理、套餐管理、财务管理等功能模块。 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
38
src/utils/ui/loading.ts
Normal file
38
src/utils/ui/loading.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { fourDotsSpinnerSvg } from '@/assets/svg/loading'
|
||||
import { ElLoading } from 'element-plus'
|
||||
|
||||
const DEFAULT_LOADING_CONFIG = {
|
||||
lock: true,
|
||||
background: 'rgba(0, 0, 0, 0)',
|
||||
svg: fourDotsSpinnerSvg,
|
||||
svgViewBox: '0 0 40 40'
|
||||
} as const
|
||||
|
||||
interface LoadingInstance {
|
||||
close: () => void
|
||||
}
|
||||
|
||||
let loadingInstance: LoadingInstance | null = null
|
||||
|
||||
export const loadingService = {
|
||||
/**
|
||||
* 显示 loading
|
||||
* @returns 关闭 loading 的函数
|
||||
*/
|
||||
showLoading(): () => void {
|
||||
if (!loadingInstance) {
|
||||
loadingInstance = ElLoading.service(DEFAULT_LOADING_CONFIG)
|
||||
}
|
||||
return () => this.hideLoading()
|
||||
},
|
||||
|
||||
/**
|
||||
* 隐藏 loading
|
||||
*/
|
||||
hideLoading(): void {
|
||||
if (loadingInstance) {
|
||||
loadingInstance.close()
|
||||
loadingInstance = null
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user