Git Product home page Git Product logo

Comments (6)

527395632 avatar 527395632 commented on June 19, 2024
    public static void RegisterOpenEvent(this RegistryKey source, string scheme, string appPath)
    {
        var index = scheme.IndexOf(":");
        if (index == 0) throw new ArgumentException("无效的'scheme'", "scheme");
        var key = index < 0 ? scheme : scheme.Substring(0, index);
        var rootPath = source.CreateSubKey(key);
        rootPath.SetValue(string.Empty, $"{ key }Protocol");
        rootPath.SetValue("URL Protocol", appPath);
        rootPath.CreateSubKey("DefaultIcon").SetValue(string.Empty, $"{ appPath },1");
        var command = rootPath.CreateSubKey("shell").CreateSubKey("open").CreateSubKey("command");
        command.SetValue(string.Empty, $"{ appPath } %1");
    }

    public static void UnRegisterOpenEvent(this RegistryKey source, string scheme)
    {
        var index = scheme.IndexOf(":");
        if (index == 0) throw new ArgumentException("无效的'scheme'", "scheme");
        var key = index < 0 ? scheme : scheme.Substring(0, index);
        source.DeleteSubKeyTree(key, false);
    }

from nanui.

andywu188 avatar andywu188 commented on June 19, 2024

大哥,你没理解问题含义呢,你的代码是“在注册表中注册URL Protocol协议”,而我说的问题是,如何在NanUI中,点击链接,并自动调用。这是两个问题,注册,根本不需要我自己写代码注册,因为一般客户端安装程序,本来就会自动注册,哪需要我自己注册呢?你注意看我上面说的一段话:“只要是系统中已安装的软件并支持web client app Protocol的软件,都能在NanUI调用”,问题是如何在NanUI调用

from nanui.

527395632 avatar 527395632 commented on June 19, 2024

自定义的URL Protocol需要在注册表中注册, 这个是肯定的。至于这个工作是由哪里来做, 这个可以视情况而定。既然NanUI没有实现, 那么我们自己实现下也可以, 或者在制作安装包的时候把这块注册表添加上也可以。调用可以直接用a标签的href写, 如href="abc://123"

from nanui.

andywu188 avatar andywu188 commented on June 19, 2024

还是没说到重点啊,HTML链接代码<a href="search://">打开APP</a>,不用说,谁都会写的,问题是,点击后,NanUI如何处理这个事件,如何调用URL协议

from nanui.

XuanchenLin avatar XuanchenLin commented on June 19, 2024

CEF 的模型中在很多个环节上都提供了 CefRequest 对象,例如 BeforeBrowse 事件、GetResourceRequestHandler事件等等,那么捕获到浏览器的 Request,其中包括了请求的 URL 也就包含了目标的 Scheme,根据目标 Scheme 那么就可以开发相应的功能逻辑,要么交给系统(正如楼主的需求一样),要么自行处理。

from nanui.

XuanchenLin avatar XuanchenLin commented on June 19, 2024

image

写了段代码说明一下。

from nanui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.