迪朗达尔和MVC4地区多个水疗 [英] Durandal and MVC4 Areas for multiple SPAs

查看:270
本文介绍了迪朗达尔和MVC4地区多个水疗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有地区互联网应用mvc4,为我的组织重新present一个水疗中心,并通过每个区域的管理的NuGet包我安装了迪朗达尔1.2.0,迪朗达尔转换1.2.0和迪朗达尔路由器1.2.0。我组织的文件夹和退出从迪朗达尔的文件夹应用程序的意见和的ViewModels,并把新的观点文件夹mvc4区的意见,例如:

I have a internet application mvc4 with areas, for my organization each area represent a SPA and through "Manage NuGet Package" I installed "Durandal 1.2.0", "Durandal Transitions 1.2.0" and "Durandal Router 1.2.0". I organized the folders and quit the "views" and "viewmodels" from folder "App" of Durandal and put the new views in folder "VIews" of mvc4 area for example:

领域 - > NewArea - >查看 - > ControllerFolder - >视图 - > shell.html

Areas-->NewArea-->Views-->ControllerFolder-->views-->shell.html

然后我把'的ViewModels中的脚本文件夹,例如:

Then I put the '"viewmodels" in "Script" folder for example:

脚本 - > NewArea - > ControllerFolder - >的ViewModels - > shell.js

Scripts-->NewArea-->ControllerFolder-->viewmodels-->shell.js

脚本 - > NewArea - > ControllerFolder - > main.js

Scripts-->NewArea-->ControllerFolder-->main.js

然后,我改变路径,迪朗达尔的JS,例如在main.js:

Then I changed paths for JS of durandal, for example in main.js:

define(['../../../App/durandal/app',
    '../../../App/durandal/viewLocator',
    '../../../App/durandal/system',
    '../../../App/durandal/plugins/router',
    '../../../App/services/logger'],

和我换到下一行main.js:

And I changed main.js in the next line:

viewLocator.useConvention('viewmodels', '../Areas/NewArea/Views/ControllerFolder/views');

但由于下一行的定义调用不同的时间模块viewLocator和改写useConvention使用默认值的配置文件夹的该配置失败:

But that configuration of folders fails because the next line calls various times the module "viewLocator" in its definition and rewrite the configuration of "useConvention" with default value:

app.setRoot('viewmodels/shell', 'entrance');

这行为,只有当文件夹意见和的ViewModels不属于迪朗达尔的应用程序文件夹中呆发生。

That behavior only happen when the folders "views" and "viewmodels" don't stay under "App" folder of "Durandal".

请帮帮我,怎么有各种各样的水疗中心在同一个项目?

Please help me, how to have various SPAs in the same project?

推荐答案

您可能要考虑部署策略。例如,如果需要,以优化此应用,无论是水疗将在相同的文件结束。然而,而不是应用程序文件夹下有他们两个,你可以单独的文件夹,并为每个SPA它自己的main.js文件。

You might want to consider your deployment strategy. For example, if you need to optimize this app, both SPAs will end up in the same file. However, instead of having them both under the app folder, you can make separate folders, and give each SPA it's own main.js file.

在更高级的方案,您可以创建加载一种或另一种的温泉的引导程序应用程序。引导程序将包含code是常见的两种温泉。但每个SPA(和引导程序)可以独立优化。

In more advanced scenarios, you may create a "bootstrapper" app that loads one or another of the SPAs. The bootstrapper would contain code that is common to both SPAs. But each SPA (and the bootstrapper) can be optimized independently.

有多种选择。主要是考虑你的最终部署策略,这将有助于引导你在这里。

There are many options. Mainly, consider your final deployment strategy and that will help guide you here.

此外,你有上面的问题可能涉及到的事实标准约定可能不会在你的安装工作,你就需要重写某些功能与自己的映射。

Also, the issue you have above is probably related to the fact that the standard conventions may not work in your setup, and you would need to override some functions with your own mapping.

这篇关于迪朗达尔和MVC4地区多个水疗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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