mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2026-02-02 00:25:22 +08:00
前端和后端源码,合并到一个git仓库中,方便用户下载,避免前后端不匹配的问题
This commit is contained in:
41
jeecgboot-vue3/src/directives/loading.ts
Normal file
41
jeecgboot-vue3/src/directives/loading.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import { createLoading } from '/@/components/Loading';
|
||||
import type { Directive, App } from 'vue';
|
||||
|
||||
const loadingDirective: Directive = {
|
||||
mounted(el, binding) {
|
||||
const tip = el.getAttribute('loading-tip');
|
||||
const background = el.getAttribute('loading-background');
|
||||
const size = el.getAttribute('loading-size');
|
||||
const fullscreen = !!binding.modifiers.fullscreen;
|
||||
const instance = createLoading(
|
||||
{
|
||||
tip,
|
||||
background,
|
||||
size: size || 'large',
|
||||
loading: !!binding.value,
|
||||
absolute: !fullscreen,
|
||||
},
|
||||
fullscreen ? document.body : el
|
||||
);
|
||||
el.instance = instance;
|
||||
},
|
||||
updated(el, binding) {
|
||||
const instance = el.instance;
|
||||
if (!instance) return;
|
||||
instance.setTip(el.getAttribute('loading-tip'));
|
||||
if (binding.oldValue !== binding.value) {
|
||||
if (binding.oldValue !== binding.value) {
|
||||
instance.setLoading?.(binding.value && !instance.loading);
|
||||
}
|
||||
}
|
||||
},
|
||||
unmounted(el) {
|
||||
el?.instance?.close();
|
||||
},
|
||||
};
|
||||
|
||||
export function setupLoadingDirective(app: App) {
|
||||
app.directive('loading', loadingDirective);
|
||||
}
|
||||
|
||||
export default loadingDirective;
|
||||
Reference in New Issue
Block a user