feat: 封装下载hooks

This commit is contained in:
xlsea
2024-09-05 11:06:30 +08:00
parent 824974e904
commit 0c3ea2dc86
11 changed files with 222 additions and 19 deletions

View File

@ -1,11 +1,14 @@
<script setup lang="ts">
import { createTextVNode, defineComponent } from 'vue';
import { useDialog, useLoadingBar, useMessage, useNotification } from 'naive-ui';
import { useLoading } from '@sa/hooks';
defineOptions({
name: 'AppProvider'
});
const loading = useLoading(false);
const ContextHolder = defineComponent({
name: 'ContextHolder',
setup() {
@ -14,6 +17,7 @@ const ContextHolder = defineComponent({
window.$dialog = useDialog();
window.$message = useMessage();
window.$notification = useNotification();
window.$loading = loading;
}
register();
@ -24,16 +28,18 @@ const ContextHolder = defineComponent({
</script>
<template>
<NLoadingBarProvider>
<NDialogProvider>
<NNotificationProvider>
<NMessageProvider>
<ContextHolder />
<slot></slot>
</NMessageProvider>
</NNotificationProvider>
</NDialogProvider>
</NLoadingBarProvider>
<NSpin class="h-full" content-class="h-full" :show="loading.loading.value">
<NLoadingBarProvider>
<NDialogProvider>
<NNotificationProvider>
<NMessageProvider>
<ContextHolder />
<slot></slot>
</NMessageProvider>
</NNotificationProvider>
</NDialogProvider>
</NLoadingBarProvider>
</NSpin>
</template>
<style scoped></style>