Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
monorepo
/
venus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit ffebac33
authored
Dec 19, 2025
by
Lin
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat: 修改路由配置/修改挂载初始化配置
1 parent
e6455fb1
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
190 additions
and
128 deletions
apps/frontend/venus-agentic/venus-agentic-base/src/config/center.ts
apps/frontend/venus-agentic/venus-agentic-base/src/layouts/BasicLayout.vue
apps/frontend/venus-agentic/venus-agentic-base/src/qiankun/apps.ts
apps/frontend/venus-agentic/venus-agentic-base/src/qiankun/components/MicroAppContainer.vue
apps/frontend/venus-agentic/venus-agentic-base/src/qiankun/lifecycles.ts
apps/frontend/venus-agentic/venus-agentic-base/src/router/index.ts
apps/frontend/venus-agentic/venus-agentic-base/src/stores/user.ts
apps/frontend/venus-agentic/venus-agentic-base/src/utils/menu.ts
apps/frontend/venus-agentic/venus-agentic-base/src/views/Login.vue
apps/frontend/venus-agentic/venus-agentic-base/src/config/center.ts
View file @
ffebac3
...
@@ -5,9 +5,9 @@
...
@@ -5,9 +5,9 @@
import
{
Request
,
Defaults
}
from
'glsk-toolkit'
;
import
{
Request
,
Defaults
}
from
'glsk-toolkit'
;
import
{
getToken
,
clearAuth
}
from
'@/utils/auth'
;
import
{
getToken
,
clearAuth
}
from
'@/utils/auth'
;
import
{
ElMessage
}
from
'element-plus'
;
import
{
ElMessage
}
from
'element-plus'
;
import
{
localCache
}
from
'@/utils/storage'
;
// 配置数据
// 配置数据
let
baseConfig
:
any
=
{};
let
baseConfig
:
any
=
{};
let
routerConfig
:
any
=
{};
// GSC API 请求实例(模块级单例,不挂载到 window)
// GSC API 请求实例(模块级单例,不挂载到 window)
let
gscApiInstance
:
null
|
Request
=
null
;
let
gscApiInstance
:
null
|
Request
=
null
;
...
@@ -18,11 +18,22 @@ let configReadyResolve: (() => void) | null = null;
...
@@ -18,11 +18,22 @@ let configReadyResolve: (() => void) | null = null;
// 配置请求 URL
// 配置请求 URL
const
CONFIG_URL
=
const
CONFIG_URL
=
'https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=venus-base-system-config'
;
'https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=venus-base-system-config'
;
//路由菜单配置
const
ROUTER_URL
=
const
ROUTER_URL
=
'https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=venus-agentic-router'
;
'https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=venus-agentic-router'
;
// 初始化配置就绪 Promise
// 缓存 key
const
CONFIG_CACHE_KEY
=
'venus_base_config'
;
const
ROUTER_CONFIG_CACHE_KEY
=
'venus_router_config'
;
/**
* 与waitForConfigReady方法配套使用,
* 用于创建一个“等待机制”(Promise)
* 保存“完成通知按钮”(resolve 函数)
* 让其他代码可以“等待配置加载完成”
*/
function
initConfigReadyPromise
()
{
function
initConfigReadyPromise
()
{
console
.
log
(
'initConfigReadyPromise'
,
configReadyPromise
);
if
(
!
configReadyPromise
)
{
if
(
!
configReadyPromise
)
{
configReadyPromise
=
new
Promise
<
void
>
((
resolve
)
=>
{
configReadyPromise
=
new
Promise
<
void
>
((
resolve
)
=>
{
configReadyResolve
=
resolve
;
configReadyResolve
=
resolve
;
...
@@ -30,11 +41,31 @@ function initConfigReadyPromise() {
...
@@ -30,11 +41,31 @@ function initConfigReadyPromise() {
}
}
return
configReadyPromise
;
return
configReadyPromise
;
}
}
/**
* 获取远程路由配置数据
* @returns 路由数据
*/
export
async
function
fetchMicroAppConfig
():
Promise
<
any
>
{
export
async
function
fetchMicroAppConfig
():
Promise
<
any
>
{
// 先检查本地缓存
const
cachedData
=
localCache
.
get
(
ROUTER_CONFIG_CACHE_KEY
);
if
(
cachedData
)
{
console
.
log
(
'[配置中心] 使用缓存的路由菜单配置'
);
return
cachedData
;
}
// 缓存不存在,从远程获取
const
response
=
await
fetch
(
ROUTER_URL
);
const
response
=
await
fetch
(
ROUTER_URL
);
const
result
=
await
response
.
json
();
const
result
=
await
response
.
json
();
// 保存到本地缓存
if
(
result
)
{
localCache
.
set
(
ROUTER_CONFIG_CACHE_KEY
,
result
);
console
.
log
(
'[配置中心] 路由菜单配置已缓存到本地'
);
}
return
result
;
return
result
;
}
}
/**
/**
* 获取 GSC API 请求实例
* 获取 GSC API 请求实例
* @returns Request 实例,如果未初始化则返回 null
* @returns Request 实例,如果未初始化则返回 null
...
@@ -66,8 +97,25 @@ export async function fetchConfig(): Promise<any> {
...
@@ -66,8 +97,25 @@ export async function fetchConfig(): Promise<any> {
initConfigReadyPromise
();
initConfigReadyPromise
();
try
{
try
{
const
response
=
await
fetch
(
CONFIG_URL
);
// 先检查本地缓存
const
configData
=
await
response
.
json
();
const
cachedData
=
localCache
.
get
(
CONFIG_CACHE_KEY
);
let
configData
:
any
;
if
(
cachedData
)
{
console
.
log
(
'[配置中心] 使用缓存的基本配置'
);
configData
=
cachedData
;
}
else
{
// 缓存不存在,从远程获取
const
response
=
await
fetch
(
CONFIG_URL
);
configData
=
await
response
.
json
();
// 保存到本地缓存
if
(
configData
)
{
localCache
.
set
(
CONFIG_CACHE_KEY
,
configData
);
console
.
log
(
'[配置中心] 基本配置已缓存到本地'
);
}
}
baseConfig
=
configData
;
baseConfig
=
configData
;
window
.
$fetchConfig
=
configData
;
window
.
$fetchConfig
=
configData
;
// 统一初始化 GSC API(无论 code 是什么,只要有配置就初始化)
// 统一初始化 GSC API(无论 code 是什么,只要有配置就初始化)
...
@@ -76,22 +124,10 @@ export async function fetchConfig(): Promise<any> {
...
@@ -76,22 +124,10 @@ export async function fetchConfig(): Promise<any> {
// 创建全局默认配置
// 创建全局默认配置
const
globalDefaults
=
new
Defaults
({
const
globalDefaults
=
new
Defaults
({
...
gscConfig
,
...
gscConfig
,
session
:
{
requiresSession
:
false
,
sessionId
:
'd5629aee-28c7-4def-a8fa-95d76c978dc7'
,
},
headers
:
{
'X-App-Version'
:
'1.0.0'
},
retry
:
{
retries
:
2
,
retryDelay
:
500
,
shouldResetTimeout
:
true
},
events
:
{
events
:
{
error
:
(
error
:
any
,
requestConfig
:
any
)
=>
{
error
:
(
error
:
any
,
requestConfig
:
any
)
=>
{
console
.
error
(
'[配置中心] GSC API 错误:'
,
error
,
requestConfig
);
console
.
error
(
'[配置中心] GSC API 错误:'
,
error
,
requestConfig
);
// 检查错误信息中是否包含 401 状态码
// 检查错误信息中是否包含 401 状态码
,待优化项:插件默认所有>=400状态码全部阻塞,后续业务状态码不会捕获处理
const
errorMessage
=
error
?.
msg
||
error
?.
message
||
error
?.
toString
()
||
String
(
error
);
const
errorMessage
=
error
?.
msg
||
error
?.
message
||
error
?.
toString
()
||
String
(
error
);
if
(
errorMessage
.
includes
(
'401'
))
{
if
(
errorMessage
.
includes
(
'401'
))
{
ElMessage
.
error
(
'登录已过期,请重新登录'
);
ElMessage
.
error
(
'登录已过期,请重新登录'
);
...
@@ -163,23 +199,15 @@ export function getConfig(): any {
...
@@ -163,23 +199,15 @@ export function getConfig(): any {
return
baseConfig
;
return
baseConfig
;
}
}
export
async
function
fetchRouterConfig
():
Promise
<
any
>
{
const
response
=
await
fetch
(
ROUTER_URL
);
const
result
=
await
response
.
json
();
routerConfig
=
result
;
return
result
;
}
export
function
getRouterConfig
():
any
{
return
routerConfig
;
}
/**
/**
*
设置配置数据
*
清空配置缓存
*
@param config 配置数据
*
在项目退出时调用
*/
*/
export
function
setConfig
(
config
:
any
):
void
{
export
function
clearConfigCache
():
void
{
baseConfig
=
config
;
localCache
.
remove
(
CONFIG_CACHE_KEY
);
localCache
.
remove
(
ROUTER_CONFIG_CACHE_KEY
);
console
.
log
(
'[配置中心] 配置缓存已清空'
);
}
}
// 导出配置数据(只读)
// 导出配置数据(只读)
...
...
apps/frontend/venus-agentic/venus-agentic-base/src/layouts/BasicLayout.vue
View file @
ffebac3
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
// 类型导入
import
type
{
BreadcrumbItem
,
MenuItem
}
from
'@/types/menu'
;
import
type
{
BreadcrumbItem
,
MenuItem
}
from
'@/types/menu'
;
// Vue 核心
import
{
computed
,
ref
,
watch
}
from
'vue'
;
import
{
useRoute
,
useRouter
}
from
'vue-router'
;
import
{
useRoute
,
useRouter
}
from
'vue-router'
;
import
{
computed
,
ref
,
watch
}
from
'vue'
;
// 项目配置和工具
import
{
defaultTopMenus
,
getMenuChain
,
getMenuParentPaths
}
from
'@/config/menus'
;
import
{
defaultTopMenus
,
getMenuChain
,
getMenuParentPaths
}
from
'@/config/menus'
;
import
{
microApps
}
from
'@/qiankun/apps'
;
import
{
communicationManager
}
from
'@/qiankun/communication'
;
import
{
communicationManager
}
from
'@/qiankun/communication'
;
import
{
microApps
}
from
'@/qiankun/apps'
;
import
{
useMenuStore
}
from
'@/stores'
;
import
{
useMenuStore
}
from
'@/stores'
;
// import { Download } from '@element-plus/icons-vue';
// 组件导入
import
Breadcrumb
from
'./components/Breadcrumb.vue'
;
// import NotificationCenter from './components/NotificationCenter.vue';
import
SidebarMenuItem
from
'./components/SidebarMenuItem.vue'
;
import
SidebarMenuItem
from
'./components/SidebarMenuItem.vue'
;
import
Breadcrumb
from
'./components/Breadcrumb.vue'
;
import
UserInfo
from
'./components/UserInfo.vue'
;
import
UserInfo
from
'./components/UserInfo.vue'
;
const
router
=
useRouter
();
const
router
=
useRouter
();
...
@@ -255,6 +254,7 @@ const handleMenuToggle = (menuId: string) => {
...
@@ -255,6 +254,7 @@ const handleMenuToggle = (menuId: string) => {
// 判断是否为微应用路由
// 判断是否为微应用路由
const
isMicroAppRoute
=
(
path
:
string
):
boolean
=>
{
const
isMicroAppRoute
=
(
path
:
string
):
boolean
=>
{
console
.
log
(
'isMicroAppRoute'
,
microApps
);
return
microApps
.
some
((
app
)
=>
{
return
microApps
.
some
((
app
)
=>
{
const
rule
=
app
.
activeRule
;
const
rule
=
app
.
activeRule
;
if
(
typeof
rule
===
'string'
)
{
if
(
typeof
rule
===
'string'
)
{
...
...
apps/frontend/venus-agentic/venus-agentic-base/src/qiankun/apps.ts
View file @
ffebac3
import
type
{
MicroAppConfig
}
from
'./types'
;
// 微应用配置类型
import
type
{
MicroAppConfig
}
from
'./types'
;
// 微应用配置类型
import
{
getGscApi
,
waitForConfigReady
,
fetchMicroAppConfig
}
from
'@/config/center'
;
import
{
fetchMicroAppConfig
}
from
'@/config/center'
;
// import {fetchMicroAppConfig} from '@/config/center';
import
{
createSubAppAdapter
}
from
'./subAppAdapter'
;
// 微应用统一通信适配器
import
{
transformRemoteConfigToQiankunConfig
}
from
'./configTransformer'
;
import
{
transformRemoteConfigToQiankunConfig
}
from
'./configTransformer'
;
// 微应用配置列表(初始为空,后续动态加载)
// 微应用配置列表(初始为空,后续动态加载)
export
let
microApps
:
MicroAppConfig
[]
=
[
export
let
microApps
:
MicroAppConfig
[]
=
[];
{
name
:
'assisant'
,
// 配置加载状态
entry
:
getAppEntry
(
'subapp-vue'
,
'http://agentic.test.glsx.com.cn/assisant'
),
let
isConfigLoaded
=
false
;
// entry: getAppEntry('subapp-vue', 'http://192.168.10.36:8081'),
let
configLoadPromise
:
Promise
<
void
>
|
null
=
null
;
container
:
'#subapp-container'
,
activeRule
:
'/assisant'
,
props
:
{
routerBase
:
'/assisant'
,
communicationManager
:
createSubAppAdapter
(),
// 提供获取 GSC Request 实例的函数
// 子应用可以通过此函数获取已初始化的 Request 实例
getGscRequest
:
async
()
=>
{
// 确保配置已加载完成
await
waitForConfigReady
();
const
requestInstance
=
getGscApi
();
if
(
!
requestInstance
)
{
throw
new
Error
(
'[微应用] GSC Request 实例未初始化,请确保配置中心已加载完成'
,
);
}
return
requestInstance
;
},
},
},
];
// 默认配置(作为降级方案)
// 默认配置(作为降级方案)
const
defaultMicroApps
:
MicroAppConfig
[]
=
[];
const
defaultMicroApps
:
MicroAppConfig
[]
=
[];
/**
/**
* 加载并设置微应用配置
* 加载并设置微应用配置
*/
*/
export
async
function
loadMicroAppConfig
():
Promise
<
void
>
{
export
async
function
loadMicroAppConfig
():
Promise
<
void
>
{
try
{
// 如果配置已加载,直接返回
const
remoteConfig
=
await
fetchMicroAppConfig
();
if
(
isConfigLoaded
)
{
microApps
=
transformRemoteConfigToQiankunConfig
(
remoteConfig
.
data
?.
microApps
);
return
;
// 如果远程配置为空,使用默认配置
if
(
microApps
.
length
===
0
)
{
microApps
=
defaultMicroApps
;
}
}
catch
(
error
)
{
console
.
error
(
'[微前端配置] 配置加载失败,使用默认配置:'
,
error
);
microApps
=
defaultMicroApps
;
}
}
}
/**
* 获取微应用入口地址
* @param appName 应用名称
* @param defaultEntry 默认地址(开发环境)
*/
function
getAppEntry
(
appName
:
string
,
defaultEntry
:
string
):
string
{
const
env
=
(
import
.
meta
as
any
).
env
?.
MODE
||
'development'
;
//
开发环境使用默认地址
//
如果正在加载,返回同一个 Promise
if
(
env
===
'development'
)
{
if
(
configLoadPromise
)
{
return
defaultEntry
;
return
configLoadPromise
;
}
}
// 优先使用环境变量配置的基础地址
// 创建新的加载 Promise
const
baseUrl
=
(
import
.
meta
as
any
).
env
?.
VITE_MICRO_APP_BASE_URL
;
configLoadPromise
=
(
async
()
=>
{
if
(
baseUrl
)
{
try
{
return
`
${
baseUrl
}
/
${
appName
}
`
;
const
remoteConfig
=
await
fetchMicroAppConfig
();
}
microApps
=
transformRemoteConfigToQiankunConfig
(
remoteConfig
.
data
?.
microApps
);
// 如果远程配置为空,使用默认配置
if
(
microApps
.
length
===
0
)
{
microApps
=
defaultMicroApps
;
}
isConfigLoaded
=
true
;
console
.
log
(
'[微前端配置] 配置加载完成,共加载'
,
microApps
.
length
,
'个微应用'
);
}
catch
(
error
)
{
console
.
error
(
'[微前端配置] 配置加载失败,使用默认配置:'
,
error
);
microApps
=
defaultMicroApps
;
isConfigLoaded
=
true
;
}
finally
{
configLoadPromise
=
null
;
}
})();
// 如果未配置环境变量,使用当前域名的相对路径(同域部署)
return
configLoadPromise
;
return
`
${
window
.
location
.
origin
}
/
${
appName
}
`
;
}
}
/**
/**
* 确保配置已加载(用于在需要时等待配置加载完成)
*/
async
function
ensureConfigLoaded
():
Promise
<
void
>
{
if
(
!
isConfigLoaded
&&
!
configLoadPromise
)
{
// 如果配置未加载且没有正在加载的 Promise,则开始加载
await
loadMicroAppConfig
();
}
else
if
(
configLoadPromise
)
{
// 如果正在加载,等待加载完成
await
configLoadPromise
;
}
}
/**
* 根据名称获取微应用配置
* 根据名称获取微应用配置
* @param name 微应用名称
* @param name 微应用名称
*/
*/
...
@@ -91,8 +80,17 @@ export function getMicroAppNames(): string[] {
...
@@ -91,8 +80,17 @@ export function getMicroAppNames(): string[] {
/**
/**
* 根据路由路径获取对应的微应用
* 根据路由路径获取对应的微应用
* @param path 路由路径
* @param path 路由路径
* @param waitForConfig 是否等待配置加载完成(默认 true)
*/
*/
export
function
getMicroAppByPath
(
path
:
string
):
MicroAppConfig
|
undefined
{
export
async
function
getMicroAppByPath
(
path
:
string
,
waitForConfig
:
boolean
=
true
,
):
Promise
<
MicroAppConfig
|
undefined
>
{
// 如果配置未加载且需要等待,先等待配置加载完成
if
(
waitForConfig
&&
!
isConfigLoaded
)
{
await
ensureConfigLoaded
();
}
return
microApps
.
find
((
app
)
=>
{
return
microApps
.
find
((
app
)
=>
{
if
(
typeof
app
.
activeRule
===
'string'
)
{
if
(
typeof
app
.
activeRule
===
'string'
)
{
return
path
.
startsWith
(
app
.
activeRule
);
return
path
.
startsWith
(
app
.
activeRule
);
...
...
apps/frontend/venus-agentic/venus-agentic-base/src/qiankun/components/MicroAppContainer.vue
View file @
ffebac3
...
@@ -13,9 +13,9 @@ let timer: null | number = null;
...
@@ -13,9 +13,9 @@ let timer: null | number = null;
/**
/**
* 初始化微应用容器
* 初始化微应用容器
*/
*/
onMounted
(()
=>
{
onMounted
(
async
()
=>
{
// 获取当前路径对应的微应用
// 获取当前路径对应的微应用
(等待配置加载完成)
const
microApp
=
getMicroAppByPath
(
route
.
path
);
const
microApp
=
await
getMicroAppByPath
(
route
.
path
,
true
);
if
(
!
microApp
)
{
if
(
!
microApp
)
{
error
.
value
=
'未找到对应的微应用配置'
;
error
.
value
=
'未找到对应的微应用配置'
;
...
...
apps/frontend/venus-agentic/venus-agentic-base/src/qiankun/lifecycles.ts
View file @
ffebac3
...
@@ -28,7 +28,7 @@ export const microAppLifecycles: FrameworkLifeCycles<any> = {
...
@@ -28,7 +28,7 @@ export const microAppLifecycles: FrameworkLifeCycles<any> = {
try
{
try
{
const
{
communicationManager
}
=
await
import
(
'./communication'
);
const
{
communicationManager
}
=
await
import
(
'./communication'
);
const
globalState
=
communicationManager
.
getGlobalState
();
const
globalState
=
communicationManager
.
getGlobalState
();
// 如果用户信息为空,尝试从 Store 获取并同步
// 如果用户信息为空,尝试从 Store 获取并同步
if
(
!
globalState
.
user
)
{
if
(
!
globalState
.
user
)
{
const
{
useUserStore
}
=
await
import
(
'@/stores'
);
const
{
useUserStore
}
=
await
import
(
'@/stores'
);
...
@@ -40,6 +40,29 @@ export const microAppLifecycles: FrameworkLifeCycles<any> = {
...
@@ -40,6 +40,29 @@ export const microAppLifecycles: FrameworkLifeCycles<any> = {
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
warn
(
'[qiankun] 同步用户信息失败:'
,
error
);
console
.
warn
(
'[qiankun] 同步用户信息失败:'
,
error
);
}
}
// return new Promise<void>(async (resolve, reject) => {
// try {
// // 确保主应用的数据已准备好并同步到全局状态
// const { communicationManager } = await import('./communication');
// const globalState = communicationManager.getGlobalState();
// // 如果用户信息为空,尝试从 Store 获取并同步
// if (!globalState.user) {
// const { useUserStore } = await import('@/stores');
// const userStore = useUserStore();
// if (userStore.userInfo) {
// await userStore.syncUserToQiankun();
// }
// }
// setTimeout(()=>{
// resolve();
// }, 1000);
// } catch (error) {
// console.warn('[qiankun] 同步用户信息失败:', error);
// // 即使出错也继续执行,不阻止微应用挂载
// // resolve();
// }
// });
},
},
/**
/**
...
...
apps/frontend/venus-agentic/venus-agentic-base/src/router/index.ts
View file @
ffebac3
...
@@ -166,9 +166,10 @@ async function loadDynamicRoutes() {
...
@@ -166,9 +166,10 @@ async function loadDynamicRoutes() {
* 检查路径是否可能是子应用路由
* 检查路径是否可能是子应用路由
* @param path 路由路径
* @param path 路由路径
*/
*/
function
isPossibleMicroAppPath
(
path
:
string
):
boolean
{
async
function
isPossibleMicroAppPath
(
path
:
string
):
Promise
<
boolean
>
{
// 检查路径是否以已知的微应用 activeRule 开头
// 检查路径是否以已知的微应用 activeRule 开头
const
microApp
=
getMicroAppByPath
(
path
);
// 等待配置加载完成以确保能正确匹配
const
microApp
=
await
getMicroAppByPath
(
path
,
true
);
return
!!
microApp
;
return
!!
microApp
;
}
}
...
@@ -227,27 +228,28 @@ router.beforeEach(async (to, _from, next) => {
...
@@ -227,27 +228,28 @@ router.beforeEach(async (to, _from, next) => {
const
requiresAuth
=
to
.
meta
.
requiresAuth
!==
false
;
const
requiresAuth
=
to
.
meta
.
requiresAuth
!==
false
;
// 如果匹配到404路由,检查是否是子应用路由
// 如果匹配到404路由,检查是否是子应用路由
if
(
if
(
to
.
name
===
'NotFound'
&&
token
)
{
to
.
name
===
'NotFound'
&&
// 检查当前路径是否可能是子应用路由(等待配置加载完成)
token
&&
// 检查当前路径是否可能是子应用路由
const
isMicroAppPath
=
await
isPossibleMicroAppPath
(
to
.
path
);
isPossibleMicroAppPath
(
to
.
path
)
)
{
if
(
isMicroAppPath
)
{
console
.
log
(
console
.
log
(
'[路由守卫] 检测到可能的子应用路由,等待动态路由加载:'
,
'[路由守卫] 检测到可能的子应用路由,等待动态路由加载:'
,
to
.
path
,
to
.
path
,
);
);
// 等待动态路由加载完成
// 等待动态路由加载完成
const
isMatched
=
await
waitForRoutesAndRematch
(
to
.
path
);
const
isMatched
=
await
waitForRoutesAndRematch
(
to
.
path
);
if
(
isMatched
)
{
if
(
isMatched
)
{
// 路由已匹配,重新导航到目标路径
// 路由已匹配,重新导航到目标路径
next
({
path
:
to
.
path
,
replace
:
true
});
next
({
path
:
to
.
path
,
replace
:
true
});
return
;
return
;
}
else
{
}
else
{
// 确实不存在,显示404页面
// 确实不存在,显示404页面
next
();
next
();
return
;
return
;
}
}
}
}
}
...
...
apps/frontend/venus-agentic/venus-agentic-base/src/stores/user.ts
View file @
ffebac3
...
@@ -9,6 +9,7 @@ import {
...
@@ -9,6 +9,7 @@ import {
}
from
'@/api/user'
;
}
from
'@/api/user'
;
import
{
removeToken
,
setToken
}
from
'@/utils/auth'
;
import
{
removeToken
,
setToken
}
from
'@/utils/auth'
;
import
{
defineStore
}
from
'pinia'
;
import
{
defineStore
}
from
'pinia'
;
import
{
clearConfigCache
}
from
'@/config/center'
;
// 可选:如果使用方案2,需要导入此函数
// 可选:如果使用方案2,需要导入此函数
/**
/**
...
@@ -79,6 +80,9 @@ export const useUserStore = defineStore('user', () => {
...
@@ -79,6 +80,9 @@ export const useUserStore = defineStore('user', () => {
roles
.
value
=
[];
roles
.
value
=
[];
removeToken
();
removeToken
();
// 清空配置缓存
clearConfigCache
();
console
.
log
(
'退出'
);
console
.
log
(
'退出'
);
// 同步清空 qiankun 全局状态中的用户信息
// 同步清空 qiankun 全局状态中的用户信息
syncUserToQiankun
();
syncUserToQiankun
();
...
...
apps/frontend/venus-agentic/venus-agentic-base/src/utils/menu.ts
View file @
ffebac3
...
@@ -34,13 +34,19 @@ export function getFirstSubAppFirstMenuPath(): string {
...
@@ -34,13 +34,19 @@ export function getFirstSubAppFirstMenuPath(): string {
// 如果第一个菜单有子菜单,返回第一个子菜单的路径
// 如果第一个菜单有子菜单,返回第一个子菜单的路径
if
(
firstMenu
.
children
&&
firstMenu
.
children
.
length
>
0
)
{
if
(
firstMenu
.
children
&&
firstMenu
.
children
.
length
>
0
)
{
const
targetPath
=
firstMenu
.
children
[
0
].
path
;
const
targetPath
=
firstMenu
.
children
[
0
].
path
;
console
.
log
(
'[菜单工具] 默认路径:'
,
targetPath
,
'是否为微应用路由:'
,
!!
getMicroAppByPath
(
targetPath
));
// 异步检查是否为微应用路由(不阻塞返回)
getMicroAppByPath
(
targetPath
,
true
).
then
(
microApp
=>
{
console
.
log
(
'[菜单工具] 默认路径:'
,
targetPath
,
'是否为微应用路由:'
,
!!
microApp
);
});
return
targetPath
;
return
targetPath
;
}
}
// 如果没有子菜单,返回第一个菜单本身的路径
// 如果没有子菜单,返回第一个菜单本身的路径
const
targetPath
=
firstMenu
.
path
;
const
targetPath
=
firstMenu
.
path
;
console
.
log
(
'[菜单工具] 默认路径:'
,
targetPath
,
'是否为微应用路由:'
,
!!
getMicroAppByPath
(
targetPath
));
// 异步检查是否为微应用路由(不阻塞返回)
getMicroAppByPath
(
targetPath
,
true
).
then
(
microApp
=>
{
console
.
log
(
'[菜单工具] 默认路径:'
,
targetPath
,
'是否为微应用路由:'
,
!!
microApp
);
});
return
targetPath
;
return
targetPath
;
}
}
...
...
apps/frontend/venus-agentic/venus-agentic-base/src/views/Login.vue
View file @
ffebac3
...
@@ -20,8 +20,9 @@ const userStore = useUserStore();
...
@@ -20,8 +20,9 @@ const userStore = useUserStore();
* @param targetPath 目标路径
* @param targetPath 目标路径
*/
*/
const
navigateToMicroApp
=
async
(
targetPath
:
string
)
=>
{
const
navigateToMicroApp
=
async
(
targetPath
:
string
)
=>
{
// 检查是否是微应用路由
// 检查是否是微应用路由(等待配置加载完成)
const
isMicroAppRoute
=
!!
getMicroAppByPath
(
targetPath
);
const
microApp
=
await
getMicroAppByPath
(
targetPath
,
true
);
const
isMicroAppRoute
=
!!
microApp
;
if
(
isMicroAppRoute
)
{
if
(
isMicroAppRoute
)
{
// 如果是微应用路由,先跳转到主应用的布局路由,确保容器挂载
// 如果是微应用路由,先跳转到主应用的布局路由,确保容器挂载
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment