mirror of
https://github.com/jekip/naive-ui-admin.git
synced 2026-02-12 01:02:27 +08:00
perf: 单独拆分 naive 全局 API 挂载方法
This commit is contained in:
@@ -1,35 +1,5 @@
|
||||
import type { App } from 'vue';
|
||||
import * as NaiveUI from 'naive-ui';
|
||||
import { computed } from 'vue';
|
||||
import { useDesignSettingStore } from '@/store/modules/designSetting';
|
||||
import { store } from '@/store';
|
||||
import { lighten } from '@/utils/index';
|
||||
|
||||
// NaiveUI 全局方法注册
|
||||
const designStore = useDesignSettingStore(store);
|
||||
const configProviderPropsRef = computed(() => ({
|
||||
theme: designStore.darkTheme ? NaiveUI.darkTheme : undefined,
|
||||
themeOverrides: {
|
||||
common: {
|
||||
primaryColor: designStore.appTheme,
|
||||
primaryColorHover: lighten(designStore.appTheme, 6),
|
||||
primaryColorPressed: lighten(designStore.appTheme, 6),
|
||||
},
|
||||
LoadingBar: {
|
||||
colorLoading: designStore.appTheme,
|
||||
},
|
||||
},
|
||||
}));
|
||||
const { message, dialog, notification, loadingBar } = NaiveUI.createDiscreteApi(
|
||||
['message', 'dialog', 'notification', 'loadingBar'],
|
||||
{
|
||||
configProviderProps: configProviderPropsRef,
|
||||
}
|
||||
);
|
||||
window['$message'] = message;
|
||||
window['$dialog'] = dialog;
|
||||
window['$notification'] = notification;
|
||||
window['$loading'] = loadingBar;
|
||||
|
||||
const naive = NaiveUI.create({
|
||||
components: [
|
||||
|
||||
Reference in New Issue
Block a user