mirror of
https://gitee.com/wonderful-code/buildadmin
synced 2024-11-21 22:55:36 +00:00
refactor:基础静态路由路径使用的字面量改为变量
This commit is contained in:
parent
085b5fd62c
commit
873e47c52b
@ -30,6 +30,7 @@ import useCurrentInstance from '/@/utils/useCurrentInstance'
|
||||
import Contextmenu from '/@/components/contextmenu/index.vue'
|
||||
import horizontalScroll from '/@/utils/horizontalScroll'
|
||||
import { getFirstRoute, routePush } from '/@/utils/router'
|
||||
import { adminBaseRoutePath } from '/@/router/static/adminBase'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
@ -97,7 +98,7 @@ const toLastTab = () => {
|
||||
if (lastTab) {
|
||||
router.push(lastTab)
|
||||
} else {
|
||||
router.push('/admin')
|
||||
router.push(adminBaseRoutePath)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import { defineStore } from 'pinia'
|
||||
import { STORE_TAB_VIEW_CONFIG } from '/@/stores/constant/cacheKey'
|
||||
import type { NavTabs } from '/@/stores/interface/index'
|
||||
import type { RouteLocationNormalized, RouteRecordRaw } from 'vue-router'
|
||||
import { adminBaseRoutePath } from '/@/router/static/adminBase'
|
||||
|
||||
export const useNavTabs = defineStore(
|
||||
'navTabs',
|
||||
@ -101,7 +102,7 @@ export const useNavTabs = defineStore(
|
||||
function encodeRoutesURI(data: RouteRecordRaw[]) {
|
||||
data.forEach((item) => {
|
||||
if (item.meta?.menu_type == 'iframe') {
|
||||
item.path = '/admin/iframe/' + encodeURIComponent(item.path)
|
||||
item.path = adminBaseRoutePath + '/iframe/' + encodeURIComponent(item.path)
|
||||
}
|
||||
|
||||
if (item.children && item.children.length) {
|
||||
|
@ -155,10 +155,11 @@ export const buildJsonToElTreeData = (data: any): ElTreeData[] => {
|
||||
* @param path 不传递则通过当前路由 path 检查
|
||||
*/
|
||||
export const isAdminApp = (path = '') => {
|
||||
const regex = new RegExp(`^${adminBaseRoutePath}`)
|
||||
if (path) {
|
||||
return /^\/admin/.test(path)
|
||||
return regex.test(path)
|
||||
}
|
||||
if (/^\/admin/.test(getCurrentRoutePath())) {
|
||||
if (regex.test(getCurrentRoutePath())) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
@ -247,7 +247,7 @@ export const addRouteItem = (viewsComponent: Record<string, any>, route: any, pa
|
||||
let path = '',
|
||||
component
|
||||
if (route.menu_type == 'iframe') {
|
||||
path = (isAdminApp() ? '/admin' : '/user') + '/iframe/' + encodeURIComponent(route.url)
|
||||
path = (isAdminApp() ? adminBaseRoute.path : memberCenterBaseRoute.path) + '/iframe/' + encodeURIComponent(route.url)
|
||||
component = () => import('/@/layouts/common/router-view/iframe.vue')
|
||||
} else {
|
||||
path = parentName ? route.path : '/' + route.path
|
||||
|
@ -11,7 +11,7 @@
|
||||
</div>
|
||||
<el-button
|
||||
v-if="memberCenter.state.open"
|
||||
@click="$router.push('/user')"
|
||||
@click="$router.push(memberCenterBaseRoutePath)"
|
||||
class="container-button"
|
||||
color="#ffffff"
|
||||
size="large"
|
||||
@ -35,6 +35,7 @@ import { useSiteConfig } from '/@/stores/siteConfig'
|
||||
import { useMemberCenter } from '/@/stores/memberCenter'
|
||||
import Header from '/@/layouts/frontend/components/header.vue'
|
||||
import Footer from '/@/layouts/frontend/components/footer.vue'
|
||||
import { memberCenterBaseRoutePath } from '/@/router/static/memberCenterBase'
|
||||
|
||||
const siteConfig = useSiteConfig()
|
||||
const memberCenter = useMemberCenter()
|
||||
|
Loading…
Reference in New Issue
Block a user