Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用http scheme替代local、embedded #15

Closed
wants to merge 1 commit into from
Closed

使用http scheme替代local、embedded #15

wants to merge 1 commit into from

Conversation

danel996
Copy link

@danel996 danel996 commented Feb 4, 2017

说明1: cef3官方文档强烈建议不要自定义scheme,最好是使用内置scheme,比如: http、https,因为自定义的scheme有些时候可能会收不到POST的数据以及其它问题!!!

    Request Handling -> Use the HTTP scheme instead of a custom scheme to avoid a range of potential issues.

说明2: 主要的改动:

        NanUI/Resource/LocalSchemeHandlerFactory.cs
        NanUI/Resource/LocalResourceHandler.cs
        NanUI/Resource/HtmlUILauncher.cs

用法:(参见Welcome/Program.cs的注释)
(1)注册资源
a、注册本地文件资源

        // 第1个参数指定使用http协议(schemeName)
        // 第2个参数指定网页存放的文件夹(等价于domainName)
        // 例如: http://www/index.html 等价于 ${当前工作路径}\www\index.html
        HtmlUILauncher.RegisterLocalScheme("http", "www");

b、注册程序集内嵌资源

        // 第1个参数指定使用http协议(schemeName)
        // 第2个参数指定网页存放的文件夹(等价于domainName)
        // 例如: http://www/index.html 等价于 ${程序集根目录}\www\index.html
        HtmlUILauncher.RegisterEmbeddedScheme(System.Reflection.Assembly.GetExecutingAssembly(), "http", "www");

(2)url格式
NanUI里一般都是从HtmlUIForm派生出一个Form来,在基类构造函数中指定url,比如Welcome/frmWelcome.cs

     public frmWelcome() 
               : base("http://www/index.html")     // 使用是本地资源或程序集内嵌资源,和web开发就比较类似
               //: base("embedded://www/index.html") // 不使用这种格式了!!!

@danel996
Copy link
Author

danel996 commented Feb 4, 2017

本地没有vs2015开发环境,之前创建了一个使用vs2008编译的NanUI分支(也给你发PR了 #14 ),参考vs2008的分支( #14 )改的,可能会有一点点语法错误吧。

@XuanchenLin
Copy link
Owner

使用了其他方法来实现这个目的。楼主提供的方法不全,用您提供的pull request那么如果同为http的其他在线或者离线资源将不能识别,所以本人修改了所有的SchemeHandlerFactory和ReourceHandler,在其中除了SchemeName之外还全程带上了DomainName,方便在hanlder内判断资源入口,保证了嵌入资源的有效使用,同时又不影响通过http来加载在线内容,详见Resource\EmbeddedResourceHanlder.cs和Resource\EmbeddedSchemeHanlderFactory.cs

@XuanchenLin XuanchenLin closed this Jul 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants