且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 ionic 作为桌面 Web 应用程序

更新时间:2022-01-08 04:16:05

为了进一步扩展已经说过的内容,Ionic 仅针对移动设备构建和测试.例如,Internet Explorer 没有经过测试,也没有正确处理 Ionic 中的许多功能.桌面浏览器确实与移动浏览器具有不同的功能.您会严重限制可以在桌面上使用您的应用程序的浏览器.

To expand a little bit on what has already been said, Ionic is is built and tested for mobile only. Internet Explorer for example is not tested and does not properly handle a number of the features in Ionic. Desktop browsers do have different features from their mobile browser counterparts. You would seriously limit the browsers that can use your application on a desktop.

最有可能的是,您应该为桌面和移动设备提供两个不同的应用程序.除非您有胆量或能力告诉您的用户他们必须使用 Chrome(或 Opera)来运行您的网站,否则您将需要两个独立的应用程序.您仍然可以将 Ionic 用于移动网站,但无法使用 Cordova 的完整平台集成(您将仅限于浏览器提供的本机 HTML API).您当然可以将大部分业务逻辑保留在两个应用程序之间共享的公共核心中.这将需要创建一个共享的角度模块.我在一个包含 Ionic 应用程序和普通 Angular 桌面应用程序(使用 Bootstrap)的项目中完成了这项工作.

Most likely, you should provide two different applications for desktop and mobile. Unless you have the guts or ability to tell your users that they must use Chrome (or Opera) to run your website, you'll want two separate applications. You could still use Ionic for a mobile website though, but without being able to use Cordova's full platform integration (you would be limited to the native HTML APIs provided by the browser). You could certainly retain much of your business logic in a common core that is shared between both applications. That would require creating a shared angular module(s). I have done this in a project with an Ionic app and a normal Angular desktop app (with Bootstrap).

有多种方法可以检测访问者是来自桌面设备还是移动设备.我不知道一种 100% 完美的方法,因为它们通常依赖于浏览器的用户代理字符串(并且可以被欺骗、更改等).请参阅 http://detectmobilebrowsers.com/ 了解如何在服务器或编程语言.

There are a number of ways to detect if a visitor is coming from a desktop or mobile device. I don't know of a method that is 100% perfect, because they usually rely on the browser's user agent string (and can be spoofed, changed, etc). See http://detectmobilebrowsers.com/ for some common scripts or examples how to implement mobile detection on a server or in a programming language.