import config from "./config"
import api from './api'
import tool from './utils/tool'
import http from "./utils/request"
import {
    permission,
    rolePermission
} from './utils/permission'
import xTable from './components/xTable'
import xTableColumn from './components/xTable/column.js'
import xTableSelect from './components/xTableSelect'
import xUpload from './components/xUpload'
import xUploadMultiple from './components/xUpload/multiple'
import xUploadFile from './components/xUpload/file'
import xDialog from './components/xDialog'
import xItem from './components/xForm/item'
import xUser from './components/xUser'
import xAvatar from './components/xAvatar'
import xUpdate from './components/xUpdate'
import xTitle from './components/xTitle'
import xTabledialog from './components/xTabledialog'
import xForm from './components/xForm'
import xFormTable from './components/xFormTable'
import xFilterBar from './components/xFilterBar'
import xStatusIndicator from './components/xMini/StatusIndicator'
import xTrend from './components/xMini/Trend'
import xQrCode from './components/xQrCode'
import xPageHeader from './components/xPageHeader'
import xSelect from './components/xSelect'
import xWaterMark from './components/xWaterMark'
import {
    Flexbox,
    FlexboxItem
} from './components/Flexbox'
import auth from './directives/auth'
import auths from './directives/auths'
import authsAll from './directives/authsAll'
import role from './directives/role'
import time from './directives/time'
import copy from './directives/copy'
import errorHandler from './utils/errorHandler'
import * as elIcons from '@element-plus/icons-vue'
import * as xIcons from './assets/icons'
export default {
    install(app) {
        //挂载全局对象
        app.config.globalProperties.$config = config;
        app.config.globalProperties.$tool = tool;
        app.config.globalProperties.$http = http;
        app.config.globalProperties.$api = api;
        app.config.globalProperties.$auth = permission;
        app.config.globalProperties.$role = rolePermission;
        //注册全局组件
        app.component('flexbox', Flexbox)
        app.component('flexbox-item', FlexboxItem)
        app.component('xItem', xItem);
        app.component('xUser', xUser);
        app.component('xAvatar', xAvatar);
        app.component('xUpdate', xUpdate);
        app.component('xUpload', xUpload);
        app.component('xUploadMultiple', xUploadMultiple);
        app.component('xUploadFile', xUploadFile);
        app.component('xTable', xTable);
        app.component('xTableColumn', xTableColumn);
        app.component('xTableSelect', xTableSelect);
        app.component('xFilterBar', xFilterBar);
        app.component('xForm', xForm);
        app.component('xFormTable', xFormTable);
        app.component('xPageHeader', xPageHeader);
        app.component('xSelect', xSelect);
        app.component('xDialog', xDialog);
        app.component('xTitle', xTitle);
        app.component('xTabledialog', xTabledialog);
        app.component('xWaterMark', xWaterMark);
        app.component('xQrCode', xQrCode);
        app.component('xStatusIndicator', xStatusIndicator);
        app.component('xTrend', xTrend);
        //注册全局指令
        app.directive('auth', auth)
        app.directive('auths', auths)
        app.directive('auths-all', authsAll)
        app.directive('role', role)
        app.directive('time', time)
        app.directive('copy', copy)
        //统一注册el-icon图标
        for (let icon in elIcons) {
            app.component(`ElIcon${icon}`, elIcons[icon])
        }
        //统一注册x-icon图标
        for (let icon in xIcons) {
            app.component(`xIcon${icon}`, xIcons[icon])
        }
        //关闭async-validator全局控制台警告
        window.ASYNC_VALIDATOR_NO_WARNING = 1
        //全局代码错误捕捉
        app.config.errorHandler = errorHandler
    }
}