-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
cole
committed
Jul 31, 2024
1 parent
c2bf812
commit 8927fa5
Showing
4 changed files
with
92 additions
and
2 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { h, Transition, onMounted } from 'vue' | ||
import { Spin } from 'ant-design-vue' | ||
import { createReactivePlugin, createGlobalNode, createChildApp } from '../../utils/create' | ||
|
||
let uid = 0 | ||
|
||
const defaults = { | ||
group: '__default_group__', | ||
delay: 0 | ||
} | ||
|
||
const Plugin = createReactivePlugin({ | ||
isActive: false | ||
}, { | ||
show (options) { | ||
Plugin.isActive = true | ||
const el = createGlobalNode('pro-loading') | ||
const app = createChildApp({ | ||
setup () { | ||
function onAfterLeave () { | ||
|
||
} | ||
|
||
return () => { | ||
const props = { | ||
onAfterLeave: onAfterLeave | ||
} | ||
return h(Transition, props, Spin) | ||
} | ||
} | ||
}) | ||
}, | ||
hide () { | ||
|
||
}, | ||
install () { | ||
|
||
} | ||
}) | ||
|
||
export default Plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { createApp, reactive } from 'vue' | ||
import { omit } from 'lodash-es' | ||
|
||
const bodyNode = document.body | ||
const nodes = [] | ||
|
||
export function createChildApp (rootComponent, parentApp) { | ||
const appContext = omit(parentApp._context, ['reload']) | ||
|
||
const app = createApp(rootComponent) | ||
app.config.globalProperties = parentApp.config.globalProperties | ||
|
||
Object.assign(app._context, appContext) | ||
return app | ||
} | ||
|
||
export function createGlobalNode (id, className) { | ||
const el = document.createElement('div') | ||
if (className !== undefined) { | ||
el.className = className | ||
} | ||
el.id = id | ||
bodyNode.appendChild(el) | ||
nodes.push(el) | ||
return el | ||
} | ||
|
||
export function removeGlobalNode (el) { | ||
const index = nodes.indexOf(el) | ||
nodes.splice(index, 1) | ||
el.remove() | ||
} | ||
|
||
export function createReactivePlugin (state, plugin) { | ||
const pluginState = reactive(state) | ||
|
||
for (const name in pluginState) { | ||
Object.defineProperty(plugin, name, { | ||
enumerable: true, | ||
get () { | ||
return pluginState[name] | ||
}, | ||
set (value) { | ||
pluginState[name] = value | ||
} | ||
}) | ||
} | ||
|
||
return plugin | ||
} |