feat: add manual and optional auto update in settings
This commit is contained in:
+9
-3
@@ -1,6 +1,12 @@
|
||||
import type { CapacitorConfig } from "@capacitor/cli";
|
||||
|
||||
const updateUrl = process.env.CAPACITOR_UPDATE_URL;
|
||||
/**
|
||||
* 热更新检查接口
|
||||
*
|
||||
* 默认指向生产,可用 CAPACITOR_UPDATE_URL 覆盖后指向本地服务调试
|
||||
* 更新时机由应用内控制(设置页手动检查或用户开启自动检查),插件本身不主动拉取
|
||||
*/
|
||||
const updateUrl = process.env.CAPACITOR_UPDATE_URL ?? "https://api.imyeyu.com/app/update/check";
|
||||
if (updateUrl && !updateUrl.startsWith("https://")) {
|
||||
throw new Error("热更新接口必须使用 HTTPS");
|
||||
}
|
||||
@@ -11,8 +17,8 @@ const config: CapacitorConfig = {
|
||||
webDir: "dist",
|
||||
plugins: {
|
||||
CapacitorUpdater: {
|
||||
autoUpdate: updateUrl ? "atBackground" : false,
|
||||
...(updateUrl ? { updateUrl } : {}),
|
||||
autoUpdate: false,
|
||||
updateUrl,
|
||||
statsUrl: ""
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user