diff --git a/src/components/common/AppProvider.vue b/src/components/common/AppProvider.vue index bed856c..bdb9794 100644 --- a/src/components/common/AppProvider.vue +++ b/src/components/common/AppProvider.vue @@ -6,33 +6,14 @@ :theme="appStore.isDark ? darkTheme : undefined" :theme-overrides="naiveThemeOverrides" > - - - - - - - - - - + diff --git a/src/main.js b/src/main.js index 7cf73f8..0690540 100644 --- a/src/main.js +++ b/src/main.js @@ -9,11 +9,13 @@ import { setupRouter } from '@/router' import { setupStore } from '@/store' import App from './App.vue' import { useResize } from '@zclzone/utils' +import { setupNaiveDiscreteApi } from './utils' async function setupApp() { const app = createApp(App) setupStore(app) + setupNaiveDiscreteApi() await setupRouter(app) diff --git a/src/utils/common/naiveTools.js b/src/utils/common/naiveTools.js index 320acd3..9f54055 100644 --- a/src/utils/common/naiveTools.js +++ b/src/utils/common/naiveTools.js @@ -1,4 +1,7 @@ +import * as NaiveUI from 'naive-ui' import { isNullOrUndef } from '@/utils' +import { naiveThemeOverrides as themeOverrides } from '~/settings' +import { useAppStore } from '@/store/modules/app' export function setupMessage(NMessage) { let loadingMessage = null @@ -77,3 +80,20 @@ export function setupDialog(NDialog) { return NDialog } + +export function setupNaiveDiscreteApi() { + const appStore = useAppStore() + const configProviderProps = computed(() => ({ + theme: appStore.isDark ? NaiveUI.darkTheme : undefined, + themeOverrides, + })) + const { message, dialog, notification, loadingBar } = NaiveUI.createDiscreteApi( + ['message', 'dialog', 'notification', 'loadingBar'], + { configProviderProps } + ) + + window.$loadingBar = loadingBar + window.$notification = notification + window.$message = setupMessage(message) + window.$dialog = setupDialog(dialog) +}