import { App } from 'vue';
//引入按钮权限
import { permission } from '@/directives/permission'
// 文本输入框回车事件
import { enterfocus } from '@/directives/enterfocus';
// 正则匹配
import { clearOnlyRegex } from '@/directives/clearOnlyRegex';
// 滚动到底部
import { tableScrollBottom } from '@/directives/tablescrollbottom';
import loadingDirective from '@/directives/loading';

function useDirectives(app: App) {
    app.directive('permission', permission)
    app.directive('enterfocus', enterfocus)
    app.directive('clearOnlyRegex', clearOnlyRegex)
    app.directive('tableScrollBottom', tableScrollBottom)
    app.directive('loadings', loadingDirective);
    // TODO 待解决 动态导入自定义指令模块-打包没有生效
    // const modules = import.meta.glob("./directives/**/*.ts");
    // Object.keys(modules).forEach((name) => {
    //     // 由于vite不支持import导入变量，用于忽略
    //     import(/* @vite-ignore */ name).then((module) => {
    //         // 遍历模块中的指令并注册
    //         Object.keys(module).forEach((key) => {
    //             app.directive(key, module[key]);
    //         });
    //     });
    // });
    // app.directive('enterfocus', enterfocus)
}

export { useDirectives }