import usePermissionStore from "@/store/modules/permission"; //const usePermission = usePermissionStore(); const settingFirstPathStore = defineStore("first-path", { state: () => ({ path: "", }), actions: { getFistPath() { let accessRoutes = usePermissionStore().addRoutes; for (let index in accessRoutes) { let route = accessRoutes[index]; if (route.children != null && route.children && route.children.length) { route.children = this.getFistPath(route.children); } else { this.path = route.componentfullPath ? `/${route.componentfullPath.split("/index")[0]}` : ""; break; } } //return; // try { // accessRoutes.forEach((route) => { // //跳出条件 // if ( // route.children != null && // route.children && // route.children.length // ) { // route.children = this.getFistPath(route.children); // } else { // // this.path = `/${route.componentfullPath.split("/index")[0]}`; // this.path = `/system/user`; // console.log("this.path ", this.path); // console.log("route ", route); // throw new Error("结束循环"); //结束循环 // } // }); // } catch (e) { // console.log(e); // } }, }, }); export default settingFirstPathStore;