style: 优化全屏 loading hook 命名 (#44)
This commit is contained in:
parent
1161939616
commit
f4fa12332d
@ -31,23 +31,23 @@ export function getRemoteSelectData() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IBirdsItem {
|
export interface IComicsItem {
|
||||||
id: number
|
id: number
|
||||||
name: string
|
name: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getBirds = () => {
|
export const getComics = () => {
|
||||||
return new Promise<IBirdsItem[]>((resolve) => {
|
return new Promise<IComicsItem[]>((resolve) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
resolve([...Array(5)].map((_t, index) => ({ id: index, name: `t${index}` })))
|
resolve([...Array(5)].map((_t, index) => ({ id: index, name: `c${index}` })))
|
||||||
}, 1000)
|
}, 1000)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getCars = (id: number) => {
|
export const getAnimations = (id: number) => {
|
||||||
return new Promise((_resolve, reject) => {
|
return new Promise((_resolve, reject) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
reject(new Error("sorry" + id))
|
reject(new Error(`Sorry, there is an error here. The error id is ${id}`))
|
||||||
}, 1000)
|
}, 1000)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -6,13 +6,13 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { getBirds, getCars, type IBirdsItem } from "@/api/mock"
|
import { getComics, getAnimations, type IComicsItem } from "@/api/mock"
|
||||||
import { useFullscreenLoading } from "@/hooks/useFullscreenLoading"
|
import { useFullscreenLoading } from "@/hooks/useFullscreenLoading"
|
||||||
import { ElMessage } from "element-plus"
|
import { ElMessage } from "element-plus"
|
||||||
|
|
||||||
const querySuccess = async () => {
|
const querySuccess = async () => {
|
||||||
const birds = await useFullscreenLoading(getBirds)()
|
const comics = await useFullscreenLoading(getComics)()
|
||||||
ElMessage.success(birds.map((t: IBirdsItem) => t.name).join())
|
ElMessage.success("Successfully get comics: " + comics.map((t: IComicsItem) => t.name).join())
|
||||||
}
|
}
|
||||||
|
|
||||||
const svg = `
|
const svg = `
|
||||||
@ -28,7 +28,7 @@ const svg = `
|
|||||||
|
|
||||||
const queryFailed = async () => {
|
const queryFailed = async () => {
|
||||||
try {
|
try {
|
||||||
await useFullscreenLoading(getCars, {
|
await useFullscreenLoading(getAnimations, {
|
||||||
text: "自定义加载文字",
|
text: "自定义加载文字",
|
||||||
background: "rgba(255, 214, 210, 0.7)",
|
background: "rgba(255, 214, 210, 0.7)",
|
||||||
svg,
|
svg,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user