naive.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. import type { App } from 'vue';
  2. import * as NaiveUI from 'naive-ui';
  3. import { computed } from 'vue';
  4. // import { MessageProviderProps } from 'naive-ui';
  5. import { lighten } from '@/utils';
  6. import setting from '@/settings/designSetting';
  7. // NaiveUI 全局方法注册
  8. const configProviderPropsRef = computed(() => ({
  9. theme: undefined,
  10. themeOverrides: {
  11. common: {
  12. primaryColor: setting.appTheme,
  13. primaryColorHover: lighten(setting.appTheme, 6),
  14. primaryColorPressed: lighten(setting.appTheme, 6)
  15. },
  16. LoadingBar: {
  17. colorLoading: setting.appTheme
  18. }
  19. }
  20. }));
  21. // const messageProviderPropsRef = computed(
  22. // () =>
  23. // ({
  24. // closable: false,
  25. // containerStyle: 'undefined',
  26. // duration: 3,
  27. // keepAliveOnHover: false,
  28. // max: 1,
  29. // placement: 'top',
  30. // to: 'body'
  31. // } as MessageProviderProps)
  32. // );
  33. // const { message, dialog, notification, loadingBar } = NaiveUI.createDiscreteApi(
  34. // ['message', 'dialog', 'notification', 'loadingBar'],
  35. // {
  36. // configProviderProps: configProviderPropsRef
  37. // }
  38. // )
  39. // const w = window as any
  40. // window['$message'] = message
  41. // window['$dialog'] = dialog
  42. // window['$notification'] = notification
  43. // window['$loading'] = loadingBar
  44. const naive = NaiveUI.create({
  45. components: [
  46. NaiveUI.NMessageProvider,
  47. NaiveUI.NDialogProvider,
  48. NaiveUI.NConfigProvider,
  49. NaiveUI.NInput,
  50. NaiveUI.NButton,
  51. NaiveUI.NForm,
  52. NaiveUI.NFormItem,
  53. NaiveUI.NCheckboxGroup,
  54. NaiveUI.NCheckbox,
  55. NaiveUI.NIcon,
  56. NaiveUI.NLayout,
  57. NaiveUI.NLayoutHeader,
  58. NaiveUI.NLayoutContent,
  59. NaiveUI.NLayoutFooter,
  60. NaiveUI.NLayoutSider,
  61. NaiveUI.NMenu,
  62. NaiveUI.NBreadcrumb,
  63. NaiveUI.NBreadcrumbItem,
  64. NaiveUI.NDropdown,
  65. NaiveUI.NSpace,
  66. NaiveUI.NTooltip,
  67. NaiveUI.NAvatar,
  68. NaiveUI.NTabs,
  69. NaiveUI.NTabPane,
  70. NaiveUI.NCard,
  71. NaiveUI.NRow,
  72. NaiveUI.NCol,
  73. NaiveUI.NDrawer,
  74. NaiveUI.NDrawerContent,
  75. NaiveUI.NDivider,
  76. NaiveUI.NSwitch,
  77. NaiveUI.NBadge,
  78. NaiveUI.NAlert,
  79. NaiveUI.NElement,
  80. NaiveUI.NTag,
  81. NaiveUI.NNotificationProvider,
  82. NaiveUI.NProgress,
  83. NaiveUI.NDatePicker,
  84. NaiveUI.NGrid,
  85. NaiveUI.NGridItem,
  86. NaiveUI.NList,
  87. NaiveUI.NListItem,
  88. NaiveUI.NThing,
  89. NaiveUI.NDataTable,
  90. NaiveUI.NPopover,
  91. NaiveUI.NPagination,
  92. NaiveUI.NSelect,
  93. NaiveUI.NRadioGroup,
  94. NaiveUI.NRadio,
  95. NaiveUI.NSteps,
  96. NaiveUI.NStep,
  97. NaiveUI.NInputGroup,
  98. NaiveUI.NResult,
  99. NaiveUI.NDescriptions,
  100. NaiveUI.NDescriptionsItem,
  101. NaiveUI.NTable,
  102. NaiveUI.NInputNumber,
  103. NaiveUI.NLoadingBarProvider,
  104. NaiveUI.NModal,
  105. NaiveUI.NUpload,
  106. NaiveUI.NTree,
  107. NaiveUI.NSpin,
  108. NaiveUI.NTimePicker,
  109. NaiveUI.NBackTop,
  110. NaiveUI.NSkeleton
  111. ]
  112. });
  113. const { message, dialog, notification, loadingBar } = NaiveUI.createDiscreteApi(
  114. ['message', 'dialog', 'notification', 'loadingBar'],
  115. {
  116. configProviderProps: configProviderPropsRef
  117. // messageProviderProps: messageProviderPropsRef
  118. }
  119. );
  120. (window as any)['$message'] = message;
  121. (window as any)['$loadingBar'] = loadingBar;
  122. // const w = window as any
  123. // window['$message'] = message
  124. // window['$dialog'] = dialog
  125. // window['$notification'] = notification
  126. // window['$loading'] = loadingBar
  127. export function setupNaive(app: App<Element>) {
  128. app.use(naive);
  129. }