diff --git a/src/permission.ts b/src/permission.ts index 0ebd780a..10963534 100644 --- a/src/permission.ts +++ b/src/permission.ts @@ -95,8 +95,20 @@ const homePublicAccessWhiteList = [ '/erp/stock/overview' ] +const homePublicAccessParamPaths = ['/', '/index'] + let homePublicAccessEnabled: boolean | undefined +const isEnabledQueryValue = (value: unknown) => { + const rawValue = Array.isArray(value) ? value[0] : value + return ['1', 'true', 'yes', 'on'].includes(String(rawValue ?? '').toLowerCase()) +} + +const hasHomePublicAccessParam = (query: Recordable = {}) => + isEnabledQueryValue(query.public) || + isEnabledQueryValue(query.homePublic) || + isEnabledQueryValue(query.noLogin) + const isHomePublicAccessEnabled = async () => { if (homePublicAccessEnabled !== undefined) return homePublicAccessEnabled try { @@ -107,8 +119,9 @@ const isHomePublicAccessEnabled = async () => { return homePublicAccessEnabled } -const isPublicHomePath = async (path: string) => { +const isPublicHomePath = async (path: string, query: Recordable = {}) => { if (homePublicAccessWhiteList.indexOf(path) === -1) return false + if (homePublicAccessParamPaths.indexOf(path) !== -1 && !hasHomePublicAccessParam(query)) return false return await isHomePublicAccessEnabled() } @@ -161,7 +174,7 @@ router.beforeEach(async (to, from, next) => { } } } else { - if (whiteList.indexOf(to.path) !== -1 || (await isPublicHomePath(to.path))) { + if (whiteList.indexOf(to.path) !== -1 || (await isPublicHomePath(to.path, to.query))) { next() } else { next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页 diff --git a/src/router/modules/remaining.ts b/src/router/modules/remaining.ts index 797f6e43..fda8f604 100644 --- a/src/router/modules/remaining.ts +++ b/src/router/modules/remaining.ts @@ -53,7 +53,7 @@ const remainingRouter: AppRouteRecordRaw[] = [ { path: '/', component: Layout, - redirect: '/index', + redirect: (to) => ({ path: '/index', query: to.query }), name: 'Root', meta: {}, children: [ diff --git a/src/views/iot/runoverview/index.vue b/src/views/iot/runoverview/index.vue index ab4ec980..718d1906 100644 --- a/src/views/iot/runoverview/index.vue +++ b/src/views/iot/runoverview/index.vue @@ -2,7 +2,7 @@
import dayjs from 'dayjs' import { useFullscreen } from '@vueuse/core' +import { useRoute } from 'vue-router' import { DeviceOperationOverviewApi } from '@/api/iot/deviceOperationOverview' import { DeviceLedgerApi, DeviceLedgerVO } from '@/api/mes/deviceledger' import { OrganizationApi } from '@/api/mes/organization' @@ -75,12 +76,22 @@ import type { defineOptions({ name: 'IotRunOverview' }) const { t } = useI18n() +const route = useRoute() const fullscreenTargetRef = ref() const { isFullscreen, toggle: toggleFullscreen } = useFullscreen(fullscreenTargetRef) const deviceLedgerList = ref([]) const groupOptions = ref([]) let deviceLedgerRequestSeq = 0 +const isEnabledQueryValue = (value: unknown) => { + const rawValue = Array.isArray(value) ? value[0] : value + return ['1', 'true', 'yes', 'on'].includes(String(rawValue ?? '').toLowerCase()) +} + +const isFullscreenLayout = computed( + () => isFullscreen.value || isEnabledQueryValue(route.query.fullscreen ?? route.query.full) +) + const createDateRangeByQuickKey = (key: QuickRangeKey): [string, string] => { const format = 'YYYY-MM-DD HH:mm:ss' const now = dayjs() @@ -453,7 +464,11 @@ onMounted(async () => { } .run-overview-page.is-fullscreen { - height: 100%; + position: fixed; + inset: 0; + z-index: 2000; + width: 100vw; + height: 100vh; padding: 16px; overflow: auto; background: #f5f7fa;