import { createApp,defineComponent,h } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import './assets/iconfont/iconfont.css'
import './assets/iconfont/iconfont.js'
import './assets/iconfont2/iconfont.css'
import flexible from './tool/flexible.js'
import 'ant-design-vue/dist/antd.css';
import Antd from 'ant-design-vue';
import './assets/style/style.less'
import VueLazyload from "vue-lazyload";
import i18n from './lang/index'
import { getBrowserInfo, murmur } from './tool/util'
import "../node_modules/@flaticon/flaticon-uicons/css/all/all.css"
import { Https } from "@/tool/https";
// import "@/tool/color-thief.js";
// import "@/tool/fabric.brushes.js";
// import "@/tool/fabric.min.js";
const app = createApp(App);
flexible()

import { getCookie, setCookie } from "@/tool/cookie";
router.beforeEach((to, from, next) => {
	if(to.name == "login"){
		if(window.location.search.substring(1) != 'oldHis'){
			isMurmur()
		}
	}
	next();
  });
async function isMurmur() {
	let murmurStr: any = localStorage.getItem('murmurStr')
	let id: any = localStorage.getItem('id')
	// let isSxis = false
	let data = {
		browserIdentifiers: murmurStr,
		id:id?id:window.location.search.substring(1)
	}
	// await Https.axiosPost(Https.httpUrls.existNoLoginRequired, data)
	// 	.then((rv) => {
	// 		isSxis = rv
	// 	})
	// 	.catch((res) => {
	// 	});
	if(data.id){
		Https.axiosPost(Https.httpUrls.noLoginRequired, data)
		.then((rv) => {
			let isTest = rv.systemUser == 3 ? true : false
			let isBeginner = rv.isBeginner == 1 ? true : false
			setCookie("isMurmur", true);
			setCookie("token", rv.token);
			setCookie("isTest", isTest);
			setCookie("isBeginner", isBeginner);
			setCookie("isBeginnerNum", 0);//从第一步开始，机器人开始的话就是从第二部开始
			setCookie("userInfo", JSON.stringify(rv));
			sessionStorage.setItem('isTimeOne', JSON.stringify(false));//是否需要公告 提示 弹窗
			let randomNum: any = Math.floor(Math.random() * 9000000000000000) + 1000000000000000;
			sessionStorage.setItem('sessionId', randomNum);
			router.push("/home");
			if(window.location.search.substring(1)){
				localStorage.setItem('id',window.location.search.substring(1))
			}
		})
		.catch((res) => {
		});
	}
	
}

// app.directive('cliAdmin', {
// 	mounted(el, binding) {
// 		el.style.cursor = 'pointer'
// 	},
// 	updated (el,binding) {
// 		// let value = binding.value
// 		// if(value.state){
// 		// 	el.firstElementChild.classList.add(`cliAdmin_${value.type}`)
// 		// 	setTimeout(()=>{
// 		// 		el.firstElementChild.classList.remove(`cliAdmin_${value.type}`)
// 		// 	},500)
// 		// }
// 	}
// });

let loadingParam = {
	loading: require('./assets/images/homePage/loading.gif'),
	attempt: 1
}
app.use(store).use(router).use(Antd).use(VueLazyload, loadingParam).use(i18n).mount('#app')

