Skip to content

Commit

Permalink
releases 4.0.77
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Jul 20, 2024
1 parent dd4f8ed commit 558d2a4
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vxe-pc-ui",
"version": "4.0.76",
"version": "4.0.77",
"description": "A vue based PC component library",
"scripts": {
"update": "npm install --legacy-peer-deps",
Expand Down
3 changes: 2 additions & 1 deletion packages/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import VxeLink from './link'
import VxeListDesign from './list-design'
import VxeListView from './list-view'
import VxeList from './list'
import VxeLoading from './loading'
import VxeLoading, { LoadingController } from './loading'
import VxeMenu from './menu'
import VxeModal, { ModalController } from './modal'
import VxeNumberInput from './number-input'
Expand Down Expand Up @@ -147,6 +147,7 @@ setLanguage(defaultLanguage)
setTheme('light')

// 兼容老版本
export const loading = LoadingController
export const modal = ModalController
export const drawer = DrawerController
export const print = printHtml
Expand Down
18 changes: 12 additions & 6 deletions packages/dynamics/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { defineComponent, h, createApp, resolveComponent, reactive, createCommentVNode } from 'vue'

import type { VxeModalDefines, VxeModalComponent, VxeDrawerDefines, VxeDrawerComponent } from '../../types'
import type { VxeModalDefines, VxeModalComponent, VxeLoadingComponent, VxeDrawerDefines, VxeLoadingProps, VxeDrawerComponent } from '../../types'

let dynamicContainerElem: HTMLElement

export const dynamicStore = reactive({
modals: [] as VxeModalDefines.ModalOptions[],
drawers: [] as VxeDrawerDefines.DrawerOptions[]
export const dynamicStore = reactive<{
modals: VxeModalDefines.ModalOptions[]
drawers: VxeDrawerDefines.DrawerOptions[]
globalLoading: null | VxeLoadingProps
}>({
modals: [],
drawers: [],
globalLoading: null
})

/**
Expand All @@ -15,7 +20,7 @@ export const dynamicStore = reactive({
const VxeDynamics = defineComponent({
setup () {
return () => {
const { modals, drawers } = dynamicStore
const { modals, drawers, globalLoading } = dynamicStore
return [
modals.length
? h('div', {
Expand All @@ -26,7 +31,8 @@ const VxeDynamics = defineComponent({
? h('div', {
class: 'vxe-dynamics--drawer'
}, drawers.map((item) => h(resolveComponent('vxe-drawer') as VxeDrawerComponent, item)))
: createCommentVNode()
: createCommentVNode(),
globalLoading ? h(resolveComponent('vxe-loading') as VxeLoadingComponent, globalLoading) : createCommentVNode()
]
}
}
Expand Down
20 changes: 19 additions & 1 deletion packages/loading/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,34 @@
import { App } from 'vue'
import { VxeUI } from '@vxe-ui/core'
import VxeLoadingComponent from './src/loading'
import { dynamicApp } from '../dynamics'
import { dynamicApp, dynamicStore, checkDynamic } from '../dynamics'

import type { VxeLoadingProps } from '../../types'

export const VxeLoading = Object.assign({}, VxeLoadingComponent, {
install (app: App) {
app.component(VxeLoadingComponent.name as string, VxeLoadingComponent)
}
})

export const LoadingController = {
open (options?: VxeLoadingProps) {
const opts = Object.assign({}, options)
dynamicStore.globalLoading = {
modelValue: true,
text: opts.text,
icon: opts.icon
}
checkDynamic()
},
close () {
dynamicStore.globalLoading = null
}
}

dynamicApp.component(VxeLoadingComponent.name as string, VxeLoadingComponent)
VxeUI.component(VxeLoadingComponent)
VxeUI.loading = LoadingController

export const Loading = VxeLoading
export default VxeLoading
18 changes: 18 additions & 0 deletions types/components/loading.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,23 @@ export interface VxeLoadingSlots {
default: (params: VxeLoadingSlotTypes.DefaultSlotParams) => any
}

/**
* 全局加载中
*/
export interface LoadingController {
/**
* 打开
* @param options 参数
*/
open(options?: {
icon?: VxeLoadingPropTypes.Icon
text?: VxeLoadingPropTypes.Text
}): void
/**
* 关闭
*/
close(): void
}

export const Loading: typeof VxeLoading
export default VxeLoading
3 changes: 3 additions & 0 deletions types/ui/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { App } from 'vue'
import { VxeUI, getI18n, setConfig } from '@vxe-ui/core'
import { LoadingController } from '../components/loading'
import { ModalController } from '../components/modal'
import { DrawerController } from '../components/drawer'
import { VxePrintDefines } from '../components/print'
Expand Down Expand Up @@ -36,6 +37,7 @@ export interface VxeGlobalStore {
export const globalStore: VxeGlobalStore

// 兼容老版本
export const loading: LoadingController
export const modal: ModalController
export const drawer: DrawerController
export const print: VxePrintDefines.PrintFunction
Expand All @@ -46,6 +48,7 @@ declare module '@vxe-ui/core' {
export interface VxeUIExport {
uiVersion: string
tableVersion: string
loading: LoadingController
modal: ModalController
drawer: DrawerController
dynamicApp: App<Element>
Expand Down

0 comments on commit 558d2a4

Please sign in to comment.