2026-01-16 13:06:44 +08:00
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { useDialog, useLoadingBar, useMessage, useNotification } from 'naive-ui'
|
|
|
|
|
import { createTextVNode, defineComponent } from 'vue'
|
|
|
|
|
|
|
|
|
|
defineOptions({
|
|
|
|
|
name: 'AppProvider',
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const ContextHolder = defineComponent({
|
|
|
|
|
name: 'ContextHolder',
|
|
|
|
|
setup() {
|
|
|
|
|
function register() {
|
2026-01-21 08:41:36 +08:00
|
|
|
window.$loadingBar = useLoadingBar() // 注册全局 loading bar
|
|
|
|
|
window.$dialog = useDialog()// 注册全局 dialog
|
|
|
|
|
window.$message = useMessage()// 注册全局 message
|
|
|
|
|
window.$notification = useNotification() // 注册全局 notification
|
2026-01-16 13:06:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
register()
|
|
|
|
|
|
|
|
|
|
return () => createTextVNode()
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<NLoadingBarProvider>
|
|
|
|
|
<NDialogProvider>
|
|
|
|
|
<NNotificationProvider>
|
|
|
|
|
<NMessageProvider>
|
|
|
|
|
<ContextHolder />
|
|
|
|
|
<slot />
|
|
|
|
|
</NMessageProvider>
|
|
|
|
|
</NNotificationProvider>
|
|
|
|
|
</NDialogProvider>
|
|
|
|
|
</NLoadingBarProvider>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped></style>
|