为客户和员工提供单独的 Angular 应用程序 [英] Separate Angular apps for customers and staff

查看:20
本文介绍了为客户和员工提供单独的 Angular 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不希望客户使用的 angular 应用包含员工使用的所有内容:

I don't want the angular app used by customers to include everything used by staff:

  • 会更大 - 员工相关代码比客户代码大 10 倍
  • 这是一个安全风险 - 我不希望客户推断我的系统在幕后做了什么(我想保护我的 IP)

所以我可能需要两款应用——一款供客户使用,一款供员工使用.也许三分之一用于共享代码.这是正确的方法吗?

So I probably need two apps - one for customers, and one for staff. Maybe a third for shared code. Is this the correct approach?

如果是这样,我发现的建议是弹出"并调整 webpack.但最新的角度不允许这样做.

If so, the advise I've found is to "eject" and tweak webpack. But the latest angular doesn't allow this.

那么对于最新的 angular,我如何在同一个项目中设置两个相关的应用程序,并使用第三个共享库?

So for the latest angular, how do I setup two related apps in the same project, with a third shared lib?

UPDATE 以避免下面评论中的参数

UPDATE to avoid the arguments in the comments below

我想要一个 git repo,我在 vscode 中工作.在内部,我有两个 Angular 应用(一个用于客户,一个用于员工)和第三个应用/项目/包/任何用于共享代码的应用.

I want a single git repo, which I work on in vscode. Inside I have two angular apps (one for customers and one for staff) and a third app/project/package/whatever for shared code.

仅仅限制对员工相关端点的访问是荒谬的——尽管客户因为不是员工而无法访问与员工相关的功能,他仍然可以推断我的系统的功能,因为他可以看到代码支持它.因此需要单独的应用程序.

Just restricting access to staff-related endpoints is nonsensical - although the customer can't access staff-related features because he is not a member of staff, he can still INFER my system's features because he can see the code that supports it. Thus the need for separate apps.

我的问题是如何使用最新的 angular 做到这一点,因为所有资源都适用于旧版本.

My question was how to do that with the latest angular, because all resources are for older versions.

推荐答案

您可以创建一个新的工作区,其中包含分离的项目

You can create a new workspace with separated projects inside

ng new appName --createApplication=false

此命令将创建空工作区.然后您可以创建两个独立的应用程序并在它们之间共享代码.

This command will create empty workspace. Then you can create two separated apps and share code between them.

ng g application customersAppng g application staffApp

现在您的工作区中将有 projects 文件夹,您可以单独运行应用程序.

Now you will have projects folder in your workspace and you can run the applications separately.

ng serve customersApp --port 4200ng serve staffApp --port 4201

你可以把共享的代码放到angular库中

You can put the shared code into angular library

ng g library sharedCode

它将添加到 tsconfig.json 的路径然后你就可以在你的应用程序中使用模块和其他导出的东西

It will add path to tsconfig.json Then you will be able to use modules and other exported stuff in your apps

您还可以查看:angular 6 - 最佳项目间共享通用代码的实践

共享代码在那里解释得很好.

The shared code is there explained well.

这篇关于为客户和员工提供单独的 Angular 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆