import App from './App'

import DictTag from "@/components/DictTag/index.vue"

/* 全局挂载请求库 */
import GraceRequest from '@/Grace6/js/request.js'
import graceJS from "@/Grace6/js/grace.js";
import router from '@/router/router.js'
import {
	CCPrintingAPI
} from "@/unit/CCPrintingAPI.min.vue.js";
import {
	baseURL
} from '@/api/env.js'
import {
	antiShake,
	hideBoard,
	parseTime
} from "@/unit/default.js"
import pinia from "@/stores/index.js"
import {
	goHome,
	goBack
} from "@/unit/navigate.js"
import {
	permission
} from "@/unit/rule.js"
// http://192.168.1.94:48080
// http://218.2.10.30:48080
// http://113.105.183.190:8181/
// uni.$baseUrl = "http://192.168.1.44:48080";
// uni.$baseUrl = "http://192.168.1.69:48080";
// uni.$baseUrl = "http://192.168.1.94:48080";
// uni.$baseUrl = "http://2227el9013.iok.la";
// uni.$baseUrl = "http://192.168.1.97:48080";
// uni.$baseUrl = "";
// uni.$baseUrl = "http://113.105.183.190:48028";
// uni.$baseUrl = "http://192.168.1.32:48080";
uni.$baseUrl = "http://113.105.183.190:15980";
// uni.$baseUrl = "http://192.168.1.26:48080";
// uni.$baseUrl = "http://113.105.183.190:15980";
// uni.$baseUrl = "http://113.105.183.190:48159";
// uni.$baseUrl = "http://61.155.26.34:36936";
// uni.$baseUrl = "http://2227el9013.iok.la";
// uni.$baseUrl = "http://218.2.10.30:48080";
// uni.$baseUrl = "http://192.168.1.85:48080"; // dev
// uni.$baseUrl = "https://222jp79013zl.vicp.fun"; 
// uni.$baseUrl = "http://113.105.183.190:48064";
// uni.$baseUrl = "http://113.105.183.190:48080";
// uni.$baseUrl = "http://113.105.183.190:48163";
// uni.$baseUrl = "http://113.105.183.190:48167";
// uni.$baseUrl = "http://192.168.2.253:48080";
// uni.$baseUrl = "http://47.107.70.17:48080";
// uni.$useStore = useStore;
uni.$debounce = antiShake;
uni.gRequest = GraceRequest;
uni.$grace = graceJS;
uni.$isPda = false;
uni.$isPhone = false;
uni.$isPad = false;
uni.$hideKeyBoard = hideBoard;

// 自定义拦截器
import {
	reqAll,
	reqGet,
	reqPut,
	reqPost,
	reqDelete
} from '@/api/index.js'

uni.CCPrintingAPI = CCPrintingAPI;
uni.$reqAll = reqAll;
uni.$reqGet = reqGet;
uni.$reqPut = reqPut;
uni.$reqPost = reqPost;
uni.$reqDelete = reqDelete;

uni.$goHome = goHome;
uni.$goBack = goBack;

// 判断是否是平板
uni.getSystemInfo({
	success: (res) => {
		if (res.screenWidth > 620) {
			uni.$isPad = true;
		}
		if (res.screenWidth > 320 && res.screenWidth < 620) {
			uni.$isPhone = true;
		}
		if (res.screenWidth <= 320) {
			uni.$isPda = true;
		}
	}
});

// 解决 global is not defined 报错问题
// if (typeof window.global === "undefined"){  
//    window.global = window;
// }
// #ifndef VUE3
import Vue from 'vue'
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
	...App
})
// app.use(Directives);
app.$mount()
// #endif

// #ifdef VUE3
import {
	createSSRApp
} from 'vue'

export function createApp() {
	const app = createSSRApp(App)
	app.component('DictTag', DictTag)
	app.use(router)
	app.use(pinia)
	// 挂载全局指令
	app.config.globalProperties.$permission = permission;
	app.config.globalProperties.$parseTime = parseTime;
	uni.getSystemInfo({
		success: (res) => {
			if (res.screenWidth > 620) {
				app.config.globalProperties.isPad = true;
				app.config.globalProperties.padWidth = res.screenWidth;
				app.config.globalProperties.padHeight = res.windowHeight;
			}
			if (res.screenWidth > 320 && res.screenWidth < 620) {
				app.config.globalProperties.isPhone = true;
				app.config.globalProperties.phoneWidth = res.screenWidth;
				app.config.globalProperties.phoneHeight = res.windowHeight;
			}
			if (res.screenWidth <= 320) {
				app.config.globalProperties.isPda = true;
				app.config.globalProperties.pdaWidth = res.screenWidth;
				app.config.globalProperties.pdaHeight = res.windowHeight;
			}
		}
	});
	return {
		app
	}
}
// #endif