新增前端vue

This commit is contained in:
2025-11-26 13:55:01 +08:00
parent ae391f1b94
commit ffd5a6ad66
781 changed files with 83348 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
import type { DirectiveBinding, ObjectDirective } from 'vue';
type DocumentHandler = <T extends MouseEvent>(mouseup: T, mousedown: T) => void;
type FlushList = Map<
HTMLElement,
{
documentHandler: DocumentHandler;
bindingFn: (...args: unknown[]) => unknown;
}
>;
const nodeList: FlushList = new Map();
function createDocumentHandler(_el: HTMLElement, binding: DirectiveBinding): DocumentHandler {
return function () {
binding.value();
};
}
// 创建新组件,调用之前创建的组件事件
const ClickOutside: ObjectDirective = {
beforeMount(el, binding) {
for (const { documentHandler } of nodeList.values()) {
documentHandler(el, binding);
}
nodeList.set(el, {
documentHandler: createDocumentHandler(el, binding),
bindingFn: binding.value,
});
},
unmounted(el) {
nodeList.delete(el);
},
};
export default ClickOutside;