Skip to Content
微前端设计与实现
book

微前端设计与实现

by Luca Mezzalira
August 2022
Beginner to intermediate
270 pages
7h 38m
Chinese
Posts & Telecom Press
Content preview from 微前端设计与实现
微前端技术实现
107
// 前置代码
const SignIn = () => {
let history = useHistory();
const onSignIn = () => {
window.sessionStorage.setItem("token", token);
history.push("/shop");
}
// 后置代码
}
按照惯例,所有微前端都从
SessionStorage
中获取
token
,并通过它来使用该域的私有
API
。毋庸置疑
,需要经过用户身份认证后才允许显示的每个微前端,都应该验证
token
确保用户有权访问内容。在横向拆分的架构中,同一个页面上有多个微前端,微前端容器
需要认证用户,然后为授权用户加载页面的微前端,向未授权用户显示错误提示信息。在
纵向拆分的架构中,在渲染任何组件之前,每个微前端都应该确认
token
有效
,并确认用
户的角色(如果有的话)有权访问相应内容。
5.3.4
 目录微前端
目录域可能是所有微前端中最复杂和最大的一个微前端。这是用户访问网站的主需求,它
不仅要易用,还要能够提供用户所寻找的完整信息。
Maki
团队负责这个微前端
,其目标是
实现多个视图,以便用户可以通过目录找到可用内容,并查看每个产品的详细信息。将来,
该团队可能需要不断开发新的功能,比如分享买家拍摄的产品图片或添加评论和评分。
该团队将实现所有这些功能并以模块化的方式进行代码开发,以便将来可以轻松地将部分
域移交给另一个团队。强大的封装和稳定的模块化会让 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Python语言及其应用(第2版)

Python语言及其应用(第2版)

Bill Lubanovic

Publisher Resources

ISBN: 9787115595089