|
|
|
@ -10,6 +10,7 @@ import InnerLink from '@/layout/components/InnerLink/index.vue'; |
|
|
|
import { ref, computed } from 'vue'; |
|
|
|
import { createCustomNameComponent } from '@/utils/createCustomNameComponent'; |
|
|
|
import { isHttp } from '@/utils/validate'; |
|
|
|
import { useUserStore } from '@/store/modules/user'; |
|
|
|
|
|
|
|
// 匹配views里面所有的.vue文件
|
|
|
|
const modules = import.meta.glob('./../../views/**/*.vue'); |
|
|
|
@ -27,12 +28,26 @@ export interface SystemCodeOption { |
|
|
|
export const CATCH_ALL_ROUTE_NAME = 'CatchAll404'; |
|
|
|
|
|
|
|
export const systemCodeOptions: SystemCodeOption[] = [ |
|
|
|
{ label: '首页', value: 'planindex', icon: 'HomeFilled', iframeUrl: 'http://localhost:85/loginByUserId?userId=1&secretKey=zdxt2024emergencyPlatForm' }, |
|
|
|
{ label: '首页', value: 'planindex', icon: 'HomeFilled', iframeUrl: 'http://localhost:85/loginByUserId' }, |
|
|
|
{ label: '执法监督码', value: 'supervisionCode', icon: 'Document' }, |
|
|
|
{ label: '后台管理', value: 'authService', icon: 'Setting' } |
|
|
|
]; |
|
|
|
|
|
|
|
export const usePermissionStore = defineStore('permission', () => { |
|
|
|
/** |
|
|
|
* 根据基础 iframeUrl 动态拼接登录凭据参数 |
|
|
|
*/ |
|
|
|
const buildIframeUrl = (baseUrl: string): string => { |
|
|
|
if (!baseUrl) return ''; |
|
|
|
const userStore = useUserStore(); |
|
|
|
const params = new URLSearchParams(); |
|
|
|
if (userStore.v1SystemCredential) { |
|
|
|
params.set('v1_system_credential', userStore.v1SystemCredential); |
|
|
|
} |
|
|
|
const separator = baseUrl.includes('?') ? '&' : '?'; |
|
|
|
return baseUrl + separator + params.toString(); |
|
|
|
}; |
|
|
|
|
|
|
|
const routes = ref<RouteRecordRaw[]>([]); |
|
|
|
const addRoutes = ref<RouteRecordRaw[]>([]); |
|
|
|
const defaultRoutes = ref<RouteRecordRaw[]>([]); |
|
|
|
@ -49,7 +64,7 @@ export const usePermissionStore = defineStore('permission', () => { |
|
|
|
/** 当前是否处于 iframe 全屏模式 */ |
|
|
|
const iframeMode = ref<boolean>(!!(savedOption?.iframeUrl || savedOption?.fullscreenRoute)); |
|
|
|
/** 当前 iframe 地址 */ |
|
|
|
const iframeUrl = ref<string>(savedOption?.iframeUrl || ''); |
|
|
|
const iframeUrl = ref<string>(savedOption?.iframeUrl ? buildIframeUrl(savedOption.iframeUrl) : ''); |
|
|
|
/** 当前全屏 Vue 路由地址 */ |
|
|
|
const fullscreenRoute = ref<string>(savedOption?.fullscreenRoute || ''); |
|
|
|
|
|
|
|
@ -161,7 +176,7 @@ export const usePermissionStore = defineStore('permission', () => { |
|
|
|
// 判断是否为全屏模式(iframe 或 Vue 路由)
|
|
|
|
if (option?.iframeUrl || option?.fullscreenRoute) { |
|
|
|
iframeMode.value = true; |
|
|
|
iframeUrl.value = option.iframeUrl || ''; |
|
|
|
iframeUrl.value = option.iframeUrl ? buildIframeUrl(option.iframeUrl) : ''; |
|
|
|
fullscreenRoute.value = option.fullscreenRoute || ''; |
|
|
|
setSidebarRouters([]); |
|
|
|
if (option.fullscreenRoute) { |
|
|
|
@ -217,7 +232,7 @@ export const usePermissionStore = defineStore('permission', () => { |
|
|
|
sessionStorage.setItem(SYSTEM_CODE_KEY, 'planindex'); |
|
|
|
const defaultOption = systemCodeOptions.find((o) => o.value === 'planindex'); |
|
|
|
iframeMode.value = defaultOption?.iframeUrl ? true : false; |
|
|
|
iframeUrl.value = defaultOption?.iframeUrl || ''; |
|
|
|
iframeUrl.value = defaultOption?.iframeUrl ? buildIframeUrl(defaultOption.iframeUrl) : ''; |
|
|
|
}; |
|
|
|
|
|
|
|
/** 根据后端返回的路由数据,动态过滤可见的系统分类选项(首页始终显示) */ |
|
|
|
|