import './assets/main.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import { createPinia } from 'pinia'
import Cookies from 'js-cookie';
import 'normalize.css/normalize.css';
import moment from 'moment';
import Echarts from 'echarts';
import App from './App.vue'
import router from './router'
import zhCn from "element-plus/es/locale/lang/zh-cn"
import 'virtual:svg-icons-register'
// import './permission' // permission control
// import permission from '@/directive/permission/index.js' // 权限判断指令

import piniaPersist from 'pinia-plugin-persist'
import MyPlugin from '@/utils/print' // 打印
const app = createApp(App)
//pinia持久化
const pinia = createPinia()
pinia.use(piniaPersist)



for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}
// 设置全局属性
app.config.globalProperties.$echarts = Echarts;
//设置全局方法
app.config.globalProperties.dateFormatA = function (row, column) {
  let date = row[column.property];
  if (this.isEmptyObjVue(date)) {
    return '';
  }
  return moment(date).format('YYYY-MM-DD HH:mm:ss');
};
app.config.globalProperties.formateTime = function (date) {
  if (this.isEmptyObjVue(date)) {
    return '';
  }
  return moment(date).format('YYYY-MM-DD HH:mm:ss');
};
app.config.globalProperties.formateDay = function (date) {
  if (this.isEmptyObjVue(date)) {
    return '';
  }
  return moment(date).format('YYYY-MM-DD');
};
// 判空
app.config.globalProperties.isEmptyObjVue = function (obj) {
  if (obj == null || obj == undefined || ("" + obj) == "") {
    return true;
  }
  return false;
};
//分页插件
zhCn.el.pagination.total = "共："+`{total}`+"条"
zhCn.el.pagination.goto = "跳转至"
// 注册全局指令
// app.directive('permission', permission);
// 使用 Print 插件
app.use(MyPlugin);
// 使用 ElementPlus 插件
app.use(ElementPlus, {
  size: Cookies.get('size') || 'medium', // set element-ui default size
  locale: zhCn
});
app.use(pinia)
app.use(router)
// console.log('环境变量：', import.meta.env);

app.mount('#app')
