jeecgBootUniapp/src/App.vue

140 lines
2.8 KiB
Vue
Raw Normal View History

2025-04-29 08:37:17 +00:00
<script lang="ts">
2025-05-09 01:42:19 +00:00
import { onLaunch, onShow } from '@dcloudio/uni-app'
2025-04-29 08:37:17 +00:00
import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'
import { beforEach } from '@/router/index'
2025-04-30 01:16:10 +00:00
import { jurisdictionApi } from '@/api/system';
import { useAppStore, useUpdateApp } from '@/store'
2025-05-09 01:42:19 +00:00
import { getLocation } from '@/utils';
2025-04-29 08:37:17 +00:00
export default {
onLaunch: function (options) {
2025-04-30 01:16:10 +00:00
// 检查更新
2025-05-29 02:07:09 +00:00
useUpdateApp().checkAppUpdate()
2025-05-09 01:42:19 +00:00
// 定位
getLocation()
2025-04-29 08:37:17 +00:00
},
onShow: function (options) {
2025-06-09 00:23:21 +00:00
//改造了一下,加了白名单验证
//为了实现实流检定的证书验证页面
//jiang 20250605
// 定义白名单页面
const publicPages = [
'/pages/sljd/index'
]
// 检查当前页面是否在白名单中
const isPublicPage = publicPages.includes(`/${options.path}`)
// 非白名单页面才执行登录检查
if (!isPublicPage) {
if (uni.getStorageSync('logintime') && uni.getStorageSync('logintime') + 1800000 <= Date.now()) {
uni.removeStorageSync('logintime')
uni.navigateTo({
url: '/pages/login/login'
})
return
}
}
2025-06-09 00:23:21 +00:00
// 路由拦截(白名单页面跳过)
2025-04-29 08:37:17 +00:00
setTimeout(() => {
const currentPage = options.path
2025-06-09 00:23:21 +00:00
if (!isPublicPage) {
beforEach({ path: '/' }, { path: currentPage, fullPath: currentPage }, (data) => {
if (data?.path) {
uni.redirectTo({ url: data.path })
}
})
}
2025-04-29 08:37:17 +00:00
}, 100)
2025-06-09 00:23:21 +00:00
// 权限检查(非白名单页面执行)
if (!isPublicPage) {
jurisdictionApi("1827997127165677570").then((res : any) => {
if (res.success) {
const appStore = useAppStore()
appStore.setIsGray(res.result.value)
}
})
}
2025-04-29 08:37:17 +00:00
},
// 全局变量
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>