<script lang="ts">
	import { onLaunch, onShow } from '@dcloudio/uni-app'
	import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'
	import { beforEach } from '@/router/index'
	import { jurisdictionApi } from '@/api/system';
	import { useAppStore, useUpdateApp } from '@/store'
	import { getLocation } from '@/utils';
	export default {
		onLaunch: function (options) {
			// 检查更新
			// useUpdateApp().checkAppUpdate()
			// 定位
			getLocation()
		},
		onShow: function (options) {
			if (uni.getStorageSync('logintime') && uni.getStorageSync('logintime') + 1800000 <= Date.now()) {  //登录半小时自动注销 需重新登陆 
				uni.removeStorageSync('logintime')
				uni.navigateTo({
					url: '/pages/login/login'
				})
				return
			}
			// 首次进入页面时路由拦截
			setTimeout(() => {
				const currentPage = options.path
				beforEach({ path: '/' }, { path: currentPage, fullPath: currentPage }, (data) => {
					if (data?.path) {
						uni.redirectTo({ url: data.path })
					}
				})
			}, 100)

			jurisdictionApi("1827997127165677570").then((res : any) => {
				// 0正常 1灰化
				if (res.success) {
					const appStore = useAppStore()
					appStore.setIsGray(res.result.value) // 更新状态
				}
			})
		},

		// 全局变量
		globalData: {
			isLocalConfig: true,
			systemInfo: uni.getSystemInfoSync(),
			navHeight: 44,
		},
	}
</script>

<style lang="scss">
	.gray {
		filter: grayscale(1);
	}

	body {
		font-size: 14px;
		color: #333333;
		font-family:
			Helvetica Neue,
			Helvetica,
			sans-serif;
	}

	uni-page-body {
		height: 100%;

		&>uni-view {
			height: 100%;
		}
	}

	.shadow-warp {
		position: relative;
		box-shadow: 0 0 5px rgba(168, 92, 92, 0.1);
	}

	/* stylelint-disable selector-type-no-unknown */
	button::after {
		border: none;
	}

	swiper,
	scroll-view {
		flex: 1;
		height: 100%;
		overflow: hidden;
	}

	image {
		width: 100%;
		height: 100%;
		vertical-align: middle;
	}

	// 单行省略，优先使用 unocss: text-ellipsis
	.ellipsis {
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	// 两行省略
	.ellipsis-2 {
		display: -webkit-box;
		overflow: hidden;
		text-overflow: ellipsis;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		word-break: break-all;
	}

	// 三行省略
	.ellipsis-3 {
		display: -webkit-box;
		overflow: hidden;
		text-overflow: ellipsis;
		-webkit-line-clamp: 3;
		-webkit-box-orient: vertical;
	}
</style>