1
0
mirror of synced 2025-12-09 23:57:39 +08:00

支持暗黑模式

This commit is contained in:
xuliangzhan
2024-05-08 16:01:04 +08:00
parent c42c39414a
commit 1cb95a3bd2
17 changed files with 589 additions and 284 deletions

View File

@@ -1,6 +1,7 @@
import { App } from 'vue'
import XEUtils from 'xe-utils'
import { config } from './v-x-e-table'
import { setTheme } from './v-x-e-table/src/theme'
import { VxeTableFilterModule } from './filter'
import { VxeTableMenuModule } from './menu'
@@ -92,6 +93,7 @@ config({
export function install (app: App, options: any) {
if (XEUtils.isPlainObject(options)) {
config(options)
setTheme(options)
}
components.forEach(component => component.install(app))
}

View File

@@ -8,10 +8,6 @@ import { warnLog, errLog } from '../../tools/log'
import { VxeTableConstructor, VxeTablePrivateMethods } from '../../../types/all'
export class ColumnInfo {
title?: string
type?: string
field?: string
/* eslint-disable @typescript-eslint/no-use-before-define */
constructor ($xetable: VxeTableConstructor & VxeTablePrivateMethods, _vm: any, { renderHeader, renderCell, renderFooter, renderData }: any = {}) {
const $xegrid = $xetable.xegrid

View File

@@ -8,6 +8,7 @@ import { formats } from './src/formats'
import { validators } from './src/validators'
import { hooks } from './src/hooks'
import { config } from './src/config'
import { setTheme } from './src/theme'
import { getLastZIndex, nextZIndex } from '../tools/utils'
import { VXETableCore } from '../../types/all'
@@ -106,6 +107,8 @@ export const VXETable = {
globalConfs
} as VXETableCore
setTheme(globalStore)
export * from './src/interceptor'
export * from './src/renderer'
export * from './src/commands'

View File

@@ -1,6 +1,7 @@
import GlobalConfig from './conf'
import XEUtils from 'xe-utils'
import DomZIndex from 'dom-zindex'
import { setTheme } from './theme'
import { VxeGlobalConfigMethod } from '../../../types/all'
@@ -8,8 +9,11 @@ import { VxeGlobalConfigMethod } from '../../../types/all'
* 全局参数设置
*/
export const config: VxeGlobalConfigMethod = (options) => {
if (options && options.zIndex) {
DomZIndex.setCurrent(options.zIndex)
if (options) {
setTheme(options)
if (options.zIndex) {
DomZIndex.setCurrent(options.zIndex)
}
}
return XEUtils.merge(GlobalConfig, options)
}

View File

@@ -0,0 +1,11 @@
import GlobalConfig from './conf'
export function setTheme (options: any) {
const theme = (options ? options.theme : null) || GlobalConfig.theme || 'default'
if (typeof document !== 'undefined') {
const documentElement = document.documentElement
if (documentElement) {
documentElement.setAttribute('data-vxe-table-theme', theme)
}
}
}