Durandal中用于不同类型用户的多个Shell(视图和视图模型)和路由器 [英] Multiple Shells (views and view models) and routers for different type of users in Durandal

查看:95
本文介绍了Durandal中用于不同类型用户的多个Shell(视图和视图模型)和路由器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我正在尝试构建一个具有两种不同类型用户(即客户和卖方)的应用。该应用程序的设计方式是,它们都将具有不同种类的导航栏,并可以通过路线访问不同种类的页面。因此,我试图了解实现这一目标的最佳方法是什么?我正在考虑以下解决方案之一:
1.在我的shell.html中使用compose绑定或区域,并通过具有容器并基于特定条件,将注入正确的特定视图(部分视图)并且默认的绑定上下文将是通用的shell.js。但是,导航栏和显示的每个导航面板均由具有

So I'm trying to build an app that has two different kind of users, namely customers and sellers. The app is designed in such a way that both of them will have different kind of navigation bars and access to different kind of pages via routes. As such, I'm trying to see what is the best way to achieve this? I'm thinking of either of the following solutions: 1. using compose binding or areas in my shell.html and by having a container and based on a certain condition, the correct specific view (partial view)will be injected and the default binding context will be a common shell.js. However, the nav bar and each navigation panel displayed is determined by the routes that have

nav:true

,卖方和客户的路线都将标为 nav:true 。如果使用这种方法,是否可以解决此限制?
2.使用组合绑定,但是有两个不同的视图和视图模型,我们将它们绑定到我们的shell.html和shell.js。换句话说,将有两个路由器。但是,我读过许多关于有两个路由器的帖子,显然不建议在一个应用程序中有多个主路由器。我是否有其他方法可以解决此问题?我曾考虑过拥有多个SPA,但由于这是一个移动应用程序,因此我认为效率不高。

and both seller and customer will have different routes that are marked nav:true. Is there a way to work around this limitation if we use this approach? 2. using compose binding but having two different views and viewmodels that we bind to our shell.html and shell.js. In other words, there will be two routers. However, I've read a number of posts about having two routers and apparently having multiple main routers in an app is not suggested. Is there another way I should approach this?I was having thinking of having multiple SPAs but I figure that would not be efficient since this is a mobile app. Any help or suggestion is greatly appreciated!

推荐答案

您可以简单地开发两个单独的SPA,但是让它们共享相同的代码库中的大部分内容! 。通过这种方法,除了您有责任对代码进行模块化以供重用之外,没有什么特别的事情。

You could simply develop two separate SPAs, but have them share much of the same codebase. With this approach, there's nothing special going on, other than your responsibility to modularize your code for reuse.

这种方法还可以消除在整个过程中合并大量逻辑的必要性,根据当前登录的用户修剪或扩充Web应用。

This approach would also eliminate the need to incorporate extensive logic throughout to curtail, trim, or augment the web app based on the user currently logged in.

这篇关于Durandal中用于不同类型用户的多个Shell(视图和视图模型)和路由器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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