开发(Developing)
¥Developing
$ quasar dev -m capacitor -T [ios|android]
# ..or the longer form:
$ quasar dev --mode capacitor --target [ios|android]
它会打开 IDE(Android Studio / Xcode),然后你可以手动选择模拟器(或同时选择多个模拟器!)并在模拟器上安装开发应用。你还可以在真实的移动/平板设备上运行开发应用。
¥It will open the IDE (Android Studio / Xcode) and from there you can manually select the emulator (or multiple ones simultaneously!) and install the dev app on it/them. You can also run the dev app on a real mobile/tablet device.
警告
在 Android Studio 中,你将收到一条建议升级 Gradle 版本的消息。请勿升级 GRADLE,因为它会破坏 Capacitor 项目。其他任何请求的升级也相同。
¥In Android Studio, you will be greeted with a message recommending to upgrade the Gradle version. DO NOT UPGRADE GRADLE as it will break the Capacitor project. Same goes for any other requested upgrades.

如果你遇到任何 IDE 错误,请点击“文件”>“使缓存无效”,然后重新启动。
¥If you encounter any IDE errors then click on File > Invalidate caches and restart.

为了让你能够在设备模拟器上或直接在手机上进行开发(包含热模块重新加载),Quasar CLI 遵循以下步骤:
¥In order for you to be able to develop on a device emulator or directly on a phone (with Hot Module Reload included), Quasar CLI follows these steps:
检测你机器的外部 IP 地址。如果检测到多个这样的 IP,它会要求你选择一个。如果你使用手机进行开发,请选择可从手机/平板电脑 ping 通的机器 IP 地址。
¥Detects your machine’s external IP address. If there are multiple such IPs detected, then it asks you to choose one. If you’ll be using a mobile phone to develop then choose the IP address of your machine that’s pingable from the phone/tablet.
它会在你的机器上启动一个开发服务器。
¥It starts up a development server on your machine.
它告诉 Capacitor 使用之前检测到的 IP。这允许应用连接到开发服务器。
¥It tells Capacitor to use the IP previously detected. This allows the app to connect to the development server.
它使用 Capacitor CLI 来更新所有插件。
¥It uses the Capacitor CLI to update all of your plugins.
最后,它会打开你的原生 IDE。在此处运行你的应用,它将自动连接到开发服务器。
¥Finally, it opens your native IDE. Run your app here, and it will automatically connect to the dev server.
危险
如果在手机/平板电脑上进行开发,务必确保构建机器的外部 IP 地址能够通过手机/平板电脑访问,否则你将获得一个白屏的开发应用。还要检查你计算机的防火墙,以允许连接到开发所选的端口。
¥If developing on a mobile phone/tablet, it is very important that the external IP address of your build machine is accessible from the phone/tablet, otherwise you’ll get a development app with white screen only. Also check your machine’s firewall to allow connections to the development chosen port.
生产环境构建(Building for Production)
¥Building for Production
$ quasar build -m capacitor -T [ios|android]
# ..or the longer form:
$ quasar build --mode capacitor --target [ios|android]
这些命令解析并构建你的
/src
文件夹,然后覆盖/src-capacitor/www
,然后使用 Gradle/xcodebuild 生成最终的资源文件,这些文件将进入手机/平板电脑。¥These commands parse and build your
/src
folder then overwrite/src-capacitor/www
then use the Gradle/xcodebuild to generate the final assets that go into a phone/tablet.除非另有配置,否则构建的包将位于
/dist/capacitor
中。¥Built packages will be located in
/dist/capacitor
unless configured otherwise.如果你希望跳过 Gradle/xcodebuild 步骤,仅填充
/src-capacitor/www
文件夹:¥If you wish to skip the Gradle/xcodebuild step and only fill
/src-capacitor/www
folder:
$ quasar build -m capacitor -T [ios|android] --skip-pkg
如果你希望使用 IDE(Android Studio / Xcode)手动构建最终资源,而不是进行终端构建,那么:
¥Should you wish to manually build the final assets using the IDE (Android Studio / Xcode) instead of doing a terminal build, then:
$ quasar build -m capacitor -T [ios|android] --ide
警告
在 Android Studio 中,你将收到一条建议升级 Gradle 版本的消息。请勿升级 GRADLE,因为它会破坏 Capacitor 项目。其他任何请求的升级也相同。
¥In Android Studio, you will be greeted with a message recommending to upgrade the Gradle version. DO NOT UPGRADE GRADLE as it will break the Capacitor project. Same goes for any other requested upgrades.

如果你遇到任何 IDE 错误,请点击“文件”>“使缓存无效”,然后重新启动。
¥If you encounter any IDE errors then click on File > Invalidate caches and restart.

如果你想要一个启用了调试功能的正式版 UI 代码:
¥If you want a production build with debugging enabled for the UI code:
$ quasar build -m capacitor -T [ios|android] -d
# ..or the longer form
$ quasar build -m capacitor -T [ios|android] --debug