PHP short video source code, Vue recursive dynamic loading menu

Game programming 2022-05-14 14:41:24 阅读数:1,001

phpshortvideosourcecode

php Short video source ,vue Recursive dynamic loading menu

/** * Static routing lazy loading * @param view Format must be xxx/xxx Don't start with a slash * @returns */export const loadView = (view) => { return (resolve) => require([`@/views/${view}.vue`], resolve)}export function GetMenuData(menuRouters,data){ if(data=='' ||data==undefined || data.length==0 ){ return Message.success(' Menu data is empty ') } let menuList = JSON.parse(JSON.stringify(data)); // Deep copy // let menuRouters = [] // const menuRouters = Object.assign([], asyncRoutes) menuList.forEach((m, i) => { if (m.upid == '0') { // Outermost layer , Without parent let module = { path:m.path, children: [], component: m.component === '#' ? Layout : loadView(m.component), name: m.code, hidden: m.hiddenStatus === 0, // Status as 0 Hide redirect: m.redirect, meta: { id: m.id,title: m.metaTitle, icon: m.metaIcon}, } menuRouters.push(module); } }) function convertTree(routers) { // Recursively add children routers.forEach(r=>{ menuList.forEach((m,i)=>{ if(m.upid && m.upid == r.meta.id){ if(!r.children) {r.children=[]; }; // let key=m.url.lastIndexOf('/') // let fileName=m.url.slice(key); // Back end transmission /system/user I need this /system/user/user let menu={ path:m.path, name:m.code, children: [], hidden: m.hiddenStatus === 0, // Status as 0 Hide redirect: m.redirect, component: m.component === '#' ? Layout : loadView(m.component), meta:{id:m.id,title:m.metaTitle, icon: m.metaIcon} } r.children.push(menu) } }) if(r.children) convertTree(r.children) }) } convertTree(menuRouters); return menuRouters }const actions = { generateRoutes({ commit }, token) { return new Promise(resolve => { // adopt token Get the user menu from the back end , And add the global state GetCourseCategoryList(token).then(res => { const menuData = Object.assign([], res) const tempAsyncRoutes = Object.assign([], asyncRoutes) // alert("info: "+token) // const accessedRoutes = generaMenu(tempAsyncRoutes, menuData) const accessedRoutes = GetMenuData(tempAsyncRoutes,res) commit('SET_ROUTES', accessedRoutes) resolve(accessedRoutes) }).catch(error => { console.log(error) }) }) }}

That's all php Short video source ,vue Recursive dynamic loading menu , More content welcome to follow the article
author : Cloudleopard network technology

Game programming , A game development favorite ~

If the picture is not displayed for a long time , Please use Chrome Kernel browser .

版权声明:本文为[Game programming]所创,转载请带上原文链接,感谢。 https://qdmana.com/2022/134/202205141435170851.html