From 66855e95ac0508f04f52d10e32fdc0e1b777c26a Mon Sep 17 00:00:00 2001 From: liutao <790864623@qq.com> Date: Fri, 10 Jul 2026 15:44:32 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E5=A2=9E=E5=8A=A0=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=9D=A5=E6=8E=A7=E5=88=B6=E6=98=AF=E5=90=A6=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/permission.ts | 17 +++++++++++++++-- src/router/modules/remaining.ts | 2 +- src/views/iot/runoverview/index.vue | 19 +++++++++++++++++-- 3 files changed, 33 insertions(+), 5 deletions(-) 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;