import { createApp } from 'vue';
import pinia from '/@/stores/index';
import App from './App.vue';
import router from './router';
import { directive } from '/@/directive';
import other from '/@/utils/other';
//  引入element
import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css';
import '/@/theme/index.scss';

import 'animate.css';
// 分页组件
import Pagination from '/@/components/Pagination/index.vue';
// 空组件
import Empty from '/@/components/Empty/index.vue';

// 组织架构组件
// import vue3TreeOrg from 'vue3-tree-org';
// import "vue3-tree-org/lib/vue3-tree-org.css";
// 图片预览
import 'viewerjs/dist/viewer.css';
import VueViewer from 'v-viewer';

//exception log
// import { Exceptionless } from "@exceptionless/browser";
import { Exceptionless } from "/@/utils/exceptionless.js";
//  全局配置
import appConfig from "/@/utils/appConfig";

const app = createApp(App);

// 自定义指令和svg组件
directive(app);
other.elSvg(app);
if (appConfig.sendLog) {
    Exceptionless.startup((c: any) => { // 初始化日志系统
        c.apiKey = appConfig.logKey
        c.serverUrl = appConfig.logServerUrl
    });
}
app.config.errorHandler = async (err: any, instance: any, info: any) => {
    // 向追踪服务报告错误
    if (appConfig.clientLog) console.log('globalError: ', err, instance, info);
    if (appConfig.sendLog) await Exceptionless.submitException(<Error>err);
}
// 全局组件挂载
app.component('Pagination', Pagination)
app.component('Empty', Empty);

app.use(pinia).use(router).use(ElementPlus).use(VueViewer).mount('#app');


