当前位置: 首页 > news >正文

徐州市中心做网站的公司招聘seo怎么弄

徐州市中心做网站的公司招聘,seo怎么弄,《网页设计与网站建设》A卷答案,网页游戏排行榜单传奇1.动态获取权限并根据获取权限转换成相对应的router 根据请求获取菜单数据,对菜单数据进行转换,分别进行下面几步: /*** 组件地址前加斜杠处理*/ export function addSlashToRouteComponent(routeList: AppRouteRecordRaw[]) {routeList.fo…

1.动态获取权限并根据获取权限转换成相对应的router

根据请求获取菜单数据,对菜单数据进行转换,分别进行下面几步:

/*** 组件地址前加斜杠处理*/
export function addSlashToRouteComponent(routeList: AppRouteRecordRaw[]) {routeList.forEach((route) => {const component = route.component as string;if (component) {const layoutFound = LayoutMap.get(component);if (!layoutFound) {route.component = component.startsWith("/") ? component : `/${component}`;}}route.children && addSlashToRouteComponent(route.children);});return routeList;
}

利用import函数+通配符,引入匹配的所有vue页面,如下:

const LayoutMap = new Map<string, () => Promise<typeof import("*.vue")>>();

以及const dynamicViewsModules = import.meta.glob("../../views/**/*.{vue,tsx}");

该map会生成一个以页面路径为key的,带有@import动态引入的方法为值的对象,这是可以通过处理key字符串,通过获取的菜单列表匹配对应的path,最终的component 就等于dynamicViewsModules[path]

function dynamicImport(dynamicViewsModules: Record<string, () => Promise<Recordable>>, component: string) {const keys = Object.keys(dynamicViewsModules);const matchKeys = keys.filter((key) => {const k = key.replace("../../views", "");const startFlag = component.startsWith("/");const endFlag = component.endsWith(".vue") || component.endsWith(".tsx");const startIndex = startFlag ? 0 : 1;const lastIndex = endFlag ? k.length : k.lastIndexOf(".");return k.substring(startIndex, lastIndex) === component;});if (matchKeys?.length === 1) {const matchKey = matchKeys[0];return dynamicViewsModules[matchKey];} else if (matchKeys?.length > 1) {console.log("Please do not create `.vue` and `.TSX` files with the same file name in the same hierarchical directory under the views folder. This will cause dynamic introduction failure");return;}
}

处理后最终返回的数据就是生成router树状结构 

2.动态添加路由addRoute

const menuRecordRoutes: RouteRecordRaw[] = Object.entries(menuRoutes).map(([, config]) => config).sort((a: any, b: any) => a.order - b.order) as RouteRecordRaw[];
menuRecordRoutes.forEach((route) => {router.addRoute(route);});

这里有个值得注意的地方如果是该菜单列表下有多个子菜单需要将子菜单也添加进去,如:

menuRecordRoutes.forEach((route) => {router.addRoute(route);if (route?.children?.length) {route.children.forEach((child) => {child.name = route.name?.toString() + "-" + child.name?.toString();if (route.name) {router.addRoute(route.name, child);}});}});

上图中后面一个router.addRoute是针对每个子菜单进行router添加,并且这里还有一个坑:

如果不同的菜单下的子菜单的name属性是一样的话 这里可能会把前面一个添加的子菜单给覆盖了,因为router中的name 属性是唯一的,所以这里对子菜单的name做了一个拼接:将父菜单名称和子菜单名称拼接到一起作为子菜单的新名称。另外这个name属性非常重要,如果name属性中含有特殊符号(如:name=detail@id),页面中如果使用了类似这样的页面跳转:router.push({ name: "detail", params: { id: row.id } }); 则会导致路由不匹配的问题

3.自定义指令控制按钮显隐 

//main.ts中引用
const app = createApp(App);
// 全局注册 自定义指令(directive)
setupDirective(app);
import type { App } from "vue";import { hasPerm } from "./permission";// 全局注册 directive
export function setupDirective(app: App<Element>) {// 使 v-hasPerm 在所有组件中都可用app.directive("hasPerm", hasPerm);
}
//自定义指令的自定义方法
export const hasPerm: Directive = {mounted(el: HTMLElement, binding: DirectiveBinding) {// 「超级管理员」拥有所有的按钮权限const { authList } = useUserStoreHook();const { value } = binding;let result = false;if (authList.length && value) {if (Array.isArray(value)) {result = value.every((ele) => authList.includes(ele));} else {result = authList.includes(value);}}if (!result) {el.parentNode && el.parentNode.removeChild(el);}return result;},
};

页面中使用

<el-button v-hasPerm="['xxx']" :icon="Delete" size="small" text type="primary">删 除</el-button>

至此,动态菜单和按钮权限功能完成 

http://www.tj-hxxt.cn/news/85441.html

相关文章:

  • 现在建站好么seo排名点击软件推荐
  • 公司网站建设如何做账seo 网站推广
  • 做平面设计常用的网站英文网站seo
  • 黄页88怎么注销seo指搜索引擎
  • 做地方服务性网站百度seo外链推广教程
  • 网站开发细节网页制作软件手机版
  • 网站建设方案书ppt手机网页链接制作
  • 网站首页tdk怎么做软文广告文案案例
  • 学院网站设计案例百度竞价排名怎么做
  • 做货代还有什么网站可以加人上海网络推广培训学校
  • 西安公司最新招聘信息重庆seo排
  • 免费免费网站模板下载网站重庆自动seo
  • 网站开发是用模版还是纯手打怎么做关键词优化排名
  • 个人网站制作wordpress网站设计与开发
  • 农村自建房设计网站做seo教程
  • 国外网站dns改成什么快济南seo全网营销
  • wordpress采集mp4seo优化推广工程师招聘
  • 免费的网站管理系统百度校招
  • 郑州网站制作公司汉狮中山seo排名
  • 重庆做网站开发的公司互联网广告推广
  • 近日发生的重大新闻seo01网站
  • 平面设计师必看的网站今天上海最新新闻事件
  • 手机网站建设怎么样网络广告创意
  • 网站开发w亿玛酷1专注大连seo优化
  • 注册网站好的平台东莞seo关键词排名优化排名
  • wordpress 悬浮通知seo小白入门
  • 一般做网站哪家好百度有哪些产品
  • 怎么给甲方做网站备案汕头seo收费
  • 网站优化软件下载在线crm网站建站
  • 免费模板的软件seo专业培训seo专业培训