@quiteer/naive-extra 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +86 -0
  3. package/dist/components/breadcrumb/index.d.ts +0 -0
  4. package/dist/components/breadcrumb/index.vue.d.ts +3 -0
  5. package/dist/components/breadcrumb/props.d.ts +0 -0
  6. package/dist/components/button/action/index.d.ts +3 -0
  7. package/dist/components/button/action/index.vue.d.ts +118 -0
  8. package/dist/components/button/action/props.d.ts +63 -0
  9. package/dist/components/button/action/utils.d.ts +8 -0
  10. package/dist/components/button/base/index.d.ts +3 -0
  11. package/dist/components/button/base/index.vue.d.ts +36 -0
  12. package/dist/components/button/base/props.d.ts +27 -0
  13. package/dist/components/button/index.d.ts +4 -0
  14. package/dist/components/button/types.d.ts +2 -0
  15. package/dist/components/form/helper.d.ts +11 -0
  16. package/dist/components/form/index.d.ts +3 -0
  17. package/dist/components/form/index.vue.d.ts +642 -0
  18. package/dist/components/form/props.d.ts +34 -0
  19. package/dist/components/icon/IconPicker.vue.d.ts +13 -0
  20. package/dist/components/icon/iconify.d.ts +25 -0
  21. package/dist/components/icon/index.d.ts +3 -0
  22. package/dist/components/icon/index.vue.d.ts +12 -0
  23. package/dist/components/layout/const.d.ts +22 -0
  24. package/dist/components/layout/context.d.ts +77 -0
  25. package/dist/components/layout/index.d.ts +5 -0
  26. package/dist/components/layout/index.vue.d.ts +80 -0
  27. package/dist/components/layout/layout-parts/AppBreadcrumb.vue.d.ts +3 -0
  28. package/dist/components/layout/layout-parts/AppFooter.vue.d.ts +18 -0
  29. package/dist/components/layout/layout-parts/AppHeader.vue.d.ts +18 -0
  30. package/dist/components/layout/layout-parts/AppLeftLogoInfo.vue.d.ts +3 -0
  31. package/dist/components/layout/layout-parts/AppMain.vue.d.ts +18 -0
  32. package/dist/components/layout/layout-parts/AppSidebar.vue.d.ts +4067 -0
  33. package/dist/components/layout/layout-parts/LayoutTransition.vue.d.ts +58 -0
  34. package/dist/components/layout/mode.d.ts +0 -0
  35. package/dist/components/layout/props.d.ts +35 -0
  36. package/dist/components/layout/types.d.ts +59 -0
  37. package/dist/components/layout/utils.d.ts +97 -0
  38. package/dist/components/provider/index.d.ts +3 -0
  39. package/dist/components/provider/index.vue.d.ts +19 -0
  40. package/dist/components/provider/props.d.ts +33 -0
  41. package/dist/components/search-bar/index.d.ts +3 -0
  42. package/dist/components/search-bar/index.vue.d.ts +1288 -0
  43. package/dist/components/search-bar/props.d.ts +15 -0
  44. package/dist/components/table/TableSetting.vue.d.ts +15 -0
  45. package/dist/components/table/index.d.ts +4 -0
  46. package/dist/components/table/index.vue.d.ts +17246 -0
  47. package/dist/components/table/props.d.ts +26 -0
  48. package/dist/components/table/useColumn.d.ts +15 -0
  49. package/dist/components/upload/enum.d.ts +18 -0
  50. package/dist/components/upload/index.d.ts +4 -0
  51. package/dist/components/upload/index.vue.d.ts +17 -0
  52. package/dist/components/upload/props.d.ts +7 -0
  53. package/dist/const/defaults.d.ts +7 -0
  54. package/dist/const/index.d.ts +2 -0
  55. package/dist/const/types.d.ts +134 -0
  56. package/dist/context/color.d.ts +13 -0
  57. package/dist/context/common.d.ts +117 -0
  58. package/dist/context/index.d.ts +41 -0
  59. package/dist/context/layout.d.ts +52 -0
  60. package/dist/context/loading-bar.d.ts +14 -0
  61. package/dist/context/locale.d.ts +143 -0
  62. package/dist/context/menu.d.ts +212 -0
  63. package/dist/context/message.d.ts +14 -0
  64. package/dist/context/notification.d.ts +14 -0
  65. package/dist/context/table.d.ts +917 -0
  66. package/dist/context/theme.d.ts +20 -0
  67. package/dist/hooks/index.d.ts +6 -0
  68. package/dist/hooks/useAdmin.d.ts +0 -0
  69. package/dist/hooks/useForm.d.ts +54 -0
  70. package/dist/hooks/useLayout.d.ts +116 -0
  71. package/dist/hooks/useProviderContext.d.ts +17 -0
  72. package/dist/hooks/useTable.d.ts +66 -0
  73. package/dist/hooks/useThemeOverrides.d.ts +8 -0
  74. package/dist/hooks/useUpload.d.ts +22 -0
  75. package/dist/index.css +36 -0
  76. package/dist/index.d.ts +29 -0
  77. package/dist/index.js +6771 -0
  78. package/dist/share/compact.d.ts +16 -0
  79. package/dist/share/index.d.ts +2 -0
  80. package/dist/share/menu.d.ts +0 -0
  81. package/dist/share/route.d.ts +0 -0
  82. package/dist/share/slot.d.ts +6 -0
  83. package/dist/utils/form.d.ts +0 -0
  84. package/dist/utils/index.d.ts +0 -0
  85. package/dist/utils/transformRoutes.d.ts +67 -0
  86. package/dist/utils/tree.d.ts +6 -0
  87. package/package.json +53 -0
  88. package/src/auto-imports.d.ts +73 -0
  89. package/src/components/breadcrumb/index.ts +0 -0
  90. package/src/components/breadcrumb/index.vue +0 -0
  91. package/src/components/breadcrumb/props.ts +0 -0
  92. package/src/components/button/action/index.ts +4 -0
  93. package/src/components/button/action/index.vue +313 -0
  94. package/src/components/button/action/props.ts +78 -0
  95. package/src/components/button/action/utils.ts +122 -0
  96. package/src/components/button/base/index.ts +4 -0
  97. package/src/components/button/base/index.vue +156 -0
  98. package/src/components/button/base/props.ts +29 -0
  99. package/src/components/button/index.ts +4 -0
  100. package/src/components/button/types.ts +2 -0
  101. package/src/components/form/helper.ts +73 -0
  102. package/src/components/form/index.ts +5 -0
  103. package/src/components/form/index.vue +243 -0
  104. package/src/components/form/props.ts +75 -0
  105. package/src/components/icon/IconPicker.vue +255 -0
  106. package/src/components/icon/iconify.ts +80 -0
  107. package/src/components/icon/index.ts +7 -0
  108. package/src/components/icon/index.vue +23 -0
  109. package/src/components/layout/const.ts +102 -0
  110. package/src/components/layout/context.ts +189 -0
  111. package/src/components/layout/index.ts +8 -0
  112. package/src/components/layout/index.vue +64 -0
  113. package/src/components/layout/layout-parts/AppBreadcrumb.vue +108 -0
  114. package/src/components/layout/layout-parts/AppFooter.vue +26 -0
  115. package/src/components/layout/layout-parts/AppHeader.vue +112 -0
  116. package/src/components/layout/layout-parts/AppLeftLogoInfo.vue +30 -0
  117. package/src/components/layout/layout-parts/AppMain.vue +34 -0
  118. package/src/components/layout/layout-parts/AppSidebar.vue +174 -0
  119. package/src/components/layout/layout-parts/LayoutTransition.vue +366 -0
  120. package/src/components/layout/mode.ts +0 -0
  121. package/src/components/layout/props.ts +36 -0
  122. package/src/components/layout/types.ts +79 -0
  123. package/src/components/layout/utils.ts +201 -0
  124. package/src/components/provider/index.ts +5 -0
  125. package/src/components/provider/index.vue +69 -0
  126. package/src/components/provider/props.ts +45 -0
  127. package/src/components/search-bar/index.ts +5 -0
  128. package/src/components/search-bar/index.vue +282 -0
  129. package/src/components/search-bar/props.ts +26 -0
  130. package/src/components/table/TableSetting.vue +253 -0
  131. package/src/components/table/index.ts +14 -0
  132. package/src/components/table/index.vue +179 -0
  133. package/src/components/table/props.ts +29 -0
  134. package/src/components/table/useColumn.ts +104 -0
  135. package/src/components/upload/enum.ts +21 -0
  136. package/src/components/upload/index.ts +9 -0
  137. package/src/components/upload/index.vue +267 -0
  138. package/src/components/upload/props.ts +8 -0
  139. package/src/components.d.ts +154 -0
  140. package/src/const/defaults.ts +94 -0
  141. package/src/const/index.ts +2 -0
  142. package/src/const/types.ts +139 -0
  143. package/src/context/color.ts +53 -0
  144. package/src/context/common.ts +27 -0
  145. package/src/context/index.ts +141 -0
  146. package/src/context/layout.ts +34 -0
  147. package/src/context/loading-bar.ts +26 -0
  148. package/src/context/locale.ts +22 -0
  149. package/src/context/menu.ts +26 -0
  150. package/src/context/message.ts +30 -0
  151. package/src/context/notification.ts +29 -0
  152. package/src/context/table.ts +32 -0
  153. package/src/context/theme.ts +35 -0
  154. package/src/hooks/index.ts +6 -0
  155. package/src/hooks/useAdmin.ts +0 -0
  156. package/src/hooks/useForm.ts +272 -0
  157. package/src/hooks/useLayout.ts +300 -0
  158. package/src/hooks/useProviderContext.ts +47 -0
  159. package/src/hooks/useTable.ts +241 -0
  160. package/src/hooks/useThemeOverrides.ts +18 -0
  161. package/src/hooks/useUpload.ts +82 -0
  162. package/src/index.ts +59 -0
  163. package/src/share/compact.ts +35 -0
  164. package/src/share/index.ts +2 -0
  165. package/src/share/menu.ts +0 -0
  166. package/src/share/route.ts +0 -0
  167. package/src/share/slot.ts +29 -0
  168. package/src/utils/form.ts +0 -0
  169. package/src/utils/index.ts +0 -0
  170. package/src/utils/transformRoutes.ts +163 -0
  171. package/src/utils/tree.ts +31 -0
@@ -0,0 +1,53 @@
1
+ import type { ComputedRef } from 'vue'
2
+ import type { NaiveExtraThemeConfig } from '../const'
3
+ import { generateColorScale } from '@quiteer/color'
4
+ import { provideNaiveTheme } from '@quiteer/unocss/provide'
5
+ import { computed, watchEffect } from 'vue'
6
+
7
+ /**
8
+ * 品牌色管理模块
9
+ *
10
+ * 负责生成品牌色阶并同步 CSS 变量到 :root
11
+ *
12
+ * @param mergedConfig - 合并后的响应式配置
13
+ * @returns 包含 common 变量中颜色部分的计算结果
14
+ */
15
+ export function useColorModule(mergedConfig: ComputedRef<Required<NaiveExtraThemeConfig>>) {
16
+ /**
17
+ * 计算 Naive UI common 变量中的颜色部分
18
+ */
19
+ const colorVars = computed(() => {
20
+ const { palette } = mergedConfig.value
21
+ const vars: any = {}
22
+
23
+ const brandKeys = ['primary', 'info', 'success', 'warning', 'error'] as const
24
+ brandKeys.forEach((key) => {
25
+ const baseColor = palette[key]
26
+ if (baseColor) {
27
+ const scale = generateColorScale(baseColor)
28
+ vars[`${key}Color`] = scale.DEFAULT
29
+ vars[`${key}ColorHover`] = scale.hover
30
+ vars[`${key}ColorPressed`] = scale.pressed
31
+ vars[`${key}ColorSuppl`] = scale.suppl
32
+ vars[`${key}ColorActive`] = scale.active
33
+ }
34
+ })
35
+
36
+ return vars
37
+ })
38
+
39
+ // 同步 CSS 变量到 :root
40
+ watchEffect((onCleanup) => {
41
+ const cleanup = provideNaiveTheme({
42
+ theme: colorVars.value as any
43
+ })
44
+ onCleanup(() => {
45
+ if (cleanup)
46
+ cleanup()
47
+ })
48
+ })
49
+
50
+ return {
51
+ colorVars
52
+ }
53
+ }
@@ -0,0 +1,27 @@
1
+ import type { ComputedRef } from 'vue'
2
+ import type { NaiveExtraThemeConfig } from '../const'
3
+ import { computed } from 'vue'
4
+
5
+ /**
6
+ * 基础变量管理模块
7
+ *
8
+ * 负责处理圆角、基础配置等 Naive UI common 变量
9
+ *
10
+ * @param mergedConfig - 合并后的响应式配置
11
+ * @returns 包含 common 变量中非颜色部分的计算结果
12
+ */
13
+ export function useCommonModule(mergedConfig: ComputedRef<Required<NaiveExtraThemeConfig>>) {
14
+ const commonVars = computed(() => {
15
+ const { borderRadius, common } = mergedConfig.value
16
+
17
+ return {
18
+ ...common,
19
+ borderRadius: `${borderRadius}px`,
20
+ borderRadiusSmall: `${Math.max(0, borderRadius - 2)}px`
21
+ }
22
+ })
23
+
24
+ return {
25
+ commonVars
26
+ }
27
+ }
@@ -0,0 +1,141 @@
1
+ import type { ConfigProviderProps, GlobalThemeOverrides } from 'naive-ui'
2
+ import type { ComputedRef, InjectionKey, Ref } from 'vue'
3
+ import type { NaiveExtraThemeConfig } from '../const'
4
+ import { defu } from 'defu'
5
+ import { computed, provide, ref } from 'vue'
6
+
7
+ import { DEFAULT_THEME_CONFIG } from '../const'
8
+ import { useColorModule } from './color'
9
+ import { useCommonModule } from './common'
10
+ import { useLayoutModule } from './layout'
11
+ import { useLoadingBarModule } from './loading-bar'
12
+ import { useLocaleModule } from './locale'
13
+ import { useMenuModule } from './menu'
14
+ import { useMessageModule } from './message'
15
+ import { useNotificationModule } from './notification'
16
+ import { useTableModule } from './table'
17
+ // 导入子模块
18
+ import { useThemeModule } from './theme'
19
+
20
+ export * from '../const'
21
+
22
+ /**
23
+ * NaiveExtra 上下文接口
24
+ */
25
+ export interface NaiveExtraContext {
26
+ /** 响应式的主题配置 */
27
+ config: Ref<NaiveExtraThemeConfig>
28
+ /** 合并了默认值的最终配置 */
29
+ mergedConfig: ComputedRef<Required<NaiveExtraThemeConfig>>
30
+ /** ConfigProvider 所需的所有 Props */
31
+ providerProps: ComputedRef<ConfigProviderProps>
32
+ loadingBarProviderProps: ComputedRef<any>
33
+ messageProviderProps: ComputedRef<any>
34
+ notificationProviderProps: ComputedRef<any>
35
+ /** 是否为暗黑模式 */
36
+ isDark: ComputedRef<boolean>
37
+ /** 更新配置的方法 */
38
+ updateConfig: (newConfig: Partial<NaiveExtraThemeConfig>) => void
39
+ /** 主题控制方法 */
40
+ setThemeMode: (mode: 'light' | 'dark' | 'system') => void
41
+ toggleTheme: () => void
42
+ /** 语言控制方法 */
43
+ setLocaleMode: (mode: 'zh' | 'en') => void
44
+ toggleLocale: () => void
45
+ /** 样式快捷操作 */
46
+ setPrimaryColor: (color: string) => void
47
+ setBorderRadius: (radius: number) => void
48
+ }
49
+
50
+ /**
51
+ * Context 注入标识
52
+ */
53
+ export const NAIVE_EXTRA_CONTEXT_KEY: InjectionKey<NaiveExtraContext> = Symbol('NAIVE_EXTRA_CONTEXT')
54
+
55
+ /**
56
+ * 创建并提供主题配置上下文
57
+ *
58
+ * 通过聚合多个子模块逻辑,实现一站式的主题与配置管理。
59
+ */
60
+ export function createProviderContext(initialConfig: NaiveExtraThemeConfig = {}): NaiveExtraContext {
61
+ const config = ref<NaiveExtraThemeConfig>(JSON.parse(JSON.stringify(initialConfig)))
62
+
63
+ /**
64
+ * 基础合并配置逻辑 (使用 defu 进行深度合并)
65
+ */
66
+ const mergedConfig = computed(() => {
67
+ return defu(config.value, DEFAULT_THEME_CONFIG) as Required<NaiveExtraThemeConfig>
68
+ })
69
+
70
+ // 初始化子模块
71
+ const { isDark, theme } = useThemeModule(mergedConfig)
72
+ const { locale, dateLocale } = useLocaleModule(mergedConfig)
73
+ const { colorVars } = useColorModule(mergedConfig)
74
+ const { commonVars } = useCommonModule(mergedConfig)
75
+ const { tableOverrides } = useTableModule(mergedConfig)
76
+ const { menuOverrides } = useMenuModule(mergedConfig)
77
+ const { layoutOverrides } = useLayoutModule(mergedConfig)
78
+ const { loadingBarProviderProps } = useLoadingBarModule(mergedConfig)
79
+ const { messageProviderProps } = useMessageModule(mergedConfig)
80
+ const { notificationProviderProps } = useNotificationModule(mergedConfig)
81
+
82
+ /**
83
+ * 聚合所有覆盖样式
84
+ */
85
+ const themeOverrides = computed<GlobalThemeOverrides>(() => ({
86
+ common: {
87
+ ...commonVars.value,
88
+ ...colorVars.value
89
+ },
90
+ DataTable: tableOverrides.value,
91
+ Layout: layoutOverrides.value,
92
+ Menu: menuOverrides.value,
93
+ ...mergedConfig.value.overrides
94
+ }))
95
+
96
+ /**
97
+ * 组装最终给 ConfigProvider 的 Props
98
+ */
99
+ const providerProps = computed<ConfigProviderProps>(() => ({
100
+ theme: theme.value,
101
+ locale: locale.value,
102
+ dateLocale: dateLocale.value,
103
+ themeOverrides: themeOverrides.value
104
+ }))
105
+
106
+ // 操作方法
107
+ const updateConfig = (newConfig: Partial<NaiveExtraThemeConfig>) => {
108
+ // 显式触发更新,确保响应式追踪
109
+ config.value = defu(JSON.parse(JSON.stringify(newConfig)), config.value)
110
+ }
111
+
112
+ const setThemeMode = (mode: 'light' | 'dark' | 'system') => updateConfig({ themeMode: mode })
113
+ const toggleTheme = () => setThemeMode(isDark.value ? 'light' : 'dark')
114
+ const setLocaleMode = (mode: 'zh' | 'en') => updateConfig({ localeMode: mode })
115
+ const toggleLocale = () => setLocaleMode(mergedConfig.value.localeMode === 'zh' ? 'en' : 'zh')
116
+ const setPrimaryColor = (color: string) => {
117
+ updateConfig({ palette: { primary: color } })
118
+ }
119
+ const setBorderRadius = (radius: number) => updateConfig({ borderRadius: radius })
120
+
121
+ const context: NaiveExtraContext = {
122
+ config,
123
+ mergedConfig,
124
+ providerProps,
125
+ loadingBarProviderProps,
126
+ messageProviderProps,
127
+ notificationProviderProps,
128
+ isDark,
129
+ updateConfig,
130
+ setThemeMode,
131
+ toggleTheme,
132
+ setLocaleMode,
133
+ toggleLocale,
134
+ setPrimaryColor,
135
+ setBorderRadius
136
+ }
137
+
138
+ provide(NAIVE_EXTRA_CONTEXT_KEY, context)
139
+
140
+ return context
141
+ }
@@ -0,0 +1,34 @@
1
+ import type { GlobalThemeOverrides } from 'naive-ui'
2
+ import type { ComputedRef } from 'vue'
3
+ import type { NaiveExtraThemeConfig } from '../const'
4
+ import { computed } from 'vue'
5
+ import { compact, formatPx } from '../share'
6
+
7
+ /**
8
+ * 布局相关组件样式覆盖模块
9
+ *
10
+ * 涵盖 Layout, Tabs, Scrollbar 等
11
+ *
12
+ * @param mergedConfig - 合并后的响应式配置
13
+ * @returns 包含各组件主题覆盖对象的集合
14
+ */
15
+ export function useLayoutModule(mergedConfig: ComputedRef<Required<NaiveExtraThemeConfig>>) {
16
+ const layoutOverrides = computed<GlobalThemeOverrides['Layout']>(() => {
17
+ const { layout } = mergedConfig.value
18
+ return compact({
19
+ headerHeight: formatPx(layout.headerHeight),
20
+ footerHeight: formatPx(layout.footerHeight),
21
+ siderWidth: formatPx(layout.siderWidth),
22
+ siderCollapsedWidth: formatPx(layout.siderCollapsedWidth),
23
+ color: layout.color,
24
+ colorEmbedded: layout.colorEmbedded,
25
+ headerColor: layout.headerColor,
26
+ footerColor: layout.footerColor,
27
+ siderColor: layout.siderColor
28
+ })
29
+ })
30
+
31
+ return {
32
+ layoutOverrides
33
+ }
34
+ }
@@ -0,0 +1,26 @@
1
+ import type { LoadingBarProviderProps } from 'naive-ui'
2
+ import type { ComputedRef } from 'vue'
3
+ import type { NaiveExtraThemeConfig } from '../const'
4
+ import { computed } from 'vue'
5
+ import { compact } from '../share'
6
+
7
+ /**
8
+ * 加载条 (LoadingBar) 配置模块
9
+ *
10
+ * 负责管理 NLoadingBarProvider 的全局属性和样式
11
+ *
12
+ * @param mergedConfig - 合并后的完整主题配置
13
+ * @returns 包含 loadingBarProviderProps 的计算引用
14
+ */
15
+ export function useLoadingBarModule(mergedConfig: ComputedRef<Required<NaiveExtraThemeConfig>>) {
16
+ const loadingBarProviderProps = computed<LoadingBarProviderProps>(() => {
17
+ const { loadingBar } = mergedConfig.value
18
+ return compact({
19
+ loadingBarStyle: loadingBar.loadingBarStyle
20
+ })
21
+ })
22
+
23
+ return {
24
+ loadingBarProviderProps
25
+ }
26
+ }
@@ -0,0 +1,22 @@
1
+ import type { ComputedRef } from 'vue'
2
+ import type { NaiveExtraThemeConfig } from '../const'
3
+ import { dateEnUS, dateZhCN, enUS, zhCN } from 'naive-ui'
4
+ import { computed } from 'vue'
5
+
6
+ /**
7
+ * 国际化管理模块
8
+ *
9
+ * 负责语言包及日期语言包的切换逻辑
10
+ *
11
+ * @param mergedConfig - 合并后的响应式配置
12
+ * @returns 包含语言包、日期语言包计算结果的对象
13
+ */
14
+ export function useLocaleModule(mergedConfig: ComputedRef<Required<NaiveExtraThemeConfig>>) {
15
+ const locale = computed(() => (mergedConfig.value.localeMode === 'zh' ? zhCN : enUS))
16
+ const dateLocale = computed(() => (mergedConfig.value.localeMode === 'zh' ? dateZhCN : dateEnUS))
17
+
18
+ return {
19
+ locale,
20
+ dateLocale
21
+ }
22
+ }
@@ -0,0 +1,26 @@
1
+ import type { GlobalThemeOverrides } from 'naive-ui'
2
+ import type { ComputedRef } from 'vue'
3
+ import type { NaiveExtraThemeConfig } from '../const'
4
+ import { computed } from 'vue'
5
+ import { compact, formatPx } from '../share'
6
+
7
+ /**
8
+ * 菜单组件样式覆盖模块
9
+ *
10
+ * @param mergedConfig - 合并后的响应式配置
11
+ * @returns 包含菜单组件主题覆盖对象的集合
12
+ */
13
+ export function useMenuModule(mergedConfig: ComputedRef<Required<NaiveExtraThemeConfig>>) {
14
+ const menuOverrides = computed<GlobalThemeOverrides['Menu']>(() => {
15
+ const { menu } = mergedConfig.value
16
+ return compact({
17
+ itemHeight: formatPx(menu.itemHeight),
18
+ collapsedWidth: formatPx(menu.collapsedWidth),
19
+ itemIconSize: formatPx(menu.iconSize)
20
+ })
21
+ })
22
+
23
+ return {
24
+ menuOverrides
25
+ }
26
+ }
@@ -0,0 +1,30 @@
1
+ import type { MessageProviderProps } from 'naive-ui'
2
+ import type { ComputedRef } from 'vue'
3
+ import type { NaiveExtraThemeConfig } from '../const'
4
+ import { computed } from 'vue'
5
+ import { compact } from '../share'
6
+
7
+ /**
8
+ * 消息 (Message) 配置模块
9
+ *
10
+ * 负责管理 NMessageProvider 的全局展示逻辑
11
+ *
12
+ * @param mergedConfig - 合并后的完整主题配置
13
+ * @returns 包含 messageProviderProps 的计算引用
14
+ */
15
+ export function useMessageModule(mergedConfig: ComputedRef<Required<NaiveExtraThemeConfig>>) {
16
+ const messageProviderProps = computed<MessageProviderProps>(() => {
17
+ const { message } = mergedConfig.value
18
+ return compact({
19
+ duration: message.duration,
20
+ max: message.max,
21
+ placement: message.placement,
22
+ closable: message.closable,
23
+ keepAliveOnHover: true
24
+ })
25
+ })
26
+
27
+ return {
28
+ messageProviderProps
29
+ }
30
+ }
@@ -0,0 +1,29 @@
1
+ import type { NotificationProviderProps } from 'naive-ui'
2
+ import type { ComputedRef } from 'vue'
3
+ import type { NaiveExtraThemeConfig } from '../const'
4
+ import { computed } from 'vue'
5
+ import { compact } from '../share'
6
+
7
+ /**
8
+ * 通知 (Notification) 配置模块
9
+ *
10
+ * 负责管理 NNotificationProvider 的全局展示逻辑
11
+ *
12
+ * @param mergedConfig - 合并后的完整主题配置
13
+ * @returns 包含 notificationProviderProps 的计算引用
14
+ */
15
+ export function useNotificationModule(mergedConfig: ComputedRef<Required<NaiveExtraThemeConfig>>) {
16
+ const notificationProviderProps = computed<NotificationProviderProps>(() => {
17
+ const { notification } = mergedConfig.value
18
+ return compact({
19
+ duration: notification.duration,
20
+ max: notification.max,
21
+ placement: notification.placement,
22
+ keepAliveOnHover: true
23
+ })
24
+ })
25
+
26
+ return {
27
+ notificationProviderProps
28
+ }
29
+ }
@@ -0,0 +1,32 @@
1
+ import type { GlobalThemeOverrides } from 'naive-ui'
2
+ import type { ComputedRef } from 'vue'
3
+ import type { NaiveExtraThemeConfig } from '../const'
4
+ import { computed } from 'vue'
5
+ import { compact } from '../share'
6
+
7
+ /**
8
+ * 表格组件样式覆盖模块
9
+ *
10
+ * @param mergedConfig - 合并后的响应式配置
11
+ * @returns DataTable 的主题覆盖对象
12
+ */
13
+ export function useTableModule(mergedConfig: ComputedRef<Required<NaiveExtraThemeConfig>>) {
14
+ const tableOverrides = computed<GlobalThemeOverrides['DataTable']>(() => {
15
+ const { table } = mergedConfig.value
16
+
17
+ return compact({
18
+ tdPaddingHorizontal: table.tdPaddingHorizontal,
19
+ tdPaddingVertical: table.tdPaddingVertical,
20
+ thPaddingHorizontal: table.thPaddingHorizontal,
21
+ thPaddingVertical: table.thPaddingVertical,
22
+ tableColor: table.tableColor,
23
+ thColor: table.tableHeaderColor,
24
+ tdColorStriped: table.tableColorStriped,
25
+ tdColorHover: table.tableColorHover
26
+ })
27
+ })
28
+
29
+ return {
30
+ tableOverrides
31
+ }
32
+ }
@@ -0,0 +1,35 @@
1
+ import type { ComputedRef } from 'vue'
2
+ import type { NaiveExtraThemeConfig } from '../const'
3
+ import { darkTheme, useOsTheme } from 'naive-ui'
4
+ import { computed } from 'vue'
5
+
6
+ /**
7
+ * 主题管理模块
8
+ *
9
+ * 负责应用明暗模式的响应式计算,支持跟随系统主题 (OS Theme)。
10
+ *
11
+ * @param mergedConfig - 合并后的完整主题配置
12
+ * @returns 包含当前是否为暗黑模式 (isDark) 及 Naive UI 主题对象 (theme) 的计算引用
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const { isDark, theme } = useThemeModule(mergedConfig)
17
+ * ```
18
+ */
19
+ export function useThemeModule(mergedConfig: ComputedRef<Required<NaiveExtraThemeConfig>>) {
20
+ const osTheme = useOsTheme()
21
+
22
+ const isDark = computed(() => {
23
+ const mode = mergedConfig.value.themeMode
24
+ if (mode === 'system')
25
+ return osTheme.value === 'dark'
26
+ return mode === 'dark'
27
+ })
28
+
29
+ const theme = computed(() => (isDark.value ? darkTheme : null))
30
+
31
+ return {
32
+ isDark,
33
+ theme
34
+ }
35
+ }
@@ -0,0 +1,6 @@
1
+ export * from './useForm'
2
+ export * from './useLayout'
3
+ export * from './useProviderContext'
4
+ export * from './useTable'
5
+ export * from './useThemeOverrides'
6
+ export * from './useUpload'
File without changes