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 scTable from './components/scTable'
import scTableColumn from './components/scTable/column.js'
import scFilterBar from './components/scFilterBar'
import scUpload from './components/scUpload'
import scUploadMultiple from './components/scUpload/multiple'
import scUploadFile from './components/scUpload/file'
import scFormTable from './components/scFormTable'
import scTableSelect from './components/scTableSelect'
import scPageHeader from './components/scPageHeader'
import scSelect from './components/scSelect'
import scDialog from './components/scDialog'
import scForm from './components/scForm'
import scTitle from './components/scTitle'
import scWaterMark from './components/scWaterMark'
import scQrCode from './components/scQrCode'
import ossImgUpload from "./components/scUpload/uploadImg";
import ossImgListUpload from "./components/scUpload/uploadListImg";
import scDatePicker from "./components/scDatePicker";
import scMultipleSelect from "./components/scMultipleSelect";
import scInput from "./components/scInput";
import scVgInput from "./components/scInput/inputVague";
import scSearch from "./components/scSearch";
import scTableSearch from "./components/scTable/components/headerSearch";
import herderMultipleSearch from "./components/scTable/components/herderMultipleInput";
import scExport from "./components/scExport";
import scExportList from "./components/scExport/exportList";
import scImport from "./components/scImport";
import scCustomer from "./components/scCustomer"

import scStatusIndicator from './components/scMini/scStatusIndicator'
import scTrend from './components/scMini/scTrend'

import authSetup from './directives/authSetup'
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 number from './directives/number'
import focus from './directives/focus'
import draggable from './directives/draggable'
import errorHandler from './utils/errorHandler'

import * as elIcons from '@element-plus/icons-vue'
import * as scIcons from './assets/icons'
import * as socketApi from "@/utils/websocket";
import * as sseApi from "@/utils/sseService";

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.config.globalProperties.$socketApi = socketApi;
		app.config.globalProperties.$seeApi = sseApi;

		//注册全局组件
		app.component('scTable', scTable);
		app.component('scTableColumn', scTableColumn);
		app.component('scFilterBar', scFilterBar);
		app.component('scUpload', scUpload);
		app.component('scUploadMultiple', scUploadMultiple);
		app.component('scUploadFile', scUploadFile);
		app.component('scFormTable', scFormTable);
		app.component('scTableSelect', scTableSelect);
		app.component('scPageHeader', scPageHeader);
		app.component('scSelect', scSelect);
		app.component('scDialog', scDialog);
		app.component('scForm', scForm);
		app.component('scTitle', scTitle);
		app.component('scWaterMark', scWaterMark);
		app.component('scQrCode', scQrCode);
		app.component('scStatusIndicator', scStatusIndicator);
		app.component('scTrend', scTrend);
		app.component('ossImgUpload', ossImgUpload);
		app.component('ossImgListUpload', ossImgListUpload);
		app.component('scDatePicker', scDatePicker);
		app.component('scMultipleSelect', scMultipleSelect);
		app.component('scInput', scInput);
		app.component('scVgInput', scVgInput);
		app.component('scSearch', scSearch);
		app.component('scTableSearch', scTableSearch);
		app.component('herderMultipleSearch', herderMultipleSearch);
		app.component('scExport', scExport);
		app.component('scExportList', scExportList);
		app.component('scImport', scImport);
		app.component('scCustomer', scCustomer);

		//注册全局指令
		app.directive('authSetup', authSetup)
		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)
		app.directive('number', number)
		app.directive('focus', focus)
		app.directive('draggable', draggable)

		//统一注册el-icon图标
		for(let icon in elIcons){
			app.component(`ElIcon${icon}`, elIcons[icon])
		}
		//统一注册sc-icon图标
		for(let icon in scIcons){
			app.component(`ScIcon${icon}`, scIcons[icon])
		}

		//关闭async-validator全局控制台警告
		window.ASYNC_VALIDATOR_NO_WARNING = 1

		//全局代码错误捕捉
		app.config.errorHandler = errorHandler
	}
}
