Browse Source

修复菜单数据不全时的报错

yanglzh 3 years ago
parent
commit
fc6818c875

+ 1 - 3
.env.production

@@ -5,6 +5,4 @@ ENV = 'production'
 VITE_PUBLIC_PATH = /
 
 # 线上环境接口地址
-VITE_API_URL = '/api/v1'
-
-
+VITE_API_URL = 'http://101.200.198.249:8899/api/v1'

+ 2 - 2
CHANGELOG.md

@@ -144,7 +144,7 @@
 `2021.08.14`
 
 - 🌟 更新 依赖更新最新版本
-- 🎯 优化 菜单高亮(详情且详情设置了 meta.isHide 时,顶级菜单高亮),感谢群友@YourObject
+- 🎯 优化 菜单高亮(详情且详情设置了 meta?.isHide 时,顶级菜单高亮),感谢群友@YourObject
 - 🎯 优化 详情路径写法:如父级(/pages/filtering),那么详情为(/pages/filtering/details?id=1)。这样写可实现(详情时,父级菜单高亮),否则写成(/pages/filteringDetails?id=1)顶级菜单将不会高亮。可参考:`页面/过滤筛选组件`,点击当前图片进行测试
 - 🎯 优化 tagsView 右键菜单全屏时,打开的界面高度问题
 - 🎯 优化 图表批量 resize 问题
@@ -303,5 +303,5 @@
 
 - 🎉 新增 更新日志文件 `CHANGELOG.md`,以后每次更新都会在这里显示对应内容
 - 🌟 更新 依赖更新最新版本
-- 🐞 修复 分栏、经典布局路由设置 `meta.isHide` 为 `true` 时报错问题,感谢群友@29、@芭芭拉
+- 🐞 修复 分栏、经典布局路由设置 `meta?.isHide` 为 `true` 时报错问题,感谢群友@29、@芭芭拉
 - 🐞 修复 经典布局点击 `tagsView` 左侧菜单数据不变问题

+ 1 - 1
src/api/system/menu/index.ts

@@ -10,7 +10,7 @@ export function getMenuList(query:Object) {
 
 export function getUserMenus() {
     return request({
-        url: '/api/v1/system/user/getUserMenus',
+        url: '/system/user/getUserMenus',
         method: 'get'
     })
 }

+ 1 - 1
src/layout/component/aside.vue

@@ -90,7 +90,7 @@ export default defineComponent({
 		// 路由过滤递归函数
 		const filterRoutesFun = (arr: Array<object>) => {
 			return arr
-				.filter((item: any) => !item.meta.isHide)
+				.filter((item: any) => !item.meta?.isHide)
 				.map((item: any) => {
 					item = Object.assign({}, item);
 					if (item.children) item.children = filterRoutesFun(item.children);

+ 8 - 8
src/layout/component/columnsAside.vue

@@ -13,19 +13,19 @@
 						}
 					"
 					:class="{ 'layout-columns-active': liIndex === k, 'layout-columns-hover': liHoverIndex === k }"
-					:title="v.meta.title.indexOf('.')>0?$t(v.meta.title):v.meta.title"
+					:title="v.meta?.title.indexOf('.')>0?$t(v.meta?.title):v.meta?.title"
 				>
-					<div :class="setColumnsAsidelayout" v-if="!v.meta.isLink || (v.meta.isLink && v.meta.isIframe)">
-						<SvgIcon :name="v.meta.icon" />
+					<div :class="setColumnsAsidelayout" v-if="!v.meta?.isLink || (v.meta?.isLink && v.meta.isIframe)">
+						<SvgIcon :name="v.meta?.icon" />
 						<div class="columns-vertical-title font12">
-							{{tMenuTitle(v.meta.title)}}
+							{{tMenuTitle(v.meta?.title)}}
 						</div>
 					</div>
 					<div :class="setColumnsAsidelayout" v-else>
-						<a :href="v.meta.isLink" target="_blank">
-							<SvgIcon :name="v.meta.icon" />
+						<a :href="v.meta?.isLink" target="_blank">
+							<SvgIcon :name="v.meta?.icon" />
 							<div class="columns-vertical-title font12">
-								{{tMenuTitle(v.meta.title)}}
+								{{tMenuTitle(v.meta?.title)}}
 							</div>
 						</a>
 					</div>
@@ -154,7 +154,7 @@ export default defineComponent({
 		// 路由过滤递归函数
 		const filterRoutesFun = (arr: Array<object>) => {
 			return arr
-				.filter((item: any) => !item.meta.isHide)
+				.filter((item: any) => !item.meta?.isHide)
 				.map((item: any) => {
 					item = Object.assign({}, item);
 					if (item.children) item.children = filterRoutesFun(item.children);

+ 4 - 4
src/layout/component/main.vue

@@ -3,7 +3,7 @@
 		<el-scrollbar
 			class="layout-scrollbar"
 			ref="layoutScrollbarRef"
-			:style="{ padding: currentRouteMeta.isLink && currentRouteMeta.isIframe ? 0 : '', transition: 'padding 0.3s ease-in-out' }"
+			:style="{ padding: currentRoutemeta?.isLink && currentRouteMeta.isIframe ? 0 : '', transition: 'padding 0.3s ease-in-out' }"
 		>
 			<LayoutParentView :style="{ minHeight: `calc(100vh - ${headerHeight})` }" />
 			<Footer v-if="getThemeConfig.isFooter" />
@@ -41,7 +41,7 @@ export default defineComponent({
 		});
 		// 设置 main 的高度
 		const initHeaderHeight = () => {
-			const bool = state.currentRouteMeta.isLink && state.currentRouteMeta.isIframe;
+			const bool = state.currentRoutemeta?.isLink && state.currentRouteMeta.isIframe;
 			let { isTagsview } = store.state.themeConfig.themeConfig;
 			if (isTagsview) return (state.headerHeight = bool ? `85px` : `114px`);
 			else return (state.headerHeight = `51px`);
@@ -60,7 +60,7 @@ export default defineComponent({
 			() => route.path,
 			() => {
 				state.currentRouteMeta = route.meta;
-				const bool = state.currentRouteMeta.isLink && state.currentRouteMeta.isIframe;
+				const bool = state.currentRoutemeta?.isLink && state.currentRouteMeta.isIframe;
 				state.headerHeight = bool ? `85px` : `114px`;
 				proxy.$refs.layoutScrollbarRef.update();
 			}
@@ -68,7 +68,7 @@ export default defineComponent({
 		// 监听 themeConfig 配置文件的变化,更新菜单 el-scrollbar 的高度
 		watch(store.state.themeConfig.themeConfig, (val) => {
 			state.currentRouteMeta = route.meta;
-			const bool = state.currentRouteMeta.isLink && state.currentRouteMeta.isIframe;
+			const bool = state.currentRoutemeta?.isLink && state.currentRouteMeta.isIframe;
 			state.headerHeight = val.isTagsview ? (bool ? `85px` : `114px`) : '51px';
 			if (val.isFixedHeaderChange !== val.isFixedHeader) {
 				if (!proxy.$refs.layoutScrollbarRef) return false;

+ 3 - 3
src/layout/navBars/breadcrumb/breadcrumb.vue

@@ -8,12 +8,12 @@
 		/>
 		<el-breadcrumb class="layout-navbars-breadcrumb-hide">
 			<transition-group name="breadcrumb" mode="out-in">
-				<el-breadcrumb-item v-for="(v, k) in breadcrumbList" :key="v.meta.title">
+				<el-breadcrumb-item v-for="(v, k) in breadcrumbList" :key="v.meta?.title">
 					<span v-if="k === breadcrumbList.length - 1" class="layout-navbars-breadcrumb-span">
-						<SvgIcon :name="v.meta.icon" class="layout-navbars-breadcrumb-iconfont" v-if="getThemeConfig.isBreadcrumbIcon" />{{ v.meta.title.indexOf('.')>0?$t(v.meta.title):v.meta.title }}
+						<SvgIcon :name="v.meta?.icon" class="layout-navbars-breadcrumb-iconfont" v-if="getThemeConfig.isBreadcrumbIcon" />{{ v.meta?.title.indexOf('.')>0?$t(v.meta?.title):v.meta?.title }}
 					</span>
 					<a v-else @click.prevent="onBreadcrumbClick(v)">
-						<SvgIcon :name="v.meta.icon" class="layout-navbars-breadcrumb-iconfont" v-if="getThemeConfig.isBreadcrumbIcon" />{{ v.meta.title.indexOf('.')>0?$t(v.meta.title):v.meta.title }}
+						<SvgIcon :name="v.meta?.icon" class="layout-navbars-breadcrumb-iconfont" v-if="getThemeConfig.isBreadcrumbIcon" />{{ v.meta?.title.indexOf('.')>0?$t(v.meta?.title):v.meta?.title }}
 					</a>
 				</el-breadcrumb-item>
 			</transition-group>

+ 1 - 1
src/layout/navBars/breadcrumb/index.vue

@@ -62,7 +62,7 @@ export default defineComponent({
 		// 路由过滤递归函数
 		const filterRoutesFun = (arr: Array<object>) => {
 			return arr
-				.filter((item: any) => !item.meta.isHide)
+				.filter((item: any) => !item.meta?.isHide)
 				.map((item: any) => {
 					item = Object.assign({}, item);
 					if (item.children) item.children = filterRoutesFun(item.children);

+ 6 - 6
src/layout/navBars/breadcrumb/search.vue

@@ -16,8 +16,8 @@
 				</template>
 				<template #default="{ item }">
 					<div>
-						<SvgIcon :name="item.meta.icon" class="mr5" />
-						{{ item.meta.title.indexOf('.')>0?$t(item.meta.title):item.meta.title }}
+						<SvgIcon :name="item.meta?.icon" class="mr5" />
+						{{ item.meta?.title.indexOf('.')>0?$t(item.meta?.title):item.meta?.title }}
 					</div>
 				</template>
 			</el-autocomplete>
@@ -79,8 +79,8 @@ export default defineComponent({
 			return (restaurant: Restaurant) => {
 				return (
 					restaurant.path.toLowerCase().indexOf(queryString.toLowerCase()) > -1 ||
-					restaurant.meta.title.toLowerCase().indexOf(queryString.toLowerCase()) > -1 ||
-					t(restaurant.meta.title).indexOf(queryString.toLowerCase()) > -1
+					restaurant.meta?.title.toLowerCase().indexOf(queryString.toLowerCase()) > -1 ||
+					t(restaurant.meta?.title).indexOf(queryString.toLowerCase()) > -1
 				);
 			};
 		};
@@ -88,13 +88,13 @@ export default defineComponent({
 		const initTageView = () => {
 			if (state.tagsViewList.length > 0) return false;
 			store.state.tagsViewRoutes.tagsViewRoutes.map((v: any) => {
-				if (!v.meta.isHide) state.tagsViewList.push({ ...v });
+				if (!v.meta?.isHide) state.tagsViewList.push({ ...v });
 			});
 		};
 		// 当前菜单选中时
 		const onHandleSelect = (item: any) => {
 			let { path, redirect } = item;
-			if (item.meta.isLink && !item.meta.isIframe) window.open(item.meta.isLink);
+			if (item.meta?.isLink && !item.meta.isIframe) window.open(item.meta?.isLink);
 			else if (redirect) router.push(redirect);
 			else router.push(path);
 			closeSearch();

+ 1 - 1
src/layout/navBars/tagsView/contextmenu.vue

@@ -81,7 +81,7 @@ export default defineComponent({
 		// 打开右键菜单:判断是否固定,固定则不显示关闭按钮
 		const openContextmenu = (item: any) => {
 			state.item = item;
-			item.meta.isAffix ? (state.dropdownList[1].affix = true) : (state.dropdownList[1].affix = false);
+			item.meta?.isAffix ? (state.dropdownList[1].affix = true) : (state.dropdownList[1].affix = false);
 			closeContextmenu();
 			setTimeout(() => {
 				state.isShow = true;

+ 12 - 12
src/layout/navBars/tagsView/tagsView.vue

@@ -17,8 +17,8 @@
 					"
 				>
 					<i class="iconfont icon-webicon318 layout-navbars-tagsview-ul-li-iconfont" v-if="isActive(v)"></i>
-					<SvgIcon :name="v.meta.icon" v-if="!isActive(v) && getThemeConfig.isTagsviewIcon" class="pr5" />
-					<span>{{ v.meta.title.indexOf('.')>0?$t(v.meta.title):v.meta.title }}</span>
+					<SvgIcon :name="v.meta?.icon" v-if="!isActive(v) && getThemeConfig.isTagsviewIcon" class="pr5" />
+					<span>{{ v.meta?.title.indexOf('.')>0?$t(v.meta?.title):v.meta?.title }}</span>
 					<template v-if="isActive(v)">
 						<SvgIcon
 							name="ele-RefreshRight"
@@ -28,14 +28,14 @@
 						<SvgIcon
 							name="ele-Close"
 							class="layout-navbars-tagsview-ul-li-icon layout-icon-active"
-							v-if="!v.meta.isAffix"
+							v-if="!v.meta?.isAffix"
 							@click.stop="closeCurrentTagsView(getThemeConfig.isShareTagsView ? v.path : v.url)"
 						/>
 					</template>
 					<SvgIcon
 						name="ele-Close"
 						class="layout-navbars-tagsview-ul-li-icon layout-icon-three"
-						v-if="!v.meta.isAffix"
+						v-if="!v.meta?.isAffix"
 						@click.stop="closeCurrentTagsView(getThemeConfig.isShareTagsView ? v.path : v.url)"
 					/>
 				</li>
@@ -151,7 +151,7 @@ export default defineComponent({
 				state.tagsViewList = await Session.get('tagsViewList');
 			} else {
 				await state.tagsViewRoutesList.map((v: any) => {
-					if (v.meta.isAffix && !v.meta.isHide) {
+					if (v.meta?.isAffix && !v.meta?.isHide) {
 						v.url = setTagsViewHighlight(v);
 						state.tagsViewList.push({ ...v });
 					}
@@ -175,8 +175,8 @@ export default defineComponent({
 			if (current.length <= 0) {
 				// 防止:Avoid app logic that relies on enumerating keys on a component instance. The keys will be empty in production mode to avoid performance overhead.
 				let findItem = state.tagsViewRoutesList.find((v: any) => v.path === isDynamicPath);
-				if (findItem.meta.isAffix) return false;
-				if (findItem.meta.isLink && !findItem.meta.isIframe) return false;
+				if (findItem.meta?.isAffix) return false;
+				if (findItem.meta?.isLink && !findItem.meta.isIframe) return false;
 				to.meta.isDynamic ? (findItem.params = to.params) : (findItem.query = to.query);
 				findItem.url = setTagsViewHighlight(findItem);
 				state.tagsViewList.push({ ...findItem });
@@ -219,7 +219,7 @@ export default defineComponent({
 					if (state.tagsViewList.some((v: any) => v.path === path)) return false;
 					item = state.tagsViewRoutesList.find((v: any) => v.path === path);
 				}
-				if (item.meta.isLink && !item.meta.isIframe) return false;
+				if (item.meta?.isLink && !item.meta.isIframe) return false;
 				if (to && to.meta.isDynamic) item.params = to?.params ? to?.params : route.params;
 				else item.query = to?.query ? to?.query : route.query;
 				item.url = setTagsViewHighlight(item);
@@ -234,7 +234,7 @@ export default defineComponent({
 		// 3、关闭当前 tagsView:如果是设置了固定的(isAffix),不可以关闭
 		const closeCurrentTagsView = (path: string) => {
 			state.tagsViewList.map((v: any, k: number, arr: any) => {
-				if (!v.meta.isAffix) {
+				if (!v.meta?.isAffix) {
 					if (getThemeConfig.value.isShareTagsView ? v.path === path : v.url === path) {
 						state.tagsViewList.splice(k, 1);
 						setTimeout(() => {
@@ -271,7 +271,7 @@ export default defineComponent({
 		const closeOtherTagsView = (path: string) => {
 			state.tagsViewList = [];
 			state.tagsViewRoutesList.map((v: any) => {
-				if (v.meta.isAffix && !v.meta.isHide) state.tagsViewList.push({ ...v });
+				if (v.meta?.isAffix && !v.meta?.isHide) state.tagsViewList.push({ ...v });
 			});
 			addTagsView(path, route);
 		};
@@ -279,7 +279,7 @@ export default defineComponent({
 		const closeAllTagsView = () => {
 			state.tagsViewList = [];
 			state.tagsViewRoutesList.map((v: any) => {
-				if (v.meta.isAffix && !v.meta.isHide) {
+				if (v.meta?.isAffix && !v.meta?.isHide) {
 					state.tagsViewList.push({ ...v });
 					router.push({ path: state.tagsViewList[state.tagsViewList.length - 1].path });
 				}
@@ -487,7 +487,7 @@ export default defineComponent({
 					router.push('/home');
 					state.tagsViewList = [];
 					state.tagsViewRoutesList.map((v: any) => {
-						if (v.meta.isAffix && !v.meta.isHide) {
+						if (v.meta?.isAffix && !v.meta?.isHide) {
 							v.url = setTagsViewHighlight(v);
 							state.tagsViewList.push({ ...v });
 						}

+ 10 - 10
src/layout/navMenu/horizontal.vue

@@ -5,21 +5,21 @@
 				<template v-for="val in menuLists">
 					<el-sub-menu :index="val.path" v-if="val.children && val.children.length > 0" :key="val.path">
 						<template #title>
-							<SvgIcon :name="val.meta.icon" />
-							<span>{{ val.meta.title.indexOf('.')>0?$t(val.meta.title):val.meta.title }}</span>
+							<SvgIcon :name="val.meta?.icon" />
+							<span>{{ val.meta?.title.indexOf('.')>0?$t(val.meta?.title):val.meta?.title }}</span>
 						</template>
 						<SubItem :chil="val.children" />
 					</el-sub-menu>
 					<template v-else>
 						<el-menu-item :index="val.path" :key="val.path">
-							<template #title v-if="!val.meta.isLink || (val.meta.isLink && val.meta.isIframe)">
-								<SvgIcon :name="val.meta.icon" />
-								{{ val.meta.title.indexOf('.')>0?$t(val.meta.title):val.meta.title }}
+							<template #title v-if="!val.meta?.isLink || (val.meta?.isLink && val.meta.isIframe)">
+								<SvgIcon :name="val.meta?.icon" />
+								{{ val.meta?.title.indexOf('.')>0?$t(val.meta?.title):val.meta?.title }}
 							</template>
 							<template #title v-else>
-								<a :href="val.meta.isLink" target="_blank" rel="opener" class="w100">
-									<SvgIcon :name="val.meta.icon" />
-									{{ val.meta.title.indexOf('.')>0?$t(val.meta.title):val.meta.title }}
+								<a :href="val.meta?.isLink" target="_blank" rel="opener" class="w100">
+									<SvgIcon :name="val.meta?.icon" />
+									{{ val.meta?.title.indexOf('.')>0?$t(val.meta?.title):val.meta?.title }}
 								</a>
 							</template>
 						</el-menu-item>
@@ -71,7 +71,7 @@ export default defineComponent({
 		// 路由过滤递归函数
 		const filterRoutesFun = (arr: Array<object>) => {
 			return arr
-				.filter((item: any) => !item.meta.isHide)
+				.filter((item: any) => !item.meta?.isHide)
 				.map((item: any) => {
 					item = Object.assign({}, item);
 					if (item.children) item.children = filterRoutesFun(item.children);
@@ -99,7 +99,7 @@ export default defineComponent({
 				(<any>state.defaultActive) = `/${path.split('/')[1]}`;
 			} else {
 				const pathSplit = meta.isDynamic ? meta.isDynamicPath.split('/') : path.split('/');
-				if (pathSplit.length >= 4 && meta.isHide) state.defaultActive = pathSplit.splice(0, 3).join('/');
+				if (pathSplit.length >= 4 && meta?.isHide) state.defaultActive = pathSplit.splice(0, 3).join('/');
 				else state.defaultActive = path;
 			}
 		};

+ 8 - 8
src/layout/navMenu/subItem.vue

@@ -2,21 +2,21 @@
 	<template v-for="val in chils">
 		<el-sub-menu :index="val.path" :key="val.path" v-if="val.children && val.children.length > 0">
 			<template #title>
-				<SvgIcon :name="val.meta.icon" />
-				<span>{{ val.meta.title.indexOf('.')>0?$t(val.meta.title):val.meta.title }}</span>
+				<SvgIcon :name="val.meta?.icon" />
+				<span>{{ val.meta?.title.indexOf('.')>0?$t(val.meta?.title):val.meta?.title }}</span>
 			</template>
 			<sub-item :chil="val.children" />
 		</el-sub-menu>
 		<template v-else>
 			<el-menu-item :index="val.path" :key="val.path">
-				<template v-if="!val.meta.isLink || (val.meta.isLink && val.meta.isIframe)">
-					<SvgIcon :name="val.meta.icon" />
-					<span>{{ val.meta.title.indexOf('.')>0?$t(val.meta.title):val.meta.title }}</span>
+				<template v-if="!val.meta?.isLink || (val.meta?.isLink && val.meta.isIframe)">
+					<SvgIcon :name="val.meta?.icon" />
+					<span>{{ val.meta?.title.indexOf('.')>0?$t(val.meta?.title):val.meta?.title }}</span>
 				</template>
 				<template v-else>
-					<a :href="val.meta.isLink" target="_blank" rel="opener" class="w100">
-						<SvgIcon :name="val.meta.icon" />
-						{{ val.meta.title.indexOf('.')>0?$t(val.meta.title):val.meta.title }}
+					<a :href="val.meta?.isLink" target="_blank" rel="opener" class="w100">
+						<SvgIcon :name="val.meta?.icon" />
+						{{ val.meta?.title.indexOf('.')>0?$t(val.meta?.title):val.meta?.title }}
 					</a>
 				</template>
 			</el-menu-item>

+ 7 - 7
src/layout/navMenu/vertical.vue

@@ -10,19 +10,19 @@
 		<template v-for="val in menuLists">
 			<el-sub-menu :index="val.path" v-if="val.children && val.children.length > 0" :key="val.path">
 				<template #title>
-					<SvgIcon :name="val.meta.icon" />
-					<span>{{ val.meta.title.indexOf('.')>0?$t(val.meta.title):val.meta.title }}</span>
+					<SvgIcon :name="val.meta?.icon" />
+					<span>{{ val.meta?.title.indexOf('.')>0?$t(val.meta?.title):val.meta?.title }}</span>
 				</template>
 				<SubItem :chil="val.children" />
 			</el-sub-menu>
 			<template v-else>
 				<el-menu-item :index="val.path" :key="val.path">
-					<SvgIcon :name="val.meta.icon" />
-					<template #title v-if="!val.meta.isLink || (val.meta.isLink && val.meta.isIframe)">
-						<span>{{ val.meta.title.indexOf('.')>0?$t(val.meta.title):val.meta.title }}</span>
+					<SvgIcon :name="val.meta?.icon" />
+					<template #title v-if="!val.meta?.isLink || (val.meta?.isLink && val.meta.isIframe)">
+						<span>{{ val.meta?.title.indexOf('.')>0?$t(val.meta?.title):val.meta?.title }}</span>
 					</template>
 					<template #title v-else>
-						<a :href="val.meta.isLink" target="_blank" rel="opener" class="w100">{{ val.meta.title.indexOf('.')>0?$t(val.meta.title):val.meta.title }}</a>
+						<a :href="val.meta?.isLink" target="_blank" rel="opener" class="w100">{{ val.meta?.title.indexOf('.')>0?$t(val.meta?.title):val.meta?.title }}</a>
 					</template>
 				</el-menu-item>
 			</template>
@@ -64,7 +64,7 @@ export default defineComponent({
 		const setParentHighlight = (currentRoute: any) => {
 			const { path, meta } = currentRoute;
 			const pathSplit = meta.isDynamic ? meta.isDynamicPath.split('/') : path.split('/');
-			if (pathSplit.length >= 4 && meta.isHide) return pathSplit.splice(0, 3).join('/');
+			if (pathSplit.length >= 4 && meta?.isHide) return pathSplit.splice(0, 3).join('/');
 			else return path;
 		};
 		// 设置菜单的收起/展开

+ 1 - 1
src/layout/routerView/iframes.vue

@@ -19,7 +19,7 @@ export default defineComponent({
 		});
 		// 初始化页面加载 loading
 		const initIframeLoad = () => {
-			state.iframeUrl = <any>route.meta.isLink;
+			state.iframeUrl = <any>route.meta?.isLink;
 			nextTick(() => {
 				state.iframeLoading = true;
 				const iframe = document.getElementById('iframe');

+ 2 - 2
src/layout/routerView/link.vue

@@ -1,7 +1,7 @@
 <template>
 	<div class="layout-view-bg-white flex layout-view-link" :style="{ height: `calc(100vh - ${setLinkHeight}` }">
-		<a :href="currentRouteMeta.isLink" target="_blank" rel="opener" class="flex-margin">
-			{{ currentRouteMeta.title.indexOf('.')>0?$t(currentRouteMeta.title):currentRouteMeta.title }}:{{ currentRouteMeta.isLink }}
+		<a :href="currentRoutemeta?.isLink" target="_blank" rel="opener" class="flex-margin">
+			{{ currentRoutemeta?.title.indexOf('.')>0?$t(currentRoutemeta?.title):currentRoutemeta?.title }}:{{ currentRoutemeta?.isLink }}
 		</a>
 	</div>
 </template>

+ 9 - 8
src/router/backEnd.ts

@@ -3,7 +3,7 @@ import { Session } from '/@/utils/storage';
 import { NextLoading } from '/@/utils/loading';
 import { setAddRoute, setFilterMenuAndCacheTagsViewRoutes } from '/@/router/index';
 import {demoRoutes, dynamicRoutes} from '/@/router/route';
-import { getUserMenus } from '/@/api/system/menu';
+import { currentUser } from '/@/api/login';
 
 
 
@@ -31,10 +31,10 @@ export async function initBackEndControlRoutes() {
 	if (!Session.get('token')) return false;
 	// 触发初始化用户信息
 	store.dispatch('userInfos/setUserInfos');
-	store.dispatch('userInfos/setPermissions');
+	// store.dispatch('userInfos/setPermissions');
 	let menuRoute = Session.get('userMenu')
-	let permissions = Session.get('permissions')
-	if (!menuRoute || !permissions) {
+	// let permissions = Session.get('permissions')
+	if (!menuRoute) {
 		await getBackEndControlRoutes(); // 获取路由
 		menuRoute = Session.get('userMenu')
 	}
@@ -56,10 +56,11 @@ export async function initBackEndControlRoutes() {
  * @returns 返回后端路由菜单数据
  */
 export async function getBackEndControlRoutes() {
-	return getUserMenus().then((res:any)=>{
-		Session.set('userMenu',res.data.menuList)
-		Session.set('permissions',res.data.permissions)
-		store.dispatch('userInfos/setPermissions',res.data.permissions)
+	return currentUser().then((res: any) => {
+		console.log(res)
+		// Session.set('userMenu',res.data.menuList)
+		// Session.set('permissions',res.data.permissions)
+		// store.dispatch('userInfos/setPermissions',res.data.permissions)
 	})
 }
 

+ 2 - 2
src/router/index.ts

@@ -66,7 +66,7 @@ export function formatTwoStageRoutes(arr: any) {
 			newArr[0].children.push({ ...v });
 			// 存 name 值,keep-alive 中 include 使用,实现路由的缓存
 			// 路径:/@/layout/routerView/parent.vue
-			if (newArr[0].meta.isKeepAlive && v.meta.isKeepAlive) {
+			if (newArr[0].meta?.isKeepAlive && v.meta?.isKeepAlive) {
 				cacheList.push(v.name);
 				store.dispatch('keepAliveNames/setCacheKeepAlive', cacheList);
 			}
@@ -192,7 +192,7 @@ if (!isRequestRoutes) initFrontEndControlRoutes();
 // 路由加载前
 router.beforeEach(async (to, from, next) => {
 	NProgress.configure({ showSpinner: false });
-	if (to.meta.title) NProgress.start();
+	if (to.meta?.title) NProgress.start();
 	//  系统初始化
 	if (to.path === '/dbInit') {
 		next();

+ 2 - 2
src/utils/other.ts

@@ -30,8 +30,8 @@ export function useTitle() {
 		let webTitle = '';
 		let globalTitle: string = store.state.themeConfig.themeConfig.globalTitle;
 		router.currentRoute.value.path === '/login'
-			? (webTitle = router.currentRoute.value.meta.title as any)
-			: (webTitle = i18n.global.t(router.currentRoute.value.meta.title as any));
+			? (webTitle = router.currentRoute.value.meta?.title as any)
+			: (webTitle = i18n.global.t(router.currentRoute.value.meta?.title as any));
 		document.title = `${webTitle} - ${globalTitle}` || globalTitle;
 	});
 }

+ 1 - 1
src/utils/request.ts

@@ -41,7 +41,7 @@ service.interceptors.response.use(
 			ElMessage.error(res.message)
 			return Promise.reject(new Error(res.message))
 		} else {
-			return res
+			return res.data?.Data || res.data
 		}
 	},
 	(error) => {

+ 9 - 6
src/views/login/component/account.vue

@@ -62,6 +62,7 @@ import * as api from '/@/api/login';
 export default defineComponent({
 	name: 'loginAccount',
 	setup() {
+			console.log('setup')
 		const { t } = useI18n();
 		const store = useStore();
 		const route = useRoute();
@@ -86,7 +87,9 @@ export default defineComponent({
 			captchaSrc: '',
 		});
 		onMounted(() => {
+			console.log('onMounted')
 			getCaptcha();
+			currentUser();
 		});
 		// 时间获取
 		const currentTime = computed(() => {
@@ -95,8 +98,8 @@ export default defineComponent({
 
 		const getCaptcha = () => {
 			captcha().then((res: any) => {
-				state.captchaSrc = res.data.img;
-				state.ruleForm.VerifyKey = res.data.key;
+				state.captchaSrc = res.img;
+				state.ruleForm.VerifyKey = res.key;
 			});
 		};
 
@@ -109,10 +112,10 @@ export default defineComponent({
 						state.loading.signIn = true;
 						login(state.ruleForm)
 							.then(async (res: any) => {
-								const userInfos = res.data.userInfo;
+								const userInfos = res.userInfo;
 								userInfos.avatar = proxy.getUpFileUrl(userInfos.avatar);
 								// 存储 token 到浏览器缓存
-								Session.set('token', res.data.token);
+								Session.set('token', res.token);
 								// 存储用户信息到浏览器缓存
 								Session.set('userInfo', userInfos);
 								await store.dispatch('userInfos/setUserInfos', userInfos);
@@ -131,8 +134,8 @@ export default defineComponent({
 		const currentUser = async () => {
 			api.currentUser().then((res) => {
 				// 设置用户菜单
-				Session.set('userMenu', res.data.Data);
-				store.dispatch('requestOldRoutes/setBackEndControlRoutes', res.data.Data);
+				Session.set('userMenu', res);
+				store.dispatch('requestOldRoutes/setBackEndControlRoutes', res);
 			});
 			// // 设置按钮权限
 			// Session.set('permissions', res.data.permissions);