56 lines
1.2 KiB
TypeScript
56 lines
1.2 KiB
TypeScript
/*
|
|
* @Author: 田鑫
|
|
* @Date: 2023-02-21 15:11:01
|
|
* @LastEditors: 田鑫
|
|
* @LastEditTime: 2023-02-21 15:11:02
|
|
* @Description:
|
|
*/
|
|
import type { AppContext, Component, DefineComponent } from 'vue';
|
|
import type { ModalConfig } from '@arco-design/web-vue';
|
|
|
|
import { ModalSimple } from '@/components/_base';
|
|
|
|
type CompType = DefineComponent | Component;
|
|
interface SlotsType {
|
|
default?: CompType;
|
|
header?: CompType;
|
|
close?: CompType;
|
|
}
|
|
|
|
export const useModal = () => {
|
|
const instance = getCurrentInstance();
|
|
|
|
const Modal = AModal;
|
|
|
|
Modal._context = instance?.appContext as AppContext;
|
|
|
|
Modal.simple = (config: ModalConfig, slots: SlotsType) => {
|
|
const { title, content, ..._config } = config || {};
|
|
|
|
const modal = Modal.open({
|
|
..._config,
|
|
simple: false,
|
|
footer: false,
|
|
closable: false,
|
|
content: () =>
|
|
h(
|
|
ModalSimple,
|
|
{
|
|
title,
|
|
content,
|
|
onClose: modal.close,
|
|
},
|
|
{
|
|
default: slots?.default,
|
|
header: slots?.header,
|
|
close: slots?.close,
|
|
},
|
|
),
|
|
});
|
|
|
|
return modal;
|
|
};
|
|
|
|
return { Modal };
|
|
};
|