如何在现代和经典应用程序ExtJs之间自动切换

如何在现代和经典应用程序ExtJs之间自动切换,extjs,extjs6-classic,extjs6-modern,Extjs,Extjs6 Classic,Extjs6 Modern,我有一个方法,点击按钮后切换到现代版本: Ext.beforeLoad = function (tags) { var s = location.search, // the query string (ex "?foo=1&bar") profile; if (s.match(/\bclassic\b/)) { profile = 'classic'; } else i

我有一个方法,点击按钮后切换到现代版本:

 Ext.beforeLoad = function (tags) {
        var s = location.search,  // the query string (ex "?foo=1&bar")
            profile;

        if (s.match(/\bclassic\b/)) {
            profile = 'classic';
        }
        else if (s.match(/\bmodern\b/)) {
            profile = 'modern';
        }

        else {               
            profile = tags.phone ? 'modern' : 'classic';
        }

        Ext.manifest = profile; // this name must match a build profile name

    };
该代码在加载页面之前设置配置文件。我使用以下方法添加参数:

onSwitchToClassicConfirmed: function (choice) {
    if (choice === 'yes') {
        var s = location.search;

        // Strip "?modern" or "&modern" with optionally more "&foo" tokens following
        // and ensure we don't start with "?".
        s = s.replace(/(^\?|&)modern($|&)/, '').replace(/^\?/, '');

        // Add "?classic&" before the remaining tokens and strip & if there are none.
        location.search = ('?classic&' + s).replace(/&$/, '');
    }
}
但如果设备是手机或平板电脑,我想在现代和经典屏幕之间自动切换。

查看属性,它包含当前设备的信息。
文档中的描述:

当前设备的常规类型

可能值:

  • 电话
  • 平板电脑
  • 桌面
根据这些信息,您可以设置配置文件

var profile = Ext.os.deviceType === "Phone" ? "modern" : "classic";