完善购买和套餐功能
This commit is contained in:
@@ -231,6 +231,22 @@ export async function loadAndAddDynamicRoutes() {
|
||||
return routesLoadingPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新拉取菜单并重建动态路由。
|
||||
* 动态路由在构建时会把「未开通模块」的菜单注册为锁定占位页(views/locked),
|
||||
* 仅调用 menuStore.refreshMenus() 只更新菜单数据、不会重建路由,
|
||||
* 因此支付开通/套餐变更后必须调用本方法,才能让占位页切换为真实页面。
|
||||
*/
|
||||
export async function reloadMenusAndDynamicRoutes() {
|
||||
const { useMenuStore } = await import("@/stores/menu");
|
||||
const menuStore = useMenuStore();
|
||||
// 强制从接口拉取最新菜单(含 locked 标记),写入 store 与缓存
|
||||
await menuStore.refreshMenus();
|
||||
// 重置加载标志后重建路由表
|
||||
resetDynamicRoutes();
|
||||
await loadAndAddDynamicRoutes();
|
||||
}
|
||||
|
||||
// 核心修改:移除扁平化,直接使用嵌套菜单生成路由
|
||||
function addDynamicRoutes(menus) {
|
||||
if (!menus?.length) {
|
||||
|
||||
Reference in New Issue
Block a user