capacitor.config.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { CapacitorConfig } from '@capacitor/cli';
  2. // import { updateVersion } from './scripts/sync-version';
  3. // updateVersion()
  4. // 获取本地服务
  5. console.log("import.meta.env=", process.env.DAPP_BUILD)
  6. const config: CapacitorConfig = {
  7. appId: 'com.acc.app',
  8. appName: 'AngelTokens',
  9. webDir: 'dist',
  10. // 插件配置
  11. plugins: {
  12. CapacitorAssets: {
  13. iconBackgroundColor: '#ffffff' // 应用图标背景色
  14. },
  15. // 注意:原JSON中嵌套了重复的"plugins"键,已修正
  16. PushNotifications: {
  17. presentationOptions: ['badge', 'sound', 'alert']
  18. },
  19. CapacitorUpdater: {
  20. autoUpdate: false, // 自行控制
  21. statsUrl: '', // 统计上报: POST /api/stats 接收 JSON(内容是插件的事件日志),返回 200 即可。
  22. },
  23. LocalNotifications: {
  24. sound: "" // 为空:使用默认的系统通知声音。如果未提供,则 Android 系统将发出默认声音,iOS 系统则不发出声音。
  25. }
  26. },
  27. // iOS专属配置
  28. ios: {
  29. scheme: 'acc',
  30. scrollEnabled: true,
  31. },
  32. // Android专属配置
  33. android: {
  34. scheme: 'acc',
  35. allowMixedContent: true, // 允许混合HTTP/HTTPS内容
  36. useLegacyBridge: true, // 使用旧版桥接(兼容性)
  37. // 签名证书配置(建议通过环境变量注入敏感信息)
  38. buildOptions: {
  39. keystorePath: 'f62.keystore',
  40. keystoreAlias: 'f62', // // 生成时指定的别名
  41. keystorePassword: 'LkSvN1Ys', // 从环境变量读取
  42. keystoreAliasPassword: 'LkSvN1Ys'
  43. }
  44. }
  45. };
  46. // 开发服务器配置(热更新用)
  47. if (process.env.DAPP_BUILD != "1") {
  48. config.server = {
  49. url: 'http://192.168.0.59:5173',
  50. cleartext: true, // 允许HTTP明文通信(仅开发环境)
  51. allowNavigation: ['*'] // 允许任意URL导航
  52. }
  53. }
  54. export default config;